1 WARNING: Run the following script before configure:
9 Vsevolod Volkov <vvv@mutt.org.ua>
12 diff -udprP mutt-1.5.15.orig/ChangeLog.nntp mutt-1.5.15/ChangeLog.nntp
13 --- mutt-1.5.15.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14 +++ mutt-1.5.15/ChangeLog.nntp 2007-04-11 17:33:57.000000000 +0300
16 +* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
17 +- fixed posting error if $smtp_url is set
18 +- added support of print-style sequence %R (x-comment-to)
20 +* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
22 +- nntp://... url changed to news://...
23 +- added indicator of fetching descriptions progress
25 +* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
28 +* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
31 +* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
33 +- fixed reading empty .newsrc
35 +* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
38 +* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
41 +* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
44 +* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
47 +* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
49 +- function mutt_update_list_file() moved to newsrc.c and changed algorithm
51 +* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
52 +- fixed error in nntp_logout_all()
54 +* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
55 +- fixed debug output in mutt_newsrc_update()
56 +- added optional support of LISTGROUP command
57 +- fixed typo in nntp_parse_xref()
59 +* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
62 +* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
65 +* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
68 +* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
70 +- added space after newsgroup name in .newsrc file
72 +* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
73 +- nntp patch: fixed SIGSEGV when posting article
75 +* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
78 +* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
80 +- replace safe_free calls by the FREE macro
82 +* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
84 +- nntp authentication can be passed after any command
86 +* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
89 +* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
92 +* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
94 +- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
95 + <reconstruct-thread> functions
96 +- fixed message about nntp reconnect
97 +- fixed <attach-news-message> function using browser
98 +- added support of Followup-To: poster
99 +- added %n (new articles) in group_index_format
100 +- posting articles without inews by default
102 +* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
105 +* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
108 +* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
110 +- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
111 +- added default content disposition
113 +* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
116 +* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
117 +- update to 1.3.23.2
118 +- fixed segfault if mutt_conn_find() returns null
120 +* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
121 +- update to 1.3.23.1
122 +- added support of LISTGROUP command
123 +- added support for servers with broken overview
124 +- disabled <flag-message> function on news server
125 +- fixed error storing bad authentication information
127 +* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
129 +- fixed typo in buffy.c
130 +- added substitution of %s parameter in $inews variable
132 +* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
133 +- update to 1.3.22.1
136 +* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
139 +* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
141 +- removed 'server-hook', use 'account-hook' instead
142 +- fixed error opening NNTP server without newsgroup using -f option
144 +* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
147 +* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
149 +- fixed typo in nntp_attempt_features()
150 +- changed algorithm of XGTITLE command testing
151 +- disabled writing of NNTP password in debug file
152 +- fixed reading and writing of long newsrc lines
153 +- changed checking of last line while reading lines from server
154 +- fixed possible buffer overrun in nntp_parse_newsrc_line()
155 +- removed checking of XHDR command
156 +- compare NNTP return codes without trailing space
158 +* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
160 +- support for 'LIST NEWSGROUPS' command to read descriptions
162 +* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
165 +* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
168 +* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
170 +- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
172 +* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
175 +* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
176 +- Fixed problem if last article in group is deleted
178 +* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
179 +- Fixed checking of XGTITLE command on some servers
181 +* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
182 +- Added \r in AUTHINFO commands
184 +* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
187 +* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
189 +- fixed error opening newsgroup from mutt started with -g or -G
191 +* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
193 +- hotkey 'G' (get-message) replaced with '^G'
195 +* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
197 +- changed delay displaying error messages from 1 to 2 seconds
198 +- fixed error compiling with nntp and without imap
200 +* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
201 +- fixed catchup in index
202 +- fixed nntp_open_mailbox()
204 +* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
205 +- functions <edit> and <delete-entry> disabled
206 +- format of news mailbox names changed to url form
207 +- option nntp_attempts removed
208 +- option reconnect_news renamed to nntp_reconnect
209 +- default value of nntp_poll changed from 30 to 60
210 +- error handling improved
212 +* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
214 +- new option show_only_unread
215 +- add newsgroup completion
217 +* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
220 +* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
223 +* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
225 +- authentication code update
226 +- fix for changing to newsgroup from mailbox with read messages
227 +- socket code optimization
229 +* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
232 +* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
233 +- don't substitute current newsgroup with deleted new messages
235 +* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
237 +- fix for substitution of newsgroup after reconnection
238 +- fix for loading newsgroups with very long names
239 +- fix for loading more than 32768 newsgroups
241 +* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
244 +* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
247 +* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
250 +* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
253 +* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
256 +* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
259 +* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
260 +- add substitution of newsgroup with new messages by default
262 +* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
263 +- add attach message from newsgroup
264 +- add one-line help in newsreader mode
265 +- disable 'change-dir' command in newsgroups browser
268 +* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
269 +- get default newsserver name from file /etc/nntpserver
270 +- use case insensitive server names
271 +- add print-style sequence %s to $newsrc
274 +* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
275 +- remove 'X-FTN-Origin' header processing
277 +* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
281 +* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
282 +- fix mutt_select_newsserver()
283 +- remove 'toggle-mode' function
284 +- add 'change-newsgroup' function
286 +* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
289 +* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
290 +- fix error 'bounce' function after 'post'
291 +- add 'forward to newsgroup' function
293 +* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
294 +- 'forward' function works in newsreader mode
295 +- add 'post' and 'followup' functions to pager and attachment menu
296 +- fix active descriptions and allowed flag reload
298 +* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
300 +- remove deleted newsgroups from list
302 +* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
303 +- update .newsrc in browser
305 +* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
306 +- reload .newsrc if externally modified
307 +- fix active cache update
309 +* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
312 +* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
313 +- patch *.update_list_file is not required
314 +- count lines when loading descriptions
315 +- remove cache of unsubscribed newsgroups
317 +* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
318 +- load list of newsgroups from cache faster
320 +* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
323 +* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
324 +- fix unread messages in browser
325 +- fix newsrc_gen_entries()
327 +* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
328 +- fix mutt_newsgroup_stat()
329 +- fix nntp_delete_cache()
330 +- fix nntp_get_status()
331 +- fix check_children()
332 +- fix nntp_fetch_headers()
334 +* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
337 +* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
338 +- fix updating new messages in cache
340 +* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
341 +- change default cache filenames
342 +- fix updating new messages in cache
344 +* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
345 +- fix segmentation fault in news groups browser
347 +* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
350 +* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
353 +* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
354 +- add X-Comment-To editing
355 +- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
356 +- add variables $ask_followup_to and $ask_x_comment_to
358 +* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
360 diff -udprP mutt-1.5.15.orig/OPS mutt-1.5.15/OPS
361 --- mutt-1.5.15.orig/OPS 2007-04-02 00:58:55.000000000 +0300
362 +++ mutt-1.5.15/OPS 2007-04-11 17:25:15.000000000 +0300
363 @@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
364 OP_BROWSER_NEW_FILE "select a new file in this directory"
365 OP_BROWSER_VIEW_FILE "view file"
366 OP_BROWSER_TELL "display the currently selected file's name"
367 -OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
368 -OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
369 +OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
370 +OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
371 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
372 OP_BUFFY_LIST "list mailboxes with new mail"
373 +OP_CATCHUP "mark all articles in newsgroup as read"
374 OP_CHANGE_DIRECTORY "change directories"
375 OP_CHECK_NEW "check mailboxes for new mail"
376 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
377 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
378 +OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message"
379 OP_COMPOSE_EDIT_BCC "edit the BCC list"
380 OP_COMPOSE_EDIT_CC "edit the CC list"
381 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
382 @@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
383 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
384 OP_COMPOSE_EDIT_MESSAGE "edit the message"
385 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
386 +OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
387 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
388 +OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
389 +OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
390 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
391 OP_COMPOSE_EDIT_TO "edit the TO list"
392 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
393 @@ -85,8 +90,13 @@ OP_EXIT "exit this menu"
394 OP_FILTER "filter attachment through a shell command"
395 OP_FIRST_ENTRY "move to the first entry"
396 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
397 +OP_FOLLOWUP "followup to newsgroup"
398 +OP_FORWARD_TO_GROUP "forward to newsgroup"
399 OP_FORWARD_MESSAGE "forward a message with comments"
400 OP_GENERIC_SELECT_ENTRY "select the current entry"
401 +OP_GET_CHILDREN "get all children of the current message"
402 +OP_GET_MESSAGE "get message with Message-Id"
403 +OP_GET_PARENT "get parent of the current message"
404 OP_GROUP_REPLY "reply to all recipients"
405 OP_HALF_DOWN "scroll down 1/2 page"
406 OP_HALF_UP "scroll up 1/2 page"
407 @@ -94,11 +104,14 @@ OP_HELP "this screen"
408 OP_JUMP "jump to an index number"
409 OP_LAST_ENTRY "move to the last entry"
410 OP_LIST_REPLY "reply to specified mailing list"
411 +OP_LOAD_ACTIVE "load active file from NNTP server"
412 OP_MACRO "execute a macro"
413 OP_MAIL "compose a new mail message"
414 OP_MAIN_BREAK_THREAD "break the thread in two"
415 OP_MAIN_CHANGE_FOLDER "open a different folder"
416 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
417 +OP_MAIN_CHANGE_GROUP "open a different newsgroup"
418 +OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
419 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
420 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
421 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
422 @@ -136,6 +149,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
423 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
424 OP_PAGER_TOP "jump to the top of the message"
425 OP_PIPE "pipe message/attachment to a shell command"
426 +OP_POST "post message to newsgroup"
427 OP_PREV_ENTRY "move to the previous entry"
428 OP_PREV_LINE "scroll up one line"
429 OP_PREV_PAGE "move to the previous page"
430 @@ -144,6 +158,7 @@ OP_QUERY "query external program for add
431 OP_QUERY_APPEND "append new query results to current results"
432 OP_QUIT "save changes to mailbox and quit"
433 OP_RECALL_MESSAGE "recall a postponed message"
434 +OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
435 OP_REDRAW "clear and redraw the screen"
436 OP_REFORMAT_WINCH "{internal}"
437 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
438 @@ -158,18 +173,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
439 OP_SHELL_ESCAPE "invoke a command in a subshell"
440 OP_SORT "sort messages"
441 OP_SORT_REVERSE "sort messages in reverse order"
442 +OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
443 OP_TAG "tag the current entry"
444 OP_TAG_PREFIX "apply next function to tagged messages"
445 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
446 OP_TAG_SUBTHREAD "tag the current subthread"
447 OP_TAG_THREAD "tag the current thread"
448 OP_TOGGLE_NEW "toggle a message's 'new' flag"
449 +OP_TOGGLE_READ "toggle view of read messages"
450 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
451 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
452 OP_TOP_PAGE "move to the top of the page"
453 +OP_UNCATCHUP "mark all articles in newsgroup as unread"
454 OP_UNDELETE "undelete the current entry"
455 OP_UNDELETE_THREAD "undelete all messages in thread"
456 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
457 +OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
458 OP_VERSION "show the Mutt version number and date"
459 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
460 OP_VIEW_ATTACHMENTS "show MIME attachments"
461 diff -udprP mutt-1.5.15.orig/PATCHES mutt-1.5.15/PATCHES
462 --- mutt-1.5.15.orig/PATCHES 2007-03-15 17:49:37.000000000 +0200
463 +++ mutt-1.5.15/PATCHES 2007-04-11 17:25:15.000000000 +0300
466 diff -udprP mutt-1.5.15.orig/account.c mutt-1.5.15/account.c
467 --- mutt-1.5.15.orig/account.c 2007-04-02 00:58:55.000000000 +0300
468 +++ mutt-1.5.15/account.c 2007-04-11 17:25:15.000000000 +0300
469 @@ -54,6 +54,11 @@ int mutt_account_match (const ACCOUNT* a
474 + if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
478 if (a1->flags & a2->flags & M_ACCT_USER)
479 return (!strcmp (a1->user, a2->user));
480 if (a1->flags & M_ACCT_USER)
481 @@ -133,6 +138,16 @@ void mutt_account_tourl (ACCOUNT* accoun
486 + if (account->type == M_ACCT_TYPE_NNTP)
488 + if (account->flags & M_ACCT_SSL)
489 + url->scheme = U_NNTPS;
491 + url->scheme = U_NNTP;
495 url->host = account->host;
496 if (account->flags & M_ACCT_PORT)
497 url->port = account->port;
498 @@ -158,6 +173,10 @@ int mutt_account_getuser (ACCOUNT* accou
499 else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
500 strfcpy (account->user, PopUser, sizeof (account->user));
503 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
504 + strfcpy (account->user, NntpUser, sizeof (account->user));
506 /* prompt (defaults to unix username), copy into account->user */
509 @@ -214,6 +233,10 @@ int mutt_account_getpass (ACCOUNT* accou
510 else if ((account->type == M_ACCT_TYPE_POP) && PopPass)
511 strfcpy (account->pass, PopPass, sizeof (account->pass));
514 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
515 + strfcpy (account->pass, NntpPass, sizeof (account->pass));
519 snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
520 diff -udprP mutt-1.5.15.orig/account.h mutt-1.5.15/account.h
521 --- mutt-1.5.15.orig/account.h 2007-04-02 00:58:55.000000000 +0300
522 +++ mutt-1.5.15/account.h 2007-04-11 17:25:15.000000000 +0300
523 @@ -29,7 +29,8 @@ enum
524 M_ACCT_TYPE_NONE = 0,
533 diff -udprP mutt-1.5.15.orig/attach.h mutt-1.5.15/attach.h
534 --- mutt-1.5.15.orig/attach.h 2007-04-02 00:58:55.000000000 +0300
535 +++ mutt-1.5.15/attach.h 2007-04-11 17:25:15.000000000 +0300
536 @@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f
538 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
539 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
540 -void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
541 +void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
542 void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
544 #endif /* _ATTACH_H_ */
545 diff -udprP mutt-1.5.15.orig/browser.c mutt-1.5.15/browser.c
546 --- mutt-1.5.15.orig/browser.c 2007-04-03 07:57:21.000000000 +0300
547 +++ mutt-1.5.15/browser.c 2007-04-11 17:25:15.000000000 +0300
558 @@ -49,6 +52,19 @@ static struct mapping_t FolderHelp[] = {
563 +static struct mapping_t FolderNewsHelp[] = {
564 + { N_("Exit"), OP_EXIT },
565 + { N_("List"), OP_TOGGLE_MAILBOXES },
566 + { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
567 + { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
568 + { N_("Catchup"), OP_CATCHUP },
569 + { N_("Mask"), OP_ENTER_MASK },
570 + { N_("Help"), OP_HELP },
575 typedef struct folder_t
577 struct folder_file *ff;
578 @@ -114,9 +130,17 @@ static void browser_sort (struct browser
583 + if (option (OPTNEWS))
586 f = browser_compare_date;
590 + if (option (OPTNEWS))
593 f = browser_compare_size;
596 @@ -306,8 +330,106 @@ folder_format_str (char *dest, size_t de
602 +newsgroup_format_str (char *dest, size_t destlen, char op, const char *src,
603 + const char *fmt, const char *ifstring, const char *elsestring,
604 + unsigned long data, format_flag flags)
606 + char fn[SHORT_STRING], tmp[SHORT_STRING];
607 + FOLDER *folder = (FOLDER *) data;
612 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
613 + snprintf (dest, destlen, tmp, folder->num + 1);
617 + strncpy (fn, folder->ff->name, sizeof(fn) - 1);
618 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
619 + snprintf (dest, destlen, tmp, fn);
623 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
624 + if (folder->ff->nd->subscribed)
625 + snprintf (dest, destlen, tmp, ' ');
627 + snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
631 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
632 + if (folder->ff->nd->deleted)
633 + snprintf (dest, destlen, tmp, 'D');
635 + snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
639 + if (flags & M_FORMAT_OPTIONAL)
641 + if (folder->ff->nd->unread != 0)
642 + mutt_FormatString (dest, destlen, ifstring, newsgroup_format_str,
645 + mutt_FormatString (dest, destlen, elsestring, newsgroup_format_str,
648 + else if (Context && Context->data == folder->ff->nd)
650 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
651 + snprintf (dest, destlen, tmp, Context->unread);
655 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
656 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
661 + if (Context && Context->data == folder->ff->nd)
663 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
664 + snprintf (dest, destlen, tmp, Context->new);
666 + else if (option (OPTMARKOLD) &&
667 + folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
668 + folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
670 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
671 + snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
675 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
676 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
681 + if (folder->ff->nd->desc != NULL)
683 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
684 + snprintf (dest, destlen, tmp, folder->ff->nd->desc);
688 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
689 + snprintf (dest, destlen, tmp, "");
695 +#endif /* USE_NNTP */
697 static void add_folder (MUTTMENU *m, struct browser_state *state,
698 - const char *name, const struct stat *s, int new)
699 + const char *name, const struct stat *s,
700 + void *data, int new)
702 if (state->entrylen == state->entrymax)
704 @@ -336,6 +458,10 @@ static void add_folder (MUTTMENU *m, str
706 (state->entry)[state->entrylen].imap = 0;
709 + if (option (OPTNEWS))
710 + (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
715 @@ -351,9 +477,35 @@ static void init_state (struct browser_s
716 menu->data = state->entry;
719 +/* get list of all files/newsgroups with mask */
720 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
721 char *d, const char *prefix)
724 + if (option (OPTNEWS))
728 + NNTP_SERVER *news = CurrentNewsSrv;
730 +/* mutt_buffy_check (0); */
731 + init_state (state, menu);
733 + for (tmp = news->list; tmp; tmp = tmp->next)
735 + if (!(data = (NNTP_DATA *)tmp->data))
737 + if (prefix && *prefix && strncmp (prefix, data->group,
738 + strlen (prefix)) != 0)
740 + if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
742 + add_folder (menu, state, data->group, NULL, data, data->new);
746 +#endif /* USE_NNTP */
751 @@ -414,17 +566,40 @@ static int examine_directory (MUTTMENU *
753 while (tmp && mutt_strcmp (buffer, tmp->path))
755 - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
756 + add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
761 browser_sort (state);
765 +/* get list of mailboxes/subscribed newsgroups */
766 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
769 char buffer[LONG_STRING];
772 + if (option (OPTNEWS))
776 + NNTP_SERVER *news = CurrentNewsSrv;
778 +/* mutt_buffy_check (0); */
779 + init_state (state, menu);
781 + for (tmp = news->list; tmp; tmp = tmp->next)
783 + if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
784 + (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
785 + add_folder (menu, state, data->group, NULL, data, data->new);
791 BUFFY *tmp = Incoming;
793 struct mailbox_state mbox;
794 @@ -442,14 +617,21 @@ static int examine_mailboxes (MUTTMENU *
795 if (mx_is_imap (tmp->path))
797 imap_mailbox_state (tmp->path, &mbox);
798 - add_folder (menu, state, tmp->path, NULL, mbox.new);
799 + add_folder (menu, state, tmp->path, NULL, NULL, mbox.new);
804 if (mx_is_pop (tmp->path))
806 - add_folder (menu, state, tmp->path, NULL, tmp->new);
807 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
812 + if (mx_is_nntp (tmp->path))
814 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
818 @@ -463,15 +645,20 @@ static int examine_mailboxes (MUTTMENU *
819 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
820 mutt_pretty_mailbox (buffer);
822 - add_folder (menu, state, buffer, &s, tmp->new);
823 + add_folder (menu, state, buffer, &s, NULL, tmp->new);
825 while ((tmp = tmp->next));
827 browser_sort (state);
831 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
834 + if (option (OPTNEWS))
835 + return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
837 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
840 @@ -482,7 +669,13 @@ static void folder_entry (char *s, size_
841 folder.ff = &((struct folder_file *) menu->data)[num];
844 - mutt_FormatString (s, slen, NONULL(FolderFormat), folder_format_str,
846 + if (option (OPTNEWS))
847 + mutt_FormatString (s, slen, NONULL(GroupFormat), newsgroup_format_str,
848 + (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
851 + mutt_FormatString (s, slen, NONULL(FolderFormat), folder_format_str,
852 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
855 @@ -502,6 +695,17 @@ static void init_menu (struct browser_st
860 + if (option (OPTNEWS))
863 + snprintf (title, titlelen, _("Subscribed newsgroups"));
865 + snprintf (title, titlelen, _("Newsgroups on server [%s]"),
866 + CurrentNewsSrv->conn->account.host);
871 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
873 @@ -557,6 +761,31 @@ void _mutt_select_file (char *f, size_t
875 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
878 + if (option (OPTNEWS))
881 + strfcpy (prefix, f, sizeof (prefix));
886 + /* default state for news reader mode is browse subscribed newsgroups */
888 + for (list = CurrentNewsSrv->list; list; list = list->next)
890 + NNTP_DATA *data = (NNTP_DATA *) list->data;
892 + if (data && data->subscribed)
904 mutt_expand_path (f, flen);
905 @@ -646,6 +875,9 @@ void _mutt_select_file (char *f, size_t
906 menu->tag = file_tag;
908 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
910 + (option (OPTNEWS)) ? FolderNewsHelp :
914 init_menu (&state, menu, title, sizeof (title), buffy);
915 @@ -784,7 +1016,11 @@ void _mutt_select_file (char *f, size_t
920 + if (buffy || option (OPTNEWS)) /* news have not path */
925 strfcpy (f, state.entry[menu->current].name, flen);
926 mutt_expand_path (f, flen);
927 @@ -842,14 +1078,6 @@ void _mutt_select_file (char *f, size_t
931 - case OP_BROWSER_SUBSCRIBE:
932 - imap_subscribe (state.entry[menu->current].name, 1);
935 - case OP_BROWSER_UNSUBSCRIBE:
936 - imap_subscribe (state.entry[menu->current].name, 0);
939 case OP_BROWSER_TOGGLE_LSUB:
940 if (option (OPTIMAPLSUB))
942 @@ -948,6 +1176,11 @@ void _mutt_select_file (char *f, size_t
944 case OP_CHANGE_DIRECTORY:
947 + if (option (OPTNEWS))
951 strfcpy (buf, LastDir, sizeof (buf));
953 if (!state.imap_browse)
954 @@ -1204,6 +1437,190 @@ void _mutt_select_file (char *f, size_t
956 mutt_error _("Error trying to view file");
963 + if (option (OPTNEWS))
965 + struct folder_file *f = &state.entry[menu->current];
968 + if (i == OP_CATCHUP)
969 + nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
971 + nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
976 + struct folder_file ff;
977 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
980 + folder.ff->name = f->name;
981 + folder.ff->st = NULL;
982 + folder.ff->is_new = nd->new;
983 + folder.ff->nd = nd;
985 + mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
986 + newsgroup_format_str, (unsigned long) &folder,
987 + M_FORMAT_ARROWCURSOR);
988 + f->desc = safe_strdup (buffer); */
989 + if (menu->current + 1 < menu->max)
991 + menu->redraw = REDRAW_MOTION_RESYNCH;
996 + case OP_LOAD_ACTIVE:
997 + if (!option (OPTNEWS))
1004 + for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
1006 + if ((data = (NNTP_DATA *)tmp->data))
1007 + data->deleted = 1;
1010 + nntp_get_active (CurrentNewsSrv);
1012 + destroy_state (&state);
1014 + examine_mailboxes (menu, &state);
1016 + examine_directory (menu, &state, NULL, NULL);
1017 + init_menu (&state, menu, title, sizeof (title), buffy);
1019 +#endif /* USE_NNTP */
1021 +#if defined USE_IMAP || defined USE_NNTP
1022 + case OP_BROWSER_SUBSCRIBE:
1023 + case OP_BROWSER_UNSUBSCRIBE:
1026 + case OP_SUBSCRIBE_PATTERN:
1027 + case OP_UNSUBSCRIBE_PATTERN:
1028 + if (option (OPTNEWS))
1030 + regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1032 + int j = menu->current;
1034 + NNTP_SERVER *news = CurrentNewsSrv;
1036 + if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1042 + if (i == OP_SUBSCRIBE_PATTERN)
1043 + snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1045 + snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1046 + if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1052 + if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1054 + regerror (err, rx, buf, sizeof (buf));
1057 + mutt_error ("%s", buf);
1060 + menu->redraw = REDRAW_FULL;
1063 + else if (!state.entrylen)
1065 + mutt_error _("No newsgroups match the mask");
1069 + for ( ; j < state.entrylen; j++)
1071 + struct folder_file *f = &state.entry[j];
1073 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1074 + regexec (rx, f->name, 0, NULL, 0) == 0)
1076 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1077 + nd = mutt_newsgroup_subscribe (news, f->name);
1079 + nd = mutt_newsgroup_unsubscribe (news, f->name);
1083 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1085 + folder.name = f->name;
1087 + folder.new = nd->new;
1090 + mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
1091 + newsgroup_format_str, (unsigned long) &folder,
1092 + M_FORMAT_ARROWCURSOR);
1093 + f->desc = safe_strdup (buffer);
1096 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1098 + if (menu->current + 1 < menu->max)
1100 + menu->redraw = REDRAW_MOTION_RESYNCH;
1104 + if (i == OP_SUBSCRIBE_PATTERN)
1106 + LIST *grouplist = NULL;
1109 + grouplist = news->list;
1110 + for (; grouplist; grouplist = grouplist->next)
1112 + nd = (NNTP_DATA *) grouplist->data;
1113 + if (nd && nd->group && !nd->subscribed)
1115 + if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1117 + mutt_newsgroup_subscribe (news, nd->group);
1118 + add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1122 + init_menu (&state, menu, title, sizeof (title), buffy);
1124 + mutt_newsrc_update (news);
1125 + nntp_clear_cacheindex (news);
1126 + if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1132 +#endif /* USE_IMAP && USE_NNTP */
1133 +#endif /* USE_NNTP */
1136 + if (i == OP_BROWSER_SUBSCRIBE)
1137 + imap_subscribe (state.entry[menu->current].name, 1);
1139 + imap_subscribe (state.entry[menu->current].name, 0);
1141 +#endif /* USE_IMAP */
1145 diff -udprP mutt-1.5.15.orig/browser.h mutt-1.5.15/browser.h
1146 --- mutt-1.5.15.orig/browser.h 2007-04-03 07:57:21.000000000 +0300
1147 +++ mutt-1.5.15/browser.h 2007-04-11 17:25:15.000000000 +0300
1150 #define _BROWSER_H 1
1159 @@ -38,14 +42,17 @@ struct folder_file
1160 unsigned selectable : 1;
1161 unsigned inferiors : 1;
1166 unsigned tagged : 1;
1169 struct browser_state
1171 struct folder_file *entry;
1172 - short entrylen; /* number of real entries */
1173 - short entrymax; /* max entry */
1174 + unsigned int entrylen; /* number of real entries */
1175 + unsigned int entrymax; /* max entry */
1179 diff -udprP mutt-1.5.15.orig/buffy.c mutt-1.5.15/buffy.c
1180 --- mutt-1.5.15.orig/buffy.c 2007-04-02 00:58:55.000000000 +0300
1181 +++ mutt-1.5.15/buffy.c 2007-04-11 17:25:15.000000000 +0300
1182 @@ -285,6 +285,9 @@ int mutt_buffy_check (int force)
1184 if (!Context || Context->magic != M_POP)
1187 + if (!Context || Context->magic != M_NNTP)
1189 /* check device ID and serial number instead of comparing paths */
1190 if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0)
1192 @@ -308,6 +311,11 @@ int mutt_buffy_check (int force)
1197 + if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1198 + tmp->magic = M_NNTP;
1201 if (stat (tmp->path, &sb) != 0 || sb.st_size == 0 ||
1202 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1204 @@ -325,25 +333,21 @@ int mutt_buffy_check (int force)
1205 /* check to see if the folder is the currently selected folder
1207 if (!Context || !Context->path ||
1208 -#if defined USE_IMAP || defined USE_POP
1213 - tmp->magic == M_IMAP
1214 + || tmp->magic == M_IMAP
1220 - tmp->magic == M_POP
1222 - ) ? mutt_strcmp (tmp->path, Context->path) :
1223 + || tmp->magic == M_POP
1225 - (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1226 -#if defined USE_IMAP || defined USE_POP
1229 + || tmp->magic == M_NNTP
1233 + ) ? mutt_strcmp (tmp->path, Context->path) :
1234 + (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1240 diff -udprP mutt-1.5.15.orig/complete.c mutt-1.5.15/complete.c
1241 --- mutt-1.5.15.orig/complete.c 2007-04-02 00:58:55.000000000 +0300
1242 +++ mutt-1.5.15/complete.c 2007-04-11 17:25:15.000000000 +0300
1244 #include "mailbox.h"
1253 @@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen)
1254 char filepart[_POSIX_PATH_MAX];
1256 char imap_path[LONG_STRING];
1259 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1262 + if (option (OPTNEWS))
1264 + LIST *l = CurrentNewsSrv->list;
1266 + strfcpy (filepart, s, sizeof (filepart));
1269 + * special case to handle when there is no filepart yet.
1270 + * find the first subscribed newsgroup
1272 + if ((len = mutt_strlen (filepart)) == 0)
1274 + for (; l; l = l->next)
1276 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1278 + if (data && data->subscribed)
1280 + strfcpy (filepart, data->group, sizeof (filepart));
1288 + for (; l; l = l->next)
1290 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1292 + if (data && data->subscribed &&
1293 + mutt_strncmp (data->group, filepart, len) == 0)
1297 + for (i = 0; filepart[i] && data->group[i]; i++)
1299 + if (filepart[i] != data->group[i])
1309 + strfcpy (filepart, data->group, sizeof (filepart));
1315 + strcpy (s, filepart);
1317 + return (init ? 0 : -1);
1322 /* we can use '/' as a delimiter, imap_complete rewrites it */
1323 if (*s == '=' || *s == '+' || *s == '!')
1325 diff -udprP mutt-1.5.15.orig/compose.c mutt-1.5.15/compose.c
1326 --- mutt-1.5.15.orig/compose.c 2007-04-02 00:58:55.000000000 +0300
1327 +++ mutt-1.5.15/compose.c 2007-04-11 17:25:15.000000000 +0300
1329 #include "mailbox.h"
1331 #include "charset.h"
1335 #include "remailer.h"
1344 @@ -60,18 +65,21 @@ enum
1361 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1364 -#define HDR_XOFFSET 10
1365 -#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1366 +#define HDR_XOFFSET 14
1367 +#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1368 #define W (COLS - HDR_XOFFSET)
1370 static char *Prompts[] =
1371 @@ -83,6 +91,16 @@ static char *Prompts[] =
1387 static struct mapping_t ComposeHelp[] = {
1388 @@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] =
1393 +static struct mapping_t ComposeNewsHelp[] = {
1394 + { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1395 + { N_("Abort"), OP_EXIT },
1396 + { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1397 + { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1398 + { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1399 + { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1400 + { N_("Help"), OP_HELP },
1405 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1407 mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
1408 @@ -115,16 +146,16 @@ static void redraw_crypt_lines (HEADER *
1409 if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
1412 - mvaddstr (HDR_CRYPT, 0, "Security: ");
1413 + mvaddstr (HDR_CRYPT, 0, " Security: ");
1414 else if (msg->security & APPLICATION_SMIME)
1415 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1416 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1417 else if (msg->security & APPLICATION_PGP)
1418 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1419 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1421 else if ((WithCrypto & APPLICATION_SMIME))
1422 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1423 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1424 else if ((WithCrypto & APPLICATION_PGP))
1425 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1426 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1430 @@ -252,9 +283,28 @@ static void draw_envelope_addr (int line
1431 static void draw_envelope (HEADER *msg, char *fcc)
1433 draw_envelope_addr (HDR_FROM, msg->env->from);
1435 + if (!option (OPTNEWSSEND))
1438 draw_envelope_addr (HDR_TO, msg->env->to);
1439 draw_envelope_addr (HDR_CC, msg->env->cc);
1440 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1445 + mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1446 + mutt_paddstr (W, NONULL (msg->env->newsgroups));
1447 + mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1448 + mutt_paddstr (W, NONULL (msg->env->followup_to));
1449 + if (option (OPTXCOMMENTTO))
1451 + mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1452 + mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1456 mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1457 mutt_paddstr (W, NONULL (msg->env->subject));
1458 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1459 @@ -507,6 +557,12 @@ int mutt_compose_menu (HEADER *msg, /*
1460 /* Sort, SortAux could be changed in mutt_index_menu() */
1461 int oldSort, oldSortAux;
1464 + int news = 0; /* is it a news article ? */
1466 + if (option (OPTNEWSSEND))
1470 mutt_attach_init (msg->content);
1471 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
1472 @@ -518,10 +574,18 @@ int mutt_compose_menu (HEADER *msg, /*
1473 menu->make_entry = snd_entry;
1474 menu->tag = mutt_tag_attach;
1478 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1481 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1486 + unset_option (OPTNEWS); /* for any case */
1488 switch (op = mutt_menuLoop (menu))
1491 @@ -534,17 +598,87 @@ int mutt_compose_menu (HEADER *msg, /*
1492 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1494 case OP_COMPOSE_EDIT_TO:
1499 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1500 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1502 case OP_COMPOSE_EDIT_BCC:
1507 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1508 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1510 case OP_COMPOSE_EDIT_CC:
1515 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1516 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1519 + case OP_COMPOSE_EDIT_NEWSGROUPS:
1522 + if (msg->env->newsgroups)
1523 + strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1526 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1528 + FREE (&msg->env->newsgroups);
1529 + mutt_remove_trailing_ws (buf);
1530 + msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1531 + move (HDR_TO, HDR_XOFFSET);
1533 + if (msg->env->newsgroups)
1534 + printw ("%-*.*s", W, W, msg->env->newsgroups);
1539 + case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1543 + if (msg->env->followup_to)
1544 + strfcpy (buf, msg->env->followup_to, sizeof (buf));
1545 + if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1547 + FREE (&msg->env->followup_to);
1548 + mutt_remove_trailing_ws (buf);
1549 + msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1550 + move (HDR_CC, HDR_XOFFSET);
1552 + if (msg->env->followup_to)
1553 + printw ("%-*.*s", W, W, msg->env->followup_to);
1558 + case OP_COMPOSE_EDIT_X_COMMENT_TO:
1559 + if (news && option (OPTXCOMMENTTO))
1562 + if (msg->env->x_comment_to)
1563 + strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1564 + if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1566 + FREE (&msg->env->x_comment_to);
1567 + msg->env->x_comment_to = safe_strdup (buf);
1568 + move (HDR_BCC, HDR_XOFFSET);
1570 + if (msg->env->x_comment_to)
1571 + printw ("%-*.*s", W, W, msg->env->x_comment_to);
1576 case OP_COMPOSE_EDIT_SUBJECT:
1577 if (msg->env->subject)
1578 strfcpy (buf, msg->env->subject, sizeof (buf));
1579 @@ -707,6 +841,9 @@ int mutt_compose_menu (HEADER *msg, /*
1582 case OP_COMPOSE_ATTACH_MESSAGE:
1584 + case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1589 @@ -714,7 +851,22 @@ int mutt_compose_menu (HEADER *msg, /*
1591 prompt = _("Open mailbox to attach message from");
1594 + unset_option (OPTNEWS);
1595 + if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1597 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1600 + prompt = _("Open newsgroup to attach message from");
1601 + set_option (OPTNEWS);
1607 + if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1610 strfcpy (fname, NONULL (Context->path), sizeof (fname));
1611 mutt_pretty_mailbox (fname);
1612 @@ -723,6 +875,11 @@ int mutt_compose_menu (HEADER *msg, /*
1613 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1617 + if (option (OPTNEWS))
1618 + nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1621 mutt_expand_path (fname, sizeof (fname));
1623 if (!mx_is_imap (fname))
1624 @@ -730,6 +887,9 @@ int mutt_compose_menu (HEADER *msg, /*
1626 if (!mx_is_pop (fname))
1629 + if (!mx_is_nntp (fname) && !option (OPTNEWS))
1631 /* check to make sure the file exists and is readable */
1632 if (access (fname, R_OK) == -1)
1634 diff -udprP mutt-1.5.15.orig/config.h.in mutt-1.5.15/config.h.in
1635 --- mutt-1.5.15.orig/config.h.in 2007-04-06 10:18:47.000000000 +0300
1636 +++ mutt-1.5.15/config.h.in 2007-04-11 17:25:15.000000000 +0300
1638 significant more memory when defined. */
1639 #undef EXACT_ADDRESS
1641 +/* Compiling with newsreading support with NNTP */
1644 /* program to use for shell commands */
1647 diff -udprP mutt-1.5.15.orig/configure.ac mutt-1.5.15/configure.ac
1648 --- mutt-1.5.15.orig/configure.ac 2007-04-06 10:11:53.000000000 +0300
1649 +++ mutt-1.5.15/configure.ac 2007-04-11 17:25:15.000000000 +0300
1650 @@ -584,6 +584,14 @@ if test x"$need_imap" = xyes -o x"$need_
1651 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1654 +AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1655 +[ if test x$enableval = xyes ; then
1656 + AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1657 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1662 dnl -- end socket dependencies --
1664 if test "$need_socket" = "yes"
1665 diff -udprP mutt-1.5.15.orig/curs_main.c mutt-1.5.15/curs_main.c
1666 --- mutt-1.5.15.orig/curs_main.c 2007-04-03 20:41:14.000000000 +0300
1667 +++ mutt-1.5.15/curs_main.c 2007-04-11 17:25:15.000000000 +0300
1671 #include "mutt_curses.h"
1673 #include "mutt_menu.h"
1675 #include "mailbox.h"
1678 #include "mutt_crypt.h"
1687 @@ -415,12 +420,27 @@ struct mapping_t IndexHelp[] = {
1692 +struct mapping_t IndexNewsHelp[] = {
1693 + { N_("Quit"), OP_QUIT },
1694 + { N_("Del"), OP_DELETE },
1695 + { N_("Undel"), OP_UNDELETE },
1696 + { N_("Save"), OP_SAVE },
1697 + { N_("Post"), OP_POST },
1698 + { N_("Followup"), OP_FOLLOWUP },
1699 + { N_("Catchup"), OP_CATCHUP },
1700 + { N_("Help"), OP_HELP },
1705 /* This function handles the message index window as well as commands returned
1706 * from the pager (MENU_PAGER).
1708 int mutt_index_menu (void)
1710 char buf[LONG_STRING], helpstr[LONG_STRING];
1713 int done = 0; /* controls when to exit the "event" loop */
1715 @@ -442,7 +462,11 @@ int mutt_index_menu (void)
1716 menu->make_entry = index_make_entry;
1717 menu->color = index_color;
1718 menu->current = ci_first_message ();
1719 - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1720 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1722 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1727 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
1728 @@ -694,6 +718,9 @@ int mutt_index_menu (void)
1729 mutt_curs_set (1); /* fallback from the pager */
1733 + unset_option (OPTNEWS); /* for any case */
1738 @@ -744,6 +771,120 @@ int mutt_index_menu (void)
1739 menu_current_bottom (menu);
1743 + case OP_GET_MESSAGE:
1744 + case OP_GET_PARENT:
1746 + if (Context->magic == M_NNTP)
1750 + if (op == OP_GET_MESSAGE)
1753 + if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1759 + LIST *ref = CURHDR->env->references;
1762 + mutt_error _("Article has no parent reference!");
1765 + strfcpy (buf, ref->data, sizeof (buf));
1767 + if (!Context->id_hash)
1768 + Context->id_hash = mutt_make_id_hash (Context);
1769 + if ((h = hash_find (Context->id_hash, buf)))
1771 + if (h->virtual != -1)
1773 + menu->current = h->virtual;
1774 + menu->redraw = REDRAW_MOTION_RESYNCH;
1776 + else if (h->collapsed)
1778 + mutt_uncollapse_thread (Context, h);
1779 + mutt_set_virtual (Context);
1780 + menu->current = h->virtual;
1781 + menu->redraw = REDRAW_MOTION_RESYNCH;
1784 + mutt_error _("Message not visible in limited view.");
1788 + if (nntp_check_msgid (Context, buf) == 0)
1790 + h = Context->hdrs[Context->msgcount-1];
1791 + mutt_sort_headers (Context, 0);
1792 + menu->current = h->virtual;
1793 + menu->redraw = REDRAW_FULL;
1796 + mutt_error (_("Article %s not found on server"), buf);
1801 + case OP_GET_CHILDREN:
1802 + case OP_RECONSTRUCT_THREAD:
1804 + if (Context->magic == M_NNTP)
1807 + int old = CURHDR->index, i;
1809 + if (!CURHDR->env->message_id)
1811 + mutt_error _("No Message-Id. Unable to perform operation");
1815 + if (!Context->id_hash)
1816 + Context->id_hash = mutt_make_id_hash (Context);
1817 + strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1819 + if (op == OP_RECONSTRUCT_THREAD)
1821 + LIST *ref = CURHDR->env->references;
1824 + nntp_check_msgid (Context, ref->data);
1825 + /* the last msgid in References is the root message */
1827 + strfcpy (buf, ref->data, sizeof (buf));
1831 + mutt_message _("Check for children of message...");
1832 + if (nntp_check_children (Context, buf) == 0)
1834 + mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1835 + h = hash_find (Context->id_hash, buf);
1836 + /* if the root message was retrieved, move to it */
1838 + menu->current = h->virtual;
1839 + else /* try to restore old position */
1840 + for (i = 0; i < Context->msgcount; i++)
1841 + if (Context->hdrs[i]->index == old)
1843 + menu->current = Context->hdrs[i]->virtual;
1844 + /* As an added courtesy, recenter the menu
1845 + * with the current entry at the middle of the screen */
1846 + menu_check_recenter (menu);
1847 + menu_current_middle (menu);
1850 + menu->redraw = REDRAW_FULL;
1851 + mutt_clear_error ();
1859 @@ -841,11 +982,33 @@ int mutt_index_menu (void)
1863 + case OP_TOGGLE_READ:
1866 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1868 - if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1869 + if (op == OP_TOGGLE_READ)
1871 + char buf[LONG_STRING];
1873 + if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1875 + snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1876 + Context->pattern ? Context->pattern : ".*");
1877 + set_option (OPTHIDEREAD);
1881 + strfcpy (buf, Context->pattern + 8, sizeof(buf));
1882 + if (!*buf || strncmp (buf, ".*", 2) == 0)
1883 + snprintf (buf, sizeof(buf), "~A");
1884 + unset_option (OPTHIDEREAD);
1886 + FREE (&Context->pattern);
1887 + Context->pattern = safe_strdup (buf);
1889 + if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1890 + mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1892 if (menu->oldcurrent >= 0)
1894 @@ -1052,20 +1215,43 @@ int mutt_index_menu (void)
1897 case OP_MAIN_CHANGE_FOLDER:
1900 - op = OP_MAIN_CHANGE_FOLDER_READONLY;
1902 - /* fallback to the readonly case */
1904 case OP_MAIN_CHANGE_FOLDER_READONLY:
1906 + case OP_MAIN_CHANGE_GROUP:
1907 + case OP_MAIN_CHANGE_GROUP_READONLY:
1910 - if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1911 + if (attach_msg || option (OPTREADONLY) ||
1913 + op == OP_MAIN_CHANGE_GROUP_READONLY ||
1915 + op == OP_MAIN_CHANGE_FOLDER_READONLY)
1916 + flags = M_READONLY;
1921 cp = _("Open mailbox in read-only mode");
1923 cp = _("Open mailbox");
1927 + unset_option (OPTNEWS);
1928 + if (op == OP_MAIN_CHANGE_GROUP ||
1929 + op == OP_MAIN_CHANGE_GROUP_READONLY)
1931 + set_option (OPTNEWS);
1932 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1935 + cp = _("Open newsgroup in read-only mode");
1937 + cp = _("Open newsgroup");
1942 mutt_buffy (buf, sizeof (buf));
1944 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1945 @@ -1084,6 +1270,14 @@ int mutt_index_menu (void)
1950 + if (option (OPTNEWS))
1952 + unset_option (OPTNEWS);
1953 + nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1957 mutt_expand_path (buf, sizeof (buf));
1958 if (mx_get_magic (buf) <= 0)
1960 @@ -1121,15 +1315,18 @@ int mutt_index_menu (void)
1961 CurrentMenu = MENU_MAIN;
1962 mutt_folder_hook (buf);
1964 - if ((Context = mx_open_mailbox (buf,
1965 - (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1966 - M_READONLY : 0, NULL)) != NULL)
1967 + if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1969 menu->current = ci_first_message ();
1975 + /* mutt_buffy_check() must be done with mail-reader mode! */
1976 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1977 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1979 mutt_clear_error ();
1980 mutt_buffy_check(1); /* force the buffy check after we have changed
1982 @@ -1500,6 +1697,15 @@ int mutt_index_menu (void)
1984 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1987 + if (Context->magic == M_NNTP)
1990 + mutt_error _("Can't change 'important' flag on NNTP server.");
1997 for (j = 0; j < Context->vcount; j++)
1998 @@ -1847,6 +2053,17 @@ int mutt_index_menu (void)
2004 + if (Context && Context->magic == M_NNTP)
2006 + if (mutt_newsgroup_catchup (CurrentNewsSrv,
2007 + ((NNTP_DATA *)Context->data)->group))
2008 + menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2013 case OP_DISPLAY_ADDRESS:
2016 @@ -1974,6 +2191,15 @@ int mutt_index_menu (void)
2017 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2022 + if (Context->magic == M_NNTP)
2025 + mutt_error _("Can't edit message on newsserver.");
2030 MAYBE_REDRAW (menu->redraw);
2032 @@ -2045,6 +2271,37 @@ int mutt_index_menu (void)
2034 menu->redraw = REDRAW_FULL;
2040 + case OP_FORWARD_TO_GROUP:
2043 + if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2044 + mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2045 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2047 + if (Context && Context->magic == M_NNTP &&
2048 + !((NNTP_DATA *)Context->data)->allowed &&
2049 + query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2051 + if (op == OP_POST)
2052 + ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2056 + if (op == OP_FOLLOWUP)
2057 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2058 + tag ? NULL : CURHDR);
2060 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2061 + tag ? NULL : CURHDR);
2063 + menu->redraw = REDRAW_FULL;
2070 @@ -2118,6 +2375,12 @@ int mutt_index_menu (void)
2072 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2075 + /* Close all open NNTP connections */
2077 + nntp_logout_all ();
2080 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2081 op == OP_UNDELETE_THREAD ? 0 : 1);
2083 diff -udprP mutt-1.5.15.orig/doc/manual.xml.head mutt-1.5.15/doc/manual.xml.head
2084 --- mutt-1.5.15.orig/doc/manual.xml.head 2007-04-04 08:37:13.000000000 +0300
2085 +++ mutt-1.5.15/doc/manual.xml.head 2007-04-11 17:25:15.000000000 +0300
2086 @@ -1295,6 +1295,22 @@ fo-table</literal> for details.
2091 +<title>Reading news via NNTP</title>
2094 +If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2095 +read news from newsserver via NNTP. You can open a newsgroup with
2096 +function ``change-newsgroup'' (default: ``i''). Default newsserver
2097 +can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2098 +variable. Like other news readers, info about subscribed newsgroups
2099 +is saved in file by <link linkend="newsrc">$newsrc</link>
2100 +variable. Article headers are cached and can be loaded from file when
2101 +newsgroup entered instead loading from newsserver.
2108 <sect1 id="forwarding-mail">
2109 diff -udprP mutt-1.5.15.orig/doc/mutt.man mutt-1.5.15/doc/mutt.man
2110 --- mutt-1.5.15.orig/doc/mutt.man 2007-04-04 08:37:13.000000000 +0300
2111 +++ mutt-1.5.15/doc/mutt.man 2007-04-11 17:25:15.000000000 +0300
2112 @@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2117 -[-e \fIcmd\fP] [-F \fIfile\fP] [-m \fItype\fP] [-f \fIfile\fP]
2119 +[-e \fIcmd\fP] [-F \fIfile\fP] [-g \fIserver\fP] [-m \fItype\fP] [-f \fIfile\fP]
2123 @@ -83,6 +83,10 @@ files.
2124 Specify which mailbox to load.
2125 .IP "-F \fImuttrc\fP"
2126 Specify an initialization file to read instead of ~/.muttrc
2127 +.IP "-g \fIserver\fP"
2128 +Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2130 +Start Mutt with a listing of subscribed newsgroups.
2133 .IP "-H \fIdraft\fP"
2134 diff -udprP mutt-1.5.15.orig/functions.h mutt-1.5.15/functions.h
2135 --- mutt-1.5.15.orig/functions.h 2007-04-02 00:58:55.000000000 +0300
2136 +++ mutt-1.5.15/functions.h 2007-04-11 17:25:15.000000000 +0300
2137 @@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in
2138 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2139 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2140 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2142 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2143 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2145 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2146 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
2147 { "copy-message", OP_COPY_MESSAGE, "C" },
2148 @@ -100,7 +104,15 @@ struct binding_t OpMain[] = { /* map: in
2149 { "edit", OP_EDIT_MESSAGE, "e" },
2150 { "edit-type", OP_EDIT_TYPE, "\005" },
2151 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2152 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2154 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2155 + { "followup-message", OP_FOLLOWUP, "F" },
2156 + { "get-children", OP_GET_CHILDREN, NULL },
2157 + { "get-message", OP_GET_MESSAGE, "\007" },
2158 + { "get-parent", OP_GET_PARENT, "\033G" },
2159 + { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2161 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2162 { "group-reply", OP_GROUP_REPLY, "g" },
2164 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2165 @@ -126,6 +138,9 @@ struct binding_t OpMain[] = { /* map: in
2166 { "sort-mailbox", OP_SORT, "o" },
2167 { "sort-reverse", OP_SORT_REVERSE, "O" },
2168 { "print-message", OP_PRINT, "p" },
2170 + { "post-message", OP_POST, "P" },
2172 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2173 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2174 { "recall-message", OP_RECALL_MESSAGE, "R" },
2175 @@ -145,6 +160,10 @@ struct binding_t OpMain[] = { /* map: in
2176 { "show-version", OP_VERSION, "V" },
2177 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2178 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2179 + { "toggle-read", OP_TOGGLE_READ, "X" },
2181 + { "catchup", OP_CATCHUP, "y" },
2183 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2184 { "buffy-list", OP_BUFFY_LIST, "." },
2185 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
2186 @@ -156,7 +175,7 @@ struct binding_t OpMain[] = { /* map: in
2187 { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" },
2188 { "next-unread", OP_MAIN_NEXT_UNREAD, NULL },
2189 { "previous-unread", OP_MAIN_PREV_UNREAD, NULL },
2190 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2191 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2194 { "extract-keys", OP_EXTRACT_KEYS, "\013" },
2195 @@ -176,6 +195,10 @@ struct binding_t OpPager[] = { /* map: p
2196 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2197 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2198 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2200 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2201 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2203 { "copy-message", OP_COPY_MESSAGE, "C" },
2204 { "decode-copy", OP_DECODE_COPY, "\033C" },
2205 { "delete-message", OP_DELETE, "d" },
2206 @@ -183,8 +206,12 @@ struct binding_t OpPager[] = { /* map: p
2207 { "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" },
2208 { "edit", OP_EDIT_MESSAGE, "e" },
2209 { "edit-type", OP_EDIT_TYPE, "\005" },
2211 + { "followup-message", OP_FOLLOWUP, "F" },
2212 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2214 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2215 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2216 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2217 { "group-reply", OP_GROUP_REPLY, "g" },
2219 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
2220 @@ -203,6 +230,9 @@ struct binding_t OpPager[] = { /* map: p
2221 { "next-thread", OP_MAIN_NEXT_THREAD, "\016" },
2222 { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" },
2223 { "print-message", OP_PRINT, "p" },
2225 + { "post-message", OP_POST, "P" },
2227 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2228 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2229 { "quit", OP_QUIT, "Q" },
2230 @@ -250,7 +280,7 @@ struct binding_t OpPager[] = { /* map: p
2231 { "half-down", OP_HALF_DOWN, NULL },
2232 { "previous-line", OP_PREV_LINE, NULL },
2233 { "bottom", OP_PAGER_BOTTOM, NULL },
2234 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2235 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2239 @@ -270,6 +300,10 @@ struct binding_t OpAttach[] = { /* map:
2240 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2241 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2242 { "edit-type", OP_EDIT_TYPE, "\005" },
2244 + { "followup-message", OP_FOLLOWUP, "F" },
2245 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2247 { "print-entry", OP_PRINT, "p" },
2248 { "save-entry", OP_SAVE, "s" },
2249 { "pipe-entry", OP_PIPE, "|" },
2250 @@ -295,6 +329,7 @@ struct binding_t OpAttach[] = { /* map:
2251 struct binding_t OpCompose[] = { /* map: compose */
2252 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2253 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2254 + { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2255 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2256 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2257 { "copy-file", OP_SAVE, "C" },
2258 @@ -314,6 +349,11 @@ struct binding_t OpCompose[] = { /* map:
2259 { "print-entry", OP_PRINT, "l" },
2260 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2261 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2263 + { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2264 + { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2265 + { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2267 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2268 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2269 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
2270 @@ -365,14 +405,25 @@ struct binding_t OpBrowser[] = { /* map:
2271 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2272 { "check-new", OP_CHECK_NEW, NULL },
2273 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2275 + { "reload-active", OP_LOAD_ACTIVE, "g" },
2276 + { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2277 + { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2278 + { "catchup", OP_CATCHUP, "y" },
2279 + { "uncatchup", OP_UNCATCHUP, "Y" },
2281 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2282 { "buffy-list", OP_BUFFY_LIST, "." },
2284 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2285 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2286 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2288 +#if defined USE_IMAP || defined USE_NNTP
2289 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2290 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2293 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2296 diff -udprP mutt-1.5.15.orig/globals.h mutt-1.5.15/globals.h
2297 --- mutt-1.5.15.orig/globals.h 2007-04-05 19:04:56.000000000 +0300
2298 +++ mutt-1.5.15/globals.h 2007-04-11 17:25:15.000000000 +0300
2299 @@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
2302 WHERE char *Muttrc INITVAL (NULL);
2304 +WHERE char *NewsCacheDir;
2305 +WHERE char *GroupFormat;
2307 +WHERE char *NewsServer;
2308 +WHERE char *NntpUser;
2309 +WHERE char *NntpPass;
2310 +WHERE char *NewsRc;
2314 WHERE char *PagerFmt;
2315 @@ -189,6 +198,11 @@ extern unsigned char QuadOptions[];
2317 WHERE unsigned short Counter INITVAL (0);
2320 +WHERE short NewsPollTimeout;
2321 +WHERE short NntpContext;
2324 WHERE short ConnectTimeout;
2325 WHERE short HistSize;
2326 WHERE short MenuContext;
2327 diff -udprP mutt-1.5.15.orig/hash.c mutt-1.5.15/hash.c
2328 --- mutt-1.5.15.orig/hash.c 2007-04-02 00:58:56.000000000 +0300
2329 +++ mutt-1.5.15/hash.c 2007-04-11 17:25:15.000000000 +0300
2330 @@ -51,10 +51,35 @@ HASH *hash_create (int nelem)
2333 table->nelem = nelem;
2334 + table->curnelem = 0;
2335 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2339 +HASH *hash_resize (HASH *ptr, int nelem)
2342 + struct hash_elem *elem, *tmp;
2345 + table = hash_create (nelem);
2347 + for (i = 0; i < ptr->nelem; i++)
2349 + for (elem = ptr->table[i]; elem; )
2352 + elem = elem->next;
2353 + hash_insert (table, tmp->key, tmp->data, 1);
2357 + FREE (&ptr->table);
2363 /* table hash table to update
2364 * key key to hash on
2365 * data data to associate with `key'
2366 @@ -74,6 +99,7 @@ int hash_insert (HASH * table, const cha
2368 ptr->next = table->table[h];
2369 table->table[h] = ptr;
2370 + table->curnelem++;
2374 @@ -96,6 +122,7 @@ int hash_insert (HASH * table, const cha
2376 table->table[h] = ptr;
2378 + table->curnelem++;
2382 @@ -126,6 +153,7 @@ void hash_delete_hash (HASH * table, int
2384 destroy (ptr->data);
2386 + table->curnelem--;
2390 diff -udprP mutt-1.5.15.orig/hash.h mutt-1.5.15/hash.h
2391 --- mutt-1.5.15.orig/hash.h 2007-04-02 00:58:56.000000000 +0300
2392 +++ mutt-1.5.15/hash.h 2007-04-11 17:25:15.000000000 +0300
2393 @@ -28,7 +28,7 @@ struct hash_elem
2398 + int nelem, curnelem;
2399 struct hash_elem **table;
2402 @@ -40,6 +40,7 @@ HASH;
2403 HASH *hash_create (int nelem);
2404 int hash_string (const unsigned char *s, int n);
2405 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2406 +HASH *hash_resize (HASH * table, int nelem);
2407 void *hash_find_hash (const HASH * table, int hash, const char *key);
2408 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2409 void (*destroy) (void *));
2410 diff -udprP mutt-1.5.15.orig/hdrline.c mutt-1.5.15/hdrline.c
2411 --- mutt-1.5.15.orig/hdrline.c 2007-04-03 20:52:56.000000000 +0300
2412 +++ mutt-1.5.15/hdrline.c 2007-04-11 17:29:25.000000000 +0300
2413 @@ -209,6 +209,7 @@ int mutt_user_is_recipient (HEADER *h)
2414 * %E = number of messages in current thread
2415 * %f = entire from line
2416 * %F = like %n, unless from self
2417 + * %g = newsgroup name (if compiled with nntp support)
2419 * %l = number of lines in the message
2420 * %L = like %F, except `lists' are displayed first
2421 @@ -216,12 +217,14 @@ int mutt_user_is_recipient (HEADER *h)
2422 * %n = name of author
2424 * %O = like %L, except using address instead of name
2425 + * %R = `x-comment-to:' field (if present and compiled with nntp support)
2427 * %S = short message status (e.g., N/O/D/!/r/-)
2428 * %t = `to:' field (recipients)
2430 * %u = user (login) name of author
2431 * %v = first name of author, unless from self
2432 + * %W = where user is (organization)
2433 * %X = number of MIME attachments
2434 * %y = `x-label:' field (if present)
2435 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2436 @@ -459,6 +462,12 @@ hdr_format_str (char *dest,
2442 + mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2447 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2449 @@ -546,6 +555,15 @@ hdr_format_str (char *dest,
2456 + mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2457 + else if (!hdr->env->x_comment_to)
2464 if (flags & M_FORMAT_TREE && !hdr->collapsed)
2465 @@ -635,6 +653,13 @@ hdr_format_str (char *dest,
2466 mutt_format_s (dest, destlen, prefix, buf2);
2471 + mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2472 + else if (!hdr->env->organization)
2479 diff -udprP mutt-1.5.15.orig/headers.c mutt-1.5.15/headers.c
2480 --- mutt-1.5.15.orig/headers.c 2007-04-02 00:58:56.000000000 +0300
2481 +++ mutt-1.5.15/headers.c 2007-04-11 17:25:15.000000000 +0300
2482 @@ -118,6 +118,9 @@ void mutt_edit_headers (const char *edit
2483 msg->env = n; n = NULL;
2485 if (!msg->env->in_reply_to)
2487 + if (!option (OPTNEWSSEND))
2489 mutt_free_list (&msg->env->references);
2491 mutt_expand_aliases_env (msg->env);
2492 diff -udprP mutt-1.5.15.orig/init.c mutt-1.5.15/init.c
2493 --- mutt-1.5.15.orig/init.c 2007-04-02 00:58:56.000000000 +0300
2494 +++ mutt-1.5.15/init.c 2007-04-11 17:25:15.000000000 +0300
2495 @@ -2859,6 +2859,28 @@ void mutt_init (int skip_sys_rc, LIST *c
2497 Fqdn = safe_strdup(NONULL(Hostname));
2504 + if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2507 + fgets (buffer, sizeof (buffer), f);
2511 + while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2513 + NewsServer = safe_strdup (p);
2517 + if ((p = getenv ("NNTPSERVER")))
2518 + NewsServer = safe_strdup (p);
2521 if ((p = getenv ("MAIL")))
2522 Spoolfile = safe_strdup (p);
2523 else if ((p = getenv ("MAILDIR")))
2524 diff -udprP mutt-1.5.15.orig/init.h mutt-1.5.15/init.h
2525 --- mutt-1.5.15.orig/init.h 2007-04-05 19:03:55.000000000 +0300
2526 +++ mutt-1.5.15/init.h 2007-04-11 17:29:25.000000000 +0300
2527 @@ -169,6 +169,20 @@ struct option_t MuttVars[] = {
2528 ** If set, Mutt will prompt you for carbon-copy (Cc) recipients before
2529 ** editing the body of an outgoing message.
2532 + { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2535 + ** If set, Mutt will prompt you for follow-up groups before editing
2536 + ** the body of an outgoing message.
2538 + { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2541 + ** If set, Mutt will prompt you for x-comment-to field before editing
2542 + ** the body of an outgoing message.
2545 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2548 @@ -308,6 +322,14 @@ struct option_t MuttVars[] = {
2549 ** When this variable is set, mutt will use file size attribute instead of
2550 ** access time when checking for new mail.
2553 + { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2556 + ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2557 + ** as read when you quit the newsgroup (catchup newsgroup).
2560 { "charset", DT_STR, R_NONE, UL &Charset, UL 0 },
2563 @@ -635,6 +657,16 @@ struct option_t MuttVars[] = {
2564 ** sent to both the list and your address, resulting in two copies
2565 ** of the same email for you.
2568 + { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2571 + ** If this variable is \fIset\fP and the keyword "poster" is present in
2572 + ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2573 + ** permitted. The message will be mailed to the submitter of the
2574 + ** message via mail.
2577 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2580 @@ -706,6 +738,27 @@ struct option_t MuttVars[] = {
2581 ** a regular expression that will match the whole name so mutt will expand
2582 ** "Franklin" to "Franklin, Steve".
2585 + { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2588 + ** This variable allows you to customize the newsgroup browser display to
2589 + ** your personal taste. This string is similar to ``$index_format'', but
2590 + ** has its own set of printf()-like sequences:
2593 + ** %C current newsgroup number
2594 + ** %d description of newsgroup (becomes from server)
2595 + ** %f newsgroup name
2596 + ** %M - if newsgroup not allowed for direct post (moderated for example)
2597 + ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2598 + ** %n number of new articles in newsgroup
2599 + ** %s number of unread articles in newsgroup
2600 + ** %>X right justify the rest of the string and pad with character "X"
2601 + ** %|X pad to the end of the line with character "X"
2605 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2608 @@ -996,6 +1049,7 @@ struct option_t MuttVars[] = {
2609 ** .dt %E .dd number of messages in current thread
2610 ** .dt %f .dd entire From: line (address + real name)
2611 ** .dt %F .dd author name, or recipient name if the message is from you
2612 + ** .dt %g .dd newsgroup name (if compiled with nntp support)
2613 ** .dt %H .dd spam attribute(s) of this message
2614 ** .dt %i .dd message-id of the current message
2615 ** .dt %l .dd number of lines in the message (does not work with maildir,
2616 @@ -1009,12 +1063,14 @@ struct option_t MuttVars[] = {
2617 ** .dt %n .dd author's real name (or address if missing)
2618 ** .dt %O .dd (_O_riginal save folder) Where mutt would formerly have
2619 ** stashed the message: list name or recipient name if no list
2620 + ** .dt %R .dd `x-comment-to:' field (if present and compiled with nntp support)
2621 ** .dt %s .dd subject of the message
2622 ** .dt %S .dd status of the message (N/D/d/!/r/\(as)
2623 ** .dt %t .dd `to:' field (recipients)
2624 ** .dt %T .dd the appropriate character from the $$to_chars string
2625 ** .dt %u .dd user (login) name of the author
2626 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2627 + ** .dt %W .dd name of organization of author (`organization:' field)
2628 ** .dt %X .dd number of attachments
2629 ** (please see the ``$attachments'' section for possible speed effects)
2630 ** .dt %y .dd `x-label:' field, if present
2631 @@ -1039,6 +1095,21 @@ struct option_t MuttVars[] = {
2633 ** See also: ``$$to_chars''.
2636 + { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2639 + ** If set, specifies the program and arguments used to deliver news posted
2640 + ** by Mutt. Otherwise, mutt posts article using current connection to
2641 + ** news server. The following printf-style sequence is understood:
2644 + ** %s newsserver name
2647 + ** Example: set inews="/usr/local/bin/inews -hS"
2650 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2653 @@ -1253,6 +1324,16 @@ struct option_t MuttVars[] = {
2654 ** be attached to the newly composed message if this option is set.
2658 + { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2661 + ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2662 + ** encoded according to RFC2047 to base64. This is useful when message
2663 + ** is Usenet article, because MIME for news is nonstandard feature.
2668 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2670 @@ -1323,6 +1404,77 @@ struct option_t MuttVars[] = {
2671 ** See also ``$$read_inc'' and ``$$write_inc''.
2675 + { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2678 + ** This variable pointing to directory where Mutt will save cached news
2679 + ** articles headers in. If \fIunset\fP, headers will not be saved at all
2680 + ** and will be reloaded each time when you enter to newsgroup.
2682 + { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2685 + ** This variable specifies domain name or address of NNTP server. It
2686 + ** defaults to the newsserver specified in the environment variable
2687 + ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2688 + ** specify username and an alternative port for each newsserver, ie:
2690 + ** [news[s]://][username[:password]@]newsserver[:port]
2692 + { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2695 + ** The file, containing info about subscribed newsgroups - names and
2696 + ** indexes of read articles. The following printf-style sequence
2700 + ** %s newsserver name
2703 + { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2706 + ** This variable defines number of articles which will be in index when
2707 + ** newsgroup entered. If active newsgroup have more articles than this
2708 + ** number, oldest articles will be ignored. Also controls how many
2709 + ** articles headers will be saved in cache when you quit newsgroup.
2711 + { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2714 + ** This variable controls whether or not descriptions for each newsgroup
2715 + ** must be loaded when newsgroup is added to list (first time list
2716 + ** loading or new newsgroup adding).
2718 + { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2721 + ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2722 + ** authentification, Mutt will prompt you for your account name when you
2723 + ** connect to newsserver.
2725 + { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2728 + ** Your password for NNTP account.
2730 + { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2733 + ** The time in seconds until any operations on newsgroup except post new
2734 + ** article will cause recheck for new news. If set to 0, Mutt will
2735 + ** recheck newsgroup on each operation in index (stepping, read article,
2738 + { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2741 + ** Controls whether or not Mutt will try to reconnect to newsserver when
2742 + ** connection lost.
2745 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2748 @@ -2133,6 +2285,16 @@ struct option_t MuttVars[] = {
2749 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2753 + { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2756 + ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2757 + ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2758 + ** does not support posting to that newsgroup or totally read-only, that
2759 + ** posting will not have an effect.
2762 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2765 @@ -2489,6 +2651,28 @@ struct option_t MuttVars[] = {
2766 ** Command to use when spawning a subshell. By default, the user's login
2767 ** shell from /etc/passwd is used.
2770 + { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2773 + ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2774 + ** ``newsrc'' file and into cache.
2776 + { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2779 + ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2780 + ** the browser. Otherwise, it will be done only once for a newsserver.
2781 + ** Also controls whether or not number of new articles of subscribed
2782 + ** newsgroups will be then checked.
2784 + { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2787 + ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2788 + ** will be displayed in browser.
2791 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2794 @@ -2987,6 +3171,14 @@ struct option_t MuttVars[] = {
2795 ** option does nothing: mutt will never write out the BCC header
2799 + { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2802 + ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2803 + ** name of original article author) to article that followuped to newsgroup.
2809 diff -udprP mutt-1.5.15.orig/keymap.c mutt-1.5.15/keymap.c
2810 --- mutt-1.5.15.orig/keymap.c 2007-04-02 00:58:56.000000000 +0300
2811 +++ mutt-1.5.15/keymap.c 2007-04-11 17:25:15.000000000 +0300
2812 @@ -629,7 +629,6 @@ void km_init (void)
2813 km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE);
2815 km_bindkey ("x", MENU_PAGER, OP_EXIT);
2816 - km_bindkey ("i", MENU_PAGER, OP_EXIT);
2817 km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE);
2818 km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE);
2819 km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE);
2820 diff -udprP mutt-1.5.15.orig/mailbox.h mutt-1.5.15/mailbox.h
2821 --- mutt-1.5.15.orig/mailbox.h 2007-04-02 00:58:56.000000000 +0300
2822 +++ mutt-1.5.15/mailbox.h 2007-04-11 17:25:15.000000000 +0300
2823 @@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2825 int mx_is_pop (const char *);
2828 +int mx_is_nntp (const char *);
2831 int mx_access (const char*, int);
2832 int mx_check_empty (const char *);
2833 diff -udprP mutt-1.5.15.orig/main.c mutt-1.5.15/main.c
2834 --- mutt-1.5.15.orig/main.c 2007-04-04 08:37:13.000000000 +0300
2835 +++ mutt-1.5.15/main.c 2007-04-11 17:25:15.000000000 +0300
2837 #include <stringprep.h>
2844 static const char *ReachingUs = N_("\
2845 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2846 To report a bug, please visit http://bugs.mutt.org/.\n");
2847 @@ -127,6 +131,8 @@ options:\n\
2848 " -e <command>\tspecify a command to be executed after initialization\n\
2849 -f <file>\tspecify which mailbox to read\n\
2850 -F <file>\tspecify an alternate muttrc file\n\
2851 + -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2852 + -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2853 -H <file>\tspecify a draft file to read header and body from\n\
2854 -i <file>\tspecify a file which Mutt should include in the body\n\
2855 -m <type>\tspecify a default mailbox type\n\
2856 @@ -253,6 +259,12 @@ static void show_version (void)
2869 @@ -521,6 +533,9 @@ static void start_curses (void)
2870 #define M_NOSYSRC (1<<2) /* -n */
2871 #define M_RO (1<<3) /* -R */
2872 #define M_SELECT (1<<4) /* -y */
2874 +#define M_NEWS (1<<5) /* -g and -G */
2877 int main (int argc, char **argv)
2879 @@ -577,7 +592,11 @@ int main (int argc, char **argv)
2884 + while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2886 while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2891 @@ -670,6 +689,20 @@ int main (int argc, char **argv)
2896 + case 'g': /* Specify a newsserver */
2898 + char buf[LONG_STRING];
2900 + snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2901 + commands = mutt_add_list (commands, buf);
2904 + case 'G': /* List of newsgroups */
2905 + flags |= M_SELECT | M_NEWS;
2912 @@ -943,6 +976,18 @@ int main (int argc, char **argv)
2914 else if (flags & M_SELECT)
2917 + if (flags & M_NEWS)
2919 + set_option (OPTNEWS);
2920 + if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2922 + mutt_endwin (Errorbuf);
2929 mutt_endwin _("No incoming mailboxes defined.");
2931 @@ -958,6 +1003,15 @@ int main (int argc, char **argv)
2934 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2937 + if (option (OPTNEWS))
2939 + unset_option (OPTNEWS);
2940 + nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2944 mutt_expand_path (folder, sizeof (folder));
2946 mutt_str_replace (&CurrentFolder, folder);
2947 diff -udprP mutt-1.5.15.orig/mutt.h mutt-1.5.15/mutt.h
2948 --- mutt-1.5.15.orig/mutt.h 2007-04-02 21:04:35.000000000 +0300
2949 +++ mutt-1.5.15/mutt.h 2007-04-11 17:25:15.000000000 +0300
2950 @@ -243,6 +243,9 @@ enum
2958 /* Options for Mailcap lookup */
2960 @@ -298,6 +301,12 @@ enum
2963 OPT_VERIFYSIG, /* verify PGP signatures */
2966 + OPT_NNTPRECONNECT,
2968 + OPT_FOLLOWUPTOPOSTER,
2969 +#endif /* USE_NNTP */
2971 /* THIS MUST BE THE LAST VALUE. */
2973 @@ -313,6 +322,7 @@ enum
2974 #define SENDMAILX (1<<6)
2975 #define SENDKEY (1<<7)
2976 #define SENDRESEND (1<<8)
2977 +#define SENDNEWS (1<<9)
2979 /* flags to _mutt_select_file() */
2980 #define M_SEL_BUFFY (1<<0)
2981 @@ -332,6 +342,8 @@ enum
2990 @@ -404,6 +416,9 @@ enum
2995 + OPTMIMESUBJECT, /* encode subject line with RFC2047 */
3000 @@ -485,6 +500,16 @@ enum
3004 + /* news options */
3008 + OPTSHOWONLYUNREAD,
3012 +#endif /* USE_NNTP */
3014 /* pseudo options */
3016 OPTAUXSORT, /* (pseudo) using auxillary sort function */
3017 @@ -505,6 +530,7 @@ enum
3018 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
3019 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3020 OPTATTACHMSG, /* (pseudo) used by attach-message */
3021 + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3022 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3023 * functions while we are executing an
3025 @@ -515,6 +541,12 @@ enum
3026 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3027 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
3030 + OPTNEWS, /* (pseudo) used to change reader mode */
3031 + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3032 + OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
3038 @@ -592,6 +624,13 @@ typedef struct envelope
3042 + char *organization;
3046 + char *followup_to;
3047 + char *x_comment_to;
3050 LIST *references; /* message references (in reverse order) */
3051 LIST *in_reply_to; /* in-reply-to header content */
3052 @@ -758,6 +797,9 @@ typedef struct header
3053 ENVELOPE *env; /* envelope information */
3054 BODY *content; /* list of MIME parts */
3060 char *tree; /* character string to print thread tree */
3061 struct thread *thread;
3062 @@ -773,7 +815,7 @@ typedef struct header
3063 int refno; /* message number on server */
3066 -#if defined USE_POP || defined USE_IMAP
3067 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3068 void *data; /* driver-specific data */
3071 diff -udprP mutt-1.5.15.orig/muttlib.c mutt-1.5.15/muttlib.c
3072 --- mutt-1.5.15.orig/muttlib.c 2007-04-03 20:52:56.000000000 +0300
3073 +++ mutt-1.5.15/muttlib.c 2007-04-11 17:25:15.000000000 +0300
3074 @@ -286,7 +286,7 @@ void mutt_free_header (HEADER **h)
3076 mutt_free_list (&(*h)->chain);
3078 -#if defined USE_POP || defined USE_IMAP
3079 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3082 FREE (h); /* __FREE_CHECKED__ */
3083 @@ -674,6 +674,13 @@ void mutt_free_envelope (ENVELOPE **p)
3084 FREE (&(*p)->supersedes);
3086 FREE (&(*p)->x_label);
3087 + FREE (&(*p)->organization);
3089 + FREE (&(*p)->newsgroups);
3090 + FREE (&(*p)->xref);
3091 + FREE (&(*p)->followup_to);
3092 + FREE (&(*p)->x_comment_to);
3095 mutt_buffer_free (&(*p)->spam);
3097 @@ -1392,6 +1399,14 @@ int mutt_save_confirm (const char *s, st
3102 + if (magic == M_NNTP)
3104 + mutt_error _("Can't save message to newsserver.");
3109 if (stat (s, st) != -1)
3112 diff -udprP mutt-1.5.15.orig/mx.c mutt-1.5.15/mx.c
3113 --- mutt-1.5.15.orig/mx.c 2007-04-03 20:41:14.000000000 +0300
3114 +++ mutt-1.5.15/mx.c 2007-04-11 17:25:15.000000000 +0300
3115 @@ -348,6 +348,22 @@ int mx_is_pop (const char *p)
3120 +int mx_is_nntp (const char *p)
3122 + url_scheme_t scheme;
3127 + scheme = url_check_scheme (p);
3128 + if (scheme == U_NNTP || scheme == U_NNTPS)
3135 int mx_get_magic (const char *path)
3138 @@ -365,6 +381,11 @@ int mx_get_magic (const char *path)
3140 #endif /* USE_POP */
3143 + if (mx_is_nntp (path))
3145 +#endif /* USE_NNTP */
3147 if (stat (path, &st) == -1)
3149 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
3150 @@ -704,6 +725,12 @@ CONTEXT *mx_open_mailbox (const char *pa
3152 #endif /* USE_POP */
3156 + rc = nntp_open_mailbox (ctx);
3158 +#endif /* USE_NNTP */
3163 @@ -796,6 +823,12 @@ static int sync_mailbox (CONTEXT *ctx, i
3164 rc = pop_sync_mailbox (ctx, index_hint);
3166 #endif /* USE_POP */
3170 + rc = nntp_sync_mailbox (ctx);
3172 +#endif /* USE_NNTP */
3176 @@ -822,6 +855,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
3181 + if (ctx->magic == M_NNTP)
3185 + ret = nntp_close_mailbox (ctx);
3186 + mx_fastclose_mailbox (ctx);
3190 if (ctx->readonly || ctx->dontwrite)
3192 /* mailbox is readonly or we don't want to write */
3193 @@ -1359,6 +1402,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
3195 return (pop_check_mailbox (ctx, index_hint));
3196 #endif /* USE_POP */
3200 + return (nntp_check_mailbox (ctx));
3201 +#endif /* USE_NNTP */
3205 @@ -1419,6 +1467,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
3207 #endif /* USE_POP */
3212 + if (nntp_fetch_message (msg, ctx, msgno) != 0)
3216 +#endif /* USE_NNTP */
3219 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3221 @@ -1500,6 +1557,9 @@ int mx_close_message (MESSAGE **msg)
3223 || (*msg)->magic == M_POP
3226 + || (*msg)->magic == M_NNTP
3230 r = safe_fclose (&(*msg)->fp);
3231 diff -udprP mutt-1.5.15.orig/mx.h mutt-1.5.15/mx.h
3232 --- mutt-1.5.15.orig/mx.h 2007-04-02 00:58:56.000000000 +0300
3233 +++ mutt-1.5.15/mx.h 2007-04-11 17:25:15.000000000 +0300
3234 @@ -40,6 +40,9 @@ enum
3243 WHERE short DefaultMagic INITVAL (M_MBOX);
3244 diff -udprP mutt-1.5.15.orig/newsrc.c mutt-1.5.15/newsrc.c
3245 --- mutt-1.5.15.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3246 +++ mutt-1.5.15/newsrc.c 2007-04-11 18:13:00.000000000 +0300
3249 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3250 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
3251 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
3253 + * This program is free software; you can redistribute it and/or modify
3254 + * it under the terms of the GNU General Public License as published by
3255 + * the Free Software Foundation; either version 2 of the License, or
3256 + * (at your option) any later version.
3258 + * This program is distributed in the hope that it will be useful,
3259 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3260 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3261 + * GNU General Public License for more details.
3263 + * You should have received a copy of the GNU General Public License
3264 + * along with this program; if not, write to the Free Software
3265 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3269 +# include "config.h"
3273 +#include "mutt_curses.h"
3277 +#include "mailbox.h"
3279 +#include "rfc822.h"
3280 +#include "rfc1524.h"
3281 +#include "rfc2047.h"
3283 +#include <unistd.h>
3284 +#include <string.h>
3286 +#include <stdlib.h>
3287 +#include <sys/stat.h>
3289 +void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3296 + l = safe_calloc (1, sizeof (LIST));
3298 + s->tail->next = l;
3302 + l->data = (void *) d;
3305 +static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3308 + char group[LONG_STRING];
3310 + char *p = line, *b, *h;
3320 + while (*p && (*p != ':' && *p != '!')) p++;
3323 + len = p + 1 - line;
3324 + if (len > sizeof (group))
3325 + len = sizeof (group);
3326 + strfcpy (group, line, len);
3327 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3329 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3330 + data->group = (char *) data + sizeof (NNTP_DATA);
3331 + strcpy (data->group, group);
3332 + data->nserv = news;
3333 + data->deleted = 1;
3334 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3335 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3336 + hash_insert (news->newsgroups, data->group, data, 0);
3337 + nntp_add_to_list (news, data);
3340 + FREE ((void **) &data->entries);
3343 + data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3347 + data->subscribed = 1;
3349 + data->subscribed = 0;
3356 + while (*p && *p != ',' && *p != '\n') p++;
3362 + if ((h = strchr(b, '-')))
3366 + data->entries[x].first = atoi(b);
3367 + data->entries[x].last = atoi(h);
3371 + data->entries[x].first = atoi(b);
3372 + data->entries[x].last = data->entries[x].first;
3375 + if (data->entries[x].last != 0)
3378 + if (x && !data->lastMessage)
3379 + data->lastMessage = data->entries[x-1].last;
3381 + mutt_newsgroup_stat (data);
3382 + dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3387 +static int slurp_newsrc (NNTP_SERVER *news)
3393 + news->stat = stat (news->newsrc, &sb);
3394 + news->size = sb.st_size;
3395 + news->mtime = sb.st_mtime;
3397 + if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3399 + /* hmm, should we use dotlock? */
3400 + if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3406 + buf = safe_malloc (sb.st_size + 1);
3407 + while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3408 + nntp_parse_newsrc_line (news, buf);
3411 + mx_unlock_file (news->newsrc, fileno (fp), 0);
3416 +void nntp_cache_expand (char *dst, const char *src)
3418 + snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3419 + mutt_expand_path (dst, _POSIX_PATH_MAX);
3422 +/* Loads $news_cache_dir/.index into memory, loads newsserver data
3423 + * and newsgroup cache names */
3424 +static int nntp_parse_cacheindex (NNTP_SERVER *news)
3427 + char buf[HUGE_STRING], *cp;
3428 + char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3433 + /* check is server name defined or not */
3434 + if (!news || !news->conn || !news->conn->account.host)
3436 + unset_option (OPTNEWSCACHE);
3437 + if (!NewsCacheDir || !*NewsCacheDir)
3440 + strfcpy (dir, NewsCacheDir, sizeof (dir));
3441 + mutt_expand_path (dir, sizeof(dir));
3443 + if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3445 + snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3446 + if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3449 + mutt_error _("Cache directory not created!");
3452 + mutt_clear_error();
3455 + set_option (OPTNEWSCACHE);
3457 + FREE (&news->cache);
3458 + snprintf (buf, sizeof(buf), "%s/.index", dir);
3459 + if (!(index = safe_fopen (buf, "a+")))
3462 + while (fgets (buf, sizeof(buf), index))
3464 + buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3465 + if (!mutt_strncmp (buf, "#: ", 3) &&
3466 + !mutt_strcasecmp (buf+3, news->conn->account.host))
3469 + while (fgets (buf, sizeof(buf), index))
3472 + while (*cp && *cp != ' ') cp++;
3473 + if (!*cp) continue;
3475 + if (!mutt_strcmp (buf, "#:"))
3477 + sscanf (cp + 1, "%s %d %d", file, &l, &m);
3478 + if (!mutt_strcmp (buf, "ALL"))
3480 + news->cache = safe_strdup (file);
3481 + news->newgroups_time = m;
3483 + else if (news->newsgroups)
3485 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3487 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3488 + data->group = (char *) data + sizeof (NNTP_DATA);
3489 + strcpy(data->group, buf);
3490 + data->nserv = news;
3491 + data->deleted = 1;
3492 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3493 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3494 + hash_insert (news->newsgroups, data->group, data, 0);
3495 + nntp_add_to_list (news, data);
3497 + data->cache = safe_strdup (file);
3499 + if (!data->firstMessage || data->lastMessage < m)
3501 + if (!data->firstMessage)
3502 + data->firstMessage = l;
3503 + if (data->lastMessage < m)
3504 + data->lastMessage = m;
3505 + data->lastCached = m;
3506 + if (t || !data->unread)
3507 + mutt_newsgroup_stat (data);
3515 +nntp_format_str (char *dest, size_t destlen, char op, const char *src,
3516 + const char *fmt, const char *ifstring, const char *elsestring,
3517 + unsigned long data, format_flag flags)
3519 + char fn[SHORT_STRING], tmp[SHORT_STRING];
3524 + strncpy (fn, NewsServer, sizeof(fn) - 1);
3525 + mutt_strlower (fn);
3526 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3527 + snprintf (dest, destlen, tmp, fn);
3533 +/* nntp_parse_url: given an NNPT URL, return host, port,
3534 + * username, password and newsgroup will recognise. */
3535 +int nntp_parse_url (const char *server, ACCOUNT *acct,
3536 + char *group, size_t group_len)
3544 + acct->port = NNTP_PORT;
3545 + acct->type = M_ACCT_TYPE_NNTP;
3547 + c = safe_strdup (server);
3548 + url_parse_ciss (&url, c);
3550 + if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3552 + if (url.scheme == U_NNTPS)
3554 + acct->flags |= M_ACCT_SSL;
3555 + acct->port = NNTP_SSL_PORT;
3560 + strfcpy (group, url.path, group_len);
3562 + ret = mutt_account_fromurl (acct, &url);
3569 +void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3573 + url.path = safe_strdup (line);
3574 + mutt_account_tourl (acct, &url);
3575 + url_ciss_tostring (&url, line, len, 0);
3580 + * Automatically loads a newsrc into memory, if necessary.
3581 + * Checks the size/mtime of a newsrc file, if it doesn't match, load
3582 + * again. Hmm, if a system has broken mtimes, this might mean the file
3583 + * is reloaded every time, which we'd have to fix.
3585 + * a newsrc file is a line per newsgroup, with the newsgroup, then a
3586 + * ':' denoting subscribed or '!' denoting unsubscribed, then a
3587 + * comma separated list of article numbers and ranges.
3589 +NNTP_SERVER *mutt_select_newsserver (char *server)
3591 + char file[_POSIX_PATH_MAX];
3595 + NNTP_SERVER *serv;
3598 + if (!server || !*server)
3600 + mutt_error _("No newsserver defined!");
3604 + buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3605 + if (url_check_scheme (server) == U_UNKNOWN)
3607 + strcpy (buf, "news://");
3608 + p = strchr (buf, '\0');
3610 + strcpy (p, server);
3612 + if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3615 + mutt_error (_("%s is an invalid newsserver specification!"), server);
3620 + conn = mutt_conn_find (NULL, &acct);
3624 + mutt_FormatString (file, sizeof (file), NONULL (NewsRc), nntp_format_str, 0, 0);
3625 + mutt_expand_path (file, sizeof (file));
3627 + serv = (NNTP_SERVER *)conn->data;
3632 + /* externally modified? */
3633 + if (serv->stat != stat (file, &sb) || (!serv->stat &&
3634 + (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3636 + for (list = serv->list; list; list = list->next)
3638 + NNTP_DATA *data = (NNTP_DATA *) list->data;
3642 + data->subscribed = 0;
3647 + slurp_newsrc (serv);
3648 + nntp_clear_cacheindex (serv);
3651 + if (serv->status == NNTP_BYE)
3652 + serv->status = NNTP_NONE;
3653 + nntp_check_newgroups (serv, 0);
3657 + /* New newsserver */
3658 + serv = safe_calloc (1, sizeof (NNTP_SERVER));
3659 + serv->conn = conn;
3660 + serv->newsrc = safe_strdup (file);
3661 + serv->newsgroups = hash_create (1009);
3662 + slurp_newsrc (serv); /* load .newsrc */
3663 + nntp_parse_cacheindex (serv); /* load .index */
3664 + if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3665 + nntp_check_newgroups (serv, 1);
3666 + else if (nntp_get_active (serv) < 0)
3668 + hash_destroy (&serv->newsgroups, nntp_delete_data);
3669 + for (list = serv->list; list; list = list->next)
3670 + list->data = NULL;
3671 + mutt_free_list (&serv->list);
3672 + FREE (&serv->newsrc);
3673 + FREE (&serv->cache);
3677 + nntp_clear_cacheindex (serv);
3678 + conn->data = (void *)serv;
3684 + * full status flags are not supported by nntp, but we can fake some
3685 + * of them. This is how:
3686 + * Read = a read message number is in the .newsrc
3687 + * New = a message is new since we last read this newsgroup
3688 + * Old = anything else
3689 + * So, Read is marked as such in the newsrc, old is anything that is
3690 + * "skipped" in the newsrc, and new is anything not in the newsrc nor
3691 + * in the cache. By skipped, I mean before the last unread message
3693 +void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3695 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3699 + data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3705 + dprint (3, (debugfile, "newsgroup %s not found\n", group));
3710 + for (x = 0; x < data->num; x++)
3712 + if ((article >= data->entries[x].first) &&
3713 + (article <= data->entries[x].last))
3715 + /* we cannot use mutt_set_flag() because mx_update_context()
3716 + didn't called yet */
3721 + /* If article was not cached yet, it is new! :) */
3722 + if (!data->cache || article > data->lastCached)
3724 + /* Old articles are articles which aren't read but an article after them
3725 + * has been cached */
3726 + if (option (OPTMARKOLD))
3730 +void mutt_newsgroup_stat (NNTP_DATA *data)
3733 + unsigned int first, last;
3736 + if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3739 + data->unread = data->lastMessage - data->firstMessage + 1;
3740 + for (i = 0; i < data->num; i++)
3742 + first = data->entries[i].first;
3743 + if (first < data->firstMessage)
3744 + first = data->firstMessage;
3745 + last = data->entries[i].last;
3746 + if (last > data->lastMessage)
3747 + last = data->lastMessage;
3748 + if (first <= last)
3749 + data->unread -= last - first + 1;
3753 +static int puti (char *line, int num)
3757 + for (p = s; num; )
3759 + *p++ = '0' + num % 10;
3763 + *line++ = *--p, num++;
3768 +static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3770 + char *line = *pline;
3771 + size_t len = *buflen - (*pline - *buf);
3774 + if (len < LONG_STRING * 10)
3779 + safe_realloc (buf, *buflen);
3780 + line = *buf + (*pline - line);
3782 + strcpy (line, data->group);
3783 + len -= strlen (line) + 1;
3784 + line += strlen (line);
3785 + *line++ = data->subscribed ? ':' : '!';
3789 + for (x = 0; x < data->num; x++)
3791 + if (len < LONG_STRING)
3797 + safe_realloc (buf, *buflen);
3798 + line = *buf + (*pline - line);
3807 + if (data->entries[x].first == data->entries[x].last)
3808 + snprintf (line, len, "%d%n", data->entries[x].first, &i);
3810 + snprintf (line, len, "%d-%d%n",
3811 + data->entries[x].first, data->entries[x].last, &i);
3815 + i = puti (line, data->entries[x].first);
3816 + line +=i; len -= i;
3817 + if (data->entries[x].first != data->entries[x].last)
3821 + i = puti (line, data->entries[x].last);
3822 + line +=i; len -= i;
3831 +void newsrc_gen_entries (CONTEXT *ctx)
3833 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3835 + unsigned int last = 0, first = 1;
3836 + int save_sort = SORT_ORDER;
3838 + if (Sort != SORT_ORDER)
3841 + Sort = SORT_ORDER;
3842 + mutt_sort_headers (ctx, 0);
3847 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3852 + * Set up to fake initial sequence from 1 to the article before the
3853 + * first article in our list
3858 + for (x = 0; x < ctx->msgcount; x++)
3860 + if (series) /* search for first unread */
3863 + * We don't actually check sequential order, since we mark
3864 + * "missing" entries as read/deleted
3866 + last = ctx->hdrs[x]->article_num;
3867 + if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3868 + !ctx->hdrs[x]->read)
3870 + if (data->num >= data->max)
3872 + data->max = data->max * 2;
3873 + safe_realloc (&data->entries,
3874 + data->max * sizeof (NEWSRC_ENTRY));
3876 + data->entries[data->num].first = first;
3877 + data->entries[data->num].last = last - 1;
3882 + else /* search for first read */
3884 + if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3889 + last = ctx->hdrs[x]->article_num;
3892 + if (series && first <= data->lastLoaded)
3894 + if (data->num >= data->max)
3896 + data->max = data->max * 2;
3897 + safe_realloc (&data->entries,
3898 + data->max * sizeof (NEWSRC_ENTRY));
3900 + data->entries[data->num].first = first;
3901 + data->entries[data->num].last = data->lastLoaded;
3905 + if (save_sort != Sort)
3908 + mutt_sort_headers (ctx, 0);
3912 +static int mutt_update_list_file (char *filename, char *section,
3913 + char *key, char *line)
3917 + char buf[HUGE_STRING];
3918 + char tmpfile[_POSIX_PATH_MAX];
3920 + int ext = 0, done = 0, r = 0;
3922 + /* if file not exist, create it */
3923 + if ((ifp = safe_fopen (filename, "a")))
3925 + dprint (1, (debugfile, "Opening %s\n", filename));
3926 + if (!(ifp = safe_fopen (filename, "r")))
3928 + mutt_error (_("Unable to open %s for reading"), filename);
3931 + if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3934 + mutt_error (_("Unable to lock %s"), filename);
3937 + snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3938 + dprint (1, (debugfile, "Opening %s\n", tmpfile));
3939 + if (!(ofp = fopen (tmpfile, "w")))
3942 + mutt_error (_("Unable to open %s for writing"), tmpfile);
3948 + while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3950 + r = fputs (buf, ofp);
3952 + while (*c && *c != '\n') c++;
3953 + c[0] = 0; /* strip EOL */
3954 + if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3957 + if (r != EOF && !done)
3959 + snprintf (buf, sizeof(buf), "#: %s\n", section);
3960 + r = fputs (buf, ofp);
3965 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3970 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3972 + if (*c != '\\') ext = 0;
3974 + else if ((section && !strncmp (buf, "#: ", 3)))
3976 + if (!done && line)
3978 + fputs (line, ofp);
3979 + fputc ('\n', ofp);
3981 + r = fputs (buf, ofp);
3985 + else if (key && !strncmp (buf, key, strlen(key)) &&
3986 + (!*key || buf[strlen(key)] == ' '))
3990 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3992 + if (*c == '\\') ext = 1;
3993 + if (!done && line)
3995 + r = fputs (line, ofp);
3997 + r = fputc ('\n', ofp);
4003 + r = fputs (buf, ofp);
4007 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
4008 + r = fputs (buf, ofp);
4010 + /* If there wasn't a line to replace, put it on the end of the file */
4011 + if (r != EOF && !done && line)
4013 + fputs (line, ofp);
4014 + r = fputc ('\n', ofp);
4016 + mx_unlock_file (filename, fileno (ifp), 0);
4022 + mutt_error (_("Can't write %s"), tmpfile);
4025 + if (rename (tmpfile, filename) < 0)
4028 + mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
4034 +int mutt_newsrc_update (NNTP_SERVER *news)
4044 + llen = len = 10 * LONG_STRING;
4045 + line = buf = safe_calloc (1, len);
4046 + /* we will generate full newsrc here */
4047 + for (tmp = news->list; tmp; tmp = tmp->next)
4049 + data = (NNTP_DATA *) tmp->data;
4050 + if (!data || !data->rc)
4052 + nntp_create_newsrc_line (data, &buf, &line, &llen);
4054 + dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4055 + line += strlen (line);
4057 + /* newrc being fully rewritten */
4058 + if (news->newsrc &&
4059 + (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4063 + stat (news->newsrc, &st);
4064 + news->size = st.st_size;
4065 + news->mtime = st.st_mtime;
4071 +static FILE *mutt_mkname (char *s)
4073 + char buf[_POSIX_PATH_MAX], *pc;
4077 + nntp_cache_expand (buf, s);
4078 + if ((fp = safe_fopen (buf, "w")))
4081 + nntp_cache_expand (buf, "cache-XXXXXX");
4082 + pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4083 + if ((fd = mkstemp (buf)) == -1)
4085 + strcpy (s, pc); /* generated name */
4086 + return fdopen (fd, "w");
4089 +/* Updates info into .index file: ALL or about selected newsgroup */
4090 +static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4092 + char buf[LONG_STRING], *key = "ALL";
4093 + char file[_POSIX_PATH_MAX];
4095 + if (!serv || !serv->conn || !serv->conn->account.host)
4098 + if (data && data->group)
4100 + key = data->group;
4101 + snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4102 + data->firstMessage, data->lastLoaded);
4106 + strfcpy (file, serv->cache, sizeof (file));
4107 + snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4109 + nntp_cache_expand (file, ".index");
4110 + return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4113 +/* Remove cache files of unsubscribed newsgroups */
4114 +void nntp_clear_cacheindex (NNTP_SERVER *news)
4119 + if (option (OPTSAVEUNSUB) || !news)
4122 + for (tmp = news->list; tmp; tmp = tmp->next)
4124 + data = (NNTP_DATA *) tmp->data;
4125 + if (!data || data->subscribed || !data->cache)
4127 + nntp_delete_cache (data);
4128 + dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4133 +int nntp_save_cache_index (NNTP_SERVER *news)
4135 + char buf[HUGE_STRING];
4136 + char file[_POSIX_PATH_MAX];
4141 + if (!news || !news->newsgroups)
4143 + if (!option (OPTNEWSCACHE))
4148 + nntp_cache_expand (file, news->cache);
4150 + f = safe_fopen (file, "w");
4154 + strfcpy (buf, news->conn->account.host, sizeof(buf));
4155 + f = mutt_mkname (buf);
4156 + news->cache = safe_strdup (buf);
4157 + nntp_cache_expand (file, buf);
4162 + for (l = news->list; l; l = l->next)
4164 + if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4167 + snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4168 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4171 + snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4172 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4173 + if (fputs (buf, f) == EOF)
4183 + if (nntp_update_cacheindex (news, NULL))
4191 +int nntp_save_cache_group (CONTEXT *ctx)
4193 + char buf[HUGE_STRING], addr[STRING];
4194 + char file[_POSIX_PATH_MAX];
4198 + int i = 0, save = SORT_ORDER;
4201 + if (!option (OPTNEWSCACHE))
4203 + if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4206 + if (((NNTP_DATA *)ctx->data)->cache)
4208 + nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4210 + f = safe_fopen (file, "w");
4214 + snprintf (buf, sizeof(buf), "%s-%s",
4215 + ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4216 + ((NNTP_DATA *)ctx->data)->group);
4217 + f = mutt_mkname (buf);
4218 + ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4219 + nntp_cache_expand (file, buf);
4224 + if (Sort != SORT_ORDER)
4227 + Sort = SORT_ORDER;
4228 + mutt_sort_headers (ctx, 0);
4231 + /* Save only $nntp_context messages... */
4232 + ((NNTP_DATA *)ctx->data)->lastCached = 0;
4233 + if (NntpContext && ctx->msgcount > NntpContext)
4234 + i = ctx->msgcount - NntpContext;
4235 + for (; i < ctx->msgcount; i++)
4237 + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4241 + rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4242 + tm = gmtime (&h->date_sent);
4243 + snprintf (buf, sizeof(buf),
4244 + "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4245 + h->article_num, h->env->subject, addr, tm->tm_mday,
4246 + Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4247 + tm->tm_sec, h->env->message_id);
4249 + if (h->env->references)
4250 + mutt_write_references (h->env->references, f);
4251 + snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length,
4252 + (int) h->lines, NONULL(h->env->xref));
4253 + if (fputs (buf, f) == EOF)
4260 + prev = ctx->hdrs[i]->article_num;
4266 + mutt_sort_headers (ctx, 0);
4270 + if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4271 + (NNTP_DATA *)ctx->data))
4276 + ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4280 +void nntp_delete_cache (NNTP_DATA *data)
4282 + char buf[_POSIX_PATH_MAX];
4284 + if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4287 + nntp_cache_expand (buf, data->cache);
4289 + FREE (&data->cache);
4290 + data->lastCached = 0;
4291 + nntp_cache_expand (buf, ".index");
4292 + mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4295 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4299 + if (!news || !news->newsgroups || !group || !*group)
4301 + if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4303 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4304 + data->group = (char *) data + sizeof (NNTP_DATA);
4305 + strcpy (data->group, group);
4306 + data->nserv = news;
4307 + data->deleted = 1;
4308 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4309 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
4310 + hash_insert (news->newsgroups, data->group, data, 0);
4311 + nntp_add_to_list (news, data);
4313 + if (!data->subscribed)
4315 + data->subscribed = 1;
4321 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4325 + if (!news || !news->newsgroups || !group || !*group ||
4326 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4328 + if (data->subscribed)
4330 + data->subscribed = 0;
4331 + if (!option (OPTSAVEUNSUB))
4337 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4341 + if (!news || !news->newsgroups || !group || !*group ||
4342 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4346 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4350 + data->entries[0].first = 1;
4352 + data->entries[0].last = data->lastMessage;
4353 + if (Context && Context->data == data)
4357 + for (x = 0; x < Context->msgcount; x++)
4358 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4363 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4367 + if (!news || !news->newsgroups || !group || !*group ||
4368 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4372 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4376 + data->entries[0].first = 1;
4377 + data->entries[0].last = data->firstMessage - 1;
4378 + if (Context && Context->data == data)
4382 + data->unread = Context->msgcount;
4383 + for (x = 0; x < Context->msgcount; x++)
4384 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4387 + data->unread = data->lastMessage - data->entries[0].last;
4391 +/* this routine gives the first newsgroup with new messages */
4392 +void nntp_buffy (char *s)
4396 + for (list = CurrentNewsSrv->list; list; list = list->next)
4398 + NNTP_DATA *data = (NNTP_DATA *) list->data;
4400 + if (data && data->subscribed && data->unread)
4402 + if (Context && Context->magic == M_NNTP &&
4403 + !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4405 + unsigned int i, unread = 0;
4407 + for (i = 0; i < Context->msgcount; i++)
4408 + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4413 + strcpy (s, data->group);
4418 diff -udprP mutt-1.5.15.orig/nntp.c mutt-1.5.15/nntp.c
4419 --- mutt-1.5.15.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4420 +++ mutt-1.5.15/nntp.c 2007-04-11 17:48:16.000000000 +0300
4423 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4424 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4425 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
4427 + * This program is free software; you can redistribute it and/or modify
4428 + * it under the terms of the GNU General Public License as published by
4429 + * the Free Software Foundation; either version 2 of the License, or
4430 + * (at your option) any later version.
4432 + * This program is distributed in the hope that it will be useful,
4433 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4434 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4435 + * GNU General Public License for more details.
4437 + * You should have received a copy of the GNU General Public License
4438 + * along with this program; if not, write to the Free Software
4439 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4443 +# include "config.h"
4447 +#include "mutt_curses.h"
4451 +#include "rfc1524.h"
4452 +#include "rfc2047.h"
4453 +#include "mailbox.h"
4464 +#include <unistd.h>
4465 +#include <string.h>
4467 +#include <stdlib.h>
4469 +static unsigned int _checked = 0;
4472 +static void nntp_error (const char *where, const char *msg)
4474 + dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4478 +static int nntp_auth (NNTP_SERVER *serv)
4480 + CONNECTION *conn = serv->conn;
4482 + unsigned char flags = conn->account.flags;
4484 + if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4485 + mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4487 + conn->account.flags = flags;
4491 + mutt_message _("Logging in...");
4493 + snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4494 + mutt_socket_write (conn, buf);
4495 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4497 + conn->account.flags = flags;
4502 + /* don't print the password unless we're at the ungodly debugging level */
4503 + if (debuglevel < M_SOCK_LOG_FULL)
4504 + dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4506 + snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4507 + mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4508 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4510 + conn->account.flags = flags;
4514 + if (mutt_strncmp ("281", buf, 3))
4516 + conn->account.flags = flags;
4517 + mutt_error _("Login failed.");
4525 +static int nntp_connect_error (NNTP_SERVER *serv)
4527 + serv->status = NNTP_NONE;
4528 + mutt_socket_close (serv->conn);
4529 + mutt_error _("Server closed connection!");
4534 +static int nntp_connect_and_auth (NNTP_SERVER *serv)
4536 + CONNECTION *conn = serv->conn;
4540 + serv->status = NNTP_NONE;
4542 + if (mutt_socket_open (conn) < 0)
4545 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4546 + return nntp_connect_error (serv);
4548 + if (!mutt_strncmp ("200", buf, 3))
4549 + mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4550 + else if (!mutt_strncmp ("201", buf, 3))
4551 + mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4554 + mutt_socket_close (conn);
4555 + mutt_remove_trailing_ws (buf);
4556 + mutt_error ("%s", buf);
4563 + /* Tell INN to switch to mode reader if it isn't so. Ignore all
4564 + returned codes and messages. */
4565 + mutt_socket_write (conn, "MODE READER\r\n");
4566 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4567 + return nntp_connect_error (serv);
4569 + mutt_socket_write (conn, "STAT\r\n");
4570 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4571 + return nntp_connect_error (serv);
4573 + if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
4575 + serv->status = NNTP_OK;
4579 + rc = nntp_auth (serv);
4581 + return nntp_connect_error (serv);
4584 + mutt_socket_close (conn);
4585 + serv->status = NNTP_BYE;
4590 + mutt_socket_close (conn);
4591 + mutt_error _("Login failed.");
4595 + serv->status = NNTP_OK;
4599 +static int nntp_attempt_features (NNTP_SERVER *serv)
4601 + char buf[LONG_STRING];
4602 + CONNECTION *conn = serv->conn;
4604 + mutt_socket_write (conn, "XOVER\r\n");
4605 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4606 + return nntp_connect_error (serv);
4607 + if (mutt_strncmp ("500", buf, 3))
4608 + serv->hasXOVER = 1;
4610 + mutt_socket_write (conn, "XPAT\r\n");
4611 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4612 + return nntp_connect_error (serv);
4613 + if (mutt_strncmp ("500", buf, 3))
4614 + serv->hasXPAT = 1;
4616 + mutt_socket_write (conn, "LISTGROUP\r\n");
4617 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4618 + return nntp_connect_error (serv);
4619 + if (mutt_strncmp ("500", buf, 3))
4620 + serv->hasLISTGROUP = 1;
4622 + mutt_socket_write (conn, "XGTITLE +\r\n");
4623 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4624 + return nntp_connect_error (serv);
4625 + if (mutt_strncmp ("500", buf, 3))
4626 + serv->hasXGTITLE = 1;
4628 + if (!mutt_strncmp ("282", buf, 3))
4632 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4633 + return nntp_connect_error (serv);
4634 + } while (!(buf[0] == '.' && buf[1] == '\0'));
4640 +static int nntp_open_connection (NNTP_SERVER *serv)
4642 + if (serv->status == NNTP_OK)
4644 + if (serv->status == NNTP_BYE)
4646 + if (nntp_connect_and_auth (serv) < 0)
4648 + if (nntp_attempt_features (serv) < 0)
4653 +static int nntp_reconnect (NNTP_SERVER *serv)
4655 + char buf[SHORT_STRING];
4657 + mutt_socket_close (serv->conn);
4661 + if (nntp_connect_and_auth (serv) == 0)
4664 + snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
4665 + serv->conn->account.host);
4666 + if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
4668 + serv->status = NNTP_BYE;
4674 +/* Send data from line[LONG_STRING] and receive answer to same line */
4675 +static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
4677 + char buf[LONG_STRING];
4680 + if (data->nserv->status == NNTP_BYE)
4687 + mutt_socket_write (data->nserv->conn, line);
4689 + else if (data->group)
4691 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4692 + mutt_socket_write (data->nserv->conn, buf);
4696 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4698 + if (nntp_reconnect (data->nserv) < 0)
4703 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4704 + mutt_socket_write (data->nserv->conn, buf);
4705 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4711 + else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
4715 + strfcpy (line, buf, linelen);
4720 + * This function calls funct(*line, *data) for each received line,
4721 + * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
4724 + * 1 - correct but not performed (may be, have to be continued),
4725 + * -1 - conection lost,
4726 + * -2 - invalid command or execution error,
4727 + * -3 - error in funct(*line, *data).
4729 +static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
4730 + int (*funct) (char *, void *), void *data, int tagged)
4732 + char buf[LONG_STRING];
4736 + size_t lenbuf = 0;
4741 + strfcpy (buf, query, sizeof (buf));
4742 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
4744 + if (buf[0] == '5')
4746 + if (buf[0] != '2')
4751 + inbuf = safe_malloc (sizeof (buf));
4755 + chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
4761 + if (!lenbuf && buf[0] == '.')
4763 + if (buf[1] == '\0')
4768 + if (buf[1] == '.')
4772 + strfcpy (inbuf + lenbuf, p, sizeof (buf));
4774 + if (chunk >= sizeof (buf))
4776 + lenbuf += strlen (p);
4781 + if (msg && ReadInc && (line % ReadInc == 0)) {
4783 + mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
4785 + mutt_message ("%s %d", msg, line);
4788 + if (ret == 0 && funct (inbuf, data) < 0)
4793 + safe_realloc (&inbuf, lenbuf + sizeof (buf));
4796 + funct (NULL, data);
4802 +static int nntp_read_tempfile (char *line, void *file)
4804 + FILE *f = (FILE *)file;
4811 + if (fputc ('\n', f) == EOF)
4817 +static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
4819 + register char *p, *b;
4820 + register char *colon = NULL;
4825 + /* skip to next word */
4827 + while (*b && ((*b == ' ') || (*b == '\t'))) b++;
4830 + /* skip to end of word */
4831 + while (*p && (*p != ' ') && (*p != '\t'))
4846 + nntp_get_status (ctx, h, b, atoi(colon));
4847 + if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
4848 + h->article_num = atoi(colon);
4856 + * 1 if article not found
4857 + * -1 if read or write error on tempfile or socket
4859 +static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
4861 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
4863 + char buf[LONG_STRING];
4864 + char tempfile[_POSIX_PATH_MAX];
4866 + HEADER *h = ctx->hdrs[ctx->msgcount];
4868 + mutt_mktemp (tempfile);
4869 + if (!(f = safe_fopen (tempfile, "w+")))
4873 + snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
4875 + snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
4877 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
4882 + dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
4885 + unlink (tempfile);
4886 + return (ret == -1 ? -1 : 1);
4889 + h->article_num = article_num;
4890 + h->env = mutt_read_rfc822_header (f, h, 0, 0);
4892 + unlink (tempfile);
4894 + if (h->env->xref != NULL)
4895 + nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
4896 + else if (h->article_num == 0 && msgid)
4898 + snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
4899 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
4900 + h->article_num = atoi (buf + 4);
4906 +static int parse_description (char *line, void *n)
4908 +#define news ((NNTP_SERVER *) n)
4909 + register char *d = line;
4914 + while (*d && *d != '\t' && *d != ' ') d++;
4917 + while (*d && (*d == '\t' || *d == ' ')) d++;
4918 + dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
4919 + if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
4920 + mutt_strcmp (d, data->desc))
4922 + FREE (&data->desc);
4923 + data->desc = safe_strdup (d);
4929 +static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
4933 + if (!option (OPTLOADDESC) || !data || !data->nserv)
4936 + /* Get newsgroup description, if we can */
4937 + if (data->nserv->hasXGTITLE)
4938 + snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
4940 + snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
4941 + if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
4944 + nntp_error ("nntp_get_desc()", buf);
4950 + * XOVER returns a tab separated list of:
4951 + * id|subject|from|date|Msgid|references|bytes|lines|xref
4953 + * This has to duplicate some of the functionality of
4954 + * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
4955 + * a limited number of headers which are "parsed" by placement in the list)
4957 +static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
4959 + NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
4963 + hdr->env = mutt_new_envelope();
4964 + hdr->env->newsgroups = safe_strdup (nntp_data->group);
4965 + hdr->content = mutt_new_body();
4966 + hdr->content->type = TYPETEXT;
4967 + hdr->content->subtype = safe_strdup ("plain");
4968 + hdr->content->encoding = ENC7BIT;
4969 + hdr->content->disposition = DISPINLINE;
4970 + hdr->content->length = -1;
4973 + for (x = 0; !done && x < 9; x++)
4975 + /* if from file, need to skip newline character */
4976 + while (*p && *p != '\n' && *p != '\t') p++;
4984 + hdr->article_num = atoi (b);
4985 + nntp_get_status (ctx, hdr, NULL, hdr->article_num);
4988 + hdr->env->subject = safe_strdup (b);
4989 + /* Now we need to do the things which would normally be done in
4990 + * mutt_read_rfc822_header() */
4991 + if (hdr->env->subject)
4993 + regmatch_t pmatch[1];
4995 + rfc2047_decode (&hdr->env->subject);
4997 + if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
4998 + hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
5000 + hdr->env->real_subj = hdr->env->subject;
5004 + rfc822_free_address (&hdr->env->from);
5005 + hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
5006 + rfc2047_decode_adrlist (hdr->env->from);
5009 + hdr->date_sent = mutt_parse_date (b, hdr);
5010 + hdr->received = hdr->date_sent;
5013 + FREE (&hdr->env->message_id);
5014 + hdr->env->message_id = safe_strdup (b);
5017 + mutt_free_list (&hdr->env->references);
5018 + hdr->env->references = mutt_parse_references (b, 0);
5021 + hdr->content->length = atoi (b);
5024 + hdr->lines = atoi (b);
5028 + FREE (&hdr->env->xref);
5029 + b = b + 6; /* skips the "Xref: " */
5030 + hdr->env->xref = safe_strdup (b);
5031 + nntp_parse_xref (ctx, nntp_data->group, b, hdr);
5043 + unsigned int base;
5044 + unsigned int first;
5045 + unsigned int last;
5046 + unsigned short *messages;
5050 +#define fc ((FETCH_CONTEXT *) c)
5051 +static int nntp_fetch_numbers (char *line, void *c)
5057 + num = atoi (line);
5058 + if (num < fc->base || num > fc->last)
5060 + fc->messages[num - fc->base] = 1;
5064 +static int add_xover_line (char *line, void *c)
5066 + unsigned int num, total;
5067 + CONTEXT *ctx = fc->ctx;
5068 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5073 + if (ctx->msgcount >= ctx->hdrmax)
5074 + mx_alloc_memory (ctx);
5075 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5076 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5078 + nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5079 + num = ctx->hdrs[ctx->msgcount]->article_num;
5081 + if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5084 + if (num > data->lastLoaded)
5085 + data->lastLoaded = num;
5086 + num = num - fc->first + 1;
5087 + total = fc->last - fc->first + 1;
5088 + if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5089 + mutt_message ("%s %d/%d", fc->msg, num, total);
5092 + mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5098 +static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5099 + unsigned int last)
5101 + char buf[HUGE_STRING];
5102 + char *msg = _("Fetching message headers...");
5103 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5107 + unsigned int current;
5111 + /* if empty group or nothing to do */
5112 + if (!last || first > last)
5115 + /* fetch list of articles */
5119 + fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5120 + if (nntp_data->nserv->hasLISTGROUP)
5122 + mutt_message _("Fetching list of articles...");
5123 + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5124 + if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5126 + mutt_error (_("LISTGROUP command failed: %s"), buf);
5128 + nntp_error ("nntp_fetch_headers()", buf);
5130 + FREE (&fc.messages);
5136 + for (num = 0; num < last - first + 1; num++)
5137 + fc.messages[num] = 1;
5140 + /* CACHE: must be loaded xover cache here */
5141 + num = nntp_data->lastCached - first + 1;
5142 + if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5144 + nntp_cache_expand (buf, nntp_data->cache);
5145 + mutt_message _("Fetching headers from cache...");
5146 + if ((f = safe_fopen (buf, "r")))
5150 + /* counting number of lines */
5151 + while (fgets (buf, sizeof (buf), f) != NULL)
5154 + while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5156 + oldmsgcount = ctx->msgcount;
5158 + fc.last = first + num - 1;
5160 + while (fgets (buf, sizeof (buf), f) != NULL)
5161 + add_xover_line (buf, &fc);
5163 + nntp_data->lastLoaded = fc.last;
5164 + first = fc.last + 1;
5165 + if (ctx->msgcount > oldmsgcount)
5166 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5169 + nntp_delete_cache (nntp_data);
5171 + num = last - first + 1;
5174 + FREE (&fc.messages);
5179 + * Without XOVER, we have to fetch each article header and parse
5180 + * it. With XOVER, we ask for all of them
5182 + mutt_message (msg);
5183 + if (nntp_data->nserv->hasXOVER)
5185 + oldmsgcount = ctx->msgcount;
5189 + snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5190 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5191 + if (ctx->msgcount > oldmsgcount)
5192 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5195 + mutt_error (_("XOVER command failed: %s"), buf);
5197 + nntp_error ("nntp_fetch_headers()", buf);
5199 + FREE (&fc.messages);
5205 + for (current = first; current <= last; current++)
5209 + ret = current - first + 1;
5210 + mutt_message ("%s %d/%d", msg, ret, num);
5212 + if (!fc.messages[current - fc.base])
5215 + if (ctx->msgcount >= ctx->hdrmax)
5216 + mx_alloc_memory (ctx);
5217 + h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5218 + h->index = ctx->msgcount;
5220 + ret = nntp_read_header (ctx, NULL, current);
5221 + if (ret == 0) /* Got article. Fetch next header */
5223 + nntp_get_status (ctx, h, NULL, h->article_num);
5225 + mx_update_context (ctx, 1);
5228 + mutt_free_header (&h); /* skip it */
5231 + FREE (&fc.messages);
5235 + if (current > nntp_data->lastLoaded)
5236 + nntp_data->lastLoaded = current;
5238 + FREE (&fc.messages);
5239 + nntp_data->lastLoaded = last;
5240 + mutt_clear_error ();
5245 + * currently, nntp "mailbox" is "newsgroup"
5247 +int nntp_open_mailbox (CONTEXT *ctx)
5249 + NNTP_DATA *nntp_data;
5250 + NNTP_SERVER *serv;
5251 + char buf[HUGE_STRING];
5252 + char server[LONG_STRING];
5254 + unsigned int first;
5257 + if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5259 + mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5265 + nntp_expand_path (server, sizeof (server), &acct);
5266 + if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5269 + CurrentNewsSrv = serv;
5271 + /* create NNTP-specific state struct if nof found in list */
5272 + if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5274 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5275 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5276 + strcpy (nntp_data->group, buf);
5277 + hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5278 + nntp_add_to_list (serv, nntp_data);
5280 + ctx->data = nntp_data;
5281 + ctx->mx_close = nntp_fastclose_mailbox;
5282 + nntp_data->nserv = serv;
5284 + mutt_message (_("Selecting %s..."), nntp_data->group);
5286 + if (!nntp_data->desc)
5288 + nntp_get_desc (nntp_data, nntp_data->group, NULL);
5289 + if (nntp_data->desc)
5290 + nntp_save_cache_index (serv);
5294 + if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5297 + nntp_error ("nntp_open_mailbox()", buf);
5302 + if (mutt_strncmp ("211", buf, 3))
5304 + LIST *l = serv->list;
5306 + /* GROUP command failed */
5307 + if (!mutt_strncmp ("411", buf, 3))
5309 + mutt_error (_("Newsgroup %s not found on server %s"),
5310 + nntp_data->group, serv->conn->account.host);
5312 + /* CACHE: delete cache and line from .index */
5313 + nntp_delete_cache (nntp_data);
5314 + hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5315 + while (l && l->data != (void *) nntp_data) l = l->next;
5325 + sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5326 + &nntp_data->lastMessage, buf);
5328 + nntp_data->deleted = 0;
5330 + time (&serv->check_time);
5333 + * Check for max adding context. If it is greater than $nntp_context,
5334 + * strip off extra articles
5336 + first = nntp_data->firstMessage;
5337 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5338 + first = nntp_data->lastMessage - NntpContext + 1;
5340 + nntp_data->lastLoaded = first - 1;
5341 + return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5344 +int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5346 + char buf[LONG_STRING];
5347 + char path[_POSIX_PATH_MAX];
5348 + NNTP_CACHE *cache;
5349 + char *m = _("Fetching message...");
5352 + /* see if we already have the message in our cache */
5353 + cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5355 + /* if everything is fine, assign msg->fp and return */
5356 + if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5357 + (msg->fp = fopen (cache->path, "r")))
5360 + /* clear the previous entry */
5361 + unlink (cache->path);
5362 + free (cache->path);
5366 + cache->index = ctx->hdrs[msgno]->index;
5367 + mutt_mktemp (path);
5368 + cache->path = safe_strdup (path);
5369 + if (!(msg->fp = safe_fopen (path, "w+")))
5371 + FREE (&cache->path);
5375 + if (ctx->hdrs[msgno]->article_num == 0)
5376 + snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5377 + ctx->hdrs[msgno]->env->message_id);
5379 + snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5380 + ctx->hdrs[msgno]->article_num);
5382 + ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5383 + msg->fp, ctx->tagged);
5386 + mutt_error (_("Article %d not found on server"),
5387 + ctx->hdrs[msgno]->article_num);
5388 + dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5395 + FREE (&cache->path);
5399 + mutt_free_envelope (&ctx->hdrs[msgno]->env);
5400 + ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5401 + /* fix content length */
5402 + fseek(msg->fp, 0, SEEK_END);
5403 + ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5404 + ctx->hdrs[msgno]->content->offset;
5406 + /* this is called in mutt before the open which fetches the message,
5407 + * which is probably wrong, but we just call it again here to handle
5408 + * the problem instead of fixing it.
5410 + mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5412 + /* These would normally be updated in mx_update_context(), but the
5413 + * full headers aren't parsed with XOVER, so the information wasn't
5416 +#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5417 + ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5418 +#endif /* HAVE_PGP || HAVE_SMIME */
5420 + mutt_clear_error();
5427 +int nntp_post (const char *msg) {
5428 + char buf[LONG_STRING];
5431 + NNTP_DATA *nntp_data;
5433 + if (Context && Context->magic == M_NNTP)
5434 + nntp_data = (NNTP_DATA *)Context->data;
5437 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5438 + !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5440 + mutt_error (_("Can't post article. No connection to news server."));
5443 + nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5446 + if (!(f = safe_fopen (msg, "r")))
5448 + mutt_error (_("Can't post article. Unable to open %s"), msg);
5452 + strfcpy (buf, "POST\r\n", sizeof (buf));
5453 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5455 + mutt_error (_("Can't post article. Connection to %s lost."),
5456 + nntp_data->nserv->conn->account.host);
5459 + if (buf[0] != '3')
5461 + mutt_error (_("Can't post article: %s"), buf);
5467 + while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5469 + len = strlen (buf);
5470 + if (buf[len - 1] == '\n')
5472 + buf[len - 1] = '\r';
5477 + if (buf[1] == '.')
5478 + mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5480 + mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5484 + if (buf[strlen (buf) - 1] != '\n')
5485 + mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5486 + mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5487 + if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5489 + mutt_error (_("Can't post article. Connection to %s lost."),
5490 + nntp_data->nserv->conn->account.host);
5493 + if (buf[0] != '2')
5495 + mutt_error (_("Can't post article: %s"), buf);
5502 +/* nntp_logout_all: close all open connections. */
5503 +void nntp_logout_all (void)
5505 + char buf[LONG_STRING];
5508 + conn = mutt_socket_head ();
5512 + CONNECTION *next = conn->next;
5514 + if (conn->account.type == M_ACCT_TYPE_NNTP)
5516 + mutt_message (_("Closing connection to %s..."), conn->account.host);
5517 + mutt_socket_write (conn, "QUIT\r\n");
5518 + mutt_socket_readln (buf, sizeof (buf), conn);
5519 + mutt_clear_error ();
5520 + mutt_socket_close (conn);
5521 + mutt_socket_free (conn);
5528 +static void nntp_free_acache (NNTP_DATA *data)
5532 + for (i = 0; i < NNTP_CACHE_LEN; i++)
5534 + if (data->acache[i].path)
5536 + unlink (data->acache[i].path);
5537 + FREE (&data->acache[i].path);
5542 +void nntp_delete_data (void *p)
5544 + NNTP_DATA *data = (NNTP_DATA *)p;
5548 + FREE (&data->entries);
5549 + FREE (&data->desc);
5550 + FREE (&data->cache);
5551 + nntp_free_acache (data);
5555 +int nntp_sync_mailbox (CONTEXT *ctx)
5557 + NNTP_DATA *data = ctx->data;
5559 + /* CACHE: update cache and .index files */
5560 + if ((option (OPTSAVEUNSUB) || data->subscribed))
5561 + nntp_save_cache_group (ctx);
5562 + nntp_free_acache (data);
5564 + data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
5568 +int nntp_fastclose_mailbox (CONTEXT *ctx)
5570 + NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
5574 + nntp_free_acache (data);
5575 + if (!data->nserv || !data->nserv->newsgroups || !data->group)
5577 + nntp_save_cache_index (data->nserv);
5578 + if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
5580 + nntp_delete_data (data);
5584 +/* commit changes and terminate connection */
5585 +int nntp_close_mailbox (CONTEXT *ctx)
5589 + mutt_message _("Quitting newsgroup...");
5592 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
5595 + if (data->nserv && data->nserv->conn && ctx->unread)
5597 + ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
5599 + mutt_newsgroup_catchup (data->nserv, data->group);
5604 + nntp_sync_mailbox (ctx);
5605 + if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
5607 + NNTP_SERVER *news;
5609 + news = ((NNTP_DATA *)ctx->data)->nserv;
5610 + newsrc_gen_entries (ctx);
5611 + ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
5612 + mutt_newsrc_update (news);
5614 + mutt_clear_error();
5618 +/* use the GROUP command to poll for new mail */
5619 +static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
5621 + char buf[LONG_STRING];
5624 + if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
5628 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5631 + nntp_error ("nntp_check_mailbox()", buf);
5635 + if (mutt_strncmp ("211", buf, 3))
5638 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5641 + nntp_error ("nntp_check_mailbox()", buf);
5646 + if (!mutt_strncmp ("211", buf, 3))
5651 + sscanf (buf + 4, "%d %d %d", &count, &first, &last);
5652 + nntp_data->firstMessage = first;
5653 + nntp_data->lastMessage = last;
5654 + if (ctx && last > nntp_data->lastLoaded)
5656 + nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
5657 + time (&nntp_data->nserv->check_time);
5660 + if (!last || (!nntp_data->rc && !nntp_data->lastCached))
5661 + nntp_data->unread = count;
5663 + mutt_newsgroup_stat (nntp_data);
5664 + /* active was renumbered? */
5665 + if (last < nntp_data->lastLoaded)
5667 + if (!nntp_data->max)
5669 + nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
5670 + nntp_data->max = 5;
5672 + nntp_data->lastCached = 0;
5673 + nntp_data->num = 1;
5674 + nntp_data->entries[0].first = 1;
5675 + nntp_data->entries[0].last = 0;
5679 + time (&nntp_data->nserv->check_time);
5683 +int nntp_check_mailbox (CONTEXT *ctx)
5685 + return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
5688 +static int add_group (char *buf, void *serv)
5690 +#define s ((NNTP_SERVER *) serv)
5691 + char group[LONG_STRING], mod, desc[HUGE_STRING];
5693 + NNTP_DATA *nntp_data;
5696 + _checked = n; /* _checked have N, where N = number of groups */
5697 + if (!buf) /* at EOF must be zerouth */
5704 + sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
5707 + if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
5710 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
5711 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5712 + strcpy (nntp_data->group, group);
5713 + nntp_data->nserv = s;
5714 + if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
5715 + s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2);
5716 + hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
5717 + nntp_add_to_list (s, nntp_data);
5719 + nntp_data->deleted = 0;
5720 + nntp_data->firstMessage = first;
5721 + nntp_data->lastMessage = last;
5723 + nntp_data->allowed = 1;
5725 + nntp_data->allowed = 0;
5726 + if (nntp_data->desc)
5727 + FREE (&nntp_data->desc);
5729 + nntp_data->desc = safe_strdup (desc);
5730 + if (nntp_data->rc || nntp_data->lastCached)
5731 + mutt_newsgroup_stat (nntp_data);
5732 + else if (nntp_data->lastMessage &&
5733 + nntp_data->firstMessage <= nntp_data->lastMessage)
5734 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
5736 + nntp_data->unread = 0;
5742 +int nntp_check_newgroups (NNTP_SERVER *serv, int force)
5744 + char buf[LONG_STRING];
5745 + char msg[SHORT_STRING];
5746 + NNTP_DATA nntp_data;
5751 + unsigned int count = 0;
5752 + unsigned int total = 0;
5754 + if (!serv || !serv->newgroups_time)
5757 + if (nntp_open_connection (serv) < 0)
5760 + /* check subscribed groups for new news */
5761 + if (option (OPTSHOWNEWNEWS))
5763 + mutt_message _("Checking for new messages...");
5764 + for (l = serv->list; l; l = l->next)
5766 + serv->check_time = 0; /* really check! */
5767 + if (l->data && ((NNTP_DATA *) l->data)->subscribed)
5768 + _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
5774 + mutt_message _("Checking for new newsgroups...");
5775 + now = serv->newgroups_time;
5776 + time (&serv->newgroups_time);
5777 + t = gmtime (&now);
5778 + snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
5779 + (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
5781 + nntp_data.nserv = serv;
5782 + if (Context && Context->magic == M_NNTP)
5783 + nntp_data.group = ((NNTP_DATA *)Context->data)->group;
5785 + nntp_data.group = NULL;
5787 + if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
5788 + add_group, serv, 0) != 0)
5791 + nntp_error ("nntp_check_newgroups()", buf);
5796 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5797 + mutt_message (msg);
5799 + emp.next = l->next;
5801 + emp.next = serv->list;
5806 + ((NNTP_DATA *) l->data)->new = 1;
5813 + nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
5815 + if (ReadInc && (count % ReadInc == 0))
5816 + mutt_message ("%s %d/%d", msg, count, total);
5819 + nntp_save_cache_index (serv);
5820 + mutt_clear_error ();
5824 +/* Load list of all newsgroups from cache ALL */
5825 +int nntp_get_cache_all (NNTP_SERVER *serv)
5827 + char buf[HUGE_STRING];
5830 + nntp_cache_expand (buf, serv->cache);
5831 + if ((f = safe_fopen (buf, "r")))
5835 + while (fgets (buf, sizeof(buf), f) != NULL)
5837 + if (ReadInc && (i % ReadInc == 0))
5838 + mutt_message (_("Loading list from cache... %d"), i);
5839 + add_group (buf, serv);
5842 + add_group (NULL, NULL);
5844 + mutt_clear_error ();
5849 + FREE (&serv->cache);
5854 +/* Load list of all newsgroups from active */
5855 +int nntp_get_active (NNTP_SERVER *serv)
5857 + char msg[SHORT_STRING];
5858 + NNTP_DATA nntp_data;
5861 + if (nntp_open_connection (serv) < 0)
5864 + snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
5865 + serv->conn->account.host);
5866 + mutt_message (msg);
5867 + time (&serv->newgroups_time);
5868 + nntp_data.nserv = serv;
5869 + nntp_data.group = NULL;
5871 + if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
5874 + nntp_error ("nntp_get_active()", "LIST\r\n");
5879 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5880 + mutt_message (msg);
5881 + nntp_get_desc (&nntp_data, "*", msg);
5883 + for (tmp = serv->list; tmp; tmp = tmp->next)
5885 + NNTP_DATA *data = (NNTP_DATA *)tmp->data;
5887 + if (data && data->deleted && !data->rc)
5889 + nntp_delete_cache (data);
5890 + hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
5894 + nntp_save_cache_index (serv);
5896 + mutt_clear_error ();
5901 + * returns -1 if error ocurred while retrieving header,
5902 + * number of articles which ones exist in context on success.
5904 +int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
5908 + /* if msgid is already in context, don't reload them */
5909 + if (hash_find (ctx->id_hash, msgid))
5911 + if (ctx->msgcount == ctx->hdrmax)
5912 + mx_alloc_memory (ctx);
5913 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5914 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5916 + mutt_message (_("Fetching %s from server..."), msgid);
5917 + ret = nntp_read_header (ctx, msgid, 0);
5918 + /* since nntp_read_header() may set read flag, we must reset it */
5919 + ctx->hdrs[ctx->msgcount]->read = 0;
5921 + mutt_free_header (&ctx->hdrs[ctx->msgcount]);
5925 + mx_update_context (ctx, 1);
5936 + unsigned int *child;
5939 +static int check_children (char *s, void *c)
5941 +#define cc ((CHILD_CONTEXT *) c)
5942 + unsigned int i, n;
5944 + if (!s || (n = atoi (s)) == 0)
5946 + for (i = 0; i < cc->ctx->msgcount; i++)
5947 + if (cc->ctx->hdrs[i]->article_num == n)
5949 + if (cc->num >= cc->max)
5950 + safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
5951 + cc->child[cc->num++] = n;
5957 +int nntp_check_children (CONTEXT *ctx, const char *msgid)
5959 + NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
5961 + int i, ret = 0, tmp = 0;
5964 + if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
5965 + !nntp_data->nserv->conn->account.host)
5967 + if (nntp_data->firstMessage > nntp_data->lastLoaded)
5969 + if (!nntp_data->nserv->hasXPAT)
5971 + mutt_error (_("Server %s does not support this operation!"),
5972 + nntp_data->nserv->conn->account.host);
5976 + snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
5977 + nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
5982 + cc.child = safe_malloc (sizeof (unsigned int) * 25);
5983 + if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
5988 + /* dont try to read the xover cache. check_children() already
5989 + * made sure that we dont have the article, so we need to visit
5990 + * the server. Reading the cache at this point is also bad
5991 + * because it would duplicate messages */
5992 + if (option (OPTNEWSCACHE))
5995 + unset_option (OPTNEWSCACHE);
5997 + for (i = 0; i < cc.num; i++)
5999 + if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
6001 + if (ctx->msgcount &&
6002 + ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
6003 + ctx->hdrs[ctx->msgcount - 1]->read = 0;
6006 + set_option (OPTNEWSCACHE);
6010 diff -udprP mutt-1.5.15.orig/nntp.h mutt-1.5.15/nntp.h
6011 --- mutt-1.5.15.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
6012 +++ mutt-1.5.15/nntp.h 2007-04-11 17:46:58.000000000 +0300
6015 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
6016 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
6017 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
6019 + * This program is free software; you can redistribute it and/or modify
6020 + * it under the terms of the GNU General Public License as published by
6021 + * the Free Software Foundation; either version 2 of the License, or
6022 + * (at your option) any later version.
6024 + * This program is distributed in the hope that it will be useful,
6025 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6026 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6027 + * GNU General Public License for more details.
6029 + * You should have received a copy of the GNU General Public License
6030 + * along with this program; if not, write to the Free Software
6031 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6037 +#include "mutt_socket.h"
6038 +#include "mailbox.h"
6042 +#define NNTP_PORT 119
6043 +#define NNTP_SSL_PORT 563
6045 +/* number of entries in the hash table */
6046 +#define NNTP_CACHE_LEN 10
6063 + unsigned int hasXPAT : 1;
6064 + unsigned int hasXGTITLE : 1;
6065 + unsigned int hasXOVER : 1;
6066 + unsigned int hasLISTGROUP : 1;
6067 + unsigned int status : 3;
6073 + time_t newgroups_time;
6074 + time_t check_time;
6076 + LIST *list; /* list of newsgroups */
6077 + LIST *tail; /* last entry of list */
6083 + unsigned int index;
6089 + NEWSRC_ENTRY *entries;
6090 + unsigned int num; /* number of used entries */
6091 + unsigned int max; /* number of allocated entries */
6092 + unsigned int unread;
6093 + unsigned int firstMessage;
6094 + unsigned int lastMessage;
6095 + unsigned int lastLoaded;
6096 + unsigned int lastCached;
6097 + unsigned int subscribed : 1;
6098 + unsigned int rc : 1;
6099 + unsigned int new : 1;
6100 + unsigned int allowed : 1;
6101 + unsigned int deleted : 1;
6105 + NNTP_SERVER *nserv;
6106 + NNTP_CACHE acache[NNTP_CACHE_LEN];
6109 +/* internal functions */
6110 +int nntp_get_active (NNTP_SERVER *);
6111 +int nntp_get_cache_all (NNTP_SERVER *);
6112 +int nntp_save_cache_index (NNTP_SERVER *);
6113 +int nntp_check_newgroups (NNTP_SERVER *, int);
6114 +int nntp_save_cache_group (CONTEXT *);
6115 +int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6116 +void newsrc_gen_entries (CONTEXT *);
6117 +void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6118 +void mutt_newsgroup_stat (NNTP_DATA *);
6119 +void nntp_delete_cache (NNTP_DATA *);
6120 +void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6121 +void nntp_cache_expand (char *, const char *);
6122 +void nntp_delete_data (void *);
6124 +/* exposed interface */
6125 +NNTP_SERVER *mutt_select_newsserver (char *);
6126 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6127 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6128 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6129 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6130 +void nntp_clear_cacheindex (NNTP_SERVER *);
6131 +int mutt_newsrc_update (NNTP_SERVER *);
6132 +int nntp_open_mailbox (CONTEXT *);
6133 +int nntp_sync_mailbox (CONTEXT *);
6134 +int nntp_check_mailbox (CONTEXT *);
6135 +int nntp_close_mailbox (CONTEXT *);
6136 +int nntp_fastclose_mailbox (CONTEXT *);
6137 +int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6138 +int nntp_post (const char *);
6139 +int nntp_check_msgid (CONTEXT *, const char *);
6140 +int nntp_check_children (CONTEXT *, const char *);
6141 +void nntp_buffy (char *);
6142 +void nntp_expand_path (char *, size_t, ACCOUNT *);
6143 +void nntp_logout_all ();
6144 +const char *nntp_format_str (char *, size_t, char, const char *, const char *,
6145 + const char *, const char *, unsigned long, format_flag);
6147 +NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6149 +#endif /* _NNTP_H_ */
6150 diff -udprP mutt-1.5.15.orig/pager.c mutt-1.5.15/pager.c
6151 --- mutt-1.5.15.orig/pager.c 2007-04-02 00:58:56.000000000 +0300
6152 +++ mutt-1.5.15/pager.c 2007-04-11 17:25:15.000000000 +0300
6153 @@ -1055,6 +1055,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
6163 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6164 int flags, ansi_attr *pa, int cnt,
6165 @@ -1490,6 +1495,16 @@ static struct mapping_t PagerHelpExtra[]
6170 +static struct mapping_t PagerNewsHelpExtra[] = {
6171 + { N_("Post"), OP_POST },
6172 + { N_("Followup"), OP_FOLLOWUP },
6173 + { N_("Del"), OP_DELETE },
6174 + { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6181 /* This pager is actually not so simple as it once was. It now operates in
6182 @@ -1531,6 +1546,10 @@ mutt_pager (const char *banner, const ch
6183 int old_PagerIndexLines; /* some people want to resize it
6184 * while inside the pager... */
6187 + char *followup_to;
6190 if (!(flags & M_SHOWCOLOR))
6191 flags |= M_SHOWFLAT;
6193 @@ -1570,7 +1589,11 @@ mutt_pager (const char *banner, const ch
6194 if (IsHeader (extra))
6196 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6197 - mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6198 + mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6200 + (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6203 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6206 @@ -2393,6 +2416,15 @@ search_next:
6208 CHECK_ACL(M_ACL_WRITE, "flag message");
6211 + if (Context->magic == M_NNTP)
6214 + mutt_error _("Can't change 'important' flag on NNTP server.");
6219 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6220 redraw = REDRAW_STATUS | REDRAW_INDEX;
6221 if (option (OPTRESOLVE))
6222 @@ -2426,6 +2458,60 @@ search_next:
6223 redraw = REDRAW_FULL;
6228 + CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6230 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6231 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6232 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6234 + ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6235 + redraw = REDRAW_FULL;
6238 + case OP_FORWARD_TO_GROUP:
6239 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6241 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6242 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6243 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6245 + if (IsMsgAttach (extra))
6246 + mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6247 + extra->idxlen, extra->bdy, SENDNEWS);
6249 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6250 + redraw = REDRAW_FULL;
6254 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6257 + if (IsMsgAttach (extra))
6258 + followup_to = extra->bdy->hdr->env->followup_to;
6260 + followup_to = extra->hdr->env->followup_to;
6262 + if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6263 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6265 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6266 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6267 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6269 + if (IsMsgAttach (extra))
6270 + mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6271 + extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6273 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6274 + extra->ctx, extra->hdr);
6275 + redraw = REDRAW_FULL;
6281 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6283 @@ -2472,7 +2558,7 @@ search_next:
6285 if (IsMsgAttach (extra))
6286 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6287 - extra->idxlen, extra->bdy);
6288 + extra->idxlen, extra->bdy, 0);
6290 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6291 redraw = REDRAW_FULL;
6292 diff -udprP mutt-1.5.15.orig/parse.c mutt-1.5.15/parse.c
6293 --- mutt-1.5.15.orig/parse.c 2007-04-02 00:58:56.000000000 +0300
6294 +++ mutt-1.5.15/parse.c 2007-04-11 17:25:15.000000000 +0300
6295 @@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
6299 -static LIST *mutt_parse_references (char *s, int in_reply_to)
6300 +LIST *mutt_parse_references (char *s, int in_reply_to)
6302 LIST *t, *lst = NULL;
6304 @@ -1068,6 +1068,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6305 e->from = rfc822_parse_adrlist (e->from, p);
6309 + else if (!mutt_strcasecmp (line+1, "ollowup-to"))
6311 + if (!e->followup_to)
6313 + mutt_remove_trailing_ws (p);
6314 + e->followup_to = safe_strdup (mutt_skip_whitespace (p));
6322 @@ -1152,6 +1163,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6328 + if (!mutt_strcasecmp (line + 1, "ewsgroups"))
6330 + FREE (&e->newsgroups);
6331 + mutt_remove_trailing_ws (p);
6332 + e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
6339 + /* field `Organization:' saves only for pager! */
6340 + if (!mutt_strcasecmp (line + 1, "rganization"))
6342 + if (!e->organization && mutt_strcasecmp (p, "unknown"))
6343 + e->organization = safe_strdup (p);
6348 if (!ascii_strcasecmp (line + 1, "eferences"))
6350 @@ -1260,6 +1292,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6351 e->x_label = safe_strdup(p);
6355 + else if (!mutt_strcasecmp (line + 1, "-comment-to"))
6357 + if (!e->x_comment_to)
6358 + e->x_comment_to = safe_strdup (p);
6361 + else if (!mutt_strcasecmp (line + 1, "ref"))
6364 + e->xref = safe_strdup (p);
6371 diff -udprP mutt-1.5.15.orig/pattern.c mutt-1.5.15/pattern.c
6372 --- mutt-1.5.15.orig/pattern.c 2007-04-02 00:58:56.000000000 +0300
6373 +++ mutt-1.5.15/pattern.c 2007-04-11 17:25:15.000000000 +0300
6374 @@ -91,6 +91,9 @@ Flags[] =
6375 { 'U', M_UNREAD, 0, NULL },
6376 { 'v', M_COLLAPSED, 0, NULL },
6377 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6379 + { 'w', M_NEWSGROUPS, 0, eat_regexp },
6381 { 'x', M_REFERENCE, 0, eat_regexp },
6382 { 'X', M_MIMEATTACH, 0, eat_range },
6383 { 'y', M_XLABEL, 0, eat_regexp },
6384 @@ -1208,6 +1211,10 @@ mutt_pattern_exec (struct pattern_t *pat
6386 case M_UNREFERENCED:
6387 return (pat->not ^ (h->thread && !h->thread->child));
6389 + case M_NEWSGROUPS:
6390 + return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6393 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6395 @@ -1276,6 +1283,7 @@ int mutt_pattern_func (int op, char *pro
6396 progress_t progress;
6398 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6399 + if (prompt || op != M_LIMIT)
6400 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6403 diff -udprP mutt-1.5.15.orig/po/POTFILES.in mutt-1.5.15/po/POTFILES.in
6404 --- mutt-1.5.15.orig/po/POTFILES.in 2007-04-02 00:58:57.000000000 +0300
6405 +++ mutt-1.5.15/po/POTFILES.in 2007-04-11 17:25:15.000000000 +0300
6406 @@ -47,6 +47,8 @@ mutt_ssl_gnutls.c
6415 diff -udprP mutt-1.5.15.orig/postpone.c mutt-1.5.15/postpone.c
6416 --- mutt-1.5.15.orig/postpone.c 2007-04-02 00:58:57.000000000 +0300
6417 +++ mutt-1.5.15/postpone.c 2007-04-11 17:25:15.000000000 +0300
6418 @@ -126,15 +126,26 @@ int mutt_num_postponed (int force)
6420 if (LastModify < st.st_mtime)
6423 + int optnews = option (OPTNEWS);
6425 LastModify = st.st_mtime;
6427 if (access (Postponed, R_OK | F_OK) != 0)
6428 return (PostCount = 0);
6431 + unset_option (OPTNEWS);
6433 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6436 PostCount = ctx.msgcount;
6437 mx_fastclose_mailbox (&ctx);
6440 + set_option (OPTNEWS);
6445 diff -udprP mutt-1.5.15.orig/protos.h mutt-1.5.15/protos.h
6446 --- mutt-1.5.15.orig/protos.h 2007-04-02 00:58:57.000000000 +0300
6447 +++ mutt-1.5.15/protos.h 2007-04-11 17:25:15.000000000 +0300
6448 @@ -104,6 +104,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
6449 HASH *mutt_make_subj_hash (CONTEXT *);
6451 LIST *mutt_make_references(ENVELOPE *e);
6452 +LIST *mutt_parse_references (char *, int);
6454 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6455 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
6456 @@ -246,6 +247,7 @@ void mutt_unblock_signals_system (int);
6457 void mutt_update_encoding (BODY *a);
6458 void mutt_version (void);
6459 void mutt_view_attachments (HEADER *);
6460 +void mutt_write_references (LIST *, FILE *);
6461 void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen, int display);
6462 void mutt_set_virtual (CONTEXT *);
6464 diff -udprP mutt-1.5.15.orig/recvattach.c mutt-1.5.15/recvattach.c
6465 --- mutt-1.5.15.orig/recvattach.c 2007-04-02 00:58:57.000000000 +0300
6466 +++ mutt-1.5.15/recvattach.c 2007-04-11 17:25:15.000000000 +0300
6467 @@ -1087,6 +1087,15 @@ void mutt_view_attachments (HEADER *hdr)
6472 + if (Context->magic == M_NNTP)
6475 + mutt_error _("Can't delete attachment from newsserver.");
6480 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6483 @@ -1178,10 +1187,33 @@ void mutt_view_attachments (HEADER *hdr)
6484 case OP_FORWARD_MESSAGE:
6486 mutt_attach_forward (fp, hdr, idx, idxlen,
6487 - menu->tagprefix ? NULL : idx[menu->current]->content);
6488 + menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6489 menu->redraw = REDRAW_FULL;
6493 + case OP_FORWARD_TO_GROUP:
6495 + mutt_attach_forward (fp, hdr, idx, idxlen,
6496 + menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6497 + menu->redraw = REDRAW_FULL;
6503 + if (!idx[menu->current]->content->hdr->env->followup_to ||
6504 + mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6505 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6507 + mutt_attach_reply (fp, hdr, idx, idxlen,
6508 + menu->tagprefix ? NULL : idx[menu->current]->content,
6509 + SENDNEWS|SENDREPLY);
6510 + menu->redraw = REDRAW_FULL;
6516 case OP_GROUP_REPLY:
6518 diff -udprP mutt-1.5.15.orig/recvcmd.c mutt-1.5.15/recvcmd.c
6519 --- mutt-1.5.15.orig/recvcmd.c 2007-04-02 00:58:57.000000000 +0300
6520 +++ mutt-1.5.15/recvcmd.c 2007-04-11 17:25:15.000000000 +0300
6521 @@ -377,7 +377,7 @@ static BODY ** copy_problematic_attachme
6522 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6523 ATTACHPTR ** idx, short idxlen,
6526 + short nattach, int flags)
6529 short mime_fwd_all = 0;
6530 @@ -523,7 +523,7 @@ _("Can't decode all tagged attachments.
6533 /* now that we have the template, send it. */
6534 - ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6535 + ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6539 @@ -550,7 +550,7 @@ _("Can't decode all tagged attachments.
6542 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6543 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6544 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6546 HEADER *curhdr = NULL;
6548 @@ -655,23 +655,23 @@ static void attach_forward_msgs (FILE *
6550 mutt_free_header (&tmphdr);
6552 - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6553 + ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
6558 void mutt_attach_forward (FILE * fp, HEADER * hdr,
6559 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6560 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6565 if (check_all_msg (idx, idxlen, cur, 0) == 0)
6566 - attach_forward_msgs (fp, hdr, idx, idxlen, cur);
6567 + attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
6570 nattach = count_tagged (idx, idxlen);
6571 - attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
6572 + attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
6576 @@ -729,28 +729,40 @@ attach_reply_envelope_defaults (ENVELOPE
6582 + if ((flags & SENDNEWS))
6584 - if (mutt_fetch_recips (env, curenv, flags) == -1)
6586 + /* in case followup set Newsgroups: with Followup-To: if it present */
6587 + if (!env->newsgroups && curenv &&
6588 + mutt_strcasecmp (curenv->followup_to, "poster"))
6589 + env->newsgroups = safe_strdup (curenv->followup_to);
6594 - for (i = 0; i < idxlen; i++)
6597 - if (idx[i]->content->tagged
6598 - && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6599 + if (mutt_fetch_recips (env, curenv, flags) == -1)
6604 + for (i = 0; i < idxlen; i++)
6606 + if (idx[i]->content->tagged
6607 + && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6612 + if ((flags & SENDLISTREPLY) && !env->to)
6614 + mutt_error _("No mailing lists found!");
6618 + mutt_fix_reply_recipients (env);
6621 - if ((flags & SENDLISTREPLY) && !env->to)
6623 - mutt_error _("No mailing lists found!");
6627 - mutt_fix_reply_recipients (env);
6628 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
6631 @@ -811,6 +823,13 @@ void mutt_attach_reply (FILE * fp, HEADE
6632 char prefix[SHORT_STRING];
6636 + if (flags & SENDNEWS)
6637 + set_option (OPTNEWSSEND);
6639 + unset_option (OPTNEWSSEND);
6642 if (check_all_msg (idx, idxlen, cur, 0) == -1)
6644 nattach = count_tagged (idx, idxlen);
6645 diff -udprP mutt-1.5.15.orig/rfc1524.c mutt-1.5.15/rfc1524.c
6646 --- mutt-1.5.15.orig/rfc1524.c 2007-04-02 00:58:58.000000000 +0300
6647 +++ mutt-1.5.15/rfc1524.c 2007-04-11 17:25:15.000000000 +0300
6648 @@ -569,13 +569,13 @@ int rfc1524_expand_filename (char *namet
6652 -int mutt_rename_file (char *oldfile, char *newfile)
6653 +int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
6657 if (access (oldfile, F_OK) != 0)
6659 - if (access (newfile, F_OK) == 0)
6660 + if (!overwrite && access (newfile, F_OK) == 0)
6662 if ((ofp = fopen (oldfile,"r")) == NULL)
6664 @@ -590,3 +590,8 @@ int mutt_rename_file (char *oldfile, cha
6665 mutt_unlink (oldfile);
6669 +int mutt_rename_file (char *oldfile, char *newfile)
6671 + return _mutt_rename_file (oldfile, newfile, 0);
6673 diff -udprP mutt-1.5.15.orig/rfc1524.h mutt-1.5.15/rfc1524.h
6674 --- mutt-1.5.15.orig/rfc1524.h 2007-04-02 00:58:58.000000000 +0300
6675 +++ mutt-1.5.15/rfc1524.h 2007-04-11 17:25:15.000000000 +0300
6676 @@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char
6677 int rfc1524_expand_filename (char *, char *, char *, size_t);
6678 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
6679 int mutt_rename_file (char *, char *);
6680 +int _mutt_rename_file (char *, char *, int);
6682 #endif /* _RFC1524_H */
6683 diff -udprP mutt-1.5.15.orig/send.c mutt-1.5.15/send.c
6684 --- mutt-1.5.15.orig/send.c 2007-04-02 00:58:58.000000000 +0300
6685 +++ mutt-1.5.15/send.c 2007-04-11 16:07:11.000000000 +0300
6687 #include <sys/types.h>
6695 #include "remailer.h"
6697 @@ -214,17 +218,51 @@ static int edit_address (ADDRESS **a, /*
6701 -static int edit_envelope (ENVELOPE *en)
6702 +static int edit_envelope (ENVELOPE *en, int flags)
6704 char buf[HUGE_STRING];
6705 LIST *uh = UserHeader;
6707 - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6709 - if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6711 - if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6714 + if (option (OPTNEWSSEND))
6716 + if (en->newsgroups)
6717 + strfcpy (buf, en->newsgroups, sizeof (buf));
6720 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
6722 + FREE (&en->newsgroups);
6723 + en->newsgroups = safe_strdup (buf);
6725 + if (en->followup_to)
6726 + strfcpy (buf, en->followup_to, sizeof (buf));
6729 + if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
6731 + FREE (&en->followup_to);
6732 + en->followup_to = safe_strdup (buf);
6734 + if (en->x_comment_to)
6735 + strfcpy (buf, en->x_comment_to, sizeof (buf));
6738 + if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
6740 + FREE (&en->x_comment_to);
6741 + en->x_comment_to = safe_strdup (buf);
6746 + if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6748 + if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6750 + if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6756 @@ -260,6 +298,14 @@ static int edit_envelope (ENVELOPE *en)
6761 +char *nntp_get_header (const char *s)
6764 + return safe_strdup (s);
6768 static void process_user_recips (ENVELOPE *env)
6770 LIST *uh = UserHeader;
6771 @@ -272,6 +318,14 @@ static void process_user_recips (ENVELOP
6772 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
6773 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
6774 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
6776 + else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
6777 + env->newsgroups = nntp_get_header (uh->data + 11);
6778 + else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
6779 + env->followup_to = nntp_get_header (uh->data + 12);
6780 + else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
6781 + env->x_comment_to = nntp_get_header (uh->data + 13);
6786 @@ -302,6 +356,12 @@ static void process_user_header (ENVELOP
6787 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
6788 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
6789 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
6791 + ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
6792 + ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
6793 + ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
6795 + ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
6796 ascii_strncasecmp ("subject:", uh->data, 8) != 0)
6799 @@ -645,6 +705,10 @@ void mutt_add_to_reference_headers (ENVE
6804 + if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
6805 + env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
6810 @@ -701,6 +765,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
6812 if (flags & SENDREPLY)
6815 + if ((flags & SENDNEWS))
6817 + /* in case followup set Newsgroups: with Followup-To: if it present */
6818 + if (!env->newsgroups && curenv &&
6819 + mutt_strcasecmp (curenv->followup_to, "poster"))
6820 + env->newsgroups = safe_strdup (curenv->followup_to);
6827 @@ -847,7 +921,18 @@ void mutt_set_followup_to (ENVELOPE *e)
6828 * it hasn't already been set
6831 - if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
6832 + if (!option (OPTFOLLOWUPTO))
6835 + if (option (OPTNEWSSEND))
6837 + if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
6838 + e->followup_to = safe_strdup (e->newsgroups);
6843 + if (!e->mail_followup_to)
6845 if (mutt_is_list_cc (0, e->to, e->cc))
6847 @@ -1008,6 +1093,9 @@ static int send_message (HEADER *msg)
6852 + if (!option (OPTNEWSSEND))
6853 +#endif /* USE_NNTP */
6855 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
6856 msg->env->bcc, tempfile,
6857 @@ -1100,6 +1188,13 @@ ci_send_message (int flags, /* send mod
6862 + if (flags & SENDNEWS)
6863 + set_option (OPTNEWSSEND);
6865 + unset_option (OPTNEWSSEND);
6868 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
6869 mutt_num_postponed (1))
6871 @@ -1130,6 +1225,22 @@ ci_send_message (int flags, /* send mod
6873 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
6877 + * If postponed message is a news article, it have
6878 + * a "Newsgroups:" header line, then set appropriate flag.
6880 + if (msg->env->newsgroups)
6882 + flags |= SENDNEWS;
6883 + set_option (OPTNEWSSEND);
6887 + flags &= ~SENDNEWS;
6888 + unset_option (OPTNEWSSEND);
6893 if (flags & (SENDPOSTPONED|SENDRESEND))
6894 @@ -1237,11 +1348,16 @@ ci_send_message (int flags, /* send mod
6895 if (flags & SENDREPLY)
6896 mutt_fix_reply_recipients (msg->env);
6899 + if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
6900 + msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
6903 if (! (flags & SENDMAILX) &&
6904 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
6905 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
6907 - if (edit_envelope (msg->env) == -1)
6908 + if (edit_envelope (msg->env, flags) == -1)
6912 @@ -1495,6 +1611,11 @@ main_loop:
6917 + if (flags & SENDNEWS)
6918 + mutt_message _("Article not posted.");
6921 mutt_message _("Mail not sent.");
6924 @@ -1527,6 +1648,9 @@ main_loop:
6929 + if (!(flags & SENDNEWS))
6931 if (!msg->env->to && !msg->env->cc && !msg->env->bcc)
6933 if (! (flags & SENDBATCH))
6934 @@ -1559,6 +1683,19 @@ main_loop:
6935 mutt_error _("No subject specified.");
6939 + if ((flags & SENDNEWS) && !msg->env->subject)
6941 + mutt_error _("No subject specified.");
6945 + if ((flags & SENDNEWS) && !msg->env->newsgroups)
6947 + mutt_error _("No newsgroup specified.");
6952 if (msg->content->next)
6953 msg->content = mutt_make_multipart (msg->content);
6954 @@ -1764,7 +1901,12 @@ full_fcc:
6957 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
6958 - mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
6959 + mutt_message (i != 0 ? _("Sending in background.") :
6961 + (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
6966 if (WithCrypto && (msg->security & ENCRYPT))
6968 diff -udprP mutt-1.5.15.orig/sendlib.c mutt-1.5.15/sendlib.c
6969 --- mutt-1.5.15.orig/sendlib.c 2007-04-03 20:52:56.000000000 +0300
6970 +++ mutt-1.5.15/sendlib.c 2007-04-11 17:25:15.000000000 +0300
6972 #include <sys/wait.h>
6979 #ifdef HAVE_SYSEXITS_H
6980 #include <sysexits.h>
6981 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
6982 @@ -1525,7 +1529,7 @@ void mutt_write_address_list (ADDRESS *a
6983 /* need to write the list in reverse because they are stored in reverse order
6984 * when parsed to speed up threading
6986 -static void write_references (LIST *r, FILE *f)
6987 +void mutt_write_references (LIST *r, FILE *f)
6990 int refcnt = 0, refmax = 0;
6991 @@ -1742,6 +1746,9 @@ int mutt_write_rfc822_header (FILE *fp,
6992 LIST *tmp = env->userhdrs;
6993 int has_agent = 0; /* user defined user-agent header field exists */
6996 + if (!option (OPTNEWSSEND))
6998 if (mode == 0 && !privacy)
6999 fputs (mutt_make_date (buffer, sizeof(buffer)), fp);
7001 @@ -1768,6 +1775,9 @@ int mutt_write_rfc822_header (FILE *fp,
7002 mutt_write_address_list (env->to, fp, 4, 0);
7006 + if (!option (OPTNEWSSEND))
7008 fputs ("To: \n", fp);
7011 @@ -1776,6 +1786,9 @@ int mutt_write_rfc822_header (FILE *fp,
7012 mutt_write_address_list (env->cc, fp, 4, 0);
7016 + if (!option (OPTNEWSSEND))
7018 fputs ("Cc: \n", fp);
7021 @@ -1787,8 +1800,28 @@ int mutt_write_rfc822_header (FILE *fp,
7026 + if (!option (OPTNEWSSEND))
7028 fputs ("Bcc: \n", fp);
7031 + if (env->newsgroups)
7032 + fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
7033 + else if (mode == 1 && option (OPTNEWSSEND))
7034 + fputs ("Newsgroups: \n", fp);
7036 + if (env->followup_to)
7037 + fprintf (fp, "Followup-To: %s\n", env->followup_to);
7038 + else if (mode == 1 && option (OPTNEWSSEND))
7039 + fputs ("Followup-To: \n", fp);
7041 + if (env->x_comment_to)
7042 + fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
7043 + else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
7044 + fputs ("X-Comment-To: \n", fp);
7048 mutt_write_one_header (fp, "Subject", env->subject, NULL, 0);
7050 @@ -1807,6 +1840,9 @@ int mutt_write_rfc822_header (FILE *fp,
7051 fputs ("Reply-To: \n", fp);
7053 if (env->mail_followup_to)
7055 + if (!option (OPTNEWSSEND))
7058 fputs ("Mail-Followup-To: ", fp);
7059 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
7060 @@ -1817,7 +1853,7 @@ int mutt_write_rfc822_header (FILE *fp,
7061 if (env->references)
7063 fputs ("References:", fp);
7064 - write_references (env->references, fp);
7065 + mutt_write_references (env->references, fp);
7069 @@ -1829,7 +1865,7 @@ int mutt_write_rfc822_header (FILE *fp,
7070 if (env->in_reply_to)
7072 fputs ("In-Reply-To:", fp);
7073 - write_references (env->in_reply_to, fp);
7074 + mutt_write_references (env->in_reply_to, fp);
7078 @@ -2145,11 +2181,30 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7079 const char *msg, /* file containing message */
7080 int eightbit) /* message contains 8bit chars */
7082 - char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
7083 + char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
7085 size_t argslen = 0, argsmax = 0;
7089 + if (option (OPTNEWSSEND))
7091 + char cmd[LONG_STRING];
7093 + mutt_FormatString (cmd, sizeof (cmd), NONULL (Inews), nntp_format_str, 0, 0);
7096 + i = nntp_post (msg);
7101 + s = safe_strdup (cmd);
7105 + s = safe_strdup (Sendmail);
7109 while ((ps = strtok (ps, " ")))
7110 @@ -2173,6 +2228,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7115 + if (!option (OPTNEWSSEND))
7118 if (eightbit && option (OPTUSE8BITMIME))
7119 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7121 @@ -2204,6 +2263,9 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7122 args = add_args (args, &argslen, &argsmax, to);
7123 args = add_args (args, &argslen, &argsmax, cc);
7124 args = add_args (args, &argslen, &argsmax, bcc);
7129 if (argslen == argsmax)
7130 safe_realloc (&args, sizeof (char *) * (++argsmax));
7131 @@ -2336,6 +2398,9 @@ void mutt_prepare_envelope (ENVELOPE *en
7132 rfc2047_encode_adrlist (env->reply_to, "Reply-To");
7136 + if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
7139 rfc2047_encode_string (&env->subject);
7141 @@ -2441,6 +2506,10 @@ int mutt_bounce_message (FILE *fp, HEADE
7143 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
7146 + unset_option (OPTNEWSSEND);
7149 ret = _mutt_bounce_message (fp, h, to, resent_from, from);
7151 rfc822_free_address (&from);
7152 diff -udprP mutt-1.5.15.orig/sort.c mutt-1.5.15/sort.c
7153 --- mutt-1.5.15.orig/sort.c 2007-04-02 00:58:58.000000000 +0300
7154 +++ mutt-1.5.15/sort.c 2007-04-11 17:25:15.000000000 +0300
7155 @@ -149,6 +149,15 @@ int compare_order (const void *a, const
7156 HEADER **ha = (HEADER **) a;
7157 HEADER **hb = (HEADER **) b;
7160 + if ((*ha)->article_num && (*hb)->article_num)
7162 + int result = (*ha)->article_num - (*hb)->article_num;
7163 + AUXSORT(result,a,b);
7164 + return (SORTCODE (result));
7168 /* no need to auxsort because you will never have equality here */
7169 return (SORTCODE ((*ha)->index - (*hb)->index));
7171 diff -udprP mutt-1.5.15.orig/url.c mutt-1.5.15/url.c
7172 --- mutt-1.5.15.orig/url.c 2007-04-02 00:58:58.000000000 +0300
7173 +++ mutt-1.5.15/url.c 2007-04-11 17:25:15.000000000 +0300
7174 @@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] =
7175 { "imaps", U_IMAPS },
7178 + { "news", U_NNTP },
7179 + { "newss", U_NNTPS },
7180 { "mailto", U_MAILTO },
7182 { "smtps", U_SMTPS },
7183 diff -udprP mutt-1.5.15.orig/url.h mutt-1.5.15/url.h
7184 --- mutt-1.5.15.orig/url.h 2007-04-02 00:58:58.000000000 +0300
7185 +++ mutt-1.5.15/url.h 2007-04-11 17:25:15.000000000 +0300
7186 @@ -8,6 +8,8 @@ typedef enum url_scheme
7195 diff -udprP mutt-1.5.15.orig/Makefile.am mutt-1.5.15/Makefile.am
7196 --- mutt-1.5.15.orig/Makefile.am 2007-04-06 23:04:45.000000000 +0300
7197 +++ mutt-1.5.15/Makefile.am 2007-04-11 17:25:15.000000000 +0300
7198 @@ -62,6 +62,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
7199 smtp.c browser.h mbyte.h remailer.h url.h \
7200 crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
7201 pgppacket.c mutt_idna.h hcache.h hcache.c bcache.c bcache.h mutt_ssl_gnutls.c \
7203 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c \
7206 @@ -73,6 +74,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7207 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7208 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7209 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7210 + nntp.h ChangeLog.nntp \
7211 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7212 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
7213 makedoc.c makedoc-defs.h stamp-doc-rc README.SSL smime.h \
7214 diff -udprP mutt-1.5.15.orig/Makefile.in mutt-1.5.15/Makefile.in
7215 --- mutt-1.5.15.orig/Makefile.in 2007-04-06 23:05:40.000000000 +0300
7216 +++ mutt-1.5.15/Makefile.in 2007-04-11 17:25:15.000000000 +0300
7217 @@ -330,6 +330,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
7218 smtp.c browser.h mbyte.h remailer.h url.h \
7219 crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
7220 pgppacket.c mutt_idna.h hcache.h hcache.c bcache.c bcache.h mutt_ssl_gnutls.c \
7222 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c \
7225 @@ -341,6 +342,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7226 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7227 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7228 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7229 + nntp.h ChangeLog.nntp \
7230 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7231 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
7232 makedoc.c makedoc-defs.h stamp-doc-rc README.SSL smime.h \
7233 @@ -554,6 +556,8 @@ distclean-compile:
7234 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@
7235 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@
7236 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@
7237 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@
7238 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@
7239 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@
7240 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
7241 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@
7242 diff -udprP mutt-1.5.15.orig/Muttrc mutt-1.5.15/Muttrc
7243 --- mutt-1.5.15.orig/Muttrc 2007-04-06 23:34:36.000000000 +0300
7244 +++ mutt-1.5.15/Muttrc 2007-04-11 18:20:29.000000000 +0300
7245 @@ -263,6 +263,28 @@ attachments -I message/external-body
7249 +# set ask_follow_up=no
7251 +# Name: ask_follow_up
7256 +# If set, Mutt will prompt you for follow-up groups before editing
7257 +# the body of an outgoing message.
7260 +# set ask_x_comment_to=no
7262 +# Name: ask_x_comment_to
7267 +# If set, Mutt will prompt you for x-comment-to field before editing
7268 +# the body of an outgoing message.
7271 # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
7273 # Name: attach_format
7274 @@ -430,6 +452,17 @@ attachments -I message/external-body
7275 # access time when checking for new mail.
7278 +# set catchup_newsgroup=ask-yes
7280 +# Name: catchup_newsgroup
7285 +# If this variable is set, Mutt will mark all articles in newsgroup
7286 +# as read when you quit the newsgroup (catchup newsgroup).
7292 @@ -927,6 +960,19 @@ attachments -I message/external-body
7293 # of the same email for you.
7296 +# set followup_to_poster=ask-yes
7298 +# Name: followup_to_poster
7303 +# If this variable is set and the keyword "poster" is present in
7304 +# Followup-To header, follow-up to newsgroup function is not
7305 +# permitted. The message will be mailed to the submitter of the
7306 +# message via mail.
7312 @@ -1024,6 +1070,28 @@ attachments -I message/external-body
7313 # "Franklin" to "Franklin, Steve".
7316 +# set group_index_format="%4C %M%N %5s %-45.45f %d"
7318 +# Name: group_index_format
7320 +# Default: "%4C %M%N %5s %-45.45f %d"
7323 +# This variable allows you to customize the newsgroup browser display to
7324 +# your personal taste. This string is similar to ``index_format'', but
7325 +# has its own set of printf()-like sequences:
7327 +# %C current newsgroup number
7328 +# %d description of newsgroup (becomes from server)
7329 +# %f newsgroup name
7330 +# %M - if newsgroup not allowed for direct post (moderated for example)
7331 +# %N N if newsgroup is new, u if unsubscribed, blank otherwise
7332 +# %n number of new articles in newsgroup
7333 +# %s number of unread articles in newsgroup
7334 +# %>X right justify the rest of the string and pad with character "X"
7335 +# %|X pad to the end of the line with character "X"
7341 @@ -1469,6 +1537,7 @@ attachments -I message/external-body
7342 # %E number of messages in current thread
7343 # %f entire From: line (address + real name)
7344 # %F author name, or recipient name if the message is from you
7345 +# %g newsgroup name (if compiled with nntp support)
7346 # %H spam attribute(s) of this message
7347 # %i message-id of the current message
7348 # %l number of lines in the message (does not work with maildir,
7349 @@ -1482,12 +1551,14 @@ attachments -I message/external-body
7350 # %n author's real name (or address if missing)
7351 # %O (_O_riginal save folder) Where mutt would formerly have
7352 # stashed the message: list name or recipient name if no list
7353 +# %R `x-comment-to:' field (if present and compiled with nntp support)
7354 # %s subject of the message
7355 # %S status of the message (N/D/d/!/r/*)
7356 # %t `to:' field (recipients)
7357 # %T the appropriate character from the $to_chars string
7358 # %u user (login) name of the author
7359 # %v first name of the author, or the recipient if the message is from you
7360 +# %W name of organization of author (`organization:' field)
7361 # %X number of attachments
7362 # (please see the ``attachments'' section for possible speed effects)
7363 # %y `x-label:' field, if present
7364 @@ -1513,6 +1584,22 @@ attachments -I message/external-body
7365 # See also: ``$to_chars''.
7375 +# If set, specifies the program and arguments used to deliver news posted
7376 +# by Mutt. Otherwise, mutt posts article using current connection to
7377 +# news server. The following printf-style sequence is understood:
7379 +# %s newsserver name
7381 +# Example: set inews="/usr/local/bin/inews -hS"
7384 # set ispell="ispell"
7387 @@ -1856,6 +1943,18 @@ attachments -I message/external-body
7388 # be attached to the newly composed message if this option is set.
7391 +# set mime_subject=yes
7393 +# Name: mime_subject
7398 +# If unset, 8-bit ``subject:'' line in article header will not be
7399 +# encoded according to RFC2047 to base64. This is useful when message
7400 +# is Usenet article, because MIME for news is nonstandard feature.
7403 # set mix_entry_format="%4n %c %-16s %a"
7405 # Name: mix_entry_format
7406 @@ -1948,6 +2047,118 @@ attachments -I message/external-body
7407 # See also ``$read_inc'' and ``$write_inc''.
7410 +# set news_cache_dir="~/.mutt"
7412 +# Name: news_cache_dir
7414 +# Default: "~/.mutt"
7417 +# This variable pointing to directory where Mutt will save cached news
7418 +# articles headers in. If unset, headers will not be saved at all
7419 +# and will be reloaded each time when you enter to newsgroup.
7422 +# set news_server=""
7424 +# Name: news_server
7429 +# This variable specifies domain name or address of NNTP server. It
7430 +# defaults to the newsserver specified in the environment variable
7431 +# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
7432 +# specify username and an alternative port for each newsserver, ie:
7434 +# [news[s]://][username[:password]@]newsserver[:port]
7437 +# set newsrc="~/.newsrc"
7441 +# Default: "~/.newsrc"
7444 +# The file, containing info about subscribed newsgroups - names and
7445 +# indexes of read articles. The following printf-style sequence
7448 +# %s newsserver name
7451 +# set nntp_context=1000
7453 +# Name: nntp_context
7458 +# This variable defines number of articles which will be in index when
7459 +# newsgroup entered. If active newsgroup have more articles than this
7460 +# number, oldest articles will be ignored. Also controls how many
7461 +# articles headers will be saved in cache when you quit newsgroup.
7464 +# set nntp_load_description=yes
7466 +# Name: nntp_load_description
7471 +# This variable controls whether or not descriptions for each newsgroup
7472 +# must be loaded when newsgroup is added to list (first time list
7473 +# loading or new newsgroup adding).
7483 +# Your login name on the NNTP server. If unset and NNTP server requires
7484 +# authentification, Mutt will prompt you for your account name when you
7485 +# connect to newsserver.
7495 +# Your password for NNTP account.
7505 +# The time in seconds until any operations on newsgroup except post new
7506 +# article will cause recheck for new news. If set to 0, Mutt will
7507 +# recheck newsgroup on each operation in index (stepping, read article,
7511 +# set nntp_reconnect=ask-yes
7513 +# Name: nntp_reconnect
7518 +# Controls whether or not Mutt will try to reconnect to newsserver when
7522 # set pager="builtin"
7525 @@ -3151,6 +3362,19 @@ attachments -I message/external-body
7526 # string after the inclusion of a message which is being replied to.
7529 +# set post_moderated=ask-yes
7531 +# Name: post_moderated
7536 +# If set to yes, Mutt will post article to newsgroup that have
7537 +# not permissions to posting (e.g. moderated). Note: if newsserver
7538 +# does not support posting to that newsgroup or totally read-only, that
7539 +# posting will not have an effect.
7542 # set postpone=ask-yes
7545 @@ -3676,6 +3900,41 @@ attachments -I message/external-body
7546 # shell from /etc/passwd is used.
7549 +# set save_unsubscribed=no
7551 +# Name: save_unsubscribed
7556 +# When set, info about unsubscribed newsgroups will be saved into
7557 +# ``newsrc'' file and into cache.
7560 +# set show_new_news=yes
7562 +# Name: show_new_news
7567 +# If set, newsserver will be asked for new newsgroups on entering
7568 +# the browser. Otherwise, it will be done only once for a newsserver.
7569 +# Also controls whether or not number of new articles of subscribed
7570 +# newsgroups will be then checked.
7573 +# set show_only_unread=no
7575 +# Name: show_only_unread
7580 +# If set, only subscribed newsgroups that contain unread articles
7581 +# will be displayed in browser.
7584 # set sig_dashes=yes
7587 @@ -4374,3 +4633,14 @@ attachments -I message/external-body
7591 +# set x_comment_to=no
7593 +# Name: x_comment_to
7598 +# If set, Mutt will add ``X-Comment-To:'' field (that contains full
7599 +# name of original article author) to article that followuped to newsgroup.
7602 diff -udprP mutt-1.5.15.orig/configure mutt-1.5.15/configure
7603 --- mutt-1.5.15.orig/configure 2007-04-06 10:17:16.000000000 +0300
7604 +++ mutt-1.5.15/configure 2007-04-11 17:25:15.000000000 +0300
7605 @@ -1341,6 +1341,7 @@ Optional Features:
7606 Force use of an external dotlock program
7607 --enable-pop Enable POP3 support
7608 --enable-imap Enable IMAP support
7609 + --enable-nntp Enable NNTP support
7610 --enable-smtp include internal SMTP relay support
7611 --enable-debug Enable debugging support
7612 --enable-flock Use flock() to lock files
7613 @@ -13918,6 +13919,20 @@ fi
7617 +# Check whether --enable-nntp or --disable-nntp was given.
7618 +if test "${enable_nntp+set}" = set; then
7619 + enableval="$enable_nntp"
7620 + if test x$enableval = xyes ; then
7621 + cat >>confdefs.h <<\_ACEOF
7625 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
7633 for ac_func in strftime