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 @@ -67,11 +69,17 @@ enum
1361 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1364 -#define HDR_XOFFSET 10
1365 -#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1366 +#define HDR_XOFFSET 14
1367 +#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1368 #define W (COLS - HDR_XOFFSET)
1370 static char *Prompts[] =
1371 @@ -83,6 +91,16 @@ static char *Prompts[] =
1387 static struct mapping_t ComposeHelp[] = {
1388 @@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] =
1393 +static struct mapping_t ComposeNewsHelp[] = {
1394 + { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1395 + { N_("Abort"), OP_EXIT },
1396 + { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1397 + { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1398 + { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1399 + { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1400 + { N_("Help"), OP_HELP },
1405 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1407 mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt,
1408 @@ -115,16 +146,16 @@ static void redraw_crypt_lines (HEADER *
1409 if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
1412 - mvaddstr (HDR_CRYPT, 0, "Security: ");
1413 + mvaddstr (HDR_CRYPT, 0, " Security: ");
1414 else if (msg->security & APPLICATION_SMIME)
1415 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1416 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1417 else if (msg->security & APPLICATION_PGP)
1418 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1419 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1421 else if ((WithCrypto & APPLICATION_SMIME))
1422 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1423 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1424 else if ((WithCrypto & APPLICATION_PGP))
1425 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1426 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1430 @@ -252,9 +283,28 @@ static void draw_envelope_addr (int line
1431 static void draw_envelope (HEADER *msg, char *fcc)
1433 draw_envelope_addr (HDR_FROM, msg->env->from);
1435 + if (!option (OPTNEWSSEND))
1438 draw_envelope_addr (HDR_TO, msg->env->to);
1439 draw_envelope_addr (HDR_CC, msg->env->cc);
1440 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1445 + mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1446 + mutt_paddstr (W, NONULL (msg->env->newsgroups));
1447 + mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1448 + mutt_paddstr (W, NONULL (msg->env->followup_to));
1449 + if (option (OPTXCOMMENTTO))
1451 + mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1452 + mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1456 mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1457 mutt_paddstr (W, NONULL (msg->env->subject));
1458 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1459 @@ -507,6 +557,12 @@ int mutt_compose_menu (HEADER *msg, /*
1460 /* Sort, SortAux could be changed in mutt_index_menu() */
1461 int oldSort, oldSortAux;
1464 + int news = 0; /* is it a news article ? */
1466 + if (option (OPTNEWSSEND))
1470 mutt_attach_init (msg->content);
1471 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
1472 @@ -517,10 +573,18 @@ int mutt_compose_menu (HEADER *msg, /*
1473 menu->make_entry = snd_entry;
1474 menu->tag = mutt_tag_attach;
1478 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1481 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1486 + unset_option (OPTNEWS); /* for any case */
1488 switch (op = mutt_menuLoop (menu))
1491 @@ -533,17 +597,87 @@ int mutt_compose_menu (HEADER *msg, /*
1492 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1494 case OP_COMPOSE_EDIT_TO:
1499 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1500 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1502 case OP_COMPOSE_EDIT_BCC:
1507 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1508 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1510 case OP_COMPOSE_EDIT_CC:
1515 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1516 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1519 + case OP_COMPOSE_EDIT_NEWSGROUPS:
1522 + if (msg->env->newsgroups)
1523 + strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1526 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1528 + FREE (&msg->env->newsgroups);
1529 + mutt_remove_trailing_ws (buf);
1530 + msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1531 + move (HDR_TO, HDR_XOFFSET);
1533 + if (msg->env->newsgroups)
1534 + printw ("%-*.*s", W, W, msg->env->newsgroups);
1539 + case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1543 + if (msg->env->followup_to)
1544 + strfcpy (buf, msg->env->followup_to, sizeof (buf));
1545 + if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1547 + FREE (&msg->env->followup_to);
1548 + mutt_remove_trailing_ws (buf);
1549 + msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1550 + move (HDR_CC, HDR_XOFFSET);
1552 + if (msg->env->followup_to)
1553 + printw ("%-*.*s", W, W, msg->env->followup_to);
1558 + case OP_COMPOSE_EDIT_X_COMMENT_TO:
1559 + if (news && option (OPTXCOMMENTTO))
1562 + if (msg->env->x_comment_to)
1563 + strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1564 + if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1566 + FREE (&msg->env->x_comment_to);
1567 + msg->env->x_comment_to = safe_strdup (buf);
1568 + move (HDR_BCC, HDR_XOFFSET);
1570 + if (msg->env->x_comment_to)
1571 + printw ("%-*.*s", W, W, msg->env->x_comment_to);
1576 case OP_COMPOSE_EDIT_SUBJECT:
1577 if (msg->env->subject)
1578 strfcpy (buf, msg->env->subject, sizeof (buf));
1579 @@ -706,6 +840,9 @@ int mutt_compose_menu (HEADER *msg, /*
1582 case OP_COMPOSE_ATTACH_MESSAGE:
1584 + case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1589 @@ -713,7 +850,22 @@ int mutt_compose_menu (HEADER *msg, /*
1591 prompt = _("Open mailbox to attach message from");
1594 + unset_option (OPTNEWS);
1595 + if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1597 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1600 + prompt = _("Open newsgroup to attach message from");
1601 + set_option (OPTNEWS);
1607 + if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1610 strfcpy (fname, NONULL (Context->path), sizeof (fname));
1611 mutt_pretty_mailbox (fname, sizeof (fname));
1612 @@ -722,6 +874,11 @@ int mutt_compose_menu (HEADER *msg, /*
1613 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1617 + if (option (OPTNEWS))
1618 + nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1621 mutt_expand_path (fname, sizeof (fname));
1623 if (!mx_is_imap (fname))
1624 @@ -729,6 +886,9 @@ int mutt_compose_menu (HEADER *msg, /*
1626 if (!mx_is_pop (fname))
1629 + if (!mx_is_nntp (fname) && !option (OPTNEWS))
1631 /* check to make sure the file exists and is readable */
1632 if (access (fname, R_OK) == -1)
1634 diff -udprP mutt-1.5.19.orig/config.h.in mutt-1.5.19/config.h.in
1635 --- mutt-1.5.19.orig/config.h.in 2008-11-18 01:54:00.000000000 +0200
1636 +++ mutt-1.5.19/config.h.in 2009-01-06 22:27:38.000000000 +0200
1638 significant more memory when defined. */
1639 #undef EXACT_ADDRESS
1641 +/* Compiling with newsreading support with NNTP */
1644 /* program to use for shell commands */
1647 diff -udprP mutt-1.5.19.orig/configure.ac mutt-1.5.19/configure.ac
1648 --- mutt-1.5.19.orig/configure.ac 2008-11-17 22:15:26.000000000 +0200
1649 +++ mutt-1.5.19/configure.ac 2009-01-06 22:27:38.000000000 +0200
1650 @@ -598,6 +598,14 @@ if test x"$need_imap" = xyes -o x"$need_
1651 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1654 +AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1655 +[ if test x$enableval = xyes ; then
1656 + AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1657 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1662 dnl -- end socket dependencies --
1664 if test "$need_socket" = "yes"
1665 diff -udprP mutt-1.5.19.orig/curs_main.c mutt-1.5.19/curs_main.c
1666 --- mutt-1.5.19.orig/curs_main.c 2009-01-05 21:20:53.000000000 +0200
1667 +++ mutt-1.5.19/curs_main.c 2009-01-06 22:27:38.000000000 +0200
1671 #include "mutt_curses.h"
1673 #include "mutt_menu.h"
1674 #include "mailbox.h"
1675 #include "mapping.h"
1678 #include "mutt_crypt.h"
1687 @@ -413,12 +418,27 @@ static struct mapping_t IndexHelp[] = {
1692 +struct mapping_t IndexNewsHelp[] = {
1693 + { N_("Quit"), OP_QUIT },
1694 + { N_("Del"), OP_DELETE },
1695 + { N_("Undel"), OP_UNDELETE },
1696 + { N_("Save"), OP_SAVE },
1697 + { N_("Post"), OP_POST },
1698 + { N_("Followup"), OP_FOLLOWUP },
1699 + { N_("Catchup"), OP_CATCHUP },
1700 + { N_("Help"), OP_HELP },
1705 /* This function handles the message index window as well as commands returned
1706 * from the pager (MENU_PAGER).
1708 int mutt_index_menu (void)
1710 char buf[LONG_STRING], helpstr[LONG_STRING];
1713 int done = 0; /* controls when to exit the "event" loop */
1715 @@ -439,7 +459,11 @@ int mutt_index_menu (void)
1716 menu->make_entry = index_make_entry;
1717 menu->color = index_color;
1718 menu->current = ci_first_message ();
1719 - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1720 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1722 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1727 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
1728 @@ -690,6 +714,9 @@ int mutt_index_menu (void)
1729 imap_disallow_reopen (Context);
1733 + unset_option (OPTNEWS); /* for any case */
1738 @@ -740,6 +767,120 @@ int mutt_index_menu (void)
1739 menu_current_bottom (menu);
1743 + case OP_GET_MESSAGE:
1744 + case OP_GET_PARENT:
1746 + if (Context->magic == M_NNTP)
1750 + if (op == OP_GET_MESSAGE)
1753 + if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1759 + LIST *ref = CURHDR->env->references;
1762 + mutt_error _("Article has no parent reference!");
1765 + strfcpy (buf, ref->data, sizeof (buf));
1767 + if (!Context->id_hash)
1768 + Context->id_hash = mutt_make_id_hash (Context);
1769 + if ((h = hash_find (Context->id_hash, buf)))
1771 + if (h->virtual != -1)
1773 + menu->current = h->virtual;
1774 + menu->redraw = REDRAW_MOTION_RESYNCH;
1776 + else if (h->collapsed)
1778 + mutt_uncollapse_thread (Context, h);
1779 + mutt_set_virtual (Context);
1780 + menu->current = h->virtual;
1781 + menu->redraw = REDRAW_MOTION_RESYNCH;
1784 + mutt_error _("Message not visible in limited view.");
1788 + if (nntp_check_msgid (Context, buf) == 0)
1790 + h = Context->hdrs[Context->msgcount-1];
1791 + mutt_sort_headers (Context, 0);
1792 + menu->current = h->virtual;
1793 + menu->redraw = REDRAW_FULL;
1796 + mutt_error (_("Article %s not found on server"), buf);
1801 + case OP_GET_CHILDREN:
1802 + case OP_RECONSTRUCT_THREAD:
1804 + if (Context->magic == M_NNTP)
1807 + int old = CURHDR->index, i;
1809 + if (!CURHDR->env->message_id)
1811 + mutt_error _("No Message-Id. Unable to perform operation");
1815 + if (!Context->id_hash)
1816 + Context->id_hash = mutt_make_id_hash (Context);
1817 + strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1819 + if (op == OP_RECONSTRUCT_THREAD)
1821 + LIST *ref = CURHDR->env->references;
1824 + nntp_check_msgid (Context, ref->data);
1825 + /* the last msgid in References is the root message */
1827 + strfcpy (buf, ref->data, sizeof (buf));
1831 + mutt_message _("Check for children of message...");
1832 + if (nntp_check_children (Context, buf) == 0)
1834 + mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1835 + h = hash_find (Context->id_hash, buf);
1836 + /* if the root message was retrieved, move to it */
1838 + menu->current = h->virtual;
1839 + else /* try to restore old position */
1840 + for (i = 0; i < Context->msgcount; i++)
1841 + if (Context->hdrs[i]->index == old)
1843 + menu->current = Context->hdrs[i]->virtual;
1844 + /* As an added courtesy, recenter the menu
1845 + * with the current entry at the middle of the screen */
1846 + menu_check_recenter (menu);
1847 + menu_current_middle (menu);
1850 + menu->redraw = REDRAW_FULL;
1851 + mutt_clear_error ();
1859 @@ -837,11 +978,33 @@ int mutt_index_menu (void)
1863 + case OP_TOGGLE_READ:
1866 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1868 - if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1869 + if (op == OP_TOGGLE_READ)
1871 + char buf[LONG_STRING];
1873 + if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1875 + snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1876 + Context->pattern ? Context->pattern : ".*");
1877 + set_option (OPTHIDEREAD);
1881 + strfcpy (buf, Context->pattern + 8, sizeof(buf));
1882 + if (!*buf || strncmp (buf, ".*", 2) == 0)
1883 + snprintf (buf, sizeof(buf), "~A");
1884 + unset_option (OPTHIDEREAD);
1886 + FREE (&Context->pattern);
1887 + Context->pattern = safe_strdup (buf);
1889 + if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1890 + mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1892 if (menu->oldcurrent >= 0)
1894 @@ -1050,15 +1213,22 @@ int mutt_index_menu (void)
1896 case OP_MAIN_CHANGE_FOLDER:
1897 case OP_MAIN_NEXT_UNREAD_MAILBOX:
1900 - op = OP_MAIN_CHANGE_FOLDER_READONLY;
1902 - /* fallback to the readonly case */
1904 case OP_MAIN_CHANGE_FOLDER_READONLY:
1906 + case OP_MAIN_CHANGE_GROUP:
1907 + case OP_MAIN_CHANGE_GROUP_READONLY:
1908 + unset_option (OPTNEWS);
1910 + if (attach_msg || option (OPTREADONLY) ||
1912 + op == OP_MAIN_CHANGE_GROUP_READONLY ||
1914 + op == OP_MAIN_CHANGE_FOLDER_READONLY)
1915 + flags = M_READONLY;
1919 - if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1921 cp = _("Open mailbox in read-only mode");
1923 cp = _("Open mailbox");
1924 @@ -1077,6 +1247,21 @@ int mutt_index_menu (void)
1929 + if (op == OP_MAIN_CHANGE_GROUP ||
1930 + op == OP_MAIN_CHANGE_GROUP_READONLY)
1932 + set_option (OPTNEWS);
1933 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1936 + cp = _("Open newsgroup in read-only mode");
1938 + cp = _("Open newsgroup");
1943 mutt_buffy (buf, sizeof (buf));
1945 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1946 @@ -1096,6 +1281,14 @@ int mutt_index_menu (void)
1951 + if (option (OPTNEWS))
1953 + unset_option (OPTNEWS);
1954 + nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1958 mutt_expand_path (buf, sizeof (buf));
1959 if (mx_get_magic (buf) <= 0)
1961 @@ -1133,15 +1326,18 @@ int mutt_index_menu (void)
1962 CurrentMenu = MENU_MAIN;
1963 mutt_folder_hook (buf);
1965 - if ((Context = mx_open_mailbox (buf,
1966 - (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1967 - M_READONLY : 0, NULL)) != NULL)
1968 + if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1970 menu->current = ci_first_message ();
1976 + /* mutt_buffy_check() must be done with mail-reader mode! */
1977 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1978 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1980 mutt_clear_error ();
1981 mutt_buffy_check(1); /* force the buffy check after we have changed
1983 @@ -1512,6 +1708,15 @@ int mutt_index_menu (void)
1985 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1988 + if (Context->magic == M_NNTP)
1991 + mutt_error _("Can't change 'important' flag on NNTP server.");
1998 for (j = 0; j < Context->vcount; j++)
1999 @@ -1859,6 +2064,17 @@ int mutt_index_menu (void)
2005 + if (Context && Context->magic == M_NNTP)
2007 + if (mutt_newsgroup_catchup (CurrentNewsSrv,
2008 + ((NNTP_DATA *)Context->data)->group))
2009 + menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2014 case OP_DISPLAY_ADDRESS:
2017 @@ -1986,6 +2202,15 @@ int mutt_index_menu (void)
2018 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2023 + if (Context->magic == M_NNTP)
2026 + mutt_error _("Can't edit message on newsserver.");
2031 MAYBE_REDRAW (menu->redraw);
2033 @@ -2057,6 +2282,41 @@ int mutt_index_menu (void)
2035 menu->redraw = REDRAW_FULL;
2040 + case OP_FORWARD_TO_GROUP:
2048 + if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2049 + mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2050 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2052 + if (Context && Context->magic == M_NNTP &&
2053 + !((NNTP_DATA *)Context->data)->allowed &&
2054 + query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2056 + if (op == OP_POST)
2057 + ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2061 + if (op == OP_FOLLOWUP)
2062 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2063 + tag ? NULL : CURHDR);
2065 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2066 + tag ? NULL : CURHDR);
2068 + menu->redraw = REDRAW_FULL;
2075 @@ -2133,6 +2393,12 @@ int mutt_index_menu (void)
2077 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2080 + /* Close all open NNTP connections */
2082 + nntp_logout_all ();
2085 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2086 op == OP_UNDELETE_THREAD ? 0 : 1);
2088 diff -udprP mutt-1.5.19.orig/doc/manual.xml.head mutt-1.5.19/doc/manual.xml.head
2089 --- mutt-1.5.19.orig/doc/manual.xml.head 2009-01-05 21:20:53.000000000 +0200
2090 +++ mutt-1.5.19/doc/manual.xml.head 2009-01-06 22:27:38.000000000 +0200
2091 @@ -1388,6 +1388,22 @@ fo-table</literal> for details.
2096 +<title>Reading news via NNTP</title>
2099 +If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2100 +read news from newsserver via NNTP. You can open a newsgroup with
2101 +function ``change-newsgroup'' (default: ``i''). Default newsserver
2102 +can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2103 +variable. Like other news readers, info about subscribed newsgroups
2104 +is saved in file by <link linkend="newsrc">$newsrc</link>
2105 +variable. Article headers are cached and can be loaded from file when
2106 +newsgroup entered instead loading from newsserver.
2113 <sect1 id="forwarding-mail">
2114 diff -udprP mutt-1.5.19.orig/doc/mutt.man mutt-1.5.19/doc/mutt.man
2115 --- mutt-1.5.19.orig/doc/mutt.man 2009-01-05 22:18:18.000000000 +0200
2116 +++ mutt-1.5.19/doc/mutt.man 2009-01-06 22:27:38.000000000 +0200
2117 @@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2122 -[-e \fIcmd\fP] [-F \fIfile\fP] [-m \fItype\fP] [-f \fIfile\fP]
2124 +[-e \fIcmd\fP] [-F \fIfile\fP] [-g \fIserver\fP] [-m \fItype\fP] [-f \fIfile\fP]
2128 @@ -101,6 +101,10 @@ files.
2129 Specify which mailbox to load.
2130 .IP "-F \fImuttrc\fP"
2131 Specify an initialization file to read instead of ~/.muttrc
2132 +.IP "-g \fIserver\fP"
2133 +Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2135 +Start Mutt with a listing of subscribed newsgroups.
2138 .IP "-H \fIdraft\fP"
2139 diff -udprP mutt-1.5.19.orig/functions.h mutt-1.5.19/functions.h
2140 --- mutt-1.5.19.orig/functions.h 2009-01-05 21:20:53.000000000 +0200
2141 +++ mutt-1.5.19/functions.h 2009-01-06 22:27:38.000000000 +0200
2142 @@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in
2143 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2144 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2145 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2147 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2148 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2150 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2151 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2152 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
2153 @@ -101,7 +105,15 @@ struct binding_t OpMain[] = { /* map: in
2154 { "edit", OP_EDIT_MESSAGE, "e" },
2155 { "edit-type", OP_EDIT_TYPE, "\005" },
2156 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2157 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2159 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2160 + { "followup-message", OP_FOLLOWUP, "F" },
2161 + { "get-children", OP_GET_CHILDREN, NULL },
2162 + { "get-message", OP_GET_MESSAGE, "\007" },
2163 + { "get-parent", OP_GET_PARENT, "\033G" },
2164 + { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2166 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2167 { "group-reply", OP_GROUP_REPLY, "g" },
2169 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2170 @@ -127,6 +139,9 @@ struct binding_t OpMain[] = { /* map: in
2171 { "sort-mailbox", OP_SORT, "o" },
2172 { "sort-reverse", OP_SORT_REVERSE, "O" },
2173 { "print-message", OP_PRINT, "p" },
2175 + { "post-message", OP_POST, "P" },
2177 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2178 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2179 { "recall-message", OP_RECALL_MESSAGE, "R" },
2180 @@ -146,6 +161,10 @@ struct binding_t OpMain[] = { /* map: in
2181 { "show-version", OP_VERSION, "V" },
2182 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2183 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2184 + { "toggle-read", OP_TOGGLE_READ, "X" },
2186 + { "catchup", OP_CATCHUP, "y" },
2188 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2189 { "buffy-list", OP_BUFFY_LIST, "." },
2190 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
2191 @@ -157,7 +176,7 @@ struct binding_t OpMain[] = { /* map: in
2192 { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" },
2193 { "next-unread", OP_MAIN_NEXT_UNREAD, NULL },
2194 { "previous-unread", OP_MAIN_PREV_UNREAD, NULL },
2195 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2196 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2199 { "extract-keys", OP_EXTRACT_KEYS, "\013" },
2200 @@ -177,6 +196,10 @@ struct binding_t OpPager[] = { /* map: p
2201 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2202 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2203 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2205 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2206 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2208 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2209 { "copy-message", OP_COPY_MESSAGE, "C" },
2210 { "decode-copy", OP_DECODE_COPY, "\033C" },
2211 @@ -185,8 +208,12 @@ struct binding_t OpPager[] = { /* map: p
2212 { "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" },
2213 { "edit", OP_EDIT_MESSAGE, "e" },
2214 { "edit-type", OP_EDIT_TYPE, "\005" },
2216 + { "followup-message", OP_FOLLOWUP, "F" },
2217 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2219 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2220 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2221 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2222 { "group-reply", OP_GROUP_REPLY, "g" },
2224 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
2225 @@ -205,6 +232,9 @@ struct binding_t OpPager[] = { /* map: p
2226 { "next-thread", OP_MAIN_NEXT_THREAD, "\016" },
2227 { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" },
2228 { "print-message", OP_PRINT, "p" },
2230 + { "post-message", OP_POST, "P" },
2232 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2233 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2234 { "quit", OP_QUIT, "Q" },
2235 @@ -252,7 +282,7 @@ struct binding_t OpPager[] = { /* map: p
2236 { "half-down", OP_HALF_DOWN, NULL },
2237 { "previous-line", OP_PREV_LINE, NULL },
2238 { "bottom", OP_PAGER_BOTTOM, NULL },
2239 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2240 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2244 @@ -273,6 +303,10 @@ struct binding_t OpAttach[] = { /* map:
2245 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2246 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2247 { "edit-type", OP_EDIT_TYPE, "\005" },
2249 + { "followup-message", OP_FOLLOWUP, "F" },
2250 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2252 { "print-entry", OP_PRINT, "p" },
2253 { "save-entry", OP_SAVE, "s" },
2254 { "pipe-entry", OP_PIPE, "|" },
2255 @@ -298,6 +332,7 @@ struct binding_t OpAttach[] = { /* map:
2256 struct binding_t OpCompose[] = { /* map: compose */
2257 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2258 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2259 + { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2260 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2261 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2262 { "copy-file", OP_SAVE, "C" },
2263 @@ -317,6 +352,11 @@ struct binding_t OpCompose[] = { /* map:
2264 { "print-entry", OP_PRINT, "l" },
2265 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2266 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2268 + { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2269 + { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2270 + { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2272 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2273 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2274 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
2275 @@ -368,14 +408,25 @@ struct binding_t OpBrowser[] = { /* map:
2276 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2277 { "check-new", OP_CHECK_NEW, NULL },
2278 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2280 + { "reload-active", OP_LOAD_ACTIVE, "g" },
2281 + { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2282 + { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2283 + { "catchup", OP_CATCHUP, "y" },
2284 + { "uncatchup", OP_UNCATCHUP, "Y" },
2286 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2287 { "buffy-list", OP_BUFFY_LIST, "." },
2289 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2290 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2291 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2293 +#if defined USE_IMAP || defined USE_NNTP
2294 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2295 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2298 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2301 diff -udprP mutt-1.5.19.orig/globals.h mutt-1.5.19/globals.h
2302 --- mutt-1.5.19.orig/globals.h 2009-01-04 01:27:10.000000000 +0200
2303 +++ mutt-1.5.19/globals.h 2009-01-06 22:27:38.000000000 +0200
2304 @@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
2307 WHERE char *Muttrc INITVAL (NULL);
2309 +WHERE char *NewsCacheDir;
2310 +WHERE char *GroupFormat;
2312 +WHERE char *NewsServer;
2313 +WHERE char *NntpUser;
2314 +WHERE char *NntpPass;
2315 +WHERE char *NewsRc;
2319 WHERE char *PagerFmt;
2320 @@ -187,6 +196,11 @@ extern unsigned char QuadOptions[];
2322 WHERE unsigned short Counter INITVAL (0);
2325 +WHERE short NewsPollTimeout;
2326 +WHERE short NntpContext;
2329 WHERE short ConnectTimeout;
2330 WHERE short HistSize;
2331 WHERE short MenuContext;
2332 diff -udprP mutt-1.5.19.orig/hash.c mutt-1.5.19/hash.c
2333 --- mutt-1.5.19.orig/hash.c 2009-01-04 01:27:10.000000000 +0200
2334 +++ mutt-1.5.19/hash.c 2009-01-06 22:27:38.000000000 +0200
2335 @@ -45,10 +45,35 @@ HASH *hash_create (int nelem)
2338 table->nelem = nelem;
2339 + table->curnelem = 0;
2340 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2344 +HASH *hash_resize (HASH *ptr, int nelem)
2347 + struct hash_elem *elem, *tmp;
2350 + table = hash_create (nelem);
2352 + for (i = 0; i < ptr->nelem; i++)
2354 + for (elem = ptr->table[i]; elem; )
2357 + elem = elem->next;
2358 + hash_insert (table, tmp->key, tmp->data, 1);
2362 + FREE (&ptr->table);
2368 /* table hash table to update
2369 * key key to hash on
2370 * data data to associate with `key'
2371 @@ -68,6 +93,7 @@ int hash_insert (HASH * table, const cha
2373 ptr->next = table->table[h];
2374 table->table[h] = ptr;
2375 + table->curnelem++;
2379 @@ -90,6 +116,7 @@ int hash_insert (HASH * table, const cha
2381 table->table[h] = ptr;
2383 + table->curnelem++;
2387 @@ -120,6 +147,7 @@ void hash_delete_hash (HASH * table, int
2389 destroy (ptr->data);
2391 + table->curnelem--;
2395 diff -udprP mutt-1.5.19.orig/hash.h mutt-1.5.19/hash.h
2396 --- mutt-1.5.19.orig/hash.h 2009-01-04 01:27:10.000000000 +0200
2397 +++ mutt-1.5.19/hash.h 2009-01-06 22:27:38.000000000 +0200
2398 @@ -28,7 +28,7 @@ struct hash_elem
2403 + int nelem, curnelem;
2404 struct hash_elem **table;
2407 @@ -40,6 +40,7 @@ HASH;
2408 HASH *hash_create (int nelem);
2409 unsigned int hash_string (const unsigned char *s, unsigned int n);
2410 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2411 +HASH *hash_resize (HASH * table, int nelem);
2412 void *hash_find_hash (const HASH * table, int hash, const char *key);
2413 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2414 void (*destroy) (void *));
2415 diff -udprP mutt-1.5.19.orig/hdrline.c mutt-1.5.19/hdrline.c
2416 --- mutt-1.5.19.orig/hdrline.c 2009-01-05 21:20:53.000000000 +0200
2417 +++ mutt-1.5.19/hdrline.c 2009-01-06 22:27:38.000000000 +0200
2418 @@ -209,6 +209,7 @@ int mutt_user_is_recipient (HEADER *h)
2419 * %E = number of messages in current thread
2420 * %f = entire from line
2421 * %F = like %n, unless from self
2422 + * %g = newsgroup name (if compiled with nntp support)
2424 * %l = number of lines in the message
2425 * %L = like %F, except `lists' are displayed first
2426 @@ -217,12 +218,14 @@ int mutt_user_is_recipient (HEADER *h)
2428 * %O = like %L, except using address instead of name
2429 * %P = progress indicator for builtin pager
2430 + * %R = `x-comment-to:' field (if present and compiled with nntp support)
2432 * %S = short message status (e.g., N/O/D/!/r/-)
2433 * %t = `to:' field (recipients)
2435 * %u = user (login) name of author
2436 * %v = first name of author, unless from self
2437 + * %W = where user is (organization)
2438 * %X = number of MIME attachments
2439 * %y = `x-label:' field (if present)
2440 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2441 @@ -455,6 +458,12 @@ hdr_format_str (char *dest,
2447 + mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2452 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2454 @@ -546,6 +555,15 @@ hdr_format_str (char *dest,
2455 strfcpy(dest, NONULL(hfi->pager_progress), destlen);
2461 + mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2462 + else if (!hdr->env->x_comment_to)
2469 if (flags & M_FORMAT_TREE && !hdr->collapsed)
2470 @@ -635,6 +653,13 @@ hdr_format_str (char *dest,
2471 mutt_format_s (dest, destlen, prefix, buf2);
2476 + mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2477 + else if (!hdr->env->organization)
2484 diff -udprP mutt-1.5.19.orig/headers.c mutt-1.5.19/headers.c
2485 --- mutt-1.5.19.orig/headers.c 2008-08-15 21:30:12.000000000 +0300
2486 +++ mutt-1.5.19/headers.c 2009-01-06 22:27:38.000000000 +0200
2487 @@ -118,6 +118,9 @@ void mutt_edit_headers (const char *edit
2488 msg->env = n; n = NULL;
2490 if (!msg->env->in_reply_to)
2492 + if (!option (OPTNEWSSEND))
2494 mutt_free_list (&msg->env->references);
2496 mutt_expand_aliases_env (msg->env);
2497 diff -udprP mutt-1.5.19.orig/init.c mutt-1.5.19/init.c
2498 --- mutt-1.5.19.orig/init.c 2009-01-05 21:20:53.000000000 +0200
2499 +++ mutt-1.5.19/init.c 2009-01-06 22:27:38.000000000 +0200
2500 @@ -2965,6 +2965,28 @@ void mutt_init (int skip_sys_rc, LIST *c
2502 Fqdn = safe_strdup(NONULL(Hostname));
2509 + if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2512 + fgets (buffer, sizeof (buffer), f);
2516 + while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2518 + NewsServer = safe_strdup (p);
2522 + if ((p = getenv ("NNTPSERVER")))
2523 + NewsServer = safe_strdup (p);
2526 if ((p = getenv ("MAIL")))
2527 Spoolfile = safe_strdup (p);
2528 else if ((p = getenv ("MAILDIR")))
2529 diff -udprP mutt-1.5.19.orig/init.h mutt-1.5.19/init.h
2530 --- mutt-1.5.19.orig/init.h 2009-01-05 21:20:53.000000000 +0200
2531 +++ mutt-1.5.19/init.h 2009-01-06 22:27:38.000000000 +0200
2532 @@ -176,6 +176,20 @@ struct option_t MuttVars[] = {
2533 ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before
2534 ** editing the body of an outgoing message.
2537 + { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2540 + ** If set, Mutt will prompt you for follow-up groups before editing
2541 + ** the body of an outgoing message.
2543 + { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2546 + ** If set, Mutt will prompt you for x-comment-to field before editing
2547 + ** the body of an outgoing message.
2550 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2553 @@ -329,6 +343,14 @@ struct option_t MuttVars[] = {
2554 ** mailbox by performing a fast mailbox scan when it is defined.
2555 ** Afterwards the new mail status is tracked by file size changes.
2558 + { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2561 + ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2562 + ** as read when you quit the newsgroup (catchup newsgroup).
2565 { "charset", DT_STR, R_NONE, UL &Charset, UL 0 },
2568 @@ -690,6 +712,16 @@ struct option_t MuttVars[] = {
2569 ** sent to both the list and your address, resulting in two copies
2570 ** of the same email for you.
2573 + { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2576 + ** If this variable is \fIset\fP and the keyword "poster" is present in
2577 + ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2578 + ** permitted. The message will be mailed to the submitter of the
2579 + ** message via mail.
2582 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2585 @@ -760,6 +792,27 @@ struct option_t MuttVars[] = {
2586 ** a regular expression that will match the whole name so mutt will expand
2587 ** ``Franklin'' to ``Franklin, Steve''.
2590 + { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2593 + ** This variable allows you to customize the newsgroup browser display to
2594 + ** your personal taste. This string is similar to ``$index_format'', but
2595 + ** has its own set of printf()-like sequences:
2598 + ** %C current newsgroup number
2599 + ** %d description of newsgroup (becomes from server)
2600 + ** %f newsgroup name
2601 + ** %M - if newsgroup not allowed for direct post (moderated for example)
2602 + ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2603 + ** %n number of new articles in newsgroup
2604 + ** %s number of unread articles in newsgroup
2605 + ** %>X right justify the rest of the string and pad with character "X"
2606 + ** %|X pad to the end of the line with character "X"
2610 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2613 @@ -1090,6 +1143,7 @@ struct option_t MuttVars[] = {
2614 ** .dt %E .dd number of messages in current thread
2615 ** .dt %f .dd sender (address + real name), either From: or Return-Path:
2616 ** .dt %F .dd author name, or recipient name if the message is from you
2617 + ** .dt %g .dd newsgroup name (if compiled with nntp support)
2618 ** .dt %H .dd spam attribute(s) of this message
2619 ** .dt %i .dd message-id of the current message
2620 ** .dt %l .dd number of lines in the message (does not work with maildir,
2621 @@ -1105,12 +1159,14 @@ struct option_t MuttVars[] = {
2622 ** stashed the message: list name or recipient name
2623 ** if not sent to a list
2624 ** .dt %P .dd progress indicator for the builtin pager (how much of the file has been displayed)
2625 + ** .dt %R .dd `x-comment-to:' field (if present and compiled with nntp support)
2626 ** .dt %s .dd subject of the message
2627 ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as)
2628 ** .dt %t .dd ``To:'' field (recipients)
2629 ** .dt %T .dd the appropriate character from the $$to_chars string
2630 ** .dt %u .dd user (login) name of the author
2631 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2632 + ** .dt %W .dd name of organization of author (`organization:' field)
2633 ** .dt %X .dd number of attachments
2634 ** (please see the ``$attachments'' section for possible speed effects)
2635 ** .dt %y .dd ``X-Label:'' field, if present
2636 @@ -1145,6 +1201,21 @@ struct option_t MuttVars[] = {
2637 ** Note that these expandos are supported in
2638 ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too.
2641 + { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2644 + ** If set, specifies the program and arguments used to deliver news posted
2645 + ** by Mutt. Otherwise, mutt posts article using current connection to
2646 + ** news server. The following printf-style sequence is understood:
2649 + ** %s newsserver name
2652 + ** Example: set inews="/usr/local/bin/inews -hS"
2655 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2658 @@ -1368,6 +1439,15 @@ struct option_t MuttVars[] = {
2659 ** menu, attachments which cannot be decoded in a reasonable manner will
2660 ** be attached to the newly composed message if this option is \fIset\fP.
2663 + { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2666 + ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2667 + ** encoded according to RFC2047 to base64. This is useful when message
2668 + ** is Usenet article, because MIME for news is nonstandard feature.
2672 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2674 @@ -1448,6 +1528,77 @@ struct option_t MuttVars[] = {
2675 ** See also $$read_inc, $$write_inc and $$net_inc.
2679 + { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2682 + ** This variable pointing to directory where Mutt will save cached news
2683 + ** articles headers in. If \fIunset\fP, headers will not be saved at all
2684 + ** and will be reloaded each time when you enter to newsgroup.
2686 + { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2689 + ** This variable specifies domain name or address of NNTP server. It
2690 + ** defaults to the newsserver specified in the environment variable
2691 + ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2692 + ** specify username and an alternative port for each newsserver, ie:
2694 + ** [news[s]://][username[:password]@]newsserver[:port]
2696 + { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2699 + ** The file, containing info about subscribed newsgroups - names and
2700 + ** indexes of read articles. The following printf-style sequence
2704 + ** %s newsserver name
2707 + { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2710 + ** This variable defines number of articles which will be in index when
2711 + ** newsgroup entered. If active newsgroup have more articles than this
2712 + ** number, oldest articles will be ignored. Also controls how many
2713 + ** articles headers will be saved in cache when you quit newsgroup.
2715 + { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2718 + ** This variable controls whether or not descriptions for each newsgroup
2719 + ** must be loaded when newsgroup is added to list (first time list
2720 + ** loading or new newsgroup adding).
2722 + { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2725 + ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2726 + ** authentification, Mutt will prompt you for your account name when you
2727 + ** connect to newsserver.
2729 + { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2732 + ** Your password for NNTP account.
2734 + { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2737 + ** The time in seconds until any operations on newsgroup except post new
2738 + ** article will cause recheck for new news. If set to 0, Mutt will
2739 + ** recheck newsgroup on each operation in index (stepping, read article,
2742 + { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2745 + ** Controls whether or not Mutt will try to reconnect to newsserver when
2746 + ** connection lost.
2749 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2752 @@ -2331,6 +2482,16 @@ struct option_t MuttVars[] = {
2753 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2757 + { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2760 + ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2761 + ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2762 + ** does not support posting to that newsgroup or totally read-only, that
2763 + ** posting will not have an effect.
2766 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2769 @@ -2725,6 +2886,28 @@ struct option_t MuttVars[] = {
2770 ** Command to use when spawning a subshell. By default, the user's login
2771 ** shell from \fC/etc/passwd\fP is used.
2774 + { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2777 + ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2778 + ** ``newsrc'' file and into cache.
2780 + { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2783 + ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2784 + ** the browser. Otherwise, it will be done only once for a newsserver.
2785 + ** Also controls whether or not number of new articles of subscribed
2786 + ** newsgroups will be then checked.
2788 + { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2791 + ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2792 + ** will be displayed in browser.
2795 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2798 @@ -3275,6 +3458,14 @@ struct option_t MuttVars[] = {
2799 ** option does nothing: mutt will never write out the ``Bcc:'' header
2803 + { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2806 + ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2807 + ** name of original article author) to article that followuped to newsgroup.
2813 diff -udprP mutt-1.5.19.orig/keymap.c mutt-1.5.19/keymap.c
2814 --- mutt-1.5.19.orig/keymap.c 2008-11-26 20:48:48.000000000 +0200
2815 +++ mutt-1.5.19/keymap.c 2009-01-06 22:27:38.000000000 +0200
2816 @@ -654,7 +654,6 @@ void km_init (void)
2817 km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE);
2819 km_bindkey ("x", MENU_PAGER, OP_EXIT);
2820 - km_bindkey ("i", MENU_PAGER, OP_EXIT);
2821 km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE);
2822 km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE);
2823 km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE);
2824 diff -udprP mutt-1.5.19.orig/mailbox.h mutt-1.5.19/mailbox.h
2825 --- mutt-1.5.19.orig/mailbox.h 2008-03-19 22:07:06.000000000 +0200
2826 +++ mutt-1.5.19/mailbox.h 2009-01-06 22:27:38.000000000 +0200
2827 @@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2829 int mx_is_pop (const char *);
2832 +int mx_is_nntp (const char *);
2835 int mx_access (const char*, int);
2836 int mx_check_empty (const char *);
2837 diff -udprP mutt-1.5.19.orig/main.c mutt-1.5.19/main.c
2838 --- mutt-1.5.19.orig/main.c 2009-01-04 01:27:10.000000000 +0200
2839 +++ mutt-1.5.19/main.c 2009-01-06 22:27:38.000000000 +0200
2841 #include <stringprep.h>
2848 static const char *ReachingUs = N_("\
2849 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2850 To report a bug, please visit http://bugs.mutt.org/.\n");
2851 @@ -133,6 +137,8 @@ options:\n\
2852 " -e <command>\tspecify a command to be executed after initialization\n\
2853 -f <file>\tspecify which mailbox to read\n\
2854 -F <file>\tspecify an alternate muttrc file\n\
2855 + -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2856 + -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2857 -H <file>\tspecify a draft file to read header and body from\n\
2858 -i <file>\tspecify a file which Mutt should include in the body\n\
2859 -m <type>\tspecify a default mailbox type\n\
2860 @@ -255,6 +261,12 @@ static void show_version (void)
2873 @@ -522,6 +534,9 @@ static void start_curses (void)
2874 #define M_NOSYSRC (1<<2) /* -n */
2875 #define M_RO (1<<3) /* -R */
2876 #define M_SELECT (1<<4) /* -y */
2878 +#define M_NEWS (1<<5) /* -g and -G */
2881 int main (int argc, char **argv)
2883 @@ -594,7 +609,11 @@ int main (int argc, char **argv)
2884 argv[nargc++] = argv[optind];
2888 + if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2890 if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2895 @@ -687,6 +706,20 @@ int main (int argc, char **argv)
2900 + case 'g': /* Specify a newsserver */
2902 + char buf[LONG_STRING];
2904 + snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2905 + commands = mutt_add_list (commands, buf);
2908 + case 'G': /* List of newsgroups */
2909 + flags |= M_SELECT | M_NEWS;
2916 @@ -974,6 +1007,18 @@ int main (int argc, char **argv)
2918 else if (flags & M_SELECT)
2921 + if (flags & M_NEWS)
2923 + set_option (OPTNEWS);
2924 + if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2926 + mutt_endwin (Errorbuf);
2933 mutt_endwin _("No incoming mailboxes defined.");
2935 @@ -989,6 +1034,15 @@ int main (int argc, char **argv)
2938 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2941 + if (option (OPTNEWS))
2943 + unset_option (OPTNEWS);
2944 + nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2948 mutt_expand_path (folder, sizeof (folder));
2950 mutt_str_replace (&CurrentFolder, folder);
2951 diff -udprP mutt-1.5.19.orig/mutt.h mutt-1.5.19/mutt.h
2952 --- mutt-1.5.19.orig/mutt.h 2008-09-26 01:00:03.000000000 +0300
2953 +++ mutt-1.5.19/mutt.h 2009-01-06 22:27:38.000000000 +0200
2954 @@ -223,6 +223,9 @@ enum
2962 /* Options for Mailcap lookup */
2964 @@ -278,6 +281,12 @@ enum
2967 OPT_VERIFYSIG, /* verify PGP signatures */
2970 + OPT_NNTPRECONNECT,
2972 + OPT_FOLLOWUPTOPOSTER,
2973 +#endif /* USE_NNTP */
2975 /* THIS MUST BE THE LAST VALUE. */
2977 @@ -293,6 +302,7 @@ enum
2978 #define SENDMAILX (1<<6)
2979 #define SENDKEY (1<<7)
2980 #define SENDRESEND (1<<8)
2981 +#define SENDNEWS (1<<9)
2983 /* flags to _mutt_select_file() */
2984 #define M_SEL_BUFFY (1<<0)
2985 @@ -312,6 +322,8 @@ enum
2994 @@ -387,6 +399,9 @@ enum
2999 + OPTMIMESUBJECT, /* encode subject line with RFC2047 */
3004 @@ -468,6 +483,16 @@ enum
3008 + /* news options */
3012 + OPTSHOWONLYUNREAD,
3016 +#endif /* USE_NNTP */
3018 /* pseudo options */
3020 OPTAUXSORT, /* (pseudo) using auxillary sort function */
3021 @@ -488,6 +513,7 @@ enum
3022 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
3023 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3024 OPTATTACHMSG, /* (pseudo) used by attach-message */
3025 + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3026 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3027 * functions while we are executing an
3029 @@ -498,6 +524,12 @@ enum
3030 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3031 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
3034 + OPTNEWS, /* (pseudo) used to change reader mode */
3035 + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3036 + OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
3042 @@ -575,6 +607,13 @@ typedef struct envelope
3046 + char *organization;
3050 + char *followup_to;
3051 + char *x_comment_to;
3054 LIST *references; /* message references (in reverse order) */
3055 LIST *in_reply_to; /* in-reply-to header content */
3056 @@ -741,6 +780,9 @@ typedef struct header
3057 ENVELOPE *env; /* envelope information */
3058 BODY *content; /* list of MIME parts */
3064 char *tree; /* character string to print thread tree */
3065 struct thread *thread;
3066 @@ -756,7 +798,7 @@ typedef struct header
3067 int refno; /* message number on server */
3070 -#if defined USE_POP || defined USE_IMAP
3071 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3072 void *data; /* driver-specific data */
3075 diff -udprP mutt-1.5.19.orig/muttlib.c mutt-1.5.19/muttlib.c
3076 --- mutt-1.5.19.orig/muttlib.c 2009-01-05 21:20:53.000000000 +0200
3077 +++ mutt-1.5.19/muttlib.c 2009-01-06 22:27:38.000000000 +0200
3078 @@ -286,7 +286,7 @@ void mutt_free_header (HEADER **h)
3080 mutt_free_list (&(*h)->chain);
3082 -#if defined USE_POP || defined USE_IMAP
3083 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3086 FREE (h); /* __FREE_CHECKED__ */
3087 @@ -674,6 +674,13 @@ void mutt_free_envelope (ENVELOPE **p)
3088 FREE (&(*p)->supersedes);
3090 FREE (&(*p)->x_label);
3091 + FREE (&(*p)->organization);
3093 + FREE (&(*p)->newsgroups);
3094 + FREE (&(*p)->xref);
3095 + FREE (&(*p)->followup_to);
3096 + FREE (&(*p)->x_comment_to);
3099 mutt_buffer_free (&(*p)->spam);
3101 @@ -1455,6 +1462,14 @@ int mutt_save_confirm (const char *s, st
3106 + if (magic == M_NNTP)
3108 + mutt_error _("Can't save message to newsserver.");
3113 if (stat (s, st) != -1)
3116 diff -udprP mutt-1.5.19.orig/mx.c mutt-1.5.19/mx.c
3117 --- mutt-1.5.19.orig/mx.c 2009-01-05 21:20:53.000000000 +0200
3118 +++ mutt-1.5.19/mx.c 2009-01-06 22:27:38.000000000 +0200
3119 @@ -343,6 +343,22 @@ int mx_is_pop (const char *p)
3124 +int mx_is_nntp (const char *p)
3126 + url_scheme_t scheme;
3131 + scheme = url_check_scheme (p);
3132 + if (scheme == U_NNTP || scheme == U_NNTPS)
3139 int mx_get_magic (const char *path)
3142 @@ -360,6 +376,11 @@ int mx_get_magic (const char *path)
3144 #endif /* USE_POP */
3147 + if (mx_is_nntp (path))
3149 +#endif /* USE_NNTP */
3151 if (stat (path, &st) == -1)
3153 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
3154 @@ -699,6 +720,12 @@ CONTEXT *mx_open_mailbox (const char *pa
3156 #endif /* USE_POP */
3160 + rc = nntp_open_mailbox (ctx);
3162 +#endif /* USE_NNTP */
3167 @@ -791,6 +818,12 @@ static int sync_mailbox (CONTEXT *ctx, i
3168 rc = pop_sync_mailbox (ctx, index_hint);
3170 #endif /* USE_POP */
3174 + rc = nntp_sync_mailbox (ctx);
3176 +#endif /* USE_NNTP */
3180 @@ -817,6 +850,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
3185 + if (ctx->magic == M_NNTP)
3189 + ret = nntp_close_mailbox (ctx);
3190 + mx_fastclose_mailbox (ctx);
3194 if (ctx->readonly || ctx->dontwrite)
3196 /* mailbox is readonly or we don't want to write */
3197 @@ -1354,6 +1397,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
3199 return (pop_check_mailbox (ctx, index_hint));
3200 #endif /* USE_POP */
3204 + return (nntp_check_mailbox (ctx));
3205 +#endif /* USE_NNTP */
3209 @@ -1414,6 +1462,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
3211 #endif /* USE_POP */
3216 + if (nntp_fetch_message (msg, ctx, msgno) != 0)
3220 +#endif /* USE_NNTP */
3223 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3225 @@ -1495,6 +1552,9 @@ int mx_close_message (MESSAGE **msg)
3227 || (*msg)->magic == M_POP
3230 + || (*msg)->magic == M_NNTP
3234 r = safe_fclose (&(*msg)->fp);
3235 diff -udprP mutt-1.5.19.orig/mx.h mutt-1.5.19/mx.h
3236 --- mutt-1.5.19.orig/mx.h 2008-03-19 22:07:06.000000000 +0200
3237 +++ mutt-1.5.19/mx.h 2009-01-06 22:27:38.000000000 +0200
3238 @@ -40,6 +40,9 @@ enum
3247 WHERE short DefaultMagic INITVAL (M_MBOX);
3248 diff -udprP mutt-1.5.19.orig/newsrc.c mutt-1.5.19/newsrc.c
3249 --- mutt-1.5.19.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3250 +++ mutt-1.5.19/newsrc.c 2009-01-06 22:27:38.000000000 +0200
3253 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3254 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
3255 + * Copyright (C) 2000-2009 Vsevolod Volkov <vvv@mutt.org.ua>
3257 + * This program is free software; you can redistribute it and/or modify
3258 + * it under the terms of the GNU General Public License as published by
3259 + * the Free Software Foundation; either version 2 of the License, or
3260 + * (at your option) any later version.
3262 + * This program is distributed in the hope that it will be useful,
3263 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3264 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3265 + * GNU General Public License for more details.
3267 + * You should have received a copy of the GNU General Public License
3268 + * along with this program; if not, write to the Free Software
3269 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3273 +# include "config.h"
3277 +#include "mutt_curses.h"
3281 +#include "mailbox.h"
3283 +#include "rfc822.h"
3284 +#include "rfc1524.h"
3285 +#include "rfc2047.h"
3287 +#include <unistd.h>
3288 +#include <string.h>
3290 +#include <stdlib.h>
3291 +#include <sys/stat.h>
3293 +void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3300 + l = safe_calloc (1, sizeof (LIST));
3302 + s->tail->next = l;
3306 + l->data = (void *) d;
3309 +static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3312 + char group[LONG_STRING];
3314 + char *p = line, *b, *h;
3324 + while (*p && (*p != ':' && *p != '!')) p++;
3327 + len = p + 1 - line;
3328 + if (len > sizeof (group))
3329 + len = sizeof (group);
3330 + strfcpy (group, line, len);
3331 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3333 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3334 + data->group = (char *) data + sizeof (NNTP_DATA);
3335 + strcpy (data->group, group);
3336 + data->nserv = news;
3337 + data->deleted = 1;
3338 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3339 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3340 + hash_insert (news->newsgroups, data->group, data, 0);
3341 + nntp_add_to_list (news, data);
3344 + FREE ((void **) &data->entries);
3347 + data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3351 + data->subscribed = 1;
3353 + data->subscribed = 0;
3360 + while (*p && *p != ',' && *p != '\n') p++;
3366 + if ((h = strchr(b, '-')))
3370 + data->entries[x].first = atoi(b);
3371 + data->entries[x].last = atoi(h);
3375 + data->entries[x].first = atoi(b);
3376 + data->entries[x].last = data->entries[x].first;
3379 + if (data->entries[x].last != 0)
3382 + if (x && !data->lastMessage)
3383 + data->lastMessage = data->entries[x-1].last;
3385 + mutt_newsgroup_stat (data);
3386 + dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3391 +static int slurp_newsrc (NNTP_SERVER *news)
3397 + news->stat = stat (news->newsrc, &sb);
3398 + news->size = sb.st_size;
3399 + news->mtime = sb.st_mtime;
3401 + if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3403 + /* hmm, should we use dotlock? */
3404 + if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3410 + buf = safe_malloc (sb.st_size + 1);
3411 + while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3412 + nntp_parse_newsrc_line (news, buf);
3415 + mx_unlock_file (news->newsrc, fileno (fp), 0);
3420 +void nntp_cache_expand (char *dst, const char *src)
3422 + snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3423 + mutt_expand_path (dst, _POSIX_PATH_MAX);
3426 +/* Loads $news_cache_dir/.index into memory, loads newsserver data
3427 + * and newsgroup cache names */
3428 +static int nntp_parse_cacheindex (NNTP_SERVER *news)
3431 + char buf[HUGE_STRING], *cp;
3432 + char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3437 + /* check is server name defined or not */
3438 + if (!news || !news->conn || !news->conn->account.host)
3440 + unset_option (OPTNEWSCACHE);
3441 + if (!NewsCacheDir || !*NewsCacheDir)
3444 + strfcpy (dir, NewsCacheDir, sizeof (dir));
3445 + mutt_expand_path (dir, sizeof(dir));
3447 + if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3449 + snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3450 + if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3453 + mutt_error _("Cache directory not created!");
3456 + mutt_clear_error();
3459 + set_option (OPTNEWSCACHE);
3461 + FREE (&news->cache);
3462 + snprintf (buf, sizeof(buf), "%s/.index", dir);
3463 + if (!(index = safe_fopen (buf, "a+")))
3466 + while (fgets (buf, sizeof(buf), index))
3468 + buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3469 + if (!mutt_strncmp (buf, "#: ", 3) &&
3470 + !mutt_strcasecmp (buf+3, news->conn->account.host))
3473 + while (fgets (buf, sizeof(buf), index))
3476 + while (*cp && *cp != ' ') cp++;
3477 + if (!*cp) continue;
3479 + if (!mutt_strcmp (buf, "#:"))
3481 + sscanf (cp + 1, "%s %d %d", file, &l, &m);
3482 + if (!mutt_strcmp (buf, "ALL"))
3484 + news->cache = safe_strdup (file);
3485 + news->newgroups_time = m;
3487 + else if (news->newsgroups)
3489 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3491 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3492 + data->group = (char *) data + sizeof (NNTP_DATA);
3493 + strcpy(data->group, buf);
3494 + data->nserv = news;
3495 + data->deleted = 1;
3496 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3497 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3498 + hash_insert (news->newsgroups, data->group, data, 0);
3499 + nntp_add_to_list (news, data);
3501 + data->cache = safe_strdup (file);
3503 + if (!data->firstMessage || data->lastMessage < m)
3505 + if (!data->firstMessage)
3506 + data->firstMessage = l;
3507 + if (data->lastMessage < m)
3508 + data->lastMessage = m;
3509 + data->lastCached = m;
3510 + if (t || !data->unread)
3511 + mutt_newsgroup_stat (data);
3519 +nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
3520 + const char *fmt, const char *ifstring, const char *elsestring,
3521 + unsigned long data, format_flag flags)
3523 + char fn[SHORT_STRING], tmp[SHORT_STRING];
3528 + strncpy (fn, NewsServer, sizeof(fn) - 1);
3529 + mutt_strlower (fn);
3530 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3531 + snprintf (dest, destlen, tmp, fn);
3537 +/* nntp_parse_url: given an NNPT URL, return host, port,
3538 + * username, password and newsgroup will recognise. */
3539 +int nntp_parse_url (const char *server, ACCOUNT *acct,
3540 + char *group, size_t group_len)
3548 + acct->port = NNTP_PORT;
3549 + acct->type = M_ACCT_TYPE_NNTP;
3551 + c = safe_strdup (server);
3552 + url_parse_ciss (&url, c);
3554 + if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3556 + if (url.scheme == U_NNTPS)
3558 + acct->flags |= M_ACCT_SSL;
3559 + acct->port = NNTP_SSL_PORT;
3564 + strfcpy (group, url.path, group_len);
3566 + ret = mutt_account_fromurl (acct, &url);
3573 +void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3577 + url.path = safe_strdup (line);
3578 + mutt_account_tourl (acct, &url);
3579 + url_ciss_tostring (&url, line, len, 0);
3584 + * Automatically loads a newsrc into memory, if necessary.
3585 + * Checks the size/mtime of a newsrc file, if it doesn't match, load
3586 + * again. Hmm, if a system has broken mtimes, this might mean the file
3587 + * is reloaded every time, which we'd have to fix.
3589 + * a newsrc file is a line per newsgroup, with the newsgroup, then a
3590 + * ':' denoting subscribed or '!' denoting unsubscribed, then a
3591 + * comma separated list of article numbers and ranges.
3593 +NNTP_SERVER *mutt_select_newsserver (char *server)
3595 + char file[_POSIX_PATH_MAX];
3599 + NNTP_SERVER *serv;
3602 + if (!server || !*server)
3604 + mutt_error _("No newsserver defined!");
3608 + buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3609 + if (url_check_scheme (server) == U_UNKNOWN)
3611 + strcpy (buf, "news://");
3612 + p = strchr (buf, '\0');
3614 + strcpy (p, server);
3616 + if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3619 + mutt_error (_("%s is an invalid newsserver specification!"), server);
3624 + conn = mutt_conn_find (NULL, &acct);
3628 + mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), nntp_format_str, 0, 0);
3629 + mutt_expand_path (file, sizeof (file));
3631 + serv = (NNTP_SERVER *)conn->data;
3636 + /* externally modified? */
3637 + if (serv->stat != stat (file, &sb) || (!serv->stat &&
3638 + (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3640 + for (list = serv->list; list; list = list->next)
3642 + NNTP_DATA *data = (NNTP_DATA *) list->data;
3646 + data->subscribed = 0;
3651 + slurp_newsrc (serv);
3652 + nntp_clear_cacheindex (serv);
3655 + if (serv->status == NNTP_BYE)
3656 + serv->status = NNTP_NONE;
3657 + nntp_check_newgroups (serv, 0);
3661 + /* New newsserver */
3662 + serv = safe_calloc (1, sizeof (NNTP_SERVER));
3663 + serv->conn = conn;
3664 + serv->newsrc = safe_strdup (file);
3665 + serv->newsgroups = hash_create (1009);
3666 + slurp_newsrc (serv); /* load .newsrc */
3667 + nntp_parse_cacheindex (serv); /* load .index */
3668 + if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3669 + nntp_check_newgroups (serv, 1);
3670 + else if (nntp_get_active (serv) < 0)
3672 + hash_destroy (&serv->newsgroups, nntp_delete_data);
3673 + for (list = serv->list; list; list = list->next)
3674 + list->data = NULL;
3675 + mutt_free_list (&serv->list);
3676 + FREE (&serv->newsrc);
3677 + FREE (&serv->cache);
3681 + nntp_clear_cacheindex (serv);
3682 + conn->data = (void *)serv;
3688 + * full status flags are not supported by nntp, but we can fake some
3689 + * of them. This is how:
3690 + * Read = a read message number is in the .newsrc
3691 + * New = a message is new since we last read this newsgroup
3692 + * Old = anything else
3693 + * So, Read is marked as such in the newsrc, old is anything that is
3694 + * "skipped" in the newsrc, and new is anything not in the newsrc nor
3695 + * in the cache. By skipped, I mean before the last unread message
3697 +void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3699 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3703 + data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3709 + dprint (3, (debugfile, "newsgroup %s not found\n", group));
3714 + for (x = 0; x < data->num; x++)
3716 + if ((article >= data->entries[x].first) &&
3717 + (article <= data->entries[x].last))
3719 + /* we cannot use mutt_set_flag() because mx_update_context()
3720 + didn't called yet */
3725 + /* If article was not cached yet, it is new! :) */
3726 + if (!data->cache || article > data->lastCached)
3728 + /* Old articles are articles which aren't read but an article after them
3729 + * has been cached */
3730 + if (option (OPTMARKOLD))
3734 +void mutt_newsgroup_stat (NNTP_DATA *data)
3737 + unsigned int first, last;
3740 + if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3743 + data->unread = data->lastMessage - data->firstMessage + 1;
3744 + for (i = 0; i < data->num; i++)
3746 + first = data->entries[i].first;
3747 + if (first < data->firstMessage)
3748 + first = data->firstMessage;
3749 + last = data->entries[i].last;
3750 + if (last > data->lastMessage)
3751 + last = data->lastMessage;
3752 + if (first <= last)
3753 + data->unread -= last - first + 1;
3757 +static int puti (char *line, int num)
3761 + for (p = s; num; )
3763 + *p++ = '0' + num % 10;
3767 + *line++ = *--p, num++;
3772 +static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3774 + char *line = *pline;
3775 + size_t len = *buflen - (*pline - *buf);
3778 + if (len < LONG_STRING * 10)
3783 + safe_realloc (buf, *buflen);
3784 + line = *buf + (*pline - line);
3786 + strcpy (line, data->group);
3787 + len -= strlen (line) + 1;
3788 + line += strlen (line);
3789 + *line++ = data->subscribed ? ':' : '!';
3793 + for (x = 0; x < data->num; x++)
3795 + if (len < LONG_STRING)
3801 + safe_realloc (buf, *buflen);
3802 + line = *buf + (*pline - line);
3811 + if (data->entries[x].first == data->entries[x].last)
3812 + snprintf (line, len, "%d%n", data->entries[x].first, &i);
3814 + snprintf (line, len, "%d-%d%n",
3815 + data->entries[x].first, data->entries[x].last, &i);
3819 + i = puti (line, data->entries[x].first);
3820 + line +=i; len -= i;
3821 + if (data->entries[x].first != data->entries[x].last)
3825 + i = puti (line, data->entries[x].last);
3826 + line +=i; len -= i;
3835 +void newsrc_gen_entries (CONTEXT *ctx)
3837 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3839 + unsigned int last = 0, first = 1;
3840 + int save_sort = SORT_ORDER;
3842 + if (Sort != SORT_ORDER)
3845 + Sort = SORT_ORDER;
3846 + mutt_sort_headers (ctx, 0);
3851 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3856 + * Set up to fake initial sequence from 1 to the article before the
3857 + * first article in our list
3862 + for (x = 0; x < ctx->msgcount; x++)
3864 + if (series) /* search for first unread */
3867 + * We don't actually check sequential order, since we mark
3868 + * "missing" entries as read/deleted
3870 + last = ctx->hdrs[x]->article_num;
3871 + if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3872 + !ctx->hdrs[x]->read)
3874 + if (data->num >= data->max)
3876 + data->max = data->max * 2;
3877 + safe_realloc (&data->entries,
3878 + data->max * sizeof (NEWSRC_ENTRY));
3880 + data->entries[data->num].first = first;
3881 + data->entries[data->num].last = last - 1;
3886 + else /* search for first read */
3888 + if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3893 + last = ctx->hdrs[x]->article_num;
3896 + if (series && first <= data->lastLoaded)
3898 + if (data->num >= data->max)
3900 + data->max = data->max * 2;
3901 + safe_realloc (&data->entries,
3902 + data->max * sizeof (NEWSRC_ENTRY));
3904 + data->entries[data->num].first = first;
3905 + data->entries[data->num].last = data->lastLoaded;
3909 + if (save_sort != Sort)
3912 + mutt_sort_headers (ctx, 0);
3916 +static int mutt_update_list_file (char *filename, char *section,
3917 + char *key, char *line)
3921 + char buf[HUGE_STRING];
3922 + char tmpfile[_POSIX_PATH_MAX];
3924 + int ext = 0, done = 0, r = 0;
3926 + /* if file not exist, create it */
3927 + if ((ifp = safe_fopen (filename, "a")))
3929 + dprint (1, (debugfile, "Opening %s\n", filename));
3930 + if (!(ifp = safe_fopen (filename, "r")))
3932 + mutt_error (_("Unable to open %s for reading"), filename);
3935 + if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3938 + mutt_error (_("Unable to lock %s"), filename);
3941 + snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3942 + dprint (1, (debugfile, "Opening %s\n", tmpfile));
3943 + if (!(ofp = fopen (tmpfile, "w")))
3946 + mutt_error (_("Unable to open %s for writing"), tmpfile);
3952 + while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3954 + r = fputs (buf, ofp);
3956 + while (*c && *c != '\n') c++;
3957 + c[0] = 0; /* strip EOL */
3958 + if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3961 + if (r != EOF && !done)
3963 + snprintf (buf, sizeof(buf), "#: %s\n", section);
3964 + r = fputs (buf, ofp);
3969 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3974 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3976 + if (*c != '\\') ext = 0;
3978 + else if ((section && !strncmp (buf, "#: ", 3)))
3980 + if (!done && line)
3982 + fputs (line, ofp);
3983 + fputc ('\n', ofp);
3985 + r = fputs (buf, ofp);
3989 + else if (key && !strncmp (buf, key, strlen(key)) &&
3990 + (!*key || buf[strlen(key)] == ' '))
3994 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3996 + if (*c == '\\') ext = 1;
3997 + if (!done && line)
3999 + r = fputs (line, ofp);
4001 + r = fputc ('\n', ofp);
4007 + r = fputs (buf, ofp);
4011 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
4012 + r = fputs (buf, ofp);
4014 + /* If there wasn't a line to replace, put it on the end of the file */
4015 + if (r != EOF && !done && line)
4017 + fputs (line, ofp);
4018 + r = fputc ('\n', ofp);
4020 + mx_unlock_file (filename, fileno (ifp), 0);
4026 + mutt_error (_("Can't write %s"), tmpfile);
4029 + if (rename (tmpfile, filename) < 0)
4032 + mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
4038 +int mutt_newsrc_update (NNTP_SERVER *news)
4048 + llen = len = 10 * LONG_STRING;
4049 + line = buf = safe_calloc (1, len);
4050 + /* we will generate full newsrc here */
4051 + for (tmp = news->list; tmp; tmp = tmp->next)
4053 + data = (NNTP_DATA *) tmp->data;
4054 + if (!data || !data->rc)
4056 + nntp_create_newsrc_line (data, &buf, &line, &llen);
4058 + dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4059 + line += strlen (line);
4061 + /* newrc being fully rewritten */
4062 + if (news->newsrc &&
4063 + (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4067 + stat (news->newsrc, &st);
4068 + news->size = st.st_size;
4069 + news->mtime = st.st_mtime;
4075 +static FILE *mutt_mkname (char *s)
4077 + char buf[_POSIX_PATH_MAX], *pc;
4081 + nntp_cache_expand (buf, s);
4082 + if ((fp = safe_fopen (buf, "w")))
4085 + nntp_cache_expand (buf, "cache-XXXXXX");
4086 + pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4087 + if ((fd = mkstemp (buf)) == -1)
4089 + strcpy (s, pc); /* generated name */
4090 + return fdopen (fd, "w");
4093 +/* Updates info into .index file: ALL or about selected newsgroup */
4094 +static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4096 + char buf[LONG_STRING], *key = "ALL";
4097 + char file[_POSIX_PATH_MAX];
4099 + if (!serv || !serv->conn || !serv->conn->account.host)
4102 + if (data && data->group)
4104 + key = data->group;
4105 + snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4106 + data->firstMessage, data->lastLoaded);
4110 + strfcpy (file, serv->cache, sizeof (file));
4111 + snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4113 + nntp_cache_expand (file, ".index");
4114 + return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4117 +/* Remove cache files of unsubscribed newsgroups */
4118 +void nntp_clear_cacheindex (NNTP_SERVER *news)
4123 + if (option (OPTSAVEUNSUB) || !news)
4126 + for (tmp = news->list; tmp; tmp = tmp->next)
4128 + data = (NNTP_DATA *) tmp->data;
4129 + if (!data || data->subscribed || !data->cache)
4131 + nntp_delete_cache (data);
4132 + dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4137 +int nntp_save_cache_index (NNTP_SERVER *news)
4139 + char buf[HUGE_STRING];
4140 + char file[_POSIX_PATH_MAX];
4145 + if (!news || !news->newsgroups)
4147 + if (!option (OPTNEWSCACHE))
4152 + nntp_cache_expand (file, news->cache);
4154 + f = safe_fopen (file, "w");
4158 + strfcpy (buf, news->conn->account.host, sizeof(buf));
4159 + f = mutt_mkname (buf);
4160 + news->cache = safe_strdup (buf);
4161 + nntp_cache_expand (file, buf);
4166 + for (l = news->list; l; l = l->next)
4168 + if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4171 + snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4172 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4175 + snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4176 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4177 + if (fputs (buf, f) == EOF)
4187 + if (nntp_update_cacheindex (news, NULL))
4195 +int nntp_save_cache_group (CONTEXT *ctx)
4197 + char buf[HUGE_STRING], addr[STRING];
4198 + char file[_POSIX_PATH_MAX];
4202 + int i = 0, save = SORT_ORDER;
4205 + if (!option (OPTNEWSCACHE))
4207 + if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4210 + if (((NNTP_DATA *)ctx->data)->cache)
4212 + nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4214 + f = safe_fopen (file, "w");
4218 + snprintf (buf, sizeof(buf), "%s-%s",
4219 + ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4220 + ((NNTP_DATA *)ctx->data)->group);
4221 + f = mutt_mkname (buf);
4222 + ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4223 + nntp_cache_expand (file, buf);
4228 + if (Sort != SORT_ORDER)
4231 + Sort = SORT_ORDER;
4232 + mutt_sort_headers (ctx, 0);
4235 + /* Save only $nntp_context messages... */
4236 + ((NNTP_DATA *)ctx->data)->lastCached = 0;
4237 + if (NntpContext && ctx->msgcount > NntpContext)
4238 + i = ctx->msgcount - NntpContext;
4239 + for (; i < ctx->msgcount; i++)
4241 + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4245 + rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4246 + tm = gmtime (&h->date_sent);
4247 + snprintf (buf, sizeof(buf),
4248 + "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4249 + h->article_num, h->env->subject, addr, tm->tm_mday,
4250 + Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4251 + tm->tm_sec, h->env->message_id);
4253 + if (h->env->references)
4254 + mutt_write_references (h->env->references, f, 10);
4255 + snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length,
4256 + (int) h->lines, NONULL(h->env->xref));
4257 + if (fputs (buf, f) == EOF)
4264 + prev = ctx->hdrs[i]->article_num;
4270 + mutt_sort_headers (ctx, 0);
4274 + if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4275 + (NNTP_DATA *)ctx->data))
4280 + ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4284 +void nntp_delete_cache (NNTP_DATA *data)
4286 + char buf[_POSIX_PATH_MAX];
4288 + if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4291 + nntp_cache_expand (buf, data->cache);
4293 + FREE (&data->cache);
4294 + data->lastCached = 0;
4295 + nntp_cache_expand (buf, ".index");
4296 + mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4299 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4303 + if (!news || !news->newsgroups || !group || !*group)
4305 + if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4307 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4308 + data->group = (char *) data + sizeof (NNTP_DATA);
4309 + strcpy (data->group, group);
4310 + data->nserv = news;
4311 + data->deleted = 1;
4312 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4313 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
4314 + hash_insert (news->newsgroups, data->group, data, 0);
4315 + nntp_add_to_list (news, data);
4317 + if (!data->subscribed)
4319 + data->subscribed = 1;
4325 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4329 + if (!news || !news->newsgroups || !group || !*group ||
4330 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4332 + if (data->subscribed)
4334 + data->subscribed = 0;
4335 + if (!option (OPTSAVEUNSUB))
4341 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4345 + if (!news || !news->newsgroups || !group || !*group ||
4346 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4350 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4354 + data->entries[0].first = 1;
4356 + data->entries[0].last = data->lastMessage;
4357 + if (Context && Context->data == data)
4361 + for (x = 0; x < Context->msgcount; x++)
4362 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4367 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4371 + if (!news || !news->newsgroups || !group || !*group ||
4372 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4376 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4380 + data->entries[0].first = 1;
4381 + data->entries[0].last = data->firstMessage - 1;
4382 + if (Context && Context->data == data)
4386 + data->unread = Context->msgcount;
4387 + for (x = 0; x < Context->msgcount; x++)
4388 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4391 + data->unread = data->lastMessage - data->entries[0].last;
4395 +/* this routine gives the first newsgroup with new messages */
4396 +void nntp_buffy (char *s)
4400 + for (list = CurrentNewsSrv->list; list; list = list->next)
4402 + NNTP_DATA *data = (NNTP_DATA *) list->data;
4404 + if (data && data->subscribed && data->unread)
4406 + if (Context && Context->magic == M_NNTP &&
4407 + !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4409 + unsigned int i, unread = 0;
4411 + for (i = 0; i < Context->msgcount; i++)
4412 + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4417 + strcpy (s, data->group);
4422 diff -udprP mutt-1.5.19.orig/nntp.c mutt-1.5.19/nntp.c
4423 --- mutt-1.5.19.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4424 +++ mutt-1.5.19/nntp.c 2009-01-06 22:27:38.000000000 +0200
4427 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4428 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4429 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
4431 + * This program is free software; you can redistribute it and/or modify
4432 + * it under the terms of the GNU General Public License as published by
4433 + * the Free Software Foundation; either version 2 of the License, or
4434 + * (at your option) any later version.
4436 + * This program is distributed in the hope that it will be useful,
4437 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4438 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4439 + * GNU General Public License for more details.
4441 + * You should have received a copy of the GNU General Public License
4442 + * along with this program; if not, write to the Free Software
4443 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4447 +# include "config.h"
4451 +#include "mutt_curses.h"
4455 +#include "rfc1524.h"
4456 +#include "rfc2047.h"
4457 +#include "mailbox.h"
4468 +#include <unistd.h>
4469 +#include <string.h>
4471 +#include <stdlib.h>
4473 +static unsigned int _checked = 0;
4476 +static void nntp_error (const char *where, const char *msg)
4478 + dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4482 +static int nntp_auth (NNTP_SERVER *serv)
4484 + CONNECTION *conn = serv->conn;
4486 + unsigned char flags = conn->account.flags;
4488 + if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4489 + mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4491 + conn->account.flags = flags;
4495 + mutt_message _("Logging in...");
4497 + snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4498 + mutt_socket_write (conn, buf);
4499 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4501 + conn->account.flags = flags;
4506 + /* don't print the password unless we're at the ungodly debugging level */
4507 + if (debuglevel < M_SOCK_LOG_FULL)
4508 + dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4510 + snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4511 + mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4512 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4514 + conn->account.flags = flags;
4518 + if (mutt_strncmp ("281", buf, 3))
4520 + conn->account.flags = flags;
4521 + mutt_error _("Login failed.");
4529 +static int nntp_connect_error (NNTP_SERVER *serv)
4531 + serv->status = NNTP_NONE;
4532 + mutt_socket_close (serv->conn);
4533 + mutt_error _("Server closed connection!");
4538 +static int nntp_connect_and_auth (NNTP_SERVER *serv)
4540 + CONNECTION *conn = serv->conn;
4544 + serv->status = NNTP_NONE;
4546 + if (mutt_socket_open (conn) < 0)
4549 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4550 + return nntp_connect_error (serv);
4552 + if (!mutt_strncmp ("200", buf, 3))
4553 + mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4554 + else if (!mutt_strncmp ("201", buf, 3))
4555 + mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4558 + mutt_socket_close (conn);
4559 + mutt_remove_trailing_ws (buf);
4560 + mutt_error ("%s", buf);
4567 + /* Tell INN to switch to mode reader if it isn't so. Ignore all
4568 + returned codes and messages. */
4569 + mutt_socket_write (conn, "MODE READER\r\n");
4570 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4571 + return nntp_connect_error (serv);
4573 + mutt_socket_write (conn, "STAT\r\n");
4574 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4575 + return nntp_connect_error (serv);
4577 + if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
4579 + serv->status = NNTP_OK;
4583 + rc = nntp_auth (serv);
4585 + return nntp_connect_error (serv);
4588 + mutt_socket_close (conn);
4589 + serv->status = NNTP_BYE;
4594 + mutt_socket_close (conn);
4595 + mutt_error _("Login failed.");
4599 + serv->status = NNTP_OK;
4603 +static int nntp_attempt_features (NNTP_SERVER *serv)
4605 + char buf[LONG_STRING];
4606 + CONNECTION *conn = serv->conn;
4608 + mutt_socket_write (conn, "XOVER\r\n");
4609 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4610 + return nntp_connect_error (serv);
4611 + if (mutt_strncmp ("500", buf, 3))
4612 + serv->hasXOVER = 1;
4614 + mutt_socket_write (conn, "XPAT\r\n");
4615 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4616 + return nntp_connect_error (serv);
4617 + if (mutt_strncmp ("500", buf, 3))
4618 + serv->hasXPAT = 1;
4620 + mutt_socket_write (conn, "LISTGROUP\r\n");
4621 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4622 + return nntp_connect_error (serv);
4623 + if (mutt_strncmp ("500", buf, 3))
4624 + serv->hasLISTGROUP = 1;
4626 + mutt_socket_write (conn, "XGTITLE +\r\n");
4627 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4628 + return nntp_connect_error (serv);
4629 + if (mutt_strncmp ("500", buf, 3))
4630 + serv->hasXGTITLE = 1;
4632 + if (!mutt_strncmp ("282", buf, 3))
4636 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4637 + return nntp_connect_error (serv);
4638 + } while (!(buf[0] == '.' && buf[1] == '\0'));
4644 +static int nntp_open_connection (NNTP_SERVER *serv)
4646 + if (serv->status == NNTP_OK)
4648 + if (serv->status == NNTP_BYE)
4650 + if (nntp_connect_and_auth (serv) < 0)
4652 + if (nntp_attempt_features (serv) < 0)
4657 +static int nntp_reconnect (NNTP_SERVER *serv)
4659 + char buf[SHORT_STRING];
4661 + mutt_socket_close (serv->conn);
4665 + if (nntp_connect_and_auth (serv) == 0)
4668 + snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
4669 + serv->conn->account.host);
4670 + if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
4672 + serv->status = NNTP_BYE;
4678 +/* Send data from line[LONG_STRING] and receive answer to same line */
4679 +static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
4681 + char buf[LONG_STRING];
4684 + if (data->nserv->status == NNTP_BYE)
4691 + mutt_socket_write (data->nserv->conn, line);
4693 + else if (data->group)
4695 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4696 + mutt_socket_write (data->nserv->conn, buf);
4700 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4702 + if (nntp_reconnect (data->nserv) < 0)
4707 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4708 + mutt_socket_write (data->nserv->conn, buf);
4709 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4715 + else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
4719 + strfcpy (line, buf, linelen);
4724 + * This function calls funct(*line, *data) for each received line,
4725 + * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
4728 + * 1 - correct but not performed (may be, have to be continued),
4729 + * -1 - conection lost,
4730 + * -2 - invalid command or execution error,
4731 + * -3 - error in funct(*line, *data).
4733 +static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
4734 + int (*funct) (char *, void *), void *data, int tagged)
4736 + char buf[LONG_STRING];
4740 + size_t lenbuf = 0;
4745 + strfcpy (buf, query, sizeof (buf));
4746 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
4748 + if (buf[0] == '5')
4750 + if (buf[0] != '2')
4755 + inbuf = safe_malloc (sizeof (buf));
4759 + chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
4765 + if (!lenbuf && buf[0] == '.')
4767 + if (buf[1] == '\0')
4772 + if (buf[1] == '.')
4776 + strfcpy (inbuf + lenbuf, p, sizeof (buf));
4778 + if (chunk >= sizeof (buf))
4780 + lenbuf += strlen (p);
4785 + if (msg && ReadInc && (line % ReadInc == 0)) {
4787 + mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
4789 + mutt_message ("%s %d", msg, line);
4792 + if (ret == 0 && funct (inbuf, data) < 0)
4797 + safe_realloc (&inbuf, lenbuf + sizeof (buf));
4800 + funct (NULL, data);
4806 +static int nntp_read_tempfile (char *line, void *file)
4808 + FILE *f = (FILE *)file;
4815 + if (fputc ('\n', f) == EOF)
4821 +static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
4823 + register char *p, *b;
4824 + register char *colon = NULL;
4829 + /* skip to next word */
4831 + while (*b && ((*b == ' ') || (*b == '\t'))) b++;
4834 + /* skip to end of word */
4835 + while (*p && (*p != ' ') && (*p != '\t'))
4850 + nntp_get_status (ctx, h, b, atoi(colon));
4851 + if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
4852 + h->article_num = atoi(colon);
4860 + * 1 if article not found
4861 + * -1 if read or write error on tempfile or socket
4863 +static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
4865 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
4867 + char buf[LONG_STRING];
4868 + char tempfile[_POSIX_PATH_MAX];
4870 + HEADER *h = ctx->hdrs[ctx->msgcount];
4872 + mutt_mktemp (tempfile);
4873 + if (!(f = safe_fopen (tempfile, "w+")))
4877 + snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
4879 + snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
4881 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
4886 + dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
4889 + unlink (tempfile);
4890 + return (ret == -1 ? -1 : 1);
4893 + h->article_num = article_num;
4894 + h->env = mutt_read_rfc822_header (f, h, 0, 0);
4896 + unlink (tempfile);
4898 + if (h->env->xref != NULL)
4899 + nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
4900 + else if (h->article_num == 0 && msgid)
4902 + snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
4903 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
4904 + h->article_num = atoi (buf + 4);
4910 +static int parse_description (char *line, void *n)
4912 +#define news ((NNTP_SERVER *) n)
4913 + register char *d = line;
4918 + while (*d && *d != '\t' && *d != ' ') d++;
4921 + while (*d && (*d == '\t' || *d == ' ')) d++;
4922 + dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
4923 + if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
4924 + mutt_strcmp (d, data->desc))
4926 + FREE (&data->desc);
4927 + data->desc = safe_strdup (d);
4933 +static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
4937 + if (!option (OPTLOADDESC) || !data || !data->nserv)
4940 + /* Get newsgroup description, if we can */
4941 + if (data->nserv->hasXGTITLE)
4942 + snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
4944 + snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
4945 + if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
4948 + nntp_error ("nntp_get_desc()", buf);
4954 + * XOVER returns a tab separated list of:
4955 + * id|subject|from|date|Msgid|references|bytes|lines|xref
4957 + * This has to duplicate some of the functionality of
4958 + * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
4959 + * a limited number of headers which are "parsed" by placement in the list)
4961 +static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
4963 + NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
4967 + hdr->env = mutt_new_envelope();
4968 + hdr->env->newsgroups = safe_strdup (nntp_data->group);
4969 + hdr->content = mutt_new_body();
4970 + hdr->content->type = TYPETEXT;
4971 + hdr->content->subtype = safe_strdup ("plain");
4972 + hdr->content->encoding = ENC7BIT;
4973 + hdr->content->disposition = DISPINLINE;
4974 + hdr->content->length = -1;
4977 + for (x = 0; !done && x < 9; x++)
4979 + /* if from file, need to skip newline character */
4980 + while (*p && *p != '\n' && *p != '\t') p++;
4988 + hdr->article_num = atoi (b);
4989 + nntp_get_status (ctx, hdr, NULL, hdr->article_num);
4992 + hdr->env->subject = safe_strdup (b);
4993 + /* Now we need to do the things which would normally be done in
4994 + * mutt_read_rfc822_header() */
4995 + if (hdr->env->subject)
4997 + regmatch_t pmatch[1];
4999 + rfc2047_decode (&hdr->env->subject);
5001 + if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
5002 + hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
5004 + hdr->env->real_subj = hdr->env->subject;
5008 + rfc822_free_address (&hdr->env->from);
5009 + hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
5010 + rfc2047_decode_adrlist (hdr->env->from);
5013 + hdr->date_sent = mutt_parse_date (b, hdr);
5014 + hdr->received = hdr->date_sent;
5017 + FREE (&hdr->env->message_id);
5018 + hdr->env->message_id = safe_strdup (b);
5021 + mutt_free_list (&hdr->env->references);
5022 + hdr->env->references = mutt_parse_references (b, 0);
5025 + hdr->content->length = atoi (b);
5028 + hdr->lines = atoi (b);
5032 + FREE (&hdr->env->xref);
5033 + b = b + 6; /* skips the "Xref: " */
5034 + hdr->env->xref = safe_strdup (b);
5035 + nntp_parse_xref (ctx, nntp_data->group, b, hdr);
5047 + unsigned int base;
5048 + unsigned int first;
5049 + unsigned int last;
5050 + unsigned short *messages;
5054 +#define fc ((FETCH_CONTEXT *) c)
5055 +static int nntp_fetch_numbers (char *line, void *c)
5061 + num = atoi (line);
5062 + if (num < fc->base || num > fc->last)
5064 + fc->messages[num - fc->base] = 1;
5068 +static int add_xover_line (char *line, void *c)
5070 + unsigned int num, total;
5071 + CONTEXT *ctx = fc->ctx;
5072 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5077 + if (ctx->msgcount >= ctx->hdrmax)
5078 + mx_alloc_memory (ctx);
5079 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5080 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5082 + nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5083 + num = ctx->hdrs[ctx->msgcount]->article_num;
5085 + if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5088 + if (num > data->lastLoaded)
5089 + data->lastLoaded = num;
5090 + num = num - fc->first + 1;
5091 + total = fc->last - fc->first + 1;
5092 + if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5093 + mutt_message ("%s %d/%d", fc->msg, num, total);
5096 + mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5102 +static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5103 + unsigned int last)
5105 + char buf[HUGE_STRING];
5106 + char *msg = _("Fetching message headers...");
5107 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5111 + unsigned int current;
5115 + /* if empty group or nothing to do */
5116 + if (!last || first > last)
5119 + /* fetch list of articles */
5123 + fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5124 + if (nntp_data->nserv->hasLISTGROUP)
5126 + mutt_message _("Fetching list of articles...");
5127 + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5128 + if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5130 + mutt_error (_("LISTGROUP command failed: %s"), buf);
5132 + nntp_error ("nntp_fetch_headers()", buf);
5134 + FREE (&fc.messages);
5140 + for (num = 0; num < last - first + 1; num++)
5141 + fc.messages[num] = 1;
5144 + /* CACHE: must be loaded xover cache here */
5145 + num = nntp_data->lastCached - first + 1;
5146 + if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5148 + nntp_cache_expand (buf, nntp_data->cache);
5149 + mutt_message _("Fetching headers from cache...");
5150 + if ((f = safe_fopen (buf, "r")))
5154 + /* counting number of lines */
5155 + while (fgets (buf, sizeof (buf), f) != NULL)
5158 + while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5160 + oldmsgcount = ctx->msgcount;
5162 + fc.last = first + num - 1;
5164 + while (fgets (buf, sizeof (buf), f) != NULL)
5165 + add_xover_line (buf, &fc);
5167 + nntp_data->lastLoaded = fc.last;
5168 + first = fc.last + 1;
5169 + if (ctx->msgcount > oldmsgcount)
5170 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5173 + nntp_delete_cache (nntp_data);
5175 + num = last - first + 1;
5178 + FREE (&fc.messages);
5183 + * Without XOVER, we have to fetch each article header and parse
5184 + * it. With XOVER, we ask for all of them
5186 + mutt_message (msg);
5187 + if (nntp_data->nserv->hasXOVER)
5189 + oldmsgcount = ctx->msgcount;
5193 + snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5194 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5195 + if (ctx->msgcount > oldmsgcount)
5196 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5199 + mutt_error (_("XOVER command failed: %s"), buf);
5201 + nntp_error ("nntp_fetch_headers()", buf);
5203 + FREE (&fc.messages);
5209 + for (current = first; current <= last; current++)
5213 + ret = current - first + 1;
5214 + mutt_message ("%s %d/%d", msg, ret, num);
5216 + if (!fc.messages[current - fc.base])
5219 + if (ctx->msgcount >= ctx->hdrmax)
5220 + mx_alloc_memory (ctx);
5221 + h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5222 + h->index = ctx->msgcount;
5224 + ret = nntp_read_header (ctx, NULL, current);
5225 + if (ret == 0) /* Got article. Fetch next header */
5227 + nntp_get_status (ctx, h, NULL, h->article_num);
5229 + mx_update_context (ctx, 1);
5232 + mutt_free_header (&h); /* skip it */
5235 + FREE (&fc.messages);
5239 + if (current > nntp_data->lastLoaded)
5240 + nntp_data->lastLoaded = current;
5242 + FREE (&fc.messages);
5243 + nntp_data->lastLoaded = last;
5244 + mutt_clear_error ();
5249 + * currently, nntp "mailbox" is "newsgroup"
5251 +int nntp_open_mailbox (CONTEXT *ctx)
5253 + NNTP_DATA *nntp_data;
5254 + NNTP_SERVER *serv;
5255 + char buf[HUGE_STRING];
5256 + char server[LONG_STRING];
5258 + unsigned int first;
5261 + if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5263 + mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5269 + nntp_expand_path (server, sizeof (server), &acct);
5270 + if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5273 + CurrentNewsSrv = serv;
5275 + /* create NNTP-specific state struct if nof found in list */
5276 + if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5278 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5279 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5280 + strcpy (nntp_data->group, buf);
5281 + hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5282 + nntp_add_to_list (serv, nntp_data);
5284 + ctx->data = nntp_data;
5285 + ctx->mx_close = nntp_fastclose_mailbox;
5286 + nntp_data->nserv = serv;
5288 + mutt_message (_("Selecting %s..."), nntp_data->group);
5290 + if (!nntp_data->desc)
5292 + nntp_get_desc (nntp_data, nntp_data->group, NULL);
5293 + if (nntp_data->desc)
5294 + nntp_save_cache_index (serv);
5298 + if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5301 + nntp_error ("nntp_open_mailbox()", buf);
5306 + if (mutt_strncmp ("211", buf, 3))
5308 + LIST *l = serv->list;
5310 + /* GROUP command failed */
5311 + if (!mutt_strncmp ("411", buf, 3))
5313 + mutt_error (_("Newsgroup %s not found on server %s"),
5314 + nntp_data->group, serv->conn->account.host);
5316 + /* CACHE: delete cache and line from .index */
5317 + nntp_delete_cache (nntp_data);
5318 + hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5319 + while (l && l->data != (void *) nntp_data) l = l->next;
5329 + sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5330 + &nntp_data->lastMessage, buf);
5332 + nntp_data->deleted = 0;
5334 + time (&serv->check_time);
5337 + * Check for max adding context. If it is greater than $nntp_context,
5338 + * strip off extra articles
5340 + first = nntp_data->firstMessage;
5341 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5342 + first = nntp_data->lastMessage - NntpContext + 1;
5344 + nntp_data->lastLoaded = first - 1;
5345 + return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5348 +int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5350 + char buf[LONG_STRING];
5351 + char path[_POSIX_PATH_MAX];
5352 + NNTP_CACHE *cache;
5353 + char *m = _("Fetching message...");
5356 + /* see if we already have the message in our cache */
5357 + cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5359 + /* if everything is fine, assign msg->fp and return */
5360 + if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5361 + (msg->fp = fopen (cache->path, "r")))
5364 + /* clear the previous entry */
5365 + unlink (cache->path);
5366 + free (cache->path);
5370 + cache->index = ctx->hdrs[msgno]->index;
5371 + mutt_mktemp (path);
5372 + cache->path = safe_strdup (path);
5373 + if (!(msg->fp = safe_fopen (path, "w+")))
5375 + FREE (&cache->path);
5379 + if (ctx->hdrs[msgno]->article_num == 0)
5380 + snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5381 + ctx->hdrs[msgno]->env->message_id);
5383 + snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5384 + ctx->hdrs[msgno]->article_num);
5386 + ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5387 + msg->fp, ctx->tagged);
5390 + mutt_error (_("Article %d not found on server"),
5391 + ctx->hdrs[msgno]->article_num);
5392 + dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5399 + FREE (&cache->path);
5403 + mutt_free_envelope (&ctx->hdrs[msgno]->env);
5404 + ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5405 + /* fix content length */
5406 + fseek(msg->fp, 0, SEEK_END);
5407 + ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5408 + ctx->hdrs[msgno]->content->offset;
5410 + /* this is called in mutt before the open which fetches the message,
5411 + * which is probably wrong, but we just call it again here to handle
5412 + * the problem instead of fixing it.
5414 + mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5416 + /* These would normally be updated in mx_update_context(), but the
5417 + * full headers aren't parsed with XOVER, so the information wasn't
5420 +#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5421 + ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5422 +#endif /* HAVE_PGP || HAVE_SMIME */
5424 + mutt_clear_error();
5431 +int nntp_post (const char *msg) {
5432 + char buf[LONG_STRING];
5435 + NNTP_DATA *nntp_data;
5437 + if (Context && Context->magic == M_NNTP)
5438 + nntp_data = (NNTP_DATA *)Context->data;
5441 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5442 + !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5444 + mutt_error (_("Can't post article. No connection to news server."));
5447 + nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5450 + if (!(f = safe_fopen (msg, "r")))
5452 + mutt_error (_("Can't post article. Unable to open %s"), msg);
5456 + strfcpy (buf, "POST\r\n", sizeof (buf));
5457 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5459 + mutt_error (_("Can't post article. Connection to %s lost."),
5460 + nntp_data->nserv->conn->account.host);
5463 + if (buf[0] != '3')
5465 + mutt_error (_("Can't post article: %s"), buf);
5471 + while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5473 + len = strlen (buf);
5474 + if (buf[len - 1] == '\n')
5476 + buf[len - 1] = '\r';
5481 + if (buf[1] == '.')
5482 + mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5484 + mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5488 + if (buf[strlen (buf) - 1] != '\n')
5489 + mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5490 + mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5491 + if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5493 + mutt_error (_("Can't post article. Connection to %s lost."),
5494 + nntp_data->nserv->conn->account.host);
5497 + if (buf[0] != '2')
5499 + mutt_error (_("Can't post article: %s"), buf);
5506 +/* nntp_logout_all: close all open connections. */
5507 +void nntp_logout_all (void)
5509 + char buf[LONG_STRING];
5512 + conn = mutt_socket_head ();
5516 + CONNECTION *next = conn->next;
5518 + if (conn->account.type == M_ACCT_TYPE_NNTP)
5520 + mutt_message (_("Closing connection to %s..."), conn->account.host);
5521 + mutt_socket_write (conn, "QUIT\r\n");
5522 + mutt_socket_readln (buf, sizeof (buf), conn);
5523 + mutt_clear_error ();
5524 + mutt_socket_close (conn);
5525 + mutt_socket_free (conn);
5532 +static void nntp_free_acache (NNTP_DATA *data)
5536 + for (i = 0; i < NNTP_CACHE_LEN; i++)
5538 + if (data->acache[i].path)
5540 + unlink (data->acache[i].path);
5541 + FREE (&data->acache[i].path);
5546 +void nntp_delete_data (void *p)
5548 + NNTP_DATA *data = (NNTP_DATA *)p;
5552 + FREE (&data->entries);
5553 + FREE (&data->desc);
5554 + FREE (&data->cache);
5555 + nntp_free_acache (data);
5559 +int nntp_sync_mailbox (CONTEXT *ctx)
5561 + NNTP_DATA *data = ctx->data;
5563 + /* CACHE: update cache and .index files */
5564 + if ((option (OPTSAVEUNSUB) || data->subscribed))
5565 + nntp_save_cache_group (ctx);
5566 + nntp_free_acache (data);
5568 + data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
5572 +int nntp_fastclose_mailbox (CONTEXT *ctx)
5574 + NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
5578 + nntp_free_acache (data);
5579 + if (!data->nserv || !data->nserv->newsgroups || !data->group)
5581 + nntp_save_cache_index (data->nserv);
5582 + if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
5584 + nntp_delete_data (data);
5588 +/* commit changes and terminate connection */
5589 +int nntp_close_mailbox (CONTEXT *ctx)
5593 + mutt_message _("Quitting newsgroup...");
5596 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
5599 + if (data->nserv && data->nserv->conn && ctx->unread)
5601 + ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
5603 + mutt_newsgroup_catchup (data->nserv, data->group);
5608 + nntp_sync_mailbox (ctx);
5609 + if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
5611 + NNTP_SERVER *news;
5613 + news = ((NNTP_DATA *)ctx->data)->nserv;
5614 + newsrc_gen_entries (ctx);
5615 + ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
5616 + mutt_newsrc_update (news);
5618 + mutt_clear_error();
5622 +/* use the GROUP command to poll for new mail */
5623 +static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
5625 + char buf[LONG_STRING];
5628 + if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
5632 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5635 + nntp_error ("nntp_check_mailbox()", buf);
5639 + if (mutt_strncmp ("211", buf, 3))
5642 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5645 + nntp_error ("nntp_check_mailbox()", buf);
5650 + if (!mutt_strncmp ("211", buf, 3))
5655 + sscanf (buf + 4, "%d %d %d", &count, &first, &last);
5656 + nntp_data->firstMessage = first;
5657 + nntp_data->lastMessage = last;
5658 + if (ctx && last > nntp_data->lastLoaded)
5660 + nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
5661 + time (&nntp_data->nserv->check_time);
5664 + if (!last || (!nntp_data->rc && !nntp_data->lastCached))
5665 + nntp_data->unread = count;
5667 + mutt_newsgroup_stat (nntp_data);
5668 + /* active was renumbered? */
5669 + if (last < nntp_data->lastLoaded)
5671 + if (!nntp_data->max)
5673 + nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
5674 + nntp_data->max = 5;
5676 + nntp_data->lastCached = 0;
5677 + nntp_data->num = 1;
5678 + nntp_data->entries[0].first = 1;
5679 + nntp_data->entries[0].last = 0;
5683 + time (&nntp_data->nserv->check_time);
5687 +int nntp_check_mailbox (CONTEXT *ctx)
5689 + return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
5692 +static int add_group (char *buf, void *serv)
5694 +#define s ((NNTP_SERVER *) serv)
5695 + char group[LONG_STRING], mod, desc[HUGE_STRING];
5697 + NNTP_DATA *nntp_data;
5700 + _checked = n; /* _checked have N, where N = number of groups */
5701 + if (!buf) /* at EOF must be zerouth */
5708 + sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
5711 + if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
5714 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
5715 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5716 + strcpy (nntp_data->group, group);
5717 + nntp_data->nserv = s;
5718 + if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
5719 + s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2);
5720 + hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
5721 + nntp_add_to_list (s, nntp_data);
5723 + nntp_data->deleted = 0;
5724 + nntp_data->firstMessage = first;
5725 + nntp_data->lastMessage = last;
5727 + nntp_data->allowed = 1;
5729 + nntp_data->allowed = 0;
5730 + if (nntp_data->desc)
5731 + FREE (&nntp_data->desc);
5733 + nntp_data->desc = safe_strdup (desc);
5734 + if (nntp_data->rc || nntp_data->lastCached)
5735 + mutt_newsgroup_stat (nntp_data);
5736 + else if (nntp_data->lastMessage &&
5737 + nntp_data->firstMessage <= nntp_data->lastMessage)
5738 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
5740 + nntp_data->unread = 0;
5746 +int nntp_check_newgroups (NNTP_SERVER *serv, int force)
5748 + char buf[LONG_STRING];
5749 + char msg[SHORT_STRING];
5750 + NNTP_DATA nntp_data;
5755 + unsigned int count = 0;
5756 + unsigned int total = 0;
5758 + if (!serv || !serv->newgroups_time)
5761 + if (nntp_open_connection (serv) < 0)
5764 + /* check subscribed groups for new news */
5765 + if (option (OPTSHOWNEWNEWS))
5767 + mutt_message _("Checking for new messages...");
5768 + for (l = serv->list; l; l = l->next)
5770 + serv->check_time = 0; /* really check! */
5771 + if (l->data && ((NNTP_DATA *) l->data)->subscribed)
5772 + _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
5778 + mutt_message _("Checking for new newsgroups...");
5779 + now = serv->newgroups_time;
5780 + time (&serv->newgroups_time);
5781 + t = gmtime (&now);
5782 + snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
5783 + (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
5785 + nntp_data.nserv = serv;
5786 + if (Context && Context->magic == M_NNTP)
5787 + nntp_data.group = ((NNTP_DATA *)Context->data)->group;
5789 + nntp_data.group = NULL;
5791 + if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
5792 + add_group, serv, 0) != 0)
5795 + nntp_error ("nntp_check_newgroups()", buf);
5800 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5801 + mutt_message (msg);
5803 + emp.next = l->next;
5805 + emp.next = serv->list;
5810 + ((NNTP_DATA *) l->data)->new = 1;
5817 + nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
5819 + if (ReadInc && (count % ReadInc == 0))
5820 + mutt_message ("%s %d/%d", msg, count, total);
5823 + nntp_save_cache_index (serv);
5824 + mutt_clear_error ();
5828 +/* Load list of all newsgroups from cache ALL */
5829 +int nntp_get_cache_all (NNTP_SERVER *serv)
5831 + char buf[HUGE_STRING];
5834 + nntp_cache_expand (buf, serv->cache);
5835 + if ((f = safe_fopen (buf, "r")))
5839 + while (fgets (buf, sizeof(buf), f) != NULL)
5841 + if (ReadInc && (i % ReadInc == 0))
5842 + mutt_message (_("Loading list from cache... %d"), i);
5843 + add_group (buf, serv);
5846 + add_group (NULL, NULL);
5848 + mutt_clear_error ();
5853 + FREE (&serv->cache);
5858 +/* Load list of all newsgroups from active */
5859 +int nntp_get_active (NNTP_SERVER *serv)
5861 + char msg[SHORT_STRING];
5862 + NNTP_DATA nntp_data;
5865 + if (nntp_open_connection (serv) < 0)
5868 + snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
5869 + serv->conn->account.host);
5870 + mutt_message (msg);
5871 + time (&serv->newgroups_time);
5872 + nntp_data.nserv = serv;
5873 + nntp_data.group = NULL;
5875 + if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
5878 + nntp_error ("nntp_get_active()", "LIST\r\n");
5883 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5884 + mutt_message (msg);
5885 + nntp_get_desc (&nntp_data, "*", msg);
5887 + for (tmp = serv->list; tmp; tmp = tmp->next)
5889 + NNTP_DATA *data = (NNTP_DATA *)tmp->data;
5891 + if (data && data->deleted && !data->rc)
5893 + nntp_delete_cache (data);
5894 + hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
5898 + nntp_save_cache_index (serv);
5900 + mutt_clear_error ();
5905 + * returns -1 if error ocurred while retrieving header,
5906 + * number of articles which ones exist in context on success.
5908 +int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
5912 + /* if msgid is already in context, don't reload them */
5913 + if (hash_find (ctx->id_hash, msgid))
5915 + if (ctx->msgcount == ctx->hdrmax)
5916 + mx_alloc_memory (ctx);
5917 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5918 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5920 + mutt_message (_("Fetching %s from server..."), msgid);
5921 + ret = nntp_read_header (ctx, msgid, 0);
5922 + /* since nntp_read_header() may set read flag, we must reset it */
5923 + ctx->hdrs[ctx->msgcount]->read = 0;
5925 + mutt_free_header (&ctx->hdrs[ctx->msgcount]);
5929 + mx_update_context (ctx, 1);
5940 + unsigned int *child;
5943 +static int check_children (char *s, void *c)
5945 +#define cc ((CHILD_CONTEXT *) c)
5946 + unsigned int i, n;
5948 + if (!s || (n = atoi (s)) == 0)
5950 + for (i = 0; i < cc->ctx->msgcount; i++)
5951 + if (cc->ctx->hdrs[i]->article_num == n)
5953 + if (cc->num >= cc->max)
5954 + safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
5955 + cc->child[cc->num++] = n;
5961 +int nntp_check_children (CONTEXT *ctx, const char *msgid)
5963 + NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
5965 + int i, ret = 0, tmp = 0;
5968 + if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
5969 + !nntp_data->nserv->conn->account.host)
5971 + if (nntp_data->firstMessage > nntp_data->lastLoaded)
5973 + if (!nntp_data->nserv->hasXPAT)
5975 + mutt_error (_("Server %s does not support this operation!"),
5976 + nntp_data->nserv->conn->account.host);
5980 + snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
5981 + nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
5986 + cc.child = safe_malloc (sizeof (unsigned int) * 25);
5987 + if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
5992 + /* dont try to read the xover cache. check_children() already
5993 + * made sure that we dont have the article, so we need to visit
5994 + * the server. Reading the cache at this point is also bad
5995 + * because it would duplicate messages */
5996 + if (option (OPTNEWSCACHE))
5999 + unset_option (OPTNEWSCACHE);
6001 + for (i = 0; i < cc.num; i++)
6003 + if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
6005 + if (ctx->msgcount &&
6006 + ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
6007 + ctx->hdrs[ctx->msgcount - 1]->read = 0;
6010 + set_option (OPTNEWSCACHE);
6014 diff -udprP mutt-1.5.19.orig/nntp.h mutt-1.5.19/nntp.h
6015 --- mutt-1.5.19.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
6016 +++ mutt-1.5.19/nntp.h 2009-01-06 22:27:38.000000000 +0200
6019 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
6020 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
6021 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
6023 + * This program is free software; you can redistribute it and/or modify
6024 + * it under the terms of the GNU General Public License as published by
6025 + * the Free Software Foundation; either version 2 of the License, or
6026 + * (at your option) any later version.
6028 + * This program is distributed in the hope that it will be useful,
6029 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6030 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6031 + * GNU General Public License for more details.
6033 + * You should have received a copy of the GNU General Public License
6034 + * along with this program; if not, write to the Free Software
6035 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6041 +#include "mutt_socket.h"
6042 +#include "mailbox.h"
6046 +#define NNTP_PORT 119
6047 +#define NNTP_SSL_PORT 563
6049 +/* number of entries in the hash table */
6050 +#define NNTP_CACHE_LEN 10
6067 + unsigned int hasXPAT : 1;
6068 + unsigned int hasXGTITLE : 1;
6069 + unsigned int hasXOVER : 1;
6070 + unsigned int hasLISTGROUP : 1;
6071 + unsigned int status : 3;
6077 + time_t newgroups_time;
6078 + time_t check_time;
6080 + LIST *list; /* list of newsgroups */
6081 + LIST *tail; /* last entry of list */
6087 + unsigned int index;
6093 + NEWSRC_ENTRY *entries;
6094 + unsigned int num; /* number of used entries */
6095 + unsigned int max; /* number of allocated entries */
6096 + unsigned int unread;
6097 + unsigned int firstMessage;
6098 + unsigned int lastMessage;
6099 + unsigned int lastLoaded;
6100 + unsigned int lastCached;
6101 + unsigned int subscribed : 1;
6102 + unsigned int rc : 1;
6103 + unsigned int new : 1;
6104 + unsigned int allowed : 1;
6105 + unsigned int deleted : 1;
6109 + NNTP_SERVER *nserv;
6110 + NNTP_CACHE acache[NNTP_CACHE_LEN];
6113 +/* internal functions */
6114 +int nntp_get_active (NNTP_SERVER *);
6115 +int nntp_get_cache_all (NNTP_SERVER *);
6116 +int nntp_save_cache_index (NNTP_SERVER *);
6117 +int nntp_check_newgroups (NNTP_SERVER *, int);
6118 +int nntp_save_cache_group (CONTEXT *);
6119 +int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6120 +void newsrc_gen_entries (CONTEXT *);
6121 +void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6122 +void mutt_newsgroup_stat (NNTP_DATA *);
6123 +void nntp_delete_cache (NNTP_DATA *);
6124 +void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6125 +void nntp_cache_expand (char *, const char *);
6126 +void nntp_delete_data (void *);
6128 +/* exposed interface */
6129 +NNTP_SERVER *mutt_select_newsserver (char *);
6130 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6131 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6132 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6133 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6134 +void nntp_clear_cacheindex (NNTP_SERVER *);
6135 +int mutt_newsrc_update (NNTP_SERVER *);
6136 +int nntp_open_mailbox (CONTEXT *);
6137 +int nntp_sync_mailbox (CONTEXT *);
6138 +int nntp_check_mailbox (CONTEXT *);
6139 +int nntp_close_mailbox (CONTEXT *);
6140 +int nntp_fastclose_mailbox (CONTEXT *);
6141 +int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6142 +int nntp_post (const char *);
6143 +int nntp_check_msgid (CONTEXT *, const char *);
6144 +int nntp_check_children (CONTEXT *, const char *);
6145 +void nntp_buffy (char *);
6146 +void nntp_expand_path (char *, size_t, ACCOUNT *);
6147 +void nntp_logout_all ();
6148 +const char *nntp_format_str (char *, size_t, size_t, char, const char *, const char *,
6149 + const char *, const char *, unsigned long, format_flag);
6151 +NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6153 +#endif /* _NNTP_H_ */
6154 diff -udprP mutt-1.5.19.orig/pager.c mutt-1.5.19/pager.c
6155 --- mutt-1.5.19.orig/pager.c 2009-01-05 21:20:53.000000000 +0200
6156 +++ mutt-1.5.19/pager.c 2009-01-06 22:27:38.000000000 +0200
6157 @@ -1048,6 +1048,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
6167 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6168 int flags, ansi_attr *pa, int cnt,
6169 @@ -1489,6 +1494,16 @@ static struct mapping_t PagerHelpExtra[]
6174 +static struct mapping_t PagerNewsHelpExtra[] = {
6175 + { N_("Post"), OP_POST },
6176 + { N_("Followup"), OP_FOLLOWUP },
6177 + { N_("Del"), OP_DELETE },
6178 + { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6185 /* This pager is actually not so simple as it once was. It now operates in
6186 @@ -1530,6 +1545,10 @@ mutt_pager (const char *banner, const ch
6187 int old_PagerIndexLines; /* some people want to resize it
6188 * while inside the pager... */
6191 + char *followup_to;
6194 if (!(flags & M_SHOWCOLOR))
6195 flags |= M_SHOWFLAT;
6197 @@ -1569,7 +1588,11 @@ mutt_pager (const char *banner, const ch
6198 if (IsHeader (extra))
6200 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6201 - mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6202 + mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6204 + (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6207 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6210 @@ -2407,6 +2430,15 @@ search_next:
6212 CHECK_ACL(M_ACL_WRITE, "flag message");
6215 + if (Context->magic == M_NNTP)
6218 + mutt_error _("Can't change 'important' flag on NNTP server.");
6223 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6224 redraw = REDRAW_STATUS | REDRAW_INDEX;
6225 if (option (OPTRESOLVE))
6226 @@ -2440,6 +2472,60 @@ search_next:
6227 redraw = REDRAW_FULL;
6232 + CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6234 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6235 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6236 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6238 + ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6239 + redraw = REDRAW_FULL;
6242 + case OP_FORWARD_TO_GROUP:
6243 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6245 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6246 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6247 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6249 + if (IsMsgAttach (extra))
6250 + mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6251 + extra->idxlen, extra->bdy, SENDNEWS);
6253 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6254 + redraw = REDRAW_FULL;
6258 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6261 + if (IsMsgAttach (extra))
6262 + followup_to = extra->bdy->hdr->env->followup_to;
6264 + followup_to = extra->hdr->env->followup_to;
6266 + if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6267 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6269 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6270 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6271 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6273 + if (IsMsgAttach (extra))
6274 + mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6275 + extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6277 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6278 + extra->ctx, extra->hdr);
6279 + redraw = REDRAW_FULL;
6285 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6287 @@ -2486,7 +2572,7 @@ search_next:
6289 if (IsMsgAttach (extra))
6290 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6291 - extra->idxlen, extra->bdy);
6292 + extra->idxlen, extra->bdy, 0);
6294 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6295 redraw = REDRAW_FULL;
6296 diff -udprP mutt-1.5.19.orig/parse.c mutt-1.5.19/parse.c
6297 --- mutt-1.5.19.orig/parse.c 2009-01-05 21:20:53.000000000 +0200
6298 +++ mutt-1.5.19/parse.c 2009-01-06 22:27:38.000000000 +0200
6299 @@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
6303 -static LIST *mutt_parse_references (char *s, int in_reply_to)
6304 +LIST *mutt_parse_references (char *s, int in_reply_to)
6306 LIST *t, *lst = NULL;
6308 @@ -1067,6 +1067,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6309 e->from = rfc822_parse_adrlist (e->from, p);
6313 + else if (!mutt_strcasecmp (line+1, "ollowup-to"))
6315 + if (!e->followup_to)
6317 + mutt_remove_trailing_ws (p);
6318 + e->followup_to = safe_strdup (mutt_skip_whitespace (p));
6326 @@ -1151,6 +1162,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6332 + if (!mutt_strcasecmp (line + 1, "ewsgroups"))
6334 + FREE (&e->newsgroups);
6335 + mutt_remove_trailing_ws (p);
6336 + e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
6343 + /* field `Organization:' saves only for pager! */
6344 + if (!mutt_strcasecmp (line + 1, "rganization"))
6346 + if (!e->organization && mutt_strcasecmp (p, "unknown"))
6347 + e->organization = safe_strdup (p);
6352 if (!ascii_strcasecmp (line + 1, "eferences"))
6354 @@ -1259,6 +1291,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6355 e->x_label = safe_strdup(p);
6359 + else if (!mutt_strcasecmp (line + 1, "-comment-to"))
6361 + if (!e->x_comment_to)
6362 + e->x_comment_to = safe_strdup (p);
6365 + else if (!mutt_strcasecmp (line + 1, "ref"))
6368 + e->xref = safe_strdup (p);
6375 diff -udprP mutt-1.5.19.orig/pattern.c mutt-1.5.19/pattern.c
6376 --- mutt-1.5.19.orig/pattern.c 2009-01-05 21:20:53.000000000 +0200
6377 +++ mutt-1.5.19/pattern.c 2009-01-06 22:27:38.000000000 +0200
6378 @@ -91,6 +91,9 @@ Flags[] =
6379 { 'U', M_UNREAD, 0, NULL },
6380 { 'v', M_COLLAPSED, 0, NULL },
6381 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6383 + { 'w', M_NEWSGROUPS, 0, eat_regexp },
6385 { 'x', M_REFERENCE, 0, eat_regexp },
6386 { 'X', M_MIMEATTACH, 0, eat_range },
6387 { 'y', M_XLABEL, 0, eat_regexp },
6388 @@ -1201,6 +1204,10 @@ mutt_pattern_exec (struct pattern_t *pat
6390 case M_UNREFERENCED:
6391 return (pat->not ^ (h->thread && !h->thread->child));
6393 + case M_NEWSGROUPS:
6394 + return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6397 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6399 @@ -1282,6 +1289,7 @@ int mutt_pattern_func (int op, char *pro
6400 progress_t progress;
6402 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6403 + if (prompt || op != M_LIMIT)
6404 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6407 diff -udprP mutt-1.5.19.orig/po/POTFILES.in mutt-1.5.19/po/POTFILES.in
6408 --- mutt-1.5.19.orig/po/POTFILES.in 2008-03-19 22:07:57.000000000 +0200
6409 +++ mutt-1.5.19/po/POTFILES.in 2009-01-06 22:27:38.000000000 +0200
6410 @@ -46,6 +46,8 @@ mutt_ssl_gnutls.c
6419 diff -udprP mutt-1.5.19.orig/postpone.c mutt-1.5.19/postpone.c
6420 --- mutt-1.5.19.orig/postpone.c 2009-01-05 21:20:53.000000000 +0200
6421 +++ mutt-1.5.19/postpone.c 2009-01-06 22:27:38.000000000 +0200
6422 @@ -124,15 +124,26 @@ int mutt_num_postponed (int force)
6424 if (LastModify < st.st_mtime)
6427 + int optnews = option (OPTNEWS);
6429 LastModify = st.st_mtime;
6431 if (access (Postponed, R_OK | F_OK) != 0)
6432 return (PostCount = 0);
6435 + unset_option (OPTNEWS);
6437 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6440 PostCount = ctx.msgcount;
6441 mx_fastclose_mailbox (&ctx);
6444 + set_option (OPTNEWS);
6449 diff -udprP mutt-1.5.19.orig/protos.h mutt-1.5.19/protos.h
6450 --- mutt-1.5.19.orig/protos.h 2009-01-05 21:20:53.000000000 +0200
6451 +++ mutt-1.5.19/protos.h 2009-01-06 22:27:38.000000000 +0200
6452 @@ -115,6 +115,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
6453 HASH *mutt_make_subj_hash (CONTEXT *);
6455 LIST *mutt_make_references(ENVELOPE *e);
6456 +LIST *mutt_parse_references (char *, int);
6458 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6459 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
6460 diff -udprP mutt-1.5.19.orig/recvattach.c mutt-1.5.19/recvattach.c
6461 --- mutt-1.5.19.orig/recvattach.c 2009-01-05 21:20:53.000000000 +0200
6462 +++ mutt-1.5.19/recvattach.c 2009-01-06 22:27:38.000000000 +0200
6463 @@ -1107,6 +1107,15 @@ void mutt_view_attachments (HEADER *hdr)
6468 + if (Context->magic == M_NNTP)
6471 + mutt_error _("Can't delete attachment from newsserver.");
6476 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6479 @@ -1198,10 +1207,33 @@ void mutt_view_attachments (HEADER *hdr)
6480 case OP_FORWARD_MESSAGE:
6482 mutt_attach_forward (fp, hdr, idx, idxlen,
6483 - menu->tagprefix ? NULL : idx[menu->current]->content);
6484 + menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6485 menu->redraw = REDRAW_FULL;
6489 + case OP_FORWARD_TO_GROUP:
6491 + mutt_attach_forward (fp, hdr, idx, idxlen,
6492 + menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6493 + menu->redraw = REDRAW_FULL;
6499 + if (!idx[menu->current]->content->hdr->env->followup_to ||
6500 + mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6501 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6503 + mutt_attach_reply (fp, hdr, idx, idxlen,
6504 + menu->tagprefix ? NULL : idx[menu->current]->content,
6505 + SENDNEWS|SENDREPLY);
6506 + menu->redraw = REDRAW_FULL;
6512 case OP_GROUP_REPLY:
6514 diff -udprP mutt-1.5.19.orig/recvcmd.c mutt-1.5.19/recvcmd.c
6515 --- mutt-1.5.19.orig/recvcmd.c 2009-01-05 21:20:53.000000000 +0200
6516 +++ mutt-1.5.19/recvcmd.c 2009-01-06 22:27:38.000000000 +0200
6517 @@ -373,7 +373,7 @@ static BODY ** copy_problematic_attachme
6518 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6519 ATTACHPTR ** idx, short idxlen,
6522 + short nattach, int flags)
6525 short mime_fwd_all = 0;
6526 @@ -519,7 +519,7 @@ _("Can't decode all tagged attachments.
6529 /* now that we have the template, send it. */
6530 - ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6531 + ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6535 @@ -546,7 +546,7 @@ _("Can't decode all tagged attachments.
6538 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6539 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6540 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6542 HEADER *curhdr = NULL;
6544 @@ -651,23 +651,23 @@ static void attach_forward_msgs (FILE *
6546 mutt_free_header (&tmphdr);
6548 - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6549 + ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
6554 void mutt_attach_forward (FILE * fp, HEADER * hdr,
6555 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6556 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6561 if (check_all_msg (idx, idxlen, cur, 0) == 0)
6562 - attach_forward_msgs (fp, hdr, idx, idxlen, cur);
6563 + attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
6566 nattach = count_tagged (idx, idxlen);
6567 - attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
6568 + attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
6572 @@ -725,28 +725,40 @@ attach_reply_envelope_defaults (ENVELOPE
6578 + if ((flags & SENDNEWS))
6580 - if (mutt_fetch_recips (env, curenv, flags) == -1)
6582 + /* in case followup set Newsgroups: with Followup-To: if it present */
6583 + if (!env->newsgroups && curenv &&
6584 + mutt_strcasecmp (curenv->followup_to, "poster"))
6585 + env->newsgroups = safe_strdup (curenv->followup_to);
6590 - for (i = 0; i < idxlen; i++)
6593 - if (idx[i]->content->tagged
6594 - && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6595 + if (mutt_fetch_recips (env, curenv, flags) == -1)
6600 + for (i = 0; i < idxlen; i++)
6602 + if (idx[i]->content->tagged
6603 + && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6608 + if ((flags & SENDLISTREPLY) && !env->to)
6610 + mutt_error _("No mailing lists found!");
6614 + mutt_fix_reply_recipients (env);
6617 - if ((flags & SENDLISTREPLY) && !env->to)
6619 - mutt_error _("No mailing lists found!");
6623 - mutt_fix_reply_recipients (env);
6624 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
6627 @@ -807,6 +819,13 @@ void mutt_attach_reply (FILE * fp, HEADE
6628 char prefix[SHORT_STRING];
6632 + if (flags & SENDNEWS)
6633 + set_option (OPTNEWSSEND);
6635 + unset_option (OPTNEWSSEND);
6638 if (check_all_msg (idx, idxlen, cur, 0) == -1)
6640 nattach = count_tagged (idx, idxlen);
6641 diff -udprP mutt-1.5.19.orig/rfc1524.c mutt-1.5.19/rfc1524.c
6642 --- mutt-1.5.19.orig/rfc1524.c 2009-01-05 21:20:53.000000000 +0200
6643 +++ mutt-1.5.19/rfc1524.c 2009-01-06 22:27:38.000000000 +0200
6644 @@ -569,13 +569,13 @@ int rfc1524_expand_filename (char *namet
6648 -int mutt_rename_file (char *oldfile, char *newfile)
6649 +int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
6653 if (access (oldfile, F_OK) != 0)
6655 - if (access (newfile, F_OK) == 0)
6656 + if (!overwrite && access (newfile, F_OK) == 0)
6658 if ((ofp = fopen (oldfile,"r")) == NULL)
6660 @@ -590,3 +590,8 @@ int mutt_rename_file (char *oldfile, cha
6661 mutt_unlink (oldfile);
6665 +int mutt_rename_file (char *oldfile, char *newfile)
6667 + return _mutt_rename_file (oldfile, newfile, 0);
6669 diff -udprP mutt-1.5.19.orig/rfc1524.h mutt-1.5.19/rfc1524.h
6670 --- mutt-1.5.19.orig/rfc1524.h 2008-03-19 22:07:06.000000000 +0200
6671 +++ mutt-1.5.19/rfc1524.h 2009-01-06 22:27:38.000000000 +0200
6672 @@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char
6673 int rfc1524_expand_filename (char *, char *, char *, size_t);
6674 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
6675 int mutt_rename_file (char *, char *);
6676 +int _mutt_rename_file (char *, char *, int);
6678 #endif /* _RFC1524_H */
6679 diff -udprP mutt-1.5.19.orig/send.c mutt-1.5.19/send.c
6680 --- mutt-1.5.19.orig/send.c 2009-01-05 21:20:53.000000000 +0200
6681 +++ mutt-1.5.19/send.c 2009-01-06 22:27:38.000000000 +0200
6683 #include <sys/types.h>
6692 #include "remailer.h"
6694 @@ -213,17 +218,51 @@ static int edit_address (ADDRESS **a, /*
6698 -static int edit_envelope (ENVELOPE *en)
6699 +static int edit_envelope (ENVELOPE *en, int flags)
6701 char buf[HUGE_STRING];
6702 LIST *uh = UserHeader;
6704 - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6706 - if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6708 - if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6711 + if (option (OPTNEWSSEND))
6713 + if (en->newsgroups)
6714 + strfcpy (buf, en->newsgroups, sizeof (buf));
6717 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
6719 + FREE (&en->newsgroups);
6720 + en->newsgroups = safe_strdup (buf);
6722 + if (en->followup_to)
6723 + strfcpy (buf, en->followup_to, sizeof (buf));
6726 + if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
6728 + FREE (&en->followup_to);
6729 + en->followup_to = safe_strdup (buf);
6731 + if (en->x_comment_to)
6732 + strfcpy (buf, en->x_comment_to, sizeof (buf));
6735 + if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
6737 + FREE (&en->x_comment_to);
6738 + en->x_comment_to = safe_strdup (buf);
6743 + if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6745 + if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6747 + if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6753 @@ -259,6 +298,14 @@ static int edit_envelope (ENVELOPE *en)
6758 +char *nntp_get_header (const char *s)
6761 + return safe_strdup (s);
6765 static void process_user_recips (ENVELOPE *env)
6767 LIST *uh = UserHeader;
6768 @@ -271,6 +318,14 @@ static void process_user_recips (ENVELOP
6769 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
6770 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
6771 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
6773 + else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
6774 + env->newsgroups = nntp_get_header (uh->data + 11);
6775 + else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
6776 + env->followup_to = nntp_get_header (uh->data + 12);
6777 + else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
6778 + env->x_comment_to = nntp_get_header (uh->data + 13);
6783 @@ -309,6 +364,12 @@ static void process_user_header (ENVELOP
6784 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
6785 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
6786 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
6788 + ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
6789 + ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
6790 + ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
6792 + ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
6793 ascii_strncasecmp ("subject:", uh->data, 8) != 0)
6796 @@ -652,6 +713,10 @@ void mutt_add_to_reference_headers (ENVE
6801 + if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
6802 + env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
6807 @@ -708,6 +773,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
6809 if (flags & SENDREPLY)
6812 + if ((flags & SENDNEWS))
6814 + /* in case followup set Newsgroups: with Followup-To: if it present */
6815 + if (!env->newsgroups && curenv &&
6816 + mutt_strcasecmp (curenv->followup_to, "poster"))
6817 + env->newsgroups = safe_strdup (curenv->followup_to);
6824 @@ -854,7 +929,18 @@ void mutt_set_followup_to (ENVELOPE *e)
6825 * it hasn't already been set
6828 - if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
6829 + if (!option (OPTFOLLOWUPTO))
6832 + if (option (OPTNEWSSEND))
6834 + if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
6835 + e->followup_to = safe_strdup (e->newsgroups);
6840 + if (!e->mail_followup_to)
6842 if (mutt_is_list_cc (0, e->to, e->cc))
6844 @@ -1015,6 +1101,9 @@ static int send_message (HEADER *msg)
6849 + if (!option (OPTNEWSSEND))
6850 +#endif /* USE_NNTP */
6852 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
6853 msg->env->bcc, tempfile,
6854 @@ -1107,6 +1196,13 @@ ci_send_message (int flags, /* send mod
6859 + if (flags & SENDNEWS)
6860 + set_option (OPTNEWSSEND);
6862 + unset_option (OPTNEWSSEND);
6865 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
6866 mutt_num_postponed (1))
6868 @@ -1137,6 +1233,22 @@ ci_send_message (int flags, /* send mod
6870 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
6874 + * If postponed message is a news article, it have
6875 + * a "Newsgroups:" header line, then set appropriate flag.
6877 + if (msg->env->newsgroups)
6879 + flags |= SENDNEWS;
6880 + set_option (OPTNEWSSEND);
6884 + flags &= ~SENDNEWS;
6885 + unset_option (OPTNEWSSEND);
6890 if (flags & (SENDPOSTPONED|SENDRESEND))
6891 @@ -1248,11 +1360,16 @@ ci_send_message (int flags, /* send mod
6892 if (flags & SENDREPLY)
6893 mutt_fix_reply_recipients (msg->env);
6896 + if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
6897 + msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
6900 if (! (flags & SENDMAILX) &&
6901 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
6902 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
6904 - if (edit_envelope (msg->env) == -1)
6905 + if (edit_envelope (msg->env, flags) == -1)
6909 @@ -1509,6 +1626,11 @@ main_loop:
6914 + if (flags & SENDNEWS)
6915 + mutt_message _("Article not posted.");
6918 mutt_message _("Mail not sent.");
6921 @@ -1541,6 +1663,9 @@ main_loop:
6926 + if (!(flags & SENDNEWS))
6928 if (!msg->env->to && !msg->env->cc && !msg->env->bcc)
6930 if (! (flags & SENDBATCH))
6931 @@ -1573,6 +1698,19 @@ main_loop:
6932 mutt_error _("No subject specified.");
6936 + if ((flags & SENDNEWS) && !msg->env->subject)
6938 + mutt_error _("No subject specified.");
6942 + if ((flags & SENDNEWS) && !msg->env->newsgroups)
6944 + mutt_error _("No newsgroup specified.");
6949 if (msg->content->next)
6950 msg->content = mutt_make_multipart (msg->content);
6951 @@ -1778,7 +1916,12 @@ full_fcc:
6954 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
6955 - mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
6956 + mutt_message (i != 0 ? _("Sending in background.") :
6958 + (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
6963 if (WithCrypto && (msg->security & ENCRYPT))
6965 diff -udprP mutt-1.5.19.orig/sendlib.c mutt-1.5.19/sendlib.c
6966 --- mutt-1.5.19.orig/sendlib.c 2009-01-04 01:27:11.000000000 +0200
6967 +++ mutt-1.5.19/sendlib.c 2009-01-06 22:27:38.000000000 +0200
6969 #include <sys/wait.h>
6976 #ifdef HAVE_SYSEXITS_H
6977 #include <sysexits.h>
6978 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
6979 @@ -1748,6 +1752,9 @@ int mutt_write_rfc822_header (FILE *fp,
6980 LIST *tmp = env->userhdrs;
6981 int has_agent = 0; /* user defined user-agent header field exists */
6984 + if (!option (OPTNEWSSEND))
6986 if (mode == 0 && !privacy)
6987 fputs (mutt_make_date (buffer, sizeof(buffer)), fp);
6989 @@ -1774,6 +1781,9 @@ int mutt_write_rfc822_header (FILE *fp,
6990 mutt_write_address_list (env->to, fp, 4, 0);
6994 + if (!option (OPTNEWSSEND))
6996 fputs ("To: \n", fp);
6999 @@ -1782,6 +1792,9 @@ int mutt_write_rfc822_header (FILE *fp,
7000 mutt_write_address_list (env->cc, fp, 4, 0);
7004 + if (!option (OPTNEWSSEND))
7006 fputs ("Cc: \n", fp);
7009 @@ -1793,8 +1806,28 @@ int mutt_write_rfc822_header (FILE *fp,
7014 + if (!option (OPTNEWSSEND))
7016 fputs ("Bcc: \n", fp);
7019 + if (env->newsgroups)
7020 + fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
7021 + else if (mode == 1 && option (OPTNEWSSEND))
7022 + fputs ("Newsgroups: \n", fp);
7024 + if (env->followup_to)
7025 + fprintf (fp, "Followup-To: %s\n", env->followup_to);
7026 + else if (mode == 1 && option (OPTNEWSSEND))
7027 + fputs ("Followup-To: \n", fp);
7029 + if (env->x_comment_to)
7030 + fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
7031 + else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
7032 + fputs ("X-Comment-To: \n", fp);
7036 mutt_write_one_header (fp, "Subject", env->subject, NULL, 0);
7038 @@ -1813,6 +1846,9 @@ int mutt_write_rfc822_header (FILE *fp,
7039 fputs ("Reply-To: \n", fp);
7041 if (env->mail_followup_to)
7043 + if (!option (OPTNEWSSEND))
7046 fputs ("Mail-Followup-To: ", fp);
7047 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
7048 @@ -2151,11 +2187,30 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7049 const char *msg, /* file containing message */
7050 int eightbit) /* message contains 8bit chars */
7052 - char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
7053 + char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
7055 size_t argslen = 0, argsmax = 0;
7059 + if (option (OPTNEWSSEND))
7061 + char cmd[LONG_STRING];
7063 + mutt_FormatString (cmd, sizeof (cmd), 0, NONULL (Inews), nntp_format_str, 0, 0);
7066 + i = nntp_post (msg);
7071 + s = safe_strdup (cmd);
7075 + s = safe_strdup (Sendmail);
7079 while ((ps = strtok (ps, " ")))
7080 @@ -2179,6 +2234,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7085 + if (!option (OPTNEWSSEND))
7088 if (eightbit && option (OPTUSE8BITMIME))
7089 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7091 @@ -2210,6 +2269,9 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7092 args = add_args (args, &argslen, &argsmax, to);
7093 args = add_args (args, &argslen, &argsmax, cc);
7094 args = add_args (args, &argslen, &argsmax, bcc);
7099 if (argslen == argsmax)
7100 safe_realloc (&args, sizeof (char *) * (++argsmax));
7101 @@ -2290,6 +2352,9 @@ void mutt_prepare_envelope (ENVELOPE *en
7102 rfc2047_encode_string (&env->x_label);
7106 + if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
7109 rfc2047_encode_string (&env->subject);
7111 @@ -2399,6 +2464,10 @@ int mutt_bounce_message (FILE *fp, HEADE
7113 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
7116 + unset_option (OPTNEWSSEND);
7119 ret = _mutt_bounce_message (fp, h, to, resent_from, from);
7121 rfc822_free_address (&from);
7122 diff -udprP mutt-1.5.19.orig/sort.c mutt-1.5.19/sort.c
7123 --- mutt-1.5.19.orig/sort.c 2008-10-29 00:29:44.000000000 +0200
7124 +++ mutt-1.5.19/sort.c 2009-01-06 22:27:38.000000000 +0200
7125 @@ -151,6 +151,15 @@ static int compare_order (const void *a,
7126 HEADER **ha = (HEADER **) a;
7127 HEADER **hb = (HEADER **) b;
7130 + if ((*ha)->article_num && (*hb)->article_num)
7132 + int result = (*ha)->article_num - (*hb)->article_num;
7133 + AUXSORT(result,a,b);
7134 + return (SORTCODE (result));
7138 /* no need to auxsort because you will never have equality here */
7139 return (SORTCODE ((*ha)->index - (*hb)->index));
7141 diff -udprP mutt-1.5.19.orig/url.c mutt-1.5.19/url.c
7142 --- mutt-1.5.19.orig/url.c 2009-01-05 21:20:53.000000000 +0200
7143 +++ mutt-1.5.19/url.c 2009-01-06 22:27:38.000000000 +0200
7144 @@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] =
7145 { "imaps", U_IMAPS },
7148 + { "news", U_NNTP },
7149 + { "newss", U_NNTPS },
7150 { "mailto", U_MAILTO },
7152 { "smtps", U_SMTPS },
7153 diff -udprP mutt-1.5.19.orig/url.h mutt-1.5.19/url.h
7154 --- mutt-1.5.19.orig/url.h 2008-03-19 22:07:57.000000000 +0200
7155 +++ mutt-1.5.19/url.h 2009-01-06 22:27:38.000000000 +0200
7156 @@ -8,6 +8,8 @@ typedef enum url_scheme
7165 diff -udprP mutt-1.5.19.orig/Makefile.am mutt-1.5.19/Makefile.am
7166 --- mutt-1.5.19.orig/Makefile.am 2009-01-05 21:20:53.000000000 +0200
7167 +++ mutt-1.5.19/Makefile.am 2009-01-06 22:27:38.000000000 +0200
7168 @@ -53,6 +53,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
7169 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
7170 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
7171 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
7173 smime.c smtp.c utf8.c wcwidth.c \
7174 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
7176 @@ -64,6 +65,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7177 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7178 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7179 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7180 + nntp.h ChangeLog.nntp \
7181 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7182 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
7183 README.SSL smime.h \
7184 diff -udprP mutt-1.5.19.orig/Makefile.in mutt-1.5.19/Makefile.in
7185 --- mutt-1.5.19.orig/Makefile.in 2009-01-05 21:24:13.000000000 +0200
7186 +++ mutt-1.5.19/Makefile.in 2009-01-06 22:27:38.000000000 +0200
7187 @@ -323,6 +323,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
7188 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
7189 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
7190 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
7192 smime.c smtp.c utf8.c wcwidth.c \
7193 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
7195 @@ -334,6 +335,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7196 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7197 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7198 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7199 + nntp.h ChangeLog.nntp \
7200 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7201 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
7202 README.SSL smime.h \
7203 @@ -555,6 +557,8 @@ distclean-compile:
7204 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@
7205 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@
7206 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@
7207 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@
7208 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@
7209 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@
7210 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
7211 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@
7212 diff -udprP mutt-1.5.19.orig/configure mutt-1.5.19/configure
7213 --- mutt-1.5.19.orig/configure 2008-11-18 01:53:41.000000000 +0200
7214 +++ mutt-1.5.19/configure 2009-01-06 22:27:38.000000000 +0200
7215 @@ -1359,6 +1359,7 @@ Optional Features:
7216 Force use of an external dotlock program
7217 --enable-pop Enable POP3 support
7218 --enable-imap Enable IMAP support
7219 + --enable-nntp Enable NNTP support
7220 --enable-smtp include internal SMTP relay support
7221 --enable-debug Enable debugging support
7222 --enable-flock Use flock() to lock files
7223 @@ -12547,6 +12548,20 @@ fi
7227 +# Check whether --enable-nntp or --disable-nntp was given.
7228 +if test "${enable_nntp+set}" = set; then
7229 + enableval="$enable_nntp"
7230 + if test x$enableval = xyes ; then
7231 + cat >>confdefs.h <<\_ACEOF
7235 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
7243 for ac_func in strftime
7244 diff -udprP mutt-1.5.19.orig/doc/Muttrc mutt-1.5.19/doc/Muttrc
7245 --- mutt-1.5.19.orig/doc/Muttrc 2009-01-06 02:36:17.000000000 +0200
7246 +++ mutt-1.5.19/doc/Muttrc 2009-01-06 22:27:38.000000000 +0200
7247 @@ -278,6 +278,28 @@ attachments -I message/external-body
7248 # of the value as shown above if included.
7251 +# set ask_follow_up=no
7253 +# Name: ask_follow_up
7258 +# If set, Mutt will prompt you for follow-up groups before editing
7259 +# the body of an outgoing message.
7262 +# set ask_x_comment_to=no
7264 +# Name: ask_x_comment_to
7269 +# If set, Mutt will prompt you for x-comment-to field before editing
7270 +# the body of an outgoing message.
7273 # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
7275 # Name: attach_format
7276 @@ -458,6 +480,17 @@ attachments -I message/external-body
7277 # Afterwards the new mail status is tracked by file size changes.
7280 +# set catchup_newsgroup=ask-yes
7282 +# Name: catchup_newsgroup
7287 +# If this variable is set, Mutt will mark all articles in newsgroup
7288 +# as read when you quit the newsgroup (catchup newsgroup).
7294 @@ -988,6 +1021,19 @@ attachments -I message/external-body
7295 # of the same email for you.
7298 +# set followup_to_poster=ask-yes
7300 +# Name: followup_to_poster
7305 +# If this variable is set and the keyword "poster" is present in
7306 +# Followup-To header, follow-up to newsgroup function is not
7307 +# permitted. The message will be mailed to the submitter of the
7308 +# message via mail.
7314 @@ -1084,6 +1130,28 @@ attachments -I message/external-body
7315 # ``Franklin'' to ``Franklin, Steve''.
7318 +# set group_index_format="%4C %M%N %5s %-45.45f %d"
7320 +# Name: group_index_format
7322 +# Default: "%4C %M%N %5s %-45.45f %d"
7325 +# This variable allows you to customize the newsgroup browser display to
7326 +# your personal taste. This string is similar to ``index_format'', but
7327 +# has its own set of printf()-like sequences:
7329 +# %C current newsgroup number
7330 +# %d description of newsgroup (becomes from server)
7331 +# %f newsgroup name
7332 +# %M - if newsgroup not allowed for direct post (moderated for example)
7333 +# %N N if newsgroup is new, u if unsubscribed, blank otherwise
7334 +# %n number of new articles in newsgroup
7335 +# %s number of unread articles in newsgroup
7336 +# %>X right justify the rest of the string and pad with character "X"
7337 +# %|X pad to the end of the line with character "X"
7343 @@ -1572,6 +1640,7 @@ attachments -I message/external-body
7344 # %E number of messages in current thread
7345 # %f sender (address + real name), either From: or Return-Path:
7346 # %F author name, or recipient name if the message is from you
7347 +# %g newsgroup name (if compiled with nntp support)
7348 # %H spam attribute(s) of this message
7349 # %i message-id of the current message
7350 # %l number of lines in the message (does not work with maildir,
7351 @@ -1587,12 +1656,14 @@ attachments -I message/external-body
7352 # stashed the message: list name or recipient name
7353 # if not sent to a list
7354 # %P progress indicator for the builtin pager (how much of the file has been displayed)
7355 +# %R `x-comment-to:' field (if present and compiled with nntp support)
7356 # %s subject of the message
7357 # %S status of the message (``N''/``D''/``d''/``!''/``r''/*)
7358 # %t ``To:'' field (recipients)
7359 # %T the appropriate character from the $to_chars string
7360 # %u user (login) name of the author
7361 # %v first name of the author, or the recipient if the message is from you
7362 +# %W name of organization of author (`organization:' field)
7363 # %X number of attachments
7364 # (please see the ``attachments'' section for possible speed effects)
7365 # %y ``X-Label:'' field, if present
7366 @@ -1628,6 +1699,22 @@ attachments -I message/external-body
7367 # ``save-hook'', ``fcc-hook'' and ``fcc-save-hook'', too.
7377 +# If set, specifies the program and arguments used to deliver news posted
7378 +# by Mutt. Otherwise, mutt posts article using current connection to
7379 +# news server. The following printf-style sequence is understood:
7381 +# %s newsserver name
7383 +# Example: set inews="/usr/local/bin/inews -hS"
7386 # set ispell="ispell"
7389 @@ -1982,6 +2069,18 @@ attachments -I message/external-body
7390 # be attached to the newly composed message if this option is set.
7393 +# set mime_subject=yes
7395 +# Name: mime_subject
7400 +# If unset, 8-bit ``subject:'' line in article header will not be
7401 +# encoded according to RFC2047 to base64. This is useful when message
7402 +# is Usenet article, because MIME for news is nonstandard feature.
7405 # set mix_entry_format="%4n %c %-16s %a"
7407 # Name: mix_entry_format
7408 @@ -2091,6 +2190,118 @@ attachments -I message/external-body
7409 # See also $read_inc, $write_inc and $net_inc.
7412 +# set news_cache_dir="~/.mutt"
7414 +# Name: news_cache_dir
7416 +# Default: "~/.mutt"
7419 +# This variable pointing to directory where Mutt will save cached news
7420 +# articles headers in. If unset, headers will not be saved at all
7421 +# and will be reloaded each time when you enter to newsgroup.
7424 +# set news_server=""
7426 +# Name: news_server
7431 +# This variable specifies domain name or address of NNTP server. It
7432 +# defaults to the newsserver specified in the environment variable
7433 +# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
7434 +# specify username and an alternative port for each newsserver, ie:
7436 +# [news[s]://][username[:password]@]newsserver[:port]
7439 +# set newsrc="~/.newsrc"
7443 +# Default: "~/.newsrc"
7446 +# The file, containing info about subscribed newsgroups - names and
7447 +# indexes of read articles. The following printf-style sequence
7450 +# %s newsserver name
7453 +# set nntp_context=1000
7455 +# Name: nntp_context
7460 +# This variable defines number of articles which will be in index when
7461 +# newsgroup entered. If active newsgroup have more articles than this
7462 +# number, oldest articles will be ignored. Also controls how many
7463 +# articles headers will be saved in cache when you quit newsgroup.
7466 +# set nntp_load_description=yes
7468 +# Name: nntp_load_description
7473 +# This variable controls whether or not descriptions for each newsgroup
7474 +# must be loaded when newsgroup is added to list (first time list
7475 +# loading or new newsgroup adding).
7485 +# Your login name on the NNTP server. If unset and NNTP server requires
7486 +# authentification, Mutt will prompt you for your account name when you
7487 +# connect to newsserver.
7497 +# Your password for NNTP account.
7507 +# The time in seconds until any operations on newsgroup except post new
7508 +# article will cause recheck for new news. If set to 0, Mutt will
7509 +# recheck newsgroup on each operation in index (stepping, read article,
7513 +# set nntp_reconnect=ask-yes
7515 +# Name: nntp_reconnect
7520 +# Controls whether or not Mutt will try to reconnect to newsserver when
7524 # set pager="builtin"
7527 @@ -3361,6 +3572,19 @@ attachments -I message/external-body
7528 # string after the inclusion of a message which is being replied to.
7531 +# set post_moderated=ask-yes
7533 +# Name: post_moderated
7538 +# If set to yes, Mutt will post article to newsgroup that have
7539 +# not permissions to posting (e.g. moderated). Note: if newsserver
7540 +# does not support posting to that newsgroup or totally read-only, that
7541 +# posting will not have an effect.
7544 # set postpone=ask-yes
7547 @@ -3924,6 +4148,41 @@ attachments -I message/external-body
7548 # shell from /etc/passwd is used.
7551 +# set save_unsubscribed=no
7553 +# Name: save_unsubscribed
7558 +# When set, info about unsubscribed newsgroups will be saved into
7559 +# ``newsrc'' file and into cache.
7562 +# set show_new_news=yes
7564 +# Name: show_new_news
7569 +# If set, newsserver will be asked for new newsgroups on entering
7570 +# the browser. Otherwise, it will be done only once for a newsserver.
7571 +# Also controls whether or not number of new articles of subscribed
7572 +# newsgroups will be then checked.
7575 +# set show_only_unread=no
7577 +# Name: show_only_unread
7582 +# If set, only subscribed newsgroups that contain unread articles
7583 +# will be displayed in browser.
7586 # set sig_dashes=yes
7589 @@ -4678,3 +4937,14 @@ attachments -I message/external-body
7593 +# set x_comment_to=no
7595 +# Name: x_comment_to
7600 +# If set, Mutt will add ``X-Comment-To:'' field (that contains full
7601 +# name of original article author) to article that followuped to newsgroup.