1 WARNING: Run the following script before configure:
9 Vsevolod Volkov <vvv@mutt.org.ua>
12 diff -udprP mutt-1.5.19.orig/ChangeLog.nntp mutt-1.5.19/ChangeLog.nntp
13 --- mutt-1.5.19.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14 +++ mutt-1.5.19/ChangeLog.nntp 2009-01-06 22:27:38.000000000 +0200
16 +* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua>
19 +* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua>
21 +- fixed SIGSEGV when followup or forward to newsgroup
23 +* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua>
26 +* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua>
27 +- fixed arguments of nntp_format_str()
29 +* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua>
30 +- fixed error selecting news group
32 +* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua>
35 +* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
36 +- fixed posting error if $smtp_url is set
37 +- added support of print-style sequence %R (x-comment-to)
39 +* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
41 +- nntp://... url changed to news://...
42 +- added indicator of fetching descriptions progress
44 +* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
47 +* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
50 +* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
52 +- fixed reading empty .newsrc
54 +* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
57 +* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
60 +* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
63 +* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
66 +* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
68 +- function mutt_update_list_file() moved to newsrc.c and changed algorithm
70 +* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
71 +- fixed error in nntp_logout_all()
73 +* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
74 +- fixed debug output in mutt_newsrc_update()
75 +- added optional support of LISTGROUP command
76 +- fixed typo in nntp_parse_xref()
78 +* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
81 +* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
84 +* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
87 +* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
89 +- added space after newsgroup name in .newsrc file
91 +* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
92 +- nntp patch: fixed SIGSEGV when posting article
94 +* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
97 +* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
99 +- replace safe_free calls by the FREE macro
101 +* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
103 +- nntp authentication can be passed after any command
105 +* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
108 +* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
111 +* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
113 +- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
114 + <reconstruct-thread> functions
115 +- fixed message about nntp reconnect
116 +- fixed <attach-news-message> function using browser
117 +- added support of Followup-To: poster
118 +- added %n (new articles) in group_index_format
119 +- posting articles without inews by default
121 +* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
124 +* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
127 +* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
129 +- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
130 +- added default content disposition
132 +* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
135 +* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
136 +- update to 1.3.23.2
137 +- fixed segfault if mutt_conn_find() returns null
139 +* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
140 +- update to 1.3.23.1
141 +- added support of LISTGROUP command
142 +- added support for servers with broken overview
143 +- disabled <flag-message> function on news server
144 +- fixed error storing bad authentication information
146 +* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
148 +- fixed typo in buffy.c
149 +- added substitution of %s parameter in $inews variable
151 +* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
152 +- update to 1.3.22.1
155 +* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
158 +* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
160 +- removed 'server-hook', use 'account-hook' instead
161 +- fixed error opening NNTP server without newsgroup using -f option
163 +* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
166 +* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
168 +- fixed typo in nntp_attempt_features()
169 +- changed algorithm of XGTITLE command testing
170 +- disabled writing of NNTP password in debug file
171 +- fixed reading and writing of long newsrc lines
172 +- changed checking of last line while reading lines from server
173 +- fixed possible buffer overrun in nntp_parse_newsrc_line()
174 +- removed checking of XHDR command
175 +- compare NNTP return codes without trailing space
177 +* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
179 +- support for 'LIST NEWSGROUPS' command to read descriptions
181 +* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
184 +* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
187 +* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
189 +- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
191 +* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
194 +* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
195 +- Fixed problem if last article in group is deleted
197 +* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
198 +- Fixed checking of XGTITLE command on some servers
200 +* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
201 +- Added \r in AUTHINFO commands
203 +* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
206 +* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
208 +- fixed error opening newsgroup from mutt started with -g or -G
210 +* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
212 +- hotkey 'G' (get-message) replaced with '^G'
214 +* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
216 +- changed delay displaying error messages from 1 to 2 seconds
217 +- fixed error compiling with nntp and without imap
219 +* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
220 +- fixed catchup in index
221 +- fixed nntp_open_mailbox()
223 +* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
224 +- functions <edit> and <delete-entry> disabled
225 +- format of news mailbox names changed to url form
226 +- option nntp_attempts removed
227 +- option reconnect_news renamed to nntp_reconnect
228 +- default value of nntp_poll changed from 30 to 60
229 +- error handling improved
231 +* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
233 +- new option show_only_unread
234 +- add newsgroup completion
236 +* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
239 +* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
242 +* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
244 +- authentication code update
245 +- fix for changing to newsgroup from mailbox with read messages
246 +- socket code optimization
248 +* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
251 +* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
252 +- don't substitute current newsgroup with deleted new messages
254 +* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
256 +- fix for substitution of newsgroup after reconnection
257 +- fix for loading newsgroups with very long names
258 +- fix for loading more than 32768 newsgroups
260 +* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
263 +* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
266 +* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
269 +* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
272 +* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
275 +* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
278 +* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
279 +- add substitution of newsgroup with new messages by default
281 +* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
282 +- add attach message from newsgroup
283 +- add one-line help in newsreader mode
284 +- disable 'change-dir' command in newsgroups browser
287 +* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
288 +- get default newsserver name from file /etc/nntpserver
289 +- use case insensitive server names
290 +- add print-style sequence %s to $newsrc
293 +* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
294 +- remove 'X-FTN-Origin' header processing
296 +* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
300 +* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
301 +- fix mutt_select_newsserver()
302 +- remove 'toggle-mode' function
303 +- add 'change-newsgroup' function
305 +* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
308 +* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
309 +- fix error 'bounce' function after 'post'
310 +- add 'forward to newsgroup' function
312 +* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
313 +- 'forward' function works in newsreader mode
314 +- add 'post' and 'followup' functions to pager and attachment menu
315 +- fix active descriptions and allowed flag reload
317 +* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
319 +- remove deleted newsgroups from list
321 +* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
322 +- update .newsrc in browser
324 +* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
325 +- reload .newsrc if externally modified
326 +- fix active cache update
328 +* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
331 +* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
332 +- patch *.update_list_file is not required
333 +- count lines when loading descriptions
334 +- remove cache of unsubscribed newsgroups
336 +* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
337 +- load list of newsgroups from cache faster
339 +* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
342 +* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
343 +- fix unread messages in browser
344 +- fix newsrc_gen_entries()
346 +* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
347 +- fix mutt_newsgroup_stat()
348 +- fix nntp_delete_cache()
349 +- fix nntp_get_status()
350 +- fix check_children()
351 +- fix nntp_fetch_headers()
353 +* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
356 +* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
357 +- fix updating new messages in cache
359 +* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
360 +- change default cache filenames
361 +- fix updating new messages in cache
363 +* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
364 +- fix segmentation fault in news groups browser
366 +* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
369 +* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
372 +* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
373 +- add X-Comment-To editing
374 +- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
375 +- add variables $ask_followup_to and $ask_x_comment_to
377 +* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
379 diff -udprP mutt-1.5.19.orig/OPS mutt-1.5.19/OPS
380 --- mutt-1.5.19.orig/OPS 2008-03-19 22:07:57.000000000 +0200
381 +++ mutt-1.5.19/OPS 2009-01-06 22:27:38.000000000 +0200
382 @@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
383 OP_BROWSER_NEW_FILE "select a new file in this directory"
384 OP_BROWSER_VIEW_FILE "view file"
385 OP_BROWSER_TELL "display the currently selected file's name"
386 -OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
387 -OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
388 +OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
389 +OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
390 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
391 OP_BUFFY_LIST "list mailboxes with new mail"
392 +OP_CATCHUP "mark all articles in newsgroup as read"
393 OP_CHANGE_DIRECTORY "change directories"
394 OP_CHECK_NEW "check mailboxes for new mail"
395 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
396 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
397 +OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message"
398 OP_COMPOSE_EDIT_BCC "edit the BCC list"
399 OP_COMPOSE_EDIT_CC "edit the CC list"
400 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
401 @@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
402 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
403 OP_COMPOSE_EDIT_MESSAGE "edit the message"
404 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
405 +OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
406 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
407 +OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
408 +OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
409 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
410 OP_COMPOSE_EDIT_TO "edit the TO list"
411 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
412 @@ -85,8 +90,13 @@ OP_EXIT "exit this menu"
413 OP_FILTER "filter attachment through a shell command"
414 OP_FIRST_ENTRY "move to the first entry"
415 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
416 +OP_FOLLOWUP "followup to newsgroup"
417 +OP_FORWARD_TO_GROUP "forward to newsgroup"
418 OP_FORWARD_MESSAGE "forward a message with comments"
419 OP_GENERIC_SELECT_ENTRY "select the current entry"
420 +OP_GET_CHILDREN "get all children of the current message"
421 +OP_GET_MESSAGE "get message with Message-Id"
422 +OP_GET_PARENT "get parent of the current message"
423 OP_GROUP_REPLY "reply to all recipients"
424 OP_HALF_DOWN "scroll down 1/2 page"
425 OP_HALF_UP "scroll up 1/2 page"
426 @@ -94,11 +104,14 @@ OP_HELP "this screen"
427 OP_JUMP "jump to an index number"
428 OP_LAST_ENTRY "move to the last entry"
429 OP_LIST_REPLY "reply to specified mailing list"
430 +OP_LOAD_ACTIVE "load active file from NNTP server"
431 OP_MACRO "execute a macro"
432 OP_MAIL "compose a new mail message"
433 OP_MAIN_BREAK_THREAD "break the thread in two"
434 OP_MAIN_CHANGE_FOLDER "open a different folder"
435 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
436 +OP_MAIN_CHANGE_GROUP "open a different newsgroup"
437 +OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
438 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
439 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
440 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
441 @@ -137,6 +150,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
442 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
443 OP_PAGER_TOP "jump to the top of the message"
444 OP_PIPE "pipe message/attachment to a shell command"
445 +OP_POST "post message to newsgroup"
446 OP_PREV_ENTRY "move to the previous entry"
447 OP_PREV_LINE "scroll up one line"
448 OP_PREV_PAGE "move to the previous page"
449 @@ -145,6 +159,7 @@ OP_QUERY "query external program for add
450 OP_QUERY_APPEND "append new query results to current results"
451 OP_QUIT "save changes to mailbox and quit"
452 OP_RECALL_MESSAGE "recall a postponed message"
453 +OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
454 OP_REDRAW "clear and redraw the screen"
455 OP_REFORMAT_WINCH "{internal}"
456 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
457 @@ -159,18 +174,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
458 OP_SHELL_ESCAPE "invoke a command in a subshell"
459 OP_SORT "sort messages"
460 OP_SORT_REVERSE "sort messages in reverse order"
461 +OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
462 OP_TAG "tag the current entry"
463 OP_TAG_PREFIX "apply next function to tagged messages"
464 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
465 OP_TAG_SUBTHREAD "tag the current subthread"
466 OP_TAG_THREAD "tag the current thread"
467 OP_TOGGLE_NEW "toggle a message's 'new' flag"
468 +OP_TOGGLE_READ "toggle view of read messages"
469 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
470 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
471 OP_TOP_PAGE "move to the top of the page"
472 +OP_UNCATCHUP "mark all articles in newsgroup as unread"
473 OP_UNDELETE "undelete the current entry"
474 OP_UNDELETE_THREAD "undelete all messages in thread"
475 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
476 +OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
477 OP_VERSION "show the Mutt version number and date"
478 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
479 OP_VIEW_ATTACHMENTS "show MIME attachments"
480 diff -udprP mutt-1.5.19.orig/PATCHES mutt-1.5.19/PATCHES
481 --- mutt-1.5.19.orig/PATCHES 2008-03-19 22:07:06.000000000 +0200
482 +++ mutt-1.5.19/PATCHES 2009-01-06 22:27:38.000000000 +0200
485 diff -udprP mutt-1.5.19.orig/account.c mutt-1.5.19/account.c
486 --- mutt-1.5.19.orig/account.c 2008-10-30 02:30:17.000000000 +0200
487 +++ mutt-1.5.19/account.c 2009-01-06 22:27:38.000000000 +0200
488 @@ -51,6 +51,11 @@ int mutt_account_match (const ACCOUNT* a
493 + if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
497 if (a1->flags & a2->flags & M_ACCT_USER)
498 return (!strcmp (a1->user, a2->user));
499 if (a1->flags & M_ACCT_USER)
500 @@ -130,6 +135,16 @@ void mutt_account_tourl (ACCOUNT* accoun
505 + if (account->type == M_ACCT_TYPE_NNTP)
507 + if (account->flags & M_ACCT_SSL)
508 + url->scheme = U_NNTPS;
510 + url->scheme = U_NNTP;
514 url->host = account->host;
515 if (account->flags & M_ACCT_PORT)
516 url->port = account->port;
517 @@ -155,6 +170,10 @@ int mutt_account_getuser (ACCOUNT* accou
518 else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
519 strfcpy (account->user, PopUser, sizeof (account->user));
522 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
523 + strfcpy (account->user, NntpUser, sizeof (account->user));
525 /* prompt (defaults to unix username), copy into account->user */
528 @@ -215,6 +234,10 @@ int mutt_account_getpass (ACCOUNT* accou
529 else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass)
530 strfcpy (account->pass, SmtpPass, sizeof (account->pass));
533 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
534 + strfcpy (account->pass, NntpPass, sizeof (account->pass));
538 snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
539 diff -udprP mutt-1.5.19.orig/account.h mutt-1.5.19/account.h
540 --- mutt-1.5.19.orig/account.h 2008-03-19 22:07:06.000000000 +0200
541 +++ mutt-1.5.19/account.h 2009-01-06 22:27:38.000000000 +0200
542 @@ -29,7 +29,8 @@ enum
543 M_ACCT_TYPE_NONE = 0,
552 diff -udprP mutt-1.5.19.orig/attach.h mutt-1.5.19/attach.h
553 --- mutt-1.5.19.orig/attach.h 2008-03-19 22:07:06.000000000 +0200
554 +++ mutt-1.5.19/attach.h 2009-01-06 22:27:38.000000000 +0200
555 @@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f
557 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
558 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
559 -void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
560 +void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
561 void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
563 #endif /* _ATTACH_H_ */
564 diff -udprP mutt-1.5.19.orig/browser.c mutt-1.5.19/browser.c
565 --- mutt-1.5.19.orig/browser.c 2009-01-06 01:36:28.000000000 +0200
566 +++ mutt-1.5.19/browser.c 2009-01-06 22:27:38.000000000 +0200
577 @@ -49,6 +52,19 @@ static struct mapping_t FolderHelp[] = {
582 +static struct mapping_t FolderNewsHelp[] = {
583 + { N_("Exit"), OP_EXIT },
584 + { N_("List"), OP_TOGGLE_MAILBOXES },
585 + { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
586 + { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
587 + { N_("Catchup"), OP_CATCHUP },
588 + { N_("Mask"), OP_ENTER_MASK },
589 + { N_("Help"), OP_HELP },
594 typedef struct folder_t
596 struct folder_file *ff;
597 @@ -114,9 +130,17 @@ static void browser_sort (struct browser
602 + if (option (OPTNEWS))
605 f = browser_compare_date;
609 + if (option (OPTNEWS))
612 f = browser_compare_size;
615 @@ -307,8 +331,106 @@ folder_format_str (char *dest, size_t de
621 +newsgroup_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
622 + const char *fmt, const char *ifstring, const char *elsestring,
623 + unsigned long data, format_flag flags)
625 + char fn[SHORT_STRING], tmp[SHORT_STRING];
626 + FOLDER *folder = (FOLDER *) data;
631 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
632 + snprintf (dest, destlen, tmp, folder->num + 1);
636 + strncpy (fn, folder->ff->name, sizeof(fn) - 1);
637 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
638 + snprintf (dest, destlen, tmp, fn);
642 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
643 + if (folder->ff->nd->subscribed)
644 + snprintf (dest, destlen, tmp, ' ');
646 + snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
650 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
651 + if (folder->ff->nd->deleted)
652 + snprintf (dest, destlen, tmp, 'D');
654 + snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
658 + if (flags & M_FORMAT_OPTIONAL)
660 + if (folder->ff->nd->unread != 0)
661 + mutt_FormatString (dest, destlen, col, ifstring, newsgroup_format_str,
664 + mutt_FormatString (dest, destlen, col, elsestring, newsgroup_format_str,
667 + else if (Context && Context->data == folder->ff->nd)
669 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
670 + snprintf (dest, destlen, tmp, Context->unread);
674 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
675 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
680 + if (Context && Context->data == folder->ff->nd)
682 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
683 + snprintf (dest, destlen, tmp, Context->new);
685 + else if (option (OPTMARKOLD) &&
686 + folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
687 + folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
689 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
690 + snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
694 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
695 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
700 + if (folder->ff->nd->desc != NULL)
702 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
703 + snprintf (dest, destlen, tmp, folder->ff->nd->desc);
707 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
708 + snprintf (dest, destlen, tmp, "");
714 +#endif /* USE_NNTP */
716 static void add_folder (MUTTMENU *m, struct browser_state *state,
717 - const char *name, const struct stat *s, int new)
718 + const char *name, const struct stat *s,
719 + void *data, int new)
721 if (state->entrylen == state->entrymax)
723 @@ -337,6 +459,10 @@ static void add_folder (MUTTMENU *m, str
725 (state->entry)[state->entrylen].imap = 0;
728 + if (option (OPTNEWS))
729 + (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
734 @@ -352,9 +478,35 @@ static void init_state (struct browser_s
735 menu->data = state->entry;
738 +/* get list of all files/newsgroups with mask */
739 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
740 char *d, const char *prefix)
743 + if (option (OPTNEWS))
747 + NNTP_SERVER *news = CurrentNewsSrv;
749 +/* mutt_buffy_check (0); */
750 + init_state (state, menu);
752 + for (tmp = news->list; tmp; tmp = tmp->next)
754 + if (!(data = (NNTP_DATA *)tmp->data))
756 + if (prefix && *prefix && strncmp (prefix, data->group,
757 + strlen (prefix)) != 0)
759 + if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
761 + add_folder (menu, state, data->group, NULL, data, data->new);
765 +#endif /* USE_NNTP */
770 @@ -415,17 +567,40 @@ static int examine_directory (MUTTMENU *
772 while (tmp && mutt_strcmp (buffer, tmp->path))
774 - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
775 + add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
780 browser_sort (state);
784 +/* get list of mailboxes/subscribed newsgroups */
785 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
788 char buffer[LONG_STRING];
791 + if (option (OPTNEWS))
795 + NNTP_SERVER *news = CurrentNewsSrv;
797 +/* mutt_buffy_check (0); */
798 + init_state (state, menu);
800 + for (tmp = news->list; tmp; tmp = tmp->next)
802 + if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
803 + (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
804 + add_folder (menu, state, data->group, NULL, data, data->new);
810 BUFFY *tmp = Incoming;
812 struct mailbox_state mbox;
813 @@ -443,14 +618,21 @@ static int examine_mailboxes (MUTTMENU *
814 if (mx_is_imap (tmp->path))
816 imap_mailbox_state (tmp->path, &mbox);
817 - add_folder (menu, state, tmp->path, NULL, mbox.new);
818 + add_folder (menu, state, tmp->path, NULL, NULL, mbox.new);
823 if (mx_is_pop (tmp->path))
825 - add_folder (menu, state, tmp->path, NULL, tmp->new);
826 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
831 + if (mx_is_nntp (tmp->path))
833 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
837 @@ -464,15 +646,20 @@ static int examine_mailboxes (MUTTMENU *
838 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
839 mutt_pretty_mailbox (buffer, sizeof (buffer));
841 - add_folder (menu, state, buffer, &s, tmp->new);
842 + add_folder (menu, state, buffer, &s, NULL, tmp->new);
844 while ((tmp = tmp->next));
846 browser_sort (state);
850 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
853 + if (option (OPTNEWS))
854 + return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
856 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
859 @@ -483,6 +670,12 @@ static void folder_entry (char *s, size_
860 folder.ff = &((struct folder_file *) menu->data)[num];
864 + if (option (OPTNEWS))
865 + mutt_FormatString (s, slen, 0, NONULL(GroupFormat), newsgroup_format_str,
866 + (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
869 mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str,
870 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
872 @@ -503,6 +696,17 @@ static void init_menu (struct browser_st
877 + if (option (OPTNEWS))
880 + snprintf (title, titlelen, _("Subscribed newsgroups"));
882 + snprintf (title, titlelen, _("Newsgroups on server [%s]"),
883 + CurrentNewsSrv->conn->account.host);
888 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
890 @@ -558,6 +762,31 @@ void _mutt_select_file (char *f, size_t
892 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
895 + if (option (OPTNEWS))
898 + strfcpy (prefix, f, sizeof (prefix));
903 + /* default state for news reader mode is browse subscribed newsgroups */
905 + for (list = CurrentNewsSrv->list; list; list = list->next)
907 + NNTP_DATA *data = (NNTP_DATA *) list->data;
909 + if (data && data->subscribed)
921 mutt_expand_path (f, flen);
922 @@ -654,6 +883,9 @@ void _mutt_select_file (char *f, size_t
923 menu->tag = file_tag;
925 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
927 + (option (OPTNEWS)) ? FolderNewsHelp :
931 init_menu (&state, menu, title, sizeof (title), buffy);
932 @@ -792,7 +1024,11 @@ void _mutt_select_file (char *f, size_t
937 + if (buffy || option (OPTNEWS)) /* news have not path */
942 strfcpy (f, state.entry[menu->current].name, flen);
943 mutt_expand_path (f, flen);
944 @@ -850,14 +1086,6 @@ void _mutt_select_file (char *f, size_t
948 - case OP_BROWSER_SUBSCRIBE:
949 - imap_subscribe (state.entry[menu->current].name, 1);
952 - case OP_BROWSER_UNSUBSCRIBE:
953 - imap_subscribe (state.entry[menu->current].name, 0);
956 case OP_BROWSER_TOGGLE_LSUB:
957 if (option (OPTIMAPLSUB))
958 unset_option (OPTIMAPLSUB);
959 @@ -958,6 +1186,11 @@ void _mutt_select_file (char *f, size_t
961 case OP_CHANGE_DIRECTORY:
964 + if (option (OPTNEWS))
968 strfcpy (buf, LastDir, sizeof (buf));
970 if (!state.imap_browse)
971 @@ -1224,6 +1457,190 @@ void _mutt_select_file (char *f, size_t
973 mutt_error _("Error trying to view file");
980 + if (option (OPTNEWS))
982 + struct folder_file *f = &state.entry[menu->current];
985 + if (i == OP_CATCHUP)
986 + nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
988 + nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
993 + struct folder_file ff;
994 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
997 + folder.ff->name = f->name;
998 + folder.ff->st = NULL;
999 + folder.ff->is_new = nd->new;
1000 + folder.ff->nd = nd;
1002 + mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1003 + newsgroup_format_str, (unsigned long) &folder,
1004 + M_FORMAT_ARROWCURSOR);
1005 + f->desc = safe_strdup (buffer); */
1006 + if (menu->current + 1 < menu->max)
1008 + menu->redraw = REDRAW_MOTION_RESYNCH;
1013 + case OP_LOAD_ACTIVE:
1014 + if (!option (OPTNEWS))
1021 + for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
1023 + if ((data = (NNTP_DATA *)tmp->data))
1024 + data->deleted = 1;
1027 + nntp_get_active (CurrentNewsSrv);
1029 + destroy_state (&state);
1031 + examine_mailboxes (menu, &state);
1033 + examine_directory (menu, &state, NULL, NULL);
1034 + init_menu (&state, menu, title, sizeof (title), buffy);
1036 +#endif /* USE_NNTP */
1038 +#if defined USE_IMAP || defined USE_NNTP
1039 + case OP_BROWSER_SUBSCRIBE:
1040 + case OP_BROWSER_UNSUBSCRIBE:
1043 + case OP_SUBSCRIBE_PATTERN:
1044 + case OP_UNSUBSCRIBE_PATTERN:
1045 + if (option (OPTNEWS))
1047 + regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1049 + int j = menu->current;
1051 + NNTP_SERVER *news = CurrentNewsSrv;
1053 + if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1059 + if (i == OP_SUBSCRIBE_PATTERN)
1060 + snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1062 + snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1063 + if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1069 + if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1071 + regerror (err, rx, buf, sizeof (buf));
1074 + mutt_error ("%s", buf);
1077 + menu->redraw = REDRAW_FULL;
1080 + else if (!state.entrylen)
1082 + mutt_error _("No newsgroups match the mask");
1086 + for ( ; j < state.entrylen; j++)
1088 + struct folder_file *f = &state.entry[j];
1090 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1091 + regexec (rx, f->name, 0, NULL, 0) == 0)
1093 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1094 + nd = mutt_newsgroup_subscribe (news, f->name);
1096 + nd = mutt_newsgroup_unsubscribe (news, f->name);
1100 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1102 + folder.name = f->name;
1104 + folder.new = nd->new;
1107 + mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1108 + newsgroup_format_str, (unsigned long) &folder,
1109 + M_FORMAT_ARROWCURSOR);
1110 + f->desc = safe_strdup (buffer);
1113 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1115 + if (menu->current + 1 < menu->max)
1117 + menu->redraw = REDRAW_MOTION_RESYNCH;
1121 + if (i == OP_SUBSCRIBE_PATTERN)
1123 + LIST *grouplist = NULL;
1126 + grouplist = news->list;
1127 + for (; grouplist; grouplist = grouplist->next)
1129 + nd = (NNTP_DATA *) grouplist->data;
1130 + if (nd && nd->group && !nd->subscribed)
1132 + if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1134 + mutt_newsgroup_subscribe (news, nd->group);
1135 + add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1139 + init_menu (&state, menu, title, sizeof (title), buffy);
1141 + mutt_newsrc_update (news);
1142 + nntp_clear_cacheindex (news);
1143 + if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1149 +#endif /* USE_IMAP && USE_NNTP */
1150 +#endif /* USE_NNTP */
1153 + if (i == OP_BROWSER_SUBSCRIBE)
1154 + imap_subscribe (state.entry[menu->current].name, 1);
1156 + imap_subscribe (state.entry[menu->current].name, 0);
1158 +#endif /* USE_IMAP */
1162 diff -udprP mutt-1.5.19.orig/browser.h mutt-1.5.19/browser.h
1163 --- mutt-1.5.19.orig/browser.h 2009-01-05 21:20:53.000000000 +0200
1164 +++ mutt-1.5.19/browser.h 2009-01-06 22:27:38.000000000 +0200
1167 #define _BROWSER_H 1
1176 @@ -37,6 +41,9 @@ struct folder_file
1177 unsigned selectable : 1;
1178 unsigned inferiors : 1;
1183 unsigned tagged : 1;
1186 diff -udprP mutt-1.5.19.orig/buffy.c mutt-1.5.19/buffy.c
1187 --- mutt-1.5.19.orig/buffy.c 2008-08-30 02:39:48.000000000 +0300
1188 +++ mutt-1.5.19/buffy.c 2009-01-06 22:27:38.000000000 +0200
1189 @@ -285,6 +285,9 @@ int mutt_buffy_check (int force)
1191 if (!Context || Context->magic != M_POP)
1194 + if (!Context || Context->magic != M_NNTP)
1196 /* check device ID and serial number instead of comparing paths */
1197 if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0)
1199 @@ -308,6 +311,11 @@ int mutt_buffy_check (int force)
1204 + if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1205 + tmp->magic = M_NNTP;
1208 if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
1209 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1211 @@ -325,25 +333,21 @@ int mutt_buffy_check (int force)
1212 /* check to see if the folder is the currently selected folder
1214 if (!Context || !Context->path ||
1215 -#if defined USE_IMAP || defined USE_POP
1220 - tmp->magic == M_IMAP
1221 + || tmp->magic == M_IMAP
1227 - tmp->magic == M_POP
1229 - ) ? mutt_strcmp (tmp->path, Context->path) :
1230 + || tmp->magic == M_POP
1232 - (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1233 -#if defined USE_IMAP || defined USE_POP
1236 + || tmp->magic == M_NNTP
1240 + ) ? mutt_strcmp (tmp->path, Context->path) :
1241 + (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1247 diff -udprP mutt-1.5.19.orig/complete.c mutt-1.5.19/complete.c
1248 --- mutt-1.5.19.orig/complete.c 2009-01-05 21:20:53.000000000 +0200
1249 +++ mutt-1.5.19/complete.c 2009-01-06 22:27:38.000000000 +0200
1251 #include "mailbox.h"
1260 @@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen)
1261 char filepart[_POSIX_PATH_MAX];
1263 char imap_path[LONG_STRING];
1266 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1269 + if (option (OPTNEWS))
1271 + LIST *l = CurrentNewsSrv->list;
1273 + strfcpy (filepart, s, sizeof (filepart));
1276 + * special case to handle when there is no filepart yet.
1277 + * find the first subscribed newsgroup
1279 + if ((len = mutt_strlen (filepart)) == 0)
1281 + for (; l; l = l->next)
1283 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1285 + if (data && data->subscribed)
1287 + strfcpy (filepart, data->group, sizeof (filepart));
1295 + for (; l; l = l->next)
1297 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1299 + if (data && data->subscribed &&
1300 + mutt_strncmp (data->group, filepart, len) == 0)
1304 + for (i = 0; filepart[i] && data->group[i]; i++)
1306 + if (filepart[i] != data->group[i])
1316 + strfcpy (filepart, data->group, sizeof (filepart));
1322 + strcpy (s, filepart);
1324 + return (init ? 0 : -1);
1329 /* we can use '/' as a delimiter, imap_complete rewrites it */
1330 if (*s == '=' || *s == '+' || *s == '!')
1332 diff -udprP mutt-1.5.19.orig/compose.c mutt-1.5.19/compose.c
1333 --- mutt-1.5.19.orig/compose.c 2009-01-05 21:20:53.000000000 +0200
1334 +++ mutt-1.5.19/compose.c 2009-01-06 22:27:38.000000000 +0200
1336 #include "mailbox.h"
1338 #include "charset.h"
1342 #include "remailer.h"
1351 @@ -60,18 +65,21 @@ enum
1368 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1371 -#define HDR_XOFFSET 10
1372 -#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1373 +#define HDR_XOFFSET 14
1374 +#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1375 #define W (COLS - HDR_XOFFSET)
1377 static char *Prompts[] =
1378 @@ -83,6 +91,16 @@ static char *Prompts[] =
1394 static struct mapping_t ComposeHelp[] = {
1395 @@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] =
1400 +static struct mapping_t ComposeNewsHelp[] = {
1401 + { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1402 + { N_("Abort"), OP_EXIT },
1403 + { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1404 + { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1405 + { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1406 + { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1407 + { N_("Help"), OP_HELP },
1412 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1414 mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt,
1415 @@ -115,16 +146,16 @@ static void redraw_crypt_lines (HEADER *
1416 if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
1419 - mvaddstr (HDR_CRYPT, 0, "Security: ");
1420 + mvaddstr (HDR_CRYPT, 0, " Security: ");
1421 else if (msg->security & APPLICATION_SMIME)
1422 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1423 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1424 else if (msg->security & APPLICATION_PGP)
1425 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1426 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1428 else if ((WithCrypto & APPLICATION_SMIME))
1429 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1430 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1431 else if ((WithCrypto & APPLICATION_PGP))
1432 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1433 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1437 @@ -252,9 +283,28 @@ static void draw_envelope_addr (int line
1438 static void draw_envelope (HEADER *msg, char *fcc)
1440 draw_envelope_addr (HDR_FROM, msg->env->from);
1442 + if (!option (OPTNEWSSEND))
1445 draw_envelope_addr (HDR_TO, msg->env->to);
1446 draw_envelope_addr (HDR_CC, msg->env->cc);
1447 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1452 + mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1453 + mutt_paddstr (W, NONULL (msg->env->newsgroups));
1454 + mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1455 + mutt_paddstr (W, NONULL (msg->env->followup_to));
1456 + if (option (OPTXCOMMENTTO))
1458 + mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1459 + mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1463 mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1464 mutt_paddstr (W, NONULL (msg->env->subject));
1465 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1466 @@ -507,6 +557,12 @@ int mutt_compose_menu (HEADER *msg, /*
1467 /* Sort, SortAux could be changed in mutt_index_menu() */
1468 int oldSort, oldSortAux;
1471 + int news = 0; /* is it a news article ? */
1473 + if (option (OPTNEWSSEND))
1477 mutt_attach_init (msg->content);
1478 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
1479 @@ -517,10 +573,18 @@ int mutt_compose_menu (HEADER *msg, /*
1480 menu->make_entry = snd_entry;
1481 menu->tag = mutt_tag_attach;
1485 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1488 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1493 + unset_option (OPTNEWS); /* for any case */
1495 switch (op = mutt_menuLoop (menu))
1498 @@ -533,17 +597,87 @@ int mutt_compose_menu (HEADER *msg, /*
1499 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1501 case OP_COMPOSE_EDIT_TO:
1506 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1507 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1509 case OP_COMPOSE_EDIT_BCC:
1514 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1515 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1517 case OP_COMPOSE_EDIT_CC:
1522 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1523 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1526 + case OP_COMPOSE_EDIT_NEWSGROUPS:
1529 + if (msg->env->newsgroups)
1530 + strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1533 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1535 + FREE (&msg->env->newsgroups);
1536 + mutt_remove_trailing_ws (buf);
1537 + msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1538 + move (HDR_TO, HDR_XOFFSET);
1540 + if (msg->env->newsgroups)
1541 + printw ("%-*.*s", W, W, msg->env->newsgroups);
1546 + case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1550 + if (msg->env->followup_to)
1551 + strfcpy (buf, msg->env->followup_to, sizeof (buf));
1552 + if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1554 + FREE (&msg->env->followup_to);
1555 + mutt_remove_trailing_ws (buf);
1556 + msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1557 + move (HDR_CC, HDR_XOFFSET);
1559 + if (msg->env->followup_to)
1560 + printw ("%-*.*s", W, W, msg->env->followup_to);
1565 + case OP_COMPOSE_EDIT_X_COMMENT_TO:
1566 + if (news && option (OPTXCOMMENTTO))
1569 + if (msg->env->x_comment_to)
1570 + strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1571 + if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1573 + FREE (&msg->env->x_comment_to);
1574 + msg->env->x_comment_to = safe_strdup (buf);
1575 + move (HDR_BCC, HDR_XOFFSET);
1577 + if (msg->env->x_comment_to)
1578 + printw ("%-*.*s", W, W, msg->env->x_comment_to);
1583 case OP_COMPOSE_EDIT_SUBJECT:
1584 if (msg->env->subject)
1585 strfcpy (buf, msg->env->subject, sizeof (buf));
1586 @@ -706,6 +840,9 @@ int mutt_compose_menu (HEADER *msg, /*
1589 case OP_COMPOSE_ATTACH_MESSAGE:
1591 + case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1596 @@ -713,7 +850,22 @@ int mutt_compose_menu (HEADER *msg, /*
1598 prompt = _("Open mailbox to attach message from");
1601 + unset_option (OPTNEWS);
1602 + if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1604 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1607 + prompt = _("Open newsgroup to attach message from");
1608 + set_option (OPTNEWS);
1614 + if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1617 strfcpy (fname, NONULL (Context->path), sizeof (fname));
1618 mutt_pretty_mailbox (fname, sizeof (fname));
1619 @@ -722,6 +874,11 @@ int mutt_compose_menu (HEADER *msg, /*
1620 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1624 + if (option (OPTNEWS))
1625 + nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1628 mutt_expand_path (fname, sizeof (fname));
1630 if (!mx_is_imap (fname))
1631 @@ -729,6 +886,9 @@ int mutt_compose_menu (HEADER *msg, /*
1633 if (!mx_is_pop (fname))
1636 + if (!mx_is_nntp (fname) && !option (OPTNEWS))
1638 /* check to make sure the file exists and is readable */
1639 if (access (fname, R_OK) == -1)
1641 diff -udprP mutt-1.5.19.orig/config.h.in mutt-1.5.19/config.h.in
1642 --- mutt-1.5.19.orig/config.h.in 2008-11-18 01:54:00.000000000 +0200
1643 +++ mutt-1.5.19/config.h.in 2009-01-06 22:27:38.000000000 +0200
1645 significant more memory when defined. */
1646 #undef EXACT_ADDRESS
1648 +/* Compiling with newsreading support with NNTP */
1651 /* program to use for shell commands */
1654 diff -udprP mutt-1.5.19.orig/configure.ac mutt-1.5.19/configure.ac
1655 --- mutt-1.5.19.orig/configure.ac 2008-11-17 22:15:26.000000000 +0200
1656 +++ mutt-1.5.19/configure.ac 2009-01-06 22:27:38.000000000 +0200
1657 @@ -598,6 +598,14 @@ if test x"$need_imap" = xyes -o x"$need_
1658 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1661 +AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1662 +[ if test x$enableval = xyes ; then
1663 + AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1664 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1669 dnl -- end socket dependencies --
1671 if test "$need_socket" = "yes"
1672 diff -udprP mutt-1.5.19.orig/curs_main.c mutt-1.5.19/curs_main.c
1673 --- mutt-1.5.19.orig/curs_main.c 2009-01-05 21:20:53.000000000 +0200
1674 +++ mutt-1.5.19/curs_main.c 2009-01-06 22:27:38.000000000 +0200
1678 #include "mutt_curses.h"
1680 #include "mutt_menu.h"
1681 #include "mailbox.h"
1682 #include "mapping.h"
1685 #include "mutt_crypt.h"
1694 @@ -413,12 +418,27 @@ static struct mapping_t IndexHelp[] = {
1699 +struct mapping_t IndexNewsHelp[] = {
1700 + { N_("Quit"), OP_QUIT },
1701 + { N_("Del"), OP_DELETE },
1702 + { N_("Undel"), OP_UNDELETE },
1703 + { N_("Save"), OP_SAVE },
1704 + { N_("Post"), OP_POST },
1705 + { N_("Followup"), OP_FOLLOWUP },
1706 + { N_("Catchup"), OP_CATCHUP },
1707 + { N_("Help"), OP_HELP },
1712 /* This function handles the message index window as well as commands returned
1713 * from the pager (MENU_PAGER).
1715 int mutt_index_menu (void)
1717 char buf[LONG_STRING], helpstr[LONG_STRING];
1720 int done = 0; /* controls when to exit the "event" loop */
1722 @@ -439,7 +459,11 @@ int mutt_index_menu (void)
1723 menu->make_entry = index_make_entry;
1724 menu->color = index_color;
1725 menu->current = ci_first_message ();
1726 - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1727 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1729 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1734 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
1735 @@ -690,6 +714,9 @@ int mutt_index_menu (void)
1736 imap_disallow_reopen (Context);
1740 + unset_option (OPTNEWS); /* for any case */
1745 @@ -740,6 +767,120 @@ int mutt_index_menu (void)
1746 menu_current_bottom (menu);
1750 + case OP_GET_MESSAGE:
1751 + case OP_GET_PARENT:
1753 + if (Context->magic == M_NNTP)
1757 + if (op == OP_GET_MESSAGE)
1760 + if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1766 + LIST *ref = CURHDR->env->references;
1769 + mutt_error _("Article has no parent reference!");
1772 + strfcpy (buf, ref->data, sizeof (buf));
1774 + if (!Context->id_hash)
1775 + Context->id_hash = mutt_make_id_hash (Context);
1776 + if ((h = hash_find (Context->id_hash, buf)))
1778 + if (h->virtual != -1)
1780 + menu->current = h->virtual;
1781 + menu->redraw = REDRAW_MOTION_RESYNCH;
1783 + else if (h->collapsed)
1785 + mutt_uncollapse_thread (Context, h);
1786 + mutt_set_virtual (Context);
1787 + menu->current = h->virtual;
1788 + menu->redraw = REDRAW_MOTION_RESYNCH;
1791 + mutt_error _("Message not visible in limited view.");
1795 + if (nntp_check_msgid (Context, buf) == 0)
1797 + h = Context->hdrs[Context->msgcount-1];
1798 + mutt_sort_headers (Context, 0);
1799 + menu->current = h->virtual;
1800 + menu->redraw = REDRAW_FULL;
1803 + mutt_error (_("Article %s not found on server"), buf);
1808 + case OP_GET_CHILDREN:
1809 + case OP_RECONSTRUCT_THREAD:
1811 + if (Context->magic == M_NNTP)
1814 + int old = CURHDR->index, i;
1816 + if (!CURHDR->env->message_id)
1818 + mutt_error _("No Message-Id. Unable to perform operation");
1822 + if (!Context->id_hash)
1823 + Context->id_hash = mutt_make_id_hash (Context);
1824 + strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1826 + if (op == OP_RECONSTRUCT_THREAD)
1828 + LIST *ref = CURHDR->env->references;
1831 + nntp_check_msgid (Context, ref->data);
1832 + /* the last msgid in References is the root message */
1834 + strfcpy (buf, ref->data, sizeof (buf));
1838 + mutt_message _("Check for children of message...");
1839 + if (nntp_check_children (Context, buf) == 0)
1841 + mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1842 + h = hash_find (Context->id_hash, buf);
1843 + /* if the root message was retrieved, move to it */
1845 + menu->current = h->virtual;
1846 + else /* try to restore old position */
1847 + for (i = 0; i < Context->msgcount; i++)
1848 + if (Context->hdrs[i]->index == old)
1850 + menu->current = Context->hdrs[i]->virtual;
1851 + /* As an added courtesy, recenter the menu
1852 + * with the current entry at the middle of the screen */
1853 + menu_check_recenter (menu);
1854 + menu_current_middle (menu);
1857 + menu->redraw = REDRAW_FULL;
1858 + mutt_clear_error ();
1866 @@ -837,11 +978,33 @@ int mutt_index_menu (void)
1870 + case OP_TOGGLE_READ:
1873 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1875 - if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1876 + if (op == OP_TOGGLE_READ)
1878 + char buf[LONG_STRING];
1880 + if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1882 + snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1883 + Context->pattern ? Context->pattern : ".*");
1884 + set_option (OPTHIDEREAD);
1888 + strfcpy (buf, Context->pattern + 8, sizeof(buf));
1889 + if (!*buf || strncmp (buf, ".*", 2) == 0)
1890 + snprintf (buf, sizeof(buf), "~A");
1891 + unset_option (OPTHIDEREAD);
1893 + FREE (&Context->pattern);
1894 + Context->pattern = safe_strdup (buf);
1896 + if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1897 + mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1899 if (menu->oldcurrent >= 0)
1901 @@ -1050,15 +1213,22 @@ int mutt_index_menu (void)
1903 case OP_MAIN_CHANGE_FOLDER:
1904 case OP_MAIN_NEXT_UNREAD_MAILBOX:
1907 - op = OP_MAIN_CHANGE_FOLDER_READONLY;
1909 - /* fallback to the readonly case */
1911 case OP_MAIN_CHANGE_FOLDER_READONLY:
1913 + case OP_MAIN_CHANGE_GROUP:
1914 + case OP_MAIN_CHANGE_GROUP_READONLY:
1915 + unset_option (OPTNEWS);
1917 + if (attach_msg || option (OPTREADONLY) ||
1919 + op == OP_MAIN_CHANGE_GROUP_READONLY ||
1921 + op == OP_MAIN_CHANGE_FOLDER_READONLY)
1922 + flags = M_READONLY;
1926 - if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1928 cp = _("Open mailbox in read-only mode");
1930 cp = _("Open mailbox");
1931 @@ -1077,6 +1247,21 @@ int mutt_index_menu (void)
1936 + if (op == OP_MAIN_CHANGE_GROUP ||
1937 + op == OP_MAIN_CHANGE_GROUP_READONLY)
1939 + set_option (OPTNEWS);
1940 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1943 + cp = _("Open newsgroup in read-only mode");
1945 + cp = _("Open newsgroup");
1950 mutt_buffy (buf, sizeof (buf));
1952 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1953 @@ -1096,6 +1281,14 @@ int mutt_index_menu (void)
1958 + if (option (OPTNEWS))
1960 + unset_option (OPTNEWS);
1961 + nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1965 mutt_expand_path (buf, sizeof (buf));
1966 if (mx_get_magic (buf) <= 0)
1968 @@ -1133,15 +1326,18 @@ int mutt_index_menu (void)
1969 CurrentMenu = MENU_MAIN;
1970 mutt_folder_hook (buf);
1972 - if ((Context = mx_open_mailbox (buf,
1973 - (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1974 - M_READONLY : 0, NULL)) != NULL)
1975 + if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1977 menu->current = ci_first_message ();
1983 + /* mutt_buffy_check() must be done with mail-reader mode! */
1984 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1985 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1987 mutt_clear_error ();
1988 mutt_buffy_check(1); /* force the buffy check after we have changed
1990 @@ -1512,6 +1708,15 @@ int mutt_index_menu (void)
1992 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1995 + if (Context->magic == M_NNTP)
1998 + mutt_error _("Can't change 'important' flag on NNTP server.");
2005 for (j = 0; j < Context->vcount; j++)
2006 @@ -1859,6 +2064,17 @@ int mutt_index_menu (void)
2012 + if (Context && Context->magic == M_NNTP)
2014 + if (mutt_newsgroup_catchup (CurrentNewsSrv,
2015 + ((NNTP_DATA *)Context->data)->group))
2016 + menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2021 case OP_DISPLAY_ADDRESS:
2024 @@ -1986,6 +2202,15 @@ int mutt_index_menu (void)
2025 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2030 + if (Context->magic == M_NNTP)
2033 + mutt_error _("Can't edit message on newsserver.");
2038 MAYBE_REDRAW (menu->redraw);
2040 @@ -2057,6 +2282,41 @@ int mutt_index_menu (void)
2042 menu->redraw = REDRAW_FULL;
2047 + case OP_FORWARD_TO_GROUP:
2055 + if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2056 + mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2057 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2059 + if (Context && Context->magic == M_NNTP &&
2060 + !((NNTP_DATA *)Context->data)->allowed &&
2061 + query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2063 + if (op == OP_POST)
2064 + ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2068 + if (op == OP_FOLLOWUP)
2069 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2070 + tag ? NULL : CURHDR);
2072 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2073 + tag ? NULL : CURHDR);
2075 + menu->redraw = REDRAW_FULL;
2082 @@ -2133,6 +2393,12 @@ int mutt_index_menu (void)
2084 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2087 + /* Close all open NNTP connections */
2089 + nntp_logout_all ();
2092 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2093 op == OP_UNDELETE_THREAD ? 0 : 1);
2095 diff -udprP mutt-1.5.19.orig/doc/manual.xml.head mutt-1.5.19/doc/manual.xml.head
2096 --- mutt-1.5.19.orig/doc/manual.xml.head 2009-01-05 21:20:53.000000000 +0200
2097 +++ mutt-1.5.19/doc/manual.xml.head 2009-01-06 22:27:38.000000000 +0200
2098 @@ -1388,6 +1388,22 @@ fo-table</literal> for details.
2103 +<title>Reading news via NNTP</title>
2106 +If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2107 +read news from newsserver via NNTP. You can open a newsgroup with
2108 +function ``change-newsgroup'' (default: ``i''). Default newsserver
2109 +can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2110 +variable. Like other news readers, info about subscribed newsgroups
2111 +is saved in file by <link linkend="newsrc">$newsrc</link>
2112 +variable. Article headers are cached and can be loaded from file when
2113 +newsgroup entered instead loading from newsserver.
2120 <sect1 id="forwarding-mail">
2121 diff -udprP mutt-1.5.19.orig/doc/mutt.man mutt-1.5.19/doc/mutt.man
2122 --- mutt-1.5.19.orig/doc/mutt.man 2009-01-05 22:18:18.000000000 +0200
2123 +++ mutt-1.5.19/doc/mutt.man 2009-01-06 22:27:38.000000000 +0200
2124 @@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2129 -[-e \fIcmd\fP] [-F \fIfile\fP] [-m \fItype\fP] [-f \fIfile\fP]
2131 +[-e \fIcmd\fP] [-F \fIfile\fP] [-g \fIserver\fP] [-m \fItype\fP] [-f \fIfile\fP]
2135 @@ -101,6 +101,10 @@ files.
2136 Specify which mailbox to load.
2137 .IP "-F \fImuttrc\fP"
2138 Specify an initialization file to read instead of ~/.muttrc
2139 +.IP "-g \fIserver\fP"
2140 +Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2142 +Start Mutt with a listing of subscribed newsgroups.
2145 .IP "-H \fIdraft\fP"
2146 diff -udprP mutt-1.5.19.orig/functions.h mutt-1.5.19/functions.h
2147 --- mutt-1.5.19.orig/functions.h 2009-01-05 21:20:53.000000000 +0200
2148 +++ mutt-1.5.19/functions.h 2009-01-06 22:27:38.000000000 +0200
2149 @@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in
2150 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2151 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2152 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2154 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2155 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2157 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2158 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2159 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
2160 @@ -101,7 +105,15 @@ struct binding_t OpMain[] = { /* map: in
2161 { "edit", OP_EDIT_MESSAGE, "e" },
2162 { "edit-type", OP_EDIT_TYPE, "\005" },
2163 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2164 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2166 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2167 + { "followup-message", OP_FOLLOWUP, "F" },
2168 + { "get-children", OP_GET_CHILDREN, NULL },
2169 + { "get-message", OP_GET_MESSAGE, "\007" },
2170 + { "get-parent", OP_GET_PARENT, "\033G" },
2171 + { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2173 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2174 { "group-reply", OP_GROUP_REPLY, "g" },
2176 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2177 @@ -127,6 +139,9 @@ struct binding_t OpMain[] = { /* map: in
2178 { "sort-mailbox", OP_SORT, "o" },
2179 { "sort-reverse", OP_SORT_REVERSE, "O" },
2180 { "print-message", OP_PRINT, "p" },
2182 + { "post-message", OP_POST, "P" },
2184 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2185 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2186 { "recall-message", OP_RECALL_MESSAGE, "R" },
2187 @@ -146,6 +161,10 @@ struct binding_t OpMain[] = { /* map: in
2188 { "show-version", OP_VERSION, "V" },
2189 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2190 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2191 + { "toggle-read", OP_TOGGLE_READ, "X" },
2193 + { "catchup", OP_CATCHUP, "y" },
2195 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2196 { "buffy-list", OP_BUFFY_LIST, "." },
2197 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
2198 @@ -157,7 +176,7 @@ struct binding_t OpMain[] = { /* map: in
2199 { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" },
2200 { "next-unread", OP_MAIN_NEXT_UNREAD, NULL },
2201 { "previous-unread", OP_MAIN_PREV_UNREAD, NULL },
2202 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2203 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2206 { "extract-keys", OP_EXTRACT_KEYS, "\013" },
2207 @@ -177,6 +196,10 @@ struct binding_t OpPager[] = { /* map: p
2208 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2209 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2210 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2212 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2213 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2215 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2216 { "copy-message", OP_COPY_MESSAGE, "C" },
2217 { "decode-copy", OP_DECODE_COPY, "\033C" },
2218 @@ -185,8 +208,12 @@ struct binding_t OpPager[] = { /* map: p
2219 { "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" },
2220 { "edit", OP_EDIT_MESSAGE, "e" },
2221 { "edit-type", OP_EDIT_TYPE, "\005" },
2223 + { "followup-message", OP_FOLLOWUP, "F" },
2224 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2226 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2227 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2228 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2229 { "group-reply", OP_GROUP_REPLY, "g" },
2231 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
2232 @@ -205,6 +232,9 @@ struct binding_t OpPager[] = { /* map: p
2233 { "next-thread", OP_MAIN_NEXT_THREAD, "\016" },
2234 { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" },
2235 { "print-message", OP_PRINT, "p" },
2237 + { "post-message", OP_POST, "P" },
2239 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2240 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2241 { "quit", OP_QUIT, "Q" },
2242 @@ -252,7 +282,7 @@ struct binding_t OpPager[] = { /* map: p
2243 { "half-down", OP_HALF_DOWN, NULL },
2244 { "previous-line", OP_PREV_LINE, NULL },
2245 { "bottom", OP_PAGER_BOTTOM, NULL },
2246 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2247 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2251 @@ -273,6 +303,10 @@ struct binding_t OpAttach[] = { /* map:
2252 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2253 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2254 { "edit-type", OP_EDIT_TYPE, "\005" },
2256 + { "followup-message", OP_FOLLOWUP, "F" },
2257 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2259 { "print-entry", OP_PRINT, "p" },
2260 { "save-entry", OP_SAVE, "s" },
2261 { "pipe-entry", OP_PIPE, "|" },
2262 @@ -298,6 +332,7 @@ struct binding_t OpAttach[] = { /* map:
2263 struct binding_t OpCompose[] = { /* map: compose */
2264 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2265 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2266 + { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2267 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2268 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2269 { "copy-file", OP_SAVE, "C" },
2270 @@ -317,6 +352,11 @@ struct binding_t OpCompose[] = { /* map:
2271 { "print-entry", OP_PRINT, "l" },
2272 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2273 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2275 + { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2276 + { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2277 + { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2279 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2280 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2281 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
2282 @@ -368,14 +408,25 @@ struct binding_t OpBrowser[] = { /* map:
2283 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2284 { "check-new", OP_CHECK_NEW, NULL },
2285 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2287 + { "reload-active", OP_LOAD_ACTIVE, "g" },
2288 + { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2289 + { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2290 + { "catchup", OP_CATCHUP, "y" },
2291 + { "uncatchup", OP_UNCATCHUP, "Y" },
2293 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2294 { "buffy-list", OP_BUFFY_LIST, "." },
2296 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2297 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2298 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2300 +#if defined USE_IMAP || defined USE_NNTP
2301 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2302 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2305 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2308 diff -udprP mutt-1.5.19.orig/globals.h mutt-1.5.19/globals.h
2309 --- mutt-1.5.19.orig/globals.h 2009-01-04 01:27:10.000000000 +0200
2310 +++ mutt-1.5.19/globals.h 2009-01-06 22:27:38.000000000 +0200
2311 @@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
2314 WHERE char *Muttrc INITVAL (NULL);
2316 +WHERE char *NewsCacheDir;
2317 +WHERE char *GroupFormat;
2319 +WHERE char *NewsServer;
2320 +WHERE char *NntpUser;
2321 +WHERE char *NntpPass;
2322 +WHERE char *NewsRc;
2326 WHERE char *PagerFmt;
2327 @@ -187,6 +196,11 @@ extern unsigned char QuadOptions[];
2329 WHERE unsigned short Counter INITVAL (0);
2332 +WHERE short NewsPollTimeout;
2333 +WHERE short NntpContext;
2336 WHERE short ConnectTimeout;
2337 WHERE short HistSize;
2338 WHERE short MenuContext;
2339 diff -udprP mutt-1.5.19.orig/hash.c mutt-1.5.19/hash.c
2340 --- mutt-1.5.19.orig/hash.c 2009-01-04 01:27:10.000000000 +0200
2341 +++ mutt-1.5.19/hash.c 2009-01-06 22:27:38.000000000 +0200
2342 @@ -45,10 +45,35 @@ HASH *hash_create (int nelem)
2345 table->nelem = nelem;
2346 + table->curnelem = 0;
2347 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2351 +HASH *hash_resize (HASH *ptr, int nelem)
2354 + struct hash_elem *elem, *tmp;
2357 + table = hash_create (nelem);
2359 + for (i = 0; i < ptr->nelem; i++)
2361 + for (elem = ptr->table[i]; elem; )
2364 + elem = elem->next;
2365 + hash_insert (table, tmp->key, tmp->data, 1);
2369 + FREE (&ptr->table);
2375 /* table hash table to update
2376 * key key to hash on
2377 * data data to associate with `key'
2378 @@ -68,6 +93,7 @@ int hash_insert (HASH * table, const cha
2380 ptr->next = table->table[h];
2381 table->table[h] = ptr;
2382 + table->curnelem++;
2386 @@ -90,6 +116,7 @@ int hash_insert (HASH * table, const cha
2388 table->table[h] = ptr;
2390 + table->curnelem++;
2394 @@ -120,6 +147,7 @@ void hash_delete_hash (HASH * table, int
2396 destroy (ptr->data);
2398 + table->curnelem--;
2402 diff -udprP mutt-1.5.19.orig/hash.h mutt-1.5.19/hash.h
2403 --- mutt-1.5.19.orig/hash.h 2009-01-04 01:27:10.000000000 +0200
2404 +++ mutt-1.5.19/hash.h 2009-01-06 22:27:38.000000000 +0200
2405 @@ -28,7 +28,7 @@ struct hash_elem
2410 + int nelem, curnelem;
2411 struct hash_elem **table;
2414 @@ -40,6 +40,7 @@ HASH;
2415 HASH *hash_create (int nelem);
2416 unsigned int hash_string (const unsigned char *s, unsigned int n);
2417 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2418 +HASH *hash_resize (HASH * table, int nelem);
2419 void *hash_find_hash (const HASH * table, int hash, const char *key);
2420 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2421 void (*destroy) (void *));
2422 diff -udprP mutt-1.5.19.orig/hdrline.c mutt-1.5.19/hdrline.c
2423 --- mutt-1.5.19.orig/hdrline.c 2009-01-05 21:20:53.000000000 +0200
2424 +++ mutt-1.5.19/hdrline.c 2009-01-06 22:27:38.000000000 +0200
2425 @@ -209,6 +209,7 @@ int mutt_user_is_recipient (HEADER *h)
2426 * %E = number of messages in current thread
2427 * %f = entire from line
2428 * %F = like %n, unless from self
2429 + * %g = newsgroup name (if compiled with nntp support)
2431 * %l = number of lines in the message
2432 * %L = like %F, except `lists' are displayed first
2433 @@ -217,12 +218,14 @@ int mutt_user_is_recipient (HEADER *h)
2435 * %O = like %L, except using address instead of name
2436 * %P = progress indicator for builtin pager
2437 + * %R = `x-comment-to:' field (if present and compiled with nntp support)
2439 * %S = short message status (e.g., N/O/D/!/r/-)
2440 * %t = `to:' field (recipients)
2442 * %u = user (login) name of author
2443 * %v = first name of author, unless from self
2444 + * %W = where user is (organization)
2445 * %X = number of MIME attachments
2446 * %y = `x-label:' field (if present)
2447 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2448 @@ -455,6 +458,12 @@ hdr_format_str (char *dest,
2454 + mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2459 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2461 @@ -546,6 +555,15 @@ hdr_format_str (char *dest,
2462 strfcpy(dest, NONULL(hfi->pager_progress), destlen);
2468 + mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2469 + else if (!hdr->env->x_comment_to)
2476 if (flags & M_FORMAT_TREE && !hdr->collapsed)
2477 @@ -635,6 +653,13 @@ hdr_format_str (char *dest,
2478 mutt_format_s (dest, destlen, prefix, buf2);
2483 + mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2484 + else if (!hdr->env->organization)
2491 diff -udprP mutt-1.5.19.orig/headers.c mutt-1.5.19/headers.c
2492 --- mutt-1.5.19.orig/headers.c 2008-08-15 21:30:12.000000000 +0300
2493 +++ mutt-1.5.19/headers.c 2009-01-06 22:27:38.000000000 +0200
2494 @@ -118,6 +118,9 @@ void mutt_edit_headers (const char *edit
2495 msg->env = n; n = NULL;
2497 if (!msg->env->in_reply_to)
2499 + if (!option (OPTNEWSSEND))
2501 mutt_free_list (&msg->env->references);
2503 mutt_expand_aliases_env (msg->env);
2504 diff -udprP mutt-1.5.19.orig/init.c mutt-1.5.19/init.c
2505 --- mutt-1.5.19.orig/init.c 2009-01-05 21:20:53.000000000 +0200
2506 +++ mutt-1.5.19/init.c 2009-01-06 22:27:38.000000000 +0200
2507 @@ -2965,6 +2965,28 @@ void mutt_init (int skip_sys_rc, LIST *c
2509 Fqdn = safe_strdup(NONULL(Hostname));
2516 + if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2519 + fgets (buffer, sizeof (buffer), f);
2523 + while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2525 + NewsServer = safe_strdup (p);
2529 + if ((p = getenv ("NNTPSERVER")))
2530 + NewsServer = safe_strdup (p);
2533 if ((p = getenv ("MAIL")))
2534 Spoolfile = safe_strdup (p);
2535 else if ((p = getenv ("MAILDIR")))
2536 diff -udprP mutt-1.5.19.orig/init.h mutt-1.5.19/init.h
2537 --- mutt-1.5.19.orig/init.h 2009-01-05 21:20:53.000000000 +0200
2538 +++ mutt-1.5.19/init.h 2009-01-06 22:27:38.000000000 +0200
2539 @@ -176,6 +176,20 @@ struct option_t MuttVars[] = {
2540 ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before
2541 ** editing the body of an outgoing message.
2544 + { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2547 + ** If set, Mutt will prompt you for follow-up groups before editing
2548 + ** the body of an outgoing message.
2550 + { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2553 + ** If set, Mutt will prompt you for x-comment-to field before editing
2554 + ** the body of an outgoing message.
2557 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2560 @@ -329,6 +343,14 @@ struct option_t MuttVars[] = {
2561 ** mailbox by performing a fast mailbox scan when it is defined.
2562 ** Afterwards the new mail status is tracked by file size changes.
2565 + { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2568 + ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2569 + ** as read when you quit the newsgroup (catchup newsgroup).
2572 { "charset", DT_STR, R_NONE, UL &Charset, UL 0 },
2575 @@ -690,6 +712,16 @@ struct option_t MuttVars[] = {
2576 ** sent to both the list and your address, resulting in two copies
2577 ** of the same email for you.
2580 + { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2583 + ** If this variable is \fIset\fP and the keyword "poster" is present in
2584 + ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2585 + ** permitted. The message will be mailed to the submitter of the
2586 + ** message via mail.
2589 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2592 @@ -760,6 +792,27 @@ struct option_t MuttVars[] = {
2593 ** a regular expression that will match the whole name so mutt will expand
2594 ** ``Franklin'' to ``Franklin, Steve''.
2597 + { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2600 + ** This variable allows you to customize the newsgroup browser display to
2601 + ** your personal taste. This string is similar to ``$index_format'', but
2602 + ** has its own set of printf()-like sequences:
2605 + ** %C current newsgroup number
2606 + ** %d description of newsgroup (becomes from server)
2607 + ** %f newsgroup name
2608 + ** %M - if newsgroup not allowed for direct post (moderated for example)
2609 + ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2610 + ** %n number of new articles in newsgroup
2611 + ** %s number of unread articles in newsgroup
2612 + ** %>X right justify the rest of the string and pad with character "X"
2613 + ** %|X pad to the end of the line with character "X"
2617 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2620 @@ -1090,6 +1143,7 @@ struct option_t MuttVars[] = {
2621 ** .dt %E .dd number of messages in current thread
2622 ** .dt %f .dd sender (address + real name), either From: or Return-Path:
2623 ** .dt %F .dd author name, or recipient name if the message is from you
2624 + ** .dt %g .dd newsgroup name (if compiled with nntp support)
2625 ** .dt %H .dd spam attribute(s) of this message
2626 ** .dt %i .dd message-id of the current message
2627 ** .dt %l .dd number of lines in the message (does not work with maildir,
2628 @@ -1105,12 +1159,14 @@ struct option_t MuttVars[] = {
2629 ** stashed the message: list name or recipient name
2630 ** if not sent to a list
2631 ** .dt %P .dd progress indicator for the builtin pager (how much of the file has been displayed)
2632 + ** .dt %R .dd `x-comment-to:' field (if present and compiled with nntp support)
2633 ** .dt %s .dd subject of the message
2634 ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as)
2635 ** .dt %t .dd ``To:'' field (recipients)
2636 ** .dt %T .dd the appropriate character from the $$to_chars string
2637 ** .dt %u .dd user (login) name of the author
2638 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2639 + ** .dt %W .dd name of organization of author (`organization:' field)
2640 ** .dt %X .dd number of attachments
2641 ** (please see the ``$attachments'' section for possible speed effects)
2642 ** .dt %y .dd ``X-Label:'' field, if present
2643 @@ -1145,6 +1201,21 @@ struct option_t MuttVars[] = {
2644 ** Note that these expandos are supported in
2645 ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too.
2648 + { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2651 + ** If set, specifies the program and arguments used to deliver news posted
2652 + ** by Mutt. Otherwise, mutt posts article using current connection to
2653 + ** news server. The following printf-style sequence is understood:
2656 + ** %s newsserver name
2659 + ** Example: set inews="/usr/local/bin/inews -hS"
2662 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2665 @@ -1368,6 +1439,15 @@ struct option_t MuttVars[] = {
2666 ** menu, attachments which cannot be decoded in a reasonable manner will
2667 ** be attached to the newly composed message if this option is \fIset\fP.
2670 + { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2673 + ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2674 + ** encoded according to RFC2047 to base64. This is useful when message
2675 + ** is Usenet article, because MIME for news is nonstandard feature.
2679 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2681 @@ -1448,6 +1528,77 @@ struct option_t MuttVars[] = {
2682 ** See also $$read_inc, $$write_inc and $$net_inc.
2686 + { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2689 + ** This variable pointing to directory where Mutt will save cached news
2690 + ** articles headers in. If \fIunset\fP, headers will not be saved at all
2691 + ** and will be reloaded each time when you enter to newsgroup.
2693 + { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2696 + ** This variable specifies domain name or address of NNTP server. It
2697 + ** defaults to the newsserver specified in the environment variable
2698 + ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2699 + ** specify username and an alternative port for each newsserver, ie:
2701 + ** [news[s]://][username[:password]@]newsserver[:port]
2703 + { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2706 + ** The file, containing info about subscribed newsgroups - names and
2707 + ** indexes of read articles. The following printf-style sequence
2711 + ** %s newsserver name
2714 + { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2717 + ** This variable defines number of articles which will be in index when
2718 + ** newsgroup entered. If active newsgroup have more articles than this
2719 + ** number, oldest articles will be ignored. Also controls how many
2720 + ** articles headers will be saved in cache when you quit newsgroup.
2722 + { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2725 + ** This variable controls whether or not descriptions for each newsgroup
2726 + ** must be loaded when newsgroup is added to list (first time list
2727 + ** loading or new newsgroup adding).
2729 + { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2732 + ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2733 + ** authentification, Mutt will prompt you for your account name when you
2734 + ** connect to newsserver.
2736 + { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2739 + ** Your password for NNTP account.
2741 + { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2744 + ** The time in seconds until any operations on newsgroup except post new
2745 + ** article will cause recheck for new news. If set to 0, Mutt will
2746 + ** recheck newsgroup on each operation in index (stepping, read article,
2749 + { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2752 + ** Controls whether or not Mutt will try to reconnect to newsserver when
2753 + ** connection lost.
2756 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2759 @@ -2331,6 +2482,16 @@ struct option_t MuttVars[] = {
2760 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2764 + { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2767 + ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2768 + ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2769 + ** does not support posting to that newsgroup or totally read-only, that
2770 + ** posting will not have an effect.
2773 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2776 @@ -2725,6 +2886,28 @@ struct option_t MuttVars[] = {
2777 ** Command to use when spawning a subshell. By default, the user's login
2778 ** shell from \fC/etc/passwd\fP is used.
2781 + { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2784 + ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2785 + ** ``newsrc'' file and into cache.
2787 + { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2790 + ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2791 + ** the browser. Otherwise, it will be done only once for a newsserver.
2792 + ** Also controls whether or not number of new articles of subscribed
2793 + ** newsgroups will be then checked.
2795 + { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2798 + ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2799 + ** will be displayed in browser.
2802 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2805 @@ -3275,6 +3458,14 @@ struct option_t MuttVars[] = {
2806 ** option does nothing: mutt will never write out the ``Bcc:'' header
2810 + { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2813 + ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2814 + ** name of original article author) to article that followuped to newsgroup.
2820 diff -udprP mutt-1.5.19.orig/keymap.c mutt-1.5.19/keymap.c
2821 --- mutt-1.5.19.orig/keymap.c 2008-11-26 20:48:48.000000000 +0200
2822 +++ mutt-1.5.19/keymap.c 2009-01-06 22:27:38.000000000 +0200
2823 @@ -654,7 +654,6 @@ void km_init (void)
2824 km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE);
2826 km_bindkey ("x", MENU_PAGER, OP_EXIT);
2827 - km_bindkey ("i", MENU_PAGER, OP_EXIT);
2828 km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE);
2829 km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE);
2830 km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE);
2831 diff -udprP mutt-1.5.19.orig/mailbox.h mutt-1.5.19/mailbox.h
2832 --- mutt-1.5.19.orig/mailbox.h 2008-03-19 22:07:06.000000000 +0200
2833 +++ mutt-1.5.19/mailbox.h 2009-01-06 22:27:38.000000000 +0200
2834 @@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2836 int mx_is_pop (const char *);
2839 +int mx_is_nntp (const char *);
2842 int mx_access (const char*, int);
2843 int mx_check_empty (const char *);
2844 diff -udprP mutt-1.5.19.orig/main.c mutt-1.5.19/main.c
2845 --- mutt-1.5.19.orig/main.c 2009-01-04 01:27:10.000000000 +0200
2846 +++ mutt-1.5.19/main.c 2009-01-06 22:27:38.000000000 +0200
2848 #include <stringprep.h>
2855 static const char *ReachingUs = N_("\
2856 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2857 To report a bug, please visit http://bugs.mutt.org/.\n");
2858 @@ -133,6 +137,8 @@ options:\n\
2859 " -e <command>\tspecify a command to be executed after initialization\n\
2860 -f <file>\tspecify which mailbox to read\n\
2861 -F <file>\tspecify an alternate muttrc file\n\
2862 + -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2863 + -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2864 -H <file>\tspecify a draft file to read header and body from\n\
2865 -i <file>\tspecify a file which Mutt should include in the body\n\
2866 -m <type>\tspecify a default mailbox type\n\
2867 @@ -255,6 +261,12 @@ static void show_version (void)
2880 @@ -522,6 +534,9 @@ static void start_curses (void)
2881 #define M_NOSYSRC (1<<2) /* -n */
2882 #define M_RO (1<<3) /* -R */
2883 #define M_SELECT (1<<4) /* -y */
2885 +#define M_NEWS (1<<5) /* -g and -G */
2888 int main (int argc, char **argv)
2890 @@ -594,7 +609,11 @@ int main (int argc, char **argv)
2891 argv[nargc++] = argv[optind];
2895 + if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2897 if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2902 @@ -687,6 +706,20 @@ int main (int argc, char **argv)
2907 + case 'g': /* Specify a newsserver */
2909 + char buf[LONG_STRING];
2911 + snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2912 + commands = mutt_add_list (commands, buf);
2915 + case 'G': /* List of newsgroups */
2916 + flags |= M_SELECT | M_NEWS;
2923 @@ -974,6 +1007,18 @@ int main (int argc, char **argv)
2925 else if (flags & M_SELECT)
2928 + if (flags & M_NEWS)
2930 + set_option (OPTNEWS);
2931 + if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2933 + mutt_endwin (Errorbuf);
2940 mutt_endwin _("No incoming mailboxes defined.");
2942 @@ -989,6 +1034,15 @@ int main (int argc, char **argv)
2945 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2948 + if (option (OPTNEWS))
2950 + unset_option (OPTNEWS);
2951 + nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2955 mutt_expand_path (folder, sizeof (folder));
2957 mutt_str_replace (&CurrentFolder, folder);
2958 diff -udprP mutt-1.5.19.orig/mutt.h mutt-1.5.19/mutt.h
2959 --- mutt-1.5.19.orig/mutt.h 2008-09-26 01:00:03.000000000 +0300
2960 +++ mutt-1.5.19/mutt.h 2009-01-06 22:27:38.000000000 +0200
2961 @@ -223,6 +223,9 @@ enum
2969 /* Options for Mailcap lookup */
2971 @@ -278,6 +281,12 @@ enum
2974 OPT_VERIFYSIG, /* verify PGP signatures */
2977 + OPT_NNTPRECONNECT,
2979 + OPT_FOLLOWUPTOPOSTER,
2980 +#endif /* USE_NNTP */
2982 /* THIS MUST BE THE LAST VALUE. */
2984 @@ -293,6 +302,7 @@ enum
2985 #define SENDMAILX (1<<6)
2986 #define SENDKEY (1<<7)
2987 #define SENDRESEND (1<<8)
2988 +#define SENDNEWS (1<<9)
2990 /* flags to _mutt_select_file() */
2991 #define M_SEL_BUFFY (1<<0)
2992 @@ -312,6 +322,8 @@ enum
3001 @@ -387,6 +399,9 @@ enum
3006 + OPTMIMESUBJECT, /* encode subject line with RFC2047 */
3011 @@ -468,6 +483,16 @@ enum
3015 + /* news options */
3019 + OPTSHOWONLYUNREAD,
3023 +#endif /* USE_NNTP */
3025 /* pseudo options */
3027 OPTAUXSORT, /* (pseudo) using auxillary sort function */
3028 @@ -488,6 +513,7 @@ enum
3029 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
3030 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3031 OPTATTACHMSG, /* (pseudo) used by attach-message */
3032 + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3033 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3034 * functions while we are executing an
3036 @@ -498,6 +524,12 @@ enum
3037 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3038 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
3041 + OPTNEWS, /* (pseudo) used to change reader mode */
3042 + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3043 + OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
3049 @@ -575,6 +607,13 @@ typedef struct envelope
3053 + char *organization;
3057 + char *followup_to;
3058 + char *x_comment_to;
3061 LIST *references; /* message references (in reverse order) */
3062 LIST *in_reply_to; /* in-reply-to header content */
3063 @@ -741,6 +780,9 @@ typedef struct header
3064 ENVELOPE *env; /* envelope information */
3065 BODY *content; /* list of MIME parts */
3071 char *tree; /* character string to print thread tree */
3072 struct thread *thread;
3073 @@ -756,7 +798,7 @@ typedef struct header
3074 int refno; /* message number on server */
3077 -#if defined USE_POP || defined USE_IMAP
3078 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3079 void *data; /* driver-specific data */
3082 diff -udprP mutt-1.5.19.orig/muttlib.c mutt-1.5.19/muttlib.c
3083 --- mutt-1.5.19.orig/muttlib.c 2009-01-05 21:20:53.000000000 +0200
3084 +++ mutt-1.5.19/muttlib.c 2009-01-06 22:27:38.000000000 +0200
3085 @@ -286,7 +286,7 @@ void mutt_free_header (HEADER **h)
3087 mutt_free_list (&(*h)->chain);
3089 -#if defined USE_POP || defined USE_IMAP
3090 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3093 FREE (h); /* __FREE_CHECKED__ */
3094 @@ -674,6 +674,13 @@ void mutt_free_envelope (ENVELOPE **p)
3095 FREE (&(*p)->supersedes);
3097 FREE (&(*p)->x_label);
3098 + FREE (&(*p)->organization);
3100 + FREE (&(*p)->newsgroups);
3101 + FREE (&(*p)->xref);
3102 + FREE (&(*p)->followup_to);
3103 + FREE (&(*p)->x_comment_to);
3106 mutt_buffer_free (&(*p)->spam);
3108 @@ -1455,6 +1462,14 @@ int mutt_save_confirm (const char *s, st
3113 + if (magic == M_NNTP)
3115 + mutt_error _("Can't save message to newsserver.");
3120 if (stat (s, st) != -1)
3123 diff -udprP mutt-1.5.19.orig/mx.c mutt-1.5.19/mx.c
3124 --- mutt-1.5.19.orig/mx.c 2009-01-05 21:20:53.000000000 +0200
3125 +++ mutt-1.5.19/mx.c 2009-01-06 22:27:38.000000000 +0200
3126 @@ -343,6 +343,22 @@ int mx_is_pop (const char *p)
3131 +int mx_is_nntp (const char *p)
3133 + url_scheme_t scheme;
3138 + scheme = url_check_scheme (p);
3139 + if (scheme == U_NNTP || scheme == U_NNTPS)
3146 int mx_get_magic (const char *path)
3149 @@ -360,6 +376,11 @@ int mx_get_magic (const char *path)
3151 #endif /* USE_POP */
3154 + if (mx_is_nntp (path))
3156 +#endif /* USE_NNTP */
3158 if (stat (path, &st) == -1)
3160 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
3161 @@ -699,6 +720,12 @@ CONTEXT *mx_open_mailbox (const char *pa
3163 #endif /* USE_POP */
3167 + rc = nntp_open_mailbox (ctx);
3169 +#endif /* USE_NNTP */
3174 @@ -791,6 +818,12 @@ static int sync_mailbox (CONTEXT *ctx, i
3175 rc = pop_sync_mailbox (ctx, index_hint);
3177 #endif /* USE_POP */
3181 + rc = nntp_sync_mailbox (ctx);
3183 +#endif /* USE_NNTP */
3187 @@ -817,6 +850,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
3192 + if (ctx->magic == M_NNTP)
3196 + ret = nntp_close_mailbox (ctx);
3197 + mx_fastclose_mailbox (ctx);
3201 if (ctx->readonly || ctx->dontwrite)
3203 /* mailbox is readonly or we don't want to write */
3204 @@ -1354,6 +1397,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
3206 return (pop_check_mailbox (ctx, index_hint));
3207 #endif /* USE_POP */
3211 + return (nntp_check_mailbox (ctx));
3212 +#endif /* USE_NNTP */
3216 @@ -1414,6 +1462,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
3218 #endif /* USE_POP */
3223 + if (nntp_fetch_message (msg, ctx, msgno) != 0)
3227 +#endif /* USE_NNTP */
3230 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3232 @@ -1495,6 +1552,9 @@ int mx_close_message (MESSAGE **msg)
3234 || (*msg)->magic == M_POP
3237 + || (*msg)->magic == M_NNTP
3241 r = safe_fclose (&(*msg)->fp);
3242 diff -udprP mutt-1.5.19.orig/mx.h mutt-1.5.19/mx.h
3243 --- mutt-1.5.19.orig/mx.h 2008-03-19 22:07:06.000000000 +0200
3244 +++ mutt-1.5.19/mx.h 2009-01-06 22:27:38.000000000 +0200
3245 @@ -40,6 +40,9 @@ enum
3254 WHERE short DefaultMagic INITVAL (M_MBOX);
3255 diff -udprP mutt-1.5.19.orig/newsrc.c mutt-1.5.19/newsrc.c
3256 --- mutt-1.5.19.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3257 +++ mutt-1.5.19/newsrc.c 2009-01-06 22:27:38.000000000 +0200
3260 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3261 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
3262 + * Copyright (C) 2000-2009 Vsevolod Volkov <vvv@mutt.org.ua>
3264 + * This program is free software; you can redistribute it and/or modify
3265 + * it under the terms of the GNU General Public License as published by
3266 + * the Free Software Foundation; either version 2 of the License, or
3267 + * (at your option) any later version.
3269 + * This program is distributed in the hope that it will be useful,
3270 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3271 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3272 + * GNU General Public License for more details.
3274 + * You should have received a copy of the GNU General Public License
3275 + * along with this program; if not, write to the Free Software
3276 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3280 +# include "config.h"
3284 +#include "mutt_curses.h"
3288 +#include "mailbox.h"
3290 +#include "rfc822.h"
3291 +#include "rfc1524.h"
3292 +#include "rfc2047.h"
3294 +#include <unistd.h>
3295 +#include <string.h>
3297 +#include <stdlib.h>
3298 +#include <sys/stat.h>
3300 +void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3307 + l = safe_calloc (1, sizeof (LIST));
3309 + s->tail->next = l;
3313 + l->data = (void *) d;
3316 +static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3319 + char group[LONG_STRING];
3321 + char *p = line, *b, *h;
3331 + while (*p && (*p != ':' && *p != '!')) p++;
3334 + len = p + 1 - line;
3335 + if (len > sizeof (group))
3336 + len = sizeof (group);
3337 + strfcpy (group, line, len);
3338 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3340 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3341 + data->group = (char *) data + sizeof (NNTP_DATA);
3342 + strcpy (data->group, group);
3343 + data->nserv = news;
3344 + data->deleted = 1;
3345 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3346 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3347 + hash_insert (news->newsgroups, data->group, data, 0);
3348 + nntp_add_to_list (news, data);
3351 + FREE ((void **) &data->entries);
3354 + data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3358 + data->subscribed = 1;
3360 + data->subscribed = 0;
3367 + while (*p && *p != ',' && *p != '\n') p++;
3373 + if ((h = strchr(b, '-')))
3377 + data->entries[x].first = atoi(b);
3378 + data->entries[x].last = atoi(h);
3382 + data->entries[x].first = atoi(b);
3383 + data->entries[x].last = data->entries[x].first;
3386 + if (data->entries[x].last != 0)
3389 + if (x && !data->lastMessage)
3390 + data->lastMessage = data->entries[x-1].last;
3392 + mutt_newsgroup_stat (data);
3393 + dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3398 +static int slurp_newsrc (NNTP_SERVER *news)
3404 + news->stat = stat (news->newsrc, &sb);
3405 + news->size = sb.st_size;
3406 + news->mtime = sb.st_mtime;
3408 + if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3410 + /* hmm, should we use dotlock? */
3411 + if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3417 + buf = safe_malloc (sb.st_size + 1);
3418 + while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3419 + nntp_parse_newsrc_line (news, buf);
3422 + mx_unlock_file (news->newsrc, fileno (fp), 0);
3427 +void nntp_cache_expand (char *dst, const char *src)
3429 + snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3430 + mutt_expand_path (dst, _POSIX_PATH_MAX);
3433 +/* Loads $news_cache_dir/.index into memory, loads newsserver data
3434 + * and newsgroup cache names */
3435 +static int nntp_parse_cacheindex (NNTP_SERVER *news)
3438 + char buf[HUGE_STRING], *cp;
3439 + char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3444 + /* check is server name defined or not */
3445 + if (!news || !news->conn || !news->conn->account.host)
3447 + unset_option (OPTNEWSCACHE);
3448 + if (!NewsCacheDir || !*NewsCacheDir)
3451 + strfcpy (dir, NewsCacheDir, sizeof (dir));
3452 + mutt_expand_path (dir, sizeof(dir));
3454 + if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3456 + snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3457 + if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3460 + mutt_error _("Cache directory not created!");
3463 + mutt_clear_error();
3466 + set_option (OPTNEWSCACHE);
3468 + FREE (&news->cache);
3469 + snprintf (buf, sizeof(buf), "%s/.index", dir);
3470 + if (!(index = safe_fopen (buf, "a+")))
3473 + while (fgets (buf, sizeof(buf), index))
3475 + buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3476 + if (!mutt_strncmp (buf, "#: ", 3) &&
3477 + !mutt_strcasecmp (buf+3, news->conn->account.host))
3480 + while (fgets (buf, sizeof(buf), index))
3483 + while (*cp && *cp != ' ') cp++;
3484 + if (!*cp) continue;
3486 + if (!mutt_strcmp (buf, "#:"))
3488 + sscanf (cp + 1, "%s %d %d", file, &l, &m);
3489 + if (!mutt_strcmp (buf, "ALL"))
3491 + news->cache = safe_strdup (file);
3492 + news->newgroups_time = m;
3494 + else if (news->newsgroups)
3496 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3498 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3499 + data->group = (char *) data + sizeof (NNTP_DATA);
3500 + strcpy(data->group, buf);
3501 + data->nserv = news;
3502 + data->deleted = 1;
3503 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3504 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3505 + hash_insert (news->newsgroups, data->group, data, 0);
3506 + nntp_add_to_list (news, data);
3508 + data->cache = safe_strdup (file);
3510 + if (!data->firstMessage || data->lastMessage < m)
3512 + if (!data->firstMessage)
3513 + data->firstMessage = l;
3514 + if (data->lastMessage < m)
3515 + data->lastMessage = m;
3516 + data->lastCached = m;
3517 + if (t || !data->unread)
3518 + mutt_newsgroup_stat (data);
3526 +nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
3527 + const char *fmt, const char *ifstring, const char *elsestring,
3528 + unsigned long data, format_flag flags)
3530 + char fn[SHORT_STRING], tmp[SHORT_STRING];
3535 + strncpy (fn, NewsServer, sizeof(fn) - 1);
3536 + mutt_strlower (fn);
3537 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3538 + snprintf (dest, destlen, tmp, fn);
3544 +/* nntp_parse_url: given an NNPT URL, return host, port,
3545 + * username, password and newsgroup will recognise. */
3546 +int nntp_parse_url (const char *server, ACCOUNT *acct,
3547 + char *group, size_t group_len)
3555 + acct->port = NNTP_PORT;
3556 + acct->type = M_ACCT_TYPE_NNTP;
3558 + c = safe_strdup (server);
3559 + url_parse_ciss (&url, c);
3561 + if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3563 + if (url.scheme == U_NNTPS)
3565 + acct->flags |= M_ACCT_SSL;
3566 + acct->port = NNTP_SSL_PORT;
3571 + strfcpy (group, url.path, group_len);
3573 + ret = mutt_account_fromurl (acct, &url);
3580 +void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3584 + url.path = safe_strdup (line);
3585 + mutt_account_tourl (acct, &url);
3586 + url_ciss_tostring (&url, line, len, 0);
3591 + * Automatically loads a newsrc into memory, if necessary.
3592 + * Checks the size/mtime of a newsrc file, if it doesn't match, load
3593 + * again. Hmm, if a system has broken mtimes, this might mean the file
3594 + * is reloaded every time, which we'd have to fix.
3596 + * a newsrc file is a line per newsgroup, with the newsgroup, then a
3597 + * ':' denoting subscribed or '!' denoting unsubscribed, then a
3598 + * comma separated list of article numbers and ranges.
3600 +NNTP_SERVER *mutt_select_newsserver (char *server)
3602 + char file[_POSIX_PATH_MAX];
3606 + NNTP_SERVER *serv;
3609 + if (!server || !*server)
3611 + mutt_error _("No newsserver defined!");
3615 + buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3616 + if (url_check_scheme (server) == U_UNKNOWN)
3618 + strcpy (buf, "news://");
3619 + p = strchr (buf, '\0');
3621 + strcpy (p, server);
3623 + if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3626 + mutt_error (_("%s is an invalid newsserver specification!"), server);
3631 + conn = mutt_conn_find (NULL, &acct);
3635 + mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), nntp_format_str, 0, 0);
3636 + mutt_expand_path (file, sizeof (file));
3638 + serv = (NNTP_SERVER *)conn->data;
3643 + /* externally modified? */
3644 + if (serv->stat != stat (file, &sb) || (!serv->stat &&
3645 + (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3647 + for (list = serv->list; list; list = list->next)
3649 + NNTP_DATA *data = (NNTP_DATA *) list->data;
3653 + data->subscribed = 0;
3658 + slurp_newsrc (serv);
3659 + nntp_clear_cacheindex (serv);
3662 + if (serv->status == NNTP_BYE)
3663 + serv->status = NNTP_NONE;
3664 + nntp_check_newgroups (serv, 0);
3668 + /* New newsserver */
3669 + serv = safe_calloc (1, sizeof (NNTP_SERVER));
3670 + serv->conn = conn;
3671 + serv->newsrc = safe_strdup (file);
3672 + serv->newsgroups = hash_create (1009);
3673 + slurp_newsrc (serv); /* load .newsrc */
3674 + nntp_parse_cacheindex (serv); /* load .index */
3675 + if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3676 + nntp_check_newgroups (serv, 1);
3677 + else if (nntp_get_active (serv) < 0)
3679 + hash_destroy (&serv->newsgroups, nntp_delete_data);
3680 + for (list = serv->list; list; list = list->next)
3681 + list->data = NULL;
3682 + mutt_free_list (&serv->list);
3683 + FREE (&serv->newsrc);
3684 + FREE (&serv->cache);
3688 + nntp_clear_cacheindex (serv);
3689 + conn->data = (void *)serv;
3695 + * full status flags are not supported by nntp, but we can fake some
3696 + * of them. This is how:
3697 + * Read = a read message number is in the .newsrc
3698 + * New = a message is new since we last read this newsgroup
3699 + * Old = anything else
3700 + * So, Read is marked as such in the newsrc, old is anything that is
3701 + * "skipped" in the newsrc, and new is anything not in the newsrc nor
3702 + * in the cache. By skipped, I mean before the last unread message
3704 +void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3706 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3710 + data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3716 + dprint (3, (debugfile, "newsgroup %s not found\n", group));
3721 + for (x = 0; x < data->num; x++)
3723 + if ((article >= data->entries[x].first) &&
3724 + (article <= data->entries[x].last))
3726 + /* we cannot use mutt_set_flag() because mx_update_context()
3727 + didn't called yet */
3732 + /* If article was not cached yet, it is new! :) */
3733 + if (!data->cache || article > data->lastCached)
3735 + /* Old articles are articles which aren't read but an article after them
3736 + * has been cached */
3737 + if (option (OPTMARKOLD))
3741 +void mutt_newsgroup_stat (NNTP_DATA *data)
3744 + unsigned int first, last;
3747 + if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3750 + data->unread = data->lastMessage - data->firstMessage + 1;
3751 + for (i = 0; i < data->num; i++)
3753 + first = data->entries[i].first;
3754 + if (first < data->firstMessage)
3755 + first = data->firstMessage;
3756 + last = data->entries[i].last;
3757 + if (last > data->lastMessage)
3758 + last = data->lastMessage;
3759 + if (first <= last)
3760 + data->unread -= last - first + 1;
3764 +static int puti (char *line, int num)
3768 + for (p = s; num; )
3770 + *p++ = '0' + num % 10;
3774 + *line++ = *--p, num++;
3779 +static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3781 + char *line = *pline;
3782 + size_t len = *buflen - (*pline - *buf);
3785 + if (len < LONG_STRING * 10)
3790 + safe_realloc (buf, *buflen);
3791 + line = *buf + (*pline - line);
3793 + strcpy (line, data->group);
3794 + len -= strlen (line) + 1;
3795 + line += strlen (line);
3796 + *line++ = data->subscribed ? ':' : '!';
3800 + for (x = 0; x < data->num; x++)
3802 + if (len < LONG_STRING)
3808 + safe_realloc (buf, *buflen);
3809 + line = *buf + (*pline - line);
3818 + if (data->entries[x].first == data->entries[x].last)
3819 + snprintf (line, len, "%d%n", data->entries[x].first, &i);
3821 + snprintf (line, len, "%d-%d%n",
3822 + data->entries[x].first, data->entries[x].last, &i);
3826 + i = puti (line, data->entries[x].first);
3827 + line +=i; len -= i;
3828 + if (data->entries[x].first != data->entries[x].last)
3832 + i = puti (line, data->entries[x].last);
3833 + line +=i; len -= i;
3842 +void newsrc_gen_entries (CONTEXT *ctx)
3844 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3846 + unsigned int last = 0, first = 1;
3847 + int save_sort = SORT_ORDER;
3849 + if (Sort != SORT_ORDER)
3852 + Sort = SORT_ORDER;
3853 + mutt_sort_headers (ctx, 0);
3858 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3863 + * Set up to fake initial sequence from 1 to the article before the
3864 + * first article in our list
3869 + for (x = 0; x < ctx->msgcount; x++)
3871 + if (series) /* search for first unread */
3874 + * We don't actually check sequential order, since we mark
3875 + * "missing" entries as read/deleted
3877 + last = ctx->hdrs[x]->article_num;
3878 + if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3879 + !ctx->hdrs[x]->read)
3881 + if (data->num >= data->max)
3883 + data->max = data->max * 2;
3884 + safe_realloc (&data->entries,
3885 + data->max * sizeof (NEWSRC_ENTRY));
3887 + data->entries[data->num].first = first;
3888 + data->entries[data->num].last = last - 1;
3893 + else /* search for first read */
3895 + if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3900 + last = ctx->hdrs[x]->article_num;
3903 + if (series && first <= data->lastLoaded)
3905 + if (data->num >= data->max)
3907 + data->max = data->max * 2;
3908 + safe_realloc (&data->entries,
3909 + data->max * sizeof (NEWSRC_ENTRY));
3911 + data->entries[data->num].first = first;
3912 + data->entries[data->num].last = data->lastLoaded;
3916 + if (save_sort != Sort)
3919 + mutt_sort_headers (ctx, 0);
3923 +static int mutt_update_list_file (char *filename, char *section,
3924 + char *key, char *line)
3928 + char buf[HUGE_STRING];
3929 + char tmpfile[_POSIX_PATH_MAX];
3931 + int ext = 0, done = 0, r = 0;
3933 + /* if file not exist, create it */
3934 + if ((ifp = safe_fopen (filename, "a")))
3936 + dprint (1, (debugfile, "Opening %s\n", filename));
3937 + if (!(ifp = safe_fopen (filename, "r")))
3939 + mutt_error (_("Unable to open %s for reading"), filename);
3942 + if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3945 + mutt_error (_("Unable to lock %s"), filename);
3948 + snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3949 + dprint (1, (debugfile, "Opening %s\n", tmpfile));
3950 + if (!(ofp = fopen (tmpfile, "w")))
3953 + mutt_error (_("Unable to open %s for writing"), tmpfile);
3959 + while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3961 + r = fputs (buf, ofp);
3963 + while (*c && *c != '\n') c++;
3964 + c[0] = 0; /* strip EOL */
3965 + if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3968 + if (r != EOF && !done)
3970 + snprintf (buf, sizeof(buf), "#: %s\n", section);
3971 + r = fputs (buf, ofp);
3976 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3981 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3983 + if (*c != '\\') ext = 0;
3985 + else if ((section && !strncmp (buf, "#: ", 3)))
3987 + if (!done && line)
3989 + fputs (line, ofp);
3990 + fputc ('\n', ofp);
3992 + r = fputs (buf, ofp);
3996 + else if (key && !strncmp (buf, key, strlen(key)) &&
3997 + (!*key || buf[strlen(key)] == ' '))
4001 + while (*c && (*c != '\r') && (*c != '\n')) c++;
4003 + if (*c == '\\') ext = 1;
4004 + if (!done && line)
4006 + r = fputs (line, ofp);
4008 + r = fputc ('\n', ofp);
4014 + r = fputs (buf, ofp);
4018 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
4019 + r = fputs (buf, ofp);
4021 + /* If there wasn't a line to replace, put it on the end of the file */
4022 + if (r != EOF && !done && line)
4024 + fputs (line, ofp);
4025 + r = fputc ('\n', ofp);
4027 + mx_unlock_file (filename, fileno (ifp), 0);
4033 + mutt_error (_("Can't write %s"), tmpfile);
4036 + if (rename (tmpfile, filename) < 0)
4039 + mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
4045 +int mutt_newsrc_update (NNTP_SERVER *news)
4055 + llen = len = 10 * LONG_STRING;
4056 + line = buf = safe_calloc (1, len);
4057 + /* we will generate full newsrc here */
4058 + for (tmp = news->list; tmp; tmp = tmp->next)
4060 + data = (NNTP_DATA *) tmp->data;
4061 + if (!data || !data->rc)
4063 + nntp_create_newsrc_line (data, &buf, &line, &llen);
4065 + dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4066 + line += strlen (line);
4068 + /* newrc being fully rewritten */
4069 + if (news->newsrc &&
4070 + (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4074 + stat (news->newsrc, &st);
4075 + news->size = st.st_size;
4076 + news->mtime = st.st_mtime;
4082 +static FILE *mutt_mkname (char *s)
4084 + char buf[_POSIX_PATH_MAX], *pc;
4088 + nntp_cache_expand (buf, s);
4089 + if ((fp = safe_fopen (buf, "w")))
4092 + nntp_cache_expand (buf, "cache-XXXXXX");
4093 + pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4094 + if ((fd = mkstemp (buf)) == -1)
4096 + strcpy (s, pc); /* generated name */
4097 + return fdopen (fd, "w");
4100 +/* Updates info into .index file: ALL or about selected newsgroup */
4101 +static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4103 + char buf[LONG_STRING], *key = "ALL";
4104 + char file[_POSIX_PATH_MAX];
4106 + if (!serv || !serv->conn || !serv->conn->account.host)
4109 + if (data && data->group)
4111 + key = data->group;
4112 + snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4113 + data->firstMessage, data->lastLoaded);
4117 + strfcpy (file, serv->cache, sizeof (file));
4118 + snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4120 + nntp_cache_expand (file, ".index");
4121 + return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4124 +/* Remove cache files of unsubscribed newsgroups */
4125 +void nntp_clear_cacheindex (NNTP_SERVER *news)
4130 + if (option (OPTSAVEUNSUB) || !news)
4133 + for (tmp = news->list; tmp; tmp = tmp->next)
4135 + data = (NNTP_DATA *) tmp->data;
4136 + if (!data || data->subscribed || !data->cache)
4138 + nntp_delete_cache (data);
4139 + dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4144 +int nntp_save_cache_index (NNTP_SERVER *news)
4146 + char buf[HUGE_STRING];
4147 + char file[_POSIX_PATH_MAX];
4152 + if (!news || !news->newsgroups)
4154 + if (!option (OPTNEWSCACHE))
4159 + nntp_cache_expand (file, news->cache);
4161 + f = safe_fopen (file, "w");
4165 + strfcpy (buf, news->conn->account.host, sizeof(buf));
4166 + f = mutt_mkname (buf);
4167 + news->cache = safe_strdup (buf);
4168 + nntp_cache_expand (file, buf);
4173 + for (l = news->list; l; l = l->next)
4175 + if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4178 + snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4179 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4182 + snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4183 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4184 + if (fputs (buf, f) == EOF)
4194 + if (nntp_update_cacheindex (news, NULL))
4202 +int nntp_save_cache_group (CONTEXT *ctx)
4204 + char buf[HUGE_STRING], addr[STRING];
4205 + char file[_POSIX_PATH_MAX];
4209 + int i = 0, save = SORT_ORDER;
4212 + if (!option (OPTNEWSCACHE))
4214 + if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4217 + if (((NNTP_DATA *)ctx->data)->cache)
4219 + nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4221 + f = safe_fopen (file, "w");
4225 + snprintf (buf, sizeof(buf), "%s-%s",
4226 + ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4227 + ((NNTP_DATA *)ctx->data)->group);
4228 + f = mutt_mkname (buf);
4229 + ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4230 + nntp_cache_expand (file, buf);
4235 + if (Sort != SORT_ORDER)
4238 + Sort = SORT_ORDER;
4239 + mutt_sort_headers (ctx, 0);
4242 + /* Save only $nntp_context messages... */
4243 + ((NNTP_DATA *)ctx->data)->lastCached = 0;
4244 + if (NntpContext && ctx->msgcount > NntpContext)
4245 + i = ctx->msgcount - NntpContext;
4246 + for (; i < ctx->msgcount; i++)
4248 + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4252 + rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4253 + tm = gmtime (&h->date_sent);
4254 + snprintf (buf, sizeof(buf),
4255 + "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4256 + h->article_num, h->env->subject, addr, tm->tm_mday,
4257 + Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4258 + tm->tm_sec, h->env->message_id);
4260 + if (h->env->references)
4261 + mutt_write_references (h->env->references, f, 10);
4262 + snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length,
4263 + (int) h->lines, NONULL(h->env->xref));
4264 + if (fputs (buf, f) == EOF)
4271 + prev = ctx->hdrs[i]->article_num;
4277 + mutt_sort_headers (ctx, 0);
4281 + if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4282 + (NNTP_DATA *)ctx->data))
4287 + ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4291 +void nntp_delete_cache (NNTP_DATA *data)
4293 + char buf[_POSIX_PATH_MAX];
4295 + if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4298 + nntp_cache_expand (buf, data->cache);
4300 + FREE (&data->cache);
4301 + data->lastCached = 0;
4302 + nntp_cache_expand (buf, ".index");
4303 + mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4306 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4310 + if (!news || !news->newsgroups || !group || !*group)
4312 + if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4314 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4315 + data->group = (char *) data + sizeof (NNTP_DATA);
4316 + strcpy (data->group, group);
4317 + data->nserv = news;
4318 + data->deleted = 1;
4319 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4320 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
4321 + hash_insert (news->newsgroups, data->group, data, 0);
4322 + nntp_add_to_list (news, data);
4324 + if (!data->subscribed)
4326 + data->subscribed = 1;
4332 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4336 + if (!news || !news->newsgroups || !group || !*group ||
4337 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4339 + if (data->subscribed)
4341 + data->subscribed = 0;
4342 + if (!option (OPTSAVEUNSUB))
4348 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4352 + if (!news || !news->newsgroups || !group || !*group ||
4353 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4357 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4361 + data->entries[0].first = 1;
4363 + data->entries[0].last = data->lastMessage;
4364 + if (Context && Context->data == data)
4368 + for (x = 0; x < Context->msgcount; x++)
4369 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4374 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4378 + if (!news || !news->newsgroups || !group || !*group ||
4379 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4383 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4387 + data->entries[0].first = 1;
4388 + data->entries[0].last = data->firstMessage - 1;
4389 + if (Context && Context->data == data)
4393 + data->unread = Context->msgcount;
4394 + for (x = 0; x < Context->msgcount; x++)
4395 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4398 + data->unread = data->lastMessage - data->entries[0].last;
4402 +/* this routine gives the first newsgroup with new messages */
4403 +void nntp_buffy (char *s)
4407 + for (list = CurrentNewsSrv->list; list; list = list->next)
4409 + NNTP_DATA *data = (NNTP_DATA *) list->data;
4411 + if (data && data->subscribed && data->unread)
4413 + if (Context && Context->magic == M_NNTP &&
4414 + !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4416 + unsigned int i, unread = 0;
4418 + for (i = 0; i < Context->msgcount; i++)
4419 + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4424 + strcpy (s, data->group);
4429 diff -udprP mutt-1.5.19.orig/nntp.c mutt-1.5.19/nntp.c
4430 --- mutt-1.5.19.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4431 +++ mutt-1.5.19/nntp.c 2009-01-06 22:27:38.000000000 +0200
4434 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4435 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4436 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
4438 + * This program is free software; you can redistribute it and/or modify
4439 + * it under the terms of the GNU General Public License as published by
4440 + * the Free Software Foundation; either version 2 of the License, or
4441 + * (at your option) any later version.
4443 + * This program is distributed in the hope that it will be useful,
4444 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4445 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4446 + * GNU General Public License for more details.
4448 + * You should have received a copy of the GNU General Public License
4449 + * along with this program; if not, write to the Free Software
4450 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4454 +# include "config.h"
4458 +#include "mutt_curses.h"
4462 +#include "rfc1524.h"
4463 +#include "rfc2047.h"
4464 +#include "mailbox.h"
4475 +#include <unistd.h>
4476 +#include <string.h>
4478 +#include <stdlib.h>
4480 +static unsigned int _checked = 0;
4483 +static void nntp_error (const char *where, const char *msg)
4485 + dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4489 +static int nntp_auth (NNTP_SERVER *serv)
4491 + CONNECTION *conn = serv->conn;
4493 + unsigned char flags = conn->account.flags;
4495 + if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4496 + mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4498 + conn->account.flags = flags;
4502 + mutt_message _("Logging in...");
4504 + snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4505 + mutt_socket_write (conn, buf);
4506 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4508 + conn->account.flags = flags;
4513 + /* don't print the password unless we're at the ungodly debugging level */
4514 + if (debuglevel < M_SOCK_LOG_FULL)
4515 + dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4517 + snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4518 + mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4519 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4521 + conn->account.flags = flags;
4525 + if (mutt_strncmp ("281", buf, 3))
4527 + conn->account.flags = flags;
4528 + mutt_error _("Login failed.");
4536 +static int nntp_connect_error (NNTP_SERVER *serv)
4538 + serv->status = NNTP_NONE;
4539 + mutt_socket_close (serv->conn);
4540 + mutt_error _("Server closed connection!");
4545 +static int nntp_connect_and_auth (NNTP_SERVER *serv)
4547 + CONNECTION *conn = serv->conn;
4551 + serv->status = NNTP_NONE;
4553 + if (mutt_socket_open (conn) < 0)
4556 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4557 + return nntp_connect_error (serv);
4559 + if (!mutt_strncmp ("200", buf, 3))
4560 + mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4561 + else if (!mutt_strncmp ("201", buf, 3))
4562 + mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4565 + mutt_socket_close (conn);
4566 + mutt_remove_trailing_ws (buf);
4567 + mutt_error ("%s", buf);
4574 + /* Tell INN to switch to mode reader if it isn't so. Ignore all
4575 + returned codes and messages. */
4576 + mutt_socket_write (conn, "MODE READER\r\n");
4577 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4578 + return nntp_connect_error (serv);
4580 + mutt_socket_write (conn, "STAT\r\n");
4581 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4582 + return nntp_connect_error (serv);
4584 + if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
4586 + serv->status = NNTP_OK;
4590 + rc = nntp_auth (serv);
4592 + return nntp_connect_error (serv);
4595 + mutt_socket_close (conn);
4596 + serv->status = NNTP_BYE;
4601 + mutt_socket_close (conn);
4602 + mutt_error _("Login failed.");
4606 + serv->status = NNTP_OK;
4610 +static int nntp_attempt_features (NNTP_SERVER *serv)
4612 + char buf[LONG_STRING];
4613 + CONNECTION *conn = serv->conn;
4615 + mutt_socket_write (conn, "XOVER\r\n");
4616 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4617 + return nntp_connect_error (serv);
4618 + if (mutt_strncmp ("500", buf, 3))
4619 + serv->hasXOVER = 1;
4621 + mutt_socket_write (conn, "XPAT\r\n");
4622 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4623 + return nntp_connect_error (serv);
4624 + if (mutt_strncmp ("500", buf, 3))
4625 + serv->hasXPAT = 1;
4627 + mutt_socket_write (conn, "LISTGROUP\r\n");
4628 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4629 + return nntp_connect_error (serv);
4630 + if (mutt_strncmp ("500", buf, 3))
4631 + serv->hasLISTGROUP = 1;
4633 + mutt_socket_write (conn, "XGTITLE +\r\n");
4634 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4635 + return nntp_connect_error (serv);
4636 + if (mutt_strncmp ("500", buf, 3))
4637 + serv->hasXGTITLE = 1;
4639 + if (!mutt_strncmp ("282", buf, 3))
4643 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4644 + return nntp_connect_error (serv);
4645 + } while (!(buf[0] == '.' && buf[1] == '\0'));
4651 +static int nntp_open_connection (NNTP_SERVER *serv)
4653 + if (serv->status == NNTP_OK)
4655 + if (serv->status == NNTP_BYE)
4657 + if (nntp_connect_and_auth (serv) < 0)
4659 + if (nntp_attempt_features (serv) < 0)
4664 +static int nntp_reconnect (NNTP_SERVER *serv)
4666 + char buf[SHORT_STRING];
4668 + mutt_socket_close (serv->conn);
4672 + if (nntp_connect_and_auth (serv) == 0)
4675 + snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
4676 + serv->conn->account.host);
4677 + if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
4679 + serv->status = NNTP_BYE;
4685 +/* Send data from line[LONG_STRING] and receive answer to same line */
4686 +static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
4688 + char buf[LONG_STRING];
4691 + if (data->nserv->status == NNTP_BYE)
4698 + mutt_socket_write (data->nserv->conn, line);
4700 + else if (data->group)
4702 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4703 + mutt_socket_write (data->nserv->conn, buf);
4707 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4709 + if (nntp_reconnect (data->nserv) < 0)
4714 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4715 + mutt_socket_write (data->nserv->conn, buf);
4716 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4722 + else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
4726 + strfcpy (line, buf, linelen);
4731 + * This function calls funct(*line, *data) for each received line,
4732 + * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
4735 + * 1 - correct but not performed (may be, have to be continued),
4736 + * -1 - conection lost,
4737 + * -2 - invalid command or execution error,
4738 + * -3 - error in funct(*line, *data).
4740 +static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
4741 + int (*funct) (char *, void *), void *data, int tagged)
4743 + char buf[LONG_STRING];
4747 + size_t lenbuf = 0;
4752 + strfcpy (buf, query, sizeof (buf));
4753 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
4755 + if (buf[0] == '5')
4757 + if (buf[0] != '2')
4762 + inbuf = safe_malloc (sizeof (buf));
4766 + chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
4772 + if (!lenbuf && buf[0] == '.')
4774 + if (buf[1] == '\0')
4779 + if (buf[1] == '.')
4783 + strfcpy (inbuf + lenbuf, p, sizeof (buf));
4785 + if (chunk >= sizeof (buf))
4787 + lenbuf += strlen (p);
4792 + if (msg && ReadInc && (line % ReadInc == 0)) {
4794 + mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
4796 + mutt_message ("%s %d", msg, line);
4799 + if (ret == 0 && funct (inbuf, data) < 0)
4804 + safe_realloc (&inbuf, lenbuf + sizeof (buf));
4807 + funct (NULL, data);
4813 +static int nntp_read_tempfile (char *line, void *file)
4815 + FILE *f = (FILE *)file;
4822 + if (fputc ('\n', f) == EOF)
4828 +static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
4830 + register char *p, *b;
4831 + register char *colon = NULL;
4836 + /* skip to next word */
4838 + while (*b && ((*b == ' ') || (*b == '\t'))) b++;
4841 + /* skip to end of word */
4842 + while (*p && (*p != ' ') && (*p != '\t'))
4857 + nntp_get_status (ctx, h, b, atoi(colon));
4858 + if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
4859 + h->article_num = atoi(colon);
4867 + * 1 if article not found
4868 + * -1 if read or write error on tempfile or socket
4870 +static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
4872 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
4874 + char buf[LONG_STRING];
4875 + char tempfile[_POSIX_PATH_MAX];
4877 + HEADER *h = ctx->hdrs[ctx->msgcount];
4879 + mutt_mktemp (tempfile);
4880 + if (!(f = safe_fopen (tempfile, "w+")))
4884 + snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
4886 + snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
4888 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
4893 + dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
4896 + unlink (tempfile);
4897 + return (ret == -1 ? -1 : 1);
4900 + h->article_num = article_num;
4901 + h->env = mutt_read_rfc822_header (f, h, 0, 0);
4903 + unlink (tempfile);
4905 + if (h->env->xref != NULL)
4906 + nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
4907 + else if (h->article_num == 0 && msgid)
4909 + snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
4910 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
4911 + h->article_num = atoi (buf + 4);
4917 +static int parse_description (char *line, void *n)
4919 +#define news ((NNTP_SERVER *) n)
4920 + register char *d = line;
4925 + while (*d && *d != '\t' && *d != ' ') d++;
4928 + while (*d && (*d == '\t' || *d == ' ')) d++;
4929 + dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
4930 + if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
4931 + mutt_strcmp (d, data->desc))
4933 + FREE (&data->desc);
4934 + data->desc = safe_strdup (d);
4940 +static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
4944 + if (!option (OPTLOADDESC) || !data || !data->nserv)
4947 + /* Get newsgroup description, if we can */
4948 + if (data->nserv->hasXGTITLE)
4949 + snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
4951 + snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
4952 + if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
4955 + nntp_error ("nntp_get_desc()", buf);
4961 + * XOVER returns a tab separated list of:
4962 + * id|subject|from|date|Msgid|references|bytes|lines|xref
4964 + * This has to duplicate some of the functionality of
4965 + * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
4966 + * a limited number of headers which are "parsed" by placement in the list)
4968 +static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
4970 + NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
4974 + hdr->env = mutt_new_envelope();
4975 + hdr->env->newsgroups = safe_strdup (nntp_data->group);
4976 + hdr->content = mutt_new_body();
4977 + hdr->content->type = TYPETEXT;
4978 + hdr->content->subtype = safe_strdup ("plain");
4979 + hdr->content->encoding = ENC7BIT;
4980 + hdr->content->disposition = DISPINLINE;
4981 + hdr->content->length = -1;
4984 + for (x = 0; !done && x < 9; x++)
4986 + /* if from file, need to skip newline character */
4987 + while (*p && *p != '\n' && *p != '\t') p++;
4995 + hdr->article_num = atoi (b);
4996 + nntp_get_status (ctx, hdr, NULL, hdr->article_num);
4999 + hdr->env->subject = safe_strdup (b);
5000 + /* Now we need to do the things which would normally be done in
5001 + * mutt_read_rfc822_header() */
5002 + if (hdr->env->subject)
5004 + regmatch_t pmatch[1];
5006 + rfc2047_decode (&hdr->env->subject);
5008 + if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
5009 + hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
5011 + hdr->env->real_subj = hdr->env->subject;
5015 + rfc822_free_address (&hdr->env->from);
5016 + hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
5017 + rfc2047_decode_adrlist (hdr->env->from);
5020 + hdr->date_sent = mutt_parse_date (b, hdr);
5021 + hdr->received = hdr->date_sent;
5024 + FREE (&hdr->env->message_id);
5025 + hdr->env->message_id = safe_strdup (b);
5028 + mutt_free_list (&hdr->env->references);
5029 + hdr->env->references = mutt_parse_references (b, 0);
5032 + hdr->content->length = atoi (b);
5035 + hdr->lines = atoi (b);
5039 + FREE (&hdr->env->xref);
5040 + b = b + 6; /* skips the "Xref: " */
5041 + hdr->env->xref = safe_strdup (b);
5042 + nntp_parse_xref (ctx, nntp_data->group, b, hdr);
5054 + unsigned int base;
5055 + unsigned int first;
5056 + unsigned int last;
5057 + unsigned short *messages;
5061 +#define fc ((FETCH_CONTEXT *) c)
5062 +static int nntp_fetch_numbers (char *line, void *c)
5068 + num = atoi (line);
5069 + if (num < fc->base || num > fc->last)
5071 + fc->messages[num - fc->base] = 1;
5075 +static int add_xover_line (char *line, void *c)
5077 + unsigned int num, total;
5078 + CONTEXT *ctx = fc->ctx;
5079 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5084 + if (ctx->msgcount >= ctx->hdrmax)
5085 + mx_alloc_memory (ctx);
5086 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5087 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5089 + nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5090 + num = ctx->hdrs[ctx->msgcount]->article_num;
5092 + if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5095 + if (num > data->lastLoaded)
5096 + data->lastLoaded = num;
5097 + num = num - fc->first + 1;
5098 + total = fc->last - fc->first + 1;
5099 + if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5100 + mutt_message ("%s %d/%d", fc->msg, num, total);
5103 + mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5109 +static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5110 + unsigned int last)
5112 + char buf[HUGE_STRING];
5113 + char *msg = _("Fetching message headers...");
5114 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5118 + unsigned int current;
5122 + /* if empty group or nothing to do */
5123 + if (!last || first > last)
5126 + /* fetch list of articles */
5130 + fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5131 + if (nntp_data->nserv->hasLISTGROUP)
5133 + mutt_message _("Fetching list of articles...");
5134 + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5135 + if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5137 + mutt_error (_("LISTGROUP command failed: %s"), buf);
5139 + nntp_error ("nntp_fetch_headers()", buf);
5141 + FREE (&fc.messages);
5147 + for (num = 0; num < last - first + 1; num++)
5148 + fc.messages[num] = 1;
5151 + /* CACHE: must be loaded xover cache here */
5152 + num = nntp_data->lastCached - first + 1;
5153 + if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5155 + nntp_cache_expand (buf, nntp_data->cache);
5156 + mutt_message _("Fetching headers from cache...");
5157 + if ((f = safe_fopen (buf, "r")))
5161 + /* counting number of lines */
5162 + while (fgets (buf, sizeof (buf), f) != NULL)
5165 + while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5167 + oldmsgcount = ctx->msgcount;
5169 + fc.last = first + num - 1;
5171 + while (fgets (buf, sizeof (buf), f) != NULL)
5172 + add_xover_line (buf, &fc);
5174 + nntp_data->lastLoaded = fc.last;
5175 + first = fc.last + 1;
5176 + if (ctx->msgcount > oldmsgcount)
5177 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5180 + nntp_delete_cache (nntp_data);
5182 + num = last - first + 1;
5185 + FREE (&fc.messages);
5190 + * Without XOVER, we have to fetch each article header and parse
5191 + * it. With XOVER, we ask for all of them
5193 + mutt_message (msg);
5194 + if (nntp_data->nserv->hasXOVER)
5196 + oldmsgcount = ctx->msgcount;
5200 + snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5201 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5202 + if (ctx->msgcount > oldmsgcount)
5203 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5206 + mutt_error (_("XOVER command failed: %s"), buf);
5208 + nntp_error ("nntp_fetch_headers()", buf);
5210 + FREE (&fc.messages);
5216 + for (current = first; current <= last; current++)
5220 + ret = current - first + 1;
5221 + mutt_message ("%s %d/%d", msg, ret, num);
5223 + if (!fc.messages[current - fc.base])
5226 + if (ctx->msgcount >= ctx->hdrmax)
5227 + mx_alloc_memory (ctx);
5228 + h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5229 + h->index = ctx->msgcount;
5231 + ret = nntp_read_header (ctx, NULL, current);
5232 + if (ret == 0) /* Got article. Fetch next header */
5234 + nntp_get_status (ctx, h, NULL, h->article_num);
5236 + mx_update_context (ctx, 1);
5239 + mutt_free_header (&h); /* skip it */
5242 + FREE (&fc.messages);
5246 + if (current > nntp_data->lastLoaded)
5247 + nntp_data->lastLoaded = current;
5249 + FREE (&fc.messages);
5250 + nntp_data->lastLoaded = last;
5251 + mutt_clear_error ();
5256 + * currently, nntp "mailbox" is "newsgroup"
5258 +int nntp_open_mailbox (CONTEXT *ctx)
5260 + NNTP_DATA *nntp_data;
5261 + NNTP_SERVER *serv;
5262 + char buf[HUGE_STRING];
5263 + char server[LONG_STRING];
5265 + unsigned int first;
5268 + if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5270 + mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5276 + nntp_expand_path (server, sizeof (server), &acct);
5277 + if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5280 + CurrentNewsSrv = serv;
5282 + /* create NNTP-specific state struct if nof found in list */
5283 + if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5285 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5286 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5287 + strcpy (nntp_data->group, buf);
5288 + hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5289 + nntp_add_to_list (serv, nntp_data);
5291 + ctx->data = nntp_data;
5292 + ctx->mx_close = nntp_fastclose_mailbox;
5293 + nntp_data->nserv = serv;
5295 + mutt_message (_("Selecting %s..."), nntp_data->group);
5297 + if (!nntp_data->desc)
5299 + nntp_get_desc (nntp_data, nntp_data->group, NULL);
5300 + if (nntp_data->desc)
5301 + nntp_save_cache_index (serv);
5305 + if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5308 + nntp_error ("nntp_open_mailbox()", buf);
5313 + if (mutt_strncmp ("211", buf, 3))
5315 + LIST *l = serv->list;
5317 + /* GROUP command failed */
5318 + if (!mutt_strncmp ("411", buf, 3))
5320 + mutt_error (_("Newsgroup %s not found on server %s"),
5321 + nntp_data->group, serv->conn->account.host);
5323 + /* CACHE: delete cache and line from .index */
5324 + nntp_delete_cache (nntp_data);
5325 + hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5326 + while (l && l->data != (void *) nntp_data) l = l->next;
5336 + sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5337 + &nntp_data->lastMessage, buf);
5339 + nntp_data->deleted = 0;
5341 + time (&serv->check_time);
5344 + * Check for max adding context. If it is greater than $nntp_context,
5345 + * strip off extra articles
5347 + first = nntp_data->firstMessage;
5348 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5349 + first = nntp_data->lastMessage - NntpContext + 1;
5351 + nntp_data->lastLoaded = first - 1;
5352 + return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5355 +int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5357 + char buf[LONG_STRING];
5358 + char path[_POSIX_PATH_MAX];
5359 + NNTP_CACHE *cache;
5360 + char *m = _("Fetching message...");
5363 + /* see if we already have the message in our cache */
5364 + cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5366 + /* if everything is fine, assign msg->fp and return */
5367 + if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5368 + (msg->fp = fopen (cache->path, "r")))
5371 + /* clear the previous entry */
5372 + unlink (cache->path);
5373 + free (cache->path);
5377 + cache->index = ctx->hdrs[msgno]->index;
5378 + mutt_mktemp (path);
5379 + cache->path = safe_strdup (path);
5380 + if (!(msg->fp = safe_fopen (path, "w+")))
5382 + FREE (&cache->path);
5386 + if (ctx->hdrs[msgno]->article_num == 0)
5387 + snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5388 + ctx->hdrs[msgno]->env->message_id);
5390 + snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5391 + ctx->hdrs[msgno]->article_num);
5393 + ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5394 + msg->fp, ctx->tagged);
5397 + mutt_error (_("Article %d not found on server"),
5398 + ctx->hdrs[msgno]->article_num);
5399 + dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5406 + FREE (&cache->path);
5410 + mutt_free_envelope (&ctx->hdrs[msgno]->env);
5411 + ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5412 + /* fix content length */
5413 + fseek(msg->fp, 0, SEEK_END);
5414 + ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5415 + ctx->hdrs[msgno]->content->offset;
5417 + /* this is called in mutt before the open which fetches the message,
5418 + * which is probably wrong, but we just call it again here to handle
5419 + * the problem instead of fixing it.
5421 + mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5423 + /* These would normally be updated in mx_update_context(), but the
5424 + * full headers aren't parsed with XOVER, so the information wasn't
5427 +#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5428 + ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5429 +#endif /* HAVE_PGP || HAVE_SMIME */
5431 + mutt_clear_error();
5438 +int nntp_post (const char *msg) {
5439 + char buf[LONG_STRING];
5442 + NNTP_DATA *nntp_data;
5444 + if (Context && Context->magic == M_NNTP)
5445 + nntp_data = (NNTP_DATA *)Context->data;
5448 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5449 + !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5451 + mutt_error (_("Can't post article. No connection to news server."));
5454 + nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5457 + if (!(f = safe_fopen (msg, "r")))
5459 + mutt_error (_("Can't post article. Unable to open %s"), msg);
5463 + strfcpy (buf, "POST\r\n", sizeof (buf));
5464 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5466 + mutt_error (_("Can't post article. Connection to %s lost."),
5467 + nntp_data->nserv->conn->account.host);
5470 + if (buf[0] != '3')
5472 + mutt_error (_("Can't post article: %s"), buf);
5478 + while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5480 + len = strlen (buf);
5481 + if (buf[len - 1] == '\n')
5483 + buf[len - 1] = '\r';
5488 + if (buf[1] == '.')
5489 + mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5491 + mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5495 + if (buf[strlen (buf) - 1] != '\n')
5496 + mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5497 + mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5498 + if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5500 + mutt_error (_("Can't post article. Connection to %s lost."),
5501 + nntp_data->nserv->conn->account.host);
5504 + if (buf[0] != '2')
5506 + mutt_error (_("Can't post article: %s"), buf);
5513 +/* nntp_logout_all: close all open connections. */
5514 +void nntp_logout_all (void)
5516 + char buf[LONG_STRING];
5519 + conn = mutt_socket_head ();
5523 + CONNECTION *next = conn->next;
5525 + if (conn->account.type == M_ACCT_TYPE_NNTP)
5527 + mutt_message (_("Closing connection to %s..."), conn->account.host);
5528 + mutt_socket_write (conn, "QUIT\r\n");
5529 + mutt_socket_readln (buf, sizeof (buf), conn);
5530 + mutt_clear_error ();
5531 + mutt_socket_close (conn);
5532 + mutt_socket_free (conn);
5539 +static void nntp_free_acache (NNTP_DATA *data)
5543 + for (i = 0; i < NNTP_CACHE_LEN; i++)
5545 + if (data->acache[i].path)
5547 + unlink (data->acache[i].path);
5548 + FREE (&data->acache[i].path);
5553 +void nntp_delete_data (void *p)
5555 + NNTP_DATA *data = (NNTP_DATA *)p;
5559 + FREE (&data->entries);
5560 + FREE (&data->desc);
5561 + FREE (&data->cache);
5562 + nntp_free_acache (data);
5566 +int nntp_sync_mailbox (CONTEXT *ctx)
5568 + NNTP_DATA *data = ctx->data;
5570 + /* CACHE: update cache and .index files */
5571 + if ((option (OPTSAVEUNSUB) || data->subscribed))
5572 + nntp_save_cache_group (ctx);
5573 + nntp_free_acache (data);
5575 + data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
5579 +int nntp_fastclose_mailbox (CONTEXT *ctx)
5581 + NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
5585 + nntp_free_acache (data);
5586 + if (!data->nserv || !data->nserv->newsgroups || !data->group)
5588 + nntp_save_cache_index (data->nserv);
5589 + if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
5591 + nntp_delete_data (data);
5595 +/* commit changes and terminate connection */
5596 +int nntp_close_mailbox (CONTEXT *ctx)
5600 + mutt_message _("Quitting newsgroup...");
5603 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
5606 + if (data->nserv && data->nserv->conn && ctx->unread)
5608 + ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
5610 + mutt_newsgroup_catchup (data->nserv, data->group);
5615 + nntp_sync_mailbox (ctx);
5616 + if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
5618 + NNTP_SERVER *news;
5620 + news = ((NNTP_DATA *)ctx->data)->nserv;
5621 + newsrc_gen_entries (ctx);
5622 + ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
5623 + mutt_newsrc_update (news);
5625 + mutt_clear_error();
5629 +/* use the GROUP command to poll for new mail */
5630 +static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
5632 + char buf[LONG_STRING];
5635 + if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
5639 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5642 + nntp_error ("nntp_check_mailbox()", buf);
5646 + if (mutt_strncmp ("211", buf, 3))
5649 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5652 + nntp_error ("nntp_check_mailbox()", buf);
5657 + if (!mutt_strncmp ("211", buf, 3))
5662 + sscanf (buf + 4, "%d %d %d", &count, &first, &last);
5663 + nntp_data->firstMessage = first;
5664 + nntp_data->lastMessage = last;
5665 + if (ctx && last > nntp_data->lastLoaded)
5667 + nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
5668 + time (&nntp_data->nserv->check_time);
5671 + if (!last || (!nntp_data->rc && !nntp_data->lastCached))
5672 + nntp_data->unread = count;
5674 + mutt_newsgroup_stat (nntp_data);
5675 + /* active was renumbered? */
5676 + if (last < nntp_data->lastLoaded)
5678 + if (!nntp_data->max)
5680 + nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
5681 + nntp_data->max = 5;
5683 + nntp_data->lastCached = 0;
5684 + nntp_data->num = 1;
5685 + nntp_data->entries[0].first = 1;
5686 + nntp_data->entries[0].last = 0;
5690 + time (&nntp_data->nserv->check_time);
5694 +int nntp_check_mailbox (CONTEXT *ctx)
5696 + return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
5699 +static int add_group (char *buf, void *serv)
5701 +#define s ((NNTP_SERVER *) serv)
5702 + char group[LONG_STRING], mod, desc[HUGE_STRING];
5704 + NNTP_DATA *nntp_data;
5707 + _checked = n; /* _checked have N, where N = number of groups */
5708 + if (!buf) /* at EOF must be zerouth */
5715 + sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
5718 + if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
5721 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
5722 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5723 + strcpy (nntp_data->group, group);
5724 + nntp_data->nserv = s;
5725 + if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
5726 + s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2);
5727 + hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
5728 + nntp_add_to_list (s, nntp_data);
5730 + nntp_data->deleted = 0;
5731 + nntp_data->firstMessage = first;
5732 + nntp_data->lastMessage = last;
5734 + nntp_data->allowed = 1;
5736 + nntp_data->allowed = 0;
5737 + if (nntp_data->desc)
5738 + FREE (&nntp_data->desc);
5740 + nntp_data->desc = safe_strdup (desc);
5741 + if (nntp_data->rc || nntp_data->lastCached)
5742 + mutt_newsgroup_stat (nntp_data);
5743 + else if (nntp_data->lastMessage &&
5744 + nntp_data->firstMessage <= nntp_data->lastMessage)
5745 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
5747 + nntp_data->unread = 0;
5753 +int nntp_check_newgroups (NNTP_SERVER *serv, int force)
5755 + char buf[LONG_STRING];
5756 + char msg[SHORT_STRING];
5757 + NNTP_DATA nntp_data;
5762 + unsigned int count = 0;
5763 + unsigned int total = 0;
5765 + if (!serv || !serv->newgroups_time)
5768 + if (nntp_open_connection (serv) < 0)
5771 + /* check subscribed groups for new news */
5772 + if (option (OPTSHOWNEWNEWS))
5774 + mutt_message _("Checking for new messages...");
5775 + for (l = serv->list; l; l = l->next)
5777 + serv->check_time = 0; /* really check! */
5778 + if (l->data && ((NNTP_DATA *) l->data)->subscribed)
5779 + _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
5785 + mutt_message _("Checking for new newsgroups...");
5786 + now = serv->newgroups_time;
5787 + time (&serv->newgroups_time);
5788 + t = gmtime (&now);
5789 + snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
5790 + (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
5792 + nntp_data.nserv = serv;
5793 + if (Context && Context->magic == M_NNTP)
5794 + nntp_data.group = ((NNTP_DATA *)Context->data)->group;
5796 + nntp_data.group = NULL;
5798 + if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
5799 + add_group, serv, 0) != 0)
5802 + nntp_error ("nntp_check_newgroups()", buf);
5807 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5808 + mutt_message (msg);
5810 + emp.next = l->next;
5812 + emp.next = serv->list;
5817 + ((NNTP_DATA *) l->data)->new = 1;
5824 + nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
5826 + if (ReadInc && (count % ReadInc == 0))
5827 + mutt_message ("%s %d/%d", msg, count, total);
5830 + nntp_save_cache_index (serv);
5831 + mutt_clear_error ();
5835 +/* Load list of all newsgroups from cache ALL */
5836 +int nntp_get_cache_all (NNTP_SERVER *serv)
5838 + char buf[HUGE_STRING];
5841 + nntp_cache_expand (buf, serv->cache);
5842 + if ((f = safe_fopen (buf, "r")))
5846 + while (fgets (buf, sizeof(buf), f) != NULL)
5848 + if (ReadInc && (i % ReadInc == 0))
5849 + mutt_message (_("Loading list from cache... %d"), i);
5850 + add_group (buf, serv);
5853 + add_group (NULL, NULL);
5855 + mutt_clear_error ();
5860 + FREE (&serv->cache);
5865 +/* Load list of all newsgroups from active */
5866 +int nntp_get_active (NNTP_SERVER *serv)
5868 + char msg[SHORT_STRING];
5869 + NNTP_DATA nntp_data;
5872 + if (nntp_open_connection (serv) < 0)
5875 + snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
5876 + serv->conn->account.host);
5877 + mutt_message (msg);
5878 + time (&serv->newgroups_time);
5879 + nntp_data.nserv = serv;
5880 + nntp_data.group = NULL;
5882 + if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
5885 + nntp_error ("nntp_get_active()", "LIST\r\n");
5890 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5891 + mutt_message (msg);
5892 + nntp_get_desc (&nntp_data, "*", msg);
5894 + for (tmp = serv->list; tmp; tmp = tmp->next)
5896 + NNTP_DATA *data = (NNTP_DATA *)tmp->data;
5898 + if (data && data->deleted && !data->rc)
5900 + nntp_delete_cache (data);
5901 + hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
5905 + nntp_save_cache_index (serv);
5907 + mutt_clear_error ();
5912 + * returns -1 if error ocurred while retrieving header,
5913 + * number of articles which ones exist in context on success.
5915 +int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
5919 + /* if msgid is already in context, don't reload them */
5920 + if (hash_find (ctx->id_hash, msgid))
5922 + if (ctx->msgcount == ctx->hdrmax)
5923 + mx_alloc_memory (ctx);
5924 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5925 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5927 + mutt_message (_("Fetching %s from server..."), msgid);
5928 + ret = nntp_read_header (ctx, msgid, 0);
5929 + /* since nntp_read_header() may set read flag, we must reset it */
5930 + ctx->hdrs[ctx->msgcount]->read = 0;
5932 + mutt_free_header (&ctx->hdrs[ctx->msgcount]);
5936 + mx_update_context (ctx, 1);
5947 + unsigned int *child;
5950 +static int check_children (char *s, void *c)
5952 +#define cc ((CHILD_CONTEXT *) c)
5953 + unsigned int i, n;
5955 + if (!s || (n = atoi (s)) == 0)
5957 + for (i = 0; i < cc->ctx->msgcount; i++)
5958 + if (cc->ctx->hdrs[i]->article_num == n)
5960 + if (cc->num >= cc->max)
5961 + safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
5962 + cc->child[cc->num++] = n;
5968 +int nntp_check_children (CONTEXT *ctx, const char *msgid)
5970 + NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
5972 + int i, ret = 0, tmp = 0;
5975 + if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
5976 + !nntp_data->nserv->conn->account.host)
5978 + if (nntp_data->firstMessage > nntp_data->lastLoaded)
5980 + if (!nntp_data->nserv->hasXPAT)
5982 + mutt_error (_("Server %s does not support this operation!"),
5983 + nntp_data->nserv->conn->account.host);
5987 + snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
5988 + nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
5993 + cc.child = safe_malloc (sizeof (unsigned int) * 25);
5994 + if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
5999 + /* dont try to read the xover cache. check_children() already
6000 + * made sure that we dont have the article, so we need to visit
6001 + * the server. Reading the cache at this point is also bad
6002 + * because it would duplicate messages */
6003 + if (option (OPTNEWSCACHE))
6006 + unset_option (OPTNEWSCACHE);
6008 + for (i = 0; i < cc.num; i++)
6010 + if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
6012 + if (ctx->msgcount &&
6013 + ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
6014 + ctx->hdrs[ctx->msgcount - 1]->read = 0;
6017 + set_option (OPTNEWSCACHE);
6021 diff -udprP mutt-1.5.19.orig/nntp.h mutt-1.5.19/nntp.h
6022 --- mutt-1.5.19.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
6023 +++ mutt-1.5.19/nntp.h 2009-01-06 22:27:38.000000000 +0200
6026 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
6027 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
6028 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
6030 + * This program is free software; you can redistribute it and/or modify
6031 + * it under the terms of the GNU General Public License as published by
6032 + * the Free Software Foundation; either version 2 of the License, or
6033 + * (at your option) any later version.
6035 + * This program is distributed in the hope that it will be useful,
6036 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6037 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6038 + * GNU General Public License for more details.
6040 + * You should have received a copy of the GNU General Public License
6041 + * along with this program; if not, write to the Free Software
6042 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6048 +#include "mutt_socket.h"
6049 +#include "mailbox.h"
6053 +#define NNTP_PORT 119
6054 +#define NNTP_SSL_PORT 563
6056 +/* number of entries in the hash table */
6057 +#define NNTP_CACHE_LEN 10
6074 + unsigned int hasXPAT : 1;
6075 + unsigned int hasXGTITLE : 1;
6076 + unsigned int hasXOVER : 1;
6077 + unsigned int hasLISTGROUP : 1;
6078 + unsigned int status : 3;
6084 + time_t newgroups_time;
6085 + time_t check_time;
6087 + LIST *list; /* list of newsgroups */
6088 + LIST *tail; /* last entry of list */
6094 + unsigned int index;
6100 + NEWSRC_ENTRY *entries;
6101 + unsigned int num; /* number of used entries */
6102 + unsigned int max; /* number of allocated entries */
6103 + unsigned int unread;
6104 + unsigned int firstMessage;
6105 + unsigned int lastMessage;
6106 + unsigned int lastLoaded;
6107 + unsigned int lastCached;
6108 + unsigned int subscribed : 1;
6109 + unsigned int rc : 1;
6110 + unsigned int new : 1;
6111 + unsigned int allowed : 1;
6112 + unsigned int deleted : 1;
6116 + NNTP_SERVER *nserv;
6117 + NNTP_CACHE acache[NNTP_CACHE_LEN];
6120 +/* internal functions */
6121 +int nntp_get_active (NNTP_SERVER *);
6122 +int nntp_get_cache_all (NNTP_SERVER *);
6123 +int nntp_save_cache_index (NNTP_SERVER *);
6124 +int nntp_check_newgroups (NNTP_SERVER *, int);
6125 +int nntp_save_cache_group (CONTEXT *);
6126 +int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6127 +void newsrc_gen_entries (CONTEXT *);
6128 +void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6129 +void mutt_newsgroup_stat (NNTP_DATA *);
6130 +void nntp_delete_cache (NNTP_DATA *);
6131 +void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6132 +void nntp_cache_expand (char *, const char *);
6133 +void nntp_delete_data (void *);
6135 +/* exposed interface */
6136 +NNTP_SERVER *mutt_select_newsserver (char *);
6137 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6138 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6139 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6140 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6141 +void nntp_clear_cacheindex (NNTP_SERVER *);
6142 +int mutt_newsrc_update (NNTP_SERVER *);
6143 +int nntp_open_mailbox (CONTEXT *);
6144 +int nntp_sync_mailbox (CONTEXT *);
6145 +int nntp_check_mailbox (CONTEXT *);
6146 +int nntp_close_mailbox (CONTEXT *);
6147 +int nntp_fastclose_mailbox (CONTEXT *);
6148 +int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6149 +int nntp_post (const char *);
6150 +int nntp_check_msgid (CONTEXT *, const char *);
6151 +int nntp_check_children (CONTEXT *, const char *);
6152 +void nntp_buffy (char *);
6153 +void nntp_expand_path (char *, size_t, ACCOUNT *);
6154 +void nntp_logout_all ();
6155 +const char *nntp_format_str (char *, size_t, size_t, char, const char *, const char *,
6156 + const char *, const char *, unsigned long, format_flag);
6158 +NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6160 +#endif /* _NNTP_H_ */
6161 diff -udprP mutt-1.5.19.orig/pager.c mutt-1.5.19/pager.c
6162 --- mutt-1.5.19.orig/pager.c 2009-01-05 21:20:53.000000000 +0200
6163 +++ mutt-1.5.19/pager.c 2009-01-06 22:27:38.000000000 +0200
6164 @@ -1048,6 +1048,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
6174 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6175 int flags, ansi_attr *pa, int cnt,
6176 @@ -1489,6 +1494,16 @@ static struct mapping_t PagerHelpExtra[]
6181 +static struct mapping_t PagerNewsHelpExtra[] = {
6182 + { N_("Post"), OP_POST },
6183 + { N_("Followup"), OP_FOLLOWUP },
6184 + { N_("Del"), OP_DELETE },
6185 + { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6192 /* This pager is actually not so simple as it once was. It now operates in
6193 @@ -1530,6 +1545,10 @@ mutt_pager (const char *banner, const ch
6194 int old_PagerIndexLines; /* some people want to resize it
6195 * while inside the pager... */
6198 + char *followup_to;
6201 if (!(flags & M_SHOWCOLOR))
6202 flags |= M_SHOWFLAT;
6204 @@ -1569,7 +1588,11 @@ mutt_pager (const char *banner, const ch
6205 if (IsHeader (extra))
6207 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6208 - mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6209 + mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6211 + (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6214 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6217 @@ -2407,6 +2430,15 @@ search_next:
6219 CHECK_ACL(M_ACL_WRITE, "flag message");
6222 + if (Context->magic == M_NNTP)
6225 + mutt_error _("Can't change 'important' flag on NNTP server.");
6230 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6231 redraw = REDRAW_STATUS | REDRAW_INDEX;
6232 if (option (OPTRESOLVE))
6233 @@ -2440,6 +2472,60 @@ search_next:
6234 redraw = REDRAW_FULL;
6239 + CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6241 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6242 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6243 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6245 + ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6246 + redraw = REDRAW_FULL;
6249 + case OP_FORWARD_TO_GROUP:
6250 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6252 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6253 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6254 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6256 + if (IsMsgAttach (extra))
6257 + mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6258 + extra->idxlen, extra->bdy, SENDNEWS);
6260 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6261 + redraw = REDRAW_FULL;
6265 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6268 + if (IsMsgAttach (extra))
6269 + followup_to = extra->bdy->hdr->env->followup_to;
6271 + followup_to = extra->hdr->env->followup_to;
6273 + if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6274 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6276 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6277 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6278 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6280 + if (IsMsgAttach (extra))
6281 + mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6282 + extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6284 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6285 + extra->ctx, extra->hdr);
6286 + redraw = REDRAW_FULL;
6292 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6294 @@ -2486,7 +2572,7 @@ search_next:
6296 if (IsMsgAttach (extra))
6297 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6298 - extra->idxlen, extra->bdy);
6299 + extra->idxlen, extra->bdy, 0);
6301 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6302 redraw = REDRAW_FULL;
6303 diff -udprP mutt-1.5.19.orig/parse.c mutt-1.5.19/parse.c
6304 --- mutt-1.5.19.orig/parse.c 2009-01-05 21:20:53.000000000 +0200
6305 +++ mutt-1.5.19/parse.c 2009-01-06 22:27:38.000000000 +0200
6306 @@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
6310 -static LIST *mutt_parse_references (char *s, int in_reply_to)
6311 +LIST *mutt_parse_references (char *s, int in_reply_to)
6313 LIST *t, *lst = NULL;
6315 @@ -1067,6 +1067,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6316 e->from = rfc822_parse_adrlist (e->from, p);
6320 + else if (!mutt_strcasecmp (line+1, "ollowup-to"))
6322 + if (!e->followup_to)
6324 + mutt_remove_trailing_ws (p);
6325 + e->followup_to = safe_strdup (mutt_skip_whitespace (p));
6333 @@ -1151,6 +1162,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6339 + if (!mutt_strcasecmp (line + 1, "ewsgroups"))
6341 + FREE (&e->newsgroups);
6342 + mutt_remove_trailing_ws (p);
6343 + e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
6350 + /* field `Organization:' saves only for pager! */
6351 + if (!mutt_strcasecmp (line + 1, "rganization"))
6353 + if (!e->organization && mutt_strcasecmp (p, "unknown"))
6354 + e->organization = safe_strdup (p);
6359 if (!ascii_strcasecmp (line + 1, "eferences"))
6361 @@ -1259,6 +1291,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6362 e->x_label = safe_strdup(p);
6366 + else if (!mutt_strcasecmp (line + 1, "-comment-to"))
6368 + if (!e->x_comment_to)
6369 + e->x_comment_to = safe_strdup (p);
6372 + else if (!mutt_strcasecmp (line + 1, "ref"))
6375 + e->xref = safe_strdup (p);
6382 diff -udprP mutt-1.5.19.orig/pattern.c mutt-1.5.19/pattern.c
6383 --- mutt-1.5.19.orig/pattern.c 2009-01-05 21:20:53.000000000 +0200
6384 +++ mutt-1.5.19/pattern.c 2009-01-06 22:27:38.000000000 +0200
6385 @@ -91,6 +91,9 @@ Flags[] =
6386 { 'U', M_UNREAD, 0, NULL },
6387 { 'v', M_COLLAPSED, 0, NULL },
6388 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6390 + { 'w', M_NEWSGROUPS, 0, eat_regexp },
6392 { 'x', M_REFERENCE, 0, eat_regexp },
6393 { 'X', M_MIMEATTACH, 0, eat_range },
6394 { 'y', M_XLABEL, 0, eat_regexp },
6395 @@ -1201,6 +1204,10 @@ mutt_pattern_exec (struct pattern_t *pat
6397 case M_UNREFERENCED:
6398 return (pat->not ^ (h->thread && !h->thread->child));
6400 + case M_NEWSGROUPS:
6401 + return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6404 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6406 @@ -1282,6 +1289,7 @@ int mutt_pattern_func (int op, char *pro
6407 progress_t progress;
6409 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6410 + if (prompt || op != M_LIMIT)
6411 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6414 diff -udprP mutt-1.5.19.orig/po/POTFILES.in mutt-1.5.19/po/POTFILES.in
6415 --- mutt-1.5.19.orig/po/POTFILES.in 2008-03-19 22:07:57.000000000 +0200
6416 +++ mutt-1.5.19/po/POTFILES.in 2009-01-06 22:27:38.000000000 +0200
6417 @@ -46,6 +46,8 @@ mutt_ssl_gnutls.c
6426 diff -udprP mutt-1.5.19.orig/postpone.c mutt-1.5.19/postpone.c
6427 --- mutt-1.5.19.orig/postpone.c 2009-01-05 21:20:53.000000000 +0200
6428 +++ mutt-1.5.19/postpone.c 2009-01-06 22:27:38.000000000 +0200
6429 @@ -124,15 +124,26 @@ int mutt_num_postponed (int force)
6431 if (LastModify < st.st_mtime)
6434 + int optnews = option (OPTNEWS);
6436 LastModify = st.st_mtime;
6438 if (access (Postponed, R_OK | F_OK) != 0)
6439 return (PostCount = 0);
6442 + unset_option (OPTNEWS);
6444 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6447 PostCount = ctx.msgcount;
6448 mx_fastclose_mailbox (&ctx);
6451 + set_option (OPTNEWS);
6456 diff -udprP mutt-1.5.19.orig/protos.h mutt-1.5.19/protos.h
6457 --- mutt-1.5.19.orig/protos.h 2009-01-05 21:20:53.000000000 +0200
6458 +++ mutt-1.5.19/protos.h 2009-01-06 22:27:38.000000000 +0200
6459 @@ -115,6 +115,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
6460 HASH *mutt_make_subj_hash (CONTEXT *);
6462 LIST *mutt_make_references(ENVELOPE *e);
6463 +LIST *mutt_parse_references (char *, int);
6465 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6466 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
6467 diff -udprP mutt-1.5.19.orig/recvattach.c mutt-1.5.19/recvattach.c
6468 --- mutt-1.5.19.orig/recvattach.c 2009-01-05 21:20:53.000000000 +0200
6469 +++ mutt-1.5.19/recvattach.c 2009-01-06 22:27:38.000000000 +0200
6470 @@ -1107,6 +1107,15 @@ void mutt_view_attachments (HEADER *hdr)
6475 + if (Context->magic == M_NNTP)
6478 + mutt_error _("Can't delete attachment from newsserver.");
6483 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6486 @@ -1198,10 +1207,33 @@ void mutt_view_attachments (HEADER *hdr)
6487 case OP_FORWARD_MESSAGE:
6489 mutt_attach_forward (fp, hdr, idx, idxlen,
6490 - menu->tagprefix ? NULL : idx[menu->current]->content);
6491 + menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6492 menu->redraw = REDRAW_FULL;
6496 + case OP_FORWARD_TO_GROUP:
6498 + mutt_attach_forward (fp, hdr, idx, idxlen,
6499 + menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6500 + menu->redraw = REDRAW_FULL;
6506 + if (!idx[menu->current]->content->hdr->env->followup_to ||
6507 + mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6508 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6510 + mutt_attach_reply (fp, hdr, idx, idxlen,
6511 + menu->tagprefix ? NULL : idx[menu->current]->content,
6512 + SENDNEWS|SENDREPLY);
6513 + menu->redraw = REDRAW_FULL;
6519 case OP_GROUP_REPLY:
6521 diff -udprP mutt-1.5.19.orig/recvcmd.c mutt-1.5.19/recvcmd.c
6522 --- mutt-1.5.19.orig/recvcmd.c 2009-01-05 21:20:53.000000000 +0200
6523 +++ mutt-1.5.19/recvcmd.c 2009-01-06 22:27:38.000000000 +0200
6524 @@ -373,7 +373,7 @@ static BODY ** copy_problematic_attachme
6525 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6526 ATTACHPTR ** idx, short idxlen,
6529 + short nattach, int flags)
6532 short mime_fwd_all = 0;
6533 @@ -519,7 +519,7 @@ _("Can't decode all tagged attachments.
6536 /* now that we have the template, send it. */
6537 - ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6538 + ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6542 @@ -546,7 +546,7 @@ _("Can't decode all tagged attachments.
6545 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6546 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6547 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6549 HEADER *curhdr = NULL;
6551 @@ -651,23 +651,23 @@ static void attach_forward_msgs (FILE *
6553 mutt_free_header (&tmphdr);
6555 - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6556 + ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
6561 void mutt_attach_forward (FILE * fp, HEADER * hdr,
6562 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6563 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6568 if (check_all_msg (idx, idxlen, cur, 0) == 0)
6569 - attach_forward_msgs (fp, hdr, idx, idxlen, cur);
6570 + attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
6573 nattach = count_tagged (idx, idxlen);
6574 - attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
6575 + attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
6579 @@ -725,28 +725,40 @@ attach_reply_envelope_defaults (ENVELOPE
6585 + if ((flags & SENDNEWS))
6587 - if (mutt_fetch_recips (env, curenv, flags) == -1)
6589 + /* in case followup set Newsgroups: with Followup-To: if it present */
6590 + if (!env->newsgroups && curenv &&
6591 + mutt_strcasecmp (curenv->followup_to, "poster"))
6592 + env->newsgroups = safe_strdup (curenv->followup_to);
6597 - for (i = 0; i < idxlen; i++)
6600 - if (idx[i]->content->tagged
6601 - && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6602 + if (mutt_fetch_recips (env, curenv, flags) == -1)
6607 + for (i = 0; i < idxlen; i++)
6609 + if (idx[i]->content->tagged
6610 + && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6615 + if ((flags & SENDLISTREPLY) && !env->to)
6617 + mutt_error _("No mailing lists found!");
6621 + mutt_fix_reply_recipients (env);
6624 - if ((flags & SENDLISTREPLY) && !env->to)
6626 - mutt_error _("No mailing lists found!");
6630 - mutt_fix_reply_recipients (env);
6631 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
6634 @@ -807,6 +819,13 @@ void mutt_attach_reply (FILE * fp, HEADE
6635 char prefix[SHORT_STRING];
6639 + if (flags & SENDNEWS)
6640 + set_option (OPTNEWSSEND);
6642 + unset_option (OPTNEWSSEND);
6645 if (check_all_msg (idx, idxlen, cur, 0) == -1)
6647 nattach = count_tagged (idx, idxlen);
6648 diff -udprP mutt-1.5.19.orig/rfc1524.c mutt-1.5.19/rfc1524.c
6649 --- mutt-1.5.19.orig/rfc1524.c 2009-01-05 21:20:53.000000000 +0200
6650 +++ mutt-1.5.19/rfc1524.c 2009-01-06 22:27:38.000000000 +0200
6651 @@ -569,13 +569,13 @@ int rfc1524_expand_filename (char *namet
6655 -int mutt_rename_file (char *oldfile, char *newfile)
6656 +int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
6660 if (access (oldfile, F_OK) != 0)
6662 - if (access (newfile, F_OK) == 0)
6663 + if (!overwrite && access (newfile, F_OK) == 0)
6665 if ((ofp = fopen (oldfile,"r")) == NULL)
6667 @@ -590,3 +590,8 @@ int mutt_rename_file (char *oldfile, cha
6668 mutt_unlink (oldfile);
6672 +int mutt_rename_file (char *oldfile, char *newfile)
6674 + return _mutt_rename_file (oldfile, newfile, 0);
6676 diff -udprP mutt-1.5.19.orig/rfc1524.h mutt-1.5.19/rfc1524.h
6677 --- mutt-1.5.19.orig/rfc1524.h 2008-03-19 22:07:06.000000000 +0200
6678 +++ mutt-1.5.19/rfc1524.h 2009-01-06 22:27:38.000000000 +0200
6679 @@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char
6680 int rfc1524_expand_filename (char *, char *, char *, size_t);
6681 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
6682 int mutt_rename_file (char *, char *);
6683 +int _mutt_rename_file (char *, char *, int);
6685 #endif /* _RFC1524_H */
6686 diff -udprP mutt-1.5.19.orig/send.c mutt-1.5.19/send.c
6687 --- mutt-1.5.19.orig/send.c 2009-01-05 21:20:53.000000000 +0200
6688 +++ mutt-1.5.19/send.c 2009-01-06 22:27:38.000000000 +0200
6690 #include <sys/types.h>
6699 #include "remailer.h"
6701 @@ -213,17 +218,51 @@ static int edit_address (ADDRESS **a, /*
6705 -static int edit_envelope (ENVELOPE *en)
6706 +static int edit_envelope (ENVELOPE *en, int flags)
6708 char buf[HUGE_STRING];
6709 LIST *uh = UserHeader;
6711 - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6713 - if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6715 - if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6718 + if (option (OPTNEWSSEND))
6720 + if (en->newsgroups)
6721 + strfcpy (buf, en->newsgroups, sizeof (buf));
6724 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
6726 + FREE (&en->newsgroups);
6727 + en->newsgroups = safe_strdup (buf);
6729 + if (en->followup_to)
6730 + strfcpy (buf, en->followup_to, sizeof (buf));
6733 + if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
6735 + FREE (&en->followup_to);
6736 + en->followup_to = safe_strdup (buf);
6738 + if (en->x_comment_to)
6739 + strfcpy (buf, en->x_comment_to, sizeof (buf));
6742 + if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
6744 + FREE (&en->x_comment_to);
6745 + en->x_comment_to = safe_strdup (buf);
6750 + if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6752 + if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6754 + if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6760 @@ -259,6 +298,14 @@ static int edit_envelope (ENVELOPE *en)
6765 +char *nntp_get_header (const char *s)
6768 + return safe_strdup (s);
6772 static void process_user_recips (ENVELOPE *env)
6774 LIST *uh = UserHeader;
6775 @@ -271,6 +318,14 @@ static void process_user_recips (ENVELOP
6776 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
6777 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
6778 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
6780 + else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
6781 + env->newsgroups = nntp_get_header (uh->data + 11);
6782 + else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
6783 + env->followup_to = nntp_get_header (uh->data + 12);
6784 + else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
6785 + env->x_comment_to = nntp_get_header (uh->data + 13);
6790 @@ -309,6 +364,12 @@ static void process_user_header (ENVELOP
6791 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
6792 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
6793 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
6795 + ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
6796 + ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
6797 + ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
6799 + ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
6800 ascii_strncasecmp ("subject:", uh->data, 8) != 0)
6803 @@ -652,6 +713,10 @@ void mutt_add_to_reference_headers (ENVE
6808 + if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
6809 + env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
6814 @@ -708,6 +773,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
6816 if (flags & SENDREPLY)
6819 + if ((flags & SENDNEWS))
6821 + /* in case followup set Newsgroups: with Followup-To: if it present */
6822 + if (!env->newsgroups && curenv &&
6823 + mutt_strcasecmp (curenv->followup_to, "poster"))
6824 + env->newsgroups = safe_strdup (curenv->followup_to);
6831 @@ -854,7 +929,18 @@ void mutt_set_followup_to (ENVELOPE *e)
6832 * it hasn't already been set
6835 - if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
6836 + if (!option (OPTFOLLOWUPTO))
6839 + if (option (OPTNEWSSEND))
6841 + if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
6842 + e->followup_to = safe_strdup (e->newsgroups);
6847 + if (!e->mail_followup_to)
6849 if (mutt_is_list_cc (0, e->to, e->cc))
6851 @@ -1015,6 +1101,9 @@ static int send_message (HEADER *msg)
6856 + if (!option (OPTNEWSSEND))
6857 +#endif /* USE_NNTP */
6859 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
6860 msg->env->bcc, tempfile,
6861 @@ -1107,6 +1196,13 @@ ci_send_message (int flags, /* send mod
6866 + if (flags & SENDNEWS)
6867 + set_option (OPTNEWSSEND);
6869 + unset_option (OPTNEWSSEND);
6872 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
6873 mutt_num_postponed (1))
6875 @@ -1137,6 +1233,22 @@ ci_send_message (int flags, /* send mod
6877 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
6881 + * If postponed message is a news article, it have
6882 + * a "Newsgroups:" header line, then set appropriate flag.
6884 + if (msg->env->newsgroups)
6886 + flags |= SENDNEWS;
6887 + set_option (OPTNEWSSEND);
6891 + flags &= ~SENDNEWS;
6892 + unset_option (OPTNEWSSEND);
6897 if (flags & (SENDPOSTPONED|SENDRESEND))
6898 @@ -1248,11 +1360,16 @@ ci_send_message (int flags, /* send mod
6899 if (flags & SENDREPLY)
6900 mutt_fix_reply_recipients (msg->env);
6903 + if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
6904 + msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
6907 if (! (flags & SENDMAILX) &&
6908 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
6909 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
6911 - if (edit_envelope (msg->env) == -1)
6912 + if (edit_envelope (msg->env, flags) == -1)
6916 @@ -1509,6 +1626,11 @@ main_loop:
6921 + if (flags & SENDNEWS)
6922 + mutt_message _("Article not posted.");
6925 mutt_message _("Mail not sent.");
6928 @@ -1541,6 +1663,9 @@ main_loop:
6933 + if (!(flags & SENDNEWS))
6935 if (!msg->env->to && !msg->env->cc && !msg->env->bcc)
6937 if (! (flags & SENDBATCH))
6938 @@ -1573,6 +1698,19 @@ main_loop:
6939 mutt_error _("No subject specified.");
6943 + if ((flags & SENDNEWS) && !msg->env->subject)
6945 + mutt_error _("No subject specified.");
6949 + if ((flags & SENDNEWS) && !msg->env->newsgroups)
6951 + mutt_error _("No newsgroup specified.");
6956 if (msg->content->next)
6957 msg->content = mutt_make_multipart (msg->content);
6958 @@ -1778,7 +1916,12 @@ full_fcc:
6961 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
6962 - mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
6963 + mutt_message (i != 0 ? _("Sending in background.") :
6965 + (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
6970 if (WithCrypto && (msg->security & ENCRYPT))
6972 diff -udprP mutt-1.5.19.orig/sendlib.c mutt-1.5.19/sendlib.c
6973 --- mutt-1.5.19.orig/sendlib.c 2009-01-04 01:27:11.000000000 +0200
6974 +++ mutt-1.5.19/sendlib.c 2009-01-06 22:27:38.000000000 +0200
6976 #include <sys/wait.h>
6983 #ifdef HAVE_SYSEXITS_H
6984 #include <sysexits.h>
6985 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
6986 @@ -1748,6 +1752,9 @@ int mutt_write_rfc822_header (FILE *fp,
6987 LIST *tmp = env->userhdrs;
6988 int has_agent = 0; /* user defined user-agent header field exists */
6991 + if (!option (OPTNEWSSEND))
6993 if (mode == 0 && !privacy)
6994 fputs (mutt_make_date (buffer, sizeof(buffer)), fp);
6996 @@ -1774,6 +1781,9 @@ int mutt_write_rfc822_header (FILE *fp,
6997 mutt_write_address_list (env->to, fp, 4, 0);
7001 + if (!option (OPTNEWSSEND))
7003 fputs ("To: \n", fp);
7006 @@ -1782,6 +1792,9 @@ int mutt_write_rfc822_header (FILE *fp,
7007 mutt_write_address_list (env->cc, fp, 4, 0);
7011 + if (!option (OPTNEWSSEND))
7013 fputs ("Cc: \n", fp);
7016 @@ -1793,8 +1806,28 @@ int mutt_write_rfc822_header (FILE *fp,
7021 + if (!option (OPTNEWSSEND))
7023 fputs ("Bcc: \n", fp);
7026 + if (env->newsgroups)
7027 + fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
7028 + else if (mode == 1 && option (OPTNEWSSEND))
7029 + fputs ("Newsgroups: \n", fp);
7031 + if (env->followup_to)
7032 + fprintf (fp, "Followup-To: %s\n", env->followup_to);
7033 + else if (mode == 1 && option (OPTNEWSSEND))
7034 + fputs ("Followup-To: \n", fp);
7036 + if (env->x_comment_to)
7037 + fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
7038 + else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
7039 + fputs ("X-Comment-To: \n", fp);
7043 mutt_write_one_header (fp, "Subject", env->subject, NULL, 0);
7045 @@ -1813,6 +1846,9 @@ int mutt_write_rfc822_header (FILE *fp,
7046 fputs ("Reply-To: \n", fp);
7048 if (env->mail_followup_to)
7050 + if (!option (OPTNEWSSEND))
7053 fputs ("Mail-Followup-To: ", fp);
7054 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
7055 @@ -2151,11 +2187,30 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7056 const char *msg, /* file containing message */
7057 int eightbit) /* message contains 8bit chars */
7059 - char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
7060 + char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
7062 size_t argslen = 0, argsmax = 0;
7066 + if (option (OPTNEWSSEND))
7068 + char cmd[LONG_STRING];
7070 + mutt_FormatString (cmd, sizeof (cmd), 0, NONULL (Inews), nntp_format_str, 0, 0);
7073 + i = nntp_post (msg);
7078 + s = safe_strdup (cmd);
7082 + s = safe_strdup (Sendmail);
7086 while ((ps = strtok (ps, " ")))
7087 @@ -2179,6 +2234,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7092 + if (!option (OPTNEWSSEND))
7095 if (eightbit && option (OPTUSE8BITMIME))
7096 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7098 @@ -2210,6 +2269,9 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7099 args = add_args (args, &argslen, &argsmax, to);
7100 args = add_args (args, &argslen, &argsmax, cc);
7101 args = add_args (args, &argslen, &argsmax, bcc);
7106 if (argslen == argsmax)
7107 safe_realloc (&args, sizeof (char *) * (++argsmax));
7108 @@ -2290,6 +2352,9 @@ void mutt_prepare_envelope (ENVELOPE *en
7109 rfc2047_encode_string (&env->x_label);
7113 + if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
7116 rfc2047_encode_string (&env->subject);
7118 @@ -2399,6 +2464,10 @@ int mutt_bounce_message (FILE *fp, HEADE
7120 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
7123 + unset_option (OPTNEWSSEND);
7126 ret = _mutt_bounce_message (fp, h, to, resent_from, from);
7128 rfc822_free_address (&from);
7129 diff -udprP mutt-1.5.19.orig/sort.c mutt-1.5.19/sort.c
7130 --- mutt-1.5.19.orig/sort.c 2008-10-29 00:29:44.000000000 +0200
7131 +++ mutt-1.5.19/sort.c 2009-01-06 22:27:38.000000000 +0200
7132 @@ -151,6 +151,15 @@ static int compare_order (const void *a,
7133 HEADER **ha = (HEADER **) a;
7134 HEADER **hb = (HEADER **) b;
7137 + if ((*ha)->article_num && (*hb)->article_num)
7139 + int result = (*ha)->article_num - (*hb)->article_num;
7140 + AUXSORT(result,a,b);
7141 + return (SORTCODE (result));
7145 /* no need to auxsort because you will never have equality here */
7146 return (SORTCODE ((*ha)->index - (*hb)->index));
7148 diff -udprP mutt-1.5.19.orig/url.c mutt-1.5.19/url.c
7149 --- mutt-1.5.19.orig/url.c 2009-01-05 21:20:53.000000000 +0200
7150 +++ mutt-1.5.19/url.c 2009-01-06 22:27:38.000000000 +0200
7151 @@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] =
7152 { "imaps", U_IMAPS },
7155 + { "news", U_NNTP },
7156 + { "newss", U_NNTPS },
7157 { "mailto", U_MAILTO },
7159 { "smtps", U_SMTPS },
7160 diff -udprP mutt-1.5.19.orig/url.h mutt-1.5.19/url.h
7161 --- mutt-1.5.19.orig/url.h 2008-03-19 22:07:57.000000000 +0200
7162 +++ mutt-1.5.19/url.h 2009-01-06 22:27:38.000000000 +0200
7163 @@ -8,6 +8,8 @@ typedef enum url_scheme
7172 diff -udprP mutt-1.5.19.orig/Makefile.am mutt-1.5.19/Makefile.am
7173 --- mutt-1.5.19.orig/Makefile.am 2009-01-05 21:20:53.000000000 +0200
7174 +++ mutt-1.5.19/Makefile.am 2009-01-06 22:27:38.000000000 +0200
7175 @@ -53,6 +53,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
7176 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
7177 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
7178 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
7180 smime.c smtp.c utf8.c wcwidth.c \
7181 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
7183 @@ -64,6 +65,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7184 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7185 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7186 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7187 + nntp.h ChangeLog.nntp \
7188 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7189 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
7190 README.SSL smime.h \
7191 diff -udprP mutt-1.5.19.orig/Makefile.in mutt-1.5.19/Makefile.in
7192 --- mutt-1.5.19.orig/Makefile.in 2009-01-05 21:24:13.000000000 +0200
7193 +++ mutt-1.5.19/Makefile.in 2009-01-06 22:27:38.000000000 +0200
7194 @@ -323,6 +323,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
7195 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
7196 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
7197 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
7199 smime.c smtp.c utf8.c wcwidth.c \
7200 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
7202 @@ -334,6 +335,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7203 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7204 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7205 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7206 + nntp.h ChangeLog.nntp \
7207 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7208 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
7209 README.SSL smime.h \
7210 @@ -555,6 +557,8 @@ distclean-compile:
7211 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@
7212 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@
7213 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@
7214 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@
7215 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@
7216 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@
7217 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
7218 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@
7219 diff -udprP mutt-1.5.19.orig/configure mutt-1.5.19/configure
7220 --- mutt-1.5.19.orig/configure 2008-11-18 01:53:41.000000000 +0200
7221 +++ mutt-1.5.19/configure 2009-01-06 22:27:38.000000000 +0200
7222 @@ -1359,6 +1359,7 @@ Optional Features:
7223 Force use of an external dotlock program
7224 --enable-pop Enable POP3 support
7225 --enable-imap Enable IMAP support
7226 + --enable-nntp Enable NNTP support
7227 --enable-smtp include internal SMTP relay support
7228 --enable-debug Enable debugging support
7229 --enable-flock Use flock() to lock files
7230 @@ -12547,6 +12548,20 @@ fi
7234 +# Check whether --enable-nntp or --disable-nntp was given.
7235 +if test "${enable_nntp+set}" = set; then
7236 + enableval="$enable_nntp"
7237 + if test x$enableval = xyes ; then
7238 + cat >>confdefs.h <<\_ACEOF
7242 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
7250 for ac_func in strftime
7251 diff -udprP mutt-1.5.19.orig/doc/Muttrc mutt-1.5.19/doc/Muttrc
7252 --- mutt-1.5.19.orig/doc/Muttrc 2009-01-06 02:36:17.000000000 +0200
7253 +++ mutt-1.5.19/doc/Muttrc 2009-01-06 22:27:38.000000000 +0200
7254 @@ -278,6 +278,28 @@ attachments -I message/external-body
7255 # of the value as shown above if included.
7258 +# set ask_follow_up=no
7260 +# Name: ask_follow_up
7265 +# If set, Mutt will prompt you for follow-up groups before editing
7266 +# the body of an outgoing message.
7269 +# set ask_x_comment_to=no
7271 +# Name: ask_x_comment_to
7276 +# If set, Mutt will prompt you for x-comment-to field before editing
7277 +# the body of an outgoing message.
7280 # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
7282 # Name: attach_format
7283 @@ -458,6 +480,17 @@ attachments -I message/external-body
7284 # Afterwards the new mail status is tracked by file size changes.
7287 +# set catchup_newsgroup=ask-yes
7289 +# Name: catchup_newsgroup
7294 +# If this variable is set, Mutt will mark all articles in newsgroup
7295 +# as read when you quit the newsgroup (catchup newsgroup).
7301 @@ -988,6 +1021,19 @@ attachments -I message/external-body
7302 # of the same email for you.
7305 +# set followup_to_poster=ask-yes
7307 +# Name: followup_to_poster
7312 +# If this variable is set and the keyword "poster" is present in
7313 +# Followup-To header, follow-up to newsgroup function is not
7314 +# permitted. The message will be mailed to the submitter of the
7315 +# message via mail.
7321 @@ -1084,6 +1130,28 @@ attachments -I message/external-body
7322 # ``Franklin'' to ``Franklin, Steve''.
7325 +# set group_index_format="%4C %M%N %5s %-45.45f %d"
7327 +# Name: group_index_format
7329 +# Default: "%4C %M%N %5s %-45.45f %d"
7332 +# This variable allows you to customize the newsgroup browser display to
7333 +# your personal taste. This string is similar to ``index_format'', but
7334 +# has its own set of printf()-like sequences:
7336 +# %C current newsgroup number
7337 +# %d description of newsgroup (becomes from server)
7338 +# %f newsgroup name
7339 +# %M - if newsgroup not allowed for direct post (moderated for example)
7340 +# %N N if newsgroup is new, u if unsubscribed, blank otherwise
7341 +# %n number of new articles in newsgroup
7342 +# %s number of unread articles in newsgroup
7343 +# %>X right justify the rest of the string and pad with character "X"
7344 +# %|X pad to the end of the line with character "X"
7350 @@ -1572,6 +1640,7 @@ attachments -I message/external-body
7351 # %E number of messages in current thread
7352 # %f sender (address + real name), either From: or Return-Path:
7353 # %F author name, or recipient name if the message is from you
7354 +# %g newsgroup name (if compiled with nntp support)
7355 # %H spam attribute(s) of this message
7356 # %i message-id of the current message
7357 # %l number of lines in the message (does not work with maildir,
7358 @@ -1587,12 +1656,14 @@ attachments -I message/external-body
7359 # stashed the message: list name or recipient name
7360 # if not sent to a list
7361 # %P progress indicator for the builtin pager (how much of the file has been displayed)
7362 +# %R `x-comment-to:' field (if present and compiled with nntp support)
7363 # %s subject of the message
7364 # %S status of the message (``N''/``D''/``d''/``!''/``r''/*)
7365 # %t ``To:'' field (recipients)
7366 # %T the appropriate character from the $to_chars string
7367 # %u user (login) name of the author
7368 # %v first name of the author, or the recipient if the message is from you
7369 +# %W name of organization of author (`organization:' field)
7370 # %X number of attachments
7371 # (please see the ``attachments'' section for possible speed effects)
7372 # %y ``X-Label:'' field, if present
7373 @@ -1628,6 +1699,22 @@ attachments -I message/external-body
7374 # ``save-hook'', ``fcc-hook'' and ``fcc-save-hook'', too.
7384 +# If set, specifies the program and arguments used to deliver news posted
7385 +# by Mutt. Otherwise, mutt posts article using current connection to
7386 +# news server. The following printf-style sequence is understood:
7388 +# %s newsserver name
7390 +# Example: set inews="/usr/local/bin/inews -hS"
7393 # set ispell="ispell"
7396 @@ -1982,6 +2069,18 @@ attachments -I message/external-body
7397 # be attached to the newly composed message if this option is set.
7400 +# set mime_subject=yes
7402 +# Name: mime_subject
7407 +# If unset, 8-bit ``subject:'' line in article header will not be
7408 +# encoded according to RFC2047 to base64. This is useful when message
7409 +# is Usenet article, because MIME for news is nonstandard feature.
7412 # set mix_entry_format="%4n %c %-16s %a"
7414 # Name: mix_entry_format
7415 @@ -2091,6 +2190,118 @@ attachments -I message/external-body
7416 # See also $read_inc, $write_inc and $net_inc.
7419 +# set news_cache_dir="~/.mutt"
7421 +# Name: news_cache_dir
7423 +# Default: "~/.mutt"
7426 +# This variable pointing to directory where Mutt will save cached news
7427 +# articles headers in. If unset, headers will not be saved at all
7428 +# and will be reloaded each time when you enter to newsgroup.
7431 +# set news_server=""
7433 +# Name: news_server
7438 +# This variable specifies domain name or address of NNTP server. It
7439 +# defaults to the newsserver specified in the environment variable
7440 +# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
7441 +# specify username and an alternative port for each newsserver, ie:
7443 +# [news[s]://][username[:password]@]newsserver[:port]
7446 +# set newsrc="~/.newsrc"
7450 +# Default: "~/.newsrc"
7453 +# The file, containing info about subscribed newsgroups - names and
7454 +# indexes of read articles. The following printf-style sequence
7457 +# %s newsserver name
7460 +# set nntp_context=1000
7462 +# Name: nntp_context
7467 +# This variable defines number of articles which will be in index when
7468 +# newsgroup entered. If active newsgroup have more articles than this
7469 +# number, oldest articles will be ignored. Also controls how many
7470 +# articles headers will be saved in cache when you quit newsgroup.
7473 +# set nntp_load_description=yes
7475 +# Name: nntp_load_description
7480 +# This variable controls whether or not descriptions for each newsgroup
7481 +# must be loaded when newsgroup is added to list (first time list
7482 +# loading or new newsgroup adding).
7492 +# Your login name on the NNTP server. If unset and NNTP server requires
7493 +# authentification, Mutt will prompt you for your account name when you
7494 +# connect to newsserver.
7504 +# Your password for NNTP account.
7514 +# The time in seconds until any operations on newsgroup except post new
7515 +# article will cause recheck for new news. If set to 0, Mutt will
7516 +# recheck newsgroup on each operation in index (stepping, read article,
7520 +# set nntp_reconnect=ask-yes
7522 +# Name: nntp_reconnect
7527 +# Controls whether or not Mutt will try to reconnect to newsserver when
7531 # set pager="builtin"
7534 @@ -3361,6 +3572,19 @@ attachments -I message/external-body
7535 # string after the inclusion of a message which is being replied to.
7538 +# set post_moderated=ask-yes
7540 +# Name: post_moderated
7545 +# If set to yes, Mutt will post article to newsgroup that have
7546 +# not permissions to posting (e.g. moderated). Note: if newsserver
7547 +# does not support posting to that newsgroup or totally read-only, that
7548 +# posting will not have an effect.
7551 # set postpone=ask-yes
7554 @@ -3924,6 +4148,41 @@ attachments -I message/external-body
7555 # shell from /etc/passwd is used.
7558 +# set save_unsubscribed=no
7560 +# Name: save_unsubscribed
7565 +# When set, info about unsubscribed newsgroups will be saved into
7566 +# ``newsrc'' file and into cache.
7569 +# set show_new_news=yes
7571 +# Name: show_new_news
7576 +# If set, newsserver will be asked for new newsgroups on entering
7577 +# the browser. Otherwise, it will be done only once for a newsserver.
7578 +# Also controls whether or not number of new articles of subscribed
7579 +# newsgroups will be then checked.
7582 +# set show_only_unread=no
7584 +# Name: show_only_unread
7589 +# If set, only subscribed newsgroups that contain unread articles
7590 +# will be displayed in browser.
7593 # set sig_dashes=yes
7596 @@ -4678,3 +4937,14 @@ attachments -I message/external-body
7600 +# set x_comment_to=no
7602 +# Name: x_comment_to
7607 +# If set, Mutt will add ``X-Comment-To:'' field (that contains full
7608 +# name of original article author) to article that followuped to newsgroup.