1 WARNING: Run the following script before configure:
9 Vsevolod Volkov <vvv@mutt.org.ua>
12 diff -udprP mutt-1.5.21.orig/ChangeLog.nntp mutt-1.5.21/ChangeLog.nntp
13 --- mutt-1.5.21.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14 +++ mutt-1.5.21/ChangeLog.nntp 2010-09-16 13:14:39.000000000 +0300
16 +* Wed Sep 16 2010 Vsevolod Volkov <vvv@mutt.org.ua>
19 +* Thu Aug 13 2009 Vsevolod Volkov <vvv@mutt.org.ua>
20 +- fixed writting references in nntp_save_cache_group()
22 +* Tue Jun 15 2009 Vsevolod Volkov <vvv@mutt.org.ua>
25 +* Tue Mar 20 2009 Vsevolod Volkov <vvv@mutt.org.ua>
26 +- save Date: header of recorded outgoing articles
28 +* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua>
31 +* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua>
33 +- fixed SIGSEGV when followup or forward to newsgroup
35 +* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua>
38 +* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua>
39 +- fixed arguments of nntp_format_str()
41 +* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua>
42 +- fixed error selecting news group
44 +* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua>
47 +* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
48 +- fixed posting error if $smtp_url is set
49 +- added support of print-style sequence %R (x-comment-to)
51 +* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
53 +- nntp://... url changed to news://...
54 +- added indicator of fetching descriptions progress
56 +* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
59 +* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
62 +* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
64 +- fixed reading empty .newsrc
66 +* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
69 +* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
72 +* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
75 +* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
78 +* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
80 +- function mutt_update_list_file() moved to newsrc.c and changed algorithm
82 +* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
83 +- fixed error in nntp_logout_all()
85 +* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
86 +- fixed debug output in mutt_newsrc_update()
87 +- added optional support of LISTGROUP command
88 +- fixed typo in nntp_parse_xref()
90 +* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
93 +* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
96 +* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
99 +* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
101 +- added space after newsgroup name in .newsrc file
103 +* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
104 +- nntp patch: fixed SIGSEGV when posting article
106 +* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
109 +* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
111 +- replace safe_free calls by the FREE macro
113 +* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
115 +- nntp authentication can be passed after any command
117 +* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
120 +* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
123 +* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
125 +- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
126 + <reconstruct-thread> functions
127 +- fixed message about nntp reconnect
128 +- fixed <attach-news-message> function using browser
129 +- added support of Followup-To: poster
130 +- added %n (new articles) in group_index_format
131 +- posting articles without inews by default
133 +* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
136 +* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
139 +* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
141 +- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
142 +- added default content disposition
144 +* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
147 +* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
148 +- update to 1.3.23.2
149 +- fixed segfault if mutt_conn_find() returns null
151 +* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
152 +- update to 1.3.23.1
153 +- added support of LISTGROUP command
154 +- added support for servers with broken overview
155 +- disabled <flag-message> function on news server
156 +- fixed error storing bad authentication information
158 +* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
160 +- fixed typo in buffy.c
161 +- added substitution of %s parameter in $inews variable
163 +* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
164 +- update to 1.3.22.1
167 +* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
170 +* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
172 +- removed 'server-hook', use 'account-hook' instead
173 +- fixed error opening NNTP server without newsgroup using -f option
175 +* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
178 +* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
180 +- fixed typo in nntp_attempt_features()
181 +- changed algorithm of XGTITLE command testing
182 +- disabled writing of NNTP password in debug file
183 +- fixed reading and writing of long newsrc lines
184 +- changed checking of last line while reading lines from server
185 +- fixed possible buffer overrun in nntp_parse_newsrc_line()
186 +- removed checking of XHDR command
187 +- compare NNTP return codes without trailing space
189 +* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
191 +- support for 'LIST NEWSGROUPS' command to read descriptions
193 +* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
196 +* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
199 +* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
201 +- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
203 +* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
206 +* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
207 +- Fixed problem if last article in group is deleted
209 +* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
210 +- Fixed checking of XGTITLE command on some servers
212 +* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
213 +- Added \r in AUTHINFO commands
215 +* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
218 +* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
220 +- fixed error opening newsgroup from mutt started with -g or -G
222 +* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
224 +- hotkey 'G' (get-message) replaced with '^G'
226 +* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
228 +- changed delay displaying error messages from 1 to 2 seconds
229 +- fixed error compiling with nntp and without imap
231 +* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
232 +- fixed catchup in index
233 +- fixed nntp_open_mailbox()
235 +* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
236 +- functions <edit> and <delete-entry> disabled
237 +- format of news mailbox names changed to url form
238 +- option nntp_attempts removed
239 +- option reconnect_news renamed to nntp_reconnect
240 +- default value of nntp_poll changed from 30 to 60
241 +- error handling improved
243 +* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
245 +- new option show_only_unread
246 +- add newsgroup completion
248 +* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
251 +* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
254 +* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
256 +- authentication code update
257 +- fix for changing to newsgroup from mailbox with read messages
258 +- socket code optimization
260 +* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
263 +* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
264 +- don't substitute current newsgroup with deleted new messages
266 +* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
268 +- fix for substitution of newsgroup after reconnection
269 +- fix for loading newsgroups with very long names
270 +- fix for loading more than 32768 newsgroups
272 +* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
275 +* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
278 +* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
281 +* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
284 +* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
287 +* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
290 +* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
291 +- add substitution of newsgroup with new messages by default
293 +* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
294 +- add attach message from newsgroup
295 +- add one-line help in newsreader mode
296 +- disable 'change-dir' command in newsgroups browser
299 +* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
300 +- get default newsserver name from file /etc/nntpserver
301 +- use case insensitive server names
302 +- add print-style sequence %s to $newsrc
305 +* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
306 +- remove 'X-FTN-Origin' header processing
308 +* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
312 +* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
313 +- fix mutt_select_newsserver()
314 +- remove 'toggle-mode' function
315 +- add 'change-newsgroup' function
317 +* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
320 +* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
321 +- fix error 'bounce' function after 'post'
322 +- add 'forward to newsgroup' function
324 +* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
325 +- 'forward' function works in newsreader mode
326 +- add 'post' and 'followup' functions to pager and attachment menu
327 +- fix active descriptions and allowed flag reload
329 +* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
331 +- remove deleted newsgroups from list
333 +* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
334 +- update .newsrc in browser
336 +* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
337 +- reload .newsrc if externally modified
338 +- fix active cache update
340 +* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
343 +* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
344 +- patch *.update_list_file is not required
345 +- count lines when loading descriptions
346 +- remove cache of unsubscribed newsgroups
348 +* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
349 +- load list of newsgroups from cache faster
351 +* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
354 +* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
355 +- fix unread messages in browser
356 +- fix newsrc_gen_entries()
358 +* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
359 +- fix mutt_newsgroup_stat()
360 +- fix nntp_delete_cache()
361 +- fix nntp_get_status()
362 +- fix check_children()
363 +- fix nntp_fetch_headers()
365 +* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
368 +* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
369 +- fix updating new messages in cache
371 +* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
372 +- change default cache filenames
373 +- fix updating new messages in cache
375 +* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
376 +- fix segmentation fault in news groups browser
378 +* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
381 +* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
384 +* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
385 +- add X-Comment-To editing
386 +- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
387 +- add variables $ask_followup_to and $ask_x_comment_to
389 +* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
391 diff -udprP mutt-1.5.21.orig/OPS mutt-1.5.21/OPS
392 --- mutt-1.5.21.orig/OPS 2010-03-01 19:56:19.000000000 +0200
393 +++ mutt-1.5.21/OPS 2010-09-16 13:14:39.000000000 +0300
394 @@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
395 OP_BROWSER_NEW_FILE "select a new file in this directory"
396 OP_BROWSER_VIEW_FILE "view file"
397 OP_BROWSER_TELL "display the currently selected file's name"
398 -OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
399 -OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
400 +OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
401 +OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
402 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
403 OP_BUFFY_LIST "list mailboxes with new mail"
404 +OP_CATCHUP "mark all articles in newsgroup as read"
405 OP_CHANGE_DIRECTORY "change directories"
406 OP_CHECK_NEW "check mailboxes for new mail"
407 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
408 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
409 +OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message"
410 OP_COMPOSE_EDIT_BCC "edit the BCC list"
411 OP_COMPOSE_EDIT_CC "edit the CC list"
412 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
413 @@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
414 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
415 OP_COMPOSE_EDIT_MESSAGE "edit the message"
416 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
417 +OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
418 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
419 +OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
420 +OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
421 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
422 OP_COMPOSE_EDIT_TO "edit the TO list"
423 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
424 @@ -85,8 +90,13 @@ OP_EXIT "exit this menu"
425 OP_FILTER "filter attachment through a shell command"
426 OP_FIRST_ENTRY "move to the first entry"
427 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
428 +OP_FOLLOWUP "followup to newsgroup"
429 +OP_FORWARD_TO_GROUP "forward to newsgroup"
430 OP_FORWARD_MESSAGE "forward a message with comments"
431 OP_GENERIC_SELECT_ENTRY "select the current entry"
432 +OP_GET_CHILDREN "get all children of the current message"
433 +OP_GET_MESSAGE "get message with Message-Id"
434 +OP_GET_PARENT "get parent of the current message"
435 OP_GROUP_REPLY "reply to all recipients"
436 OP_HALF_DOWN "scroll down 1/2 page"
437 OP_HALF_UP "scroll up 1/2 page"
438 @@ -94,11 +104,14 @@ OP_HELP "this screen"
439 OP_JUMP "jump to an index number"
440 OP_LAST_ENTRY "move to the last entry"
441 OP_LIST_REPLY "reply to specified mailing list"
442 +OP_LOAD_ACTIVE "load active file from NNTP server"
443 OP_MACRO "execute a macro"
444 OP_MAIL "compose a new mail message"
445 OP_MAIN_BREAK_THREAD "break the thread in two"
446 OP_MAIN_CHANGE_FOLDER "open a different folder"
447 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
448 +OP_MAIN_CHANGE_GROUP "open a different newsgroup"
449 +OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
450 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
451 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
452 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
453 @@ -138,6 +151,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
454 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
455 OP_PAGER_TOP "jump to the top of the message"
456 OP_PIPE "pipe message/attachment to a shell command"
457 +OP_POST "post message to newsgroup"
458 OP_PREV_ENTRY "move to the previous entry"
459 OP_PREV_LINE "scroll up one line"
460 OP_PREV_PAGE "move to the previous page"
461 @@ -146,6 +160,7 @@ OP_QUERY "query external program for add
462 OP_QUERY_APPEND "append new query results to current results"
463 OP_QUIT "save changes to mailbox and quit"
464 OP_RECALL_MESSAGE "recall a postponed message"
465 +OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
466 OP_REDRAW "clear and redraw the screen"
467 OP_REFORMAT_WINCH "{internal}"
468 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
469 @@ -160,18 +175,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
470 OP_SHELL_ESCAPE "invoke a command in a subshell"
471 OP_SORT "sort messages"
472 OP_SORT_REVERSE "sort messages in reverse order"
473 +OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
474 OP_TAG "tag the current entry"
475 OP_TAG_PREFIX "apply next function to tagged messages"
476 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
477 OP_TAG_SUBTHREAD "tag the current subthread"
478 OP_TAG_THREAD "tag the current thread"
479 OP_TOGGLE_NEW "toggle a message's 'new' flag"
480 +OP_TOGGLE_READ "toggle view of read messages"
481 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
482 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
483 OP_TOP_PAGE "move to the top of the page"
484 +OP_UNCATCHUP "mark all articles in newsgroup as unread"
485 OP_UNDELETE "undelete the current entry"
486 OP_UNDELETE_THREAD "undelete all messages in thread"
487 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
488 +OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
489 OP_VERSION "show the Mutt version number and date"
490 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
491 OP_VIEW_ATTACHMENTS "show MIME attachments"
492 diff -udprP mutt-1.5.21.orig/PATCHES mutt-1.5.21/PATCHES
493 --- mutt-1.5.21.orig/PATCHES 2008-03-19 22:07:06.000000000 +0200
494 +++ mutt-1.5.21/PATCHES 2010-09-16 13:14:39.000000000 +0300
497 diff -udprP mutt-1.5.21.orig/account.c mutt-1.5.21/account.c
498 --- mutt-1.5.21.orig/account.c 2009-08-25 22:08:52.000000000 +0300
499 +++ mutt-1.5.21/account.c 2010-09-16 13:14:39.000000000 +0300
500 @@ -51,6 +51,11 @@ int mutt_account_match (const ACCOUNT* a
505 + if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
509 if (a1->flags & a2->flags & M_ACCT_USER)
510 return (!strcmp (a1->user, a2->user));
511 if (a1->flags & M_ACCT_USER)
512 @@ -130,6 +135,16 @@ void mutt_account_tourl (ACCOUNT* accoun
517 + if (account->type == M_ACCT_TYPE_NNTP)
519 + if (account->flags & M_ACCT_SSL)
520 + url->scheme = U_NNTPS;
522 + url->scheme = U_NNTP;
526 url->host = account->host;
527 if (account->flags & M_ACCT_PORT)
528 url->port = account->port;
529 @@ -155,6 +170,10 @@ int mutt_account_getuser (ACCOUNT* accou
530 else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
531 strfcpy (account->user, PopUser, sizeof (account->user));
534 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
535 + strfcpy (account->user, NntpUser, sizeof (account->user));
537 else if (option (OPTNOCURSES))
539 /* prompt (defaults to unix username), copy into account->user */
540 @@ -217,6 +236,10 @@ int mutt_account_getpass (ACCOUNT* accou
541 else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass)
542 strfcpy (account->pass, SmtpPass, sizeof (account->pass));
545 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
546 + strfcpy (account->pass, NntpPass, sizeof (account->pass));
548 else if (option (OPTNOCURSES))
551 diff -udprP mutt-1.5.21.orig/account.h mutt-1.5.21/account.h
552 --- mutt-1.5.21.orig/account.h 2008-03-19 22:07:06.000000000 +0200
553 +++ mutt-1.5.21/account.h 2010-09-16 13:14:39.000000000 +0300
554 @@ -29,7 +29,8 @@ enum
555 M_ACCT_TYPE_NONE = 0,
564 diff -udprP mutt-1.5.21.orig/attach.h mutt-1.5.21/attach.h
565 --- mutt-1.5.21.orig/attach.h 2008-03-19 22:07:06.000000000 +0200
566 +++ mutt-1.5.21/attach.h 2010-09-16 13:14:39.000000000 +0300
567 @@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f
569 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
570 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
571 -void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
572 +void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
573 void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
575 #endif /* _ATTACH_H_ */
576 diff -udprP mutt-1.5.21.orig/browser.c mutt-1.5.21/browser.c
577 --- mutt-1.5.21.orig/browser.c 2010-08-25 19:31:40.000000000 +0300
578 +++ mutt-1.5.21/browser.c 2010-09-16 13:14:39.000000000 +0300
589 @@ -50,6 +53,19 @@ static struct mapping_t FolderHelp[] = {
594 +static struct mapping_t FolderNewsHelp[] = {
595 + { N_("Exit"), OP_EXIT },
596 + { N_("List"), OP_TOGGLE_MAILBOXES },
597 + { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
598 + { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
599 + { N_("Catchup"), OP_CATCHUP },
600 + { N_("Mask"), OP_ENTER_MASK },
601 + { N_("Help"), OP_HELP },
606 typedef struct folder_t
608 struct folder_file *ff;
609 @@ -115,9 +131,17 @@ static void browser_sort (struct browser
614 + if (option (OPTNEWS))
617 f = browser_compare_date;
621 + if (option (OPTNEWS))
624 f = browser_compare_size;
627 @@ -324,8 +348,106 @@ folder_format_str (char *dest, size_t de
633 +newsgroup_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
634 + const char *fmt, const char *ifstring, const char *elsestring,
635 + unsigned long data, format_flag flags)
637 + char fn[SHORT_STRING], tmp[SHORT_STRING];
638 + FOLDER *folder = (FOLDER *) data;
643 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
644 + snprintf (dest, destlen, tmp, folder->num + 1);
648 + strncpy (fn, folder->ff->name, sizeof(fn) - 1);
649 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
650 + snprintf (dest, destlen, tmp, fn);
654 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
655 + if (folder->ff->nd->subscribed)
656 + snprintf (dest, destlen, tmp, ' ');
658 + snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
662 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
663 + if (folder->ff->nd->deleted)
664 + snprintf (dest, destlen, tmp, 'D');
666 + snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
670 + if (flags & M_FORMAT_OPTIONAL)
672 + if (folder->ff->nd->unread != 0)
673 + mutt_FormatString (dest, destlen, col, ifstring, newsgroup_format_str,
676 + mutt_FormatString (dest, destlen, col, elsestring, newsgroup_format_str,
679 + else if (Context && Context->data == folder->ff->nd)
681 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
682 + snprintf (dest, destlen, tmp, Context->unread);
686 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
687 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
692 + if (Context && Context->data == folder->ff->nd)
694 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
695 + snprintf (dest, destlen, tmp, Context->new);
697 + else if (option (OPTMARKOLD) &&
698 + folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
699 + folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
701 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
702 + snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
706 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
707 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
712 + if (folder->ff->nd->desc != NULL)
714 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
715 + snprintf (dest, destlen, tmp, folder->ff->nd->desc);
719 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
720 + snprintf (dest, destlen, tmp, "");
726 +#endif /* USE_NNTP */
728 static void add_folder (MUTTMENU *m, struct browser_state *state,
729 - const char *name, const struct stat *s, int new)
730 + const char *name, const struct stat *s,
731 + void *data, int new)
733 if (state->entrylen == state->entrymax)
735 @@ -354,6 +476,10 @@ static void add_folder (MUTTMENU *m, str
737 (state->entry)[state->entrylen].imap = 0;
740 + if (option (OPTNEWS))
741 + (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
746 @@ -369,9 +495,35 @@ static void init_state (struct browser_s
747 menu->data = state->entry;
750 +/* get list of all files/newsgroups with mask */
751 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
752 char *d, const char *prefix)
755 + if (option (OPTNEWS))
759 + NNTP_SERVER *news = CurrentNewsSrv;
761 +/* mutt_buffy_check (0); */
762 + init_state (state, menu);
764 + for (tmp = news->list; tmp; tmp = tmp->next)
766 + if (!(data = (NNTP_DATA *)tmp->data))
768 + if (prefix && *prefix && strncmp (prefix, data->group,
769 + strlen (prefix)) != 0)
771 + if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
773 + add_folder (menu, state, data->group, NULL, data, data->new);
777 +#endif /* USE_NNTP */
782 @@ -432,17 +584,40 @@ static int examine_directory (MUTTMENU *
784 while (tmp && mutt_strcmp (buffer, tmp->path))
786 - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
787 + add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
792 browser_sort (state);
796 +/* get list of mailboxes/subscribed newsgroups */
797 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
800 char buffer[LONG_STRING];
803 + if (option (OPTNEWS))
807 + NNTP_SERVER *news = CurrentNewsSrv;
809 +/* mutt_buffy_check (0); */
810 + init_state (state, menu);
812 + for (tmp = news->list; tmp; tmp = tmp->next)
814 + if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
815 + (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
816 + add_folder (menu, state, data->group, NULL, data, data->new);
822 BUFFY *tmp = Incoming;
824 struct mailbox_state mbox;
825 @@ -460,14 +635,21 @@ static int examine_mailboxes (MUTTMENU *
826 if (mx_is_imap (tmp->path))
828 imap_mailbox_state (tmp->path, &mbox);
829 - add_folder (menu, state, tmp->path, NULL, mbox.new);
830 + add_folder (menu, state, tmp->path, NULL, NULL, mbox.new);
835 if (mx_is_pop (tmp->path))
837 - add_folder (menu, state, tmp->path, NULL, tmp->new);
838 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
843 + if (mx_is_nntp (tmp->path))
845 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
849 @@ -496,15 +678,20 @@ static int examine_mailboxes (MUTTMENU *
850 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
851 mutt_pretty_mailbox (buffer, sizeof (buffer));
853 - add_folder (menu, state, buffer, &s, tmp->new);
854 + add_folder (menu, state, buffer, &s, NULL, tmp->new);
856 while ((tmp = tmp->next));
858 browser_sort (state);
862 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
865 + if (option (OPTNEWS))
866 + return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
868 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
871 @@ -515,6 +702,12 @@ static void folder_entry (char *s, size_
872 folder.ff = &((struct folder_file *) menu->data)[num];
876 + if (option (OPTNEWS))
877 + mutt_FormatString (s, slen, 0, NONULL(GroupFormat), newsgroup_format_str,
878 + (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
881 mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str,
882 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
884 @@ -535,6 +728,17 @@ static void init_menu (struct browser_st
889 + if (option (OPTNEWS))
892 + snprintf (title, titlelen, _("Subscribed newsgroups"));
894 + snprintf (title, titlelen, _("Newsgroups on server [%s]"),
895 + CurrentNewsSrv->conn->account.host);
900 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
902 @@ -590,6 +794,31 @@ void _mutt_select_file (char *f, size_t
904 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
907 + if (option (OPTNEWS))
910 + strfcpy (prefix, f, sizeof (prefix));
915 + /* default state for news reader mode is browse subscribed newsgroups */
917 + for (list = CurrentNewsSrv->list; list; list = list->next)
919 + NNTP_DATA *data = (NNTP_DATA *) list->data;
921 + if (data && data->subscribed)
933 mutt_expand_path (f, flen);
934 @@ -686,6 +915,9 @@ void _mutt_select_file (char *f, size_t
935 menu->tag = file_tag;
937 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
939 + (option (OPTNEWS)) ? FolderNewsHelp :
943 init_menu (&state, menu, title, sizeof (title), buffy);
944 @@ -824,7 +1056,11 @@ void _mutt_select_file (char *f, size_t
949 + if (buffy || option (OPTNEWS)) /* news have not path */
954 strfcpy (f, state.entry[menu->current].name, flen);
955 mutt_expand_path (f, flen);
956 @@ -882,14 +1118,6 @@ void _mutt_select_file (char *f, size_t
960 - case OP_BROWSER_SUBSCRIBE:
961 - imap_subscribe (state.entry[menu->current].name, 1);
964 - case OP_BROWSER_UNSUBSCRIBE:
965 - imap_subscribe (state.entry[menu->current].name, 0);
968 case OP_BROWSER_TOGGLE_LSUB:
969 if (option (OPTIMAPLSUB))
970 unset_option (OPTIMAPLSUB);
971 @@ -990,6 +1218,11 @@ void _mutt_select_file (char *f, size_t
973 case OP_CHANGE_DIRECTORY:
976 + if (option (OPTNEWS))
980 strfcpy (buf, LastDir, sizeof (buf));
982 if (!state.imap_browse)
983 @@ -1255,6 +1488,190 @@ void _mutt_select_file (char *f, size_t
985 mutt_error _("Error trying to view file");
992 + if (option (OPTNEWS))
994 + struct folder_file *f = &state.entry[menu->current];
997 + if (i == OP_CATCHUP)
998 + nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
1000 + nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
1005 + struct folder_file ff;
1006 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1009 + folder.ff->name = f->name;
1010 + folder.ff->st = NULL;
1011 + folder.ff->is_new = nd->new;
1012 + folder.ff->nd = nd;
1014 + mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1015 + newsgroup_format_str, (unsigned long) &folder,
1016 + M_FORMAT_ARROWCURSOR);
1017 + f->desc = safe_strdup (buffer); */
1018 + if (menu->current + 1 < menu->max)
1020 + menu->redraw = REDRAW_MOTION_RESYNCH;
1025 + case OP_LOAD_ACTIVE:
1026 + if (!option (OPTNEWS))
1033 + for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
1035 + if ((data = (NNTP_DATA *)tmp->data))
1036 + data->deleted = 1;
1039 + nntp_get_active (CurrentNewsSrv);
1041 + destroy_state (&state);
1043 + examine_mailboxes (menu, &state);
1045 + examine_directory (menu, &state, NULL, NULL);
1046 + init_menu (&state, menu, title, sizeof (title), buffy);
1048 +#endif /* USE_NNTP */
1050 +#if defined USE_IMAP || defined USE_NNTP
1051 + case OP_BROWSER_SUBSCRIBE:
1052 + case OP_BROWSER_UNSUBSCRIBE:
1055 + case OP_SUBSCRIBE_PATTERN:
1056 + case OP_UNSUBSCRIBE_PATTERN:
1057 + if (option (OPTNEWS))
1059 + regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1061 + int j = menu->current;
1063 + NNTP_SERVER *news = CurrentNewsSrv;
1065 + if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1071 + if (i == OP_SUBSCRIBE_PATTERN)
1072 + snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1074 + snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1075 + if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1081 + if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1083 + regerror (err, rx, buf, sizeof (buf));
1086 + mutt_error ("%s", buf);
1089 + menu->redraw = REDRAW_FULL;
1092 + else if (!state.entrylen)
1094 + mutt_error _("No newsgroups match the mask");
1098 + for ( ; j < state.entrylen; j++)
1100 + struct folder_file *f = &state.entry[j];
1102 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1103 + regexec (rx, f->name, 0, NULL, 0) == 0)
1105 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1106 + nd = mutt_newsgroup_subscribe (news, f->name);
1108 + nd = mutt_newsgroup_unsubscribe (news, f->name);
1112 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1114 + folder.name = f->name;
1116 + folder.new = nd->new;
1119 + mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1120 + newsgroup_format_str, (unsigned long) &folder,
1121 + M_FORMAT_ARROWCURSOR);
1122 + f->desc = safe_strdup (buffer);
1125 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1127 + if (menu->current + 1 < menu->max)
1129 + menu->redraw = REDRAW_MOTION_RESYNCH;
1133 + if (i == OP_SUBSCRIBE_PATTERN)
1135 + LIST *grouplist = NULL;
1138 + grouplist = news->list;
1139 + for (; grouplist; grouplist = grouplist->next)
1141 + nd = (NNTP_DATA *) grouplist->data;
1142 + if (nd && nd->group && !nd->subscribed)
1144 + if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1146 + mutt_newsgroup_subscribe (news, nd->group);
1147 + add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1151 + init_menu (&state, menu, title, sizeof (title), buffy);
1153 + mutt_newsrc_update (news);
1154 + nntp_clear_cacheindex (news);
1155 + if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1161 +#endif /* USE_IMAP && USE_NNTP */
1162 +#endif /* USE_NNTP */
1165 + if (i == OP_BROWSER_SUBSCRIBE)
1166 + imap_subscribe (state.entry[menu->current].name, 1);
1168 + imap_subscribe (state.entry[menu->current].name, 0);
1170 +#endif /* USE_IMAP */
1174 diff -udprP mutt-1.5.21.orig/browser.h mutt-1.5.21/browser.h
1175 --- mutt-1.5.21.orig/browser.h 2009-01-05 21:20:53.000000000 +0200
1176 +++ mutt-1.5.21/browser.h 2010-09-16 13:14:39.000000000 +0300
1179 #define _BROWSER_H 1
1188 @@ -37,6 +41,9 @@ struct folder_file
1189 unsigned selectable : 1;
1190 unsigned inferiors : 1;
1195 unsigned tagged : 1;
1198 diff -udprP mutt-1.5.21.orig/buffy.c mutt-1.5.21/buffy.c
1199 --- mutt-1.5.21.orig/buffy.c 2010-09-13 20:19:55.000000000 +0300
1200 +++ mutt-1.5.21/buffy.c 2010-09-16 13:14:39.000000000 +0300
1201 @@ -405,6 +405,9 @@ int mutt_buffy_check (int force)
1203 /* check device ID and serial number instead of comparing paths */
1204 if (!Context || Context->magic == M_IMAP || Context->magic == M_POP
1206 + || Context->magic == M_NNTP
1208 || stat (Context->path, &contex_sb) != 0)
1211 @@ -421,6 +424,11 @@ int mutt_buffy_check (int force)
1216 + if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1217 + tmp->magic = M_NNTP;
1220 if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
1221 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1223 @@ -436,8 +444,11 @@ int mutt_buffy_check (int force)
1224 /* check to see if the folder is the currently selected folder
1226 if (!Context || !Context->path ||
1227 - (( tmp->magic == M_IMAP || tmp->magic == M_POP )
1228 - ? mutt_strcmp (tmp->path, Context->path) :
1229 + (( tmp->magic == M_IMAP || tmp->magic == M_POP
1231 + || tmp->magic == M_NNTP
1233 + ) ? mutt_strcmp (tmp->path, Context->path) :
1234 (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)))
1237 diff -udprP mutt-1.5.21.orig/complete.c mutt-1.5.21/complete.c
1238 --- mutt-1.5.21.orig/complete.c 2009-01-05 21:20:53.000000000 +0200
1239 +++ mutt-1.5.21/complete.c 2010-09-16 13:14:39.000000000 +0300
1241 #include "mailbox.h"
1250 @@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen)
1251 char filepart[_POSIX_PATH_MAX];
1253 char imap_path[LONG_STRING];
1256 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1259 + if (option (OPTNEWS))
1261 + LIST *l = CurrentNewsSrv->list;
1263 + strfcpy (filepart, s, sizeof (filepart));
1266 + * special case to handle when there is no filepart yet.
1267 + * find the first subscribed newsgroup
1269 + if ((len = mutt_strlen (filepart)) == 0)
1271 + for (; l; l = l->next)
1273 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1275 + if (data && data->subscribed)
1277 + strfcpy (filepart, data->group, sizeof (filepart));
1285 + for (; l; l = l->next)
1287 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1289 + if (data && data->subscribed &&
1290 + mutt_strncmp (data->group, filepart, len) == 0)
1294 + for (i = 0; filepart[i] && data->group[i]; i++)
1296 + if (filepart[i] != data->group[i])
1306 + strfcpy (filepart, data->group, sizeof (filepart));
1312 + strcpy (s, filepart);
1314 + return (init ? 0 : -1);
1319 /* we can use '/' as a delimiter, imap_complete rewrites it */
1320 if (*s == '=' || *s == '+' || *s == '!')
1322 diff -udprP mutt-1.5.21.orig/compose.c mutt-1.5.21/compose.c
1323 --- mutt-1.5.21.orig/compose.c 2010-04-14 21:50:19.000000000 +0300
1324 +++ mutt-1.5.21/compose.c 2010-09-16 13:14:39.000000000 +0300
1326 #include "mailbox.h"
1328 #include "charset.h"
1332 #include "remailer.h"
1341 @@ -67,11 +72,17 @@ enum
1351 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1354 -#define HDR_XOFFSET 10
1355 -#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1356 +#define HDR_XOFFSET 14
1357 +#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1358 #define W (COLS - HDR_XOFFSET - SidebarWidth)
1360 static char *Prompts[] =
1361 @@ -83,6 +94,16 @@ static char *Prompts[] =
1377 static struct mapping_t ComposeHelp[] = {
1378 @@ -97,6 +118,19 @@ static struct mapping_t ComposeHelp[] =
1383 +static struct mapping_t ComposeNewsHelp[] = {
1384 + { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1385 + { N_("Abort"), OP_EXIT },
1386 + { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1387 + { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1388 + { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1389 + { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1390 + { N_("Help"), OP_HELP },
1395 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1397 mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt,
1398 @@ -112,7 +146,7 @@ static void redraw_crypt_lines (HEADER *
1402 - mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
1403 + mvprintw (HDR_CRYPT, SidebarWidth, TITLE_FMT, "Security: ");
1405 if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
1407 @@ -148,12 +182,15 @@ static void redraw_crypt_lines (HEADER *
1410 if ((WithCrypto & APPLICATION_PGP)
1411 - && msg->security & APPLICATION_PGP && msg->security & SIGN)
1412 - printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>"));
1413 + && msg->security & APPLICATION_PGP && msg->security & SIGN) {
1414 + printw (TITLE_FMT, _(" sign as: "));
1415 + printw ("%s", PgpSignAs ? PgpSignAs : _("<default>"));
1418 if ((WithCrypto & APPLICATION_SMIME)
1419 && msg->security & APPLICATION_SMIME && msg->security & SIGN) {
1420 - printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
1421 + printw (TITLE_FMT, _(" sign as: "));
1422 + printw ("%s", SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
1425 if ((WithCrypto & APPLICATION_SMIME)
1426 @@ -175,7 +212,7 @@ static void redraw_mix_line (LIST *chain
1430 - mvaddstr (HDR_MIX, SidebarWidth, " Mix: ");
1431 + mvprintw (HDR_MIX, SidebarWidth, TITLE_FMT, "Mix: ");
1435 @@ -249,9 +286,28 @@ static void draw_envelope_addr (int line
1436 static void draw_envelope (HEADER *msg, char *fcc)
1438 draw_envelope_addr (HDR_FROM, msg->env->from);
1440 + if (!option (OPTNEWSSEND))
1443 draw_envelope_addr (HDR_TO, msg->env->to);
1444 draw_envelope_addr (HDR_CC, msg->env->cc);
1445 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1450 + mvprintw (HDR_TO, SidebarWidth, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1451 + mutt_paddstr (W, NONULL (msg->env->newsgroups));
1452 + mvprintw (HDR_CC, SidebarWidth, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1453 + mutt_paddstr (W, NONULL (msg->env->followup_to));
1454 + if (option (OPTXCOMMENTTO))
1456 + mvprintw (HDR_BCC, SidebarWidth, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1457 + mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1461 mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1462 mutt_paddstr (W, NONULL (msg->env->subject));
1463 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1464 @@ -504,6 +560,12 @@ int mutt_compose_menu (HEADER *msg, /*
1465 /* Sort, SortAux could be changed in mutt_index_menu() */
1466 int oldSort, oldSortAux;
1469 + int news = 0; /* is it a news article ? */
1471 + if (option (OPTNEWSSEND))
1475 mutt_attach_init (msg->content);
1476 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
1477 @@ -514,10 +576,18 @@ int mutt_compose_menu (HEADER *msg, /*
1478 menu->make_entry = snd_entry;
1479 menu->tag = mutt_tag_attach;
1483 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1486 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1491 + unset_option (OPTNEWS); /* for any case */
1493 switch (op = mutt_menuLoop (menu))
1496 @@ -530,17 +600,87 @@ int mutt_compose_menu (HEADER *msg, /*
1497 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1499 case OP_COMPOSE_EDIT_TO:
1504 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1505 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1507 case OP_COMPOSE_EDIT_BCC:
1512 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1513 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1515 case OP_COMPOSE_EDIT_CC:
1520 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1521 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1524 + case OP_COMPOSE_EDIT_NEWSGROUPS:
1527 + if (msg->env->newsgroups)
1528 + strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1531 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1533 + FREE (&msg->env->newsgroups);
1534 + mutt_remove_trailing_ws (buf);
1535 + msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1536 + move (HDR_TO, HDR_XOFFSET);
1538 + if (msg->env->newsgroups)
1539 + printw ("%-*.*s", W, W, msg->env->newsgroups);
1544 + case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1548 + if (msg->env->followup_to)
1549 + strfcpy (buf, msg->env->followup_to, sizeof (buf));
1550 + if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1552 + FREE (&msg->env->followup_to);
1553 + mutt_remove_trailing_ws (buf);
1554 + msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1555 + move (HDR_CC, HDR_XOFFSET);
1557 + if (msg->env->followup_to)
1558 + printw ("%-*.*s", W, W, msg->env->followup_to);
1563 + case OP_COMPOSE_EDIT_X_COMMENT_TO:
1564 + if (news && option (OPTXCOMMENTTO))
1567 + if (msg->env->x_comment_to)
1568 + strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1569 + if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1571 + FREE (&msg->env->x_comment_to);
1572 + msg->env->x_comment_to = safe_strdup (buf);
1573 + move (HDR_BCC, HDR_XOFFSET);
1575 + if (msg->env->x_comment_to)
1576 + printw ("%-*.*s", W, W, msg->env->x_comment_to);
1581 case OP_COMPOSE_EDIT_SUBJECT:
1582 if (msg->env->subject)
1583 strfcpy (buf, msg->env->subject, sizeof (buf));
1584 @@ -703,6 +843,9 @@ int mutt_compose_menu (HEADER *msg, /*
1587 case OP_COMPOSE_ATTACH_MESSAGE:
1589 + case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1594 @@ -710,7 +853,22 @@ int mutt_compose_menu (HEADER *msg, /*
1596 prompt = _("Open mailbox to attach message from");
1599 + unset_option (OPTNEWS);
1600 + if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1602 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1605 + prompt = _("Open newsgroup to attach message from");
1606 + set_option (OPTNEWS);
1612 + if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1615 strfcpy (fname, NONULL (Context->path), sizeof (fname));
1616 mutt_pretty_mailbox (fname, sizeof (fname));
1617 @@ -719,6 +877,11 @@ int mutt_compose_menu (HEADER *msg, /*
1618 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1622 + if (option (OPTNEWS))
1623 + nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1626 mutt_expand_path (fname, sizeof (fname));
1628 if (!mx_is_imap (fname))
1629 @@ -726,6 +889,9 @@ int mutt_compose_menu (HEADER *msg, /*
1631 if (!mx_is_pop (fname))
1634 + if (!mx_is_nntp (fname) && !option (OPTNEWS))
1636 /* check to make sure the file exists and is readable */
1637 if (access (fname, R_OK) == -1)
1639 diff -udprP mutt-1.5.21.orig/config.h.in mutt-1.5.21/config.h.in
1640 --- mutt-1.5.21.orig/config.h.in 2010-08-25 19:32:03.000000000 +0300
1641 +++ mutt-1.5.21/config.h.in 2010-09-16 13:14:39.000000000 +0300
1643 significant more memory when defined. */
1644 #undef EXACT_ADDRESS
1646 +/* Compiling with newsreading support with NNTP */
1649 /* program to use for shell commands */
1652 diff -udprP mutt-1.5.21.orig/configure.ac mutt-1.5.21/configure.ac
1653 --- mutt-1.5.21.orig/configure.ac 2010-08-24 19:34:21.000000000 +0300
1654 +++ mutt-1.5.21/configure.ac 2010-09-16 13:14:39.000000000 +0300
1655 @@ -602,6 +602,14 @@ if test x"$need_imap" = xyes -o x"$need_
1656 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1659 +AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1660 +[ if test x$enableval = xyes ; then
1661 + AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1662 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1667 dnl -- end socket dependencies --
1669 if test "$need_socket" = "yes"
1670 diff -udprP mutt-1.5.21.orig/curs_main.c mutt-1.5.21/curs_main.c
1671 --- mutt-1.5.21.orig/curs_main.c 2010-09-13 20:19:55.000000000 +0300
1672 +++ mutt-1.5.21/curs_main.c 2010-09-16 13:14:39.000000000 +0300
1676 #include "mutt_curses.h"
1678 #include "mutt_menu.h"
1679 #include "mailbox.h"
1680 #include "mapping.h"
1683 #include "mutt_crypt.h"
1692 @@ -413,12 +418,27 @@ static struct mapping_t IndexHelp[] = {
1697 +struct mapping_t IndexNewsHelp[] = {
1698 + { N_("Quit"), OP_QUIT },
1699 + { N_("Del"), OP_DELETE },
1700 + { N_("Undel"), OP_UNDELETE },
1701 + { N_("Save"), OP_SAVE },
1702 + { N_("Post"), OP_POST },
1703 + { N_("Followup"), OP_FOLLOWUP },
1704 + { N_("Catchup"), OP_CATCHUP },
1705 + { N_("Help"), OP_HELP },
1710 /* This function handles the message index window as well as commands returned
1711 * from the pager (MENU_PAGER).
1713 int mutt_index_menu (void)
1715 char buf[LONG_STRING], helpstr[LONG_STRING];
1718 int done = 0; /* controls when to exit the "event" loop */
1720 @@ -439,7 +459,11 @@ int mutt_index_menu (void)
1721 menu->make_entry = index_make_entry;
1722 menu->color = index_color;
1723 menu->current = ci_first_message ();
1724 - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1725 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1727 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1732 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
1733 @@ -682,6 +706,9 @@ int mutt_index_menu (void)
1734 mutt_curs_set (1); /* fallback from the pager */
1738 + unset_option (OPTNEWS); /* for any case */
1743 @@ -732,6 +759,120 @@ int mutt_index_menu (void)
1744 menu_current_bottom (menu);
1748 + case OP_GET_MESSAGE:
1749 + case OP_GET_PARENT:
1751 + if (Context->magic == M_NNTP)
1755 + if (op == OP_GET_MESSAGE)
1758 + if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1764 + LIST *ref = CURHDR->env->references;
1767 + mutt_error _("Article has no parent reference!");
1770 + strfcpy (buf, ref->data, sizeof (buf));
1772 + if (!Context->id_hash)
1773 + Context->id_hash = mutt_make_id_hash (Context);
1774 + if ((h = hash_find (Context->id_hash, buf)))
1776 + if (h->virtual != -1)
1778 + menu->current = h->virtual;
1779 + menu->redraw = REDRAW_MOTION_RESYNCH;
1781 + else if (h->collapsed)
1783 + mutt_uncollapse_thread (Context, h);
1784 + mutt_set_virtual (Context);
1785 + menu->current = h->virtual;
1786 + menu->redraw = REDRAW_MOTION_RESYNCH;
1789 + mutt_error _("Message not visible in limited view.");
1793 + if (nntp_check_msgid (Context, buf) == 0)
1795 + h = Context->hdrs[Context->msgcount-1];
1796 + mutt_sort_headers (Context, 0);
1797 + menu->current = h->virtual;
1798 + menu->redraw = REDRAW_FULL;
1801 + mutt_error (_("Article %s not found on server"), buf);
1806 + case OP_GET_CHILDREN:
1807 + case OP_RECONSTRUCT_THREAD:
1809 + if (Context->magic == M_NNTP)
1812 + int old = CURHDR->index, i;
1814 + if (!CURHDR->env->message_id)
1816 + mutt_error _("No Message-Id. Unable to perform operation");
1820 + if (!Context->id_hash)
1821 + Context->id_hash = mutt_make_id_hash (Context);
1822 + strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1824 + if (op == OP_RECONSTRUCT_THREAD)
1826 + LIST *ref = CURHDR->env->references;
1829 + nntp_check_msgid (Context, ref->data);
1830 + /* the last msgid in References is the root message */
1832 + strfcpy (buf, ref->data, sizeof (buf));
1836 + mutt_message _("Check for children of message...");
1837 + if (nntp_check_children (Context, buf) == 0)
1839 + mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1840 + h = hash_find (Context->id_hash, buf);
1841 + /* if the root message was retrieved, move to it */
1843 + menu->current = h->virtual;
1844 + else /* try to restore old position */
1845 + for (i = 0; i < Context->msgcount; i++)
1846 + if (Context->hdrs[i]->index == old)
1848 + menu->current = Context->hdrs[i]->virtual;
1849 + /* As an added courtesy, recenter the menu
1850 + * with the current entry at the middle of the screen */
1851 + menu_check_recenter (menu);
1852 + menu_current_middle (menu);
1855 + menu->redraw = REDRAW_FULL;
1856 + mutt_clear_error ();
1864 @@ -828,11 +969,33 @@ int mutt_index_menu (void)
1868 + case OP_TOGGLE_READ:
1871 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1873 - if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1874 + if (op == OP_TOGGLE_READ)
1876 + char buf[LONG_STRING];
1878 + if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1880 + snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1881 + Context->pattern ? Context->pattern : ".*");
1882 + set_option (OPTHIDEREAD);
1886 + strfcpy (buf, Context->pattern + 8, sizeof(buf));
1887 + if (!*buf || strncmp (buf, ".*", 2) == 0)
1888 + snprintf (buf, sizeof(buf), "~A");
1889 + unset_option (OPTHIDEREAD);
1891 + FREE (&Context->pattern);
1892 + Context->pattern = safe_strdup (buf);
1894 + if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1895 + mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1897 if (menu->oldcurrent >= 0)
1899 @@ -1071,15 +1234,22 @@ int mutt_index_menu (void)
1901 case OP_MAIN_CHANGE_FOLDER:
1902 case OP_MAIN_NEXT_UNREAD_MAILBOX:
1905 - op = OP_MAIN_CHANGE_FOLDER_READONLY;
1907 - /* fallback to the readonly case */
1909 case OP_MAIN_CHANGE_FOLDER_READONLY:
1911 + case OP_MAIN_CHANGE_GROUP:
1912 + case OP_MAIN_CHANGE_GROUP_READONLY:
1913 + unset_option (OPTNEWS);
1915 + if (attach_msg || option (OPTREADONLY) ||
1917 + op == OP_MAIN_CHANGE_GROUP_READONLY ||
1919 + op == OP_MAIN_CHANGE_FOLDER_READONLY)
1920 + flags = M_READONLY;
1924 - if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1926 cp = _("Open mailbox in read-only mode");
1928 cp = _("Open mailbox");
1929 @@ -1098,6 +1268,21 @@ int mutt_index_menu (void)
1934 + if (op == OP_MAIN_CHANGE_GROUP ||
1935 + op == OP_MAIN_CHANGE_GROUP_READONLY)
1937 + set_option (OPTNEWS);
1938 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1941 + cp = _("Open newsgroup in read-only mode");
1943 + cp = _("Open newsgroup");
1948 mutt_buffy (buf, sizeof (buf));
1950 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1951 @@ -1117,6 +1302,14 @@ int mutt_index_menu (void)
1956 + if (option (OPTNEWS))
1958 + unset_option (OPTNEWS);
1959 + nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1963 mutt_expand_path (buf, sizeof (buf));
1964 if (mx_get_magic (buf) <= 0)
1966 @@ -1158,15 +1351,18 @@ int mutt_index_menu (void)
1967 CurrentMenu = MENU_MAIN;
1968 mutt_folder_hook (buf);
1970 - if ((Context = mx_open_mailbox (buf,
1971 - (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1972 - M_READONLY : 0, NULL)) != NULL)
1973 + if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1975 menu->current = ci_first_message ();
1981 + /* mutt_buffy_check() must be done with mail-reader mode! */
1982 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1983 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1985 mutt_clear_error ();
1986 mutt_buffy_check(1); /* force the buffy check after we have changed
1988 @@ -1539,6 +1735,15 @@ int mutt_index_menu (void)
1990 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1993 + if (Context->magic == M_NNTP)
1996 + mutt_error _("Can't change 'important' flag on NNTP server.");
2003 for (j = 0; j < Context->vcount; j++)
2004 @@ -1886,6 +2091,17 @@ int mutt_index_menu (void)
2010 + if (Context && Context->magic == M_NNTP)
2012 + if (mutt_newsgroup_catchup (CurrentNewsSrv,
2013 + ((NNTP_DATA *)Context->data)->group))
2014 + menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2019 case OP_DISPLAY_ADDRESS:
2022 @@ -2013,6 +2229,15 @@ int mutt_index_menu (void)
2023 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2028 + if (Context->magic == M_NNTP)
2031 + mutt_error _("Can't edit message on newsserver.");
2036 MAYBE_REDRAW (menu->redraw);
2038 @@ -2090,6 +2315,41 @@ int mutt_index_menu (void)
2039 menu->redraw = REDRAW_FULL;
2044 + case OP_FORWARD_TO_GROUP:
2052 + if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2053 + mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2054 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2056 + if (Context && Context->magic == M_NNTP &&
2057 + !((NNTP_DATA *)Context->data)->allowed &&
2058 + query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2060 + if (op == OP_POST)
2061 + ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2065 + if (op == OP_FOLLOWUP)
2066 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2067 + tag ? NULL : CURHDR);
2069 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2070 + tag ? NULL : CURHDR);
2072 + menu->redraw = REDRAW_FULL;
2080 @@ -2165,6 +2425,12 @@ int mutt_index_menu (void)
2082 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2085 + /* Close all open NNTP connections */
2087 + nntp_logout_all ();
2090 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2091 op == OP_UNDELETE_THREAD ? 0 : 1);
2093 diff -udprP mutt-1.5.21.orig/doc/manual.xml.head mutt-1.5.21/doc/manual.xml.head
2094 --- mutt-1.5.21.orig/doc/manual.xml.head 2010-08-24 19:34:21.000000000 +0300
2095 +++ mutt-1.5.21/doc/manual.xml.head 2010-09-16 13:14:39.000000000 +0300
2096 @@ -1611,6 +1611,22 @@ fo-table</literal> for details.
2101 +<title>Reading news via NNTP</title>
2104 +If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2105 +read news from newsserver via NNTP. You can open a newsgroup with
2106 +function ``change-newsgroup'' (default: ``i''). Default newsserver
2107 +can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2108 +variable. Like other news readers, info about subscribed newsgroups
2109 +is saved in file by <link linkend="newsrc">$newsrc</link>
2110 +variable. Article headers are cached and can be loaded from file when
2111 +newsgroup entered instead loading from newsserver.
2118 <sect1 id="forwarding-mail">
2119 diff -udprP mutt-1.5.21.orig/doc/mutt.man mutt-1.5.21/doc/mutt.man
2120 --- mutt-1.5.21.orig/doc/mutt.man 2010-08-24 19:34:21.000000000 +0300
2121 +++ mutt-1.5.21/doc/mutt.man 2010-09-16 13:14:39.000000000 +0300
2122 @@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2127 -[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2129 +[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-g \fIserver\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2133 @@ -101,6 +101,10 @@ files.
2134 Specify which mailbox to load.
2135 .IP "-F \fImuttrc\fP"
2136 Specify an initialization file to read instead of ~/.muttrc
2137 +.IP "-g \fIserver\fP"
2138 +Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2140 +Start Mutt with a listing of subscribed newsgroups.
2143 .IP "-H \fIdraft\fP"
2144 diff -udprP mutt-1.5.21.orig/functions.h mutt-1.5.21/functions.h
2145 --- mutt-1.5.21.orig/functions.h 2010-08-24 19:34:21.000000000 +0300
2146 +++ mutt-1.5.21/functions.h 2010-09-16 13:14:39.000000000 +0300
2147 @@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in
2148 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2149 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2150 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2152 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "I" },
2153 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2155 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2156 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2157 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
2158 @@ -101,7 +105,15 @@ struct binding_t OpMain[] = { /* map: in
2159 { "edit", OP_EDIT_MESSAGE, "e" },
2160 { "edit-type", OP_EDIT_TYPE, "\005" },
2161 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2162 { "flag-message", OP_FLAG_MESSAGE, "F" },
2164 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2165 + { "followup-message", OP_FOLLOWUP, "\033f" },
2166 + { "get-children", OP_GET_CHILDREN, NULL },
2167 + { "get-message", OP_GET_MESSAGE, "\007" },
2168 + { "get-parent", OP_GET_PARENT, "\033G" },
2169 + { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2171 { "group-reply", OP_GROUP_REPLY, "g" },
2173 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2174 @@ -128,6 +140,9 @@ struct binding_t OpMain[] = { /* map: in
2175 { "sort-mailbox", OP_SORT, "o" },
2176 { "sort-reverse", OP_SORT_REVERSE, "O" },
2177 { "print-message", OP_PRINT, "p" },
2179 + { "post-message", OP_POST, "\033m" },
2181 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2182 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2183 { "recall-message", OP_RECALL_MESSAGE, "R" },
2184 @@ -147,6 +162,10 @@ struct binding_t OpMain[] = { /* map: in
2185 { "show-version", OP_VERSION, "V" },
2186 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2187 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2188 + { "toggle-read", OP_TOGGLE_READ, "X" },
2190 + { "catchup", OP_CATCHUP, "y" },
2192 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2193 { "buffy-list", OP_BUFFY_LIST, "." },
2194 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
2195 @@ -178,6 +197,10 @@ struct binding_t OpPager[] = { /* map: p
2196 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2197 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2198 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2200 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2201 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2203 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2204 { "copy-message", OP_COPY_MESSAGE, "C" },
2205 { "decode-copy", OP_DECODE_COPY, "\033C" },
2206 @@ -188,8 +211,12 @@ struct binding_t OpPager[] = { /* map: p
2207 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2208 { "edit", OP_EDIT_MESSAGE, "e" },
2209 { "edit-type", OP_EDIT_TYPE, "\005" },
2211 + { "followup-message", OP_FOLLOWUP, "\033f" },
2212 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2214 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2215 { "flag-message", OP_FLAG_MESSAGE, "F" },
2216 { "group-reply", OP_GROUP_REPLY, "g" },
2218 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
2219 @@ -211,6 +238,9 @@ struct binding_t OpPager[] = { /* map: p
2220 { "sort-mailbox", OP_SORT, "o" },
2221 { "sort-reverse", OP_SORT_REVERSE, "O" },
2222 { "print-message", OP_PRINT, "p" },
2224 + { "post-message", OP_POST, "\033m" },
2226 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2227 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2228 { "quit", OP_QUIT, "Q" },
2229 @@ -279,6 +309,10 @@ struct binding_t OpAttach[] = { /* map:
2230 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2231 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2232 { "edit-type", OP_EDIT_TYPE, "\005" },
2234 + { "followup-message", OP_FOLLOWUP, "\033f" },
2235 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2237 { "print-entry", OP_PRINT, "p" },
2238 { "save-entry", OP_SAVE, "s" },
2239 { "pipe-entry", OP_PIPE, "|" },
2240 @@ -304,6 +338,7 @@ struct binding_t OpAttach[] = { /* map:
2241 struct binding_t OpCompose[] = { /* map: compose */
2242 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2243 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2244 + { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2245 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2246 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2247 { "copy-file", OP_SAVE, "C" },
2248 @@ -323,6 +358,11 @@ struct binding_t OpCompose[] = { /* map:
2249 { "print-entry", OP_PRINT, "l" },
2250 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2251 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2253 + { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2254 + { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2255 + { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2257 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2258 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2259 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
2260 @@ -374,14 +414,25 @@ struct binding_t OpBrowser[] = { /* map:
2261 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2262 { "check-new", OP_CHECK_NEW, NULL },
2263 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2265 + { "reload-active", OP_LOAD_ACTIVE, "g" },
2266 + { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2267 + { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2268 + { "catchup", OP_CATCHUP, "y" },
2269 + { "uncatchup", OP_UNCATCHUP, "Y" },
2271 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2272 { "buffy-list", OP_BUFFY_LIST, "." },
2274 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2275 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2276 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2278 +#if defined USE_IMAP || defined USE_NNTP
2279 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2280 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2283 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2286 diff -udprP mutt-1.5.21.orig/globals.h mutt-1.5.21/globals.h
2287 --- mutt-1.5.21.orig/globals.h 2009-08-25 22:08:52.000000000 +0300
2288 +++ mutt-1.5.21/globals.h 2010-09-16 13:14:39.000000000 +0300
2289 @@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
2292 WHERE char *Muttrc INITVAL (NULL);
2294 +WHERE char *NewsCacheDir;
2295 +WHERE char *GroupFormat;
2297 +WHERE char *NewsServer;
2298 +WHERE char *NntpUser;
2299 +WHERE char *NntpPass;
2300 +WHERE char *NewsRc;
2304 WHERE char *PagerFmt;
2305 @@ -188,6 +197,11 @@ extern unsigned char QuadOptions[];
2307 WHERE unsigned short Counter INITVAL (0);
2310 +WHERE short NewsPollTimeout;
2311 +WHERE short NntpContext;
2314 WHERE short ConnectTimeout;
2315 WHERE short HistSize;
2316 WHERE short MenuContext;
2317 diff -udprP mutt-1.5.21.orig/hash.c mutt-1.5.21/hash.c
2318 --- mutt-1.5.21.orig/hash.c 2009-03-19 21:41:18.000000000 +0200
2319 +++ mutt-1.5.21/hash.c 2010-09-16 13:14:39.000000000 +0300
2320 @@ -57,6 +57,7 @@ HASH *hash_create (int nelem, int lower)
2323 table->nelem = nelem;
2324 + table->curnelem = 0;
2325 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2328 @@ -71,6 +72,29 @@ HASH *hash_create (int nelem, int lower)
2332 +HASH *hash_resize (HASH *ptr, int nelem, int lower)
2335 + struct hash_elem *elem, *tmp;
2338 + table = hash_create (nelem, lower);
2340 + for (i = 0; i < ptr->nelem; i++)
2342 + for (elem = ptr->table[i]; elem; )
2345 + elem = elem->next;
2346 + hash_insert (table, tmp->key, tmp->data, 1);
2350 + FREE (&ptr->table);
2355 /* table hash table to update
2356 * key key to hash on
2357 * data data to associate with `key'
2358 @@ -90,6 +114,7 @@ int hash_insert (HASH * table, const cha
2360 ptr->next = table->table[h];
2361 table->table[h] = ptr;
2362 + table->curnelem++;
2366 @@ -112,6 +137,7 @@ int hash_insert (HASH * table, const cha
2368 table->table[h] = ptr;
2370 + table->curnelem++;
2374 @@ -142,6 +168,7 @@ void hash_delete_hash (HASH * table, int
2376 destroy (ptr->data);
2378 + table->curnelem--;
2382 diff -udprP mutt-1.5.21.orig/hash.h mutt-1.5.21/hash.h
2383 --- mutt-1.5.21.orig/hash.h 2009-03-19 21:41:18.000000000 +0200
2384 +++ mutt-1.5.21/hash.h 2010-09-16 13:14:39.000000000 +0300
2385 @@ -28,7 +28,7 @@ struct hash_elem
2390 + int nelem, curnelem;
2391 struct hash_elem **table;
2392 unsigned int (*hash_string)(const unsigned char *, unsigned int);
2393 int (*cmp_string)(const char *, const char *);
2394 @@ -41,6 +41,7 @@ HASH;
2396 HASH *hash_create (int nelem, int lower);
2397 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2398 +HASH *hash_resize (HASH * table, int nelem, int lower);
2399 void *hash_find_hash (const HASH * table, int hash, const char *key);
2400 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2401 void (*destroy) (void *));
2402 diff -udprP mutt-1.5.21.orig/hdrline.c mutt-1.5.21/hdrline.c
2403 --- mutt-1.5.21.orig/hdrline.c 2009-04-11 02:45:19.000000000 +0300
2404 +++ mutt-1.5.21/hdrline.c 2010-09-16 13:14:39.000000000 +0300
2405 @@ -211,6 +211,7 @@ int mutt_user_is_recipient (HEADER *h)
2406 * %E = number of messages in current thread
2407 * %f = entire from line
2408 * %F = like %n, unless from self
2409 + * %g = newsgroup name (if compiled with nntp support)
2411 * %l = number of lines in the message
2412 * %L = like %F, except `lists' are displayed first
2413 @@ -219,12 +220,14 @@ int mutt_user_is_recipient (HEADER *h)
2415 * %O = like %L, except using address instead of name
2416 * %P = progress indicator for builtin pager
2417 + * %R = `x-comment-to:' field (if present and compiled with nntp support)
2419 * %S = short message status (e.g., N/O/D/!/r/-)
2420 * %t = `to:' field (recipients)
2422 * %u = user (login) name of author
2423 * %v = first name of author, unless from self
2424 + * %W = where user is (organization)
2425 * %X = number of MIME attachments
2426 * %y = `x-label:' field (if present)
2427 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2428 @@ -457,6 +460,12 @@ hdr_format_str (char *dest,
2434 + mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2439 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2441 @@ -548,6 +557,15 @@ hdr_format_str (char *dest,
2442 strfcpy(dest, NONULL(hfi->pager_progress), destlen);
2448 + mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2449 + else if (!hdr->env->x_comment_to)
2456 if (flags & M_FORMAT_TREE && !hdr->collapsed)
2457 @@ -637,6 +655,13 @@ hdr_format_str (char *dest,
2458 mutt_format_s (dest, destlen, prefix, buf2);
2463 + mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2464 + else if (!hdr->env->organization)
2471 diff -udprP mutt-1.5.21.orig/headers.c mutt-1.5.21/headers.c
2472 --- mutt-1.5.21.orig/headers.c 2009-08-25 22:08:52.000000000 +0300
2473 +++ mutt-1.5.21/headers.c 2010-09-16 13:14:39.000000000 +0300
2474 @@ -114,6 +114,9 @@ void mutt_edit_headers (const char *edit
2475 $edit_headers set, we remove References: as they're likely invalid;
2476 we can simply compare strings as we don't generate References for
2477 multiple Message-Ids in IRT anyways */
2479 + if (!option (OPTNEWSSEND))
2481 if (!n->in_reply_to || (msg->env->in_reply_to &&
2482 mutt_strcmp (n->in_reply_to->data,
2483 msg->env->in_reply_to->data) != 0))
2484 diff -udprP mutt-1.5.21.orig/init.c mutt-1.5.21/init.c
2485 --- mutt-1.5.21.orig/init.c 2010-08-25 19:31:40.000000000 +0300
2486 +++ mutt-1.5.21/init.c 2010-09-16 13:14:39.000000000 +0300
2487 @@ -2966,6 +2966,28 @@ void mutt_init (int skip_sys_rc, LIST *c
2489 Fqdn = safe_strdup(NONULL(Hostname));
2496 + if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2499 + fgets (buffer, sizeof (buffer), f);
2503 + while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2505 + NewsServer = safe_strdup (p);
2509 + if ((p = getenv ("NNTPSERVER")))
2510 + NewsServer = safe_strdup (p);
2513 if ((p = getenv ("MAIL")))
2514 Spoolfile = safe_strdup (p);
2515 else if ((p = getenv ("MAILDIR")))
2516 diff -udprP mutt-1.5.21.orig/init.h mutt-1.5.21/init.h
2517 --- mutt-1.5.21.orig/init.h 2010-09-15 18:39:31.000000000 +0300
2518 +++ mutt-1.5.21/init.h 2010-09-16 13:14:39.000000000 +0300
2519 @@ -176,6 +176,20 @@ struct option_t MuttVars[] = {
2520 ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before
2521 ** editing the body of an outgoing message.
2524 + { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2527 + ** If set, Mutt will prompt you for follow-up groups before editing
2528 + ** the body of an outgoing message.
2530 + { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2533 + ** If set, Mutt will prompt you for x-comment-to field before editing
2534 + ** the body of an outgoing message.
2537 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2540 @@ -322,6 +336,14 @@ struct option_t MuttVars[] = {
2541 ** follow these menus. The option is \fIunset\fP by default because many
2542 ** visual terminals don't permit making the cursor invisible.
2545 + { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2548 + ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2549 + ** as read when you quit the newsgroup (catchup newsgroup).
2552 #if defined(USE_SSL)
2553 { "certificate_file", DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" },
2555 @@ -798,6 +820,16 @@ struct option_t MuttVars[] = {
2556 ** sent to both the list and your address, resulting in two copies
2557 ** of the same email for you.
2560 + { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2563 + ** If this variable is \fIset\fP and the keyword "poster" is present in
2564 + ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2565 + ** permitted. The message will be mailed to the submitter of the
2566 + ** message via mail.
2569 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2572 @@ -880,6 +912,27 @@ struct option_t MuttVars[] = {
2573 ** a regular expression that will match the whole name so mutt will expand
2574 ** ``Franklin'' to ``Franklin, Steve''.
2577 + { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2580 + ** This variable allows you to customize the newsgroup browser display to
2581 + ** your personal taste. This string is similar to ``$index_format'', but
2582 + ** has its own set of printf()-like sequences:
2585 + ** %C current newsgroup number
2586 + ** %d description of newsgroup (becomes from server)
2587 + ** %f newsgroup name
2588 + ** %M - if newsgroup not allowed for direct post (moderated for example)
2589 + ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2590 + ** %n number of new articles in newsgroup
2591 + ** %s number of unread articles in newsgroup
2592 + ** %>X right justify the rest of the string and pad with character "X"
2593 + ** %|X pad to the end of the line with character "X"
2597 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2600 @@ -1256,6 +1309,7 @@ struct option_t MuttVars[] = {
2601 ** .dt %E .dd number of messages in current thread
2602 ** .dt %f .dd sender (address + real name), either From: or Return-Path:
2603 ** .dt %F .dd author name, or recipient name if the message is from you
2604 + ** .dt %g .dd newsgroup name (if compiled with nntp support)
2605 ** .dt %H .dd spam attribute(s) of this message
2606 ** .dt %i .dd message-id of the current message
2607 ** .dt %l .dd number of lines in the message (does not work with maildir,
2608 @@ -1271,12 +1325,14 @@ struct option_t MuttVars[] = {
2609 ** stashed the message: list name or recipient name
2610 ** if not sent to a list
2611 ** .dt %P .dd progress indicator for the built-in pager (how much of the file has been displayed)
2612 + ** .dt %R .dd ``x-comment-to:'' field (if present and compiled with nntp support)
2613 ** .dt %s .dd subject of the message
2614 ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as)
2615 ** .dt %t .dd ``To:'' field (recipients)
2616 ** .dt %T .dd the appropriate character from the $$to_chars string
2617 ** .dt %u .dd user (login) name of the author
2618 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2619 + ** .dt %W .dd name of organization of author (``organization:'' field)
2620 ** .dt %X .dd number of attachments
2621 ** (please see the ``$attachments'' section for possible speed effects)
2622 ** .dt %y .dd ``X-Label:'' field, if present
2623 @@ -1311,6 +1367,21 @@ struct option_t MuttVars[] = {
2624 ** Note that these expandos are supported in
2625 ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too.
2628 + { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2631 + ** If set, specifies the program and arguments used to deliver news posted
2632 + ** by Mutt. Otherwise, mutt posts article using current connection to
2633 + ** news server. The following printf-style sequence is understood:
2636 + ** %s newsserver name
2639 + ** Example: set inews="/usr/local/bin/inews -hS"
2642 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2645 @@ -1545,6 +1616,15 @@ struct option_t MuttVars[] = {
2646 ** menu, attachments which cannot be decoded in a reasonable manner will
2647 ** be attached to the newly composed message if this option is \fIset\fP.
2650 + { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2653 + ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2654 + ** encoded according to RFC2047 to base64. This is useful when message
2655 + ** is Usenet article, because MIME for news is nonstandard feature.
2659 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2661 @@ -1592,6 +1672,77 @@ struct option_t MuttVars[] = {
2662 ** See also $$read_inc, $$write_inc and $$net_inc.
2666 + { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2669 + ** This variable pointing to directory where Mutt will save cached news
2670 + ** articles headers in. If \fIunset\fP, headers will not be saved at all
2671 + ** and will be reloaded each time when you enter to newsgroup.
2673 + { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2676 + ** This variable specifies domain name or address of NNTP server. It
2677 + ** defaults to the newsserver specified in the environment variable
2678 + ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2679 + ** specify username and an alternative port for each newsserver, ie:
2681 + ** [news[s]://][username[:password]@]newsserver[:port]
2683 + { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2686 + ** The file, containing info about subscribed newsgroups - names and
2687 + ** indexes of read articles. The following printf-style sequence
2691 + ** %s newsserver name
2694 + { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2697 + ** This variable defines number of articles which will be in index when
2698 + ** newsgroup entered. If active newsgroup have more articles than this
2699 + ** number, oldest articles will be ignored. Also controls how many
2700 + ** articles headers will be saved in cache when you quit newsgroup.
2702 + { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2705 + ** This variable controls whether or not descriptions for each newsgroup
2706 + ** must be loaded when newsgroup is added to list (first time list
2707 + ** loading or new newsgroup adding).
2709 + { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2712 + ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2713 + ** authentification, Mutt will prompt you for your account name when you
2714 + ** connect to newsserver.
2716 + { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2719 + ** Your password for NNTP account.
2721 + { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2724 + ** The time in seconds until any operations on newsgroup except post new
2725 + ** article will cause recheck for new news. If set to 0, Mutt will
2726 + ** recheck newsgroup on each operation in index (stepping, read article,
2729 + { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2732 + ** Controls whether or not Mutt will try to reconnect to newsserver when
2733 + ** connection lost.
2736 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2739 @@ -2091,6 +2242,16 @@ struct option_t MuttVars[] = {
2740 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2744 + { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2747 + ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2748 + ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2749 + ** does not support posting to that newsgroup or totally read-only, that
2750 + ** posting will not have an effect.
2753 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2756 @@ -2494,6 +2655,28 @@ struct option_t MuttVars[] = {
2757 ** Command to use when spawning a subshell. By default, the user's login
2758 ** shell from \fC/etc/passwd\fP is used.
2761 + { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2764 + ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2765 + ** ``newsrc'' file and into cache.
2767 + { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2770 + ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2771 + ** the browser. Otherwise, it will be done only once for a newsserver.
2772 + ** Also controls whether or not number of new articles of subscribed
2773 + ** newsgroups will be then checked.
2775 + { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2778 + ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2779 + ** will be displayed in browser.
2782 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2785 @@ -3364,6 +3547,14 @@ struct option_t MuttVars[] = {
2786 ** Also see the $$read_inc, $$net_inc and $$time_inc variables and the
2787 ** ``$tuning'' section of the manual for performance considerations.
2790 + { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2793 + ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2794 + ** name of original article author) to article that followuped to newsgroup.
2798 { NULL, 0, 0, 0, 0 }
2800 diff -udprP mutt-1.5.21.orig/mailbox.h mutt-1.5.21/mailbox.h
2801 --- mutt-1.5.21.orig/mailbox.h 2009-04-30 20:33:48.000000000 +0300
2802 +++ mutt-1.5.21/mailbox.h 2010-09-16 13:14:39.000000000 +0300
2803 @@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2805 int mx_is_pop (const char *);
2808 +int mx_is_nntp (const char *);
2811 int mx_access (const char*, int);
2812 int mx_check_empty (const char *);
2813 diff -udprP mutt-1.5.21.orig/main.c mutt-1.5.21/main.c
2814 --- mutt-1.5.21.orig/main.c 2010-09-13 20:19:55.000000000 +0300
2815 +++ mutt-1.5.21/main.c 2010-09-16 13:14:39.000000000 +0300
2817 #include <stringprep.h>
2824 static const char *ReachingUs = N_("\
2825 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2826 To report a bug, please visit http://bugs.mutt.org/.\n");
2827 @@ -134,6 +138,8 @@ options:\n\
2828 " -e <command>\tspecify a command to be executed after initialization\n\
2829 -f <file>\tspecify which mailbox to read\n\
2830 -F <file>\tspecify an alternate muttrc file\n\
2831 + -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2832 + -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2833 -H <file>\tspecify a draft file to read header and body from\n\
2834 -i <file>\tspecify a file which Mutt should include in the body\n\
2835 -m <type>\tspecify a default mailbox type\n\
2836 @@ -254,6 +260,12 @@ static void show_version (void)
2849 @@ -522,6 +534,9 @@ init_extended_keys();
2850 #define M_NOSYSRC (1<<2) /* -n */
2851 #define M_RO (1<<3) /* -R */
2852 #define M_SELECT (1<<4) /* -y */
2854 +#define M_NEWS (1<<5) /* -g and -G */
2857 int main (int argc, char **argv)
2859 @@ -594,7 +609,11 @@ int main (int argc, char **argv)
2860 argv[nargc++] = argv[optind];
2864 + if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2866 if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2871 @@ -691,6 +710,20 @@ int main (int argc, char **argv)
2876 + case 'g': /* Specify a newsserver */
2878 + char buf[LONG_STRING];
2880 + snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2881 + commands = mutt_add_list (commands, buf);
2884 + case 'G': /* List of newsgroups */
2885 + flags |= M_SELECT | M_NEWS;
2892 @@ -978,6 +1011,18 @@ int main (int argc, char **argv)
2894 else if (flags & M_SELECT)
2897 + if (flags & M_NEWS)
2899 + set_option (OPTNEWS);
2900 + if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2902 + mutt_endwin (Errorbuf);
2909 mutt_endwin _("No incoming mailboxes defined.");
2911 @@ -993,6 +1038,15 @@ int main (int argc, char **argv)
2914 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2917 + if (option (OPTNEWS))
2919 + unset_option (OPTNEWS);
2920 + nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2924 mutt_expand_path (folder, sizeof (folder));
2926 mutt_str_replace (&CurrentFolder, folder);
2927 diff -udprP mutt-1.5.21.orig/mutt.h mutt-1.5.21/mutt.h
2928 --- mutt-1.5.21.orig/mutt.h 2010-09-13 20:19:55.000000000 +0300
2929 +++ mutt-1.5.21/mutt.h 2010-09-16 13:14:39.000000000 +0300
2930 @@ -229,6 +229,9 @@ enum
2938 /* Options for Mailcap lookup */
2940 @@ -285,6 +288,12 @@ enum
2943 OPT_VERIFYSIG, /* verify PGP signatures */
2946 + OPT_NNTPRECONNECT,
2948 + OPT_FOLLOWUPTOPOSTER,
2949 +#endif /* USE_NNTP */
2951 /* THIS MUST BE THE LAST VALUE. */
2953 @@ -300,6 +309,7 @@ enum
2954 #define SENDMAILX (1<<6)
2955 #define SENDKEY (1<<7)
2956 #define SENDRESEND (1<<8)
2957 +#define SENDNEWS (1<<9)
2959 /* flags to _mutt_select_file() */
2960 #define M_SEL_BUFFY (1<<0)
2961 @@ -319,6 +329,8 @@ enum
2970 @@ -397,6 +409,9 @@ enum
2975 + OPTMIMESUBJECT, /* encode subject line with RFC2047 */
2980 @@ -478,6 +493,16 @@ enum
2984 + /* news options */
2988 + OPTSHOWONLYUNREAD,
2992 +#endif /* USE_NNTP */
2994 /* pseudo options */
2996 OPTAUXSORT, /* (pseudo) using auxillary sort function */
2997 @@ -498,6 +523,7 @@ enum
2998 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
2999 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3000 OPTATTACHMSG, /* (pseudo) used by attach-message */
3001 + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3002 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3003 * functions while we are executing an
3005 @@ -508,6 +534,12 @@ enum
3006 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3007 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
3010 + OPTNEWS, /* (pseudo) used to change reader mode */
3011 + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3012 + OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
3018 @@ -587,6 +619,13 @@ typedef struct envelope
3022 + char *organization;
3026 + char *followup_to;
3027 + char *x_comment_to;
3030 LIST *references; /* message references (in reverse order) */
3031 LIST *in_reply_to; /* in-reply-to header content */
3032 @@ -756,6 +795,9 @@ typedef struct header
3033 ENVELOPE *env; /* envelope information */
3034 BODY *content; /* list of MIME parts */
3040 char *tree; /* character string to print thread tree */
3042 @@ -771,7 +813,7 @@ typedef struct header
3043 int refno; /* message number on server */
3046 -#if defined USE_POP || defined USE_IMAP
3047 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3048 void *data; /* driver-specific data */
3051 diff -udprP mutt-1.5.21.orig/muttlib.c mutt-1.5.21/muttlib.c
3052 --- mutt-1.5.21.orig/muttlib.c 2010-08-25 19:31:40.000000000 +0300
3053 +++ mutt-1.5.21/muttlib.c 2010-09-16 13:14:39.000000000 +0300
3054 @@ -337,7 +337,7 @@ void mutt_free_header (HEADER **h)
3056 mutt_free_list (&(*h)->chain);
3058 -#if defined USE_POP || defined USE_IMAP
3059 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3062 FREE (h); /* __FREE_CHECKED__ */
3063 @@ -722,6 +722,13 @@ void mutt_free_envelope (ENVELOPE **p)
3064 FREE (&(*p)->supersedes);
3066 FREE (&(*p)->x_label);
3067 + FREE (&(*p)->organization);
3069 + FREE (&(*p)->newsgroups);
3070 + FREE (&(*p)->xref);
3071 + FREE (&(*p)->followup_to);
3072 + FREE (&(*p)->x_comment_to);
3075 mutt_buffer_free (&(*p)->spam);
3077 @@ -1525,6 +1532,14 @@ int mutt_save_confirm (const char *s, st
3082 + if (magic == M_NNTP)
3084 + mutt_error _("Can't save message to newsserver.");
3089 if (stat (s, st) != -1)
3092 diff -udprP mutt-1.5.21.orig/mx.c mutt-1.5.21/mx.c
3093 --- mutt-1.5.21.orig/mx.c 2010-09-13 20:19:55.000000000 +0300
3094 +++ mutt-1.5.21/mx.c 2010-09-16 13:14:39.000000000 +0300
3095 @@ -343,6 +343,22 @@ int mx_is_pop (const char *p)
3100 +int mx_is_nntp (const char *p)
3102 + url_scheme_t scheme;
3107 + scheme = url_check_scheme (p);
3108 + if (scheme == U_NNTP || scheme == U_NNTPS)
3115 int mx_get_magic (const char *path)
3118 @@ -360,6 +376,11 @@ int mx_get_magic (const char *path)
3120 #endif /* USE_POP */
3123 + if (mx_is_nntp (path))
3125 +#endif /* USE_NNTP */
3127 if (stat (path, &st) == -1)
3129 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
3130 @@ -668,6 +689,12 @@ CONTEXT *mx_open_mailbox (const char *pa
3132 #endif /* USE_POP */
3136 + rc = nntp_open_mailbox (ctx);
3138 +#endif /* USE_NNTP */
3143 @@ -764,6 +791,12 @@ static int sync_mailbox (CONTEXT *ctx, i
3144 rc = pop_sync_mailbox (ctx, index_hint);
3146 #endif /* USE_POP */
3150 + rc = nntp_sync_mailbox (ctx);
3152 +#endif /* USE_NNTP */
3156 @@ -790,6 +823,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
3161 + if (ctx->magic == M_NNTP)
3165 + ret = nntp_close_mailbox (ctx);
3166 + mx_fastclose_mailbox (ctx);
3170 if (ctx->readonly || ctx->dontwrite)
3172 /* mailbox is readonly or we don't want to write */
3173 @@ -1341,6 +1384,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
3175 return (pop_check_mailbox (ctx, index_hint));
3176 #endif /* USE_POP */
3180 + return (nntp_check_mailbox (ctx));
3181 +#endif /* USE_NNTP */
3185 @@ -1401,6 +1449,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
3187 #endif /* USE_POP */
3192 + if (nntp_fetch_message (msg, ctx, msgno) != 0)
3196 +#endif /* USE_NNTP */
3199 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3201 @@ -1476,6 +1533,9 @@ int mx_close_message (MESSAGE **msg)
3204 if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR
3206 + || (*msg)->magic == M_NNTP
3208 || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP)
3210 r = safe_fclose (&(*msg)->fp);
3211 diff -udprP mutt-1.5.21.orig/mx.h mutt-1.5.21/mx.h
3212 --- mutt-1.5.21.orig/mx.h 2009-08-25 22:08:52.000000000 +0300
3213 +++ mutt-1.5.21/mx.h 2010-09-16 13:14:39.000000000 +0300
3214 @@ -34,6 +34,9 @@ enum
3224 diff -udprP mutt-1.5.21.orig/newsrc.c mutt-1.5.21/newsrc.c
3225 --- mutt-1.5.21.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3226 +++ mutt-1.5.21/newsrc.c 2010-09-16 13:14:39.000000000 +0300
3229 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3230 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
3231 + * Copyright (C) 2000-2009 Vsevolod Volkov <vvv@mutt.org.ua>
3233 + * This program is free software; you can redistribute it and/or modify
3234 + * it under the terms of the GNU General Public License as published by
3235 + * the Free Software Foundation; either version 2 of the License, or
3236 + * (at your option) any later version.
3238 + * This program is distributed in the hope that it will be useful,
3239 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3240 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3241 + * GNU General Public License for more details.
3243 + * You should have received a copy of the GNU General Public License
3244 + * along with this program; if not, write to the Free Software
3245 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3249 +# include "config.h"
3253 +#include "mutt_curses.h"
3257 +#include "mailbox.h"
3259 +#include "rfc822.h"
3260 +#include "rfc1524.h"
3261 +#include "rfc2047.h"
3263 +#include <unistd.h>
3264 +#include <string.h>
3266 +#include <stdlib.h>
3267 +#include <sys/stat.h>
3269 +void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3276 + l = safe_calloc (1, sizeof (LIST));
3278 + s->tail->next = l;
3282 + l->data = (void *) d;
3285 +static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3288 + char group[LONG_STRING];
3290 + char *p = line, *b, *h;
3300 + while (*p && (*p != ':' && *p != '!')) p++;
3303 + len = p + 1 - line;
3304 + if (len > sizeof (group))
3305 + len = sizeof (group);
3306 + strfcpy (group, line, len);
3307 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3309 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3310 + data->group = (char *) data + sizeof (NNTP_DATA);
3311 + strcpy (data->group, group);
3312 + data->nserv = news;
3313 + data->deleted = 1;
3314 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3315 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
3316 + hash_insert (news->newsgroups, data->group, data, 0);
3317 + nntp_add_to_list (news, data);
3320 + FREE ((void **) &data->entries);
3323 + data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3327 + data->subscribed = 1;
3329 + data->subscribed = 0;
3336 + while (*p && *p != ',' && *p != '\n') p++;
3342 + if ((h = strchr(b, '-')))
3346 + data->entries[x].first = atoi(b);
3347 + data->entries[x].last = atoi(h);
3351 + data->entries[x].first = atoi(b);
3352 + data->entries[x].last = data->entries[x].first;
3355 + if (data->entries[x].last != 0)
3358 + if (x && !data->lastMessage)
3359 + data->lastMessage = data->entries[x-1].last;
3361 + mutt_newsgroup_stat (data);
3362 + dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3367 +static int slurp_newsrc (NNTP_SERVER *news)
3373 + news->stat = stat (news->newsrc, &sb);
3374 + news->size = sb.st_size;
3375 + news->mtime = sb.st_mtime;
3377 + if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3379 + /* hmm, should we use dotlock? */
3380 + if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3386 + buf = safe_malloc (sb.st_size + 1);
3387 + while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3388 + nntp_parse_newsrc_line (news, buf);
3391 + mx_unlock_file (news->newsrc, fileno (fp), 0);
3396 +void nntp_cache_expand (char *dst, const char *src)
3398 + snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3399 + mutt_expand_path (dst, _POSIX_PATH_MAX);
3402 +/* Loads $news_cache_dir/.index into memory, loads newsserver data
3403 + * and newsgroup cache names */
3404 +static int nntp_parse_cacheindex (NNTP_SERVER *news)
3407 + char buf[HUGE_STRING], *cp;
3408 + char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3413 + /* check is server name defined or not */
3414 + if (!news || !news->conn || !news->conn->account.host)
3416 + unset_option (OPTNEWSCACHE);
3417 + if (!NewsCacheDir || !*NewsCacheDir)
3420 + strfcpy (dir, NewsCacheDir, sizeof (dir));
3421 + mutt_expand_path (dir, sizeof(dir));
3423 + if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3425 + snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3426 + if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3429 + mutt_error _("Cache directory not created!");
3432 + mutt_clear_error();
3435 + set_option (OPTNEWSCACHE);
3437 + FREE (&news->cache);
3438 + snprintf (buf, sizeof(buf), "%s/.index", dir);
3439 + if (!(index = safe_fopen (buf, "a+")))
3442 + while (fgets (buf, sizeof(buf), index))
3444 + buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3445 + if (!mutt_strncmp (buf, "#: ", 3) &&
3446 + !mutt_strcasecmp (buf+3, news->conn->account.host))
3449 + while (fgets (buf, sizeof(buf), index))
3452 + while (*cp && *cp != ' ') cp++;
3453 + if (!*cp) continue;
3455 + if (!mutt_strcmp (buf, "#:"))
3457 + sscanf (cp + 1, "%s %d %d", file, &l, &m);
3458 + if (!mutt_strcmp (buf, "ALL"))
3460 + news->cache = safe_strdup (file);
3461 + news->newgroups_time = m;
3463 + else if (news->newsgroups)
3465 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3467 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3468 + data->group = (char *) data + sizeof (NNTP_DATA);
3469 + strcpy(data->group, buf);
3470 + data->nserv = news;
3471 + data->deleted = 1;
3472 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3473 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
3474 + hash_insert (news->newsgroups, data->group, data, 0);
3475 + nntp_add_to_list (news, data);
3477 + data->cache = safe_strdup (file);
3479 + if (!data->firstMessage || data->lastMessage < m)
3481 + if (!data->firstMessage)
3482 + data->firstMessage = l;
3483 + if (data->lastMessage < m)
3484 + data->lastMessage = m;
3485 + data->lastCached = m;
3486 + if (t || !data->unread)
3487 + mutt_newsgroup_stat (data);
3495 +nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
3496 + const char *fmt, const char *ifstring, const char *elsestring,
3497 + unsigned long data, format_flag flags)
3499 + char fn[SHORT_STRING], tmp[SHORT_STRING];
3504 + strncpy (fn, NewsServer, sizeof(fn) - 1);
3505 + mutt_strlower (fn);
3506 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3507 + snprintf (dest, destlen, tmp, fn);
3513 +/* nntp_parse_url: given an NNPT URL, return host, port,
3514 + * username, password and newsgroup will recognise. */
3515 +int nntp_parse_url (const char *server, ACCOUNT *acct,
3516 + char *group, size_t group_len)
3524 + acct->port = NNTP_PORT;
3525 + acct->type = M_ACCT_TYPE_NNTP;
3527 + c = safe_strdup (server);
3528 + url_parse_ciss (&url, c);
3530 + if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3532 + if (url.scheme == U_NNTPS)
3534 + acct->flags |= M_ACCT_SSL;
3535 + acct->port = NNTP_SSL_PORT;
3540 + strfcpy (group, url.path, group_len);
3542 + ret = mutt_account_fromurl (acct, &url);
3549 +void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3553 + url.path = safe_strdup (line);
3554 + mutt_account_tourl (acct, &url);
3555 + url_ciss_tostring (&url, line, len, 0);
3560 + * Automatically loads a newsrc into memory, if necessary.
3561 + * Checks the size/mtime of a newsrc file, if it doesn't match, load
3562 + * again. Hmm, if a system has broken mtimes, this might mean the file
3563 + * is reloaded every time, which we'd have to fix.
3565 + * a newsrc file is a line per newsgroup, with the newsgroup, then a
3566 + * ':' denoting subscribed or '!' denoting unsubscribed, then a
3567 + * comma separated list of article numbers and ranges.
3569 +NNTP_SERVER *mutt_select_newsserver (char *server)
3571 + char file[_POSIX_PATH_MAX];
3575 + NNTP_SERVER *serv;
3578 + if (!server || !*server)
3580 + mutt_error _("No newsserver defined!");
3584 + buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3585 + if (url_check_scheme (server) == U_UNKNOWN)
3587 + strcpy (buf, "news://");
3588 + p = strchr (buf, '\0');
3590 + strcpy (p, server);
3592 + if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3595 + mutt_error (_("%s is an invalid newsserver specification!"), server);
3600 + conn = mutt_conn_find (NULL, &acct);
3604 + mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), nntp_format_str, 0, 0);
3605 + mutt_expand_path (file, sizeof (file));
3607 + serv = (NNTP_SERVER *)conn->data;
3612 + /* externally modified? */
3613 + if (serv->stat != stat (file, &sb) || (!serv->stat &&
3614 + (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3616 + for (list = serv->list; list; list = list->next)
3618 + NNTP_DATA *data = (NNTP_DATA *) list->data;
3622 + data->subscribed = 0;
3627 + slurp_newsrc (serv);
3628 + nntp_clear_cacheindex (serv);
3631 + if (serv->status == NNTP_BYE)
3632 + serv->status = NNTP_NONE;
3633 + nntp_check_newgroups (serv, 0);
3637 + /* New newsserver */
3638 + serv = safe_calloc (1, sizeof (NNTP_SERVER));
3639 + serv->conn = conn;
3640 + serv->newsrc = safe_strdup (file);
3641 + serv->newsgroups = hash_create (1009, 0);
3642 + slurp_newsrc (serv); /* load .newsrc */
3643 + nntp_parse_cacheindex (serv); /* load .index */
3644 + if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3645 + nntp_check_newgroups (serv, 1);
3646 + else if (nntp_get_active (serv) < 0)
3648 + hash_destroy (&serv->newsgroups, nntp_delete_data);
3649 + for (list = serv->list; list; list = list->next)
3650 + list->data = NULL;
3651 + mutt_free_list (&serv->list);
3652 + FREE (&serv->newsrc);
3653 + FREE (&serv->cache);
3657 + nntp_clear_cacheindex (serv);
3658 + conn->data = (void *)serv;
3664 + * full status flags are not supported by nntp, but we can fake some
3665 + * of them. This is how:
3666 + * Read = a read message number is in the .newsrc
3667 + * New = a message is new since we last read this newsgroup
3668 + * Old = anything else
3669 + * So, Read is marked as such in the newsrc, old is anything that is
3670 + * "skipped" in the newsrc, and new is anything not in the newsrc nor
3671 + * in the cache. By skipped, I mean before the last unread message
3673 +void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3675 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3679 + data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3685 + dprint (3, (debugfile, "newsgroup %s not found\n", group));
3690 + for (x = 0; x < data->num; x++)
3692 + if ((article >= data->entries[x].first) &&
3693 + (article <= data->entries[x].last))
3695 + /* we cannot use mutt_set_flag() because mx_update_context()
3696 + didn't called yet */
3701 + /* If article was not cached yet, it is new! :) */
3702 + if (!data->cache || article > data->lastCached)
3704 + /* Old articles are articles which aren't read but an article after them
3705 + * has been cached */
3706 + if (option (OPTMARKOLD))
3710 +void mutt_newsgroup_stat (NNTP_DATA *data)
3713 + unsigned int first, last;
3716 + if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3719 + data->unread = data->lastMessage - data->firstMessage + 1;
3720 + for (i = 0; i < data->num; i++)
3722 + first = data->entries[i].first;
3723 + if (first < data->firstMessage)
3724 + first = data->firstMessage;
3725 + last = data->entries[i].last;
3726 + if (last > data->lastMessage)
3727 + last = data->lastMessage;
3728 + if (first <= last)
3729 + data->unread -= last - first + 1;
3733 +static int puti (char *line, int num)
3737 + for (p = s; num; )
3739 + *p++ = '0' + num % 10;
3743 + *line++ = *--p, num++;
3748 +static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3750 + char *line = *pline;
3751 + size_t len = *buflen - (*pline - *buf);
3754 + if (len < LONG_STRING * 10)
3759 + safe_realloc (buf, *buflen);
3760 + line = *buf + (*pline - line);
3762 + strcpy (line, data->group);
3763 + len -= strlen (line) + 1;
3764 + line += strlen (line);
3765 + *line++ = data->subscribed ? ':' : '!';
3769 + for (x = 0; x < data->num; x++)
3771 + if (len < LONG_STRING)
3777 + safe_realloc (buf, *buflen);
3778 + line = *buf + (*pline - line);
3787 + if (data->entries[x].first == data->entries[x].last)
3788 + snprintf (line, len, "%d%n", data->entries[x].first, &i);
3790 + snprintf (line, len, "%d-%d%n",
3791 + data->entries[x].first, data->entries[x].last, &i);
3795 + i = puti (line, data->entries[x].first);
3796 + line +=i; len -= i;
3797 + if (data->entries[x].first != data->entries[x].last)
3801 + i = puti (line, data->entries[x].last);
3802 + line +=i; len -= i;
3811 +void newsrc_gen_entries (CONTEXT *ctx)
3813 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3815 + unsigned int last = 0, first = 1;
3816 + int save_sort = SORT_ORDER;
3818 + if (Sort != SORT_ORDER)
3821 + Sort = SORT_ORDER;
3822 + mutt_sort_headers (ctx, 0);
3827 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3832 + * Set up to fake initial sequence from 1 to the article before the
3833 + * first article in our list
3838 + for (x = 0; x < ctx->msgcount; x++)
3840 + if (series) /* search for first unread */
3843 + * We don't actually check sequential order, since we mark
3844 + * "missing" entries as read/deleted
3846 + last = ctx->hdrs[x]->article_num;
3847 + if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3848 + !ctx->hdrs[x]->read)
3850 + if (data->num >= data->max)
3852 + data->max = data->max * 2;
3853 + safe_realloc (&data->entries,
3854 + data->max * sizeof (NEWSRC_ENTRY));
3856 + data->entries[data->num].first = first;
3857 + data->entries[data->num].last = last - 1;
3862 + else /* search for first read */
3864 + if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3869 + last = ctx->hdrs[x]->article_num;
3872 + if (series && first <= data->lastLoaded)
3874 + if (data->num >= data->max)
3876 + data->max = data->max * 2;
3877 + safe_realloc (&data->entries,
3878 + data->max * sizeof (NEWSRC_ENTRY));
3880 + data->entries[data->num].first = first;
3881 + data->entries[data->num].last = data->lastLoaded;
3885 + if (save_sort != Sort)
3888 + mutt_sort_headers (ctx, 0);
3892 +static int mutt_update_list_file (char *filename, char *section,
3893 + char *key, char *line)
3897 + char buf[HUGE_STRING];
3898 + char tmpfile[_POSIX_PATH_MAX];
3900 + int ext = 0, done = 0, r = 0;
3902 + /* if file not exist, create it */
3903 + if ((ifp = safe_fopen (filename, "a")))
3905 + dprint (1, (debugfile, "Opening %s\n", filename));
3906 + if (!(ifp = safe_fopen (filename, "r")))
3908 + mutt_error (_("Unable to open %s for reading"), filename);
3911 + if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3914 + mutt_error (_("Unable to lock %s"), filename);
3917 + snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3918 + dprint (1, (debugfile, "Opening %s\n", tmpfile));
3919 + if (!(ofp = fopen (tmpfile, "w")))
3922 + mutt_error (_("Unable to open %s for writing"), tmpfile);
3928 + while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3930 + r = fputs (buf, ofp);
3932 + while (*c && *c != '\n') c++;
3933 + c[0] = 0; /* strip EOL */
3934 + if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3937 + if (r != EOF && !done)
3939 + snprintf (buf, sizeof(buf), "#: %s\n", section);
3940 + r = fputs (buf, ofp);
3945 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3950 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3952 + if (*c != '\\') ext = 0;
3954 + else if ((section && !strncmp (buf, "#: ", 3)))
3956 + if (!done && line)
3958 + fputs (line, ofp);
3959 + fputc ('\n', ofp);
3961 + r = fputs (buf, ofp);
3965 + else if (key && !strncmp (buf, key, strlen(key)) &&
3966 + (!*key || buf[strlen(key)] == ' '))
3970 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3972 + if (*c == '\\') ext = 1;
3973 + if (!done && line)
3975 + r = fputs (line, ofp);
3977 + r = fputc ('\n', ofp);
3983 + r = fputs (buf, ofp);
3987 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3988 + r = fputs (buf, ofp);
3990 + /* If there wasn't a line to replace, put it on the end of the file */
3991 + if (r != EOF && !done && line)
3993 + fputs (line, ofp);
3994 + r = fputc ('\n', ofp);
3996 + mx_unlock_file (filename, fileno (ifp), 0);
4002 + mutt_error (_("Can't write %s"), tmpfile);
4005 + if (rename (tmpfile, filename) < 0)
4008 + mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
4014 +int mutt_newsrc_update (NNTP_SERVER *news)
4024 + llen = len = 10 * LONG_STRING;
4025 + line = buf = safe_calloc (1, len);
4026 + /* we will generate full newsrc here */
4027 + for (tmp = news->list; tmp; tmp = tmp->next)
4029 + data = (NNTP_DATA *) tmp->data;
4030 + if (!data || !data->rc)
4032 + nntp_create_newsrc_line (data, &buf, &line, &llen);
4034 + dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4035 + line += strlen (line);
4037 + /* newrc being fully rewritten */
4038 + if (news->newsrc &&
4039 + (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4043 + stat (news->newsrc, &st);
4044 + news->size = st.st_size;
4045 + news->mtime = st.st_mtime;
4051 +static FILE *mutt_mkname (char *s)
4053 + char buf[_POSIX_PATH_MAX], *pc;
4057 + nntp_cache_expand (buf, s);
4058 + if ((fp = safe_fopen (buf, "w")))
4061 + nntp_cache_expand (buf, "cache-XXXXXX");
4062 + pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4063 + if ((fd = mkstemp (buf)) == -1)
4065 + strcpy (s, pc); /* generated name */
4066 + return fdopen (fd, "w");
4069 +/* Updates info into .index file: ALL or about selected newsgroup */
4070 +static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4072 + char buf[LONG_STRING], *key = "ALL";
4073 + char file[_POSIX_PATH_MAX];
4075 + if (!serv || !serv->conn || !serv->conn->account.host)
4078 + if (data && data->group)
4080 + key = data->group;
4081 + snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4082 + data->firstMessage, data->lastLoaded);
4086 + strfcpy (file, serv->cache, sizeof (file));
4087 + snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4089 + nntp_cache_expand (file, ".index");
4090 + return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4093 +/* Remove cache files of unsubscribed newsgroups */
4094 +void nntp_clear_cacheindex (NNTP_SERVER *news)
4099 + if (option (OPTSAVEUNSUB) || !news)
4102 + for (tmp = news->list; tmp; tmp = tmp->next)
4104 + data = (NNTP_DATA *) tmp->data;
4105 + if (!data || data->subscribed || !data->cache)
4107 + nntp_delete_cache (data);
4108 + dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4113 +int nntp_save_cache_index (NNTP_SERVER *news)
4115 + char buf[HUGE_STRING];
4116 + char file[_POSIX_PATH_MAX];
4121 + if (!news || !news->newsgroups)
4123 + if (!option (OPTNEWSCACHE))
4128 + nntp_cache_expand (file, news->cache);
4130 + f = safe_fopen (file, "w");
4134 + strfcpy (buf, news->conn->account.host, sizeof(buf));
4135 + f = mutt_mkname (buf);
4136 + news->cache = safe_strdup (buf);
4137 + nntp_cache_expand (file, buf);
4142 + for (l = news->list; l; l = l->next)
4144 + if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4147 + snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4148 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4151 + snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4152 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4153 + if (fputs (buf, f) == EOF)
4163 + if (nntp_update_cacheindex (news, NULL))
4171 +int nntp_save_cache_group (CONTEXT *ctx)
4173 + char buf[HUGE_STRING], addr[STRING];
4174 + char file[_POSIX_PATH_MAX];
4178 + int i = 0, save = SORT_ORDER;
4181 + if (!option (OPTNEWSCACHE))
4183 + if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4186 + if (((NNTP_DATA *)ctx->data)->cache)
4188 + nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4190 + f = safe_fopen (file, "w");
4194 + snprintf (buf, sizeof(buf), "%s-%s",
4195 + ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4196 + ((NNTP_DATA *)ctx->data)->group);
4197 + f = mutt_mkname (buf);
4198 + ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4199 + nntp_cache_expand (file, buf);
4204 + if (Sort != SORT_ORDER)
4207 + Sort = SORT_ORDER;
4208 + mutt_sort_headers (ctx, 0);
4211 + /* Save only $nntp_context messages... */
4212 + ((NNTP_DATA *)ctx->data)->lastCached = 0;
4213 + if (NntpContext && ctx->msgcount > NntpContext)
4214 + i = ctx->msgcount - NntpContext;
4215 + for (; i < ctx->msgcount; i++)
4217 + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4221 + rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4222 + tm = gmtime (&h->date_sent);
4223 + snprintf (buf, sizeof(buf),
4224 + "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4225 + h->article_num, h->env->subject, addr, tm->tm_mday,
4226 + Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4227 + tm->tm_sec, h->env->message_id);
4229 + if (h->env->references)
4230 + mutt_write_references (h->env->references, f, -10);
4231 + snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length,
4232 + (int) h->lines, NONULL(h->env->xref));
4233 + if (fputs (buf, f) == EOF)
4240 + prev = ctx->hdrs[i]->article_num;
4246 + mutt_sort_headers (ctx, 0);
4250 + if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4251 + (NNTP_DATA *)ctx->data))
4256 + ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4260 +void nntp_delete_cache (NNTP_DATA *data)
4262 + char buf[_POSIX_PATH_MAX];
4264 + if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4267 + nntp_cache_expand (buf, data->cache);
4269 + FREE (&data->cache);
4270 + data->lastCached = 0;
4271 + nntp_cache_expand (buf, ".index");
4272 + mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4275 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4279 + if (!news || !news->newsgroups || !group || !*group)
4281 + if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4283 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4284 + data->group = (char *) data + sizeof (NNTP_DATA);
4285 + strcpy (data->group, group);
4286 + data->nserv = news;
4287 + data->deleted = 1;
4288 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4289 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
4290 + hash_insert (news->newsgroups, data->group, data, 0);
4291 + nntp_add_to_list (news, data);
4293 + if (!data->subscribed)
4295 + data->subscribed = 1;
4301 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4305 + if (!news || !news->newsgroups || !group || !*group ||
4306 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4308 + if (data->subscribed)
4310 + data->subscribed = 0;
4311 + if (!option (OPTSAVEUNSUB))
4317 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4321 + if (!news || !news->newsgroups || !group || !*group ||
4322 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4326 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4330 + data->entries[0].first = 1;
4332 + data->entries[0].last = data->lastMessage;
4333 + if (Context && Context->data == data)
4337 + for (x = 0; x < Context->msgcount; x++)
4338 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4343 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4347 + if (!news || !news->newsgroups || !group || !*group ||
4348 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4352 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4356 + data->entries[0].first = 1;
4357 + data->entries[0].last = data->firstMessage - 1;
4358 + if (Context && Context->data == data)
4362 + data->unread = Context->msgcount;
4363 + for (x = 0; x < Context->msgcount; x++)
4364 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4367 + data->unread = data->lastMessage - data->entries[0].last;
4371 +/* this routine gives the first newsgroup with new messages */
4372 +void nntp_buffy (char *s)
4376 + for (list = CurrentNewsSrv->list; list; list = list->next)
4378 + NNTP_DATA *data = (NNTP_DATA *) list->data;
4380 + if (data && data->subscribed && data->unread)
4382 + if (Context && Context->magic == M_NNTP &&
4383 + !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4385 + unsigned int i, unread = 0;
4387 + for (i = 0; i < Context->msgcount; i++)
4388 + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4393 + strcpy (s, data->group);
4398 diff -udprP mutt-1.5.21.orig/nntp.c mutt-1.5.21/nntp.c
4399 --- mutt-1.5.21.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4400 +++ mutt-1.5.21/nntp.c 2010-09-16 13:15:46.000000000 +0300
4403 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4404 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4405 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
4407 + * This program is free software; you can redistribute it and/or modify
4408 + * it under the terms of the GNU General Public License as published by
4409 + * the Free Software Foundation; either version 2 of the License, or
4410 + * (at your option) any later version.
4412 + * This program is distributed in the hope that it will be useful,
4413 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4414 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4415 + * GNU General Public License for more details.
4417 + * You should have received a copy of the GNU General Public License
4418 + * along with this program; if not, write to the Free Software
4419 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4423 +# include "config.h"
4427 +#include "mutt_curses.h"
4431 +#include "rfc1524.h"
4432 +#include "rfc2047.h"
4433 +#include "mailbox.h"
4444 +#include <unistd.h>
4445 +#include <string.h>
4447 +#include <stdlib.h>
4449 +static unsigned int _checked = 0;
4452 +static void nntp_error (const char *where, const char *msg)
4454 + dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4458 +static int nntp_auth (NNTP_SERVER *serv)
4460 + CONNECTION *conn = serv->conn;
4462 + unsigned char flags = conn->account.flags;
4464 + if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4465 + mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4467 + conn->account.flags = flags;
4471 + mutt_message _("Logging in...");
4473 + snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4474 + mutt_socket_write (conn, buf);
4475 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4477 + conn->account.flags = flags;
4482 + /* don't print the password unless we're at the ungodly debugging level */
4483 + if (debuglevel < M_SOCK_LOG_FULL)
4484 + dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4486 + snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4487 + mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4488 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4490 + conn->account.flags = flags;
4494 + if (mutt_strncmp ("281", buf, 3))
4496 + conn->account.flags = flags;
4497 + mutt_error _("Login failed.");
4505 +static int nntp_connect_error (NNTP_SERVER *serv)
4507 + serv->status = NNTP_NONE;
4508 + mutt_socket_close (serv->conn);
4509 + mutt_error _("Server closed connection!");
4514 +static int nntp_connect_and_auth (NNTP_SERVER *serv)
4516 + CONNECTION *conn = serv->conn;
4520 + serv->status = NNTP_NONE;
4522 + if (mutt_socket_open (conn) < 0)
4525 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4526 + return nntp_connect_error (serv);
4528 + if (!mutt_strncmp ("200", buf, 3))
4529 + mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4530 + else if (!mutt_strncmp ("201", buf, 3))
4531 + mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4534 + mutt_socket_close (conn);
4535 + mutt_remove_trailing_ws (buf);
4536 + mutt_error ("%s", buf);
4543 + /* Tell INN to switch to mode reader if it isn't so. Ignore all
4544 + returned codes and messages. */
4545 + mutt_socket_write (conn, "MODE READER\r\n");
4546 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4547 + return nntp_connect_error (serv);
4549 + mutt_socket_write (conn, "STAT\r\n");
4550 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4551 + return nntp_connect_error (serv);
4553 + if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
4555 + serv->status = NNTP_OK;
4559 + rc = nntp_auth (serv);
4561 + return nntp_connect_error (serv);
4564 + mutt_socket_close (conn);
4565 + serv->status = NNTP_BYE;
4570 + mutt_socket_close (conn);
4571 + mutt_error _("Login failed.");
4575 + serv->status = NNTP_OK;
4579 +static int nntp_attempt_features (NNTP_SERVER *serv)
4581 + char buf[LONG_STRING];
4582 + CONNECTION *conn = serv->conn;
4584 + mutt_socket_write (conn, "XOVER\r\n");
4585 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4586 + return nntp_connect_error (serv);
4587 + if (mutt_strncmp ("500", buf, 3))
4588 + serv->hasXOVER = 1;
4590 + mutt_socket_write (conn, "XPAT\r\n");
4591 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4592 + return nntp_connect_error (serv);
4593 + if (mutt_strncmp ("500", buf, 3))
4594 + serv->hasXPAT = 1;
4596 + mutt_socket_write (conn, "LISTGROUP\r\n");
4597 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4598 + return nntp_connect_error (serv);
4599 + if (mutt_strncmp ("500", buf, 3))
4600 + serv->hasLISTGROUP = 1;
4602 + mutt_socket_write (conn, "XGTITLE +\r\n");
4603 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4604 + return nntp_connect_error (serv);
4605 + if (mutt_strncmp ("500", buf, 3))
4606 + serv->hasXGTITLE = 1;
4608 + if (!mutt_strncmp ("282", buf, 3))
4612 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4613 + return nntp_connect_error (serv);
4614 + } while (!(buf[0] == '.' && buf[1] == '\0'));
4620 +static int nntp_open_connection (NNTP_SERVER *serv)
4622 + if (serv->status == NNTP_OK)
4624 + if (serv->status == NNTP_BYE)
4626 + if (nntp_connect_and_auth (serv) < 0)
4628 + if (nntp_attempt_features (serv) < 0)
4633 +static int nntp_reconnect (NNTP_SERVER *serv)
4635 + char buf[SHORT_STRING];
4637 + mutt_socket_close (serv->conn);
4641 + if (nntp_connect_and_auth (serv) == 0)
4644 + snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
4645 + serv->conn->account.host);
4646 + if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
4648 + serv->status = NNTP_BYE;
4654 +/* Send data from line[LONG_STRING] and receive answer to same line */
4655 +static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
4657 + char buf[LONG_STRING];
4660 + if (data->nserv->status == NNTP_BYE)
4667 + mutt_socket_write (data->nserv->conn, line);
4669 + else if (data->group)
4671 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4672 + mutt_socket_write (data->nserv->conn, buf);
4676 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4678 + if (nntp_reconnect (data->nserv) < 0)
4683 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4684 + mutt_socket_write (data->nserv->conn, buf);
4685 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4691 + else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
4695 + strfcpy (line, buf, linelen);
4700 + * This function calls funct(*line, *data) for each received line,
4701 + * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
4704 + * 1 - correct but not performed (may be, have to be continued),
4705 + * -1 - conection lost,
4706 + * -2 - invalid command or execution error,
4707 + * -3 - error in funct(*line, *data).
4709 +static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
4710 + int (*funct) (char *, void *), void *data, int tagged)
4712 + char buf[LONG_STRING];
4716 + size_t lenbuf = 0;
4721 + strfcpy (buf, query, sizeof (buf));
4722 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
4724 + if (buf[0] == '5')
4726 + if (buf[0] != '2')
4731 + inbuf = safe_malloc (sizeof (buf));
4735 + chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
4741 + if (!lenbuf && buf[0] == '.')
4743 + if (buf[1] == '\0')
4748 + if (buf[1] == '.')
4752 + strfcpy (inbuf + lenbuf, p, sizeof (buf));
4754 + if (chunk >= sizeof (buf))
4756 + lenbuf += strlen (p);
4761 + if (msg && ReadInc && (line % ReadInc == 0)) {
4763 + mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
4765 + mutt_message ("%s %d", msg, line);
4768 + if (ret == 0 && funct (inbuf, data) < 0)
4773 + safe_realloc (&inbuf, lenbuf + sizeof (buf));
4776 + funct (NULL, data);
4782 +static int nntp_read_tempfile (char *line, void *file)
4784 + FILE *f = (FILE *)file;
4791 + if (fputc ('\n', f) == EOF)
4797 +static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
4799 + register char *p, *b;
4800 + register char *colon = NULL;
4805 + /* skip to next word */
4807 + while (*b && ((*b == ' ') || (*b == '\t'))) b++;
4810 + /* skip to end of word */
4811 + while (*p && (*p != ' ') && (*p != '\t'))
4826 + nntp_get_status (ctx, h, b, atoi(colon));
4827 + if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
4828 + h->article_num = atoi(colon);
4836 + * 1 if article not found
4837 + * -1 if read or write error on tempfile or socket
4839 +static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
4841 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
4843 + char buf[LONG_STRING];
4844 + char tempfile[_POSIX_PATH_MAX];
4846 + HEADER *h = ctx->hdrs[ctx->msgcount];
4848 + mutt_mktemp (tempfile, sizeof(tempfile));
4849 + if (!(f = safe_fopen (tempfile, "w+")))
4853 + snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
4855 + snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
4857 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
4862 + dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
4865 + unlink (tempfile);
4866 + return (ret == -1 ? -1 : 1);
4869 + h->article_num = article_num;
4870 + h->env = mutt_read_rfc822_header (f, h, 0, 0);
4872 + unlink (tempfile);
4874 + if (h->env->xref != NULL)
4875 + nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
4876 + else if (h->article_num == 0 && msgid)
4878 + snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
4879 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
4880 + h->article_num = atoi (buf + 4);
4886 +static int parse_description (char *line, void *n)
4888 +#define news ((NNTP_SERVER *) n)
4889 + register char *d = line;
4894 + while (*d && *d != '\t' && *d != ' ') d++;
4897 + while (*d && (*d == '\t' || *d == ' ')) d++;
4898 + dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
4899 + if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
4900 + mutt_strcmp (d, data->desc))
4902 + FREE (&data->desc);
4903 + data->desc = safe_strdup (d);
4909 +static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
4913 + if (!option (OPTLOADDESC) || !data || !data->nserv)
4916 + /* Get newsgroup description, if we can */
4917 + if (data->nserv->hasXGTITLE)
4918 + snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
4920 + snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
4921 + if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
4924 + nntp_error ("nntp_get_desc()", buf);
4930 + * XOVER returns a tab separated list of:
4931 + * id|subject|from|date|Msgid|references|bytes|lines|xref
4933 + * This has to duplicate some of the functionality of
4934 + * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
4935 + * a limited number of headers which are "parsed" by placement in the list)
4937 +static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
4939 + NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
4943 + hdr->env = mutt_new_envelope();
4944 + hdr->env->newsgroups = safe_strdup (nntp_data->group);
4945 + hdr->content = mutt_new_body();
4946 + hdr->content->type = TYPETEXT;
4947 + hdr->content->subtype = safe_strdup ("plain");
4948 + hdr->content->encoding = ENC7BIT;
4949 + hdr->content->disposition = DISPINLINE;
4950 + hdr->content->length = -1;
4953 + for (x = 0; !done && x < 9; x++)
4955 + /* if from file, need to skip newline character */
4956 + while (*p && *p != '\n' && *p != '\t') p++;
4964 + hdr->article_num = atoi (b);
4965 + nntp_get_status (ctx, hdr, NULL, hdr->article_num);
4968 + hdr->env->subject = safe_strdup (b);
4969 + /* Now we need to do the things which would normally be done in
4970 + * mutt_read_rfc822_header() */
4971 + if (hdr->env->subject)
4973 + regmatch_t pmatch[1];
4975 + rfc2047_decode (&hdr->env->subject);
4977 + if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
4978 + hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
4980 + hdr->env->real_subj = hdr->env->subject;
4984 + rfc822_free_address (&hdr->env->from);
4985 + hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
4986 + rfc2047_decode_adrlist (hdr->env->from);
4989 + hdr->date_sent = mutt_parse_date (b, hdr);
4990 + hdr->received = hdr->date_sent;
4993 + FREE (&hdr->env->message_id);
4994 + hdr->env->message_id = safe_strdup (b);
4997 + mutt_free_list (&hdr->env->references);
4998 + hdr->env->references = mutt_parse_references (b, 0);
5001 + hdr->content->length = atoi (b);
5004 + hdr->lines = atoi (b);
5008 + FREE (&hdr->env->xref);
5009 + b = b + 6; /* skips the "Xref: " */
5010 + hdr->env->xref = safe_strdup (b);
5011 + nntp_parse_xref (ctx, nntp_data->group, b, hdr);
5023 + unsigned int base;
5024 + unsigned int first;
5025 + unsigned int last;
5026 + unsigned short *messages;
5030 +#define fc ((FETCH_CONTEXT *) c)
5031 +static int nntp_fetch_numbers (char *line, void *c)
5037 + num = atoi (line);
5038 + if (num < fc->base || num > fc->last)
5040 + fc->messages[num - fc->base] = 1;
5044 +static int add_xover_line (char *line, void *c)
5046 + unsigned int num, total;
5047 + CONTEXT *ctx = fc->ctx;
5048 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5053 + if (ctx->msgcount >= ctx->hdrmax)
5054 + mx_alloc_memory (ctx);
5055 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5056 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5058 + nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5059 + num = ctx->hdrs[ctx->msgcount]->article_num;
5061 + if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5064 + if (num > data->lastLoaded)
5065 + data->lastLoaded = num;
5066 + num = num - fc->first + 1;
5067 + total = fc->last - fc->first + 1;
5068 + if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5069 + mutt_message ("%s %d/%d", fc->msg, num, total);
5072 + mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5078 +static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5079 + unsigned int last)
5081 + char buf[HUGE_STRING];
5082 + char *msg = _("Fetching message headers...");
5083 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5087 + unsigned int current;
5091 + /* if empty group or nothing to do */
5092 + if (!last || first > last)
5095 + /* fetch list of articles */
5099 + fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5100 + if (nntp_data->nserv->hasLISTGROUP)
5102 + mutt_message _("Fetching list of articles...");
5103 + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5104 + if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5106 + mutt_error (_("LISTGROUP command failed: %s"), buf);
5108 + nntp_error ("nntp_fetch_headers()", buf);
5110 + FREE (&fc.messages);
5116 + for (num = 0; num < last - first + 1; num++)
5117 + fc.messages[num] = 1;
5120 + /* CACHE: must be loaded xover cache here */
5121 + num = nntp_data->lastCached - first + 1;
5122 + if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5124 + nntp_cache_expand (buf, nntp_data->cache);
5125 + mutt_message _("Fetching headers from cache...");
5126 + if ((f = safe_fopen (buf, "r")))
5130 + /* counting number of lines */
5131 + while (fgets (buf, sizeof (buf), f) != NULL)
5134 + while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5136 + oldmsgcount = ctx->msgcount;
5138 + fc.last = first + num - 1;
5140 + while (fgets (buf, sizeof (buf), f) != NULL)
5141 + add_xover_line (buf, &fc);
5143 + nntp_data->lastLoaded = fc.last;
5144 + first = fc.last + 1;
5145 + if (ctx->msgcount > oldmsgcount)
5146 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5149 + nntp_delete_cache (nntp_data);
5151 + num = last - first + 1;
5154 + FREE (&fc.messages);
5159 + * Without XOVER, we have to fetch each article header and parse
5160 + * it. With XOVER, we ask for all of them
5162 + mutt_message (msg);
5163 + if (nntp_data->nserv->hasXOVER)
5165 + oldmsgcount = ctx->msgcount;
5169 + snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5170 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5171 + if (ctx->msgcount > oldmsgcount)
5172 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5175 + mutt_error (_("XOVER command failed: %s"), buf);
5177 + nntp_error ("nntp_fetch_headers()", buf);
5179 + FREE (&fc.messages);
5185 + for (current = first; current <= last; current++)
5189 + ret = current - first + 1;
5190 + mutt_message ("%s %d/%d", msg, ret, num);
5192 + if (!fc.messages[current - fc.base])
5195 + if (ctx->msgcount >= ctx->hdrmax)
5196 + mx_alloc_memory (ctx);
5197 + h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5198 + h->index = ctx->msgcount;
5200 + ret = nntp_read_header (ctx, NULL, current);
5201 + if (ret == 0) /* Got article. Fetch next header */
5203 + nntp_get_status (ctx, h, NULL, h->article_num);
5205 + mx_update_context (ctx, 1);
5208 + mutt_free_header (&h); /* skip it */
5211 + FREE (&fc.messages);
5215 + if (current > nntp_data->lastLoaded)
5216 + nntp_data->lastLoaded = current;
5218 + FREE (&fc.messages);
5219 + nntp_data->lastLoaded = last;
5220 + mutt_clear_error ();
5225 + * currently, nntp "mailbox" is "newsgroup"
5227 +int nntp_open_mailbox (CONTEXT *ctx)
5229 + NNTP_DATA *nntp_data;
5230 + NNTP_SERVER *serv;
5231 + char buf[HUGE_STRING];
5232 + char server[LONG_STRING];
5234 + unsigned int first;
5237 + if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5239 + mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5245 + nntp_expand_path (server, sizeof (server), &acct);
5246 + if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5249 + CurrentNewsSrv = serv;
5251 + /* create NNTP-specific state struct if nof found in list */
5252 + if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5254 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5255 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5256 + strcpy (nntp_data->group, buf);
5257 + hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5258 + nntp_add_to_list (serv, nntp_data);
5260 + ctx->data = nntp_data;
5261 + ctx->mx_close = nntp_fastclose_mailbox;
5262 + nntp_data->nserv = serv;
5264 + mutt_message (_("Selecting %s..."), nntp_data->group);
5266 + if (!nntp_data->desc)
5268 + nntp_get_desc (nntp_data, nntp_data->group, NULL);
5269 + if (nntp_data->desc)
5270 + nntp_save_cache_index (serv);
5274 + if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5277 + nntp_error ("nntp_open_mailbox()", buf);
5282 + if (mutt_strncmp ("211", buf, 3))
5284 + LIST *l = serv->list;
5286 + /* GROUP command failed */
5287 + if (!mutt_strncmp ("411", buf, 3))
5289 + mutt_error (_("Newsgroup %s not found on server %s"),
5290 + nntp_data->group, serv->conn->account.host);
5292 + /* CACHE: delete cache and line from .index */
5293 + nntp_delete_cache (nntp_data);
5294 + hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5295 + while (l && l->data != (void *) nntp_data) l = l->next;
5305 + sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5306 + &nntp_data->lastMessage, buf);
5308 + nntp_data->deleted = 0;
5310 + time (&serv->check_time);
5313 + * Check for max adding context. If it is greater than $nntp_context,
5314 + * strip off extra articles
5316 + first = nntp_data->firstMessage;
5317 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5318 + first = nntp_data->lastMessage - NntpContext + 1;
5320 + nntp_data->lastLoaded = first - 1;
5321 + return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5324 +int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5326 + char buf[LONG_STRING];
5327 + char path[_POSIX_PATH_MAX];
5328 + NNTP_CACHE *cache;
5329 + char *m = _("Fetching message...");
5332 + /* see if we already have the message in our cache */
5333 + cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5335 + /* if everything is fine, assign msg->fp and return */
5336 + if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5337 + (msg->fp = fopen (cache->path, "r")))
5340 + /* clear the previous entry */
5341 + unlink (cache->path);
5342 + free (cache->path);
5346 + cache->index = ctx->hdrs[msgno]->index;
5347 + mutt_mktemp (path, sizeof(path));
5348 + cache->path = safe_strdup (path);
5349 + if (!(msg->fp = safe_fopen (path, "w+")))
5351 + FREE (&cache->path);
5355 + if (ctx->hdrs[msgno]->article_num == 0)
5356 + snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5357 + ctx->hdrs[msgno]->env->message_id);
5359 + snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5360 + ctx->hdrs[msgno]->article_num);
5362 + ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5363 + msg->fp, ctx->tagged);
5366 + mutt_error (_("Article %d not found on server"),
5367 + ctx->hdrs[msgno]->article_num);
5368 + dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5375 + FREE (&cache->path);
5379 + mutt_free_envelope (&ctx->hdrs[msgno]->env);
5380 + ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5381 + /* fix content length */
5382 + fseek(msg->fp, 0, SEEK_END);
5383 + ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5384 + ctx->hdrs[msgno]->content->offset;
5386 + /* this is called in mutt before the open which fetches the message,
5387 + * which is probably wrong, but we just call it again here to handle
5388 + * the problem instead of fixing it.
5390 + mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5392 + /* These would normally be updated in mx_update_context(), but the
5393 + * full headers aren't parsed with XOVER, so the information wasn't
5396 +#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5397 + ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5398 +#endif /* HAVE_PGP || HAVE_SMIME */
5400 + mutt_clear_error();
5407 +int nntp_post (const char *msg) {
5408 + char buf[LONG_STRING];
5411 + NNTP_DATA *nntp_data;
5413 + if (Context && Context->magic == M_NNTP)
5414 + nntp_data = (NNTP_DATA *)Context->data;
5417 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5418 + !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5420 + mutt_error (_("Can't post article. No connection to news server."));
5423 + nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5426 + if (!(f = safe_fopen (msg, "r")))
5428 + mutt_error (_("Can't post article. Unable to open %s"), msg);
5432 + strfcpy (buf, "POST\r\n", sizeof (buf));
5433 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5435 + mutt_error (_("Can't post article. Connection to %s lost."),
5436 + nntp_data->nserv->conn->account.host);
5439 + if (buf[0] != '3')
5441 + mutt_error (_("Can't post article: %s"), buf);
5447 + while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5449 + len = strlen (buf);
5450 + if (buf[len - 1] == '\n')
5452 + buf[len - 1] = '\r';
5457 + if (buf[1] == '.')
5458 + mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5460 + mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5464 + if (buf[strlen (buf) - 1] != '\n')
5465 + mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5466 + mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5467 + if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5469 + mutt_error (_("Can't post article. Connection to %s lost."),
5470 + nntp_data->nserv->conn->account.host);
5473 + if (buf[0] != '2')
5475 + mutt_error (_("Can't post article: %s"), buf);
5482 +/* nntp_logout_all: close all open connections. */
5483 +void nntp_logout_all (void)
5485 + char buf[LONG_STRING];
5488 + conn = mutt_socket_head ();
5492 + CONNECTION *next = conn->next;
5494 + if (conn->account.type == M_ACCT_TYPE_NNTP)
5496 + mutt_message (_("Closing connection to %s..."), conn->account.host);
5497 + mutt_socket_write (conn, "QUIT\r\n");
5498 + mutt_socket_readln (buf, sizeof (buf), conn);
5499 + mutt_clear_error ();
5500 + mutt_socket_close (conn);
5501 + mutt_socket_free (conn);
5508 +static void nntp_free_acache (NNTP_DATA *data)
5512 + for (i = 0; i < NNTP_CACHE_LEN; i++)
5514 + if (data->acache[i].path)
5516 + unlink (data->acache[i].path);
5517 + FREE (&data->acache[i].path);
5522 +void nntp_delete_data (void *p)
5524 + NNTP_DATA *data = (NNTP_DATA *)p;
5528 + FREE (&data->entries);
5529 + FREE (&data->desc);
5530 + FREE (&data->cache);
5531 + nntp_free_acache (data);
5535 +int nntp_sync_mailbox (CONTEXT *ctx)
5537 + NNTP_DATA *data = ctx->data;
5539 + /* CACHE: update cache and .index files */
5540 + if ((option (OPTSAVEUNSUB) || data->subscribed))
5541 + nntp_save_cache_group (ctx);
5542 + nntp_free_acache (data);
5544 + data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
5548 +int nntp_fastclose_mailbox (CONTEXT *ctx)
5550 + NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
5554 + nntp_free_acache (data);
5555 + if (!data->nserv || !data->nserv->newsgroups || !data->group)
5557 + nntp_save_cache_index (data->nserv);
5558 + if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
5560 + nntp_delete_data (data);
5564 +/* commit changes and terminate connection */
5565 +int nntp_close_mailbox (CONTEXT *ctx)
5569 + mutt_message _("Quitting newsgroup...");
5572 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
5575 + if (data->nserv && data->nserv->conn && ctx->unread)
5577 + ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
5579 + mutt_newsgroup_catchup (data->nserv, data->group);
5584 + nntp_sync_mailbox (ctx);
5585 + if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
5587 + NNTP_SERVER *news;
5589 + news = ((NNTP_DATA *)ctx->data)->nserv;
5590 + newsrc_gen_entries (ctx);
5591 + ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
5592 + mutt_newsrc_update (news);
5594 + mutt_clear_error();
5598 +/* use the GROUP command to poll for new mail */
5599 +static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
5601 + char buf[LONG_STRING];
5604 + if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
5608 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5611 + nntp_error ("nntp_check_mailbox()", buf);
5615 + if (mutt_strncmp ("211", buf, 3))
5618 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5621 + nntp_error ("nntp_check_mailbox()", buf);
5626 + if (!mutt_strncmp ("211", buf, 3))
5631 + sscanf (buf + 4, "%d %d %d", &count, &first, &last);
5632 + nntp_data->firstMessage = first;
5633 + nntp_data->lastMessage = last;
5634 + if (ctx && last > nntp_data->lastLoaded)
5636 + nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
5637 + time (&nntp_data->nserv->check_time);
5640 + if (!last || (!nntp_data->rc && !nntp_data->lastCached))
5641 + nntp_data->unread = count;
5643 + mutt_newsgroup_stat (nntp_data);
5644 + /* active was renumbered? */
5645 + if (last < nntp_data->lastLoaded)
5647 + if (!nntp_data->max)
5649 + nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
5650 + nntp_data->max = 5;
5652 + nntp_data->lastCached = 0;
5653 + nntp_data->num = 1;
5654 + nntp_data->entries[0].first = 1;
5655 + nntp_data->entries[0].last = 0;
5659 + time (&nntp_data->nserv->check_time);
5663 +int nntp_check_mailbox (CONTEXT *ctx)
5665 + return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
5668 +static int add_group (char *buf, void *serv)
5670 +#define s ((NNTP_SERVER *) serv)
5671 + char group[LONG_STRING], mod, desc[HUGE_STRING];
5673 + NNTP_DATA *nntp_data;
5676 + _checked = n; /* _checked have N, where N = number of groups */
5677 + if (!buf) /* at EOF must be zerouth */
5684 + sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
5687 + if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
5690 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
5691 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5692 + strcpy (nntp_data->group, group);
5693 + nntp_data->nserv = s;
5694 + if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
5695 + s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2, 0);
5696 + hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
5697 + nntp_add_to_list (s, nntp_data);
5699 + nntp_data->deleted = 0;
5700 + nntp_data->firstMessage = first;
5701 + nntp_data->lastMessage = last;
5703 + nntp_data->allowed = 1;
5705 + nntp_data->allowed = 0;
5706 + if (nntp_data->desc)
5707 + FREE (&nntp_data->desc);
5709 + nntp_data->desc = safe_strdup (desc);
5710 + if (nntp_data->rc || nntp_data->lastCached)
5711 + mutt_newsgroup_stat (nntp_data);
5712 + else if (nntp_data->lastMessage &&
5713 + nntp_data->firstMessage <= nntp_data->lastMessage)
5714 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
5716 + nntp_data->unread = 0;
5722 +int nntp_check_newgroups (NNTP_SERVER *serv, int force)
5724 + char buf[LONG_STRING];
5725 + char msg[SHORT_STRING];
5726 + NNTP_DATA nntp_data;
5731 + unsigned int count = 0;
5732 + unsigned int total = 0;
5734 + if (!serv || !serv->newgroups_time)
5737 + if (nntp_open_connection (serv) < 0)
5740 + /* check subscribed groups for new news */
5741 + if (option (OPTSHOWNEWNEWS))
5743 + mutt_message _("Checking for new messages...");
5744 + for (l = serv->list; l; l = l->next)
5746 + serv->check_time = 0; /* really check! */
5747 + if (l->data && ((NNTP_DATA *) l->data)->subscribed)
5748 + _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
5754 + mutt_message _("Checking for new newsgroups...");
5755 + now = serv->newgroups_time;
5756 + time (&serv->newgroups_time);
5757 + t = gmtime (&now);
5758 + snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
5759 + (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
5761 + nntp_data.nserv = serv;
5762 + if (Context && Context->magic == M_NNTP)
5763 + nntp_data.group = ((NNTP_DATA *)Context->data)->group;
5765 + nntp_data.group = NULL;
5767 + if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
5768 + add_group, serv, 0) != 0)
5771 + nntp_error ("nntp_check_newgroups()", buf);
5776 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5777 + mutt_message (msg);
5779 + emp.next = l->next;
5781 + emp.next = serv->list;
5786 + ((NNTP_DATA *) l->data)->new = 1;
5793 + nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
5795 + if (ReadInc && (count % ReadInc == 0))
5796 + mutt_message ("%s %d/%d", msg, count, total);
5799 + nntp_save_cache_index (serv);
5800 + mutt_clear_error ();
5804 +/* Load list of all newsgroups from cache ALL */
5805 +int nntp_get_cache_all (NNTP_SERVER *serv)
5807 + char buf[HUGE_STRING];
5810 + nntp_cache_expand (buf, serv->cache);
5811 + if ((f = safe_fopen (buf, "r")))
5815 + while (fgets (buf, sizeof(buf), f) != NULL)
5817 + if (ReadInc && (i % ReadInc == 0))
5818 + mutt_message (_("Loading list from cache... %d"), i);
5819 + add_group (buf, serv);
5822 + add_group (NULL, NULL);
5824 + mutt_clear_error ();
5829 + FREE (&serv->cache);
5834 +/* Load list of all newsgroups from active */
5835 +int nntp_get_active (NNTP_SERVER *serv)
5837 + char msg[SHORT_STRING];
5838 + NNTP_DATA nntp_data;
5841 + if (nntp_open_connection (serv) < 0)
5844 + snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
5845 + serv->conn->account.host);
5846 + mutt_message (msg);
5847 + time (&serv->newgroups_time);
5848 + nntp_data.nserv = serv;
5849 + nntp_data.group = NULL;
5851 + if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
5854 + nntp_error ("nntp_get_active()", "LIST\r\n");
5859 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5860 + mutt_message (msg);
5861 + nntp_get_desc (&nntp_data, "*", msg);
5863 + for (tmp = serv->list; tmp; tmp = tmp->next)
5865 + NNTP_DATA *data = (NNTP_DATA *)tmp->data;
5867 + if (data && data->deleted && !data->rc)
5869 + nntp_delete_cache (data);
5870 + hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
5874 + nntp_save_cache_index (serv);
5876 + mutt_clear_error ();
5881 + * returns -1 if error ocurred while retrieving header,
5882 + * number of articles which ones exist in context on success.
5884 +int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
5888 + /* if msgid is already in context, don't reload them */
5889 + if (hash_find (ctx->id_hash, msgid))
5891 + if (ctx->msgcount == ctx->hdrmax)
5892 + mx_alloc_memory (ctx);
5893 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5894 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5896 + mutt_message (_("Fetching %s from server..."), msgid);
5897 + ret = nntp_read_header (ctx, msgid, 0);
5898 + /* since nntp_read_header() may set read flag, we must reset it */
5899 + ctx->hdrs[ctx->msgcount]->read = 0;
5901 + mutt_free_header (&ctx->hdrs[ctx->msgcount]);
5905 + mx_update_context (ctx, 1);
5916 + unsigned int *child;
5919 +static int check_children (char *s, void *c)
5921 +#define cc ((CHILD_CONTEXT *) c)
5922 + unsigned int i, n;
5924 + if (!s || (n = atoi (s)) == 0)
5926 + for (i = 0; i < cc->ctx->msgcount; i++)
5927 + if (cc->ctx->hdrs[i]->article_num == n)
5929 + if (cc->num >= cc->max)
5930 + safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
5931 + cc->child[cc->num++] = n;
5937 +int nntp_check_children (CONTEXT *ctx, const char *msgid)
5939 + NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
5941 + int i, ret = 0, tmp = 0;
5944 + if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
5945 + !nntp_data->nserv->conn->account.host)
5947 + if (nntp_data->firstMessage > nntp_data->lastLoaded)
5949 + if (!nntp_data->nserv->hasXPAT)
5951 + mutt_error (_("Server %s does not support this operation!"),
5952 + nntp_data->nserv->conn->account.host);
5956 + snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
5957 + nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
5962 + cc.child = safe_malloc (sizeof (unsigned int) * 25);
5963 + if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
5968 + /* dont try to read the xover cache. check_children() already
5969 + * made sure that we dont have the article, so we need to visit
5970 + * the server. Reading the cache at this point is also bad
5971 + * because it would duplicate messages */
5972 + if (option (OPTNEWSCACHE))
5975 + unset_option (OPTNEWSCACHE);
5977 + for (i = 0; i < cc.num; i++)
5979 + if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
5981 + if (ctx->msgcount &&
5982 + ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
5983 + ctx->hdrs[ctx->msgcount - 1]->read = 0;
5986 + set_option (OPTNEWSCACHE);
5990 diff -udprP mutt-1.5.21.orig/nntp.h mutt-1.5.21/nntp.h
5991 --- mutt-1.5.21.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
5992 +++ mutt-1.5.21/nntp.h 2010-09-16 13:14:39.000000000 +0300
5995 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
5996 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
5997 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
5999 + * This program is free software; you can redistribute it and/or modify
6000 + * it under the terms of the GNU General Public License as published by
6001 + * the Free Software Foundation; either version 2 of the License, or
6002 + * (at your option) any later version.
6004 + * This program is distributed in the hope that it will be useful,
6005 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6006 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6007 + * GNU General Public License for more details.
6009 + * You should have received a copy of the GNU General Public License
6010 + * along with this program; if not, write to the Free Software
6011 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6017 +#include "mutt_socket.h"
6018 +#include "mailbox.h"
6022 +#define NNTP_PORT 119
6023 +#define NNTP_SSL_PORT 563
6025 +/* number of entries in the hash table */
6026 +#define NNTP_CACHE_LEN 10
6043 + unsigned int hasXPAT : 1;
6044 + unsigned int hasXGTITLE : 1;
6045 + unsigned int hasXOVER : 1;
6046 + unsigned int hasLISTGROUP : 1;
6047 + unsigned int status : 3;
6053 + time_t newgroups_time;
6054 + time_t check_time;
6056 + LIST *list; /* list of newsgroups */
6057 + LIST *tail; /* last entry of list */
6063 + unsigned int index;
6069 + NEWSRC_ENTRY *entries;
6070 + unsigned int num; /* number of used entries */
6071 + unsigned int max; /* number of allocated entries */
6072 + unsigned int unread;
6073 + unsigned int firstMessage;
6074 + unsigned int lastMessage;
6075 + unsigned int lastLoaded;
6076 + unsigned int lastCached;
6077 + unsigned int subscribed : 1;
6078 + unsigned int rc : 1;
6079 + unsigned int new : 1;
6080 + unsigned int allowed : 1;
6081 + unsigned int deleted : 1;
6085 + NNTP_SERVER *nserv;
6086 + NNTP_CACHE acache[NNTP_CACHE_LEN];
6089 +/* internal functions */
6090 +int nntp_get_active (NNTP_SERVER *);
6091 +int nntp_get_cache_all (NNTP_SERVER *);
6092 +int nntp_save_cache_index (NNTP_SERVER *);
6093 +int nntp_check_newgroups (NNTP_SERVER *, int);
6094 +int nntp_save_cache_group (CONTEXT *);
6095 +int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6096 +void newsrc_gen_entries (CONTEXT *);
6097 +void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6098 +void mutt_newsgroup_stat (NNTP_DATA *);
6099 +void nntp_delete_cache (NNTP_DATA *);
6100 +void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6101 +void nntp_cache_expand (char *, const char *);
6102 +void nntp_delete_data (void *);
6104 +/* exposed interface */
6105 +NNTP_SERVER *mutt_select_newsserver (char *);
6106 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6107 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6108 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6109 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6110 +void nntp_clear_cacheindex (NNTP_SERVER *);
6111 +int mutt_newsrc_update (NNTP_SERVER *);
6112 +int nntp_open_mailbox (CONTEXT *);
6113 +int nntp_sync_mailbox (CONTEXT *);
6114 +int nntp_check_mailbox (CONTEXT *);
6115 +int nntp_close_mailbox (CONTEXT *);
6116 +int nntp_fastclose_mailbox (CONTEXT *);
6117 +int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6118 +int nntp_post (const char *);
6119 +int nntp_check_msgid (CONTEXT *, const char *);
6120 +int nntp_check_children (CONTEXT *, const char *);
6121 +void nntp_buffy (char *);
6122 +void nntp_expand_path (char *, size_t, ACCOUNT *);
6123 +void nntp_logout_all ();
6124 +const char *nntp_format_str (char *, size_t, size_t, char, const char *, const char *,
6125 + const char *, const char *, unsigned long, format_flag);
6127 +NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6129 +#endif /* _NNTP_H_ */
6130 diff -udprP mutt-1.5.21.orig/pager.c mutt-1.5.21/pager.c
6131 --- mutt-1.5.21.orig/pager.c 2010-08-25 19:31:40.000000000 +0300
6132 +++ mutt-1.5.21/pager.c 2010-09-16 13:14:39.000000000 +0300
6133 @@ -1084,6 +1084,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
6143 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6144 int flags, ansi_attr *pa, int cnt,
6145 @@ -1540,6 +1545,16 @@ static struct mapping_t PagerHelpExtra[]
6150 +static struct mapping_t PagerNewsHelpExtra[] = {
6151 + { N_("Post"), OP_POST },
6152 + { N_("Followup"), OP_FOLLOWUP },
6153 + { N_("Del"), OP_DELETE },
6154 + { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6161 /* This pager is actually not so simple as it once was. It now operates in
6162 @@ -1581,6 +1596,10 @@ mutt_pager (const char *banner, const ch
6163 int old_PagerIndexLines; /* some people want to resize it
6164 * while inside the pager... */
6167 + char *followup_to;
6170 if (!(flags & M_SHOWCOLOR))
6171 flags |= M_SHOWFLAT;
6173 @@ -1620,7 +1639,11 @@ mutt_pager (const char *banner, const ch
6174 if (IsHeader (extra))
6176 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6177 - mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6178 + mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6180 + (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6183 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6186 @@ -2492,6 +2515,15 @@ search_next:
6188 CHECK_ACL(M_ACL_WRITE, "flag message");
6191 + if (Context->magic == M_NNTP)
6194 + mutt_error _("Can't change 'important' flag on NNTP server.");
6199 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6200 redraw = REDRAW_STATUS | REDRAW_INDEX;
6201 if (option (OPTRESOLVE))
6202 @@ -2525,6 +2557,60 @@ search_next:
6203 redraw = REDRAW_FULL;
6208 + CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6210 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6211 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6212 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6214 + ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6215 + redraw = REDRAW_FULL;
6218 + case OP_FORWARD_TO_GROUP:
6219 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6221 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6222 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6223 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6225 + if (IsMsgAttach (extra))
6226 + mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6227 + extra->idxlen, extra->bdy, SENDNEWS);
6229 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6230 + redraw = REDRAW_FULL;
6234 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6237 + if (IsMsgAttach (extra))
6238 + followup_to = extra->bdy->hdr->env->followup_to;
6240 + followup_to = extra->hdr->env->followup_to;
6242 + if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6243 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6245 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6246 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6247 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6249 + if (IsMsgAttach (extra))
6250 + mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6251 + extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6253 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6254 + extra->ctx, extra->hdr);
6255 + redraw = REDRAW_FULL;
6261 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6263 @@ -2571,7 +2657,7 @@ search_next:
6265 if (IsMsgAttach (extra))
6266 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6267 - extra->idxlen, extra->bdy);
6268 + extra->idxlen, extra->bdy, 0);
6270 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6271 redraw = REDRAW_FULL;
6272 diff -udprP mutt-1.5.21.orig/parse.c mutt-1.5.21/parse.c
6273 --- mutt-1.5.21.orig/parse.c 2009-08-25 22:08:52.000000000 +0300
6274 +++ mutt-1.5.21/parse.c 2010-09-16 13:14:39.000000000 +0300
6275 @@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
6279 -static LIST *mutt_parse_references (char *s, int in_reply_to)
6280 +LIST *mutt_parse_references (char *s, int in_reply_to)
6282 LIST *t, *lst = NULL;
6284 @@ -1067,6 +1067,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6285 e->from = rfc822_parse_adrlist (e->from, p);
6289 + else if (!mutt_strcasecmp (line+1, "ollowup-to"))
6291 + if (!e->followup_to)
6293 + mutt_remove_trailing_ws (p);
6294 + e->followup_to = safe_strdup (mutt_skip_whitespace (p));
6302 @@ -1149,6 +1160,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6308 + if (!mutt_strcasecmp (line + 1, "ewsgroups"))
6310 + FREE (&e->newsgroups);
6311 + mutt_remove_trailing_ws (p);
6312 + e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
6319 + /* field `Organization:' saves only for pager! */
6320 + if (!mutt_strcasecmp (line + 1, "rganization"))
6322 + if (!e->organization && mutt_strcasecmp (p, "unknown"))
6323 + e->organization = safe_strdup (p);
6328 if (!ascii_strcasecmp (line + 1, "eferences"))
6330 @@ -1257,6 +1289,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6331 e->x_label = safe_strdup(p);
6335 + else if (!mutt_strcasecmp (line + 1, "-comment-to"))
6337 + if (!e->x_comment_to)
6338 + e->x_comment_to = safe_strdup (p);
6341 + else if (!mutt_strcasecmp (line + 1, "ref"))
6344 + e->xref = safe_strdup (p);
6351 diff -udprP mutt-1.5.21.orig/pattern.c mutt-1.5.21/pattern.c
6352 --- mutt-1.5.21.orig/pattern.c 2010-08-24 19:34:21.000000000 +0300
6353 +++ mutt-1.5.21/pattern.c 2010-09-16 13:14:39.000000000 +0300
6354 @@ -92,6 +92,9 @@ Flags[] =
6355 { 'U', M_UNREAD, 0, NULL },
6356 { 'v', M_COLLAPSED, 0, NULL },
6357 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6359 + { 'w', M_NEWSGROUPS, 0, eat_regexp },
6361 { 'x', M_REFERENCE, 0, eat_regexp },
6362 { 'X', M_MIMEATTACH, 0, eat_range },
6363 { 'y', M_XLABEL, 0, eat_regexp },
6364 @@ -1213,6 +1216,10 @@ mutt_pattern_exec (struct pattern_t *pat
6366 case M_UNREFERENCED:
6367 return (pat->not ^ (h->thread && !h->thread->child));
6369 + case M_NEWSGROUPS:
6370 + return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6373 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6375 @@ -1294,6 +1301,7 @@ int mutt_pattern_func (int op, char *pro
6376 progress_t progress;
6378 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6379 + if (prompt || op != M_LIMIT)
6380 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6383 diff -udprP mutt-1.5.21.orig/po/POTFILES.in mutt-1.5.21/po/POTFILES.in
6384 --- mutt-1.5.21.orig/po/POTFILES.in 2008-03-19 22:07:57.000000000 +0200
6385 +++ mutt-1.5.21/po/POTFILES.in 2010-09-16 13:14:39.000000000 +0300
6386 @@ -46,6 +46,8 @@ mutt_ssl_gnutls.c
6395 diff -udprP mutt-1.5.21.orig/postpone.c mutt-1.5.21/postpone.c
6396 --- mutt-1.5.21.orig/postpone.c 2010-08-24 19:34:21.000000000 +0300
6397 +++ mutt-1.5.21/postpone.c 2010-09-16 13:14:39.000000000 +0300
6398 @@ -125,15 +125,26 @@ int mutt_num_postponed (int force)
6400 if (LastModify < st.st_mtime)
6403 + int optnews = option (OPTNEWS);
6405 LastModify = st.st_mtime;
6407 if (access (Postponed, R_OK | F_OK) != 0)
6408 return (PostCount = 0);
6411 + unset_option (OPTNEWS);
6413 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6416 PostCount = ctx.msgcount;
6417 mx_fastclose_mailbox (&ctx);
6420 + set_option (OPTNEWS);
6425 diff -udprP mutt-1.5.21.orig/protos.h mutt-1.5.21/protos.h
6426 --- mutt-1.5.21.orig/protos.h 2010-08-24 19:34:21.000000000 +0300
6427 +++ mutt-1.5.21/protos.h 2010-09-16 13:14:39.000000000 +0300
6428 @@ -110,6 +110,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
6429 HASH *mutt_make_subj_hash (CONTEXT *);
6431 LIST *mutt_make_references(ENVELOPE *e);
6432 +LIST *mutt_parse_references (char *, int);
6434 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6435 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
6436 diff -udprP mutt-1.5.21.orig/recvattach.c mutt-1.5.21/recvattach.c
6437 --- mutt-1.5.21.orig/recvattach.c 2010-09-13 20:19:55.000000000 +0300
6438 +++ mutt-1.5.21/recvattach.c 2010-09-16 13:14:39.000000000 +0300
6439 @@ -1119,6 +1119,15 @@ void mutt_view_attachments (HEADER *hdr)
6444 + if (Context->magic == M_NNTP)
6447 + mutt_error _("Can't delete attachment from newsserver.");
6452 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6455 @@ -1210,10 +1219,33 @@ void mutt_view_attachments (HEADER *hdr)
6456 case OP_FORWARD_MESSAGE:
6458 mutt_attach_forward (fp, hdr, idx, idxlen,
6459 - menu->tagprefix ? NULL : idx[menu->current]->content);
6460 + menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6461 menu->redraw = REDRAW_FULL;
6465 + case OP_FORWARD_TO_GROUP:
6467 + mutt_attach_forward (fp, hdr, idx, idxlen,
6468 + menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6469 + menu->redraw = REDRAW_FULL;
6475 + if (!idx[menu->current]->content->hdr->env->followup_to ||
6476 + mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6477 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6479 + mutt_attach_reply (fp, hdr, idx, idxlen,
6480 + menu->tagprefix ? NULL : idx[menu->current]->content,
6481 + SENDNEWS|SENDREPLY);
6482 + menu->redraw = REDRAW_FULL;
6488 case OP_GROUP_REPLY:
6490 diff -udprP mutt-1.5.21.orig/recvcmd.c mutt-1.5.21/recvcmd.c
6491 --- mutt-1.5.21.orig/recvcmd.c 2010-09-13 20:19:55.000000000 +0300
6492 +++ mutt-1.5.21/recvcmd.c 2010-09-16 13:14:39.000000000 +0300
6493 @@ -401,7 +401,7 @@ static BODY ** copy_problematic_attachme
6494 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6495 ATTACHPTR ** idx, short idxlen,
6498 + short nattach, int flags)
6501 short mime_fwd_all = 0;
6502 @@ -547,7 +547,7 @@ _("Can't decode all tagged attachments.
6505 /* now that we have the template, send it. */
6506 - ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6507 + ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6511 @@ -574,7 +574,7 @@ _("Can't decode all tagged attachments.
6514 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6515 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6516 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6518 HEADER *curhdr = NULL;
6520 @@ -679,23 +679,23 @@ static void attach_forward_msgs (FILE *
6522 mutt_free_header (&tmphdr);
6524 - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6525 + ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
6530 void mutt_attach_forward (FILE * fp, HEADER * hdr,
6531 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6532 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6537 if (check_all_msg (idx, idxlen, cur, 0) == 0)
6538 - attach_forward_msgs (fp, hdr, idx, idxlen, cur);
6539 + attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
6542 nattach = count_tagged (idx, idxlen);
6543 - attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
6544 + attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
6548 @@ -753,28 +753,40 @@ attach_reply_envelope_defaults (ENVELOPE
6554 + if ((flags & SENDNEWS))
6556 - if (mutt_fetch_recips (env, curenv, flags) == -1)
6558 + /* in case followup set Newsgroups: with Followup-To: if it present */
6559 + if (!env->newsgroups && curenv &&
6560 + mutt_strcasecmp (curenv->followup_to, "poster"))
6561 + env->newsgroups = safe_strdup (curenv->followup_to);
6566 - for (i = 0; i < idxlen; i++)
6569 - if (idx[i]->content->tagged
6570 - && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6571 + if (mutt_fetch_recips (env, curenv, flags) == -1)
6576 + for (i = 0; i < idxlen; i++)
6578 + if (idx[i]->content->tagged
6579 + && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6584 + if ((flags & SENDLISTREPLY) && !env->to)
6586 + mutt_error _("No mailing lists found!");
6590 + mutt_fix_reply_recipients (env);
6593 - if ((flags & SENDLISTREPLY) && !env->to)
6595 - mutt_error _("No mailing lists found!");
6599 - mutt_fix_reply_recipients (env);
6600 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
6603 @@ -835,6 +847,13 @@ void mutt_attach_reply (FILE * fp, HEADE
6604 char prefix[SHORT_STRING];
6608 + if (flags & SENDNEWS)
6609 + set_option (OPTNEWSSEND);
6611 + unset_option (OPTNEWSSEND);
6614 if (check_all_msg (idx, idxlen, cur, 0) == -1)
6616 nattach = count_tagged (idx, idxlen);
6617 diff -udprP mutt-1.5.21.orig/rfc1524.c mutt-1.5.21/rfc1524.c
6618 --- mutt-1.5.21.orig/rfc1524.c 2010-03-01 19:56:19.000000000 +0200
6619 +++ mutt-1.5.21/rfc1524.c 2010-09-16 13:14:39.000000000 +0300
6620 @@ -570,13 +570,13 @@ int rfc1524_expand_filename (char *namet
6624 -int mutt_rename_file (char *oldfile, char *newfile)
6625 +int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
6629 if (access (oldfile, F_OK) != 0)
6631 - if (access (newfile, F_OK) == 0)
6632 + if (!overwrite && access (newfile, F_OK) == 0)
6634 if ((ofp = fopen (oldfile,"r")) == NULL)
6636 @@ -591,3 +591,8 @@ int mutt_rename_file (char *oldfile, cha
6637 mutt_unlink (oldfile);
6641 +int mutt_rename_file (char *oldfile, char *newfile)
6643 + return _mutt_rename_file (oldfile, newfile, 0);
6645 diff -udprP mutt-1.5.21.orig/rfc1524.h mutt-1.5.21/rfc1524.h
6646 --- mutt-1.5.21.orig/rfc1524.h 2008-03-19 22:07:06.000000000 +0200
6647 +++ mutt-1.5.21/rfc1524.h 2010-09-16 13:14:39.000000000 +0300
6648 @@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char
6649 int rfc1524_expand_filename (char *, char *, char *, size_t);
6650 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
6651 int mutt_rename_file (char *, char *);
6652 +int _mutt_rename_file (char *, char *, int);
6654 #endif /* _RFC1524_H */
6655 diff -udprP mutt-1.5.21.orig/send.c mutt-1.5.21/send.c
6656 --- mutt-1.5.21.orig/send.c 2010-09-13 20:19:55.000000000 +0300
6657 +++ mutt-1.5.21/send.c 2010-09-16 13:14:39.000000000 +0300
6659 #include <sys/types.h>
6668 #include "remailer.h"
6670 @@ -213,17 +218,51 @@ static int edit_address (ADDRESS **a, /*
6674 -static int edit_envelope (ENVELOPE *en)
6675 +static int edit_envelope (ENVELOPE *en, int flags)
6677 char buf[HUGE_STRING];
6678 LIST *uh = UserHeader;
6680 - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6682 - if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6684 - if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6687 + if (option (OPTNEWSSEND))
6689 + if (en->newsgroups)
6690 + strfcpy (buf, en->newsgroups, sizeof (buf));
6693 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
6695 + FREE (&en->newsgroups);
6696 + en->newsgroups = safe_strdup (buf);
6698 + if (en->followup_to)
6699 + strfcpy (buf, en->followup_to, sizeof (buf));
6702 + if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
6704 + FREE (&en->followup_to);
6705 + en->followup_to = safe_strdup (buf);
6707 + if (en->x_comment_to)
6708 + strfcpy (buf, en->x_comment_to, sizeof (buf));
6711 + if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
6713 + FREE (&en->x_comment_to);
6714 + en->x_comment_to = safe_strdup (buf);
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)
6729 @@ -259,6 +298,14 @@ static int edit_envelope (ENVELOPE *en)
6734 +char *nntp_get_header (const char *s)
6737 + return safe_strdup (s);
6741 static void process_user_recips (ENVELOPE *env)
6743 LIST *uh = UserHeader;
6744 @@ -271,6 +318,14 @@ static void process_user_recips (ENVELOP
6745 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
6746 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
6747 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
6749 + else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
6750 + env->newsgroups = nntp_get_header (uh->data + 11);
6751 + else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
6752 + env->followup_to = nntp_get_header (uh->data + 12);
6753 + else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
6754 + env->x_comment_to = nntp_get_header (uh->data + 13);
6759 @@ -309,6 +364,12 @@ static void process_user_header (ENVELOP
6760 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
6761 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
6762 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
6764 + ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
6765 + ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
6766 + ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
6768 + ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
6769 ascii_strncasecmp ("subject:", uh->data, 8) != 0 &&
6770 ascii_strncasecmp ("return-path:", uh->data, 12) != 0)
6772 @@ -657,6 +718,10 @@ void mutt_add_to_reference_headers (ENVE
6777 + if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
6778 + env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
6783 @@ -719,6 +784,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
6785 if (flags & SENDREPLY)
6788 + if ((flags & SENDNEWS))
6790 + /* in case followup set Newsgroups: with Followup-To: if it present */
6791 + if (!env->newsgroups && curenv &&
6792 + mutt_strcasecmp (curenv->followup_to, "poster"))
6793 + env->newsgroups = safe_strdup (curenv->followup_to);
6800 @@ -865,7 +940,18 @@ void mutt_set_followup_to (ENVELOPE *e)
6801 * it hasn't already been set
6804 - if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
6805 + if (!option (OPTFOLLOWUPTO))
6808 + if (option (OPTNEWSSEND))
6810 + if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
6811 + e->followup_to = safe_strdup (e->newsgroups);
6816 + if (!e->mail_followup_to)
6818 if (mutt_is_list_cc (0, e->to, e->cc))
6820 @@ -1027,6 +1113,9 @@ static int send_message (HEADER *msg)
6825 + if (!option (OPTNEWSSEND))
6826 +#endif /* USE_NNTP */
6828 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
6829 msg->env->bcc, tempfile,
6830 @@ -1138,6 +1227,13 @@ ci_send_message (int flags, /* send mod
6835 + if (flags & SENDNEWS)
6836 + set_option (OPTNEWSSEND);
6838 + unset_option (OPTNEWSSEND);
6841 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
6842 mutt_num_postponed (1))
6844 @@ -1168,6 +1264,22 @@ ci_send_message (int flags, /* send mod
6846 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
6850 + * If postponed message is a news article, it have
6851 + * a "Newsgroups:" header line, then set appropriate flag.
6853 + if (msg->env->newsgroups)
6855 + flags |= SENDNEWS;
6856 + set_option (OPTNEWSSEND);
6860 + flags &= ~SENDNEWS;
6861 + unset_option (OPTNEWSSEND);
6866 if (flags & (SENDPOSTPONED|SENDRESEND))
6867 @@ -1262,11 +1374,16 @@ ci_send_message (int flags, /* send mod
6868 if (flags & SENDREPLY)
6869 mutt_fix_reply_recipients (msg->env);
6872 + if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
6873 + msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
6876 if (! (flags & (SENDMAILX|SENDBATCH)) &&
6877 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
6878 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
6880 - if (edit_envelope (msg->env) == -1)
6881 + if (edit_envelope (msg->env, flags) == -1)
6885 @@ -1534,6 +1651,11 @@ main_loop:
6890 + if (flags & SENDNEWS)
6891 + mutt_message _("Article not posted.");
6894 mutt_message _("Mail not sent.");
6897 @@ -1566,6 +1688,9 @@ main_loop:
6902 + if (!(flags & SENDNEWS))
6904 if (!has_recips (msg->env->to) && !has_recips (msg->env->cc) &&
6905 !has_recips (msg->env->bcc))
6907 @@ -1599,6 +1724,19 @@ main_loop:
6908 mutt_error _("No subject specified.");
6912 + if ((flags & SENDNEWS) && !msg->env->subject)
6914 + mutt_error _("No subject specified.");
6918 + if ((flags & SENDNEWS) && !msg->env->newsgroups)
6920 + mutt_error _("No newsgroup specified.");
6925 if (msg->content->next)
6926 msg->content = mutt_make_multipart (msg->content);
6927 @@ -1805,7 +1943,12 @@ full_fcc:
6930 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
6931 - mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
6932 + mutt_message (i != 0 ? _("Sending in background.") :
6934 + (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
6939 if (WithCrypto && (msg->security & ENCRYPT))
6941 diff -udprP mutt-1.5.21.orig/sendlib.c mutt-1.5.21/sendlib.c
6942 --- mutt-1.5.21.orig/sendlib.c 2010-09-13 20:19:55.000000000 +0300
6943 +++ mutt-1.5.21/sendlib.c 2010-09-16 13:14:39.000000000 +0300
6945 #include <sys/wait.h>
6952 #ifdef HAVE_SYSEXITS_H
6953 #include <sysexits.h>
6954 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
6955 @@ -1543,6 +1547,14 @@ void mutt_write_references (LIST *r, FIL
6958 int refcnt = 0, refmax = 0;
6959 + int multiline = 1;
6968 for ( ; (trim == 0 || refcnt < trim) && r ; r = r->next)
6970 @@ -1553,9 +1565,11 @@ void mutt_write_references (LIST *r, FIL
6972 while (refcnt-- > 0)
6975 + if (multiline || space)
6978 fputs (ref[refcnt]->data, f);
6980 + if (multiline && refcnt >= 1)
6984 @@ -1962,6 +1976,9 @@ int mutt_write_rfc822_header (FILE *fp,
6985 mutt_write_address_list (env->to, fp, 4, 0);
6989 + if (!option (OPTNEWSSEND))
6991 fputs ("To: \n", fp);
6994 @@ -1970,6 +1987,9 @@ int mutt_write_rfc822_header (FILE *fp,
6995 mutt_write_address_list (env->cc, fp, 4, 0);
6999 + if (!option (OPTNEWSSEND))
7001 fputs ("Cc: \n", fp);
7004 @@ -1981,8 +2001,28 @@ int mutt_write_rfc822_header (FILE *fp,
7009 + if (!option (OPTNEWSSEND))
7011 fputs ("Bcc: \n", fp);
7014 + if (env->newsgroups)
7015 + fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
7016 + else if (mode == 1 && option (OPTNEWSSEND))
7017 + fputs ("Newsgroups: \n", fp);
7019 + if (env->followup_to)
7020 + fprintf (fp, "Followup-To: %s\n", env->followup_to);
7021 + else if (mode == 1 && option (OPTNEWSSEND))
7022 + fputs ("Followup-To: \n", fp);
7024 + if (env->x_comment_to)
7025 + fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
7026 + else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
7027 + fputs ("X-Comment-To: \n", fp);
7031 mutt_write_one_header (fp, "Subject", env->subject, NULL, 0, 0);
7033 @@ -2001,6 +2041,9 @@ int mutt_write_rfc822_header (FILE *fp,
7034 fputs ("Reply-To: \n", fp);
7036 if (env->mail_followup_to)
7038 + if (!option (OPTNEWSSEND))
7041 fputs ("Mail-Followup-To: ", fp);
7042 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
7043 @@ -2339,11 +2382,30 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7044 const char *msg, /* file containing message */
7045 int eightbit) /* message contains 8bit chars */
7047 - char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
7048 + char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
7050 size_t argslen = 0, argsmax = 0;
7054 + if (option (OPTNEWSSEND))
7056 + char cmd[LONG_STRING];
7058 + mutt_FormatString (cmd, sizeof (cmd), 0, NONULL (Inews), nntp_format_str, 0, 0);
7061 + i = nntp_post (msg);
7066 + s = safe_strdup (cmd);
7070 + s = safe_strdup (Sendmail);
7074 while ((ps = strtok (ps, " ")))
7075 @@ -2367,6 +2429,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7080 + if (!option (OPTNEWSSEND))
7083 if (eightbit && option (OPTUSE8BITMIME))
7084 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7086 @@ -2398,6 +2464,9 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7087 args = add_args (args, &argslen, &argsmax, to);
7088 args = add_args (args, &argslen, &argsmax, cc);
7089 args = add_args (args, &argslen, &argsmax, bcc);
7094 if (argslen == argsmax)
7095 safe_realloc (&args, sizeof (char *) * (++argsmax));
7096 @@ -2478,6 +2547,9 @@ void mutt_prepare_envelope (ENVELOPE *en
7097 rfc2047_encode_string (&env->x_label);
7101 + if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
7104 rfc2047_encode_string (&env->subject);
7106 @@ -2598,6 +2670,10 @@ int mutt_bounce_message (FILE *fp, HEADE
7108 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
7111 + unset_option (OPTNEWSSEND);
7114 ret = _mutt_bounce_message (fp, h, to, resent_from, from);
7116 rfc822_free_address (&from);
7117 diff -udprP mutt-1.5.21.orig/sort.c mutt-1.5.21/sort.c
7118 --- mutt-1.5.21.orig/sort.c 2008-10-29 00:29:44.000000000 +0200
7119 +++ mutt-1.5.21/sort.c 2010-09-16 13:14:39.000000000 +0300
7120 @@ -151,6 +151,15 @@ static int compare_order (const void *a,
7121 HEADER **ha = (HEADER **) a;
7122 HEADER **hb = (HEADER **) b;
7125 + if ((*ha)->article_num && (*hb)->article_num)
7127 + int result = (*ha)->article_num - (*hb)->article_num;
7128 + AUXSORT(result,a,b);
7129 + return (SORTCODE (result));
7133 /* no need to auxsort because you will never have equality here */
7134 return (SORTCODE ((*ha)->index - (*hb)->index));
7136 diff -udprP mutt-1.5.21.orig/url.c mutt-1.5.21/url.c
7137 --- mutt-1.5.21.orig/url.c 2010-08-24 19:34:21.000000000 +0300
7138 +++ mutt-1.5.21/url.c 2010-09-16 13:14:39.000000000 +0300
7139 @@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] =
7140 { "imaps", U_IMAPS },
7143 + { "news", U_NNTP },
7144 + { "newss", U_NNTPS },
7145 { "mailto", U_MAILTO },
7147 { "smtps", U_SMTPS },
7148 diff -udprP mutt-1.5.21.orig/url.h mutt-1.5.21/url.h
7149 --- mutt-1.5.21.orig/url.h 2009-08-25 22:08:52.000000000 +0300
7150 +++ mutt-1.5.21/url.h 2010-09-16 13:14:39.000000000 +0300
7151 @@ -8,6 +8,8 @@ typedef enum url_scheme
7160 diff -udprP mutt-1.5.21.orig/Makefile.am mutt-1.5.21/Makefile.am
7161 --- mutt-1.5.21.orig/Makefile.am 2010-08-24 19:34:21.000000000 +0300
7162 +++ mutt-1.5.21/Makefile.am 2010-09-16 13:14:39.000000000 +0300
7163 @@ -57,6 +57,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
7164 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
7165 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
7166 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
7168 smime.c smtp.c utf8.c wcwidth.c \
7169 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
7171 @@ -68,6 +69,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7172 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7173 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7174 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7175 + nntp.h ChangeLog.nntp \
7176 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7177 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
7178 README.SSL smime.h group.h \
7179 diff -udprP mutt-1.5.21.orig/Makefile.in mutt-1.5.21/Makefile.in
7180 --- mutt-1.5.21.orig/Makefile.in 2010-08-25 19:31:48.000000000 +0300
7181 +++ mutt-1.5.21/Makefile.in 2010-09-16 13:14:39.000000000 +0300
7182 @@ -375,6 +375,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
7183 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
7184 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
7185 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
7187 smime.c smtp.c utf8.c wcwidth.c \
7188 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
7190 @@ -386,6 +387,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7191 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7192 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7193 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7194 + nntp.h ChangeLog.nntp \
7195 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7196 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
7197 README.SSL smime.h group.h \
7198 @@ -640,6 +642,8 @@ distclean-compile:
7199 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@
7200 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@
7201 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@
7202 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@
7203 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@
7204 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@
7205 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
7206 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@
7207 diff -udprP mutt-1.5.21.orig/configure mutt-1.5.21/configure
7208 --- mutt-1.5.21.orig/configure 2010-08-25 19:31:47.000000000 +0300
7209 +++ mutt-1.5.21/configure 2010-09-16 13:14:39.000000000 +0300
7210 @@ -1427,6 +1427,7 @@ Optional Features:
7211 Force use of an external dotlock program
7212 --enable-pop Enable POP3 support
7213 --enable-imap Enable IMAP support
7214 + --enable-nntp Enable NNTP support
7215 --enable-smtp include internal SMTP relay support
7216 --enable-debug Enable debugging support
7217 --enable-flock Use flock() to lock files
7218 @@ -10823,6 +10824,20 @@ _ACEOF
7222 +# Check whether --enable-nntp or --disable-nntp was given.
7223 +if test "${enable_nntp+set}" = set; then
7224 + enableval="$enable_nntp"
7225 + if test x$enableval = xyes ; then
7226 + cat >>confdefs.h <<\_ACEOF
7230 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
7239 diff -udprP mutt-1.5.21.orig/doc/Muttrc mutt-1.5.21/doc/Muttrc
7240 --- mutt-1.5.21.orig/doc/Muttrc 2010-09-15 20:07:19.000000000 +0300
7241 +++ mutt-1.5.21/doc/Muttrc 2010-09-16 13:14:39.000000000 +0300
7242 @@ -281,6 +281,28 @@
7243 # of the value as shown above if included.
7246 +# set ask_follow_up=no
7248 +# Name: ask_follow_up
7253 +# If set, Mutt will prompt you for follow-up groups before editing
7254 +# the body of an outgoing message.
7257 +# set ask_x_comment_to=no
7259 +# Name: ask_x_comment_to
7264 +# If set, Mutt will prompt you for x-comment-to field before editing
7265 +# the body of an outgoing message.
7268 # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
7270 # Name: attach_format
7271 @@ -466,6 +488,17 @@
7272 # set certificate_file=~/.mutt/certificates
7275 +# set catchup_newsgroup=ask-yes
7277 +# Name: catchup_newsgroup
7282 +# If this variable is set, Mutt will mark all articles in newsgroup
7283 +# as read when you quit the newsgroup (catchup newsgroup).
7289 @@ -1142,6 +1175,19 @@
7290 # of the same email for you.
7293 +# set followup_to_poster=ask-yes
7295 +# Name: followup_to_poster
7300 +# If this variable is set and the keyword "poster" is present in
7301 +# Followup-To header, follow-up to newsgroup function is not
7302 +# permitted. The message will be mailed to the submitter of the
7303 +# message via mail.
7309 @@ -1253,6 +1299,28 @@
7310 # ``Franklin'' to ``Franklin, Steve''.
7313 +# set group_index_format="%4C %M%N %5s %-45.45f %d"
7315 +# Name: group_index_format
7317 +# Default: "%4C %M%N %5s %-45.45f %d"
7320 +# This variable allows you to customize the newsgroup browser display to
7321 +# your personal taste. This string is similar to ``index_format'', but
7322 +# has its own set of printf()-like sequences:
7324 +# %C current newsgroup number
7325 +# %d description of newsgroup (becomes from server)
7326 +# %f newsgroup name
7327 +# %M - if newsgroup not allowed for direct post (moderated for example)
7328 +# %N N if newsgroup is new, u if unsubscribed, blank otherwise
7329 +# %n number of new articles in newsgroup
7330 +# %s number of unread articles in newsgroup
7331 +# %>X right justify the rest of the string and pad with character "X"
7332 +# %|X pad to the end of the line with character "X"
7338 @@ -1802,6 +1870,7 @@
7339 # %E number of messages in current thread
7340 # %f sender (address + real name), either From: or Return-Path:
7341 # %F author name, or recipient name if the message is from you
7342 +# %g newsgroup name (if compiled with nntp support)
7343 # %H spam attribute(s) of this message
7344 # %i message-id of the current message
7345 # %l number of lines in the message (does not work with maildir,
7346 @@ -1817,12 +1886,14 @@
7347 # stashed the message: list name or recipient name
7348 # if not sent to a list
7349 # %P progress indicator for the built-in pager (how much of the file has been displayed)
7350 +# %R ``x-comment-to:'' field (if present and compiled with nntp support)
7351 # %s subject of the message
7352 # %S status of the message (``N''/``D''/``d''/``!''/``r''/*)
7353 # %t ``To:'' field (recipients)
7354 # %T the appropriate character from the $to_chars string
7355 # %u user (login) name of the author
7356 # %v first name of the author, or the recipient if the message is from you
7357 +# %W name of organization of author (``organization:'' field)
7358 # %X number of attachments
7359 # (please see the ``attachments'' section for possible speed effects)
7360 # %y ``X-Label:'' field, if present
7361 @@ -1858,6 +1929,22 @@
7362 # ``save-hook'', ``fcc-hook'' and ``fcc-save-hook'', too.
7372 +# If set, specifies the program and arguments used to deliver news posted
7373 +# by Mutt. Otherwise, mutt posts article using current connection to
7374 +# news server. The following printf-style sequence is understood:
7376 +# %s newsserver name
7378 +# Example: set inews="/usr/local/bin/inews -hS"
7381 # set ispell="ispell"
7384 @@ -2229,6 +2316,18 @@
7385 # be attached to the newly composed message if this option is set.
7388 +# set mime_subject=yes
7390 +# Name: mime_subject
7395 +# If unset, 8-bit ``subject:'' line in article header will not be
7396 +# encoded according to RFC2047 to base64. This is useful when message
7397 +# is Usenet article, because MIME for news is nonstandard feature.
7400 # set mix_entry_format="%4n %c %-16s %a"
7402 # Name: mix_entry_format
7403 @@ -2295,6 +2394,118 @@
7404 # See also $read_inc, $write_inc and $net_inc.
7407 +# set news_cache_dir="~/.mutt"
7409 +# Name: news_cache_dir
7411 +# Default: "~/.mutt"
7414 +# This variable pointing to directory where Mutt will save cached news
7415 +# articles headers in. If unset, headers will not be saved at all
7416 +# and will be reloaded each time when you enter to newsgroup.
7419 +# set news_server=""
7421 +# Name: news_server
7426 +# This variable specifies domain name or address of NNTP server. It
7427 +# defaults to the newsserver specified in the environment variable
7428 +# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
7429 +# specify username and an alternative port for each newsserver, ie:
7431 +# [news[s]://][username[:password]@]newsserver[:port]
7434 +# set newsrc="~/.newsrc"
7438 +# Default: "~/.newsrc"
7441 +# The file, containing info about subscribed newsgroups - names and
7442 +# indexes of read articles. The following printf-style sequence
7445 +# %s newsserver name
7448 +# set nntp_context=1000
7450 +# Name: nntp_context
7455 +# This variable defines number of articles which will be in index when
7456 +# newsgroup entered. If active newsgroup have more articles than this
7457 +# number, oldest articles will be ignored. Also controls how many
7458 +# articles headers will be saved in cache when you quit newsgroup.
7461 +# set nntp_load_description=yes
7463 +# Name: nntp_load_description
7468 +# This variable controls whether or not descriptions for each newsgroup
7469 +# must be loaded when newsgroup is added to list (first time list
7470 +# loading or new newsgroup adding).
7480 +# Your login name on the NNTP server. If unset and NNTP server requires
7481 +# authentification, Mutt will prompt you for your account name when you
7482 +# connect to newsserver.
7492 +# Your password for NNTP account.
7502 +# The time in seconds until any operations on newsgroup except post new
7503 +# article will cause recheck for new news. If set to 0, Mutt will
7504 +# recheck newsgroup on each operation in index (stepping, read article,
7508 +# set nntp_reconnect=ask-yes
7510 +# Name: nntp_reconnect
7515 +# Controls whether or not Mutt will try to reconnect to newsserver when
7519 # set pager="builtin"
7522 @@ -3012,6 +3223,19 @@
7523 # string after the inclusion of a message which is being replied to.
7526 +# set post_moderated=ask-yes
7528 +# Name: post_moderated
7533 +# If set to yes, Mutt will post article to newsgroup that have
7534 +# not permissions to posting (e.g. moderated). Note: if newsserver
7535 +# does not support posting to that newsgroup or totally read-only, that
7536 +# posting will not have an effect.
7539 # set postpone=ask-yes
7542 @@ -3592,6 +3816,41 @@
7543 # shell from /etc/passwd is used.
7546 +# set save_unsubscribed=no
7548 +# Name: save_unsubscribed
7553 +# When set, info about unsubscribed newsgroups will be saved into
7554 +# ``newsrc'' file and into cache.
7557 +# set show_new_news=yes
7559 +# Name: show_new_news
7564 +# If set, newsserver will be asked for new newsgroups on entering
7565 +# the browser. Otherwise, it will be done only once for a newsserver.
7566 +# Also controls whether or not number of new articles of subscribed
7567 +# newsgroups will be then checked.
7570 +# set show_only_unread=no
7572 +# Name: show_only_unread
7577 +# If set, only subscribed newsgroups that contain unread articles
7578 +# will be displayed in browser.
7581 # set sig_dashes=yes
7584 @@ -4659,6 +4918,17 @@
7588 +# set x_comment_to=no
7590 +# Name: x_comment_to
7595 +# If set, Mutt will add ``X-Comment-To:'' field (that contains full
7596 +# name of original article author) to article that followuped to newsgroup.