1 WARNING: Run the following script before configure:
9 Vsevolod Volkov <vvv@mutt.org.ua>
12 diff -udprP mutt-1.5.20.orig/ChangeLog.nntp mutt-1.5.20/ChangeLog.nntp
13 --- mutt-1.5.20.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14 +++ mutt-1.5.20/ChangeLog.nntp 2009-06-15 21:56:06.000000000 +0300
16 +* Tue Jun 15 2009 Vsevolod Volkov <vvv@mutt.org.ua>
19 +* Tue Mar 20 2009 Vsevolod Volkov <vvv@mutt.org.ua>
20 +- save Date: header of recorded outgoing articles
22 +* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua>
25 +* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua>
27 +- fixed SIGSEGV when followup or forward to newsgroup
29 +* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua>
32 +* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua>
33 +- fixed arguments of nntp_format_str()
35 +* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua>
36 +- fixed error selecting news group
38 +* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua>
41 +* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
42 +- fixed posting error if $smtp_url is set
43 +- added support of print-style sequence %R (x-comment-to)
45 +* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
47 +- nntp://... url changed to news://...
48 +- added indicator of fetching descriptions progress
50 +* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
53 +* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
56 +* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
58 +- fixed reading empty .newsrc
60 +* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
63 +* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
66 +* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
69 +* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
72 +* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
74 +- function mutt_update_list_file() moved to newsrc.c and changed algorithm
76 +* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
77 +- fixed error in nntp_logout_all()
79 +* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
80 +- fixed debug output in mutt_newsrc_update()
81 +- added optional support of LISTGROUP command
82 +- fixed typo in nntp_parse_xref()
84 +* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
87 +* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
90 +* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
93 +* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
95 +- added space after newsgroup name in .newsrc file
97 +* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
98 +- nntp patch: fixed SIGSEGV when posting article
100 +* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
103 +* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
105 +- replace safe_free calls by the FREE macro
107 +* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
109 +- nntp authentication can be passed after any command
111 +* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
114 +* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
117 +* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
119 +- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
120 + <reconstruct-thread> functions
121 +- fixed message about nntp reconnect
122 +- fixed <attach-news-message> function using browser
123 +- added support of Followup-To: poster
124 +- added %n (new articles) in group_index_format
125 +- posting articles without inews by default
127 +* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
130 +* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
133 +* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
135 +- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
136 +- added default content disposition
138 +* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
141 +* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
142 +- update to 1.3.23.2
143 +- fixed segfault if mutt_conn_find() returns null
145 +* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
146 +- update to 1.3.23.1
147 +- added support of LISTGROUP command
148 +- added support for servers with broken overview
149 +- disabled <flag-message> function on news server
150 +- fixed error storing bad authentication information
152 +* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
154 +- fixed typo in buffy.c
155 +- added substitution of %s parameter in $inews variable
157 +* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
158 +- update to 1.3.22.1
161 +* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
164 +* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
166 +- removed 'server-hook', use 'account-hook' instead
167 +- fixed error opening NNTP server without newsgroup using -f option
169 +* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
172 +* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
174 +- fixed typo in nntp_attempt_features()
175 +- changed algorithm of XGTITLE command testing
176 +- disabled writing of NNTP password in debug file
177 +- fixed reading and writing of long newsrc lines
178 +- changed checking of last line while reading lines from server
179 +- fixed possible buffer overrun in nntp_parse_newsrc_line()
180 +- removed checking of XHDR command
181 +- compare NNTP return codes without trailing space
183 +* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
185 +- support for 'LIST NEWSGROUPS' command to read descriptions
187 +* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
190 +* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
193 +* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
195 +- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
197 +* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
200 +* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
201 +- Fixed problem if last article in group is deleted
203 +* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
204 +- Fixed checking of XGTITLE command on some servers
206 +* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
207 +- Added \r in AUTHINFO commands
209 +* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
212 +* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
214 +- fixed error opening newsgroup from mutt started with -g or -G
216 +* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
218 +- hotkey 'G' (get-message) replaced with '^G'
220 +* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
222 +- changed delay displaying error messages from 1 to 2 seconds
223 +- fixed error compiling with nntp and without imap
225 +* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
226 +- fixed catchup in index
227 +- fixed nntp_open_mailbox()
229 +* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
230 +- functions <edit> and <delete-entry> disabled
231 +- format of news mailbox names changed to url form
232 +- option nntp_attempts removed
233 +- option reconnect_news renamed to nntp_reconnect
234 +- default value of nntp_poll changed from 30 to 60
235 +- error handling improved
237 +* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
239 +- new option show_only_unread
240 +- add newsgroup completion
242 +* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
245 +* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
248 +* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
250 +- authentication code update
251 +- fix for changing to newsgroup from mailbox with read messages
252 +- socket code optimization
254 +* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
257 +* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
258 +- don't substitute current newsgroup with deleted new messages
260 +* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
262 +- fix for substitution of newsgroup after reconnection
263 +- fix for loading newsgroups with very long names
264 +- fix for loading more than 32768 newsgroups
266 +* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
269 +* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
272 +* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
275 +* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
278 +* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
281 +* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
284 +* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
285 +- add substitution of newsgroup with new messages by default
287 +* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
288 +- add attach message from newsgroup
289 +- add one-line help in newsreader mode
290 +- disable 'change-dir' command in newsgroups browser
293 +* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
294 +- get default newsserver name from file /etc/nntpserver
295 +- use case insensitive server names
296 +- add print-style sequence %s to $newsrc
299 +* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
300 +- remove 'X-FTN-Origin' header processing
302 +* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
306 +* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
307 +- fix mutt_select_newsserver()
308 +- remove 'toggle-mode' function
309 +- add 'change-newsgroup' function
311 +* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
314 +* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
315 +- fix error 'bounce' function after 'post'
316 +- add 'forward to newsgroup' function
318 +* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
319 +- 'forward' function works in newsreader mode
320 +- add 'post' and 'followup' functions to pager and attachment menu
321 +- fix active descriptions and allowed flag reload
323 +* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
325 +- remove deleted newsgroups from list
327 +* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
328 +- update .newsrc in browser
330 +* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
331 +- reload .newsrc if externally modified
332 +- fix active cache update
334 +* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
337 +* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
338 +- patch *.update_list_file is not required
339 +- count lines when loading descriptions
340 +- remove cache of unsubscribed newsgroups
342 +* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
343 +- load list of newsgroups from cache faster
345 +* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
348 +* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
349 +- fix unread messages in browser
350 +- fix newsrc_gen_entries()
352 +* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
353 +- fix mutt_newsgroup_stat()
354 +- fix nntp_delete_cache()
355 +- fix nntp_get_status()
356 +- fix check_children()
357 +- fix nntp_fetch_headers()
359 +* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
362 +* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
363 +- fix updating new messages in cache
365 +* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
366 +- change default cache filenames
367 +- fix updating new messages in cache
369 +* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
370 +- fix segmentation fault in news groups browser
372 +* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
375 +* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
378 +* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
379 +- add X-Comment-To editing
380 +- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
381 +- add variables $ask_followup_to and $ask_x_comment_to
383 +* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
385 diff -udprP mutt-1.5.20.orig/OPS mutt-1.5.20/OPS
386 --- mutt-1.5.20.orig/OPS 2009-05-13 08:01:13.000000000 +0300
387 +++ mutt-1.5.20/OPS 2009-06-15 21:05:24.000000000 +0300
388 @@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
389 OP_BROWSER_NEW_FILE "select a new file in this directory"
390 OP_BROWSER_VIEW_FILE "view file"
391 OP_BROWSER_TELL "display the currently selected file's name"
392 -OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
393 -OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
394 +OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
395 +OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
396 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
397 OP_BUFFY_LIST "list mailboxes with new mail"
398 +OP_CATCHUP "mark all articles in newsgroup as read"
399 OP_CHANGE_DIRECTORY "change directories"
400 OP_CHECK_NEW "check mailboxes for new mail"
401 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
402 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
403 +OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message"
404 OP_COMPOSE_EDIT_BCC "edit the BCC list"
405 OP_COMPOSE_EDIT_CC "edit the CC list"
406 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
407 @@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
408 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
409 OP_COMPOSE_EDIT_MESSAGE "edit the message"
410 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
411 +OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
412 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
413 +OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
414 +OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
415 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
416 OP_COMPOSE_EDIT_TO "edit the TO list"
417 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
418 @@ -85,8 +90,13 @@ OP_EXIT "exit this menu"
419 OP_FILTER "filter attachment through a shell command"
420 OP_FIRST_ENTRY "move to the first entry"
421 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
422 +OP_FOLLOWUP "followup to newsgroup"
423 +OP_FORWARD_TO_GROUP "forward to newsgroup"
424 OP_FORWARD_MESSAGE "forward a message with comments"
425 OP_GENERIC_SELECT_ENTRY "select the current entry"
426 +OP_GET_CHILDREN "get all children of the current message"
427 +OP_GET_MESSAGE "get message with Message-Id"
428 +OP_GET_PARENT "get parent of the current message"
429 OP_GROUP_REPLY "reply to all recipients"
430 OP_HALF_DOWN "scroll down 1/2 page"
431 OP_HALF_UP "scroll up 1/2 page"
432 @@ -94,11 +104,14 @@ OP_HELP "this screen"
433 OP_JUMP "jump to an index number"
434 OP_LAST_ENTRY "move to the last entry"
435 OP_LIST_REPLY "reply to specified mailing list"
436 +OP_LOAD_ACTIVE "load active file from NNTP server"
437 OP_MACRO "execute a macro"
438 OP_MAIL "compose a new mail message"
439 OP_MAIN_BREAK_THREAD "break the thread in two"
440 OP_MAIN_CHANGE_FOLDER "open a different folder"
441 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
442 +OP_MAIN_CHANGE_GROUP "open a different newsgroup"
443 +OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
444 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
445 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
446 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
447 @@ -137,6 +150,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
448 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
449 OP_PAGER_TOP "jump to the top of the message"
450 OP_PIPE "pipe message/attachment to a shell command"
451 +OP_POST "post message to newsgroup"
452 OP_PREV_ENTRY "move to the previous entry"
453 OP_PREV_LINE "scroll up one line"
454 OP_PREV_PAGE "move to the previous page"
455 @@ -145,6 +159,7 @@ OP_QUERY "query external program for add
456 OP_QUERY_APPEND "append new query results to current results"
457 OP_QUIT "save changes to mailbox and quit"
458 OP_RECALL_MESSAGE "recall a postponed message"
459 +OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
460 OP_REDRAW "clear and redraw the screen"
461 OP_REFORMAT_WINCH "{internal}"
462 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
463 @@ -159,18 +174,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
464 OP_SHELL_ESCAPE "invoke a command in a subshell"
465 OP_SORT "sort messages"
466 OP_SORT_REVERSE "sort messages in reverse order"
467 +OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
468 OP_TAG "tag the current entry"
469 OP_TAG_PREFIX "apply next function to tagged messages"
470 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
471 OP_TAG_SUBTHREAD "tag the current subthread"
472 OP_TAG_THREAD "tag the current thread"
473 OP_TOGGLE_NEW "toggle a message's 'new' flag"
474 +OP_TOGGLE_READ "toggle view of read messages"
475 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
476 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
477 OP_TOP_PAGE "move to the top of the page"
478 +OP_UNCATCHUP "mark all articles in newsgroup as unread"
479 OP_UNDELETE "undelete the current entry"
480 OP_UNDELETE_THREAD "undelete all messages in thread"
481 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
482 +OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
483 OP_VERSION "show the Mutt version number and date"
484 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
485 OP_VIEW_ATTACHMENTS "show MIME attachments"
486 diff -udprP mutt-1.5.20.orig/PATCHES mutt-1.5.20/PATCHES
487 --- mutt-1.5.20.orig/PATCHES 2008-11-11 21:55:46.000000000 +0200
488 +++ mutt-1.5.20/PATCHES 2009-06-15 21:05:24.000000000 +0300
491 diff -udprP mutt-1.5.20.orig/account.c mutt-1.5.20/account.c
492 --- mutt-1.5.20.orig/account.c 2008-11-11 21:55:46.000000000 +0200
493 +++ mutt-1.5.20/account.c 2009-06-15 21:05:24.000000000 +0300
494 @@ -51,6 +51,11 @@ int mutt_account_match (const ACCOUNT* a
499 + if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
503 if (a1->flags & a2->flags & M_ACCT_USER)
504 return (!strcmp (a1->user, a2->user));
505 if (a1->flags & M_ACCT_USER)
506 @@ -130,6 +135,16 @@ void mutt_account_tourl (ACCOUNT* accoun
511 + if (account->type == M_ACCT_TYPE_NNTP)
513 + if (account->flags & M_ACCT_SSL)
514 + url->scheme = U_NNTPS;
516 + url->scheme = U_NNTP;
520 url->host = account->host;
521 if (account->flags & M_ACCT_PORT)
522 url->port = account->port;
523 @@ -155,6 +170,10 @@ int mutt_account_getuser (ACCOUNT* accou
524 else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
525 strfcpy (account->user, PopUser, sizeof (account->user));
528 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
529 + strfcpy (account->user, NntpUser, sizeof (account->user));
531 /* prompt (defaults to unix username), copy into account->user */
534 @@ -215,6 +234,10 @@ int mutt_account_getpass (ACCOUNT* accou
535 else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass)
536 strfcpy (account->pass, SmtpPass, sizeof (account->pass));
539 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
540 + strfcpy (account->pass, NntpPass, sizeof (account->pass));
544 snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
545 diff -udprP mutt-1.5.20.orig/account.h mutt-1.5.20/account.h
546 --- mutt-1.5.20.orig/account.h 2008-11-11 21:55:46.000000000 +0200
547 +++ mutt-1.5.20/account.h 2009-06-15 21:05:24.000000000 +0300
548 @@ -29,7 +29,8 @@ enum
549 M_ACCT_TYPE_NONE = 0,
558 diff -udprP mutt-1.5.20.orig/attach.h mutt-1.5.20/attach.h
559 --- mutt-1.5.20.orig/attach.h 2008-11-11 21:55:46.000000000 +0200
560 +++ mutt-1.5.20/attach.h 2009-06-15 21:05:24.000000000 +0300
561 @@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f
563 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
564 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
565 -void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
566 +void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
567 void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
569 #endif /* _ATTACH_H_ */
570 diff -udprP mutt-1.5.20.orig/browser.c mutt-1.5.20/browser.c
571 --- mutt-1.5.20.orig/browser.c 2009-06-11 20:52:54.000000000 +0300
572 +++ mutt-1.5.20/browser.c 2009-06-15 21:05:24.000000000 +0300
583 @@ -49,6 +52,19 @@ static struct mapping_t FolderHelp[] = {
588 +static struct mapping_t FolderNewsHelp[] = {
589 + { N_("Exit"), OP_EXIT },
590 + { N_("List"), OP_TOGGLE_MAILBOXES },
591 + { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
592 + { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
593 + { N_("Catchup"), OP_CATCHUP },
594 + { N_("Mask"), OP_ENTER_MASK },
595 + { N_("Help"), OP_HELP },
600 typedef struct folder_t
602 struct folder_file *ff;
603 @@ -114,9 +130,17 @@ static void browser_sort (struct browser
608 + if (option (OPTNEWS))
611 f = browser_compare_date;
615 + if (option (OPTNEWS))
618 f = browser_compare_size;
621 @@ -307,8 +331,106 @@ folder_format_str (char *dest, size_t de
627 +newsgroup_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
628 + const char *fmt, const char *ifstring, const char *elsestring,
629 + unsigned long data, format_flag flags)
631 + char fn[SHORT_STRING], tmp[SHORT_STRING];
632 + FOLDER *folder = (FOLDER *) data;
637 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
638 + snprintf (dest, destlen, tmp, folder->num + 1);
642 + strncpy (fn, folder->ff->name, sizeof(fn) - 1);
643 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
644 + snprintf (dest, destlen, tmp, fn);
648 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
649 + if (folder->ff->nd->subscribed)
650 + snprintf (dest, destlen, tmp, ' ');
652 + snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
656 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
657 + if (folder->ff->nd->deleted)
658 + snprintf (dest, destlen, tmp, 'D');
660 + snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
664 + if (flags & M_FORMAT_OPTIONAL)
666 + if (folder->ff->nd->unread != 0)
667 + mutt_FormatString (dest, destlen, col, ifstring, newsgroup_format_str,
670 + mutt_FormatString (dest, destlen, col, elsestring, newsgroup_format_str,
673 + else if (Context && Context->data == folder->ff->nd)
675 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
676 + snprintf (dest, destlen, tmp, Context->unread);
680 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
681 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
686 + if (Context && Context->data == folder->ff->nd)
688 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
689 + snprintf (dest, destlen, tmp, Context->new);
691 + else if (option (OPTMARKOLD) &&
692 + folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
693 + folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
695 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
696 + snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
700 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
701 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
706 + if (folder->ff->nd->desc != NULL)
708 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
709 + snprintf (dest, destlen, tmp, folder->ff->nd->desc);
713 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
714 + snprintf (dest, destlen, tmp, "");
720 +#endif /* USE_NNTP */
722 static void add_folder (MUTTMENU *m, struct browser_state *state,
723 - const char *name, const struct stat *s, int new)
724 + const char *name, const struct stat *s,
725 + void *data, int new)
727 if (state->entrylen == state->entrymax)
729 @@ -337,6 +459,10 @@ static void add_folder (MUTTMENU *m, str
731 (state->entry)[state->entrylen].imap = 0;
734 + if (option (OPTNEWS))
735 + (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
740 @@ -352,9 +478,35 @@ static void init_state (struct browser_s
741 menu->data = state->entry;
744 +/* get list of all files/newsgroups with mask */
745 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
746 char *d, const char *prefix)
749 + if (option (OPTNEWS))
753 + NNTP_SERVER *news = CurrentNewsSrv;
755 +/* mutt_buffy_check (0); */
756 + init_state (state, menu);
758 + for (tmp = news->list; tmp; tmp = tmp->next)
760 + if (!(data = (NNTP_DATA *)tmp->data))
762 + if (prefix && *prefix && strncmp (prefix, data->group,
763 + strlen (prefix)) != 0)
765 + if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
767 + add_folder (menu, state, data->group, NULL, data, data->new);
771 +#endif /* USE_NNTP */
776 @@ -415,17 +567,40 @@ static int examine_directory (MUTTMENU *
778 while (tmp && mutt_strcmp (buffer, tmp->path))
780 - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
781 + add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
786 browser_sort (state);
790 +/* get list of mailboxes/subscribed newsgroups */
791 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
794 char buffer[LONG_STRING];
797 + if (option (OPTNEWS))
801 + NNTP_SERVER *news = CurrentNewsSrv;
803 +/* mutt_buffy_check (0); */
804 + init_state (state, menu);
806 + for (tmp = news->list; tmp; tmp = tmp->next)
808 + if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
809 + (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
810 + add_folder (menu, state, data->group, NULL, data, data->new);
816 BUFFY *tmp = Incoming;
818 struct mailbox_state mbox;
819 @@ -443,14 +618,21 @@ static int examine_mailboxes (MUTTMENU *
820 if (mx_is_imap (tmp->path))
822 imap_mailbox_state (tmp->path, &mbox);
823 - add_folder (menu, state, tmp->path, NULL, mbox.new);
824 + add_folder (menu, state, tmp->path, NULL, NULL, mbox.new);
829 if (mx_is_pop (tmp->path))
831 - add_folder (menu, state, tmp->path, NULL, tmp->new);
832 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
837 + if (mx_is_nntp (tmp->path))
839 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
843 @@ -479,15 +661,20 @@ static int examine_mailboxes (MUTTMENU *
844 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
845 mutt_pretty_mailbox (buffer, sizeof (buffer));
847 - add_folder (menu, state, buffer, &s, tmp->new);
848 + add_folder (menu, state, buffer, &s, NULL, tmp->new);
850 while ((tmp = tmp->next));
852 browser_sort (state);
856 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
859 + if (option (OPTNEWS))
860 + return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
862 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
865 @@ -498,6 +685,12 @@ static void folder_entry (char *s, size_
866 folder.ff = &((struct folder_file *) menu->data)[num];
870 + if (option (OPTNEWS))
871 + mutt_FormatString (s, slen, 0, NONULL(GroupFormat), newsgroup_format_str,
872 + (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
875 mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str,
876 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
878 @@ -518,6 +711,17 @@ static void init_menu (struct browser_st
883 + if (option (OPTNEWS))
886 + snprintf (title, titlelen, _("Subscribed newsgroups"));
888 + snprintf (title, titlelen, _("Newsgroups on server [%s]"),
889 + CurrentNewsSrv->conn->account.host);
894 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
896 @@ -573,6 +777,31 @@ void _mutt_select_file (char *f, size_t
898 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
901 + if (option (OPTNEWS))
904 + strfcpy (prefix, f, sizeof (prefix));
909 + /* default state for news reader mode is browse subscribed newsgroups */
911 + for (list = CurrentNewsSrv->list; list; list = list->next)
913 + NNTP_DATA *data = (NNTP_DATA *) list->data;
915 + if (data && data->subscribed)
927 mutt_expand_path (f, flen);
928 @@ -669,6 +898,9 @@ void _mutt_select_file (char *f, size_t
929 menu->tag = file_tag;
931 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
933 + (option (OPTNEWS)) ? FolderNewsHelp :
937 init_menu (&state, menu, title, sizeof (title), buffy);
938 @@ -807,7 +1039,11 @@ void _mutt_select_file (char *f, size_t
943 + if (buffy || option (OPTNEWS)) /* news have not path */
948 strfcpy (f, state.entry[menu->current].name, flen);
949 mutt_expand_path (f, flen);
950 @@ -865,14 +1101,6 @@ void _mutt_select_file (char *f, size_t
954 - case OP_BROWSER_SUBSCRIBE:
955 - imap_subscribe (state.entry[menu->current].name, 1);
958 - case OP_BROWSER_UNSUBSCRIBE:
959 - imap_subscribe (state.entry[menu->current].name, 0);
962 case OP_BROWSER_TOGGLE_LSUB:
963 if (option (OPTIMAPLSUB))
964 unset_option (OPTIMAPLSUB);
965 @@ -973,6 +1201,11 @@ void _mutt_select_file (char *f, size_t
967 case OP_CHANGE_DIRECTORY:
970 + if (option (OPTNEWS))
974 strfcpy (buf, LastDir, sizeof (buf));
976 if (!state.imap_browse)
977 @@ -1239,6 +1472,190 @@ void _mutt_select_file (char *f, size_t
979 mutt_error _("Error trying to view file");
986 + if (option (OPTNEWS))
988 + struct folder_file *f = &state.entry[menu->current];
991 + if (i == OP_CATCHUP)
992 + nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
994 + nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
999 + struct folder_file ff;
1000 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1003 + folder.ff->name = f->name;
1004 + folder.ff->st = NULL;
1005 + folder.ff->is_new = nd->new;
1006 + folder.ff->nd = nd;
1008 + mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1009 + newsgroup_format_str, (unsigned long) &folder,
1010 + M_FORMAT_ARROWCURSOR);
1011 + f->desc = safe_strdup (buffer); */
1012 + if (menu->current + 1 < menu->max)
1014 + menu->redraw = REDRAW_MOTION_RESYNCH;
1019 + case OP_LOAD_ACTIVE:
1020 + if (!option (OPTNEWS))
1027 + for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
1029 + if ((data = (NNTP_DATA *)tmp->data))
1030 + data->deleted = 1;
1033 + nntp_get_active (CurrentNewsSrv);
1035 + destroy_state (&state);
1037 + examine_mailboxes (menu, &state);
1039 + examine_directory (menu, &state, NULL, NULL);
1040 + init_menu (&state, menu, title, sizeof (title), buffy);
1042 +#endif /* USE_NNTP */
1044 +#if defined USE_IMAP || defined USE_NNTP
1045 + case OP_BROWSER_SUBSCRIBE:
1046 + case OP_BROWSER_UNSUBSCRIBE:
1049 + case OP_SUBSCRIBE_PATTERN:
1050 + case OP_UNSUBSCRIBE_PATTERN:
1051 + if (option (OPTNEWS))
1053 + regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1055 + int j = menu->current;
1057 + NNTP_SERVER *news = CurrentNewsSrv;
1059 + if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1065 + if (i == OP_SUBSCRIBE_PATTERN)
1066 + snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1068 + snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1069 + if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1075 + if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1077 + regerror (err, rx, buf, sizeof (buf));
1080 + mutt_error ("%s", buf);
1083 + menu->redraw = REDRAW_FULL;
1086 + else if (!state.entrylen)
1088 + mutt_error _("No newsgroups match the mask");
1092 + for ( ; j < state.entrylen; j++)
1094 + struct folder_file *f = &state.entry[j];
1096 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1097 + regexec (rx, f->name, 0, NULL, 0) == 0)
1099 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1100 + nd = mutt_newsgroup_subscribe (news, f->name);
1102 + nd = mutt_newsgroup_unsubscribe (news, f->name);
1106 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1108 + folder.name = f->name;
1110 + folder.new = nd->new;
1113 + mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1114 + newsgroup_format_str, (unsigned long) &folder,
1115 + M_FORMAT_ARROWCURSOR);
1116 + f->desc = safe_strdup (buffer);
1119 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1121 + if (menu->current + 1 < menu->max)
1123 + menu->redraw = REDRAW_MOTION_RESYNCH;
1127 + if (i == OP_SUBSCRIBE_PATTERN)
1129 + LIST *grouplist = NULL;
1132 + grouplist = news->list;
1133 + for (; grouplist; grouplist = grouplist->next)
1135 + nd = (NNTP_DATA *) grouplist->data;
1136 + if (nd && nd->group && !nd->subscribed)
1138 + if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1140 + mutt_newsgroup_subscribe (news, nd->group);
1141 + add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1145 + init_menu (&state, menu, title, sizeof (title), buffy);
1147 + mutt_newsrc_update (news);
1148 + nntp_clear_cacheindex (news);
1149 + if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1155 +#endif /* USE_IMAP && USE_NNTP */
1156 +#endif /* USE_NNTP */
1159 + if (i == OP_BROWSER_SUBSCRIBE)
1160 + imap_subscribe (state.entry[menu->current].name, 1);
1162 + imap_subscribe (state.entry[menu->current].name, 0);
1164 +#endif /* USE_IMAP */
1168 diff -udprP mutt-1.5.20.orig/browser.h mutt-1.5.20/browser.h
1169 --- mutt-1.5.20.orig/browser.h 2009-01-05 00:34:12.000000000 +0200
1170 +++ mutt-1.5.20/browser.h 2009-06-15 21:05:24.000000000 +0300
1173 #define _BROWSER_H 1
1182 @@ -37,6 +41,9 @@ struct folder_file
1183 unsigned selectable : 1;
1184 unsigned inferiors : 1;
1189 unsigned tagged : 1;
1192 diff -udprP mutt-1.5.20.orig/buffy.c mutt-1.5.20/buffy.c
1193 --- mutt-1.5.20.orig/buffy.c 2009-06-02 20:16:26.000000000 +0300
1194 +++ mutt-1.5.20/buffy.c 2009-06-15 21:05:24.000000000 +0300
1195 @@ -320,6 +320,9 @@ int mutt_buffy_check (int force)
1197 if (!Context || Context->magic != M_POP)
1200 + if (!Context || Context->magic != M_NNTP)
1202 /* check device ID and serial number instead of comparing paths */
1203 if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0)
1205 @@ -343,6 +346,11 @@ int mutt_buffy_check (int force)
1210 + if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1211 + tmp->magic = M_NNTP;
1214 if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
1215 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1217 @@ -360,25 +368,21 @@ int mutt_buffy_check (int force)
1218 /* check to see if the folder is the currently selected folder
1220 if (!Context || !Context->path ||
1221 -#if defined USE_IMAP || defined USE_POP
1226 - tmp->magic == M_IMAP
1227 + || tmp->magic == M_IMAP
1233 - tmp->magic == M_POP
1235 - ) ? mutt_strcmp (tmp->path, Context->path) :
1236 + || tmp->magic == M_POP
1238 - (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1239 -#if defined USE_IMAP || defined USE_POP
1242 + || tmp->magic == M_NNTP
1246 + ) ? mutt_strcmp (tmp->path, Context->path) :
1247 + (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1253 diff -udprP mutt-1.5.20.orig/complete.c mutt-1.5.20/complete.c
1254 --- mutt-1.5.20.orig/complete.c 2009-01-05 00:38:16.000000000 +0200
1255 +++ mutt-1.5.20/complete.c 2009-06-15 21:05:24.000000000 +0300
1257 #include "mailbox.h"
1266 @@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen)
1267 char filepart[_POSIX_PATH_MAX];
1269 char imap_path[LONG_STRING];
1272 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1275 + if (option (OPTNEWS))
1277 + LIST *l = CurrentNewsSrv->list;
1279 + strfcpy (filepart, s, sizeof (filepart));
1282 + * special case to handle when there is no filepart yet.
1283 + * find the first subscribed newsgroup
1285 + if ((len = mutt_strlen (filepart)) == 0)
1287 + for (; l; l = l->next)
1289 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1291 + if (data && data->subscribed)
1293 + strfcpy (filepart, data->group, sizeof (filepart));
1301 + for (; l; l = l->next)
1303 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1305 + if (data && data->subscribed &&
1306 + mutt_strncmp (data->group, filepart, len) == 0)
1310 + for (i = 0; filepart[i] && data->group[i]; i++)
1312 + if (filepart[i] != data->group[i])
1322 + strfcpy (filepart, data->group, sizeof (filepart));
1328 + strcpy (s, filepart);
1330 + return (init ? 0 : -1);
1335 /* we can use '/' as a delimiter, imap_complete rewrites it */
1336 if (*s == '=' || *s == '+' || *s == '!')
1338 diff -udprP mutt-1.5.20.orig/compose.c mutt-1.5.20/compose.c
1339 --- mutt-1.5.20.orig/compose.c 2009-03-31 09:52:43.000000000 +0300
1340 +++ mutt-1.5.20/compose.c 2009-06-15 21:05:24.000000000 +0300
1342 #include "mailbox.h"
1344 #include "charset.h"
1348 #include "remailer.h"
1357 @@ -60,18 +65,21 @@ enum
1374 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1377 -#define HDR_XOFFSET 10
1378 -#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1379 +#define HDR_XOFFSET 14
1380 +#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1381 #define W (COLS - HDR_XOFFSET)
1383 static char *Prompts[] =
1384 @@ -83,6 +91,16 @@ static char *Prompts[] =
1400 static struct mapping_t ComposeHelp[] = {
1401 @@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] =
1406 +static struct mapping_t ComposeNewsHelp[] = {
1407 + { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1408 + { N_("Abort"), OP_EXIT },
1409 + { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1410 + { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1411 + { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1412 + { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1413 + { N_("Help"), OP_HELP },
1418 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1420 mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt,
1421 @@ -115,16 +146,16 @@ static void redraw_crypt_lines (HEADER *
1422 if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
1425 - mvaddstr (HDR_CRYPT, 0, "Security: ");
1426 + mvaddstr (HDR_CRYPT, 0, " Security: ");
1427 else if (msg->security & APPLICATION_SMIME)
1428 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1429 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1430 else if (msg->security & APPLICATION_PGP)
1431 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1432 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1434 else if ((WithCrypto & APPLICATION_SMIME))
1435 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1436 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1437 else if ((WithCrypto & APPLICATION_PGP))
1438 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1439 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1443 @@ -252,9 +283,28 @@ static void draw_envelope_addr (int line
1444 static void draw_envelope (HEADER *msg, char *fcc)
1446 draw_envelope_addr (HDR_FROM, msg->env->from);
1448 + if (!option (OPTNEWSSEND))
1451 draw_envelope_addr (HDR_TO, msg->env->to);
1452 draw_envelope_addr (HDR_CC, msg->env->cc);
1453 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1458 + mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1459 + mutt_paddstr (W, NONULL (msg->env->newsgroups));
1460 + mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1461 + mutt_paddstr (W, NONULL (msg->env->followup_to));
1462 + if (option (OPTXCOMMENTTO))
1464 + mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1465 + mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1469 mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1470 mutt_paddstr (W, NONULL (msg->env->subject));
1471 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1472 @@ -507,6 +557,12 @@ int mutt_compose_menu (HEADER *msg, /*
1473 /* Sort, SortAux could be changed in mutt_index_menu() */
1474 int oldSort, oldSortAux;
1477 + int news = 0; /* is it a news article ? */
1479 + if (option (OPTNEWSSEND))
1483 mutt_attach_init (msg->content);
1484 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
1485 @@ -517,10 +573,18 @@ int mutt_compose_menu (HEADER *msg, /*
1486 menu->make_entry = snd_entry;
1487 menu->tag = mutt_tag_attach;
1491 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1494 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1499 + unset_option (OPTNEWS); /* for any case */
1501 switch (op = mutt_menuLoop (menu))
1504 @@ -533,17 +597,87 @@ int mutt_compose_menu (HEADER *msg, /*
1505 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1507 case OP_COMPOSE_EDIT_TO:
1512 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1513 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1515 case OP_COMPOSE_EDIT_BCC:
1520 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1521 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1523 case OP_COMPOSE_EDIT_CC:
1528 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1529 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1532 + case OP_COMPOSE_EDIT_NEWSGROUPS:
1535 + if (msg->env->newsgroups)
1536 + strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1539 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1541 + FREE (&msg->env->newsgroups);
1542 + mutt_remove_trailing_ws (buf);
1543 + msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1544 + move (HDR_TO, HDR_XOFFSET);
1546 + if (msg->env->newsgroups)
1547 + printw ("%-*.*s", W, W, msg->env->newsgroups);
1552 + case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1556 + if (msg->env->followup_to)
1557 + strfcpy (buf, msg->env->followup_to, sizeof (buf));
1558 + if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1560 + FREE (&msg->env->followup_to);
1561 + mutt_remove_trailing_ws (buf);
1562 + msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1563 + move (HDR_CC, HDR_XOFFSET);
1565 + if (msg->env->followup_to)
1566 + printw ("%-*.*s", W, W, msg->env->followup_to);
1571 + case OP_COMPOSE_EDIT_X_COMMENT_TO:
1572 + if (news && option (OPTXCOMMENTTO))
1575 + if (msg->env->x_comment_to)
1576 + strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1577 + if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1579 + FREE (&msg->env->x_comment_to);
1580 + msg->env->x_comment_to = safe_strdup (buf);
1581 + move (HDR_BCC, HDR_XOFFSET);
1583 + if (msg->env->x_comment_to)
1584 + printw ("%-*.*s", W, W, msg->env->x_comment_to);
1589 case OP_COMPOSE_EDIT_SUBJECT:
1590 if (msg->env->subject)
1591 strfcpy (buf, msg->env->subject, sizeof (buf));
1592 @@ -706,6 +840,9 @@ int mutt_compose_menu (HEADER *msg, /*
1595 case OP_COMPOSE_ATTACH_MESSAGE:
1597 + case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1602 @@ -713,7 +850,22 @@ int mutt_compose_menu (HEADER *msg, /*
1604 prompt = _("Open mailbox to attach message from");
1607 + unset_option (OPTNEWS);
1608 + if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1610 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1613 + prompt = _("Open newsgroup to attach message from");
1614 + set_option (OPTNEWS);
1620 + if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1623 strfcpy (fname, NONULL (Context->path), sizeof (fname));
1624 mutt_pretty_mailbox (fname, sizeof (fname));
1625 @@ -722,6 +874,11 @@ int mutt_compose_menu (HEADER *msg, /*
1626 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1630 + if (option (OPTNEWS))
1631 + nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1634 mutt_expand_path (fname, sizeof (fname));
1636 if (!mx_is_imap (fname))
1637 @@ -729,6 +886,9 @@ int mutt_compose_menu (HEADER *msg, /*
1639 if (!mx_is_pop (fname))
1642 + if (!mx_is_nntp (fname) && !option (OPTNEWS))
1644 /* check to make sure the file exists and is readable */
1645 if (access (fname, R_OK) == -1)
1647 diff -udprP mutt-1.5.20.orig/config.h.in mutt-1.5.20/config.h.in
1648 --- mutt-1.5.20.orig/config.h.in 2009-06-09 09:51:15.000000000 +0300
1649 +++ mutt-1.5.20/config.h.in 2009-06-15 21:05:24.000000000 +0300
1651 significant more memory when defined. */
1652 #undef EXACT_ADDRESS
1654 +/* Compiling with newsreading support with NNTP */
1657 /* program to use for shell commands */
1660 diff -udprP mutt-1.5.20.orig/configure.ac mutt-1.5.20/configure.ac
1661 --- mutt-1.5.20.orig/configure.ac 2009-06-09 09:50:33.000000000 +0300
1662 +++ mutt-1.5.20/configure.ac 2009-06-15 21:05:24.000000000 +0300
1663 @@ -599,6 +599,14 @@ if test x"$need_imap" = xyes -o x"$need_
1664 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1667 +AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1668 +[ if test x$enableval = xyes ; then
1669 + AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1670 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1675 dnl -- end socket dependencies --
1677 if test "$need_socket" = "yes"
1678 diff -udprP mutt-1.5.20.orig/curs_main.c mutt-1.5.20/curs_main.c
1679 --- mutt-1.5.20.orig/curs_main.c 2009-06-14 05:48:36.000000000 +0300
1680 +++ mutt-1.5.20/curs_main.c 2009-06-15 21:47:09.000000000 +0300
1684 #include "mutt_curses.h"
1686 #include "mutt_menu.h"
1687 #include "mailbox.h"
1688 #include "mapping.h"
1691 #include "mutt_crypt.h"
1700 @@ -413,12 +418,27 @@ static struct mapping_t IndexHelp[] = {
1705 +struct mapping_t IndexNewsHelp[] = {
1706 + { N_("Quit"), OP_QUIT },
1707 + { N_("Del"), OP_DELETE },
1708 + { N_("Undel"), OP_UNDELETE },
1709 + { N_("Save"), OP_SAVE },
1710 + { N_("Post"), OP_POST },
1711 + { N_("Followup"), OP_FOLLOWUP },
1712 + { N_("Catchup"), OP_CATCHUP },
1713 + { N_("Help"), OP_HELP },
1718 /* This function handles the message index window as well as commands returned
1719 * from the pager (MENU_PAGER).
1721 int mutt_index_menu (void)
1723 char buf[LONG_STRING], helpstr[LONG_STRING];
1726 int done = 0; /* controls when to exit the "event" loop */
1728 @@ -439,7 +459,11 @@ int mutt_index_menu (void)
1729 menu->make_entry = index_make_entry;
1730 menu->color = index_color;
1731 menu->current = ci_first_message ();
1732 - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1733 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1735 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1740 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
1741 @@ -690,6 +714,9 @@ int mutt_index_menu (void)
1742 imap_disallow_reopen (Context);
1746 + unset_option (OPTNEWS); /* for any case */
1751 @@ -740,6 +767,120 @@ int mutt_index_menu (void)
1752 menu_current_bottom (menu);
1756 + case OP_GET_MESSAGE:
1757 + case OP_GET_PARENT:
1759 + if (Context->magic == M_NNTP)
1763 + if (op == OP_GET_MESSAGE)
1766 + if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1772 + LIST *ref = CURHDR->env->references;
1775 + mutt_error _("Article has no parent reference!");
1778 + strfcpy (buf, ref->data, sizeof (buf));
1780 + if (!Context->id_hash)
1781 + Context->id_hash = mutt_make_id_hash (Context);
1782 + if ((h = hash_find (Context->id_hash, buf)))
1784 + if (h->virtual != -1)
1786 + menu->current = h->virtual;
1787 + menu->redraw = REDRAW_MOTION_RESYNCH;
1789 + else if (h->collapsed)
1791 + mutt_uncollapse_thread (Context, h);
1792 + mutt_set_virtual (Context);
1793 + menu->current = h->virtual;
1794 + menu->redraw = REDRAW_MOTION_RESYNCH;
1797 + mutt_error _("Message not visible in limited view.");
1801 + if (nntp_check_msgid (Context, buf) == 0)
1803 + h = Context->hdrs[Context->msgcount-1];
1804 + mutt_sort_headers (Context, 0);
1805 + menu->current = h->virtual;
1806 + menu->redraw = REDRAW_FULL;
1809 + mutt_error (_("Article %s not found on server"), buf);
1814 + case OP_GET_CHILDREN:
1815 + case OP_RECONSTRUCT_THREAD:
1817 + if (Context->magic == M_NNTP)
1820 + int old = CURHDR->index, i;
1822 + if (!CURHDR->env->message_id)
1824 + mutt_error _("No Message-Id. Unable to perform operation");
1828 + if (!Context->id_hash)
1829 + Context->id_hash = mutt_make_id_hash (Context);
1830 + strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1832 + if (op == OP_RECONSTRUCT_THREAD)
1834 + LIST *ref = CURHDR->env->references;
1837 + nntp_check_msgid (Context, ref->data);
1838 + /* the last msgid in References is the root message */
1840 + strfcpy (buf, ref->data, sizeof (buf));
1844 + mutt_message _("Check for children of message...");
1845 + if (nntp_check_children (Context, buf) == 0)
1847 + mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1848 + h = hash_find (Context->id_hash, buf);
1849 + /* if the root message was retrieved, move to it */
1851 + menu->current = h->virtual;
1852 + else /* try to restore old position */
1853 + for (i = 0; i < Context->msgcount; i++)
1854 + if (Context->hdrs[i]->index == old)
1856 + menu->current = Context->hdrs[i]->virtual;
1857 + /* As an added courtesy, recenter the menu
1858 + * with the current entry at the middle of the screen */
1859 + menu_check_recenter (menu);
1860 + menu_current_middle (menu);
1863 + menu->redraw = REDRAW_FULL;
1864 + mutt_clear_error ();
1872 @@ -836,11 +977,33 @@ int mutt_index_menu (void)
1876 + case OP_TOGGLE_READ:
1879 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1881 - if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1882 + if (op == OP_TOGGLE_READ)
1884 + char buf[LONG_STRING];
1886 + if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1888 + snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1889 + Context->pattern ? Context->pattern : ".*");
1890 + set_option (OPTHIDEREAD);
1894 + strfcpy (buf, Context->pattern + 8, sizeof(buf));
1895 + if (!*buf || strncmp (buf, ".*", 2) == 0)
1896 + snprintf (buf, sizeof(buf), "~A");
1897 + unset_option (OPTHIDEREAD);
1899 + FREE (&Context->pattern);
1900 + Context->pattern = safe_strdup (buf);
1902 + if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1903 + mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1905 if (menu->oldcurrent >= 0)
1907 @@ -1057,15 +1220,22 @@ int mutt_index_menu (void)
1909 case OP_MAIN_CHANGE_FOLDER:
1910 case OP_MAIN_NEXT_UNREAD_MAILBOX:
1913 - op = OP_MAIN_CHANGE_FOLDER_READONLY;
1915 - /* fallback to the readonly case */
1917 case OP_MAIN_CHANGE_FOLDER_READONLY:
1919 + case OP_MAIN_CHANGE_GROUP:
1920 + case OP_MAIN_CHANGE_GROUP_READONLY:
1921 + unset_option (OPTNEWS);
1923 + if (attach_msg || option (OPTREADONLY) ||
1925 + op == OP_MAIN_CHANGE_GROUP_READONLY ||
1927 + op == OP_MAIN_CHANGE_FOLDER_READONLY)
1928 + flags = M_READONLY;
1932 - if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1934 cp = _("Open mailbox in read-only mode");
1936 cp = _("Open mailbox");
1937 @@ -1084,6 +1254,21 @@ int mutt_index_menu (void)
1942 + if (op == OP_MAIN_CHANGE_GROUP ||
1943 + op == OP_MAIN_CHANGE_GROUP_READONLY)
1945 + set_option (OPTNEWS);
1946 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1949 + cp = _("Open newsgroup in read-only mode");
1951 + cp = _("Open newsgroup");
1956 mutt_buffy (buf, sizeof (buf));
1958 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1959 @@ -1103,6 +1288,14 @@ int mutt_index_menu (void)
1964 + if (option (OPTNEWS))
1966 + unset_option (OPTNEWS);
1967 + nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1971 mutt_expand_path (buf, sizeof (buf));
1972 if (mx_get_magic (buf) <= 0)
1974 @@ -1140,15 +1333,18 @@ int mutt_index_menu (void)
1975 CurrentMenu = MENU_MAIN;
1976 mutt_folder_hook (buf);
1978 - if ((Context = mx_open_mailbox (buf,
1979 - (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1980 - M_READONLY : 0, NULL)) != NULL)
1981 + if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1983 menu->current = ci_first_message ();
1989 + /* mutt_buffy_check() must be done with mail-reader mode! */
1990 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1991 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1993 mutt_clear_error ();
1994 mutt_buffy_check(1); /* force the buffy check after we have changed
1996 @@ -1519,6 +1715,15 @@ int mutt_index_menu (void)
1998 CHECK_ACL(M_ACL_WRITE, _("flag message"));
2001 + if (Context->magic == M_NNTP)
2004 + mutt_error _("Can't change 'important' flag on NNTP server.");
2011 for (j = 0; j < Context->vcount; j++)
2012 @@ -1866,6 +2071,17 @@ int mutt_index_menu (void)
2018 + if (Context && Context->magic == M_NNTP)
2020 + if (mutt_newsgroup_catchup (CurrentNewsSrv,
2021 + ((NNTP_DATA *)Context->data)->group))
2022 + menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2027 case OP_DISPLAY_ADDRESS:
2030 @@ -1993,6 +2209,15 @@ int mutt_index_menu (void)
2031 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2036 + if (Context->magic == M_NNTP)
2039 + mutt_error _("Can't edit message on newsserver.");
2044 MAYBE_REDRAW (menu->redraw);
2046 @@ -2065,6 +2290,41 @@ int mutt_index_menu (void)
2047 menu->redraw = REDRAW_FULL;
2052 + case OP_FORWARD_TO_GROUP:
2060 + if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2061 + mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2062 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2064 + if (Context && Context->magic == M_NNTP &&
2065 + !((NNTP_DATA *)Context->data)->allowed &&
2066 + query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2068 + if (op == OP_POST)
2069 + ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2073 + if (op == OP_FOLLOWUP)
2074 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2075 + tag ? NULL : CURHDR);
2077 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2078 + tag ? NULL : CURHDR);
2080 + menu->redraw = REDRAW_FULL;
2088 @@ -2140,6 +2400,12 @@ int mutt_index_menu (void)
2090 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2093 + /* Close all open NNTP connections */
2095 + nntp_logout_all ();
2098 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2099 op == OP_UNDELETE_THREAD ? 0 : 1);
2101 diff -udprP mutt-1.5.20.orig/doc/manual.xml.head mutt-1.5.20/doc/manual.xml.head
2102 --- mutt-1.5.20.orig/doc/manual.xml.head 2009-05-30 20:20:08.000000000 +0300
2103 +++ mutt-1.5.20/doc/manual.xml.head 2009-06-15 21:05:24.000000000 +0300
2104 @@ -1568,6 +1568,22 @@ fo-table</literal> for details.
2109 +<title>Reading news via NNTP</title>
2112 +If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2113 +read news from newsserver via NNTP. You can open a newsgroup with
2114 +function ``change-newsgroup'' (default: ``i''). Default newsserver
2115 +can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2116 +variable. Like other news readers, info about subscribed newsgroups
2117 +is saved in file by <link linkend="newsrc">$newsrc</link>
2118 +variable. Article headers are cached and can be loaded from file when
2119 +newsgroup entered instead loading from newsserver.
2126 <sect1 id="forwarding-mail">
2127 diff -udprP mutt-1.5.20.orig/doc/mutt.man mutt-1.5.20/doc/mutt.man
2128 --- mutt-1.5.20.orig/doc/mutt.man 2009-06-07 03:32:44.000000000 +0300
2129 +++ mutt-1.5.20/doc/mutt.man 2009-06-15 21:07:47.000000000 +0300
2130 @@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2135 -[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2137 +[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-g \fIserver\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2141 @@ -101,6 +101,10 @@ files.
2142 Specify which mailbox to load.
2143 .IP "-F \fImuttrc\fP"
2144 Specify an initialization file to read instead of ~/.muttrc
2145 +.IP "-g \fIserver\fP"
2146 +Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2148 +Start Mutt with a listing of subscribed newsgroups.
2151 .IP "-H \fIdraft\fP"
2152 diff -udprP mutt-1.5.20.orig/functions.h mutt-1.5.20/functions.h
2153 --- mutt-1.5.20.orig/functions.h 2009-04-30 08:36:17.000000000 +0300
2154 +++ mutt-1.5.20/functions.h 2009-06-15 21:05:24.000000000 +0300
2155 @@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in
2156 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2157 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2158 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2160 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2161 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2163 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2164 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2165 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
2166 @@ -101,7 +105,15 @@ struct binding_t OpMain[] = { /* map: in
2167 { "edit", OP_EDIT_MESSAGE, "e" },
2168 { "edit-type", OP_EDIT_TYPE, "\005" },
2169 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2170 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2172 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2173 + { "followup-message", OP_FOLLOWUP, "F" },
2174 + { "get-children", OP_GET_CHILDREN, NULL },
2175 + { "get-message", OP_GET_MESSAGE, "\007" },
2176 + { "get-parent", OP_GET_PARENT, "\033G" },
2177 + { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2179 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2180 { "group-reply", OP_GROUP_REPLY, "g" },
2182 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2183 @@ -127,6 +139,9 @@ struct binding_t OpMain[] = { /* map: in
2184 { "sort-mailbox", OP_SORT, "o" },
2185 { "sort-reverse", OP_SORT_REVERSE, "O" },
2186 { "print-message", OP_PRINT, "p" },
2188 + { "post-message", OP_POST, "P" },
2190 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2191 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2192 { "recall-message", OP_RECALL_MESSAGE, "R" },
2193 @@ -146,6 +161,10 @@ struct binding_t OpMain[] = { /* map: in
2194 { "show-version", OP_VERSION, "V" },
2195 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2196 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2197 + { "toggle-read", OP_TOGGLE_READ, "X" },
2199 + { "catchup", OP_CATCHUP, "y" },
2201 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2202 { "buffy-list", OP_BUFFY_LIST, "." },
2203 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
2204 @@ -157,7 +176,7 @@ struct binding_t OpMain[] = { /* map: in
2205 { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" },
2206 { "next-unread", OP_MAIN_NEXT_UNREAD, NULL },
2207 { "previous-unread", OP_MAIN_PREV_UNREAD, NULL },
2208 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2209 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2212 { "extract-keys", OP_EXTRACT_KEYS, "\013" },
2213 @@ -177,6 +196,10 @@ struct binding_t OpPager[] = { /* map: p
2214 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2215 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2216 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2218 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2219 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2221 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2222 { "copy-message", OP_COPY_MESSAGE, "C" },
2223 { "decode-copy", OP_DECODE_COPY, "\033C" },
2224 @@ -187,8 +210,12 @@ struct binding_t OpPager[] = { /* map: p
2225 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2226 { "edit", OP_EDIT_MESSAGE, "e" },
2227 { "edit-type", OP_EDIT_TYPE, "\005" },
2229 + { "followup-message", OP_FOLLOWUP, "F" },
2230 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2232 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2233 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2234 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2235 { "group-reply", OP_GROUP_REPLY, "g" },
2237 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
2238 @@ -207,6 +234,9 @@ struct binding_t OpPager[] = { /* map: p
2239 { "next-thread", OP_MAIN_NEXT_THREAD, "\016" },
2240 { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" },
2241 { "print-message", OP_PRINT, "p" },
2243 + { "post-message", OP_POST, "P" },
2245 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2246 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2247 { "quit", OP_QUIT, "Q" },
2248 @@ -254,7 +284,7 @@ struct binding_t OpPager[] = { /* map: p
2249 { "half-down", OP_HALF_DOWN, NULL },
2250 { "previous-line", OP_PREV_LINE, NULL },
2251 { "bottom", OP_PAGER_BOTTOM, NULL },
2252 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2253 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2257 @@ -275,6 +305,10 @@ struct binding_t OpAttach[] = { /* map:
2258 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2259 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2260 { "edit-type", OP_EDIT_TYPE, "\005" },
2262 + { "followup-message", OP_FOLLOWUP, "F" },
2263 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2265 { "print-entry", OP_PRINT, "p" },
2266 { "save-entry", OP_SAVE, "s" },
2267 { "pipe-entry", OP_PIPE, "|" },
2268 @@ -300,6 +334,7 @@ struct binding_t OpAttach[] = { /* map:
2269 struct binding_t OpCompose[] = { /* map: compose */
2270 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2271 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2272 + { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2273 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2274 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2275 { "copy-file", OP_SAVE, "C" },
2276 @@ -319,6 +354,11 @@ struct binding_t OpCompose[] = { /* map:
2277 { "print-entry", OP_PRINT, "l" },
2278 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2279 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2281 + { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2282 + { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2283 + { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2285 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2286 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2287 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
2288 @@ -370,14 +410,25 @@ struct binding_t OpBrowser[] = { /* map:
2289 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2290 { "check-new", OP_CHECK_NEW, NULL },
2291 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2293 + { "reload-active", OP_LOAD_ACTIVE, "g" },
2294 + { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2295 + { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2296 + { "catchup", OP_CATCHUP, "y" },
2297 + { "uncatchup", OP_UNCATCHUP, "Y" },
2299 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2300 { "buffy-list", OP_BUFFY_LIST, "." },
2302 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2303 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2304 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2306 +#if defined USE_IMAP || defined USE_NNTP
2307 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2308 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2311 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2314 diff -udprP mutt-1.5.20.orig/globals.h mutt-1.5.20/globals.h
2315 --- mutt-1.5.20.orig/globals.h 2009-06-03 23:48:31.000000000 +0300
2316 +++ mutt-1.5.20/globals.h 2009-06-15 21:05:24.000000000 +0300
2317 @@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
2320 WHERE char *Muttrc INITVAL (NULL);
2322 +WHERE char *NewsCacheDir;
2323 +WHERE char *GroupFormat;
2325 +WHERE char *NewsServer;
2326 +WHERE char *NntpUser;
2327 +WHERE char *NntpPass;
2328 +WHERE char *NewsRc;
2332 WHERE char *PagerFmt;
2333 @@ -188,6 +197,11 @@ extern unsigned char QuadOptions[];
2335 WHERE unsigned short Counter INITVAL (0);
2338 +WHERE short NewsPollTimeout;
2339 +WHERE short NntpContext;
2342 WHERE short ConnectTimeout;
2343 WHERE short HistSize;
2344 WHERE short MenuContext;
2345 diff -udprP mutt-1.5.20.orig/hash.c mutt-1.5.20/hash.c
2346 --- mutt-1.5.20.orig/hash.c 2009-03-31 09:52:43.000000000 +0300
2347 +++ mutt-1.5.20/hash.c 2009-06-15 21:19:59.000000000 +0300
2348 @@ -57,6 +57,7 @@ HASH *hash_create (int nelem, int lower)
2351 table->nelem = nelem;
2352 + table->curnelem = 0;
2353 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2356 @@ -71,6 +72,29 @@ HASH *hash_create (int nelem, int lower)
2360 +HASH *hash_resize (HASH *ptr, int nelem, int lower)
2363 + struct hash_elem *elem, *tmp;
2366 + table = hash_create (nelem, lower);
2368 + for (i = 0; i < ptr->nelem; i++)
2370 + for (elem = ptr->table[i]; elem; )
2373 + elem = elem->next;
2374 + hash_insert (table, tmp->key, tmp->data, 1);
2378 + FREE (&ptr->table);
2383 /* table hash table to update
2384 * key key to hash on
2385 * data data to associate with `key'
2386 @@ -90,6 +114,7 @@ int hash_insert (HASH * table, const cha
2388 ptr->next = table->table[h];
2389 table->table[h] = ptr;
2390 + table->curnelem++;
2394 @@ -112,6 +137,7 @@ int hash_insert (HASH * table, const cha
2396 table->table[h] = ptr;
2398 + table->curnelem++;
2402 @@ -142,6 +168,7 @@ void hash_delete_hash (HASH * table, int
2404 destroy (ptr->data);
2406 + table->curnelem--;
2410 diff -udprP mutt-1.5.20.orig/hash.h mutt-1.5.20/hash.h
2411 --- mutt-1.5.20.orig/hash.h 2009-03-31 09:52:43.000000000 +0300
2412 +++ mutt-1.5.20/hash.h 2009-06-15 21:05:24.000000000 +0300
2413 @@ -28,7 +28,7 @@ struct hash_elem
2418 + int nelem, curnelem;
2419 struct hash_elem **table;
2420 unsigned int (*hash_string)(const unsigned char *, unsigned int);
2421 int (*cmp_string)(const char *, const char *);
2422 @@ -41,6 +41,7 @@ HASH;
2424 HASH *hash_create (int nelem, int lower);
2425 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2426 +HASH *hash_resize (HASH * table, int nelem, int lower);
2427 void *hash_find_hash (const HASH * table, int hash, const char *key);
2428 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2429 void (*destroy) (void *));
2430 diff -udprP mutt-1.5.20.orig/hdrline.c mutt-1.5.20/hdrline.c
2431 --- mutt-1.5.20.orig/hdrline.c 2009-04-13 19:24:55.000000000 +0300
2432 +++ mutt-1.5.20/hdrline.c 2009-06-15 21:05:24.000000000 +0300
2433 @@ -211,6 +211,7 @@ int mutt_user_is_recipient (HEADER *h)
2434 * %E = number of messages in current thread
2435 * %f = entire from line
2436 * %F = like %n, unless from self
2437 + * %g = newsgroup name (if compiled with nntp support)
2439 * %l = number of lines in the message
2440 * %L = like %F, except `lists' are displayed first
2441 @@ -219,12 +220,14 @@ int mutt_user_is_recipient (HEADER *h)
2443 * %O = like %L, except using address instead of name
2444 * %P = progress indicator for builtin pager
2445 + * %R = `x-comment-to:' field (if present and compiled with nntp support)
2447 * %S = short message status (e.g., N/O/D/!/r/-)
2448 * %t = `to:' field (recipients)
2450 * %u = user (login) name of author
2451 * %v = first name of author, unless from self
2452 + * %W = where user is (organization)
2453 * %X = number of MIME attachments
2454 * %y = `x-label:' field (if present)
2455 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2456 @@ -457,6 +460,12 @@ hdr_format_str (char *dest,
2462 + mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2467 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2469 @@ -548,6 +557,15 @@ hdr_format_str (char *dest,
2470 strfcpy(dest, NONULL(hfi->pager_progress), destlen);
2476 + mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2477 + else if (!hdr->env->x_comment_to)
2484 if (flags & M_FORMAT_TREE && !hdr->collapsed)
2485 @@ -637,6 +655,13 @@ hdr_format_str (char *dest,
2486 mutt_format_s (dest, destlen, prefix, buf2);
2491 + mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2492 + else if (!hdr->env->organization)
2499 diff -udprP mutt-1.5.20.orig/headers.c mutt-1.5.20/headers.c
2500 --- mutt-1.5.20.orig/headers.c 2009-04-30 08:36:17.000000000 +0300
2501 +++ mutt-1.5.20/headers.c 2009-06-15 21:17:07.000000000 +0300
2502 @@ -114,6 +114,9 @@ void mutt_edit_headers (const char *edit
2503 $edit_headers set, we remove References: as they're likely invalid;
2504 we can simply compare strings as we don't generate References for
2505 multiple Message-Ids in IRT anyways */
2507 + if (!option (OPTNEWSSEND))
2509 if (!n->in_reply_to || (msg->env->in_reply_to &&
2510 mutt_strcmp (n->in_reply_to->data,
2511 msg->env->in_reply_to->data) != 0))
2512 diff -udprP mutt-1.5.20.orig/init.c mutt-1.5.20/init.c
2513 --- mutt-1.5.20.orig/init.c 2009-06-01 19:29:32.000000000 +0300
2514 +++ mutt-1.5.20/init.c 2009-06-15 21:05:24.000000000 +0300
2515 @@ -2966,6 +2966,28 @@ void mutt_init (int skip_sys_rc, LIST *c
2517 Fqdn = safe_strdup(NONULL(Hostname));
2524 + if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2527 + fgets (buffer, sizeof (buffer), f);
2531 + while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2533 + NewsServer = safe_strdup (p);
2537 + if ((p = getenv ("NNTPSERVER")))
2538 + NewsServer = safe_strdup (p);
2541 if ((p = getenv ("MAIL")))
2542 Spoolfile = safe_strdup (p);
2543 else if ((p = getenv ("MAILDIR")))
2544 diff -udprP mutt-1.5.20.orig/init.h mutt-1.5.20/init.h
2545 --- mutt-1.5.20.orig/init.h 2009-06-14 00:35:21.000000000 +0300
2546 +++ mutt-1.5.20/init.h 2009-06-15 21:15:03.000000000 +0300
2547 @@ -176,6 +176,20 @@ struct option_t MuttVars[] = {
2548 ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before
2549 ** editing the body of an outgoing message.
2552 + { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2555 + ** If set, Mutt will prompt you for follow-up groups before editing
2556 + ** the body of an outgoing message.
2558 + { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2561 + ** If set, Mutt will prompt you for x-comment-to field before editing
2562 + ** the body of an outgoing message.
2565 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2568 @@ -322,6 +336,14 @@ struct option_t MuttVars[] = {
2569 ** follow these menus. The option is \fIunset\fP by default because many
2570 ** visual terminals don't permit making the cursor invisible.
2573 + { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2576 + ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2577 + ** as read when you quit the newsgroup (catchup newsgroup).
2580 #if defined(USE_SSL)
2581 { "certificate_file", DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" },
2583 @@ -797,6 +819,16 @@ struct option_t MuttVars[] = {
2584 ** sent to both the list and your address, resulting in two copies
2585 ** of the same email for you.
2588 + { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2591 + ** If this variable is \fIset\fP and the keyword "poster" is present in
2592 + ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2593 + ** permitted. The message will be mailed to the submitter of the
2594 + ** message via mail.
2597 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2600 @@ -879,6 +911,27 @@ struct option_t MuttVars[] = {
2601 ** a regular expression that will match the whole name so mutt will expand
2602 ** ``Franklin'' to ``Franklin, Steve''.
2605 + { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2608 + ** This variable allows you to customize the newsgroup browser display to
2609 + ** your personal taste. This string is similar to ``$index_format'', but
2610 + ** has its own set of printf()-like sequences:
2613 + ** %C current newsgroup number
2614 + ** %d description of newsgroup (becomes from server)
2615 + ** %f newsgroup name
2616 + ** %M - if newsgroup not allowed for direct post (moderated for example)
2617 + ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2618 + ** %n number of new articles in newsgroup
2619 + ** %s number of unread articles in newsgroup
2620 + ** %>X right justify the rest of the string and pad with character "X"
2621 + ** %|X pad to the end of the line with character "X"
2625 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2628 @@ -1255,6 +1308,7 @@ struct option_t MuttVars[] = {
2629 ** .dt %E .dd number of messages in current thread
2630 ** .dt %f .dd sender (address + real name), either From: or Return-Path:
2631 ** .dt %F .dd author name, or recipient name if the message is from you
2632 + ** .dt %g .dd newsgroup name (if compiled with nntp support)
2633 ** .dt %H .dd spam attribute(s) of this message
2634 ** .dt %i .dd message-id of the current message
2635 ** .dt %l .dd number of lines in the message (does not work with maildir,
2636 @@ -1270,12 +1324,14 @@ struct option_t MuttVars[] = {
2637 ** stashed the message: list name or recipient name
2638 ** if not sent to a list
2639 ** .dt %P .dd progress indicator for the builtin pager (how much of the file has been displayed)
2640 + ** .dt %R .dd `x-comment-to:' field (if present and compiled with nntp support)
2641 ** .dt %s .dd subject of the message
2642 ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as)
2643 ** .dt %t .dd ``To:'' field (recipients)
2644 ** .dt %T .dd the appropriate character from the $$to_chars string
2645 ** .dt %u .dd user (login) name of the author
2646 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2647 + ** .dt %W .dd name of organization of author (`organization:' field)
2648 ** .dt %X .dd number of attachments
2649 ** (please see the ``$attachments'' section for possible speed effects)
2650 ** .dt %y .dd ``X-Label:'' field, if present
2651 @@ -1310,6 +1366,21 @@ struct option_t MuttVars[] = {
2652 ** Note that these expandos are supported in
2653 ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too.
2656 + { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2659 + ** If set, specifies the program and arguments used to deliver news posted
2660 + ** by Mutt. Otherwise, mutt posts article using current connection to
2661 + ** news server. The following printf-style sequence is understood:
2664 + ** %s newsserver name
2667 + ** Example: set inews="/usr/local/bin/inews -hS"
2670 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2673 @@ -1533,6 +1604,15 @@ struct option_t MuttVars[] = {
2674 ** menu, attachments which cannot be decoded in a reasonable manner will
2675 ** be attached to the newly composed message if this option is \fIset\fP.
2678 + { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2681 + ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2682 + ** encoded according to RFC2047 to base64. This is useful when message
2683 + ** is Usenet article, because MIME for news is nonstandard feature.
2687 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2689 @@ -1580,6 +1660,77 @@ struct option_t MuttVars[] = {
2690 ** See also $$read_inc, $$write_inc and $$net_inc.
2694 + { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2697 + ** This variable pointing to directory where Mutt will save cached news
2698 + ** articles headers in. If \fIunset\fP, headers will not be saved at all
2699 + ** and will be reloaded each time when you enter to newsgroup.
2701 + { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2704 + ** This variable specifies domain name or address of NNTP server. It
2705 + ** defaults to the newsserver specified in the environment variable
2706 + ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2707 + ** specify username and an alternative port for each newsserver, ie:
2709 + ** [news[s]://][username[:password]@]newsserver[:port]
2711 + { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2714 + ** The file, containing info about subscribed newsgroups - names and
2715 + ** indexes of read articles. The following printf-style sequence
2719 + ** %s newsserver name
2722 + { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2725 + ** This variable defines number of articles which will be in index when
2726 + ** newsgroup entered. If active newsgroup have more articles than this
2727 + ** number, oldest articles will be ignored. Also controls how many
2728 + ** articles headers will be saved in cache when you quit newsgroup.
2730 + { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2733 + ** This variable controls whether or not descriptions for each newsgroup
2734 + ** must be loaded when newsgroup is added to list (first time list
2735 + ** loading or new newsgroup adding).
2737 + { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2740 + ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2741 + ** authentification, Mutt will prompt you for your account name when you
2742 + ** connect to newsserver.
2744 + { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2747 + ** Your password for NNTP account.
2749 + { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2752 + ** The time in seconds until any operations on newsgroup except post new
2753 + ** article will cause recheck for new news. If set to 0, Mutt will
2754 + ** recheck newsgroup on each operation in index (stepping, read article,
2757 + { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2760 + ** Controls whether or not Mutt will try to reconnect to newsserver when
2761 + ** connection lost.
2764 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2767 @@ -2079,6 +2230,16 @@ struct option_t MuttVars[] = {
2768 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2772 + { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2775 + ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2776 + ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2777 + ** does not support posting to that newsgroup or totally read-only, that
2778 + ** posting will not have an effect.
2781 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2784 @@ -2479,6 +2640,28 @@ struct option_t MuttVars[] = {
2785 ** Command to use when spawning a subshell. By default, the user's login
2786 ** shell from \fC/etc/passwd\fP is used.
2789 + { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2792 + ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2793 + ** ``newsrc'' file and into cache.
2795 + { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2798 + ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2799 + ** the browser. Otherwise, it will be done only once for a newsserver.
2800 + ** Also controls whether or not number of new articles of subscribed
2801 + ** newsgroups will be then checked.
2803 + { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2806 + ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2807 + ** will be displayed in browser.
2810 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2813 @@ -3337,6 +3520,14 @@ struct option_t MuttVars[] = {
2814 ** Also see the $$read_inc, $$net_inc and $$time_inc variables and the
2815 ** ``$tuning'' section of the manual for performance considerations.
2818 + { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2821 + ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2822 + ** name of original article author) to article that followuped to newsgroup.
2826 { NULL, 0, 0, 0, 0 }
2828 diff -udprP mutt-1.5.20.orig/keymap.c mutt-1.5.20/keymap.c
2829 --- mutt-1.5.20.orig/keymap.c 2008-11-29 23:09:10.000000000 +0200
2830 +++ mutt-1.5.20/keymap.c 2009-06-15 21:05:24.000000000 +0300
2831 @@ -654,7 +654,6 @@ void km_init (void)
2832 km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE);
2834 km_bindkey ("x", MENU_PAGER, OP_EXIT);
2835 - km_bindkey ("i", MENU_PAGER, OP_EXIT);
2836 km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE);
2837 km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE);
2838 km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE);
2839 diff -udprP mutt-1.5.20.orig/mailbox.h mutt-1.5.20/mailbox.h
2840 --- mutt-1.5.20.orig/mailbox.h 2009-04-30 08:36:17.000000000 +0300
2841 +++ mutt-1.5.20/mailbox.h 2009-06-15 21:05:24.000000000 +0300
2842 @@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2844 int mx_is_pop (const char *);
2847 +int mx_is_nntp (const char *);
2850 int mx_access (const char*, int);
2851 int mx_check_empty (const char *);
2852 diff -udprP mutt-1.5.20.orig/main.c mutt-1.5.20/main.c
2853 --- mutt-1.5.20.orig/main.c 2009-06-01 19:29:32.000000000 +0300
2854 +++ mutt-1.5.20/main.c 2009-06-15 21:05:24.000000000 +0300
2856 #include <stringprep.h>
2863 static const char *ReachingUs = N_("\
2864 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2865 To report a bug, please visit http://bugs.mutt.org/.\n");
2866 @@ -133,6 +137,8 @@ options:\n\
2867 " -e <command>\tspecify a command to be executed after initialization\n\
2868 -f <file>\tspecify which mailbox to read\n\
2869 -F <file>\tspecify an alternate muttrc file\n\
2870 + -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2871 + -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2872 -H <file>\tspecify a draft file to read header and body from\n\
2873 -i <file>\tspecify a file which Mutt should include in the body\n\
2874 -m <type>\tspecify a default mailbox type\n\
2875 @@ -255,6 +261,12 @@ static void show_version (void)
2888 @@ -522,6 +534,9 @@ static void start_curses (void)
2889 #define M_NOSYSRC (1<<2) /* -n */
2890 #define M_RO (1<<3) /* -R */
2891 #define M_SELECT (1<<4) /* -y */
2893 +#define M_NEWS (1<<5) /* -g and -G */
2896 int main (int argc, char **argv)
2898 @@ -594,7 +609,11 @@ int main (int argc, char **argv)
2899 argv[nargc++] = argv[optind];
2903 + if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2905 if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2910 @@ -691,6 +710,20 @@ int main (int argc, char **argv)
2915 + case 'g': /* Specify a newsserver */
2917 + char buf[LONG_STRING];
2919 + snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2920 + commands = mutt_add_list (commands, buf);
2923 + case 'G': /* List of newsgroups */
2924 + flags |= M_SELECT | M_NEWS;
2931 @@ -978,6 +1011,18 @@ int main (int argc, char **argv)
2933 else if (flags & M_SELECT)
2936 + if (flags & M_NEWS)
2938 + set_option (OPTNEWS);
2939 + if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2941 + mutt_endwin (Errorbuf);
2948 mutt_endwin _("No incoming mailboxes defined.");
2950 @@ -993,6 +1038,15 @@ int main (int argc, char **argv)
2953 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2956 + if (option (OPTNEWS))
2958 + unset_option (OPTNEWS);
2959 + nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2963 mutt_expand_path (folder, sizeof (folder));
2965 mutt_str_replace (&CurrentFolder, folder);
2966 diff -udprP mutt-1.5.20.orig/mutt.h mutt-1.5.20/mutt.h
2967 --- mutt-1.5.20.orig/mutt.h 2009-06-13 01:15:42.000000000 +0300
2968 +++ mutt-1.5.20/mutt.h 2009-06-15 21:05:24.000000000 +0300
2969 @@ -229,6 +229,9 @@ enum
2977 /* Options for Mailcap lookup */
2979 @@ -285,6 +288,12 @@ enum
2982 OPT_VERIFYSIG, /* verify PGP signatures */
2985 + OPT_NNTPRECONNECT,
2987 + OPT_FOLLOWUPTOPOSTER,
2988 +#endif /* USE_NNTP */
2990 /* THIS MUST BE THE LAST VALUE. */
2992 @@ -300,6 +309,7 @@ enum
2993 #define SENDMAILX (1<<6)
2994 #define SENDKEY (1<<7)
2995 #define SENDRESEND (1<<8)
2996 +#define SENDNEWS (1<<9)
2998 /* flags to _mutt_select_file() */
2999 #define M_SEL_BUFFY (1<<0)
3000 @@ -319,6 +329,8 @@ enum
3009 @@ -396,6 +408,9 @@ enum
3014 + OPTMIMESUBJECT, /* encode subject line with RFC2047 */
3019 @@ -477,6 +492,16 @@ enum
3023 + /* news options */
3027 + OPTSHOWONLYUNREAD,
3031 +#endif /* USE_NNTP */
3033 /* pseudo options */
3035 OPTAUXSORT, /* (pseudo) using auxillary sort function */
3036 @@ -497,6 +522,7 @@ enum
3037 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
3038 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3039 OPTATTACHMSG, /* (pseudo) used by attach-message */
3040 + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3041 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3042 * functions while we are executing an
3044 @@ -507,6 +533,12 @@ enum
3045 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3046 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
3049 + OPTNEWS, /* (pseudo) used to change reader mode */
3050 + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3051 + OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
3057 @@ -585,6 +617,13 @@ typedef struct envelope
3061 + char *organization;
3065 + char *followup_to;
3066 + char *x_comment_to;
3069 LIST *references; /* message references (in reverse order) */
3070 LIST *in_reply_to; /* in-reply-to header content */
3071 @@ -751,6 +790,9 @@ typedef struct header
3072 ENVELOPE *env; /* envelope information */
3073 BODY *content; /* list of MIME parts */
3079 char *tree; /* character string to print thread tree */
3080 struct thread *thread;
3081 @@ -766,7 +808,7 @@ typedef struct header
3082 int refno; /* message number on server */
3085 -#if defined USE_POP || defined USE_IMAP
3086 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3087 void *data; /* driver-specific data */
3090 diff -udprP mutt-1.5.20.orig/muttlib.c mutt-1.5.20/muttlib.c
3091 --- mutt-1.5.20.orig/muttlib.c 2009-05-19 03:11:35.000000000 +0300
3092 +++ mutt-1.5.20/muttlib.c 2009-06-15 21:05:24.000000000 +0300
3093 @@ -301,7 +301,7 @@ void mutt_free_header (HEADER **h)
3095 mutt_free_list (&(*h)->chain);
3097 -#if defined USE_POP || defined USE_IMAP
3098 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3101 FREE (h); /* __FREE_CHECKED__ */
3102 @@ -689,6 +689,13 @@ void mutt_free_envelope (ENVELOPE **p)
3103 FREE (&(*p)->supersedes);
3105 FREE (&(*p)->x_label);
3106 + FREE (&(*p)->organization);
3108 + FREE (&(*p)->newsgroups);
3109 + FREE (&(*p)->xref);
3110 + FREE (&(*p)->followup_to);
3111 + FREE (&(*p)->x_comment_to);
3114 mutt_buffer_free (&(*p)->spam);
3116 @@ -1470,6 +1477,14 @@ int mutt_save_confirm (const char *s, st
3121 + if (magic == M_NNTP)
3123 + mutt_error _("Can't save message to newsserver.");
3128 if (stat (s, st) != -1)
3131 diff -udprP mutt-1.5.20.orig/mx.c mutt-1.5.20/mx.c
3132 --- mutt-1.5.20.orig/mx.c 2009-06-11 07:29:41.000000000 +0300
3133 +++ mutt-1.5.20/mx.c 2009-06-15 21:05:24.000000000 +0300
3134 @@ -343,6 +343,22 @@ int mx_is_pop (const char *p)
3139 +int mx_is_nntp (const char *p)
3141 + url_scheme_t scheme;
3146 + scheme = url_check_scheme (p);
3147 + if (scheme == U_NNTP || scheme == U_NNTPS)
3154 int mx_get_magic (const char *path)
3157 @@ -360,6 +376,11 @@ int mx_get_magic (const char *path)
3159 #endif /* USE_POP */
3162 + if (mx_is_nntp (path))
3164 +#endif /* USE_NNTP */
3166 if (stat (path, &st) == -1)
3168 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
3169 @@ -669,6 +690,12 @@ CONTEXT *mx_open_mailbox (const char *pa
3171 #endif /* USE_POP */
3175 + rc = nntp_open_mailbox (ctx);
3177 +#endif /* USE_NNTP */
3182 @@ -761,6 +788,12 @@ static int sync_mailbox (CONTEXT *ctx, i
3183 rc = pop_sync_mailbox (ctx, index_hint);
3185 #endif /* USE_POP */
3189 + rc = nntp_sync_mailbox (ctx);
3191 +#endif /* USE_NNTP */
3195 @@ -787,6 +820,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
3200 + if (ctx->magic == M_NNTP)
3204 + ret = nntp_close_mailbox (ctx);
3205 + mx_fastclose_mailbox (ctx);
3209 if (ctx->readonly || ctx->dontwrite)
3211 /* mailbox is readonly or we don't want to write */
3212 @@ -1336,6 +1379,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
3214 return (pop_check_mailbox (ctx, index_hint));
3215 #endif /* USE_POP */
3219 + return (nntp_check_mailbox (ctx));
3220 +#endif /* USE_NNTP */
3224 @@ -1396,6 +1444,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
3226 #endif /* USE_POP */
3231 + if (nntp_fetch_message (msg, ctx, msgno) != 0)
3235 +#endif /* USE_NNTP */
3238 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3240 @@ -1477,6 +1534,9 @@ int mx_close_message (MESSAGE **msg)
3242 || (*msg)->magic == M_POP
3245 + || (*msg)->magic == M_NNTP
3249 r = safe_fclose (&(*msg)->fp);
3250 diff -udprP mutt-1.5.20.orig/mx.h mutt-1.5.20/mx.h
3251 --- mutt-1.5.20.orig/mx.h 2008-11-11 21:55:47.000000000 +0200
3252 +++ mutt-1.5.20/mx.h 2009-06-15 21:05:24.000000000 +0300
3253 @@ -40,6 +40,9 @@ enum
3262 WHERE short DefaultMagic INITVAL (M_MBOX);
3263 diff -udprP mutt-1.5.20.orig/newsrc.c mutt-1.5.20/newsrc.c
3264 --- mutt-1.5.20.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3265 +++ mutt-1.5.20/newsrc.c 2009-06-15 21:05:24.000000000 +0300
3268 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3269 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
3270 + * Copyright (C) 2000-2009 Vsevolod Volkov <vvv@mutt.org.ua>
3272 + * This program is free software; you can redistribute it and/or modify
3273 + * it under the terms of the GNU General Public License as published by
3274 + * the Free Software Foundation; either version 2 of the License, or
3275 + * (at your option) any later version.
3277 + * This program is distributed in the hope that it will be useful,
3278 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3279 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3280 + * GNU General Public License for more details.
3282 + * You should have received a copy of the GNU General Public License
3283 + * along with this program; if not, write to the Free Software
3284 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3288 +# include "config.h"
3292 +#include "mutt_curses.h"
3296 +#include "mailbox.h"
3298 +#include "rfc822.h"
3299 +#include "rfc1524.h"
3300 +#include "rfc2047.h"
3302 +#include <unistd.h>
3303 +#include <string.h>
3305 +#include <stdlib.h>
3306 +#include <sys/stat.h>
3308 +void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3315 + l = safe_calloc (1, sizeof (LIST));
3317 + s->tail->next = l;
3321 + l->data = (void *) d;
3324 +static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3327 + char group[LONG_STRING];
3329 + char *p = line, *b, *h;
3339 + while (*p && (*p != ':' && *p != '!')) p++;
3342 + len = p + 1 - line;
3343 + if (len > sizeof (group))
3344 + len = sizeof (group);
3345 + strfcpy (group, line, len);
3346 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3348 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3349 + data->group = (char *) data + sizeof (NNTP_DATA);
3350 + strcpy (data->group, group);
3351 + data->nserv = news;
3352 + data->deleted = 1;
3353 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3354 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
3355 + hash_insert (news->newsgroups, data->group, data, 0);
3356 + nntp_add_to_list (news, data);
3359 + FREE ((void **) &data->entries);
3362 + data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3366 + data->subscribed = 1;
3368 + data->subscribed = 0;
3375 + while (*p && *p != ',' && *p != '\n') p++;
3381 + if ((h = strchr(b, '-')))
3385 + data->entries[x].first = atoi(b);
3386 + data->entries[x].last = atoi(h);
3390 + data->entries[x].first = atoi(b);
3391 + data->entries[x].last = data->entries[x].first;
3394 + if (data->entries[x].last != 0)
3397 + if (x && !data->lastMessage)
3398 + data->lastMessage = data->entries[x-1].last;
3400 + mutt_newsgroup_stat (data);
3401 + dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3406 +static int slurp_newsrc (NNTP_SERVER *news)
3412 + news->stat = stat (news->newsrc, &sb);
3413 + news->size = sb.st_size;
3414 + news->mtime = sb.st_mtime;
3416 + if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3418 + /* hmm, should we use dotlock? */
3419 + if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3425 + buf = safe_malloc (sb.st_size + 1);
3426 + while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3427 + nntp_parse_newsrc_line (news, buf);
3430 + mx_unlock_file (news->newsrc, fileno (fp), 0);
3435 +void nntp_cache_expand (char *dst, const char *src)
3437 + snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3438 + mutt_expand_path (dst, _POSIX_PATH_MAX);
3441 +/* Loads $news_cache_dir/.index into memory, loads newsserver data
3442 + * and newsgroup cache names */
3443 +static int nntp_parse_cacheindex (NNTP_SERVER *news)
3446 + char buf[HUGE_STRING], *cp;
3447 + char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3452 + /* check is server name defined or not */
3453 + if (!news || !news->conn || !news->conn->account.host)
3455 + unset_option (OPTNEWSCACHE);
3456 + if (!NewsCacheDir || !*NewsCacheDir)
3459 + strfcpy (dir, NewsCacheDir, sizeof (dir));
3460 + mutt_expand_path (dir, sizeof(dir));
3462 + if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3464 + snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3465 + if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3468 + mutt_error _("Cache directory not created!");
3471 + mutt_clear_error();
3474 + set_option (OPTNEWSCACHE);
3476 + FREE (&news->cache);
3477 + snprintf (buf, sizeof(buf), "%s/.index", dir);
3478 + if (!(index = safe_fopen (buf, "a+")))
3481 + while (fgets (buf, sizeof(buf), index))
3483 + buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3484 + if (!mutt_strncmp (buf, "#: ", 3) &&
3485 + !mutt_strcasecmp (buf+3, news->conn->account.host))
3488 + while (fgets (buf, sizeof(buf), index))
3491 + while (*cp && *cp != ' ') cp++;
3492 + if (!*cp) continue;
3494 + if (!mutt_strcmp (buf, "#:"))
3496 + sscanf (cp + 1, "%s %d %d", file, &l, &m);
3497 + if (!mutt_strcmp (buf, "ALL"))
3499 + news->cache = safe_strdup (file);
3500 + news->newgroups_time = m;
3502 + else if (news->newsgroups)
3504 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3506 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3507 + data->group = (char *) data + sizeof (NNTP_DATA);
3508 + strcpy(data->group, buf);
3509 + data->nserv = news;
3510 + data->deleted = 1;
3511 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3512 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
3513 + hash_insert (news->newsgroups, data->group, data, 0);
3514 + nntp_add_to_list (news, data);
3516 + data->cache = safe_strdup (file);
3518 + if (!data->firstMessage || data->lastMessage < m)
3520 + if (!data->firstMessage)
3521 + data->firstMessage = l;
3522 + if (data->lastMessage < m)
3523 + data->lastMessage = m;
3524 + data->lastCached = m;
3525 + if (t || !data->unread)
3526 + mutt_newsgroup_stat (data);
3534 +nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
3535 + const char *fmt, const char *ifstring, const char *elsestring,
3536 + unsigned long data, format_flag flags)
3538 + char fn[SHORT_STRING], tmp[SHORT_STRING];
3543 + strncpy (fn, NewsServer, sizeof(fn) - 1);
3544 + mutt_strlower (fn);
3545 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3546 + snprintf (dest, destlen, tmp, fn);
3552 +/* nntp_parse_url: given an NNPT URL, return host, port,
3553 + * username, password and newsgroup will recognise. */
3554 +int nntp_parse_url (const char *server, ACCOUNT *acct,
3555 + char *group, size_t group_len)
3563 + acct->port = NNTP_PORT;
3564 + acct->type = M_ACCT_TYPE_NNTP;
3566 + c = safe_strdup (server);
3567 + url_parse_ciss (&url, c);
3569 + if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3571 + if (url.scheme == U_NNTPS)
3573 + acct->flags |= M_ACCT_SSL;
3574 + acct->port = NNTP_SSL_PORT;
3579 + strfcpy (group, url.path, group_len);
3581 + ret = mutt_account_fromurl (acct, &url);
3588 +void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3592 + url.path = safe_strdup (line);
3593 + mutt_account_tourl (acct, &url);
3594 + url_ciss_tostring (&url, line, len, 0);
3599 + * Automatically loads a newsrc into memory, if necessary.
3600 + * Checks the size/mtime of a newsrc file, if it doesn't match, load
3601 + * again. Hmm, if a system has broken mtimes, this might mean the file
3602 + * is reloaded every time, which we'd have to fix.
3604 + * a newsrc file is a line per newsgroup, with the newsgroup, then a
3605 + * ':' denoting subscribed or '!' denoting unsubscribed, then a
3606 + * comma separated list of article numbers and ranges.
3608 +NNTP_SERVER *mutt_select_newsserver (char *server)
3610 + char file[_POSIX_PATH_MAX];
3614 + NNTP_SERVER *serv;
3617 + if (!server || !*server)
3619 + mutt_error _("No newsserver defined!");
3623 + buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3624 + if (url_check_scheme (server) == U_UNKNOWN)
3626 + strcpy (buf, "news://");
3627 + p = strchr (buf, '\0');
3629 + strcpy (p, server);
3631 + if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3634 + mutt_error (_("%s is an invalid newsserver specification!"), server);
3639 + conn = mutt_conn_find (NULL, &acct);
3643 + mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), nntp_format_str, 0, 0);
3644 + mutt_expand_path (file, sizeof (file));
3646 + serv = (NNTP_SERVER *)conn->data;
3651 + /* externally modified? */
3652 + if (serv->stat != stat (file, &sb) || (!serv->stat &&
3653 + (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3655 + for (list = serv->list; list; list = list->next)
3657 + NNTP_DATA *data = (NNTP_DATA *) list->data;
3661 + data->subscribed = 0;
3666 + slurp_newsrc (serv);
3667 + nntp_clear_cacheindex (serv);
3670 + if (serv->status == NNTP_BYE)
3671 + serv->status = NNTP_NONE;
3672 + nntp_check_newgroups (serv, 0);
3676 + /* New newsserver */
3677 + serv = safe_calloc (1, sizeof (NNTP_SERVER));
3678 + serv->conn = conn;
3679 + serv->newsrc = safe_strdup (file);
3680 + serv->newsgroups = hash_create (1009, 0);
3681 + slurp_newsrc (serv); /* load .newsrc */
3682 + nntp_parse_cacheindex (serv); /* load .index */
3683 + if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3684 + nntp_check_newgroups (serv, 1);
3685 + else if (nntp_get_active (serv) < 0)
3687 + hash_destroy (&serv->newsgroups, nntp_delete_data);
3688 + for (list = serv->list; list; list = list->next)
3689 + list->data = NULL;
3690 + mutt_free_list (&serv->list);
3691 + FREE (&serv->newsrc);
3692 + FREE (&serv->cache);
3696 + nntp_clear_cacheindex (serv);
3697 + conn->data = (void *)serv;
3703 + * full status flags are not supported by nntp, but we can fake some
3704 + * of them. This is how:
3705 + * Read = a read message number is in the .newsrc
3706 + * New = a message is new since we last read this newsgroup
3707 + * Old = anything else
3708 + * So, Read is marked as such in the newsrc, old is anything that is
3709 + * "skipped" in the newsrc, and new is anything not in the newsrc nor
3710 + * in the cache. By skipped, I mean before the last unread message
3712 +void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3714 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3718 + data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3724 + dprint (3, (debugfile, "newsgroup %s not found\n", group));
3729 + for (x = 0; x < data->num; x++)
3731 + if ((article >= data->entries[x].first) &&
3732 + (article <= data->entries[x].last))
3734 + /* we cannot use mutt_set_flag() because mx_update_context()
3735 + didn't called yet */
3740 + /* If article was not cached yet, it is new! :) */
3741 + if (!data->cache || article > data->lastCached)
3743 + /* Old articles are articles which aren't read but an article after them
3744 + * has been cached */
3745 + if (option (OPTMARKOLD))
3749 +void mutt_newsgroup_stat (NNTP_DATA *data)
3752 + unsigned int first, last;
3755 + if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3758 + data->unread = data->lastMessage - data->firstMessage + 1;
3759 + for (i = 0; i < data->num; i++)
3761 + first = data->entries[i].first;
3762 + if (first < data->firstMessage)
3763 + first = data->firstMessage;
3764 + last = data->entries[i].last;
3765 + if (last > data->lastMessage)
3766 + last = data->lastMessage;
3767 + if (first <= last)
3768 + data->unread -= last - first + 1;
3772 +static int puti (char *line, int num)
3776 + for (p = s; num; )
3778 + *p++ = '0' + num % 10;
3782 + *line++ = *--p, num++;
3787 +static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3789 + char *line = *pline;
3790 + size_t len = *buflen - (*pline - *buf);
3793 + if (len < LONG_STRING * 10)
3798 + safe_realloc (buf, *buflen);
3799 + line = *buf + (*pline - line);
3801 + strcpy (line, data->group);
3802 + len -= strlen (line) + 1;
3803 + line += strlen (line);
3804 + *line++ = data->subscribed ? ':' : '!';
3808 + for (x = 0; x < data->num; x++)
3810 + if (len < LONG_STRING)
3816 + safe_realloc (buf, *buflen);
3817 + line = *buf + (*pline - line);
3826 + if (data->entries[x].first == data->entries[x].last)
3827 + snprintf (line, len, "%d%n", data->entries[x].first, &i);
3829 + snprintf (line, len, "%d-%d%n",
3830 + data->entries[x].first, data->entries[x].last, &i);
3834 + i = puti (line, data->entries[x].first);
3835 + line +=i; len -= i;
3836 + if (data->entries[x].first != data->entries[x].last)
3840 + i = puti (line, data->entries[x].last);
3841 + line +=i; len -= i;
3850 +void newsrc_gen_entries (CONTEXT *ctx)
3852 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3854 + unsigned int last = 0, first = 1;
3855 + int save_sort = SORT_ORDER;
3857 + if (Sort != SORT_ORDER)
3860 + Sort = SORT_ORDER;
3861 + mutt_sort_headers (ctx, 0);
3866 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3871 + * Set up to fake initial sequence from 1 to the article before the
3872 + * first article in our list
3877 + for (x = 0; x < ctx->msgcount; x++)
3879 + if (series) /* search for first unread */
3882 + * We don't actually check sequential order, since we mark
3883 + * "missing" entries as read/deleted
3885 + last = ctx->hdrs[x]->article_num;
3886 + if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3887 + !ctx->hdrs[x]->read)
3889 + if (data->num >= data->max)
3891 + data->max = data->max * 2;
3892 + safe_realloc (&data->entries,
3893 + data->max * sizeof (NEWSRC_ENTRY));
3895 + data->entries[data->num].first = first;
3896 + data->entries[data->num].last = last - 1;
3901 + else /* search for first read */
3903 + if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3908 + last = ctx->hdrs[x]->article_num;
3911 + if (series && first <= data->lastLoaded)
3913 + if (data->num >= data->max)
3915 + data->max = data->max * 2;
3916 + safe_realloc (&data->entries,
3917 + data->max * sizeof (NEWSRC_ENTRY));
3919 + data->entries[data->num].first = first;
3920 + data->entries[data->num].last = data->lastLoaded;
3924 + if (save_sort != Sort)
3927 + mutt_sort_headers (ctx, 0);
3931 +static int mutt_update_list_file (char *filename, char *section,
3932 + char *key, char *line)
3936 + char buf[HUGE_STRING];
3937 + char tmpfile[_POSIX_PATH_MAX];
3939 + int ext = 0, done = 0, r = 0;
3941 + /* if file not exist, create it */
3942 + if ((ifp = safe_fopen (filename, "a")))
3944 + dprint (1, (debugfile, "Opening %s\n", filename));
3945 + if (!(ifp = safe_fopen (filename, "r")))
3947 + mutt_error (_("Unable to open %s for reading"), filename);
3950 + if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3953 + mutt_error (_("Unable to lock %s"), filename);
3956 + snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3957 + dprint (1, (debugfile, "Opening %s\n", tmpfile));
3958 + if (!(ofp = fopen (tmpfile, "w")))
3961 + mutt_error (_("Unable to open %s for writing"), tmpfile);
3967 + while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3969 + r = fputs (buf, ofp);
3971 + while (*c && *c != '\n') c++;
3972 + c[0] = 0; /* strip EOL */
3973 + if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3976 + if (r != EOF && !done)
3978 + snprintf (buf, sizeof(buf), "#: %s\n", section);
3979 + r = fputs (buf, ofp);
3984 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3989 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3991 + if (*c != '\\') ext = 0;
3993 + else if ((section && !strncmp (buf, "#: ", 3)))
3995 + if (!done && line)
3997 + fputs (line, ofp);
3998 + fputc ('\n', ofp);
4000 + r = fputs (buf, ofp);
4004 + else if (key && !strncmp (buf, key, strlen(key)) &&
4005 + (!*key || buf[strlen(key)] == ' '))
4009 + while (*c && (*c != '\r') && (*c != '\n')) c++;
4011 + if (*c == '\\') ext = 1;
4012 + if (!done && line)
4014 + r = fputs (line, ofp);
4016 + r = fputc ('\n', ofp);
4022 + r = fputs (buf, ofp);
4026 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
4027 + r = fputs (buf, ofp);
4029 + /* If there wasn't a line to replace, put it on the end of the file */
4030 + if (r != EOF && !done && line)
4032 + fputs (line, ofp);
4033 + r = fputc ('\n', ofp);
4035 + mx_unlock_file (filename, fileno (ifp), 0);
4041 + mutt_error (_("Can't write %s"), tmpfile);
4044 + if (rename (tmpfile, filename) < 0)
4047 + mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
4053 +int mutt_newsrc_update (NNTP_SERVER *news)
4063 + llen = len = 10 * LONG_STRING;
4064 + line = buf = safe_calloc (1, len);
4065 + /* we will generate full newsrc here */
4066 + for (tmp = news->list; tmp; tmp = tmp->next)
4068 + data = (NNTP_DATA *) tmp->data;
4069 + if (!data || !data->rc)
4071 + nntp_create_newsrc_line (data, &buf, &line, &llen);
4073 + dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4074 + line += strlen (line);
4076 + /* newrc being fully rewritten */
4077 + if (news->newsrc &&
4078 + (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4082 + stat (news->newsrc, &st);
4083 + news->size = st.st_size;
4084 + news->mtime = st.st_mtime;
4090 +static FILE *mutt_mkname (char *s)
4092 + char buf[_POSIX_PATH_MAX], *pc;
4096 + nntp_cache_expand (buf, s);
4097 + if ((fp = safe_fopen (buf, "w")))
4100 + nntp_cache_expand (buf, "cache-XXXXXX");
4101 + pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4102 + if ((fd = mkstemp (buf)) == -1)
4104 + strcpy (s, pc); /* generated name */
4105 + return fdopen (fd, "w");
4108 +/* Updates info into .index file: ALL or about selected newsgroup */
4109 +static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4111 + char buf[LONG_STRING], *key = "ALL";
4112 + char file[_POSIX_PATH_MAX];
4114 + if (!serv || !serv->conn || !serv->conn->account.host)
4117 + if (data && data->group)
4119 + key = data->group;
4120 + snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4121 + data->firstMessage, data->lastLoaded);
4125 + strfcpy (file, serv->cache, sizeof (file));
4126 + snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4128 + nntp_cache_expand (file, ".index");
4129 + return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4132 +/* Remove cache files of unsubscribed newsgroups */
4133 +void nntp_clear_cacheindex (NNTP_SERVER *news)
4138 + if (option (OPTSAVEUNSUB) || !news)
4141 + for (tmp = news->list; tmp; tmp = tmp->next)
4143 + data = (NNTP_DATA *) tmp->data;
4144 + if (!data || data->subscribed || !data->cache)
4146 + nntp_delete_cache (data);
4147 + dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4152 +int nntp_save_cache_index (NNTP_SERVER *news)
4154 + char buf[HUGE_STRING];
4155 + char file[_POSIX_PATH_MAX];
4160 + if (!news || !news->newsgroups)
4162 + if (!option (OPTNEWSCACHE))
4167 + nntp_cache_expand (file, news->cache);
4169 + f = safe_fopen (file, "w");
4173 + strfcpy (buf, news->conn->account.host, sizeof(buf));
4174 + f = mutt_mkname (buf);
4175 + news->cache = safe_strdup (buf);
4176 + nntp_cache_expand (file, buf);
4181 + for (l = news->list; l; l = l->next)
4183 + if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4186 + snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4187 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4190 + snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4191 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4192 + if (fputs (buf, f) == EOF)
4202 + if (nntp_update_cacheindex (news, NULL))
4210 +int nntp_save_cache_group (CONTEXT *ctx)
4212 + char buf[HUGE_STRING], addr[STRING];
4213 + char file[_POSIX_PATH_MAX];
4217 + int i = 0, save = SORT_ORDER;
4220 + if (!option (OPTNEWSCACHE))
4222 + if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4225 + if (((NNTP_DATA *)ctx->data)->cache)
4227 + nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4229 + f = safe_fopen (file, "w");
4233 + snprintf (buf, sizeof(buf), "%s-%s",
4234 + ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4235 + ((NNTP_DATA *)ctx->data)->group);
4236 + f = mutt_mkname (buf);
4237 + ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4238 + nntp_cache_expand (file, buf);
4243 + if (Sort != SORT_ORDER)
4246 + Sort = SORT_ORDER;
4247 + mutt_sort_headers (ctx, 0);
4250 + /* Save only $nntp_context messages... */
4251 + ((NNTP_DATA *)ctx->data)->lastCached = 0;
4252 + if (NntpContext && ctx->msgcount > NntpContext)
4253 + i = ctx->msgcount - NntpContext;
4254 + for (; i < ctx->msgcount; i++)
4256 + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4260 + rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4261 + tm = gmtime (&h->date_sent);
4262 + snprintf (buf, sizeof(buf),
4263 + "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4264 + h->article_num, h->env->subject, addr, tm->tm_mday,
4265 + Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4266 + tm->tm_sec, h->env->message_id);
4268 + if (h->env->references)
4269 + mutt_write_references (h->env->references, f, 10);
4270 + snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length,
4271 + (int) h->lines, NONULL(h->env->xref));
4272 + if (fputs (buf, f) == EOF)
4279 + prev = ctx->hdrs[i]->article_num;
4285 + mutt_sort_headers (ctx, 0);
4289 + if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4290 + (NNTP_DATA *)ctx->data))
4295 + ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4299 +void nntp_delete_cache (NNTP_DATA *data)
4301 + char buf[_POSIX_PATH_MAX];
4303 + if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4306 + nntp_cache_expand (buf, data->cache);
4308 + FREE (&data->cache);
4309 + data->lastCached = 0;
4310 + nntp_cache_expand (buf, ".index");
4311 + mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4314 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4318 + if (!news || !news->newsgroups || !group || !*group)
4320 + if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4322 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4323 + data->group = (char *) data + sizeof (NNTP_DATA);
4324 + strcpy (data->group, group);
4325 + data->nserv = news;
4326 + data->deleted = 1;
4327 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4328 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
4329 + hash_insert (news->newsgroups, data->group, data, 0);
4330 + nntp_add_to_list (news, data);
4332 + if (!data->subscribed)
4334 + data->subscribed = 1;
4340 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4344 + if (!news || !news->newsgroups || !group || !*group ||
4345 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4347 + if (data->subscribed)
4349 + data->subscribed = 0;
4350 + if (!option (OPTSAVEUNSUB))
4356 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4360 + if (!news || !news->newsgroups || !group || !*group ||
4361 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4365 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4369 + data->entries[0].first = 1;
4371 + data->entries[0].last = data->lastMessage;
4372 + if (Context && Context->data == data)
4376 + for (x = 0; x < Context->msgcount; x++)
4377 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4382 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4386 + if (!news || !news->newsgroups || !group || !*group ||
4387 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4391 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4395 + data->entries[0].first = 1;
4396 + data->entries[0].last = data->firstMessage - 1;
4397 + if (Context && Context->data == data)
4401 + data->unread = Context->msgcount;
4402 + for (x = 0; x < Context->msgcount; x++)
4403 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4406 + data->unread = data->lastMessage - data->entries[0].last;
4410 +/* this routine gives the first newsgroup with new messages */
4411 +void nntp_buffy (char *s)
4415 + for (list = CurrentNewsSrv->list; list; list = list->next)
4417 + NNTP_DATA *data = (NNTP_DATA *) list->data;
4419 + if (data && data->subscribed && data->unread)
4421 + if (Context && Context->magic == M_NNTP &&
4422 + !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4424 + unsigned int i, unread = 0;
4426 + for (i = 0; i < Context->msgcount; i++)
4427 + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4432 + strcpy (s, data->group);
4437 diff -udprP mutt-1.5.20.orig/nntp.c mutt-1.5.20/nntp.c
4438 --- mutt-1.5.20.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4439 +++ mutt-1.5.20/nntp.c 2009-06-15 21:05:24.000000000 +0300
4442 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4443 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4444 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
4446 + * This program is free software; you can redistribute it and/or modify
4447 + * it under the terms of the GNU General Public License as published by
4448 + * the Free Software Foundation; either version 2 of the License, or
4449 + * (at your option) any later version.
4451 + * This program is distributed in the hope that it will be useful,
4452 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4453 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4454 + * GNU General Public License for more details.
4456 + * You should have received a copy of the GNU General Public License
4457 + * along with this program; if not, write to the Free Software
4458 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4462 +# include "config.h"
4466 +#include "mutt_curses.h"
4470 +#include "rfc1524.h"
4471 +#include "rfc2047.h"
4472 +#include "mailbox.h"
4483 +#include <unistd.h>
4484 +#include <string.h>
4486 +#include <stdlib.h>
4488 +static unsigned int _checked = 0;
4491 +static void nntp_error (const char *where, const char *msg)
4493 + dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4497 +static int nntp_auth (NNTP_SERVER *serv)
4499 + CONNECTION *conn = serv->conn;
4501 + unsigned char flags = conn->account.flags;
4503 + if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4504 + mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4506 + conn->account.flags = flags;
4510 + mutt_message _("Logging in...");
4512 + snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4513 + mutt_socket_write (conn, buf);
4514 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4516 + conn->account.flags = flags;
4521 + /* don't print the password unless we're at the ungodly debugging level */
4522 + if (debuglevel < M_SOCK_LOG_FULL)
4523 + dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4525 + snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4526 + mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4527 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4529 + conn->account.flags = flags;
4533 + if (mutt_strncmp ("281", buf, 3))
4535 + conn->account.flags = flags;
4536 + mutt_error _("Login failed.");
4544 +static int nntp_connect_error (NNTP_SERVER *serv)
4546 + serv->status = NNTP_NONE;
4547 + mutt_socket_close (serv->conn);
4548 + mutt_error _("Server closed connection!");
4553 +static int nntp_connect_and_auth (NNTP_SERVER *serv)
4555 + CONNECTION *conn = serv->conn;
4559 + serv->status = NNTP_NONE;
4561 + if (mutt_socket_open (conn) < 0)
4564 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4565 + return nntp_connect_error (serv);
4567 + if (!mutt_strncmp ("200", buf, 3))
4568 + mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4569 + else if (!mutt_strncmp ("201", buf, 3))
4570 + mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4573 + mutt_socket_close (conn);
4574 + mutt_remove_trailing_ws (buf);
4575 + mutt_error ("%s", buf);
4582 + /* Tell INN to switch to mode reader if it isn't so. Ignore all
4583 + returned codes and messages. */
4584 + mutt_socket_write (conn, "MODE READER\r\n");
4585 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4586 + return nntp_connect_error (serv);
4588 + mutt_socket_write (conn, "STAT\r\n");
4589 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4590 + return nntp_connect_error (serv);
4592 + if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
4594 + serv->status = NNTP_OK;
4598 + rc = nntp_auth (serv);
4600 + return nntp_connect_error (serv);
4603 + mutt_socket_close (conn);
4604 + serv->status = NNTP_BYE;
4609 + mutt_socket_close (conn);
4610 + mutt_error _("Login failed.");
4614 + serv->status = NNTP_OK;
4618 +static int nntp_attempt_features (NNTP_SERVER *serv)
4620 + char buf[LONG_STRING];
4621 + CONNECTION *conn = serv->conn;
4623 + mutt_socket_write (conn, "XOVER\r\n");
4624 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4625 + return nntp_connect_error (serv);
4626 + if (mutt_strncmp ("500", buf, 3))
4627 + serv->hasXOVER = 1;
4629 + mutt_socket_write (conn, "XPAT\r\n");
4630 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4631 + return nntp_connect_error (serv);
4632 + if (mutt_strncmp ("500", buf, 3))
4633 + serv->hasXPAT = 1;
4635 + mutt_socket_write (conn, "LISTGROUP\r\n");
4636 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4637 + return nntp_connect_error (serv);
4638 + if (mutt_strncmp ("500", buf, 3))
4639 + serv->hasLISTGROUP = 1;
4641 + mutt_socket_write (conn, "XGTITLE +\r\n");
4642 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4643 + return nntp_connect_error (serv);
4644 + if (mutt_strncmp ("500", buf, 3))
4645 + serv->hasXGTITLE = 1;
4647 + if (!mutt_strncmp ("282", buf, 3))
4651 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4652 + return nntp_connect_error (serv);
4653 + } while (!(buf[0] == '.' && buf[1] == '\0'));
4659 +static int nntp_open_connection (NNTP_SERVER *serv)
4661 + if (serv->status == NNTP_OK)
4663 + if (serv->status == NNTP_BYE)
4665 + if (nntp_connect_and_auth (serv) < 0)
4667 + if (nntp_attempt_features (serv) < 0)
4672 +static int nntp_reconnect (NNTP_SERVER *serv)
4674 + char buf[SHORT_STRING];
4676 + mutt_socket_close (serv->conn);
4680 + if (nntp_connect_and_auth (serv) == 0)
4683 + snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
4684 + serv->conn->account.host);
4685 + if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
4687 + serv->status = NNTP_BYE;
4693 +/* Send data from line[LONG_STRING] and receive answer to same line */
4694 +static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
4696 + char buf[LONG_STRING];
4699 + if (data->nserv->status == NNTP_BYE)
4706 + mutt_socket_write (data->nserv->conn, line);
4708 + else if (data->group)
4710 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4711 + mutt_socket_write (data->nserv->conn, buf);
4715 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4717 + if (nntp_reconnect (data->nserv) < 0)
4722 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4723 + mutt_socket_write (data->nserv->conn, buf);
4724 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4730 + else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
4734 + strfcpy (line, buf, linelen);
4739 + * This function calls funct(*line, *data) for each received line,
4740 + * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
4743 + * 1 - correct but not performed (may be, have to be continued),
4744 + * -1 - conection lost,
4745 + * -2 - invalid command or execution error,
4746 + * -3 - error in funct(*line, *data).
4748 +static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
4749 + int (*funct) (char *, void *), void *data, int tagged)
4751 + char buf[LONG_STRING];
4755 + size_t lenbuf = 0;
4760 + strfcpy (buf, query, sizeof (buf));
4761 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
4763 + if (buf[0] == '5')
4765 + if (buf[0] != '2')
4770 + inbuf = safe_malloc (sizeof (buf));
4774 + chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
4780 + if (!lenbuf && buf[0] == '.')
4782 + if (buf[1] == '\0')
4787 + if (buf[1] == '.')
4791 + strfcpy (inbuf + lenbuf, p, sizeof (buf));
4793 + if (chunk >= sizeof (buf))
4795 + lenbuf += strlen (p);
4800 + if (msg && ReadInc && (line % ReadInc == 0)) {
4802 + mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
4804 + mutt_message ("%s %d", msg, line);
4807 + if (ret == 0 && funct (inbuf, data) < 0)
4812 + safe_realloc (&inbuf, lenbuf + sizeof (buf));
4815 + funct (NULL, data);
4821 +static int nntp_read_tempfile (char *line, void *file)
4823 + FILE *f = (FILE *)file;
4830 + if (fputc ('\n', f) == EOF)
4836 +static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
4838 + register char *p, *b;
4839 + register char *colon = NULL;
4844 + /* skip to next word */
4846 + while (*b && ((*b == ' ') || (*b == '\t'))) b++;
4849 + /* skip to end of word */
4850 + while (*p && (*p != ' ') && (*p != '\t'))
4865 + nntp_get_status (ctx, h, b, atoi(colon));
4866 + if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
4867 + h->article_num = atoi(colon);
4875 + * 1 if article not found
4876 + * -1 if read or write error on tempfile or socket
4878 +static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
4880 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
4882 + char buf[LONG_STRING];
4883 + char tempfile[_POSIX_PATH_MAX];
4885 + HEADER *h = ctx->hdrs[ctx->msgcount];
4887 + mutt_mktemp (tempfile);
4888 + if (!(f = safe_fopen (tempfile, "w+")))
4892 + snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
4894 + snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
4896 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
4901 + dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
4904 + unlink (tempfile);
4905 + return (ret == -1 ? -1 : 1);
4908 + h->article_num = article_num;
4909 + h->env = mutt_read_rfc822_header (f, h, 0, 0);
4911 + unlink (tempfile);
4913 + if (h->env->xref != NULL)
4914 + nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
4915 + else if (h->article_num == 0 && msgid)
4917 + snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
4918 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
4919 + h->article_num = atoi (buf + 4);
4925 +static int parse_description (char *line, void *n)
4927 +#define news ((NNTP_SERVER *) n)
4928 + register char *d = line;
4933 + while (*d && *d != '\t' && *d != ' ') d++;
4936 + while (*d && (*d == '\t' || *d == ' ')) d++;
4937 + dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
4938 + if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
4939 + mutt_strcmp (d, data->desc))
4941 + FREE (&data->desc);
4942 + data->desc = safe_strdup (d);
4948 +static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
4952 + if (!option (OPTLOADDESC) || !data || !data->nserv)
4955 + /* Get newsgroup description, if we can */
4956 + if (data->nserv->hasXGTITLE)
4957 + snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
4959 + snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
4960 + if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
4963 + nntp_error ("nntp_get_desc()", buf);
4969 + * XOVER returns a tab separated list of:
4970 + * id|subject|from|date|Msgid|references|bytes|lines|xref
4972 + * This has to duplicate some of the functionality of
4973 + * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
4974 + * a limited number of headers which are "parsed" by placement in the list)
4976 +static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
4978 + NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
4982 + hdr->env = mutt_new_envelope();
4983 + hdr->env->newsgroups = safe_strdup (nntp_data->group);
4984 + hdr->content = mutt_new_body();
4985 + hdr->content->type = TYPETEXT;
4986 + hdr->content->subtype = safe_strdup ("plain");
4987 + hdr->content->encoding = ENC7BIT;
4988 + hdr->content->disposition = DISPINLINE;
4989 + hdr->content->length = -1;
4992 + for (x = 0; !done && x < 9; x++)
4994 + /* if from file, need to skip newline character */
4995 + while (*p && *p != '\n' && *p != '\t') p++;
5003 + hdr->article_num = atoi (b);
5004 + nntp_get_status (ctx, hdr, NULL, hdr->article_num);
5007 + hdr->env->subject = safe_strdup (b);
5008 + /* Now we need to do the things which would normally be done in
5009 + * mutt_read_rfc822_header() */
5010 + if (hdr->env->subject)
5012 + regmatch_t pmatch[1];
5014 + rfc2047_decode (&hdr->env->subject);
5016 + if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
5017 + hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
5019 + hdr->env->real_subj = hdr->env->subject;
5023 + rfc822_free_address (&hdr->env->from);
5024 + hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
5025 + rfc2047_decode_adrlist (hdr->env->from);
5028 + hdr->date_sent = mutt_parse_date (b, hdr);
5029 + hdr->received = hdr->date_sent;
5032 + FREE (&hdr->env->message_id);
5033 + hdr->env->message_id = safe_strdup (b);
5036 + mutt_free_list (&hdr->env->references);
5037 + hdr->env->references = mutt_parse_references (b, 0);
5040 + hdr->content->length = atoi (b);
5043 + hdr->lines = atoi (b);
5047 + FREE (&hdr->env->xref);
5048 + b = b + 6; /* skips the "Xref: " */
5049 + hdr->env->xref = safe_strdup (b);
5050 + nntp_parse_xref (ctx, nntp_data->group, b, hdr);
5062 + unsigned int base;
5063 + unsigned int first;
5064 + unsigned int last;
5065 + unsigned short *messages;
5069 +#define fc ((FETCH_CONTEXT *) c)
5070 +static int nntp_fetch_numbers (char *line, void *c)
5076 + num = atoi (line);
5077 + if (num < fc->base || num > fc->last)
5079 + fc->messages[num - fc->base] = 1;
5083 +static int add_xover_line (char *line, void *c)
5085 + unsigned int num, total;
5086 + CONTEXT *ctx = fc->ctx;
5087 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5092 + if (ctx->msgcount >= ctx->hdrmax)
5093 + mx_alloc_memory (ctx);
5094 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5095 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5097 + nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5098 + num = ctx->hdrs[ctx->msgcount]->article_num;
5100 + if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5103 + if (num > data->lastLoaded)
5104 + data->lastLoaded = num;
5105 + num = num - fc->first + 1;
5106 + total = fc->last - fc->first + 1;
5107 + if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5108 + mutt_message ("%s %d/%d", fc->msg, num, total);
5111 + mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5117 +static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5118 + unsigned int last)
5120 + char buf[HUGE_STRING];
5121 + char *msg = _("Fetching message headers...");
5122 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5126 + unsigned int current;
5130 + /* if empty group or nothing to do */
5131 + if (!last || first > last)
5134 + /* fetch list of articles */
5138 + fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5139 + if (nntp_data->nserv->hasLISTGROUP)
5141 + mutt_message _("Fetching list of articles...");
5142 + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5143 + if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5145 + mutt_error (_("LISTGROUP command failed: %s"), buf);
5147 + nntp_error ("nntp_fetch_headers()", buf);
5149 + FREE (&fc.messages);
5155 + for (num = 0; num < last - first + 1; num++)
5156 + fc.messages[num] = 1;
5159 + /* CACHE: must be loaded xover cache here */
5160 + num = nntp_data->lastCached - first + 1;
5161 + if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5163 + nntp_cache_expand (buf, nntp_data->cache);
5164 + mutt_message _("Fetching headers from cache...");
5165 + if ((f = safe_fopen (buf, "r")))
5169 + /* counting number of lines */
5170 + while (fgets (buf, sizeof (buf), f) != NULL)
5173 + while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5175 + oldmsgcount = ctx->msgcount;
5177 + fc.last = first + num - 1;
5179 + while (fgets (buf, sizeof (buf), f) != NULL)
5180 + add_xover_line (buf, &fc);
5182 + nntp_data->lastLoaded = fc.last;
5183 + first = fc.last + 1;
5184 + if (ctx->msgcount > oldmsgcount)
5185 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5188 + nntp_delete_cache (nntp_data);
5190 + num = last - first + 1;
5193 + FREE (&fc.messages);
5198 + * Without XOVER, we have to fetch each article header and parse
5199 + * it. With XOVER, we ask for all of them
5201 + mutt_message (msg);
5202 + if (nntp_data->nserv->hasXOVER)
5204 + oldmsgcount = ctx->msgcount;
5208 + snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5209 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5210 + if (ctx->msgcount > oldmsgcount)
5211 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5214 + mutt_error (_("XOVER command failed: %s"), buf);
5216 + nntp_error ("nntp_fetch_headers()", buf);
5218 + FREE (&fc.messages);
5224 + for (current = first; current <= last; current++)
5228 + ret = current - first + 1;
5229 + mutt_message ("%s %d/%d", msg, ret, num);
5231 + if (!fc.messages[current - fc.base])
5234 + if (ctx->msgcount >= ctx->hdrmax)
5235 + mx_alloc_memory (ctx);
5236 + h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5237 + h->index = ctx->msgcount;
5239 + ret = nntp_read_header (ctx, NULL, current);
5240 + if (ret == 0) /* Got article. Fetch next header */
5242 + nntp_get_status (ctx, h, NULL, h->article_num);
5244 + mx_update_context (ctx, 1);
5247 + mutt_free_header (&h); /* skip it */
5250 + FREE (&fc.messages);
5254 + if (current > nntp_data->lastLoaded)
5255 + nntp_data->lastLoaded = current;
5257 + FREE (&fc.messages);
5258 + nntp_data->lastLoaded = last;
5259 + mutt_clear_error ();
5264 + * currently, nntp "mailbox" is "newsgroup"
5266 +int nntp_open_mailbox (CONTEXT *ctx)
5268 + NNTP_DATA *nntp_data;
5269 + NNTP_SERVER *serv;
5270 + char buf[HUGE_STRING];
5271 + char server[LONG_STRING];
5273 + unsigned int first;
5276 + if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5278 + mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5284 + nntp_expand_path (server, sizeof (server), &acct);
5285 + if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5288 + CurrentNewsSrv = serv;
5290 + /* create NNTP-specific state struct if nof found in list */
5291 + if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5293 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5294 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5295 + strcpy (nntp_data->group, buf);
5296 + hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5297 + nntp_add_to_list (serv, nntp_data);
5299 + ctx->data = nntp_data;
5300 + ctx->mx_close = nntp_fastclose_mailbox;
5301 + nntp_data->nserv = serv;
5303 + mutt_message (_("Selecting %s..."), nntp_data->group);
5305 + if (!nntp_data->desc)
5307 + nntp_get_desc (nntp_data, nntp_data->group, NULL);
5308 + if (nntp_data->desc)
5309 + nntp_save_cache_index (serv);
5313 + if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5316 + nntp_error ("nntp_open_mailbox()", buf);
5321 + if (mutt_strncmp ("211", buf, 3))
5323 + LIST *l = serv->list;
5325 + /* GROUP command failed */
5326 + if (!mutt_strncmp ("411", buf, 3))
5328 + mutt_error (_("Newsgroup %s not found on server %s"),
5329 + nntp_data->group, serv->conn->account.host);
5331 + /* CACHE: delete cache and line from .index */
5332 + nntp_delete_cache (nntp_data);
5333 + hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5334 + while (l && l->data != (void *) nntp_data) l = l->next;
5344 + sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5345 + &nntp_data->lastMessage, buf);
5347 + nntp_data->deleted = 0;
5349 + time (&serv->check_time);
5352 + * Check for max adding context. If it is greater than $nntp_context,
5353 + * strip off extra articles
5355 + first = nntp_data->firstMessage;
5356 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5357 + first = nntp_data->lastMessage - NntpContext + 1;
5359 + nntp_data->lastLoaded = first - 1;
5360 + return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5363 +int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5365 + char buf[LONG_STRING];
5366 + char path[_POSIX_PATH_MAX];
5367 + NNTP_CACHE *cache;
5368 + char *m = _("Fetching message...");
5371 + /* see if we already have the message in our cache */
5372 + cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5374 + /* if everything is fine, assign msg->fp and return */
5375 + if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5376 + (msg->fp = fopen (cache->path, "r")))
5379 + /* clear the previous entry */
5380 + unlink (cache->path);
5381 + free (cache->path);
5385 + cache->index = ctx->hdrs[msgno]->index;
5386 + mutt_mktemp (path);
5387 + cache->path = safe_strdup (path);
5388 + if (!(msg->fp = safe_fopen (path, "w+")))
5390 + FREE (&cache->path);
5394 + if (ctx->hdrs[msgno]->article_num == 0)
5395 + snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5396 + ctx->hdrs[msgno]->env->message_id);
5398 + snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5399 + ctx->hdrs[msgno]->article_num);
5401 + ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5402 + msg->fp, ctx->tagged);
5405 + mutt_error (_("Article %d not found on server"),
5406 + ctx->hdrs[msgno]->article_num);
5407 + dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5414 + FREE (&cache->path);
5418 + mutt_free_envelope (&ctx->hdrs[msgno]->env);
5419 + ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5420 + /* fix content length */
5421 + fseek(msg->fp, 0, SEEK_END);
5422 + ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5423 + ctx->hdrs[msgno]->content->offset;
5425 + /* this is called in mutt before the open which fetches the message,
5426 + * which is probably wrong, but we just call it again here to handle
5427 + * the problem instead of fixing it.
5429 + mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5431 + /* These would normally be updated in mx_update_context(), but the
5432 + * full headers aren't parsed with XOVER, so the information wasn't
5435 +#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5436 + ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5437 +#endif /* HAVE_PGP || HAVE_SMIME */
5439 + mutt_clear_error();
5446 +int nntp_post (const char *msg) {
5447 + char buf[LONG_STRING];
5450 + NNTP_DATA *nntp_data;
5452 + if (Context && Context->magic == M_NNTP)
5453 + nntp_data = (NNTP_DATA *)Context->data;
5456 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5457 + !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5459 + mutt_error (_("Can't post article. No connection to news server."));
5462 + nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5465 + if (!(f = safe_fopen (msg, "r")))
5467 + mutt_error (_("Can't post article. Unable to open %s"), msg);
5471 + strfcpy (buf, "POST\r\n", sizeof (buf));
5472 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5474 + mutt_error (_("Can't post article. Connection to %s lost."),
5475 + nntp_data->nserv->conn->account.host);
5478 + if (buf[0] != '3')
5480 + mutt_error (_("Can't post article: %s"), buf);
5486 + while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5488 + len = strlen (buf);
5489 + if (buf[len - 1] == '\n')
5491 + buf[len - 1] = '\r';
5496 + if (buf[1] == '.')
5497 + mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5499 + mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5503 + if (buf[strlen (buf) - 1] != '\n')
5504 + mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5505 + mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5506 + if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5508 + mutt_error (_("Can't post article. Connection to %s lost."),
5509 + nntp_data->nserv->conn->account.host);
5512 + if (buf[0] != '2')
5514 + mutt_error (_("Can't post article: %s"), buf);
5521 +/* nntp_logout_all: close all open connections. */
5522 +void nntp_logout_all (void)
5524 + char buf[LONG_STRING];
5527 + conn = mutt_socket_head ();
5531 + CONNECTION *next = conn->next;
5533 + if (conn->account.type == M_ACCT_TYPE_NNTP)
5535 + mutt_message (_("Closing connection to %s..."), conn->account.host);
5536 + mutt_socket_write (conn, "QUIT\r\n");
5537 + mutt_socket_readln (buf, sizeof (buf), conn);
5538 + mutt_clear_error ();
5539 + mutt_socket_close (conn);
5540 + mutt_socket_free (conn);
5547 +static void nntp_free_acache (NNTP_DATA *data)
5551 + for (i = 0; i < NNTP_CACHE_LEN; i++)
5553 + if (data->acache[i].path)
5555 + unlink (data->acache[i].path);
5556 + FREE (&data->acache[i].path);
5561 +void nntp_delete_data (void *p)
5563 + NNTP_DATA *data = (NNTP_DATA *)p;
5567 + FREE (&data->entries);
5568 + FREE (&data->desc);
5569 + FREE (&data->cache);
5570 + nntp_free_acache (data);
5574 +int nntp_sync_mailbox (CONTEXT *ctx)
5576 + NNTP_DATA *data = ctx->data;
5578 + /* CACHE: update cache and .index files */
5579 + if ((option (OPTSAVEUNSUB) || data->subscribed))
5580 + nntp_save_cache_group (ctx);
5581 + nntp_free_acache (data);
5583 + data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
5587 +int nntp_fastclose_mailbox (CONTEXT *ctx)
5589 + NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
5593 + nntp_free_acache (data);
5594 + if (!data->nserv || !data->nserv->newsgroups || !data->group)
5596 + nntp_save_cache_index (data->nserv);
5597 + if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
5599 + nntp_delete_data (data);
5603 +/* commit changes and terminate connection */
5604 +int nntp_close_mailbox (CONTEXT *ctx)
5608 + mutt_message _("Quitting newsgroup...");
5611 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
5614 + if (data->nserv && data->nserv->conn && ctx->unread)
5616 + ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
5618 + mutt_newsgroup_catchup (data->nserv, data->group);
5623 + nntp_sync_mailbox (ctx);
5624 + if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
5626 + NNTP_SERVER *news;
5628 + news = ((NNTP_DATA *)ctx->data)->nserv;
5629 + newsrc_gen_entries (ctx);
5630 + ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
5631 + mutt_newsrc_update (news);
5633 + mutt_clear_error();
5637 +/* use the GROUP command to poll for new mail */
5638 +static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
5640 + char buf[LONG_STRING];
5643 + if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
5647 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5650 + nntp_error ("nntp_check_mailbox()", buf);
5654 + if (mutt_strncmp ("211", buf, 3))
5657 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5660 + nntp_error ("nntp_check_mailbox()", buf);
5665 + if (!mutt_strncmp ("211", buf, 3))
5670 + sscanf (buf + 4, "%d %d %d", &count, &first, &last);
5671 + nntp_data->firstMessage = first;
5672 + nntp_data->lastMessage = last;
5673 + if (ctx && last > nntp_data->lastLoaded)
5675 + nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
5676 + time (&nntp_data->nserv->check_time);
5679 + if (!last || (!nntp_data->rc && !nntp_data->lastCached))
5680 + nntp_data->unread = count;
5682 + mutt_newsgroup_stat (nntp_data);
5683 + /* active was renumbered? */
5684 + if (last < nntp_data->lastLoaded)
5686 + if (!nntp_data->max)
5688 + nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
5689 + nntp_data->max = 5;
5691 + nntp_data->lastCached = 0;
5692 + nntp_data->num = 1;
5693 + nntp_data->entries[0].first = 1;
5694 + nntp_data->entries[0].last = 0;
5698 + time (&nntp_data->nserv->check_time);
5702 +int nntp_check_mailbox (CONTEXT *ctx)
5704 + return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
5707 +static int add_group (char *buf, void *serv)
5709 +#define s ((NNTP_SERVER *) serv)
5710 + char group[LONG_STRING], mod, desc[HUGE_STRING];
5712 + NNTP_DATA *nntp_data;
5715 + _checked = n; /* _checked have N, where N = number of groups */
5716 + if (!buf) /* at EOF must be zerouth */
5723 + sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
5726 + if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
5729 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
5730 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5731 + strcpy (nntp_data->group, group);
5732 + nntp_data->nserv = s;
5733 + if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
5734 + s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2, 0);
5735 + hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
5736 + nntp_add_to_list (s, nntp_data);
5738 + nntp_data->deleted = 0;
5739 + nntp_data->firstMessage = first;
5740 + nntp_data->lastMessage = last;
5742 + nntp_data->allowed = 1;
5744 + nntp_data->allowed = 0;
5745 + if (nntp_data->desc)
5746 + FREE (&nntp_data->desc);
5748 + nntp_data->desc = safe_strdup (desc);
5749 + if (nntp_data->rc || nntp_data->lastCached)
5750 + mutt_newsgroup_stat (nntp_data);
5751 + else if (nntp_data->lastMessage &&
5752 + nntp_data->firstMessage <= nntp_data->lastMessage)
5753 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
5755 + nntp_data->unread = 0;
5761 +int nntp_check_newgroups (NNTP_SERVER *serv, int force)
5763 + char buf[LONG_STRING];
5764 + char msg[SHORT_STRING];
5765 + NNTP_DATA nntp_data;
5770 + unsigned int count = 0;
5771 + unsigned int total = 0;
5773 + if (!serv || !serv->newgroups_time)
5776 + if (nntp_open_connection (serv) < 0)
5779 + /* check subscribed groups for new news */
5780 + if (option (OPTSHOWNEWNEWS))
5782 + mutt_message _("Checking for new messages...");
5783 + for (l = serv->list; l; l = l->next)
5785 + serv->check_time = 0; /* really check! */
5786 + if (l->data && ((NNTP_DATA *) l->data)->subscribed)
5787 + _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
5793 + mutt_message _("Checking for new newsgroups...");
5794 + now = serv->newgroups_time;
5795 + time (&serv->newgroups_time);
5796 + t = gmtime (&now);
5797 + snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
5798 + (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
5800 + nntp_data.nserv = serv;
5801 + if (Context && Context->magic == M_NNTP)
5802 + nntp_data.group = ((NNTP_DATA *)Context->data)->group;
5804 + nntp_data.group = NULL;
5806 + if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
5807 + add_group, serv, 0) != 0)
5810 + nntp_error ("nntp_check_newgroups()", buf);
5815 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5816 + mutt_message (msg);
5818 + emp.next = l->next;
5820 + emp.next = serv->list;
5825 + ((NNTP_DATA *) l->data)->new = 1;
5832 + nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
5834 + if (ReadInc && (count % ReadInc == 0))
5835 + mutt_message ("%s %d/%d", msg, count, total);
5838 + nntp_save_cache_index (serv);
5839 + mutt_clear_error ();
5843 +/* Load list of all newsgroups from cache ALL */
5844 +int nntp_get_cache_all (NNTP_SERVER *serv)
5846 + char buf[HUGE_STRING];
5849 + nntp_cache_expand (buf, serv->cache);
5850 + if ((f = safe_fopen (buf, "r")))
5854 + while (fgets (buf, sizeof(buf), f) != NULL)
5856 + if (ReadInc && (i % ReadInc == 0))
5857 + mutt_message (_("Loading list from cache... %d"), i);
5858 + add_group (buf, serv);
5861 + add_group (NULL, NULL);
5863 + mutt_clear_error ();
5868 + FREE (&serv->cache);
5873 +/* Load list of all newsgroups from active */
5874 +int nntp_get_active (NNTP_SERVER *serv)
5876 + char msg[SHORT_STRING];
5877 + NNTP_DATA nntp_data;
5880 + if (nntp_open_connection (serv) < 0)
5883 + snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
5884 + serv->conn->account.host);
5885 + mutt_message (msg);
5886 + time (&serv->newgroups_time);
5887 + nntp_data.nserv = serv;
5888 + nntp_data.group = NULL;
5890 + if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
5893 + nntp_error ("nntp_get_active()", "LIST\r\n");
5898 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5899 + mutt_message (msg);
5900 + nntp_get_desc (&nntp_data, "*", msg);
5902 + for (tmp = serv->list; tmp; tmp = tmp->next)
5904 + NNTP_DATA *data = (NNTP_DATA *)tmp->data;
5906 + if (data && data->deleted && !data->rc)
5908 + nntp_delete_cache (data);
5909 + hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
5913 + nntp_save_cache_index (serv);
5915 + mutt_clear_error ();
5920 + * returns -1 if error ocurred while retrieving header,
5921 + * number of articles which ones exist in context on success.
5923 +int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
5927 + /* if msgid is already in context, don't reload them */
5928 + if (hash_find (ctx->id_hash, msgid))
5930 + if (ctx->msgcount == ctx->hdrmax)
5931 + mx_alloc_memory (ctx);
5932 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5933 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5935 + mutt_message (_("Fetching %s from server..."), msgid);
5936 + ret = nntp_read_header (ctx, msgid, 0);
5937 + /* since nntp_read_header() may set read flag, we must reset it */
5938 + ctx->hdrs[ctx->msgcount]->read = 0;
5940 + mutt_free_header (&ctx->hdrs[ctx->msgcount]);
5944 + mx_update_context (ctx, 1);
5955 + unsigned int *child;
5958 +static int check_children (char *s, void *c)
5960 +#define cc ((CHILD_CONTEXT *) c)
5961 + unsigned int i, n;
5963 + if (!s || (n = atoi (s)) == 0)
5965 + for (i = 0; i < cc->ctx->msgcount; i++)
5966 + if (cc->ctx->hdrs[i]->article_num == n)
5968 + if (cc->num >= cc->max)
5969 + safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
5970 + cc->child[cc->num++] = n;
5976 +int nntp_check_children (CONTEXT *ctx, const char *msgid)
5978 + NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
5980 + int i, ret = 0, tmp = 0;
5983 + if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
5984 + !nntp_data->nserv->conn->account.host)
5986 + if (nntp_data->firstMessage > nntp_data->lastLoaded)
5988 + if (!nntp_data->nserv->hasXPAT)
5990 + mutt_error (_("Server %s does not support this operation!"),
5991 + nntp_data->nserv->conn->account.host);
5995 + snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
5996 + nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
6001 + cc.child = safe_malloc (sizeof (unsigned int) * 25);
6002 + if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
6007 + /* dont try to read the xover cache. check_children() already
6008 + * made sure that we dont have the article, so we need to visit
6009 + * the server. Reading the cache at this point is also bad
6010 + * because it would duplicate messages */
6011 + if (option (OPTNEWSCACHE))
6014 + unset_option (OPTNEWSCACHE);
6016 + for (i = 0; i < cc.num; i++)
6018 + if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
6020 + if (ctx->msgcount &&
6021 + ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
6022 + ctx->hdrs[ctx->msgcount - 1]->read = 0;
6025 + set_option (OPTNEWSCACHE);
6029 diff -udprP mutt-1.5.20.orig/nntp.h mutt-1.5.20/nntp.h
6030 --- mutt-1.5.20.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
6031 +++ mutt-1.5.20/nntp.h 2009-06-15 21:05:24.000000000 +0300
6034 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
6035 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
6036 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
6038 + * This program is free software; you can redistribute it and/or modify
6039 + * it under the terms of the GNU General Public License as published by
6040 + * the Free Software Foundation; either version 2 of the License, or
6041 + * (at your option) any later version.
6043 + * This program is distributed in the hope that it will be useful,
6044 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6045 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6046 + * GNU General Public License for more details.
6048 + * You should have received a copy of the GNU General Public License
6049 + * along with this program; if not, write to the Free Software
6050 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6056 +#include "mutt_socket.h"
6057 +#include "mailbox.h"
6061 +#define NNTP_PORT 119
6062 +#define NNTP_SSL_PORT 563
6064 +/* number of entries in the hash table */
6065 +#define NNTP_CACHE_LEN 10
6082 + unsigned int hasXPAT : 1;
6083 + unsigned int hasXGTITLE : 1;
6084 + unsigned int hasXOVER : 1;
6085 + unsigned int hasLISTGROUP : 1;
6086 + unsigned int status : 3;
6092 + time_t newgroups_time;
6093 + time_t check_time;
6095 + LIST *list; /* list of newsgroups */
6096 + LIST *tail; /* last entry of list */
6102 + unsigned int index;
6108 + NEWSRC_ENTRY *entries;
6109 + unsigned int num; /* number of used entries */
6110 + unsigned int max; /* number of allocated entries */
6111 + unsigned int unread;
6112 + unsigned int firstMessage;
6113 + unsigned int lastMessage;
6114 + unsigned int lastLoaded;
6115 + unsigned int lastCached;
6116 + unsigned int subscribed : 1;
6117 + unsigned int rc : 1;
6118 + unsigned int new : 1;
6119 + unsigned int allowed : 1;
6120 + unsigned int deleted : 1;
6124 + NNTP_SERVER *nserv;
6125 + NNTP_CACHE acache[NNTP_CACHE_LEN];
6128 +/* internal functions */
6129 +int nntp_get_active (NNTP_SERVER *);
6130 +int nntp_get_cache_all (NNTP_SERVER *);
6131 +int nntp_save_cache_index (NNTP_SERVER *);
6132 +int nntp_check_newgroups (NNTP_SERVER *, int);
6133 +int nntp_save_cache_group (CONTEXT *);
6134 +int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6135 +void newsrc_gen_entries (CONTEXT *);
6136 +void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6137 +void mutt_newsgroup_stat (NNTP_DATA *);
6138 +void nntp_delete_cache (NNTP_DATA *);
6139 +void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6140 +void nntp_cache_expand (char *, const char *);
6141 +void nntp_delete_data (void *);
6143 +/* exposed interface */
6144 +NNTP_SERVER *mutt_select_newsserver (char *);
6145 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6146 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6147 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6148 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6149 +void nntp_clear_cacheindex (NNTP_SERVER *);
6150 +int mutt_newsrc_update (NNTP_SERVER *);
6151 +int nntp_open_mailbox (CONTEXT *);
6152 +int nntp_sync_mailbox (CONTEXT *);
6153 +int nntp_check_mailbox (CONTEXT *);
6154 +int nntp_close_mailbox (CONTEXT *);
6155 +int nntp_fastclose_mailbox (CONTEXT *);
6156 +int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6157 +int nntp_post (const char *);
6158 +int nntp_check_msgid (CONTEXT *, const char *);
6159 +int nntp_check_children (CONTEXT *, const char *);
6160 +void nntp_buffy (char *);
6161 +void nntp_expand_path (char *, size_t, ACCOUNT *);
6162 +void nntp_logout_all ();
6163 +const char *nntp_format_str (char *, size_t, size_t, char, const char *, const char *,
6164 + const char *, const char *, unsigned long, format_flag);
6166 +NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6168 +#endif /* _NNTP_H_ */
6169 diff -udprP mutt-1.5.20.orig/pager.c mutt-1.5.20/pager.c
6170 --- mutt-1.5.20.orig/pager.c 2009-06-03 23:48:31.000000000 +0300
6171 +++ mutt-1.5.20/pager.c 2009-06-15 21:05:24.000000000 +0300
6172 @@ -1059,6 +1059,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
6182 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6183 int flags, ansi_attr *pa, int cnt,
6184 @@ -1512,6 +1517,16 @@ static struct mapping_t PagerHelpExtra[]
6189 +static struct mapping_t PagerNewsHelpExtra[] = {
6190 + { N_("Post"), OP_POST },
6191 + { N_("Followup"), OP_FOLLOWUP },
6192 + { N_("Del"), OP_DELETE },
6193 + { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6200 /* This pager is actually not so simple as it once was. It now operates in
6201 @@ -1553,6 +1568,10 @@ mutt_pager (const char *banner, const ch
6202 int old_PagerIndexLines; /* some people want to resize it
6203 * while inside the pager... */
6206 + char *followup_to;
6209 if (!(flags & M_SHOWCOLOR))
6210 flags |= M_SHOWFLAT;
6212 @@ -1592,7 +1611,11 @@ mutt_pager (const char *banner, const ch
6213 if (IsHeader (extra))
6215 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6216 - mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6217 + mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6219 + (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6222 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6225 @@ -2465,6 +2488,15 @@ search_next:
6227 CHECK_ACL(M_ACL_WRITE, "flag message");
6230 + if (Context->magic == M_NNTP)
6233 + mutt_error _("Can't change 'important' flag on NNTP server.");
6238 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6239 redraw = REDRAW_STATUS | REDRAW_INDEX;
6240 if (option (OPTRESOLVE))
6241 @@ -2498,6 +2530,60 @@ search_next:
6242 redraw = REDRAW_FULL;
6247 + CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6249 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6250 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6251 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6253 + ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6254 + redraw = REDRAW_FULL;
6257 + case OP_FORWARD_TO_GROUP:
6258 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6260 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6261 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6262 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6264 + if (IsMsgAttach (extra))
6265 + mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6266 + extra->idxlen, extra->bdy, SENDNEWS);
6268 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6269 + redraw = REDRAW_FULL;
6273 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6276 + if (IsMsgAttach (extra))
6277 + followup_to = extra->bdy->hdr->env->followup_to;
6279 + followup_to = extra->hdr->env->followup_to;
6281 + if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6282 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6284 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6285 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6286 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6288 + if (IsMsgAttach (extra))
6289 + mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6290 + extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6292 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6293 + extra->ctx, extra->hdr);
6294 + redraw = REDRAW_FULL;
6300 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6302 @@ -2544,7 +2630,7 @@ search_next:
6304 if (IsMsgAttach (extra))
6305 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6306 - extra->idxlen, extra->bdy);
6307 + extra->idxlen, extra->bdy, 0);
6309 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6310 redraw = REDRAW_FULL;
6311 diff -udprP mutt-1.5.20.orig/parse.c mutt-1.5.20/parse.c
6312 --- mutt-1.5.20.orig/parse.c 2009-06-01 19:29:32.000000000 +0300
6313 +++ mutt-1.5.20/parse.c 2009-06-15 21:05:24.000000000 +0300
6314 @@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
6318 -static LIST *mutt_parse_references (char *s, int in_reply_to)
6319 +LIST *mutt_parse_references (char *s, int in_reply_to)
6321 LIST *t, *lst = NULL;
6323 @@ -1067,6 +1067,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6324 e->from = rfc822_parse_adrlist (e->from, p);
6328 + else if (!mutt_strcasecmp (line+1, "ollowup-to"))
6330 + if (!e->followup_to)
6332 + mutt_remove_trailing_ws (p);
6333 + e->followup_to = safe_strdup (mutt_skip_whitespace (p));
6341 @@ -1149,6 +1160,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6347 + if (!mutt_strcasecmp (line + 1, "ewsgroups"))
6349 + FREE (&e->newsgroups);
6350 + mutt_remove_trailing_ws (p);
6351 + e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
6358 + /* field `Organization:' saves only for pager! */
6359 + if (!mutt_strcasecmp (line + 1, "rganization"))
6361 + if (!e->organization && mutt_strcasecmp (p, "unknown"))
6362 + e->organization = safe_strdup (p);
6367 if (!ascii_strcasecmp (line + 1, "eferences"))
6369 @@ -1257,6 +1289,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6370 e->x_label = safe_strdup(p);
6374 + else if (!mutt_strcasecmp (line + 1, "-comment-to"))
6376 + if (!e->x_comment_to)
6377 + e->x_comment_to = safe_strdup (p);
6380 + else if (!mutt_strcasecmp (line + 1, "ref"))
6383 + e->xref = safe_strdup (p);
6390 diff -udprP mutt-1.5.20.orig/pattern.c mutt-1.5.20/pattern.c
6391 --- mutt-1.5.20.orig/pattern.c 2009-06-03 23:48:31.000000000 +0300
6392 +++ mutt-1.5.20/pattern.c 2009-06-15 21:05:24.000000000 +0300
6393 @@ -91,6 +91,9 @@ Flags[] =
6394 { 'U', M_UNREAD, 0, NULL },
6395 { 'v', M_COLLAPSED, 0, NULL },
6396 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6398 + { 'w', M_NEWSGROUPS, 0, eat_regexp },
6400 { 'x', M_REFERENCE, 0, eat_regexp },
6401 { 'X', M_MIMEATTACH, 0, eat_range },
6402 { 'y', M_XLABEL, 0, eat_regexp },
6403 @@ -1204,6 +1207,10 @@ mutt_pattern_exec (struct pattern_t *pat
6405 case M_UNREFERENCED:
6406 return (pat->not ^ (h->thread && !h->thread->child));
6408 + case M_NEWSGROUPS:
6409 + return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6412 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6414 @@ -1285,6 +1292,7 @@ int mutt_pattern_func (int op, char *pro
6415 progress_t progress;
6417 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6418 + if (prompt || op != M_LIMIT)
6419 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6422 diff -udprP mutt-1.5.20.orig/po/POTFILES.in mutt-1.5.20/po/POTFILES.in
6423 --- mutt-1.5.20.orig/po/POTFILES.in 2008-11-11 21:55:47.000000000 +0200
6424 +++ mutt-1.5.20/po/POTFILES.in 2009-06-15 21:05:24.000000000 +0300
6425 @@ -46,6 +46,8 @@ mutt_ssl_gnutls.c
6434 diff -udprP mutt-1.5.20.orig/postpone.c mutt-1.5.20/postpone.c
6435 --- mutt-1.5.20.orig/postpone.c 2009-06-14 00:28:37.000000000 +0300
6436 +++ mutt-1.5.20/postpone.c 2009-06-15 21:05:24.000000000 +0300
6437 @@ -124,15 +124,26 @@ int mutt_num_postponed (int force)
6439 if (LastModify < st.st_mtime)
6442 + int optnews = option (OPTNEWS);
6444 LastModify = st.st_mtime;
6446 if (access (Postponed, R_OK | F_OK) != 0)
6447 return (PostCount = 0);
6450 + unset_option (OPTNEWS);
6452 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6455 PostCount = ctx.msgcount;
6456 mx_fastclose_mailbox (&ctx);
6459 + set_option (OPTNEWS);
6464 diff -udprP mutt-1.5.20.orig/protos.h mutt-1.5.20/protos.h
6465 --- mutt-1.5.20.orig/protos.h 2009-06-13 02:38:52.000000000 +0300
6466 +++ mutt-1.5.20/protos.h 2009-06-15 21:05:24.000000000 +0300
6467 @@ -115,6 +115,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
6468 HASH *mutt_make_subj_hash (CONTEXT *);
6470 LIST *mutt_make_references(ENVELOPE *e);
6471 +LIST *mutt_parse_references (char *, int);
6473 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6474 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
6475 diff -udprP mutt-1.5.20.orig/recvattach.c mutt-1.5.20/recvattach.c
6476 --- mutt-1.5.20.orig/recvattach.c 2009-05-19 03:11:35.000000000 +0300
6477 +++ mutt-1.5.20/recvattach.c 2009-06-15 21:05:24.000000000 +0300
6478 @@ -1110,6 +1110,15 @@ void mutt_view_attachments (HEADER *hdr)
6483 + if (Context->magic == M_NNTP)
6486 + mutt_error _("Can't delete attachment from newsserver.");
6491 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6494 @@ -1201,10 +1210,33 @@ void mutt_view_attachments (HEADER *hdr)
6495 case OP_FORWARD_MESSAGE:
6497 mutt_attach_forward (fp, hdr, idx, idxlen,
6498 - menu->tagprefix ? NULL : idx[menu->current]->content);
6499 + menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6500 menu->redraw = REDRAW_FULL;
6504 + case OP_FORWARD_TO_GROUP:
6506 + mutt_attach_forward (fp, hdr, idx, idxlen,
6507 + menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6508 + menu->redraw = REDRAW_FULL;
6514 + if (!idx[menu->current]->content->hdr->env->followup_to ||
6515 + mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6516 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6518 + mutt_attach_reply (fp, hdr, idx, idxlen,
6519 + menu->tagprefix ? NULL : idx[menu->current]->content,
6520 + SENDNEWS|SENDREPLY);
6521 + menu->redraw = REDRAW_FULL;
6527 case OP_GROUP_REPLY:
6529 diff -udprP mutt-1.5.20.orig/recvcmd.c mutt-1.5.20/recvcmd.c
6530 --- mutt-1.5.20.orig/recvcmd.c 2009-06-12 20:24:17.000000000 +0300
6531 +++ mutt-1.5.20/recvcmd.c 2009-06-15 21:05:24.000000000 +0300
6532 @@ -401,7 +401,7 @@ static BODY ** copy_problematic_attachme
6533 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6534 ATTACHPTR ** idx, short idxlen,
6537 + short nattach, int flags)
6540 short mime_fwd_all = 0;
6541 @@ -547,7 +547,7 @@ _("Can't decode all tagged attachments.
6544 /* now that we have the template, send it. */
6545 - ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6546 + ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6550 @@ -574,7 +574,7 @@ _("Can't decode all tagged attachments.
6553 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6554 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6555 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6557 HEADER *curhdr = NULL;
6559 @@ -679,23 +679,23 @@ static void attach_forward_msgs (FILE *
6561 mutt_free_header (&tmphdr);
6563 - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6564 + ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
6569 void mutt_attach_forward (FILE * fp, HEADER * hdr,
6570 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6571 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6576 if (check_all_msg (idx, idxlen, cur, 0) == 0)
6577 - attach_forward_msgs (fp, hdr, idx, idxlen, cur);
6578 + attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
6581 nattach = count_tagged (idx, idxlen);
6582 - attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
6583 + attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
6587 @@ -753,28 +753,40 @@ attach_reply_envelope_defaults (ENVELOPE
6593 + if ((flags & SENDNEWS))
6595 - if (mutt_fetch_recips (env, curenv, flags) == -1)
6597 + /* in case followup set Newsgroups: with Followup-To: if it present */
6598 + if (!env->newsgroups && curenv &&
6599 + mutt_strcasecmp (curenv->followup_to, "poster"))
6600 + env->newsgroups = safe_strdup (curenv->followup_to);
6605 - for (i = 0; i < idxlen; i++)
6608 - if (idx[i]->content->tagged
6609 - && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6610 + if (mutt_fetch_recips (env, curenv, flags) == -1)
6615 + for (i = 0; i < idxlen; i++)
6617 + if (idx[i]->content->tagged
6618 + && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6623 + if ((flags & SENDLISTREPLY) && !env->to)
6625 + mutt_error _("No mailing lists found!");
6629 + mutt_fix_reply_recipients (env);
6632 - if ((flags & SENDLISTREPLY) && !env->to)
6634 - mutt_error _("No mailing lists found!");
6638 - mutt_fix_reply_recipients (env);
6639 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
6642 @@ -835,6 +847,13 @@ void mutt_attach_reply (FILE * fp, HEADE
6643 char prefix[SHORT_STRING];
6647 + if (flags & SENDNEWS)
6648 + set_option (OPTNEWSSEND);
6650 + unset_option (OPTNEWSSEND);
6653 if (check_all_msg (idx, idxlen, cur, 0) == -1)
6655 nattach = count_tagged (idx, idxlen);
6656 diff -udprP mutt-1.5.20.orig/rfc1524.c mutt-1.5.20/rfc1524.c
6657 --- mutt-1.5.20.orig/rfc1524.c 2009-05-30 20:20:08.000000000 +0300
6658 +++ mutt-1.5.20/rfc1524.c 2009-06-15 21:05:24.000000000 +0300
6659 @@ -569,13 +569,13 @@ int rfc1524_expand_filename (char *namet
6663 -int mutt_rename_file (char *oldfile, char *newfile)
6664 +int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
6668 if (access (oldfile, F_OK) != 0)
6670 - if (access (newfile, F_OK) == 0)
6671 + if (!overwrite && access (newfile, F_OK) == 0)
6673 if ((ofp = fopen (oldfile,"r")) == NULL)
6675 @@ -590,3 +590,8 @@ int mutt_rename_file (char *oldfile, cha
6676 mutt_unlink (oldfile);
6680 +int mutt_rename_file (char *oldfile, char *newfile)
6682 + return _mutt_rename_file (oldfile, newfile, 0);
6684 diff -udprP mutt-1.5.20.orig/rfc1524.h mutt-1.5.20/rfc1524.h
6685 --- mutt-1.5.20.orig/rfc1524.h 2008-11-11 21:55:47.000000000 +0200
6686 +++ mutt-1.5.20/rfc1524.h 2009-06-15 21:05:24.000000000 +0300
6687 @@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char
6688 int rfc1524_expand_filename (char *, char *, char *, size_t);
6689 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
6690 int mutt_rename_file (char *, char *);
6691 +int _mutt_rename_file (char *, char *, int);
6693 #endif /* _RFC1524_H */
6694 diff -udprP mutt-1.5.20.orig/send.c mutt-1.5.20/send.c
6695 --- mutt-1.5.20.orig/send.c 2009-06-13 02:38:52.000000000 +0300
6696 +++ mutt-1.5.20/send.c 2009-06-15 21:13:13.000000000 +0300
6698 #include <sys/types.h>
6707 #include "remailer.h"
6709 @@ -213,17 +218,51 @@ static int edit_address (ADDRESS **a, /*
6713 -static int edit_envelope (ENVELOPE *en)
6714 +static int edit_envelope (ENVELOPE *en, int flags)
6716 char buf[HUGE_STRING];
6717 LIST *uh = UserHeader;
6719 - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6721 - if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6723 - if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6726 + if (option (OPTNEWSSEND))
6728 + if (en->newsgroups)
6729 + strfcpy (buf, en->newsgroups, sizeof (buf));
6732 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
6734 + FREE (&en->newsgroups);
6735 + en->newsgroups = safe_strdup (buf);
6737 + if (en->followup_to)
6738 + strfcpy (buf, en->followup_to, sizeof (buf));
6741 + if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
6743 + FREE (&en->followup_to);
6744 + en->followup_to = safe_strdup (buf);
6746 + if (en->x_comment_to)
6747 + strfcpy (buf, en->x_comment_to, sizeof (buf));
6750 + if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
6752 + FREE (&en->x_comment_to);
6753 + en->x_comment_to = safe_strdup (buf);
6758 + if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6760 + if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6762 + if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6768 @@ -259,6 +298,14 @@ static int edit_envelope (ENVELOPE *en)
6773 +char *nntp_get_header (const char *s)
6776 + return safe_strdup (s);
6780 static void process_user_recips (ENVELOPE *env)
6782 LIST *uh = UserHeader;
6783 @@ -271,6 +318,14 @@ static void process_user_recips (ENVELOP
6784 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
6785 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
6786 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
6788 + else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
6789 + env->newsgroups = nntp_get_header (uh->data + 11);
6790 + else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
6791 + env->followup_to = nntp_get_header (uh->data + 12);
6792 + else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
6793 + env->x_comment_to = nntp_get_header (uh->data + 13);
6798 @@ -309,6 +364,12 @@ static void process_user_header (ENVELOP
6799 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
6800 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
6801 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
6803 + ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
6804 + ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
6805 + ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
6807 + ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
6808 ascii_strncasecmp ("subject:", uh->data, 8) != 0 &&
6809 ascii_strncasecmp ("return-path:", uh->data, 12) != 0)
6811 @@ -657,6 +718,10 @@ void mutt_add_to_reference_headers (ENVE
6816 + if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
6817 + env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
6822 @@ -719,6 +784,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
6824 if (flags & SENDREPLY)
6827 + if ((flags & SENDNEWS))
6829 + /* in case followup set Newsgroups: with Followup-To: if it present */
6830 + if (!env->newsgroups && curenv &&
6831 + mutt_strcasecmp (curenv->followup_to, "poster"))
6832 + env->newsgroups = safe_strdup (curenv->followup_to);
6839 @@ -865,7 +940,18 @@ void mutt_set_followup_to (ENVELOPE *e)
6840 * it hasn't already been set
6843 - if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
6844 + if (!option (OPTFOLLOWUPTO))
6847 + if (option (OPTNEWSSEND))
6849 + if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
6850 + e->followup_to = safe_strdup (e->newsgroups);
6855 + if (!e->mail_followup_to)
6857 if (mutt_is_list_cc (0, e->to, e->cc))
6859 @@ -1026,6 +1112,9 @@ static int send_message (HEADER *msg)
6864 + if (!option (OPTNEWSSEND))
6865 +#endif /* USE_NNTP */
6867 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
6868 msg->env->bcc, tempfile,
6869 @@ -1137,6 +1226,13 @@ ci_send_message (int flags, /* send mod
6874 + if (flags & SENDNEWS)
6875 + set_option (OPTNEWSSEND);
6877 + unset_option (OPTNEWSSEND);
6880 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
6881 mutt_num_postponed (1))
6883 @@ -1167,6 +1263,22 @@ ci_send_message (int flags, /* send mod
6885 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
6889 + * If postponed message is a news article, it have
6890 + * a "Newsgroups:" header line, then set appropriate flag.
6892 + if (msg->env->newsgroups)
6894 + flags |= SENDNEWS;
6895 + set_option (OPTNEWSSEND);
6899 + flags &= ~SENDNEWS;
6900 + unset_option (OPTNEWSSEND);
6905 if (flags & (SENDPOSTPONED|SENDRESEND))
6906 @@ -1278,11 +1390,16 @@ ci_send_message (int flags, /* send mod
6907 if (flags & SENDREPLY)
6908 mutt_fix_reply_recipients (msg->env);
6911 + if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
6912 + msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
6915 if (! (flags & SENDMAILX) &&
6916 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
6917 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
6919 - if (edit_envelope (msg->env) == -1)
6920 + if (edit_envelope (msg->env, flags) == -1)
6924 @@ -1539,6 +1656,11 @@ main_loop:
6929 + if (flags & SENDNEWS)
6930 + mutt_message _("Article not posted.");
6933 mutt_message _("Mail not sent.");
6936 @@ -1571,6 +1693,9 @@ main_loop:
6941 + if (!(flags & SENDNEWS))
6943 if (!has_recips (msg->env->to) && !has_recips (msg->env->cc) &&
6944 !has_recips (msg->env->bcc))
6946 @@ -1604,6 +1729,19 @@ main_loop:
6947 mutt_error _("No subject specified.");
6951 + if ((flags & SENDNEWS) && !msg->env->subject)
6953 + mutt_error _("No subject specified.");
6957 + if ((flags & SENDNEWS) && !msg->env->newsgroups)
6959 + mutt_error _("No newsgroup specified.");
6964 if (msg->content->next)
6965 msg->content = mutt_make_multipart (msg->content);
6966 @@ -1810,7 +1948,12 @@ full_fcc:
6969 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
6970 - mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
6971 + mutt_message (i != 0 ? _("Sending in background.") :
6973 + (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
6978 if (WithCrypto && (msg->security & ENCRYPT))
6980 diff -udprP mutt-1.5.20.orig/sendlib.c mutt-1.5.20/sendlib.c
6981 --- mutt-1.5.20.orig/sendlib.c 2009-06-14 18:46:11.000000000 +0300
6982 +++ mutt-1.5.20/sendlib.c 2009-06-15 21:51:17.000000000 +0300
6984 #include <sys/wait.h>
6991 #ifdef HAVE_SYSEXITS_H
6992 #include <sysexits.h>
6993 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
6994 @@ -1868,6 +1872,9 @@ int mutt_write_rfc822_header (FILE *fp,
6995 mutt_write_address_list (env->to, fp, 4, 0);
6999 + if (!option (OPTNEWSSEND))
7001 fputs ("To: \n", fp);
7004 @@ -1876,6 +1883,9 @@ int mutt_write_rfc822_header (FILE *fp,
7005 mutt_write_address_list (env->cc, fp, 4, 0);
7009 + if (!option (OPTNEWSSEND))
7011 fputs ("Cc: \n", fp);
7014 @@ -1887,8 +1897,28 @@ int mutt_write_rfc822_header (FILE *fp,
7019 + if (!option (OPTNEWSSEND))
7021 fputs ("Bcc: \n", fp);
7024 + if (env->newsgroups)
7025 + fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
7026 + else if (mode == 1 && option (OPTNEWSSEND))
7027 + fputs ("Newsgroups: \n", fp);
7029 + if (env->followup_to)
7030 + fprintf (fp, "Followup-To: %s\n", env->followup_to);
7031 + else if (mode == 1 && option (OPTNEWSSEND))
7032 + fputs ("Followup-To: \n", fp);
7034 + if (env->x_comment_to)
7035 + fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
7036 + else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
7037 + fputs ("X-Comment-To: \n", fp);
7041 mutt_write_one_header (fp, "Subject", env->subject, NULL, 0, 0);
7043 @@ -1907,6 +1937,9 @@ int mutt_write_rfc822_header (FILE *fp,
7044 fputs ("Reply-To: \n", fp);
7046 if (env->mail_followup_to)
7048 + if (!option (OPTNEWSSEND))
7051 fputs ("Mail-Followup-To: ", fp);
7052 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
7053 @@ -2245,11 +2278,30 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7054 const char *msg, /* file containing message */
7055 int eightbit) /* message contains 8bit chars */
7057 - char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
7058 + char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
7060 size_t argslen = 0, argsmax = 0;
7064 + if (option (OPTNEWSSEND))
7066 + char cmd[LONG_STRING];
7068 + mutt_FormatString (cmd, sizeof (cmd), 0, NONULL (Inews), nntp_format_str, 0, 0);
7071 + i = nntp_post (msg);
7076 + s = safe_strdup (cmd);
7080 + s = safe_strdup (Sendmail);
7084 while ((ps = strtok (ps, " ")))
7085 @@ -2273,6 +2325,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7090 + if (!option (OPTNEWSSEND))
7093 if (eightbit && option (OPTUSE8BITMIME))
7094 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7096 @@ -2304,6 +2360,9 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7097 args = add_args (args, &argslen, &argsmax, to);
7098 args = add_args (args, &argslen, &argsmax, cc);
7099 args = add_args (args, &argslen, &argsmax, bcc);
7104 if (argslen == argsmax)
7105 safe_realloc (&args, sizeof (char *) * (++argsmax));
7106 @@ -2384,6 +2443,9 @@ void mutt_prepare_envelope (ENVELOPE *en
7107 rfc2047_encode_string (&env->x_label);
7111 + if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
7114 rfc2047_encode_string (&env->subject);
7116 @@ -2504,6 +2566,10 @@ int mutt_bounce_message (FILE *fp, HEADE
7118 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
7121 + unset_option (OPTNEWSSEND);
7124 ret = _mutt_bounce_message (fp, h, to, resent_from, from);
7126 rfc822_free_address (&from);
7127 diff -udprP mutt-1.5.20.orig/sort.c mutt-1.5.20/sort.c
7128 --- mutt-1.5.20.orig/sort.c 2008-11-11 21:55:47.000000000 +0200
7129 +++ mutt-1.5.20/sort.c 2009-06-15 21:05:24.000000000 +0300
7130 @@ -151,6 +151,15 @@ static int compare_order (const void *a,
7131 HEADER **ha = (HEADER **) a;
7132 HEADER **hb = (HEADER **) b;
7135 + if ((*ha)->article_num && (*hb)->article_num)
7137 + int result = (*ha)->article_num - (*hb)->article_num;
7138 + AUXSORT(result,a,b);
7139 + return (SORTCODE (result));
7143 /* no need to auxsort because you will never have equality here */
7144 return (SORTCODE ((*ha)->index - (*hb)->index));
7146 diff -udprP mutt-1.5.20.orig/url.c mutt-1.5.20/url.c
7147 --- mutt-1.5.20.orig/url.c 2009-06-01 19:29:32.000000000 +0300
7148 +++ mutt-1.5.20/url.c 2009-06-15 21:05:24.000000000 +0300
7149 @@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] =
7150 { "imaps", U_IMAPS },
7153 + { "news", U_NNTP },
7154 + { "newss", U_NNTPS },
7155 { "mailto", U_MAILTO },
7157 { "smtps", U_SMTPS },
7158 diff -udprP mutt-1.5.20.orig/url.h mutt-1.5.20/url.h
7159 --- mutt-1.5.20.orig/url.h 2008-11-11 21:55:47.000000000 +0200
7160 +++ mutt-1.5.20/url.h 2009-06-15 21:05:24.000000000 +0300
7161 @@ -8,6 +8,8 @@ typedef enum url_scheme
7170 diff -udprP mutt-1.5.20.orig/Makefile.am mutt-1.5.20/Makefile.am
7171 --- mutt-1.5.20.orig/Makefile.am 2009-01-05 04:11:29.000000000 +0200
7172 +++ mutt-1.5.20/Makefile.am 2009-06-15 21:05:24.000000000 +0300
7173 @@ -53,6 +53,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
7174 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
7175 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
7176 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
7178 smime.c smtp.c utf8.c wcwidth.c \
7179 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
7181 @@ -64,6 +65,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7182 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7183 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7184 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7185 + nntp.h ChangeLog.nntp \
7186 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7187 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
7188 README.SSL smime.h \
7189 diff -udprP mutt-1.5.20.orig/Makefile.in mutt-1.5.20/Makefile.in
7190 --- mutt-1.5.20.orig/Makefile.in 2009-06-09 09:50:44.000000000 +0300
7191 +++ mutt-1.5.20/Makefile.in 2009-06-15 21:05:24.000000000 +0300
7192 @@ -372,6 +372,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
7193 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
7194 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
7195 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
7197 smime.c smtp.c utf8.c wcwidth.c \
7198 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
7200 @@ -383,6 +384,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7201 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7202 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7203 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7204 + nntp.h ChangeLog.nntp \
7205 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7206 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
7207 README.SSL smime.h \
7208 @@ -637,6 +639,8 @@ distclean-compile:
7209 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@
7210 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@
7211 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@
7212 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@
7213 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@
7214 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@
7215 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
7216 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@
7217 diff -udprP mutt-1.5.20.orig/configure mutt-1.5.20/configure
7218 --- mutt-1.5.20.orig/configure 2009-06-09 09:50:42.000000000 +0300
7219 +++ mutt-1.5.20/configure 2009-06-15 21:05:24.000000000 +0300
7220 @@ -1478,6 +1478,7 @@ Optional Features:
7221 Force use of an external dotlock program
7222 --enable-pop Enable POP3 support
7223 --enable-imap Enable IMAP support
7224 + --enable-nntp Enable NNTP support
7225 --enable-smtp include internal SMTP relay support
7226 --enable-debug Enable debugging support
7227 --enable-flock Use flock() to lock files
7228 @@ -14198,6 +14199,20 @@ fi
7232 +# Check whether --enable-nntp or --disable-nntp was given.
7233 +if test "${enable_nntp+set}" = set; then
7234 + enableval="$enable_nntp"
7235 + if test x$enableval = xyes ; then
7236 + cat >>confdefs.h <<\_ACEOF
7240 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
7248 for ac_func in strftime
7249 diff -udprP mutt-1.5.20.orig/doc/Muttrc mutt-1.5.20/doc/Muttrc
7250 --- mutt-1.5.20.orig/doc/Muttrc 2009-06-14 21:53:24.000000000 +0300
7251 +++ mutt-1.5.20/doc/Muttrc 2009-06-15 21:05:24.000000000 +0300
7252 @@ -281,6 +281,28 @@ attachments -I message/external-body
7253 # of the value as shown above if included.
7256 +# set ask_follow_up=no
7258 +# Name: ask_follow_up
7263 +# If set, Mutt will prompt you for follow-up groups before editing
7264 +# the body of an outgoing message.
7267 +# set ask_x_comment_to=no
7269 +# Name: ask_x_comment_to
7274 +# If set, Mutt will prompt you for x-comment-to field before editing
7275 +# the body of an outgoing message.
7278 # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
7280 # Name: attach_format
7281 @@ -466,6 +488,17 @@ attachments -I message/external-body
7282 # set certificate_file=~/.mutt/certificates
7285 +# set catchup_newsgroup=ask-yes
7287 +# Name: catchup_newsgroup
7292 +# If this variable is set, Mutt will mark all articles in newsgroup
7293 +# as read when you quit the newsgroup (catchup newsgroup).
7299 @@ -1121,6 +1154,19 @@ attachments -I message/external-body
7300 # of the same email for you.
7303 +# set followup_to_poster=ask-yes
7305 +# Name: followup_to_poster
7310 +# If this variable is set and the keyword "poster" is present in
7311 +# Followup-To header, follow-up to newsgroup function is not
7312 +# permitted. The message will be mailed to the submitter of the
7313 +# message via mail.
7319 @@ -1231,6 +1277,28 @@ attachments -I message/external-body
7320 # ``Franklin'' to ``Franklin, Steve''.
7323 +# set group_index_format="%4C %M%N %5s %-45.45f %d"
7325 +# Name: group_index_format
7327 +# Default: "%4C %M%N %5s %-45.45f %d"
7330 +# This variable allows you to customize the newsgroup browser display to
7331 +# your personal taste. This string is similar to ``index_format'', but
7332 +# has its own set of printf()-like sequences:
7334 +# %C current newsgroup number
7335 +# %d description of newsgroup (becomes from server)
7336 +# %f newsgroup name
7337 +# %M - if newsgroup not allowed for direct post (moderated for example)
7338 +# %N N if newsgroup is new, u if unsubscribed, blank otherwise
7339 +# %n number of new articles in newsgroup
7340 +# %s number of unread articles in newsgroup
7341 +# %>X right justify the rest of the string and pad with character "X"
7342 +# %|X pad to the end of the line with character "X"
7348 @@ -1779,6 +1847,7 @@ attachments -I message/external-body
7349 # %E number of messages in current thread
7350 # %f sender (address + real name), either From: or Return-Path:
7351 # %F author name, or recipient name if the message is from you
7352 +# %g newsgroup name (if compiled with nntp support)
7353 # %H spam attribute(s) of this message
7354 # %i message-id of the current message
7355 # %l number of lines in the message (does not work with maildir,
7356 @@ -1794,12 +1863,14 @@ attachments -I message/external-body
7357 # stashed the message: list name or recipient name
7358 # if not sent to a list
7359 # %P progress indicator for the builtin pager (how much of the file has been displayed)
7360 +# %R `x-comment-to:' field (if present and compiled with nntp support)
7361 # %s subject of the message
7362 # %S status of the message (``N''/``D''/``d''/``!''/``r''/*)
7363 # %t ``To:'' field (recipients)
7364 # %T the appropriate character from the $to_chars string
7365 # %u user (login) name of the author
7366 # %v first name of the author, or the recipient if the message is from you
7367 +# %W name of organization of author (`organization:' field)
7368 # %X number of attachments
7369 # (please see the ``attachments'' section for possible speed effects)
7370 # %y ``X-Label:'' field, if present
7371 @@ -1835,6 +1906,22 @@ attachments -I message/external-body
7372 # ``save-hook'', ``fcc-hook'' and ``fcc-save-hook'', too.
7382 +# If set, specifies the program and arguments used to deliver news posted
7383 +# by Mutt. Otherwise, mutt posts article using current connection to
7384 +# news server. The following printf-style sequence is understood:
7386 +# %s newsserver name
7388 +# Example: set inews="/usr/local/bin/inews -hS"
7391 # set ispell="ispell"
7394 @@ -2188,6 +2275,18 @@ attachments -I message/external-body
7395 # be attached to the newly composed message if this option is set.
7398 +# set mime_subject=yes
7400 +# Name: mime_subject
7405 +# If unset, 8-bit ``subject:'' line in article header will not be
7406 +# encoded according to RFC2047 to base64. This is useful when message
7407 +# is Usenet article, because MIME for news is nonstandard feature.
7410 # set mix_entry_format="%4n %c %-16s %a"
7412 # Name: mix_entry_format
7413 @@ -2254,6 +2353,118 @@ attachments -I message/external-body
7414 # See also $read_inc, $write_inc and $net_inc.
7417 +# set news_cache_dir="~/.mutt"
7419 +# Name: news_cache_dir
7421 +# Default: "~/.mutt"
7424 +# This variable pointing to directory where Mutt will save cached news
7425 +# articles headers in. If unset, headers will not be saved at all
7426 +# and will be reloaded each time when you enter to newsgroup.
7429 +# set news_server=""
7431 +# Name: news_server
7436 +# This variable specifies domain name or address of NNTP server. It
7437 +# defaults to the newsserver specified in the environment variable
7438 +# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
7439 +# specify username and an alternative port for each newsserver, ie:
7441 +# [news[s]://][username[:password]@]newsserver[:port]
7444 +# set newsrc="~/.newsrc"
7448 +# Default: "~/.newsrc"
7451 +# The file, containing info about subscribed newsgroups - names and
7452 +# indexes of read articles. The following printf-style sequence
7455 +# %s newsserver name
7458 +# set nntp_context=1000
7460 +# Name: nntp_context
7465 +# This variable defines number of articles which will be in index when
7466 +# newsgroup entered. If active newsgroup have more articles than this
7467 +# number, oldest articles will be ignored. Also controls how many
7468 +# articles headers will be saved in cache when you quit newsgroup.
7471 +# set nntp_load_description=yes
7473 +# Name: nntp_load_description
7478 +# This variable controls whether or not descriptions for each newsgroup
7479 +# must be loaded when newsgroup is added to list (first time list
7480 +# loading or new newsgroup adding).
7490 +# Your login name on the NNTP server. If unset and NNTP server requires
7491 +# authentification, Mutt will prompt you for your account name when you
7492 +# connect to newsserver.
7502 +# Your password for NNTP account.
7512 +# The time in seconds until any operations on newsgroup except post new
7513 +# article will cause recheck for new news. If set to 0, Mutt will
7514 +# recheck newsgroup on each operation in index (stepping, read article,
7518 +# set nntp_reconnect=ask-yes
7520 +# Name: nntp_reconnect
7525 +# Controls whether or not Mutt will try to reconnect to newsserver when
7529 # set pager="builtin"
7532 @@ -2969,6 +3180,19 @@ attachments -I message/external-body
7533 # string after the inclusion of a message which is being replied to.
7536 +# set post_moderated=ask-yes
7538 +# Name: post_moderated
7543 +# If set to yes, Mutt will post article to newsgroup that have
7544 +# not permissions to posting (e.g. moderated). Note: if newsserver
7545 +# does not support posting to that newsgroup or totally read-only, that
7546 +# posting will not have an effect.
7549 # set postpone=ask-yes
7552 @@ -3543,6 +3767,41 @@ attachments -I message/external-body
7553 # shell from /etc/passwd is used.
7556 +# set save_unsubscribed=no
7558 +# Name: save_unsubscribed
7563 +# When set, info about unsubscribed newsgroups will be saved into
7564 +# ``newsrc'' file and into cache.
7567 +# set show_new_news=yes
7569 +# Name: show_new_news
7574 +# If set, newsserver will be asked for new newsgroups on entering
7575 +# the browser. Otherwise, it will be done only once for a newsserver.
7576 +# Also controls whether or not number of new articles of subscribed
7577 +# newsgroups will be then checked.
7580 +# set show_only_unread=no
7582 +# Name: show_only_unread
7587 +# If set, only subscribed newsgroups that contain unread articles
7588 +# will be displayed in browser.
7591 # set sig_dashes=yes
7594 @@ -4748,3 +5007,14 @@ attachments -I message/external-body
7595 # ``tuning'' section of the manual for performance considerations.
7598 +# set x_comment_to=no
7600 +# Name: x_comment_to
7605 +# If set, Mutt will add ``X-Comment-To:'' field (that contains full
7606 +# name of original article author) to article that followuped to newsgroup.