1 WARNING: Run the following script before configure:
9 Vsevolod Volkov <vvv@mutt.org.ua>
12 diff -udprP mutt-1.5.20.orig/ChangeLog.nntp mutt-1.5.20/ChangeLog.nntp
13 --- mutt-1.5.20.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14 +++ mutt-1.5.20/ChangeLog.nntp 2009-06-15 21:56:06.000000000 +0300
16 +* Tue Jun 15 2009 Vsevolod Volkov <vvv@mutt.org.ua>
19 +* Tue Mar 20 2009 Vsevolod Volkov <vvv@mutt.org.ua>
20 +- save Date: header of recorded outgoing articles
22 +* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua>
25 +* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua>
27 +- fixed SIGSEGV when followup or forward to newsgroup
29 +* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua>
32 +* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua>
33 +- fixed arguments of nntp_format_str()
35 +* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua>
36 +- fixed error selecting news group
38 +* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua>
41 +* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
42 +- fixed posting error if $smtp_url is set
43 +- added support of print-style sequence %R (x-comment-to)
45 +* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
47 +- nntp://... url changed to news://...
48 +- added indicator of fetching descriptions progress
50 +* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
53 +* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
56 +* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
58 +- fixed reading empty .newsrc
60 +* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
63 +* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
66 +* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
69 +* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
72 +* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
74 +- function mutt_update_list_file() moved to newsrc.c and changed algorithm
76 +* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
77 +- fixed error in nntp_logout_all()
79 +* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
80 +- fixed debug output in mutt_newsrc_update()
81 +- added optional support of LISTGROUP command
82 +- fixed typo in nntp_parse_xref()
84 +* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
87 +* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
90 +* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
93 +* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
95 +- added space after newsgroup name in .newsrc file
97 +* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
98 +- nntp patch: fixed SIGSEGV when posting article
100 +* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
103 +* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
105 +- replace safe_free calls by the FREE macro
107 +* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
109 +- nntp authentication can be passed after any command
111 +* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
114 +* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
117 +* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
119 +- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
120 + <reconstruct-thread> functions
121 +- fixed message about nntp reconnect
122 +- fixed <attach-news-message> function using browser
123 +- added support of Followup-To: poster
124 +- added %n (new articles) in group_index_format
125 +- posting articles without inews by default
127 +* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
130 +* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
133 +* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
135 +- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
136 +- added default content disposition
138 +* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
141 +* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
142 +- update to 1.3.23.2
143 +- fixed segfault if mutt_conn_find() returns null
145 +* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
146 +- update to 1.3.23.1
147 +- added support of LISTGROUP command
148 +- added support for servers with broken overview
149 +- disabled <flag-message> function on news server
150 +- fixed error storing bad authentication information
152 +* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
154 +- fixed typo in buffy.c
155 +- added substitution of %s parameter in $inews variable
157 +* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
158 +- update to 1.3.22.1
161 +* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
164 +* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
166 +- removed 'server-hook', use 'account-hook' instead
167 +- fixed error opening NNTP server without newsgroup using -f option
169 +* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
172 +* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
174 +- fixed typo in nntp_attempt_features()
175 +- changed algorithm of XGTITLE command testing
176 +- disabled writing of NNTP password in debug file
177 +- fixed reading and writing of long newsrc lines
178 +- changed checking of last line while reading lines from server
179 +- fixed possible buffer overrun in nntp_parse_newsrc_line()
180 +- removed checking of XHDR command
181 +- compare NNTP return codes without trailing space
183 +* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
185 +- support for 'LIST NEWSGROUPS' command to read descriptions
187 +* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
190 +* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
193 +* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
195 +- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
197 +* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
200 +* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
201 +- Fixed problem if last article in group is deleted
203 +* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
204 +- Fixed checking of XGTITLE command on some servers
206 +* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
207 +- Added \r in AUTHINFO commands
209 +* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
212 +* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
214 +- fixed error opening newsgroup from mutt started with -g or -G
216 +* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
218 +- hotkey 'G' (get-message) replaced with '^G'
220 +* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
222 +- changed delay displaying error messages from 1 to 2 seconds
223 +- fixed error compiling with nntp and without imap
225 +* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
226 +- fixed catchup in index
227 +- fixed nntp_open_mailbox()
229 +* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
230 +- functions <edit> and <delete-entry> disabled
231 +- format of news mailbox names changed to url form
232 +- option nntp_attempts removed
233 +- option reconnect_news renamed to nntp_reconnect
234 +- default value of nntp_poll changed from 30 to 60
235 +- error handling improved
237 +* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
239 +- new option show_only_unread
240 +- add newsgroup completion
242 +* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
245 +* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
248 +* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
250 +- authentication code update
251 +- fix for changing to newsgroup from mailbox with read messages
252 +- socket code optimization
254 +* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
257 +* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
258 +- don't substitute current newsgroup with deleted new messages
260 +* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
262 +- fix for substitution of newsgroup after reconnection
263 +- fix for loading newsgroups with very long names
264 +- fix for loading more than 32768 newsgroups
266 +* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
269 +* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
272 +* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
275 +* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
278 +* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
281 +* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
284 +* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
285 +- add substitution of newsgroup with new messages by default
287 +* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
288 +- add attach message from newsgroup
289 +- add one-line help in newsreader mode
290 +- disable 'change-dir' command in newsgroups browser
293 +* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
294 +- get default newsserver name from file /etc/nntpserver
295 +- use case insensitive server names
296 +- add print-style sequence %s to $newsrc
299 +* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
300 +- remove 'X-FTN-Origin' header processing
302 +* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
306 +* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
307 +- fix mutt_select_newsserver()
308 +- remove 'toggle-mode' function
309 +- add 'change-newsgroup' function
311 +* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
314 +* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
315 +- fix error 'bounce' function after 'post'
316 +- add 'forward to newsgroup' function
318 +* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
319 +- 'forward' function works in newsreader mode
320 +- add 'post' and 'followup' functions to pager and attachment menu
321 +- fix active descriptions and allowed flag reload
323 +* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
325 +- remove deleted newsgroups from list
327 +* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
328 +- update .newsrc in browser
330 +* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
331 +- reload .newsrc if externally modified
332 +- fix active cache update
334 +* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
337 +* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
338 +- patch *.update_list_file is not required
339 +- count lines when loading descriptions
340 +- remove cache of unsubscribed newsgroups
342 +* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
343 +- load list of newsgroups from cache faster
345 +* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
348 +* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
349 +- fix unread messages in browser
350 +- fix newsrc_gen_entries()
352 +* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
353 +- fix mutt_newsgroup_stat()
354 +- fix nntp_delete_cache()
355 +- fix nntp_get_status()
356 +- fix check_children()
357 +- fix nntp_fetch_headers()
359 +* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
362 +* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
363 +- fix updating new messages in cache
365 +* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
366 +- change default cache filenames
367 +- fix updating new messages in cache
369 +* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
370 +- fix segmentation fault in news groups browser
372 +* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
375 +* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
378 +* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
379 +- add X-Comment-To editing
380 +- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
381 +- add variables $ask_followup_to and $ask_x_comment_to
383 +* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
385 diff -udprP mutt-1.5.20.orig/OPS mutt-1.5.20/OPS
386 --- mutt-1.5.20.orig/OPS 2009-05-13 08:01:13.000000000 +0300
387 +++ mutt-1.5.20/OPS 2009-06-15 21:05:24.000000000 +0300
388 @@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
389 OP_BROWSER_NEW_FILE "select a new file in this directory"
390 OP_BROWSER_VIEW_FILE "view file"
391 OP_BROWSER_TELL "display the currently selected file's name"
392 -OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
393 -OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
394 +OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
395 +OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
396 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
397 OP_BUFFY_LIST "list mailboxes with new mail"
398 +OP_CATCHUP "mark all articles in newsgroup as read"
399 OP_CHANGE_DIRECTORY "change directories"
400 OP_CHECK_NEW "check mailboxes for new mail"
401 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
402 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
403 +OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message"
404 OP_COMPOSE_EDIT_BCC "edit the BCC list"
405 OP_COMPOSE_EDIT_CC "edit the CC list"
406 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
407 @@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
408 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
409 OP_COMPOSE_EDIT_MESSAGE "edit the message"
410 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
411 +OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
412 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
413 +OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
414 +OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
415 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
416 OP_COMPOSE_EDIT_TO "edit the TO list"
417 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
418 @@ -85,8 +90,13 @@ OP_EXIT "exit this menu"
419 OP_FILTER "filter attachment through a shell command"
420 OP_FIRST_ENTRY "move to the first entry"
421 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
422 +OP_FOLLOWUP "followup to newsgroup"
423 +OP_FORWARD_TO_GROUP "forward to newsgroup"
424 OP_FORWARD_MESSAGE "forward a message with comments"
425 OP_GENERIC_SELECT_ENTRY "select the current entry"
426 +OP_GET_CHILDREN "get all children of the current message"
427 +OP_GET_MESSAGE "get message with Message-Id"
428 +OP_GET_PARENT "get parent of the current message"
429 OP_GROUP_REPLY "reply to all recipients"
430 OP_HALF_DOWN "scroll down 1/2 page"
431 OP_HALF_UP "scroll up 1/2 page"
432 @@ -94,11 +104,14 @@ OP_HELP "this screen"
433 OP_JUMP "jump to an index number"
434 OP_LAST_ENTRY "move to the last entry"
435 OP_LIST_REPLY "reply to specified mailing list"
436 +OP_LOAD_ACTIVE "load active file from NNTP server"
437 OP_MACRO "execute a macro"
438 OP_MAIL "compose a new mail message"
439 OP_MAIN_BREAK_THREAD "break the thread in two"
440 OP_MAIN_CHANGE_FOLDER "open a different folder"
441 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
442 +OP_MAIN_CHANGE_GROUP "open a different newsgroup"
443 +OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
444 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
445 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
446 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
447 @@ -137,6 +150,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
448 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
449 OP_PAGER_TOP "jump to the top of the message"
450 OP_PIPE "pipe message/attachment to a shell command"
451 +OP_POST "post message to newsgroup"
452 OP_PREV_ENTRY "move to the previous entry"
453 OP_PREV_LINE "scroll up one line"
454 OP_PREV_PAGE "move to the previous page"
455 @@ -145,6 +159,7 @@ OP_QUERY "query external program for add
456 OP_QUERY_APPEND "append new query results to current results"
457 OP_QUIT "save changes to mailbox and quit"
458 OP_RECALL_MESSAGE "recall a postponed message"
459 +OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
460 OP_REDRAW "clear and redraw the screen"
461 OP_REFORMAT_WINCH "{internal}"
462 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
463 @@ -159,18 +174,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
464 OP_SHELL_ESCAPE "invoke a command in a subshell"
465 OP_SORT "sort messages"
466 OP_SORT_REVERSE "sort messages in reverse order"
467 +OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
468 OP_TAG "tag the current entry"
469 OP_TAG_PREFIX "apply next function to tagged messages"
470 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
471 OP_TAG_SUBTHREAD "tag the current subthread"
472 OP_TAG_THREAD "tag the current thread"
473 OP_TOGGLE_NEW "toggle a message's 'new' flag"
474 +OP_TOGGLE_READ "toggle view of read messages"
475 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
476 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
477 OP_TOP_PAGE "move to the top of the page"
478 +OP_UNCATCHUP "mark all articles in newsgroup as unread"
479 OP_UNDELETE "undelete the current entry"
480 OP_UNDELETE_THREAD "undelete all messages in thread"
481 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
482 +OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
483 OP_VERSION "show the Mutt version number and date"
484 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
485 OP_VIEW_ATTACHMENTS "show MIME attachments"
486 diff -udprP mutt-1.5.20.orig/account.c mutt-1.5.20/account.c
487 --- mutt-1.5.20.orig/account.c 2008-11-11 21:55:46.000000000 +0200
488 +++ mutt-1.5.20/account.c 2009-06-15 21:05:24.000000000 +0300
489 @@ -51,6 +51,11 @@ int mutt_account_match (const ACCOUNT* a
494 + if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
498 if (a1->flags & a2->flags & M_ACCT_USER)
499 return (!strcmp (a1->user, a2->user));
500 if (a1->flags & M_ACCT_USER)
501 @@ -130,6 +135,16 @@ void mutt_account_tourl (ACCOUNT* accoun
506 + if (account->type == M_ACCT_TYPE_NNTP)
508 + if (account->flags & M_ACCT_SSL)
509 + url->scheme = U_NNTPS;
511 + url->scheme = U_NNTP;
515 url->host = account->host;
516 if (account->flags & M_ACCT_PORT)
517 url->port = account->port;
518 @@ -155,6 +170,10 @@ int mutt_account_getuser (ACCOUNT* accou
519 else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
520 strfcpy (account->user, PopUser, sizeof (account->user));
523 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
524 + strfcpy (account->user, NntpUser, sizeof (account->user));
526 /* prompt (defaults to unix username), copy into account->user */
529 @@ -215,6 +234,10 @@ int mutt_account_getpass (ACCOUNT* accou
530 else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass)
531 strfcpy (account->pass, SmtpPass, sizeof (account->pass));
534 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
535 + strfcpy (account->pass, NntpPass, sizeof (account->pass));
539 snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
540 diff -udprP mutt-1.5.20.orig/account.h mutt-1.5.20/account.h
541 --- mutt-1.5.20.orig/account.h 2008-11-11 21:55:46.000000000 +0200
542 +++ mutt-1.5.20/account.h 2009-06-15 21:05:24.000000000 +0300
543 @@ -29,7 +29,8 @@ enum
544 M_ACCT_TYPE_NONE = 0,
553 diff -udprP mutt-1.5.20.orig/attach.h mutt-1.5.20/attach.h
554 --- mutt-1.5.20.orig/attach.h 2008-11-11 21:55:46.000000000 +0200
555 +++ mutt-1.5.20/attach.h 2009-06-15 21:05:24.000000000 +0300
556 @@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f
558 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
559 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
560 -void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
561 +void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
562 void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
564 #endif /* _ATTACH_H_ */
565 diff -udprP mutt-1.5.20.orig/browser.c mutt-1.5.20/browser.c
566 --- mutt-1.5.20.orig/browser.c 2009-06-11 20:52:54.000000000 +0300
567 +++ mutt-1.5.20/browser.c 2009-06-15 21:05:24.000000000 +0300
578 @@ -49,6 +52,19 @@ static struct mapping_t FolderHelp[] = {
583 +static struct mapping_t FolderNewsHelp[] = {
584 + { N_("Exit"), OP_EXIT },
585 + { N_("List"), OP_TOGGLE_MAILBOXES },
586 + { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
587 + { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
588 + { N_("Catchup"), OP_CATCHUP },
589 + { N_("Mask"), OP_ENTER_MASK },
590 + { N_("Help"), OP_HELP },
595 typedef struct folder_t
597 struct folder_file *ff;
598 @@ -114,9 +130,17 @@ static void browser_sort (struct browser
603 + if (option (OPTNEWS))
606 f = browser_compare_date;
610 + if (option (OPTNEWS))
613 f = browser_compare_size;
616 @@ -307,8 +331,106 @@ folder_format_str (char *dest, size_t de
622 +newsgroup_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
623 + const char *fmt, const char *ifstring, const char *elsestring,
624 + unsigned long data, format_flag flags)
626 + char fn[SHORT_STRING], tmp[SHORT_STRING];
627 + FOLDER *folder = (FOLDER *) data;
632 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
633 + snprintf (dest, destlen, tmp, folder->num + 1);
637 + strncpy (fn, folder->ff->name, sizeof(fn) - 1);
638 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
639 + snprintf (dest, destlen, tmp, fn);
643 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
644 + if (folder->ff->nd->subscribed)
645 + snprintf (dest, destlen, tmp, ' ');
647 + snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
651 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
652 + if (folder->ff->nd->deleted)
653 + snprintf (dest, destlen, tmp, 'D');
655 + snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
659 + if (flags & M_FORMAT_OPTIONAL)
661 + if (folder->ff->nd->unread != 0)
662 + mutt_FormatString (dest, destlen, col, ifstring, newsgroup_format_str,
665 + mutt_FormatString (dest, destlen, col, elsestring, newsgroup_format_str,
668 + else if (Context && Context->data == folder->ff->nd)
670 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
671 + snprintf (dest, destlen, tmp, Context->unread);
675 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
676 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
681 + if (Context && Context->data == folder->ff->nd)
683 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
684 + snprintf (dest, destlen, tmp, Context->new);
686 + else if (option (OPTMARKOLD) &&
687 + folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
688 + folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
690 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
691 + snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
695 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
696 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
701 + if (folder->ff->nd->desc != NULL)
703 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
704 + snprintf (dest, destlen, tmp, folder->ff->nd->desc);
708 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
709 + snprintf (dest, destlen, tmp, "");
715 +#endif /* USE_NNTP */
717 static void add_folder (MUTTMENU *m, struct browser_state *state,
718 - const char *name, const struct stat *s, int new)
719 + const char *name, const struct stat *s,
720 + void *data, int new)
722 if (state->entrylen == state->entrymax)
724 @@ -337,6 +459,10 @@ static void add_folder (MUTTMENU *m, str
726 (state->entry)[state->entrylen].imap = 0;
729 + if (option (OPTNEWS))
730 + (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
735 @@ -352,9 +478,35 @@ static void init_state (struct browser_s
736 menu->data = state->entry;
739 +/* get list of all files/newsgroups with mask */
740 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
741 char *d, const char *prefix)
744 + if (option (OPTNEWS))
748 + NNTP_SERVER *news = CurrentNewsSrv;
750 +/* mutt_buffy_check (0); */
751 + init_state (state, menu);
753 + for (tmp = news->list; tmp; tmp = tmp->next)
755 + if (!(data = (NNTP_DATA *)tmp->data))
757 + if (prefix && *prefix && strncmp (prefix, data->group,
758 + strlen (prefix)) != 0)
760 + if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
762 + add_folder (menu, state, data->group, NULL, data, data->new);
766 +#endif /* USE_NNTP */
771 @@ -415,17 +567,40 @@ static int examine_directory (MUTTMENU *
773 while (tmp && mutt_strcmp (buffer, tmp->path))
775 - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
776 + add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
781 browser_sort (state);
785 +/* get list of mailboxes/subscribed newsgroups */
786 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
789 char buffer[LONG_STRING];
792 + if (option (OPTNEWS))
796 + NNTP_SERVER *news = CurrentNewsSrv;
798 +/* mutt_buffy_check (0); */
799 + init_state (state, menu);
801 + for (tmp = news->list; tmp; tmp = tmp->next)
803 + if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
804 + (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
805 + add_folder (menu, state, data->group, NULL, data, data->new);
811 BUFFY *tmp = Incoming;
813 struct mailbox_state mbox;
814 @@ -443,14 +618,21 @@ static int examine_mailboxes (MUTTMENU *
815 if (mx_is_imap (tmp->path))
817 imap_mailbox_state (tmp->path, &mbox);
818 - add_folder (menu, state, tmp->path, NULL, mbox.new);
819 + add_folder (menu, state, tmp->path, NULL, NULL, mbox.new);
824 if (mx_is_pop (tmp->path))
826 - add_folder (menu, state, tmp->path, NULL, tmp->new);
827 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
832 + if (mx_is_nntp (tmp->path))
834 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
838 @@ -479,15 +661,20 @@ static int examine_mailboxes (MUTTMENU *
839 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
840 mutt_pretty_mailbox (buffer, sizeof (buffer));
842 - add_folder (menu, state, buffer, &s, tmp->new);
843 + add_folder (menu, state, buffer, &s, NULL, tmp->new);
845 while ((tmp = tmp->next));
847 browser_sort (state);
851 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
854 + if (option (OPTNEWS))
855 + return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
857 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
860 @@ -498,6 +685,12 @@ static void folder_entry (char *s, size_
861 folder.ff = &((struct folder_file *) menu->data)[num];
865 + if (option (OPTNEWS))
866 + mutt_FormatString (s, slen, 0, NONULL(GroupFormat), newsgroup_format_str,
867 + (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
870 mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str,
871 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
873 @@ -518,6 +711,17 @@ static void init_menu (struct browser_st
878 + if (option (OPTNEWS))
881 + snprintf (title, titlelen, _("Subscribed newsgroups"));
883 + snprintf (title, titlelen, _("Newsgroups on server [%s]"),
884 + CurrentNewsSrv->conn->account.host);
889 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
891 @@ -573,6 +777,31 @@ void _mutt_select_file (char *f, size_t
893 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
896 + if (option (OPTNEWS))
899 + strfcpy (prefix, f, sizeof (prefix));
904 + /* default state for news reader mode is browse subscribed newsgroups */
906 + for (list = CurrentNewsSrv->list; list; list = list->next)
908 + NNTP_DATA *data = (NNTP_DATA *) list->data;
910 + if (data && data->subscribed)
922 mutt_expand_path (f, flen);
923 @@ -669,6 +898,9 @@ void _mutt_select_file (char *f, size_t
924 menu->tag = file_tag;
926 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
928 + (option (OPTNEWS)) ? FolderNewsHelp :
932 init_menu (&state, menu, title, sizeof (title), buffy);
933 @@ -807,7 +1039,11 @@ void _mutt_select_file (char *f, size_t
938 + if (buffy || option (OPTNEWS)) /* news have not path */
943 strfcpy (f, state.entry[menu->current].name, flen);
944 mutt_expand_path (f, flen);
945 @@ -865,14 +1101,6 @@ void _mutt_select_file (char *f, size_t
949 - case OP_BROWSER_SUBSCRIBE:
950 - imap_subscribe (state.entry[menu->current].name, 1);
953 - case OP_BROWSER_UNSUBSCRIBE:
954 - imap_subscribe (state.entry[menu->current].name, 0);
957 case OP_BROWSER_TOGGLE_LSUB:
958 if (option (OPTIMAPLSUB))
959 unset_option (OPTIMAPLSUB);
960 @@ -973,6 +1201,11 @@ void _mutt_select_file (char *f, size_t
962 case OP_CHANGE_DIRECTORY:
965 + if (option (OPTNEWS))
969 strfcpy (buf, LastDir, sizeof (buf));
971 if (!state.imap_browse)
972 @@ -1239,6 +1472,190 @@ void _mutt_select_file (char *f, size_t
974 mutt_error _("Error trying to view file");
981 + if (option (OPTNEWS))
983 + struct folder_file *f = &state.entry[menu->current];
986 + if (i == OP_CATCHUP)
987 + nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
989 + nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
994 + struct folder_file ff;
995 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
998 + folder.ff->name = f->name;
999 + folder.ff->st = NULL;
1000 + folder.ff->is_new = nd->new;
1001 + folder.ff->nd = nd;
1003 + mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1004 + newsgroup_format_str, (unsigned long) &folder,
1005 + M_FORMAT_ARROWCURSOR);
1006 + f->desc = safe_strdup (buffer); */
1007 + if (menu->current + 1 < menu->max)
1009 + menu->redraw = REDRAW_MOTION_RESYNCH;
1014 + case OP_LOAD_ACTIVE:
1015 + if (!option (OPTNEWS))
1022 + for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
1024 + if ((data = (NNTP_DATA *)tmp->data))
1025 + data->deleted = 1;
1028 + nntp_get_active (CurrentNewsSrv);
1030 + destroy_state (&state);
1032 + examine_mailboxes (menu, &state);
1034 + examine_directory (menu, &state, NULL, NULL);
1035 + init_menu (&state, menu, title, sizeof (title), buffy);
1037 +#endif /* USE_NNTP */
1039 +#if defined USE_IMAP || defined USE_NNTP
1040 + case OP_BROWSER_SUBSCRIBE:
1041 + case OP_BROWSER_UNSUBSCRIBE:
1044 + case OP_SUBSCRIBE_PATTERN:
1045 + case OP_UNSUBSCRIBE_PATTERN:
1046 + if (option (OPTNEWS))
1048 + regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1050 + int j = menu->current;
1052 + NNTP_SERVER *news = CurrentNewsSrv;
1054 + if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1060 + if (i == OP_SUBSCRIBE_PATTERN)
1061 + snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1063 + snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1064 + if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1070 + if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1072 + regerror (err, rx, buf, sizeof (buf));
1075 + mutt_error ("%s", buf);
1078 + menu->redraw = REDRAW_FULL;
1081 + else if (!state.entrylen)
1083 + mutt_error _("No newsgroups match the mask");
1087 + for ( ; j < state.entrylen; j++)
1089 + struct folder_file *f = &state.entry[j];
1091 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1092 + regexec (rx, f->name, 0, NULL, 0) == 0)
1094 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1095 + nd = mutt_newsgroup_subscribe (news, f->name);
1097 + nd = mutt_newsgroup_unsubscribe (news, f->name);
1101 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1103 + folder.name = f->name;
1105 + folder.new = nd->new;
1108 + mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1109 + newsgroup_format_str, (unsigned long) &folder,
1110 + M_FORMAT_ARROWCURSOR);
1111 + f->desc = safe_strdup (buffer);
1114 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1116 + if (menu->current + 1 < menu->max)
1118 + menu->redraw = REDRAW_MOTION_RESYNCH;
1122 + if (i == OP_SUBSCRIBE_PATTERN)
1124 + LIST *grouplist = NULL;
1127 + grouplist = news->list;
1128 + for (; grouplist; grouplist = grouplist->next)
1130 + nd = (NNTP_DATA *) grouplist->data;
1131 + if (nd && nd->group && !nd->subscribed)
1133 + if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1135 + mutt_newsgroup_subscribe (news, nd->group);
1136 + add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1140 + init_menu (&state, menu, title, sizeof (title), buffy);
1142 + mutt_newsrc_update (news);
1143 + nntp_clear_cacheindex (news);
1144 + if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1150 +#endif /* USE_IMAP && USE_NNTP */
1151 +#endif /* USE_NNTP */
1154 + if (i == OP_BROWSER_SUBSCRIBE)
1155 + imap_subscribe (state.entry[menu->current].name, 1);
1157 + imap_subscribe (state.entry[menu->current].name, 0);
1159 +#endif /* USE_IMAP */
1163 diff -udprP mutt-1.5.20.orig/browser.h mutt-1.5.20/browser.h
1164 --- mutt-1.5.20.orig/browser.h 2009-01-05 00:34:12.000000000 +0200
1165 +++ mutt-1.5.20/browser.h 2009-06-15 21:05:24.000000000 +0300
1168 #define _BROWSER_H 1
1177 @@ -37,6 +41,9 @@ struct folder_file
1178 unsigned selectable : 1;
1179 unsigned inferiors : 1;
1184 unsigned tagged : 1;
1187 diff -udprP mutt-1.5.20.orig/buffy.c mutt-1.5.20/buffy.c
1188 --- mutt-1.5.20.orig/buffy.c 2009-06-02 20:16:26.000000000 +0300
1189 +++ mutt-1.5.20/buffy.c 2009-06-15 21:05:24.000000000 +0300
1190 @@ -320,6 +320,9 @@ int mutt_buffy_check (int force)
1192 if (!Context || Context->magic != M_POP)
1195 + if (!Context || Context->magic != M_NNTP)
1197 /* check device ID and serial number instead of comparing paths */
1198 if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0)
1200 @@ -343,6 +346,11 @@ int mutt_buffy_check (int force)
1205 + if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1206 + tmp->magic = M_NNTP;
1209 if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
1210 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1212 @@ -360,25 +368,21 @@ int mutt_buffy_check (int force)
1213 /* check to see if the folder is the currently selected folder
1215 if (!Context || !Context->path ||
1216 -#if defined USE_IMAP || defined USE_POP
1221 - tmp->magic == M_IMAP
1222 + || tmp->magic == M_IMAP
1228 - tmp->magic == M_POP
1230 - ) ? mutt_strcmp (tmp->path, Context->path) :
1231 + || tmp->magic == M_POP
1233 - (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1234 -#if defined USE_IMAP || defined USE_POP
1237 + || tmp->magic == M_NNTP
1241 + ) ? mutt_strcmp (tmp->path, Context->path) :
1242 + (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1248 diff -udprP mutt-1.5.20.orig/complete.c mutt-1.5.20/complete.c
1249 --- mutt-1.5.20.orig/complete.c 2009-01-05 00:38:16.000000000 +0200
1250 +++ mutt-1.5.20/complete.c 2009-06-15 21:05:24.000000000 +0300
1252 #include "mailbox.h"
1261 @@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen)
1262 char filepart[_POSIX_PATH_MAX];
1264 char imap_path[LONG_STRING];
1267 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1270 + if (option (OPTNEWS))
1272 + LIST *l = CurrentNewsSrv->list;
1274 + strfcpy (filepart, s, sizeof (filepart));
1277 + * special case to handle when there is no filepart yet.
1278 + * find the first subscribed newsgroup
1280 + if ((len = mutt_strlen (filepart)) == 0)
1282 + for (; l; l = l->next)
1284 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1286 + if (data && data->subscribed)
1288 + strfcpy (filepart, data->group, sizeof (filepart));
1296 + for (; l; l = l->next)
1298 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1300 + if (data && data->subscribed &&
1301 + mutt_strncmp (data->group, filepart, len) == 0)
1305 + for (i = 0; filepart[i] && data->group[i]; i++)
1307 + if (filepart[i] != data->group[i])
1317 + strfcpy (filepart, data->group, sizeof (filepart));
1323 + strcpy (s, filepart);
1325 + return (init ? 0 : -1);
1330 /* we can use '/' as a delimiter, imap_complete rewrites it */
1331 if (*s == '=' || *s == '+' || *s == '!')
1333 diff -udprP mutt-1.5.20.orig/compose.c mutt-1.5.20/compose.c
1334 --- mutt-1.5.20.orig/compose.c 2009-03-31 09:52:43.000000000 +0300
1335 +++ mutt-1.5.20/compose.c 2009-06-15 21:05:24.000000000 +0300
1337 #include "mailbox.h"
1339 #include "charset.h"
1343 #include "remailer.h"
1352 @@ -60,18 +65,21 @@ enum
1369 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1372 -#define HDR_XOFFSET 10
1373 -#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1374 +#define HDR_XOFFSET 14
1375 +#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1376 #define W (COLS - HDR_XOFFSET)
1378 static char *Prompts[] =
1379 @@ -83,6 +91,16 @@ static char *Prompts[] =
1395 static struct mapping_t ComposeHelp[] = {
1396 @@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] =
1401 +static struct mapping_t ComposeNewsHelp[] = {
1402 + { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1403 + { N_("Abort"), OP_EXIT },
1404 + { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1405 + { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1406 + { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1407 + { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1408 + { N_("Help"), OP_HELP },
1413 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1415 mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt,
1416 @@ -115,16 +146,16 @@ static void redraw_crypt_lines (HEADER *
1417 if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
1420 - mvaddstr (HDR_CRYPT, 0, "Security: ");
1421 + mvaddstr (HDR_CRYPT, 0, " Security: ");
1422 else if (msg->security & APPLICATION_SMIME)
1423 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1424 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1425 else if (msg->security & APPLICATION_PGP)
1426 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1427 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1429 else if ((WithCrypto & APPLICATION_SMIME))
1430 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1431 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1432 else if ((WithCrypto & APPLICATION_PGP))
1433 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1434 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1438 @@ -252,9 +283,28 @@ static void draw_envelope_addr (int line
1439 static void draw_envelope (HEADER *msg, char *fcc)
1441 draw_envelope_addr (HDR_FROM, msg->env->from);
1443 + if (!option (OPTNEWSSEND))
1446 draw_envelope_addr (HDR_TO, msg->env->to);
1447 draw_envelope_addr (HDR_CC, msg->env->cc);
1448 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1453 + mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1454 + mutt_paddstr (W, NONULL (msg->env->newsgroups));
1455 + mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1456 + mutt_paddstr (W, NONULL (msg->env->followup_to));
1457 + if (option (OPTXCOMMENTTO))
1459 + mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1460 + mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1464 mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1465 mutt_paddstr (W, NONULL (msg->env->subject));
1466 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1467 @@ -507,6 +557,12 @@ int mutt_compose_menu (HEADER *msg, /*
1468 /* Sort, SortAux could be changed in mutt_index_menu() */
1469 int oldSort, oldSortAux;
1472 + int news = 0; /* is it a news article ? */
1474 + if (option (OPTNEWSSEND))
1478 mutt_attach_init (msg->content);
1479 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
1480 @@ -517,10 +573,18 @@ int mutt_compose_menu (HEADER *msg, /*
1481 menu->make_entry = snd_entry;
1482 menu->tag = mutt_tag_attach;
1486 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1489 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1494 + unset_option (OPTNEWS); /* for any case */
1496 switch (op = mutt_menuLoop (menu))
1499 @@ -533,17 +597,87 @@ int mutt_compose_menu (HEADER *msg, /*
1500 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1502 case OP_COMPOSE_EDIT_TO:
1507 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1508 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1510 case OP_COMPOSE_EDIT_BCC:
1515 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1516 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1518 case OP_COMPOSE_EDIT_CC:
1523 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1524 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1527 + case OP_COMPOSE_EDIT_NEWSGROUPS:
1530 + if (msg->env->newsgroups)
1531 + strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1534 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1536 + FREE (&msg->env->newsgroups);
1537 + mutt_remove_trailing_ws (buf);
1538 + msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1539 + move (HDR_TO, HDR_XOFFSET);
1541 + if (msg->env->newsgroups)
1542 + printw ("%-*.*s", W, W, msg->env->newsgroups);
1547 + case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1551 + if (msg->env->followup_to)
1552 + strfcpy (buf, msg->env->followup_to, sizeof (buf));
1553 + if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1555 + FREE (&msg->env->followup_to);
1556 + mutt_remove_trailing_ws (buf);
1557 + msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1558 + move (HDR_CC, HDR_XOFFSET);
1560 + if (msg->env->followup_to)
1561 + printw ("%-*.*s", W, W, msg->env->followup_to);
1566 + case OP_COMPOSE_EDIT_X_COMMENT_TO:
1567 + if (news && option (OPTXCOMMENTTO))
1570 + if (msg->env->x_comment_to)
1571 + strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1572 + if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1574 + FREE (&msg->env->x_comment_to);
1575 + msg->env->x_comment_to = safe_strdup (buf);
1576 + move (HDR_BCC, HDR_XOFFSET);
1578 + if (msg->env->x_comment_to)
1579 + printw ("%-*.*s", W, W, msg->env->x_comment_to);
1584 case OP_COMPOSE_EDIT_SUBJECT:
1585 if (msg->env->subject)
1586 strfcpy (buf, msg->env->subject, sizeof (buf));
1587 @@ -706,6 +840,9 @@ int mutt_compose_menu (HEADER *msg, /*
1590 case OP_COMPOSE_ATTACH_MESSAGE:
1592 + case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1597 @@ -713,7 +850,22 @@ int mutt_compose_menu (HEADER *msg, /*
1599 prompt = _("Open mailbox to attach message from");
1602 + unset_option (OPTNEWS);
1603 + if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1605 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1608 + prompt = _("Open newsgroup to attach message from");
1609 + set_option (OPTNEWS);
1615 + if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1618 strfcpy (fname, NONULL (Context->path), sizeof (fname));
1619 mutt_pretty_mailbox (fname, sizeof (fname));
1620 @@ -722,6 +874,11 @@ int mutt_compose_menu (HEADER *msg, /*
1621 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1625 + if (option (OPTNEWS))
1626 + nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1629 mutt_expand_path (fname, sizeof (fname));
1631 if (!mx_is_imap (fname))
1632 @@ -729,6 +886,9 @@ int mutt_compose_menu (HEADER *msg, /*
1634 if (!mx_is_pop (fname))
1637 + if (!mx_is_nntp (fname) && !option (OPTNEWS))
1639 /* check to make sure the file exists and is readable */
1640 if (access (fname, R_OK) == -1)
1642 diff -udprP mutt-1.5.20.orig/config.h.in mutt-1.5.20/config.h.in
1643 --- mutt-1.5.20.orig/config.h.in 2009-06-09 09:51:15.000000000 +0300
1644 +++ mutt-1.5.20/config.h.in 2009-06-15 21:05:24.000000000 +0300
1646 significant more memory when defined. */
1647 #undef EXACT_ADDRESS
1649 +/* Compiling with newsreading support with NNTP */
1652 /* program to use for shell commands */
1655 diff -udprP mutt-1.5.20.orig/configure.ac mutt-1.5.20/configure.ac
1656 --- mutt-1.5.20.orig/configure.ac 2009-06-09 09:50:33.000000000 +0300
1657 +++ mutt-1.5.20/configure.ac 2009-06-15 21:05:24.000000000 +0300
1658 @@ -599,6 +599,14 @@ if test x"$need_imap" = xyes -o x"$need_
1659 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1662 +AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1663 +[ if test x$enableval = xyes ; then
1664 + AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1665 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1670 dnl -- end socket dependencies --
1672 if test "$need_socket" = "yes"
1673 diff -udprP mutt-1.5.20.orig/curs_main.c mutt-1.5.20/curs_main.c
1674 --- mutt-1.5.20.orig/curs_main.c 2009-06-14 05:48:36.000000000 +0300
1675 +++ mutt-1.5.20/curs_main.c 2009-06-15 21:47:09.000000000 +0300
1679 #include "mutt_curses.h"
1681 #include "mutt_menu.h"
1682 #include "mailbox.h"
1683 #include "mapping.h"
1686 #include "mutt_crypt.h"
1695 @@ -413,12 +418,27 @@ static struct mapping_t IndexHelp[] = {
1700 +struct mapping_t IndexNewsHelp[] = {
1701 + { N_("Quit"), OP_QUIT },
1702 + { N_("Del"), OP_DELETE },
1703 + { N_("Undel"), OP_UNDELETE },
1704 + { N_("Save"), OP_SAVE },
1705 + { N_("Post"), OP_POST },
1706 + { N_("Followup"), OP_FOLLOWUP },
1707 + { N_("Catchup"), OP_CATCHUP },
1708 + { N_("Help"), OP_HELP },
1713 /* This function handles the message index window as well as commands returned
1714 * from the pager (MENU_PAGER).
1716 int mutt_index_menu (void)
1718 char buf[LONG_STRING], helpstr[LONG_STRING];
1721 int done = 0; /* controls when to exit the "event" loop */
1723 @@ -439,7 +459,11 @@ int mutt_index_menu (void)
1724 menu->make_entry = index_make_entry;
1725 menu->color = index_color;
1726 menu->current = ci_first_message ();
1727 - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1728 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1730 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1735 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
1736 @@ -690,6 +714,9 @@ int mutt_index_menu (void)
1737 imap_disallow_reopen (Context);
1741 + unset_option (OPTNEWS); /* for any case */
1746 @@ -740,6 +767,120 @@ int mutt_index_menu (void)
1747 menu_current_bottom (menu);
1751 + case OP_GET_MESSAGE:
1752 + case OP_GET_PARENT:
1754 + if (Context->magic == M_NNTP)
1758 + if (op == OP_GET_MESSAGE)
1761 + if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1767 + LIST *ref = CURHDR->env->references;
1770 + mutt_error _("Article has no parent reference!");
1773 + strfcpy (buf, ref->data, sizeof (buf));
1775 + if (!Context->id_hash)
1776 + Context->id_hash = mutt_make_id_hash (Context);
1777 + if ((h = hash_find (Context->id_hash, buf)))
1779 + if (h->virtual != -1)
1781 + menu->current = h->virtual;
1782 + menu->redraw = REDRAW_MOTION_RESYNCH;
1784 + else if (h->collapsed)
1786 + mutt_uncollapse_thread (Context, h);
1787 + mutt_set_virtual (Context);
1788 + menu->current = h->virtual;
1789 + menu->redraw = REDRAW_MOTION_RESYNCH;
1792 + mutt_error _("Message not visible in limited view.");
1796 + if (nntp_check_msgid (Context, buf) == 0)
1798 + h = Context->hdrs[Context->msgcount-1];
1799 + mutt_sort_headers (Context, 0);
1800 + menu->current = h->virtual;
1801 + menu->redraw = REDRAW_FULL;
1804 + mutt_error (_("Article %s not found on server"), buf);
1809 + case OP_GET_CHILDREN:
1810 + case OP_RECONSTRUCT_THREAD:
1812 + if (Context->magic == M_NNTP)
1815 + int old = CURHDR->index, i;
1817 + if (!CURHDR->env->message_id)
1819 + mutt_error _("No Message-Id. Unable to perform operation");
1823 + if (!Context->id_hash)
1824 + Context->id_hash = mutt_make_id_hash (Context);
1825 + strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1827 + if (op == OP_RECONSTRUCT_THREAD)
1829 + LIST *ref = CURHDR->env->references;
1832 + nntp_check_msgid (Context, ref->data);
1833 + /* the last msgid in References is the root message */
1835 + strfcpy (buf, ref->data, sizeof (buf));
1839 + mutt_message _("Check for children of message...");
1840 + if (nntp_check_children (Context, buf) == 0)
1842 + mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1843 + h = hash_find (Context->id_hash, buf);
1844 + /* if the root message was retrieved, move to it */
1846 + menu->current = h->virtual;
1847 + else /* try to restore old position */
1848 + for (i = 0; i < Context->msgcount; i++)
1849 + if (Context->hdrs[i]->index == old)
1851 + menu->current = Context->hdrs[i]->virtual;
1852 + /* As an added courtesy, recenter the menu
1853 + * with the current entry at the middle of the screen */
1854 + menu_check_recenter (menu);
1855 + menu_current_middle (menu);
1858 + menu->redraw = REDRAW_FULL;
1859 + mutt_clear_error ();
1867 @@ -836,11 +977,33 @@ int mutt_index_menu (void)
1871 + case OP_TOGGLE_READ:
1874 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1876 - if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1877 + if (op == OP_TOGGLE_READ)
1879 + char buf[LONG_STRING];
1881 + if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1883 + snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1884 + Context->pattern ? Context->pattern : ".*");
1885 + set_option (OPTHIDEREAD);
1889 + strfcpy (buf, Context->pattern + 8, sizeof(buf));
1890 + if (!*buf || strncmp (buf, ".*", 2) == 0)
1891 + snprintf (buf, sizeof(buf), "~A");
1892 + unset_option (OPTHIDEREAD);
1894 + FREE (&Context->pattern);
1895 + Context->pattern = safe_strdup (buf);
1897 + if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1898 + mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1900 if (menu->oldcurrent >= 0)
1902 @@ -1057,15 +1220,22 @@ int mutt_index_menu (void)
1904 case OP_MAIN_CHANGE_FOLDER:
1905 case OP_MAIN_NEXT_UNREAD_MAILBOX:
1908 - op = OP_MAIN_CHANGE_FOLDER_READONLY;
1910 - /* fallback to the readonly case */
1912 case OP_MAIN_CHANGE_FOLDER_READONLY:
1914 + case OP_MAIN_CHANGE_GROUP:
1915 + case OP_MAIN_CHANGE_GROUP_READONLY:
1916 + unset_option (OPTNEWS);
1918 + if (attach_msg || option (OPTREADONLY) ||
1920 + op == OP_MAIN_CHANGE_GROUP_READONLY ||
1922 + op == OP_MAIN_CHANGE_FOLDER_READONLY)
1923 + flags = M_READONLY;
1927 - if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1929 cp = _("Open mailbox in read-only mode");
1931 cp = _("Open mailbox");
1932 @@ -1084,6 +1254,21 @@ int mutt_index_menu (void)
1937 + if (op == OP_MAIN_CHANGE_GROUP ||
1938 + op == OP_MAIN_CHANGE_GROUP_READONLY)
1940 + set_option (OPTNEWS);
1941 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1944 + cp = _("Open newsgroup in read-only mode");
1946 + cp = _("Open newsgroup");
1951 mutt_buffy (buf, sizeof (buf));
1953 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1954 @@ -1103,6 +1288,14 @@ int mutt_index_menu (void)
1959 + if (option (OPTNEWS))
1961 + unset_option (OPTNEWS);
1962 + nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1966 mutt_expand_path (buf, sizeof (buf));
1967 if (mx_get_magic (buf) <= 0)
1969 @@ -1140,15 +1333,18 @@ int mutt_index_menu (void)
1970 CurrentMenu = MENU_MAIN;
1971 mutt_folder_hook (buf);
1973 - if ((Context = mx_open_mailbox (buf,
1974 - (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1975 - M_READONLY : 0, NULL)) != NULL)
1976 + if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1978 menu->current = ci_first_message ();
1984 + /* mutt_buffy_check() must be done with mail-reader mode! */
1985 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1986 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1988 mutt_clear_error ();
1989 mutt_buffy_check(1); /* force the buffy check after we have changed
1991 @@ -1519,6 +1715,15 @@ int mutt_index_menu (void)
1993 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1996 + if (Context->magic == M_NNTP)
1999 + mutt_error _("Can't change 'important' flag on NNTP server.");
2006 for (j = 0; j < Context->vcount; j++)
2007 @@ -1866,6 +2071,17 @@ int mutt_index_menu (void)
2013 + if (Context && Context->magic == M_NNTP)
2015 + if (mutt_newsgroup_catchup (CurrentNewsSrv,
2016 + ((NNTP_DATA *)Context->data)->group))
2017 + menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2022 case OP_DISPLAY_ADDRESS:
2025 @@ -1993,6 +2209,15 @@ int mutt_index_menu (void)
2026 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2031 + if (Context->magic == M_NNTP)
2034 + mutt_error _("Can't edit message on newsserver.");
2039 MAYBE_REDRAW (menu->redraw);
2041 @@ -2065,6 +2290,41 @@ int mutt_index_menu (void)
2042 menu->redraw = REDRAW_FULL;
2047 + case OP_FORWARD_TO_GROUP:
2055 + if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2056 + mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2057 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2059 + if (Context && Context->magic == M_NNTP &&
2060 + !((NNTP_DATA *)Context->data)->allowed &&
2061 + query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2063 + if (op == OP_POST)
2064 + ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2068 + if (op == OP_FOLLOWUP)
2069 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2070 + tag ? NULL : CURHDR);
2072 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2073 + tag ? NULL : CURHDR);
2075 + menu->redraw = REDRAW_FULL;
2083 @@ -2140,6 +2400,12 @@ int mutt_index_menu (void)
2085 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2088 + /* Close all open NNTP connections */
2090 + nntp_logout_all ();
2093 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2094 op == OP_UNDELETE_THREAD ? 0 : 1);
2096 diff -udprP mutt-1.5.20.orig/doc/manual.xml.head mutt-1.5.20/doc/manual.xml.head
2097 --- mutt-1.5.20.orig/doc/manual.xml.head 2009-05-30 20:20:08.000000000 +0300
2098 +++ mutt-1.5.20/doc/manual.xml.head 2009-06-15 21:05:24.000000000 +0300
2099 @@ -1568,6 +1568,22 @@ fo-table</literal> for details.
2104 +<title>Reading news via NNTP</title>
2107 +If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2108 +read news from newsserver via NNTP. You can open a newsgroup with
2109 +function ``change-newsgroup'' (default: ``i''). Default newsserver
2110 +can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2111 +variable. Like other news readers, info about subscribed newsgroups
2112 +is saved in file by <link linkend="newsrc">$newsrc</link>
2113 +variable. Article headers are cached and can be loaded from file when
2114 +newsgroup entered instead loading from newsserver.
2121 <sect1 id="forwarding-mail">
2122 diff -udprP mutt-1.5.20.orig/doc/mutt.man mutt-1.5.20/doc/mutt.man
2123 --- mutt-1.5.20.orig/doc/mutt.man 2009-06-07 03:32:44.000000000 +0300
2124 +++ mutt-1.5.20/doc/mutt.man 2009-06-15 21:07:47.000000000 +0300
2125 @@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2130 -[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2132 +[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-g \fIserver\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2136 @@ -101,6 +101,10 @@ files.
2137 Specify which mailbox to load.
2138 .IP "-F \fImuttrc\fP"
2139 Specify an initialization file to read instead of ~/.muttrc
2140 +.IP "-g \fIserver\fP"
2141 +Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2143 +Start Mutt with a listing of subscribed newsgroups.
2146 .IP "-H \fIdraft\fP"
2147 diff -udprP mutt-1.5.20.orig/functions.h mutt-1.5.20/functions.h
2148 --- mutt-1.5.20.orig/functions.h 2009-04-30 08:36:17.000000000 +0300
2149 +++ mutt-1.5.20/functions.h 2009-06-15 21:05:24.000000000 +0300
2150 @@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in
2151 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2152 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2153 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2155 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2156 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2158 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2159 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2160 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
2161 @@ -101,7 +105,15 @@ struct binding_t OpMain[] = { /* map: in
2162 { "edit", OP_EDIT_MESSAGE, "e" },
2163 { "edit-type", OP_EDIT_TYPE, "\005" },
2164 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2165 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2167 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2168 + { "followup-message", OP_FOLLOWUP, "F" },
2169 + { "get-children", OP_GET_CHILDREN, NULL },
2170 + { "get-message", OP_GET_MESSAGE, "\007" },
2171 + { "get-parent", OP_GET_PARENT, "\033G" },
2172 + { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2174 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2175 { "group-reply", OP_GROUP_REPLY, "g" },
2177 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2178 @@ -127,6 +139,9 @@ struct binding_t OpMain[] = { /* map: in
2179 { "sort-mailbox", OP_SORT, "o" },
2180 { "sort-reverse", OP_SORT_REVERSE, "O" },
2181 { "print-message", OP_PRINT, "p" },
2183 + { "post-message", OP_POST, "P" },
2185 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2186 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2187 { "recall-message", OP_RECALL_MESSAGE, "R" },
2188 @@ -146,6 +161,10 @@ struct binding_t OpMain[] = { /* map: in
2189 { "show-version", OP_VERSION, "V" },
2190 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2191 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2192 + { "toggle-read", OP_TOGGLE_READ, "X" },
2194 + { "catchup", OP_CATCHUP, "y" },
2196 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2197 { "buffy-list", OP_BUFFY_LIST, "." },
2198 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
2199 @@ -157,7 +176,7 @@ struct binding_t OpMain[] = { /* map: in
2200 { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" },
2201 { "next-unread", OP_MAIN_NEXT_UNREAD, NULL },
2202 { "previous-unread", OP_MAIN_PREV_UNREAD, NULL },
2203 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2204 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2207 { "extract-keys", OP_EXTRACT_KEYS, "\013" },
2208 @@ -177,6 +196,10 @@ struct binding_t OpPager[] = { /* map: p
2209 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2210 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2211 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2213 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2214 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2216 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2217 { "copy-message", OP_COPY_MESSAGE, "C" },
2218 { "decode-copy", OP_DECODE_COPY, "\033C" },
2219 @@ -187,8 +210,12 @@ struct binding_t OpPager[] = { /* map: p
2220 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2221 { "edit", OP_EDIT_MESSAGE, "e" },
2222 { "edit-type", OP_EDIT_TYPE, "\005" },
2224 + { "followup-message", OP_FOLLOWUP, "F" },
2225 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2227 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2228 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2229 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2230 { "group-reply", OP_GROUP_REPLY, "g" },
2232 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
2233 @@ -207,6 +234,9 @@ struct binding_t OpPager[] = { /* map: p
2234 { "next-thread", OP_MAIN_NEXT_THREAD, "\016" },
2235 { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" },
2236 { "print-message", OP_PRINT, "p" },
2238 + { "post-message", OP_POST, "P" },
2240 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2241 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2242 { "quit", OP_QUIT, "Q" },
2243 @@ -254,7 +284,7 @@ struct binding_t OpPager[] = { /* map: p
2244 { "half-down", OP_HALF_DOWN, NULL },
2245 { "previous-line", OP_PREV_LINE, NULL },
2246 { "bottom", OP_PAGER_BOTTOM, NULL },
2247 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2248 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2252 @@ -275,6 +305,10 @@ struct binding_t OpAttach[] = { /* map:
2253 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2254 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2255 { "edit-type", OP_EDIT_TYPE, "\005" },
2257 + { "followup-message", OP_FOLLOWUP, "F" },
2258 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2260 { "print-entry", OP_PRINT, "p" },
2261 { "save-entry", OP_SAVE, "s" },
2262 { "pipe-entry", OP_PIPE, "|" },
2263 @@ -300,6 +334,7 @@ struct binding_t OpAttach[] = { /* map:
2264 struct binding_t OpCompose[] = { /* map: compose */
2265 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2266 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2267 + { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2268 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2269 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2270 { "copy-file", OP_SAVE, "C" },
2271 @@ -319,6 +354,11 @@ struct binding_t OpCompose[] = { /* map:
2272 { "print-entry", OP_PRINT, "l" },
2273 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2274 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2276 + { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2277 + { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2278 + { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2280 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2281 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2282 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
2283 @@ -370,14 +410,25 @@ struct binding_t OpBrowser[] = { /* map:
2284 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2285 { "check-new", OP_CHECK_NEW, NULL },
2286 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2288 + { "reload-active", OP_LOAD_ACTIVE, "g" },
2289 + { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2290 + { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2291 + { "catchup", OP_CATCHUP, "y" },
2292 + { "uncatchup", OP_UNCATCHUP, "Y" },
2294 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2295 { "buffy-list", OP_BUFFY_LIST, "." },
2297 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2298 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2299 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2301 +#if defined USE_IMAP || defined USE_NNTP
2302 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2303 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2306 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2309 diff -udprP mutt-1.5.20.orig/globals.h mutt-1.5.20/globals.h
2310 --- mutt-1.5.20.orig/globals.h 2009-06-03 23:48:31.000000000 +0300
2311 +++ mutt-1.5.20/globals.h 2009-06-15 21:05:24.000000000 +0300
2312 @@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
2315 WHERE char *Muttrc INITVAL (NULL);
2317 +WHERE char *NewsCacheDir;
2318 +WHERE char *GroupFormat;
2320 +WHERE char *NewsServer;
2321 +WHERE char *NntpUser;
2322 +WHERE char *NntpPass;
2323 +WHERE char *NewsRc;
2327 WHERE char *PagerFmt;
2328 @@ -188,6 +197,11 @@ extern unsigned char QuadOptions[];
2330 WHERE unsigned short Counter INITVAL (0);
2333 +WHERE short NewsPollTimeout;
2334 +WHERE short NntpContext;
2337 WHERE short ConnectTimeout;
2338 WHERE short HistSize;
2339 WHERE short MenuContext;
2340 diff -udprP mutt-1.5.20.orig/hash.c mutt-1.5.20/hash.c
2341 --- mutt-1.5.20.orig/hash.c 2009-03-31 09:52:43.000000000 +0300
2342 +++ mutt-1.5.20/hash.c 2009-06-15 21:19:59.000000000 +0300
2343 @@ -57,6 +57,7 @@ HASH *hash_create (int nelem, int lower)
2346 table->nelem = nelem;
2347 + table->curnelem = 0;
2348 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2351 @@ -71,6 +72,29 @@ HASH *hash_create (int nelem, int lower)
2355 +HASH *hash_resize (HASH *ptr, int nelem, int lower)
2358 + struct hash_elem *elem, *tmp;
2361 + table = hash_create (nelem, lower);
2363 + for (i = 0; i < ptr->nelem; i++)
2365 + for (elem = ptr->table[i]; elem; )
2368 + elem = elem->next;
2369 + hash_insert (table, tmp->key, tmp->data, 1);
2373 + FREE (&ptr->table);
2378 /* table hash table to update
2379 * key key to hash on
2380 * data data to associate with `key'
2381 @@ -90,6 +114,7 @@ int hash_insert (HASH * table, const cha
2383 ptr->next = table->table[h];
2384 table->table[h] = ptr;
2385 + table->curnelem++;
2389 @@ -112,6 +137,7 @@ int hash_insert (HASH * table, const cha
2391 table->table[h] = ptr;
2393 + table->curnelem++;
2397 @@ -142,6 +168,7 @@ void hash_delete_hash (HASH * table, int
2399 destroy (ptr->data);
2401 + table->curnelem--;
2405 diff -udprP mutt-1.5.20.orig/hash.h mutt-1.5.20/hash.h
2406 --- mutt-1.5.20.orig/hash.h 2009-03-31 09:52:43.000000000 +0300
2407 +++ mutt-1.5.20/hash.h 2009-06-15 21:05:24.000000000 +0300
2408 @@ -28,7 +28,7 @@ struct hash_elem
2413 + int nelem, curnelem;
2414 struct hash_elem **table;
2415 unsigned int (*hash_string)(const unsigned char *, unsigned int);
2416 int (*cmp_string)(const char *, const char *);
2417 @@ -41,6 +41,7 @@ HASH;
2419 HASH *hash_create (int nelem, int lower);
2420 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2421 +HASH *hash_resize (HASH * table, int nelem, int lower);
2422 void *hash_find_hash (const HASH * table, int hash, const char *key);
2423 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2424 void (*destroy) (void *));
2425 diff -udprP mutt-1.5.20.orig/hdrline.c mutt-1.5.20/hdrline.c
2426 --- mutt-1.5.20.orig/hdrline.c 2009-04-13 19:24:55.000000000 +0300
2427 +++ mutt-1.5.20/hdrline.c 2009-06-15 21:05:24.000000000 +0300
2428 @@ -211,6 +211,7 @@ int mutt_user_is_recipient (HEADER *h)
2429 * %E = number of messages in current thread
2430 * %f = entire from line
2431 * %F = like %n, unless from self
2432 + * %g = newsgroup name (if compiled with nntp support)
2434 * %l = number of lines in the message
2435 * %L = like %F, except `lists' are displayed first
2436 @@ -219,12 +220,14 @@ int mutt_user_is_recipient (HEADER *h)
2438 * %O = like %L, except using address instead of name
2439 * %P = progress indicator for builtin pager
2440 + * %R = `x-comment-to:' field (if present and compiled with nntp support)
2442 * %S = short message status (e.g., N/O/D/!/r/-)
2443 * %t = `to:' field (recipients)
2445 * %u = user (login) name of author
2446 * %v = first name of author, unless from self
2447 + * %W = where user is (organization)
2448 * %X = number of MIME attachments
2449 * %y = `x-label:' field (if present)
2450 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2451 @@ -457,6 +460,12 @@ hdr_format_str (char *dest,
2457 + mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2462 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2464 @@ -548,6 +557,15 @@ hdr_format_str (char *dest,
2465 strfcpy(dest, NONULL(hfi->pager_progress), destlen);
2471 + mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2472 + else if (!hdr->env->x_comment_to)
2479 if (flags & M_FORMAT_TREE && !hdr->collapsed)
2480 @@ -637,6 +655,13 @@ hdr_format_str (char *dest,
2481 mutt_format_s (dest, destlen, prefix, buf2);
2486 + mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2487 + else if (!hdr->env->organization)
2494 diff -udprP mutt-1.5.20.orig/headers.c mutt-1.5.20/headers.c
2495 --- mutt-1.5.20.orig/headers.c 2009-04-30 08:36:17.000000000 +0300
2496 +++ mutt-1.5.20/headers.c 2009-06-15 21:17:07.000000000 +0300
2497 @@ -114,6 +114,9 @@ void mutt_edit_headers (const char *edit
2498 $edit_headers set, we remove References: as they're likely invalid;
2499 we can simply compare strings as we don't generate References for
2500 multiple Message-Ids in IRT anyways */
2502 + if (!option (OPTNEWSSEND))
2504 if (!n->in_reply_to || (msg->env->in_reply_to &&
2505 mutt_strcmp (n->in_reply_to->data,
2506 msg->env->in_reply_to->data) != 0))
2507 diff -udprP mutt-1.5.20.orig/init.c mutt-1.5.20/init.c
2508 --- mutt-1.5.20.orig/init.c 2009-06-01 19:29:32.000000000 +0300
2509 +++ mutt-1.5.20/init.c 2009-06-15 21:05:24.000000000 +0300
2510 @@ -2966,6 +2966,28 @@ void mutt_init (int skip_sys_rc, LIST *c
2512 Fqdn = safe_strdup(NONULL(Hostname));
2519 + if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2522 + fgets (buffer, sizeof (buffer), f);
2526 + while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2528 + NewsServer = safe_strdup (p);
2532 + if ((p = getenv ("NNTPSERVER")))
2533 + NewsServer = safe_strdup (p);
2536 if ((p = getenv ("MAIL")))
2537 Spoolfile = safe_strdup (p);
2538 else if ((p = getenv ("MAILDIR")))
2539 diff -udprP mutt-1.5.20.orig/init.h mutt-1.5.20/init.h
2540 --- mutt-1.5.20.orig/init.h 2009-06-14 00:35:21.000000000 +0300
2541 +++ mutt-1.5.20/init.h 2009-06-15 21:15:03.000000000 +0300
2542 @@ -176,6 +176,20 @@ struct option_t MuttVars[] = {
2543 ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before
2544 ** editing the body of an outgoing message.
2547 + { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2550 + ** If set, Mutt will prompt you for follow-up groups before editing
2551 + ** the body of an outgoing message.
2553 + { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2556 + ** If set, Mutt will prompt you for x-comment-to field before editing
2557 + ** the body of an outgoing message.
2560 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2563 @@ -322,6 +336,14 @@ struct option_t MuttVars[] = {
2564 ** follow these menus. The option is \fIunset\fP by default because many
2565 ** visual terminals don't permit making the cursor invisible.
2568 + { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2571 + ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2572 + ** as read when you quit the newsgroup (catchup newsgroup).
2575 #if defined(USE_SSL)
2576 { "certificate_file", DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" },
2578 @@ -797,6 +819,16 @@ struct option_t MuttVars[] = {
2579 ** sent to both the list and your address, resulting in two copies
2580 ** of the same email for you.
2583 + { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2586 + ** If this variable is \fIset\fP and the keyword "poster" is present in
2587 + ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2588 + ** permitted. The message will be mailed to the submitter of the
2589 + ** message via mail.
2592 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2595 @@ -879,6 +911,27 @@ struct option_t MuttVars[] = {
2596 ** a regular expression that will match the whole name so mutt will expand
2597 ** ``Franklin'' to ``Franklin, Steve''.
2600 + { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2603 + ** This variable allows you to customize the newsgroup browser display to
2604 + ** your personal taste. This string is similar to ``$index_format'', but
2605 + ** has its own set of printf()-like sequences:
2608 + ** %C current newsgroup number
2609 + ** %d description of newsgroup (becomes from server)
2610 + ** %f newsgroup name
2611 + ** %M - if newsgroup not allowed for direct post (moderated for example)
2612 + ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2613 + ** %n number of new articles in newsgroup
2614 + ** %s number of unread articles in newsgroup
2615 + ** %>X right justify the rest of the string and pad with character "X"
2616 + ** %|X pad to the end of the line with character "X"
2620 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2623 @@ -1255,6 +1308,7 @@ struct option_t MuttVars[] = {
2624 ** .dt %E .dd number of messages in current thread
2625 ** .dt %f .dd sender (address + real name), either From: or Return-Path:
2626 ** .dt %F .dd author name, or recipient name if the message is from you
2627 + ** .dt %g .dd newsgroup name (if compiled with nntp support)
2628 ** .dt %H .dd spam attribute(s) of this message
2629 ** .dt %i .dd message-id of the current message
2630 ** .dt %l .dd number of lines in the message (does not work with maildir,
2631 @@ -1270,12 +1324,14 @@ struct option_t MuttVars[] = {
2632 ** stashed the message: list name or recipient name
2633 ** if not sent to a list
2634 ** .dt %P .dd progress indicator for the builtin pager (how much of the file has been displayed)
2635 + ** .dt %R .dd `x-comment-to:' field (if present and compiled with nntp support)
2636 ** .dt %s .dd subject of the message
2637 ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as)
2638 ** .dt %t .dd ``To:'' field (recipients)
2639 ** .dt %T .dd the appropriate character from the $$to_chars string
2640 ** .dt %u .dd user (login) name of the author
2641 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2642 + ** .dt %W .dd name of organization of author (`organization:' field)
2643 ** .dt %X .dd number of attachments
2644 ** (please see the ``$attachments'' section for possible speed effects)
2645 ** .dt %y .dd ``X-Label:'' field, if present
2646 @@ -1310,6 +1366,21 @@ struct option_t MuttVars[] = {
2647 ** Note that these expandos are supported in
2648 ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too.
2651 + { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2654 + ** If set, specifies the program and arguments used to deliver news posted
2655 + ** by Mutt. Otherwise, mutt posts article using current connection to
2656 + ** news server. The following printf-style sequence is understood:
2659 + ** %s newsserver name
2662 + ** Example: set inews="/usr/local/bin/inews -hS"
2665 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2668 @@ -1533,6 +1604,15 @@ struct option_t MuttVars[] = {
2669 ** menu, attachments which cannot be decoded in a reasonable manner will
2670 ** be attached to the newly composed message if this option is \fIset\fP.
2673 + { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2676 + ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2677 + ** encoded according to RFC2047 to base64. This is useful when message
2678 + ** is Usenet article, because MIME for news is nonstandard feature.
2682 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2684 @@ -1580,6 +1660,77 @@ struct option_t MuttVars[] = {
2685 ** See also $$read_inc, $$write_inc and $$net_inc.
2689 + { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2692 + ** This variable pointing to directory where Mutt will save cached news
2693 + ** articles headers in. If \fIunset\fP, headers will not be saved at all
2694 + ** and will be reloaded each time when you enter to newsgroup.
2696 + { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2699 + ** This variable specifies domain name or address of NNTP server. It
2700 + ** defaults to the newsserver specified in the environment variable
2701 + ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2702 + ** specify username and an alternative port for each newsserver, ie:
2704 + ** [news[s]://][username[:password]@]newsserver[:port]
2706 + { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2709 + ** The file, containing info about subscribed newsgroups - names and
2710 + ** indexes of read articles. The following printf-style sequence
2714 + ** %s newsserver name
2717 + { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2720 + ** This variable defines number of articles which will be in index when
2721 + ** newsgroup entered. If active newsgroup have more articles than this
2722 + ** number, oldest articles will be ignored. Also controls how many
2723 + ** articles headers will be saved in cache when you quit newsgroup.
2725 + { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2728 + ** This variable controls whether or not descriptions for each newsgroup
2729 + ** must be loaded when newsgroup is added to list (first time list
2730 + ** loading or new newsgroup adding).
2732 + { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2735 + ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2736 + ** authentification, Mutt will prompt you for your account name when you
2737 + ** connect to newsserver.
2739 + { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2742 + ** Your password for NNTP account.
2744 + { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2747 + ** The time in seconds until any operations on newsgroup except post new
2748 + ** article will cause recheck for new news. If set to 0, Mutt will
2749 + ** recheck newsgroup on each operation in index (stepping, read article,
2752 + { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2755 + ** Controls whether or not Mutt will try to reconnect to newsserver when
2756 + ** connection lost.
2759 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2762 @@ -2079,6 +2230,16 @@ struct option_t MuttVars[] = {
2763 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2767 + { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2770 + ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2771 + ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2772 + ** does not support posting to that newsgroup or totally read-only, that
2773 + ** posting will not have an effect.
2776 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2779 @@ -2479,6 +2640,28 @@ struct option_t MuttVars[] = {
2780 ** Command to use when spawning a subshell. By default, the user's login
2781 ** shell from \fC/etc/passwd\fP is used.
2784 + { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2787 + ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2788 + ** ``newsrc'' file and into cache.
2790 + { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2793 + ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2794 + ** the browser. Otherwise, it will be done only once for a newsserver.
2795 + ** Also controls whether or not number of new articles of subscribed
2796 + ** newsgroups will be then checked.
2798 + { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2801 + ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2802 + ** will be displayed in browser.
2805 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2808 @@ -3337,6 +3520,14 @@ struct option_t MuttVars[] = {
2809 ** Also see the $$read_inc, $$net_inc and $$time_inc variables and the
2810 ** ``$tuning'' section of the manual for performance considerations.
2813 + { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2816 + ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2817 + ** name of original article author) to article that followuped to newsgroup.
2821 { NULL, 0, 0, 0, 0 }
2823 diff -udprP mutt-1.5.20.orig/keymap.c mutt-1.5.20/keymap.c
2824 --- mutt-1.5.20.orig/keymap.c 2008-11-29 23:09:10.000000000 +0200
2825 +++ mutt-1.5.20/keymap.c 2009-06-15 21:05:24.000000000 +0300
2826 @@ -654,7 +654,6 @@ void km_init (void)
2827 km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE);
2829 km_bindkey ("x", MENU_PAGER, OP_EXIT);
2830 - km_bindkey ("i", MENU_PAGER, OP_EXIT);
2831 km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE);
2832 km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE);
2833 km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE);
2834 diff -udprP mutt-1.5.20.orig/mailbox.h mutt-1.5.20/mailbox.h
2835 --- mutt-1.5.20.orig/mailbox.h 2009-04-30 08:36:17.000000000 +0300
2836 +++ mutt-1.5.20/mailbox.h 2009-06-15 21:05:24.000000000 +0300
2837 @@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2839 int mx_is_pop (const char *);
2842 +int mx_is_nntp (const char *);
2845 int mx_access (const char*, int);
2846 int mx_check_empty (const char *);
2847 diff -udprP mutt-1.5.20.orig/main.c mutt-1.5.20/main.c
2848 --- mutt-1.5.20.orig/main.c 2009-06-01 19:29:32.000000000 +0300
2849 +++ mutt-1.5.20/main.c 2009-06-15 21:05:24.000000000 +0300
2851 #include <stringprep.h>
2858 static const char *ReachingUs = N_("\
2859 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2860 To report a bug, please visit http://bugs.mutt.org/.\n");
2861 @@ -133,6 +137,8 @@ options:\n\
2862 " -e <command>\tspecify a command to be executed after initialization\n\
2863 -f <file>\tspecify which mailbox to read\n\
2864 -F <file>\tspecify an alternate muttrc file\n\
2865 + -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2866 + -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2867 -H <file>\tspecify a draft file to read header and body from\n\
2868 -i <file>\tspecify a file which Mutt should include in the body\n\
2869 -m <type>\tspecify a default mailbox type\n\
2870 @@ -255,6 +261,12 @@ static void show_version (void)
2883 @@ -522,6 +534,9 @@ static void start_curses (void)
2884 #define M_NOSYSRC (1<<2) /* -n */
2885 #define M_RO (1<<3) /* -R */
2886 #define M_SELECT (1<<4) /* -y */
2888 +#define M_NEWS (1<<5) /* -g and -G */
2891 int main (int argc, char **argv)
2893 @@ -594,7 +609,11 @@ int main (int argc, char **argv)
2894 argv[nargc++] = argv[optind];
2898 + if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2900 if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2905 @@ -691,6 +710,20 @@ int main (int argc, char **argv)
2910 + case 'g': /* Specify a newsserver */
2912 + char buf[LONG_STRING];
2914 + snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2915 + commands = mutt_add_list (commands, buf);
2918 + case 'G': /* List of newsgroups */
2919 + flags |= M_SELECT | M_NEWS;
2926 @@ -978,6 +1011,18 @@ int main (int argc, char **argv)
2928 else if (flags & M_SELECT)
2931 + if (flags & M_NEWS)
2933 + set_option (OPTNEWS);
2934 + if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2936 + mutt_endwin (Errorbuf);
2943 mutt_endwin _("No incoming mailboxes defined.");
2945 @@ -993,6 +1038,15 @@ int main (int argc, char **argv)
2948 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2951 + if (option (OPTNEWS))
2953 + unset_option (OPTNEWS);
2954 + nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2958 mutt_expand_path (folder, sizeof (folder));
2960 mutt_str_replace (&CurrentFolder, folder);
2961 diff -udprP mutt-1.5.20.orig/mutt.h mutt-1.5.20/mutt.h
2962 --- mutt-1.5.20.orig/mutt.h 2009-06-13 01:15:42.000000000 +0300
2963 +++ mutt-1.5.20/mutt.h 2009-06-15 21:05:24.000000000 +0300
2964 @@ -229,6 +229,9 @@ enum
2972 /* Options for Mailcap lookup */
2974 @@ -285,6 +288,12 @@ enum
2977 OPT_VERIFYSIG, /* verify PGP signatures */
2980 + OPT_NNTPRECONNECT,
2982 + OPT_FOLLOWUPTOPOSTER,
2983 +#endif /* USE_NNTP */
2985 /* THIS MUST BE THE LAST VALUE. */
2987 @@ -300,6 +309,7 @@ enum
2988 #define SENDMAILX (1<<6)
2989 #define SENDKEY (1<<7)
2990 #define SENDRESEND (1<<8)
2991 +#define SENDNEWS (1<<9)
2993 /* flags to _mutt_select_file() */
2994 #define M_SEL_BUFFY (1<<0)
2995 @@ -319,6 +329,8 @@ enum
3004 @@ -396,6 +408,9 @@ enum
3009 + OPTMIMESUBJECT, /* encode subject line with RFC2047 */
3014 @@ -477,6 +492,16 @@ enum
3018 + /* news options */
3022 + OPTSHOWONLYUNREAD,
3026 +#endif /* USE_NNTP */
3028 /* pseudo options */
3030 OPTAUXSORT, /* (pseudo) using auxillary sort function */
3031 @@ -497,6 +522,7 @@ enum
3032 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
3033 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3034 OPTATTACHMSG, /* (pseudo) used by attach-message */
3035 + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3036 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3037 * functions while we are executing an
3039 @@ -507,6 +533,12 @@ enum
3040 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3041 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
3044 + OPTNEWS, /* (pseudo) used to change reader mode */
3045 + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3046 + OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
3052 @@ -585,6 +617,13 @@ typedef struct envelope
3056 + char *organization;
3060 + char *followup_to;
3061 + char *x_comment_to;
3064 LIST *references; /* message references (in reverse order) */
3065 LIST *in_reply_to; /* in-reply-to header content */
3066 @@ -751,6 +790,9 @@ typedef struct header
3067 ENVELOPE *env; /* envelope information */
3068 BODY *content; /* list of MIME parts */
3074 char *tree; /* character string to print thread tree */
3075 struct thread *thread;
3076 @@ -766,7 +808,7 @@ typedef struct header
3077 int refno; /* message number on server */
3080 -#if defined USE_POP || defined USE_IMAP
3081 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3082 void *data; /* driver-specific data */
3085 diff -udprP mutt-1.5.20.orig/muttlib.c mutt-1.5.20/muttlib.c
3086 --- mutt-1.5.20.orig/muttlib.c 2009-05-19 03:11:35.000000000 +0300
3087 +++ mutt-1.5.20/muttlib.c 2009-06-15 21:05:24.000000000 +0300
3088 @@ -301,7 +301,7 @@ void mutt_free_header (HEADER **h)
3090 mutt_free_list (&(*h)->chain);
3092 -#if defined USE_POP || defined USE_IMAP
3093 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3096 FREE (h); /* __FREE_CHECKED__ */
3097 @@ -689,6 +689,13 @@ void mutt_free_envelope (ENVELOPE **p)
3098 FREE (&(*p)->supersedes);
3100 FREE (&(*p)->x_label);
3101 + FREE (&(*p)->organization);
3103 + FREE (&(*p)->newsgroups);
3104 + FREE (&(*p)->xref);
3105 + FREE (&(*p)->followup_to);
3106 + FREE (&(*p)->x_comment_to);
3109 mutt_buffer_free (&(*p)->spam);
3111 @@ -1470,6 +1477,14 @@ int mutt_save_confirm (const char *s, st
3116 + if (magic == M_NNTP)
3118 + mutt_error _("Can't save message to newsserver.");
3123 if (stat (s, st) != -1)
3126 diff -udprP mutt-1.5.20.orig/mx.c mutt-1.5.20/mx.c
3127 --- mutt-1.5.20.orig/mx.c 2009-06-11 07:29:41.000000000 +0300
3128 +++ mutt-1.5.20/mx.c 2009-06-15 21:05:24.000000000 +0300
3129 @@ -343,6 +343,22 @@ int mx_is_pop (const char *p)
3134 +int mx_is_nntp (const char *p)
3136 + url_scheme_t scheme;
3141 + scheme = url_check_scheme (p);
3142 + if (scheme == U_NNTP || scheme == U_NNTPS)
3149 int mx_get_magic (const char *path)
3152 @@ -360,6 +376,11 @@ int mx_get_magic (const char *path)
3154 #endif /* USE_POP */
3157 + if (mx_is_nntp (path))
3159 +#endif /* USE_NNTP */
3161 if (stat (path, &st) == -1)
3163 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
3164 @@ -669,6 +690,12 @@ CONTEXT *mx_open_mailbox (const char *pa
3166 #endif /* USE_POP */
3170 + rc = nntp_open_mailbox (ctx);
3172 +#endif /* USE_NNTP */
3177 @@ -761,6 +788,12 @@ static int sync_mailbox (CONTEXT *ctx, i
3178 rc = pop_sync_mailbox (ctx, index_hint);
3180 #endif /* USE_POP */
3184 + rc = nntp_sync_mailbox (ctx);
3186 +#endif /* USE_NNTP */
3190 @@ -787,6 +820,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
3195 + if (ctx->magic == M_NNTP)
3199 + ret = nntp_close_mailbox (ctx);
3200 + mx_fastclose_mailbox (ctx);
3204 if (ctx->readonly || ctx->dontwrite)
3206 /* mailbox is readonly or we don't want to write */
3207 @@ -1336,6 +1379,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
3209 return (pop_check_mailbox (ctx, index_hint));
3210 #endif /* USE_POP */
3214 + return (nntp_check_mailbox (ctx));
3215 +#endif /* USE_NNTP */
3219 @@ -1396,6 +1444,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
3221 #endif /* USE_POP */
3226 + if (nntp_fetch_message (msg, ctx, msgno) != 0)
3230 +#endif /* USE_NNTP */
3233 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3235 @@ -1477,6 +1534,9 @@ int mx_close_message (MESSAGE **msg)
3237 || (*msg)->magic == M_POP
3240 + || (*msg)->magic == M_NNTP
3244 r = safe_fclose (&(*msg)->fp);
3245 diff -udprP mutt-1.5.20.orig/mx.h mutt-1.5.20/mx.h
3246 --- mutt-1.5.20.orig/mx.h 2008-11-11 21:55:47.000000000 +0200
3247 +++ mutt-1.5.20/mx.h 2009-06-15 21:05:24.000000000 +0300
3248 @@ -40,6 +40,9 @@ enum
3257 WHERE short DefaultMagic INITVAL (M_MBOX);
3258 diff -udprP mutt-1.5.20.orig/newsrc.c mutt-1.5.20/newsrc.c
3259 --- mutt-1.5.20.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3260 +++ mutt-1.5.20/newsrc.c 2009-06-15 21:05:24.000000000 +0300
3263 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3264 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
3265 + * Copyright (C) 2000-2009 Vsevolod Volkov <vvv@mutt.org.ua>
3267 + * This program is free software; you can redistribute it and/or modify
3268 + * it under the terms of the GNU General Public License as published by
3269 + * the Free Software Foundation; either version 2 of the License, or
3270 + * (at your option) any later version.
3272 + * This program is distributed in the hope that it will be useful,
3273 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3274 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3275 + * GNU General Public License for more details.
3277 + * You should have received a copy of the GNU General Public License
3278 + * along with this program; if not, write to the Free Software
3279 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3283 +# include "config.h"
3287 +#include "mutt_curses.h"
3291 +#include "mailbox.h"
3293 +#include "rfc822.h"
3294 +#include "rfc1524.h"
3295 +#include "rfc2047.h"
3297 +#include <unistd.h>
3298 +#include <string.h>
3300 +#include <stdlib.h>
3301 +#include <sys/stat.h>
3303 +void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3310 + l = safe_calloc (1, sizeof (LIST));
3312 + s->tail->next = l;
3316 + l->data = (void *) d;
3319 +static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3322 + char group[LONG_STRING];
3324 + char *p = line, *b, *h;
3334 + while (*p && (*p != ':' && *p != '!')) p++;
3337 + len = p + 1 - line;
3338 + if (len > sizeof (group))
3339 + len = sizeof (group);
3340 + strfcpy (group, line, len);
3341 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3343 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3344 + data->group = (char *) data + sizeof (NNTP_DATA);
3345 + strcpy (data->group, group);
3346 + data->nserv = news;
3347 + data->deleted = 1;
3348 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3349 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
3350 + hash_insert (news->newsgroups, data->group, data, 0);
3351 + nntp_add_to_list (news, data);
3354 + FREE ((void **) &data->entries);
3357 + data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3361 + data->subscribed = 1;
3363 + data->subscribed = 0;
3370 + while (*p && *p != ',' && *p != '\n') p++;
3376 + if ((h = strchr(b, '-')))
3380 + data->entries[x].first = atoi(b);
3381 + data->entries[x].last = atoi(h);
3385 + data->entries[x].first = atoi(b);
3386 + data->entries[x].last = data->entries[x].first;
3389 + if (data->entries[x].last != 0)
3392 + if (x && !data->lastMessage)
3393 + data->lastMessage = data->entries[x-1].last;
3395 + mutt_newsgroup_stat (data);
3396 + dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3401 +static int slurp_newsrc (NNTP_SERVER *news)
3407 + news->stat = stat (news->newsrc, &sb);
3408 + news->size = sb.st_size;
3409 + news->mtime = sb.st_mtime;
3411 + if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3413 + /* hmm, should we use dotlock? */
3414 + if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3420 + buf = safe_malloc (sb.st_size + 1);
3421 + while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3422 + nntp_parse_newsrc_line (news, buf);
3425 + mx_unlock_file (news->newsrc, fileno (fp), 0);
3430 +void nntp_cache_expand (char *dst, const char *src)
3432 + snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3433 + mutt_expand_path (dst, _POSIX_PATH_MAX);
3436 +/* Loads $news_cache_dir/.index into memory, loads newsserver data
3437 + * and newsgroup cache names */
3438 +static int nntp_parse_cacheindex (NNTP_SERVER *news)
3441 + char buf[HUGE_STRING], *cp;
3442 + char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3447 + /* check is server name defined or not */
3448 + if (!news || !news->conn || !news->conn->account.host)
3450 + unset_option (OPTNEWSCACHE);
3451 + if (!NewsCacheDir || !*NewsCacheDir)
3454 + strfcpy (dir, NewsCacheDir, sizeof (dir));
3455 + mutt_expand_path (dir, sizeof(dir));
3457 + if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3459 + snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3460 + if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3463 + mutt_error _("Cache directory not created!");
3466 + mutt_clear_error();
3469 + set_option (OPTNEWSCACHE);
3471 + FREE (&news->cache);
3472 + snprintf (buf, sizeof(buf), "%s/.index", dir);
3473 + if (!(index = safe_fopen (buf, "a+")))
3476 + while (fgets (buf, sizeof(buf), index))
3478 + buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3479 + if (!mutt_strncmp (buf, "#: ", 3) &&
3480 + !mutt_strcasecmp (buf+3, news->conn->account.host))
3483 + while (fgets (buf, sizeof(buf), index))
3486 + while (*cp && *cp != ' ') cp++;
3487 + if (!*cp) continue;
3489 + if (!mutt_strcmp (buf, "#:"))
3491 + sscanf (cp + 1, "%s %d %d", file, &l, &m);
3492 + if (!mutt_strcmp (buf, "ALL"))
3494 + news->cache = safe_strdup (file);
3495 + news->newgroups_time = m;
3497 + else if (news->newsgroups)
3499 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3501 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3502 + data->group = (char *) data + sizeof (NNTP_DATA);
3503 + strcpy(data->group, buf);
3504 + data->nserv = news;
3505 + data->deleted = 1;
3506 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3507 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
3508 + hash_insert (news->newsgroups, data->group, data, 0);
3509 + nntp_add_to_list (news, data);
3511 + data->cache = safe_strdup (file);
3513 + if (!data->firstMessage || data->lastMessage < m)
3515 + if (!data->firstMessage)
3516 + data->firstMessage = l;
3517 + if (data->lastMessage < m)
3518 + data->lastMessage = m;
3519 + data->lastCached = m;
3520 + if (t || !data->unread)
3521 + mutt_newsgroup_stat (data);
3529 +nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
3530 + const char *fmt, const char *ifstring, const char *elsestring,
3531 + unsigned long data, format_flag flags)
3533 + char fn[SHORT_STRING], tmp[SHORT_STRING];
3538 + strncpy (fn, NewsServer, sizeof(fn) - 1);
3539 + mutt_strlower (fn);
3540 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3541 + snprintf (dest, destlen, tmp, fn);
3547 +/* nntp_parse_url: given an NNPT URL, return host, port,
3548 + * username, password and newsgroup will recognise. */
3549 +int nntp_parse_url (const char *server, ACCOUNT *acct,
3550 + char *group, size_t group_len)
3558 + acct->port = NNTP_PORT;
3559 + acct->type = M_ACCT_TYPE_NNTP;
3561 + c = safe_strdup (server);
3562 + url_parse_ciss (&url, c);
3564 + if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3566 + if (url.scheme == U_NNTPS)
3568 + acct->flags |= M_ACCT_SSL;
3569 + acct->port = NNTP_SSL_PORT;
3574 + strfcpy (group, url.path, group_len);
3576 + ret = mutt_account_fromurl (acct, &url);
3583 +void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3587 + url.path = safe_strdup (line);
3588 + mutt_account_tourl (acct, &url);
3589 + url_ciss_tostring (&url, line, len, 0);
3594 + * Automatically loads a newsrc into memory, if necessary.
3595 + * Checks the size/mtime of a newsrc file, if it doesn't match, load
3596 + * again. Hmm, if a system has broken mtimes, this might mean the file
3597 + * is reloaded every time, which we'd have to fix.
3599 + * a newsrc file is a line per newsgroup, with the newsgroup, then a
3600 + * ':' denoting subscribed or '!' denoting unsubscribed, then a
3601 + * comma separated list of article numbers and ranges.
3603 +NNTP_SERVER *mutt_select_newsserver (char *server)
3605 + char file[_POSIX_PATH_MAX];
3609 + NNTP_SERVER *serv;
3612 + if (!server || !*server)
3614 + mutt_error _("No newsserver defined!");
3618 + buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3619 + if (url_check_scheme (server) == U_UNKNOWN)
3621 + strcpy (buf, "news://");
3622 + p = strchr (buf, '\0');
3624 + strcpy (p, server);
3626 + if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3629 + mutt_error (_("%s is an invalid newsserver specification!"), server);
3634 + conn = mutt_conn_find (NULL, &acct);
3638 + mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), nntp_format_str, 0, 0);
3639 + mutt_expand_path (file, sizeof (file));
3641 + serv = (NNTP_SERVER *)conn->data;
3646 + /* externally modified? */
3647 + if (serv->stat != stat (file, &sb) || (!serv->stat &&
3648 + (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3650 + for (list = serv->list; list; list = list->next)
3652 + NNTP_DATA *data = (NNTP_DATA *) list->data;
3656 + data->subscribed = 0;
3661 + slurp_newsrc (serv);
3662 + nntp_clear_cacheindex (serv);
3665 + if (serv->status == NNTP_BYE)
3666 + serv->status = NNTP_NONE;
3667 + nntp_check_newgroups (serv, 0);
3671 + /* New newsserver */
3672 + serv = safe_calloc (1, sizeof (NNTP_SERVER));
3673 + serv->conn = conn;
3674 + serv->newsrc = safe_strdup (file);
3675 + serv->newsgroups = hash_create (1009, 0);
3676 + slurp_newsrc (serv); /* load .newsrc */
3677 + nntp_parse_cacheindex (serv); /* load .index */
3678 + if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3679 + nntp_check_newgroups (serv, 1);
3680 + else if (nntp_get_active (serv) < 0)
3682 + hash_destroy (&serv->newsgroups, nntp_delete_data);
3683 + for (list = serv->list; list; list = list->next)
3684 + list->data = NULL;
3685 + mutt_free_list (&serv->list);
3686 + FREE (&serv->newsrc);
3687 + FREE (&serv->cache);
3691 + nntp_clear_cacheindex (serv);
3692 + conn->data = (void *)serv;
3698 + * full status flags are not supported by nntp, but we can fake some
3699 + * of them. This is how:
3700 + * Read = a read message number is in the .newsrc
3701 + * New = a message is new since we last read this newsgroup
3702 + * Old = anything else
3703 + * So, Read is marked as such in the newsrc, old is anything that is
3704 + * "skipped" in the newsrc, and new is anything not in the newsrc nor
3705 + * in the cache. By skipped, I mean before the last unread message
3707 +void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3709 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3713 + data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3719 + dprint (3, (debugfile, "newsgroup %s not found\n", group));
3724 + for (x = 0; x < data->num; x++)
3726 + if ((article >= data->entries[x].first) &&
3727 + (article <= data->entries[x].last))
3729 + /* we cannot use mutt_set_flag() because mx_update_context()
3730 + didn't called yet */
3735 + /* If article was not cached yet, it is new! :) */
3736 + if (!data->cache || article > data->lastCached)
3738 + /* Old articles are articles which aren't read but an article after them
3739 + * has been cached */
3740 + if (option (OPTMARKOLD))
3744 +void mutt_newsgroup_stat (NNTP_DATA *data)
3747 + unsigned int first, last;
3750 + if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3753 + data->unread = data->lastMessage - data->firstMessage + 1;
3754 + for (i = 0; i < data->num; i++)
3756 + first = data->entries[i].first;
3757 + if (first < data->firstMessage)
3758 + first = data->firstMessage;
3759 + last = data->entries[i].last;
3760 + if (last > data->lastMessage)
3761 + last = data->lastMessage;
3762 + if (first <= last)
3763 + data->unread -= last - first + 1;
3767 +static int puti (char *line, int num)
3771 + for (p = s; num; )
3773 + *p++ = '0' + num % 10;
3777 + *line++ = *--p, num++;
3782 +static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3784 + char *line = *pline;
3785 + size_t len = *buflen - (*pline - *buf);
3788 + if (len < LONG_STRING * 10)
3793 + safe_realloc (buf, *buflen);
3794 + line = *buf + (*pline - line);
3796 + strcpy (line, data->group);
3797 + len -= strlen (line) + 1;
3798 + line += strlen (line);
3799 + *line++ = data->subscribed ? ':' : '!';
3803 + for (x = 0; x < data->num; x++)
3805 + if (len < LONG_STRING)
3811 + safe_realloc (buf, *buflen);
3812 + line = *buf + (*pline - line);
3821 + if (data->entries[x].first == data->entries[x].last)
3822 + snprintf (line, len, "%d%n", data->entries[x].first, &i);
3824 + snprintf (line, len, "%d-%d%n",
3825 + data->entries[x].first, data->entries[x].last, &i);
3829 + i = puti (line, data->entries[x].first);
3830 + line +=i; len -= i;
3831 + if (data->entries[x].first != data->entries[x].last)
3835 + i = puti (line, data->entries[x].last);
3836 + line +=i; len -= i;
3845 +void newsrc_gen_entries (CONTEXT *ctx)
3847 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3849 + unsigned int last = 0, first = 1;
3850 + int save_sort = SORT_ORDER;
3852 + if (Sort != SORT_ORDER)
3855 + Sort = SORT_ORDER;
3856 + mutt_sort_headers (ctx, 0);
3861 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3866 + * Set up to fake initial sequence from 1 to the article before the
3867 + * first article in our list
3872 + for (x = 0; x < ctx->msgcount; x++)
3874 + if (series) /* search for first unread */
3877 + * We don't actually check sequential order, since we mark
3878 + * "missing" entries as read/deleted
3880 + last = ctx->hdrs[x]->article_num;
3881 + if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3882 + !ctx->hdrs[x]->read)
3884 + if (data->num >= data->max)
3886 + data->max = data->max * 2;
3887 + safe_realloc (&data->entries,
3888 + data->max * sizeof (NEWSRC_ENTRY));
3890 + data->entries[data->num].first = first;
3891 + data->entries[data->num].last = last - 1;
3896 + else /* search for first read */
3898 + if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3903 + last = ctx->hdrs[x]->article_num;
3906 + if (series && first <= data->lastLoaded)
3908 + if (data->num >= data->max)
3910 + data->max = data->max * 2;
3911 + safe_realloc (&data->entries,
3912 + data->max * sizeof (NEWSRC_ENTRY));
3914 + data->entries[data->num].first = first;
3915 + data->entries[data->num].last = data->lastLoaded;
3919 + if (save_sort != Sort)
3922 + mutt_sort_headers (ctx, 0);
3926 +static int mutt_update_list_file (char *filename, char *section,
3927 + char *key, char *line)
3931 + char buf[HUGE_STRING];
3932 + char tmpfile[_POSIX_PATH_MAX];
3934 + int ext = 0, done = 0, r = 0;
3936 + /* if file not exist, create it */
3937 + if ((ifp = safe_fopen (filename, "a")))
3939 + dprint (1, (debugfile, "Opening %s\n", filename));
3940 + if (!(ifp = safe_fopen (filename, "r")))
3942 + mutt_error (_("Unable to open %s for reading"), filename);
3945 + if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3948 + mutt_error (_("Unable to lock %s"), filename);
3951 + snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3952 + dprint (1, (debugfile, "Opening %s\n", tmpfile));
3953 + if (!(ofp = fopen (tmpfile, "w")))
3956 + mutt_error (_("Unable to open %s for writing"), tmpfile);
3962 + while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3964 + r = fputs (buf, ofp);
3966 + while (*c && *c != '\n') c++;
3967 + c[0] = 0; /* strip EOL */
3968 + if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3971 + if (r != EOF && !done)
3973 + snprintf (buf, sizeof(buf), "#: %s\n", section);
3974 + r = fputs (buf, ofp);
3979 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3984 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3986 + if (*c != '\\') ext = 0;
3988 + else if ((section && !strncmp (buf, "#: ", 3)))
3990 + if (!done && line)
3992 + fputs (line, ofp);
3993 + fputc ('\n', ofp);
3995 + r = fputs (buf, ofp);
3999 + else if (key && !strncmp (buf, key, strlen(key)) &&
4000 + (!*key || buf[strlen(key)] == ' '))
4004 + while (*c && (*c != '\r') && (*c != '\n')) c++;
4006 + if (*c == '\\') ext = 1;
4007 + if (!done && line)
4009 + r = fputs (line, ofp);
4011 + r = fputc ('\n', ofp);
4017 + r = fputs (buf, ofp);
4021 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
4022 + r = fputs (buf, ofp);
4024 + /* If there wasn't a line to replace, put it on the end of the file */
4025 + if (r != EOF && !done && line)
4027 + fputs (line, ofp);
4028 + r = fputc ('\n', ofp);
4030 + mx_unlock_file (filename, fileno (ifp), 0);
4036 + mutt_error (_("Can't write %s"), tmpfile);
4039 + if (rename (tmpfile, filename) < 0)
4042 + mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
4048 +int mutt_newsrc_update (NNTP_SERVER *news)
4058 + llen = len = 10 * LONG_STRING;
4059 + line = buf = safe_calloc (1, len);
4060 + /* we will generate full newsrc here */
4061 + for (tmp = news->list; tmp; tmp = tmp->next)
4063 + data = (NNTP_DATA *) tmp->data;
4064 + if (!data || !data->rc)
4066 + nntp_create_newsrc_line (data, &buf, &line, &llen);
4068 + dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4069 + line += strlen (line);
4071 + /* newrc being fully rewritten */
4072 + if (news->newsrc &&
4073 + (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4077 + stat (news->newsrc, &st);
4078 + news->size = st.st_size;
4079 + news->mtime = st.st_mtime;
4085 +static FILE *mutt_mkname (char *s)
4087 + char buf[_POSIX_PATH_MAX], *pc;
4091 + nntp_cache_expand (buf, s);
4092 + if ((fp = safe_fopen (buf, "w")))
4095 + nntp_cache_expand (buf, "cache-XXXXXX");
4096 + pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4097 + if ((fd = mkstemp (buf)) == -1)
4099 + strcpy (s, pc); /* generated name */
4100 + return fdopen (fd, "w");
4103 +/* Updates info into .index file: ALL or about selected newsgroup */
4104 +static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4106 + char buf[LONG_STRING], *key = "ALL";
4107 + char file[_POSIX_PATH_MAX];
4109 + if (!serv || !serv->conn || !serv->conn->account.host)
4112 + if (data && data->group)
4114 + key = data->group;
4115 + snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4116 + data->firstMessage, data->lastLoaded);
4120 + strfcpy (file, serv->cache, sizeof (file));
4121 + snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4123 + nntp_cache_expand (file, ".index");
4124 + return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4127 +/* Remove cache files of unsubscribed newsgroups */
4128 +void nntp_clear_cacheindex (NNTP_SERVER *news)
4133 + if (option (OPTSAVEUNSUB) || !news)
4136 + for (tmp = news->list; tmp; tmp = tmp->next)
4138 + data = (NNTP_DATA *) tmp->data;
4139 + if (!data || data->subscribed || !data->cache)
4141 + nntp_delete_cache (data);
4142 + dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4147 +int nntp_save_cache_index (NNTP_SERVER *news)
4149 + char buf[HUGE_STRING];
4150 + char file[_POSIX_PATH_MAX];
4155 + if (!news || !news->newsgroups)
4157 + if (!option (OPTNEWSCACHE))
4162 + nntp_cache_expand (file, news->cache);
4164 + f = safe_fopen (file, "w");
4168 + strfcpy (buf, news->conn->account.host, sizeof(buf));
4169 + f = mutt_mkname (buf);
4170 + news->cache = safe_strdup (buf);
4171 + nntp_cache_expand (file, buf);
4176 + for (l = news->list; l; l = l->next)
4178 + if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4181 + snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4182 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4185 + snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4186 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4187 + if (fputs (buf, f) == EOF)
4197 + if (nntp_update_cacheindex (news, NULL))
4205 +int nntp_save_cache_group (CONTEXT *ctx)
4207 + char buf[HUGE_STRING], addr[STRING];
4208 + char file[_POSIX_PATH_MAX];
4212 + int i = 0, save = SORT_ORDER;
4215 + if (!option (OPTNEWSCACHE))
4217 + if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4220 + if (((NNTP_DATA *)ctx->data)->cache)
4222 + nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4224 + f = safe_fopen (file, "w");
4228 + snprintf (buf, sizeof(buf), "%s-%s",
4229 + ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4230 + ((NNTP_DATA *)ctx->data)->group);
4231 + f = mutt_mkname (buf);
4232 + ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4233 + nntp_cache_expand (file, buf);
4238 + if (Sort != SORT_ORDER)
4241 + Sort = SORT_ORDER;
4242 + mutt_sort_headers (ctx, 0);
4245 + /* Save only $nntp_context messages... */
4246 + ((NNTP_DATA *)ctx->data)->lastCached = 0;
4247 + if (NntpContext && ctx->msgcount > NntpContext)
4248 + i = ctx->msgcount - NntpContext;
4249 + for (; i < ctx->msgcount; i++)
4251 + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4255 + rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4256 + tm = gmtime (&h->date_sent);
4257 + snprintf (buf, sizeof(buf),
4258 + "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4259 + h->article_num, h->env->subject, addr, tm->tm_mday,
4260 + Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4261 + tm->tm_sec, h->env->message_id);
4263 + if (h->env->references)
4264 + mutt_write_references (h->env->references, f, 10);
4265 + snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length,
4266 + (int) h->lines, NONULL(h->env->xref));
4267 + if (fputs (buf, f) == EOF)
4274 + prev = ctx->hdrs[i]->article_num;
4280 + mutt_sort_headers (ctx, 0);
4284 + if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4285 + (NNTP_DATA *)ctx->data))
4290 + ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4294 +void nntp_delete_cache (NNTP_DATA *data)
4296 + char buf[_POSIX_PATH_MAX];
4298 + if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4301 + nntp_cache_expand (buf, data->cache);
4303 + FREE (&data->cache);
4304 + data->lastCached = 0;
4305 + nntp_cache_expand (buf, ".index");
4306 + mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4309 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4313 + if (!news || !news->newsgroups || !group || !*group)
4315 + if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4317 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4318 + data->group = (char *) data + sizeof (NNTP_DATA);
4319 + strcpy (data->group, group);
4320 + data->nserv = news;
4321 + data->deleted = 1;
4322 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4323 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
4324 + hash_insert (news->newsgroups, data->group, data, 0);
4325 + nntp_add_to_list (news, data);
4327 + if (!data->subscribed)
4329 + data->subscribed = 1;
4335 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4339 + if (!news || !news->newsgroups || !group || !*group ||
4340 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4342 + if (data->subscribed)
4344 + data->subscribed = 0;
4345 + if (!option (OPTSAVEUNSUB))
4351 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4355 + if (!news || !news->newsgroups || !group || !*group ||
4356 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4360 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4364 + data->entries[0].first = 1;
4366 + data->entries[0].last = data->lastMessage;
4367 + if (Context && Context->data == data)
4371 + for (x = 0; x < Context->msgcount; x++)
4372 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4377 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4381 + if (!news || !news->newsgroups || !group || !*group ||
4382 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4386 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4390 + data->entries[0].first = 1;
4391 + data->entries[0].last = data->firstMessage - 1;
4392 + if (Context && Context->data == data)
4396 + data->unread = Context->msgcount;
4397 + for (x = 0; x < Context->msgcount; x++)
4398 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4401 + data->unread = data->lastMessage - data->entries[0].last;
4405 +/* this routine gives the first newsgroup with new messages */
4406 +void nntp_buffy (char *s)
4410 + for (list = CurrentNewsSrv->list; list; list = list->next)
4412 + NNTP_DATA *data = (NNTP_DATA *) list->data;
4414 + if (data && data->subscribed && data->unread)
4416 + if (Context && Context->magic == M_NNTP &&
4417 + !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4419 + unsigned int i, unread = 0;
4421 + for (i = 0; i < Context->msgcount; i++)
4422 + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4427 + strcpy (s, data->group);
4432 diff -udprP mutt-1.5.20.orig/nntp.c mutt-1.5.20/nntp.c
4433 --- mutt-1.5.20.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4434 +++ mutt-1.5.20/nntp.c 2009-06-15 21:05:24.000000000 +0300
4437 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4438 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4439 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
4441 + * This program is free software; you can redistribute it and/or modify
4442 + * it under the terms of the GNU General Public License as published by
4443 + * the Free Software Foundation; either version 2 of the License, or
4444 + * (at your option) any later version.
4446 + * This program is distributed in the hope that it will be useful,
4447 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4448 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4449 + * GNU General Public License for more details.
4451 + * You should have received a copy of the GNU General Public License
4452 + * along with this program; if not, write to the Free Software
4453 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4457 +# include "config.h"
4461 +#include "mutt_curses.h"
4465 +#include "rfc1524.h"
4466 +#include "rfc2047.h"
4467 +#include "mailbox.h"
4478 +#include <unistd.h>
4479 +#include <string.h>
4481 +#include <stdlib.h>
4483 +static unsigned int _checked = 0;
4486 +static void nntp_error (const char *where, const char *msg)
4488 + dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4492 +static int nntp_auth (NNTP_SERVER *serv)
4494 + CONNECTION *conn = serv->conn;
4496 + unsigned char flags = conn->account.flags;
4498 + if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4499 + mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4501 + conn->account.flags = flags;
4505 + mutt_message _("Logging in...");
4507 + snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4508 + mutt_socket_write (conn, buf);
4509 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4511 + conn->account.flags = flags;
4516 + /* don't print the password unless we're at the ungodly debugging level */
4517 + if (debuglevel < M_SOCK_LOG_FULL)
4518 + dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4520 + snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4521 + mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4522 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4524 + conn->account.flags = flags;
4528 + if (mutt_strncmp ("281", buf, 3))
4530 + conn->account.flags = flags;
4531 + mutt_error _("Login failed.");
4539 +static int nntp_connect_error (NNTP_SERVER *serv)
4541 + serv->status = NNTP_NONE;
4542 + mutt_socket_close (serv->conn);
4543 + mutt_error _("Server closed connection!");
4548 +static int nntp_connect_and_auth (NNTP_SERVER *serv)
4550 + CONNECTION *conn = serv->conn;
4554 + serv->status = NNTP_NONE;
4556 + if (mutt_socket_open (conn) < 0)
4559 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4560 + return nntp_connect_error (serv);
4562 + if (!mutt_strncmp ("200", buf, 3))
4563 + mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4564 + else if (!mutt_strncmp ("201", buf, 3))
4565 + mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4568 + mutt_socket_close (conn);
4569 + mutt_remove_trailing_ws (buf);
4570 + mutt_error ("%s", buf);
4577 + /* Tell INN to switch to mode reader if it isn't so. Ignore all
4578 + returned codes and messages. */
4579 + mutt_socket_write (conn, "MODE READER\r\n");
4580 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4581 + return nntp_connect_error (serv);
4583 + mutt_socket_write (conn, "STAT\r\n");
4584 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4585 + return nntp_connect_error (serv);
4587 + if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
4589 + serv->status = NNTP_OK;
4593 + rc = nntp_auth (serv);
4595 + return nntp_connect_error (serv);
4598 + mutt_socket_close (conn);
4599 + serv->status = NNTP_BYE;
4604 + mutt_socket_close (conn);
4605 + mutt_error _("Login failed.");
4609 + serv->status = NNTP_OK;
4613 +static int nntp_attempt_features (NNTP_SERVER *serv)
4615 + char buf[LONG_STRING];
4616 + CONNECTION *conn = serv->conn;
4618 + mutt_socket_write (conn, "XOVER\r\n");
4619 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4620 + return nntp_connect_error (serv);
4621 + if (mutt_strncmp ("500", buf, 3))
4622 + serv->hasXOVER = 1;
4624 + mutt_socket_write (conn, "XPAT\r\n");
4625 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4626 + return nntp_connect_error (serv);
4627 + if (mutt_strncmp ("500", buf, 3))
4628 + serv->hasXPAT = 1;
4630 + mutt_socket_write (conn, "LISTGROUP\r\n");
4631 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4632 + return nntp_connect_error (serv);
4633 + if (mutt_strncmp ("500", buf, 3))
4634 + serv->hasLISTGROUP = 1;
4636 + mutt_socket_write (conn, "XGTITLE +\r\n");
4637 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4638 + return nntp_connect_error (serv);
4639 + if (mutt_strncmp ("500", buf, 3))
4640 + serv->hasXGTITLE = 1;
4642 + if (!mutt_strncmp ("282", buf, 3))
4646 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4647 + return nntp_connect_error (serv);
4648 + } while (!(buf[0] == '.' && buf[1] == '\0'));
4654 +static int nntp_open_connection (NNTP_SERVER *serv)
4656 + if (serv->status == NNTP_OK)
4658 + if (serv->status == NNTP_BYE)
4660 + if (nntp_connect_and_auth (serv) < 0)
4662 + if (nntp_attempt_features (serv) < 0)
4667 +static int nntp_reconnect (NNTP_SERVER *serv)
4669 + char buf[SHORT_STRING];
4671 + mutt_socket_close (serv->conn);
4675 + if (nntp_connect_and_auth (serv) == 0)
4678 + snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
4679 + serv->conn->account.host);
4680 + if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
4682 + serv->status = NNTP_BYE;
4688 +/* Send data from line[LONG_STRING] and receive answer to same line */
4689 +static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
4691 + char buf[LONG_STRING];
4694 + if (data->nserv->status == NNTP_BYE)
4701 + mutt_socket_write (data->nserv->conn, line);
4703 + else if (data->group)
4705 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4706 + mutt_socket_write (data->nserv->conn, buf);
4710 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4712 + if (nntp_reconnect (data->nserv) < 0)
4717 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4718 + mutt_socket_write (data->nserv->conn, buf);
4719 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4725 + else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
4729 + strfcpy (line, buf, linelen);
4734 + * This function calls funct(*line, *data) for each received line,
4735 + * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
4738 + * 1 - correct but not performed (may be, have to be continued),
4739 + * -1 - conection lost,
4740 + * -2 - invalid command or execution error,
4741 + * -3 - error in funct(*line, *data).
4743 +static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
4744 + int (*funct) (char *, void *), void *data, int tagged)
4746 + char buf[LONG_STRING];
4750 + size_t lenbuf = 0;
4755 + strfcpy (buf, query, sizeof (buf));
4756 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
4758 + if (buf[0] == '5')
4760 + if (buf[0] != '2')
4765 + inbuf = safe_malloc (sizeof (buf));
4769 + chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
4775 + if (!lenbuf && buf[0] == '.')
4777 + if (buf[1] == '\0')
4782 + if (buf[1] == '.')
4786 + strfcpy (inbuf + lenbuf, p, sizeof (buf));
4788 + if (chunk >= sizeof (buf))
4790 + lenbuf += strlen (p);
4795 + if (msg && ReadInc && (line % ReadInc == 0)) {
4797 + mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
4799 + mutt_message ("%s %d", msg, line);
4802 + if (ret == 0 && funct (inbuf, data) < 0)
4807 + safe_realloc (&inbuf, lenbuf + sizeof (buf));
4810 + funct (NULL, data);
4816 +static int nntp_read_tempfile (char *line, void *file)
4818 + FILE *f = (FILE *)file;
4825 + if (fputc ('\n', f) == EOF)
4831 +static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
4833 + register char *p, *b;
4834 + register char *colon = NULL;
4839 + /* skip to next word */
4841 + while (*b && ((*b == ' ') || (*b == '\t'))) b++;
4844 + /* skip to end of word */
4845 + while (*p && (*p != ' ') && (*p != '\t'))
4860 + nntp_get_status (ctx, h, b, atoi(colon));
4861 + if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
4862 + h->article_num = atoi(colon);
4870 + * 1 if article not found
4871 + * -1 if read or write error on tempfile or socket
4873 +static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
4875 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
4877 + char buf[LONG_STRING];
4878 + char tempfile[_POSIX_PATH_MAX];
4880 + HEADER *h = ctx->hdrs[ctx->msgcount];
4882 + mutt_mktemp (tempfile);
4883 + if (!(f = safe_fopen (tempfile, "w+")))
4887 + snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
4889 + snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
4891 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
4896 + dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
4899 + unlink (tempfile);
4900 + return (ret == -1 ? -1 : 1);
4903 + h->article_num = article_num;
4904 + h->env = mutt_read_rfc822_header (f, h, 0, 0);
4906 + unlink (tempfile);
4908 + if (h->env->xref != NULL)
4909 + nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
4910 + else if (h->article_num == 0 && msgid)
4912 + snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
4913 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
4914 + h->article_num = atoi (buf + 4);
4920 +static int parse_description (char *line, void *n)
4922 +#define news ((NNTP_SERVER *) n)
4923 + register char *d = line;
4928 + while (*d && *d != '\t' && *d != ' ') d++;
4931 + while (*d && (*d == '\t' || *d == ' ')) d++;
4932 + dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
4933 + if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
4934 + mutt_strcmp (d, data->desc))
4936 + FREE (&data->desc);
4937 + data->desc = safe_strdup (d);
4943 +static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
4947 + if (!option (OPTLOADDESC) || !data || !data->nserv)
4950 + /* Get newsgroup description, if we can */
4951 + if (data->nserv->hasXGTITLE)
4952 + snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
4954 + snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
4955 + if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
4958 + nntp_error ("nntp_get_desc()", buf);
4964 + * XOVER returns a tab separated list of:
4965 + * id|subject|from|date|Msgid|references|bytes|lines|xref
4967 + * This has to duplicate some of the functionality of
4968 + * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
4969 + * a limited number of headers which are "parsed" by placement in the list)
4971 +static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
4973 + NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
4977 + hdr->env = mutt_new_envelope();
4978 + hdr->env->newsgroups = safe_strdup (nntp_data->group);
4979 + hdr->content = mutt_new_body();
4980 + hdr->content->type = TYPETEXT;
4981 + hdr->content->subtype = safe_strdup ("plain");
4982 + hdr->content->encoding = ENC7BIT;
4983 + hdr->content->disposition = DISPINLINE;
4984 + hdr->content->length = -1;
4987 + for (x = 0; !done && x < 9; x++)
4989 + /* if from file, need to skip newline character */
4990 + while (*p && *p != '\n' && *p != '\t') p++;
4998 + hdr->article_num = atoi (b);
4999 + nntp_get_status (ctx, hdr, NULL, hdr->article_num);
5002 + hdr->env->subject = safe_strdup (b);
5003 + /* Now we need to do the things which would normally be done in
5004 + * mutt_read_rfc822_header() */
5005 + if (hdr->env->subject)
5007 + regmatch_t pmatch[1];
5009 + rfc2047_decode (&hdr->env->subject);
5011 + if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
5012 + hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
5014 + hdr->env->real_subj = hdr->env->subject;
5018 + rfc822_free_address (&hdr->env->from);
5019 + hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
5020 + rfc2047_decode_adrlist (hdr->env->from);
5023 + hdr->date_sent = mutt_parse_date (b, hdr);
5024 + hdr->received = hdr->date_sent;
5027 + FREE (&hdr->env->message_id);
5028 + hdr->env->message_id = safe_strdup (b);
5031 + mutt_free_list (&hdr->env->references);
5032 + hdr->env->references = mutt_parse_references (b, 0);
5035 + hdr->content->length = atoi (b);
5038 + hdr->lines = atoi (b);
5042 + FREE (&hdr->env->xref);
5043 + b = b + 6; /* skips the "Xref: " */
5044 + hdr->env->xref = safe_strdup (b);
5045 + nntp_parse_xref (ctx, nntp_data->group, b, hdr);
5057 + unsigned int base;
5058 + unsigned int first;
5059 + unsigned int last;
5060 + unsigned short *messages;
5064 +#define fc ((FETCH_CONTEXT *) c)
5065 +static int nntp_fetch_numbers (char *line, void *c)
5071 + num = atoi (line);
5072 + if (num < fc->base || num > fc->last)
5074 + fc->messages[num - fc->base] = 1;
5078 +static int add_xover_line (char *line, void *c)
5080 + unsigned int num, total;
5081 + CONTEXT *ctx = fc->ctx;
5082 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5087 + if (ctx->msgcount >= ctx->hdrmax)
5088 + mx_alloc_memory (ctx);
5089 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5090 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5092 + nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5093 + num = ctx->hdrs[ctx->msgcount]->article_num;
5095 + if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5098 + if (num > data->lastLoaded)
5099 + data->lastLoaded = num;
5100 + num = num - fc->first + 1;
5101 + total = fc->last - fc->first + 1;
5102 + if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5103 + mutt_message ("%s %d/%d", fc->msg, num, total);
5106 + mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5112 +static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5113 + unsigned int last)
5115 + char buf[HUGE_STRING];
5116 + char *msg = _("Fetching message headers...");
5117 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5121 + unsigned int current;
5125 + /* if empty group or nothing to do */
5126 + if (!last || first > last)
5129 + /* fetch list of articles */
5133 + fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5134 + if (nntp_data->nserv->hasLISTGROUP)
5136 + mutt_message _("Fetching list of articles...");
5137 + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5138 + if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5140 + mutt_error (_("LISTGROUP command failed: %s"), buf);
5142 + nntp_error ("nntp_fetch_headers()", buf);
5144 + FREE (&fc.messages);
5150 + for (num = 0; num < last - first + 1; num++)
5151 + fc.messages[num] = 1;
5154 + /* CACHE: must be loaded xover cache here */
5155 + num = nntp_data->lastCached - first + 1;
5156 + if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5158 + nntp_cache_expand (buf, nntp_data->cache);
5159 + mutt_message _("Fetching headers from cache...");
5160 + if ((f = safe_fopen (buf, "r")))
5164 + /* counting number of lines */
5165 + while (fgets (buf, sizeof (buf), f) != NULL)
5168 + while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5170 + oldmsgcount = ctx->msgcount;
5172 + fc.last = first + num - 1;
5174 + while (fgets (buf, sizeof (buf), f) != NULL)
5175 + add_xover_line (buf, &fc);
5177 + nntp_data->lastLoaded = fc.last;
5178 + first = fc.last + 1;
5179 + if (ctx->msgcount > oldmsgcount)
5180 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5183 + nntp_delete_cache (nntp_data);
5185 + num = last - first + 1;
5188 + FREE (&fc.messages);
5193 + * Without XOVER, we have to fetch each article header and parse
5194 + * it. With XOVER, we ask for all of them
5196 + mutt_message (msg);
5197 + if (nntp_data->nserv->hasXOVER)
5199 + oldmsgcount = ctx->msgcount;
5203 + snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5204 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5205 + if (ctx->msgcount > oldmsgcount)
5206 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5209 + mutt_error (_("XOVER command failed: %s"), buf);
5211 + nntp_error ("nntp_fetch_headers()", buf);
5213 + FREE (&fc.messages);
5219 + for (current = first; current <= last; current++)
5223 + ret = current - first + 1;
5224 + mutt_message ("%s %d/%d", msg, ret, num);
5226 + if (!fc.messages[current - fc.base])
5229 + if (ctx->msgcount >= ctx->hdrmax)
5230 + mx_alloc_memory (ctx);
5231 + h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5232 + h->index = ctx->msgcount;
5234 + ret = nntp_read_header (ctx, NULL, current);
5235 + if (ret == 0) /* Got article. Fetch next header */
5237 + nntp_get_status (ctx, h, NULL, h->article_num);
5239 + mx_update_context (ctx, 1);
5242 + mutt_free_header (&h); /* skip it */
5245 + FREE (&fc.messages);
5249 + if (current > nntp_data->lastLoaded)
5250 + nntp_data->lastLoaded = current;
5252 + FREE (&fc.messages);
5253 + nntp_data->lastLoaded = last;
5254 + mutt_clear_error ();
5259 + * currently, nntp "mailbox" is "newsgroup"
5261 +int nntp_open_mailbox (CONTEXT *ctx)
5263 + NNTP_DATA *nntp_data;
5264 + NNTP_SERVER *serv;
5265 + char buf[HUGE_STRING];
5266 + char server[LONG_STRING];
5268 + unsigned int first;
5271 + if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5273 + mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5279 + nntp_expand_path (server, sizeof (server), &acct);
5280 + if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5283 + CurrentNewsSrv = serv;
5285 + /* create NNTP-specific state struct if nof found in list */
5286 + if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5288 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5289 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5290 + strcpy (nntp_data->group, buf);
5291 + hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5292 + nntp_add_to_list (serv, nntp_data);
5294 + ctx->data = nntp_data;
5295 + ctx->mx_close = nntp_fastclose_mailbox;
5296 + nntp_data->nserv = serv;
5298 + mutt_message (_("Selecting %s..."), nntp_data->group);
5300 + if (!nntp_data->desc)
5302 + nntp_get_desc (nntp_data, nntp_data->group, NULL);
5303 + if (nntp_data->desc)
5304 + nntp_save_cache_index (serv);
5308 + if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5311 + nntp_error ("nntp_open_mailbox()", buf);
5316 + if (mutt_strncmp ("211", buf, 3))
5318 + LIST *l = serv->list;
5320 + /* GROUP command failed */
5321 + if (!mutt_strncmp ("411", buf, 3))
5323 + mutt_error (_("Newsgroup %s not found on server %s"),
5324 + nntp_data->group, serv->conn->account.host);
5326 + /* CACHE: delete cache and line from .index */
5327 + nntp_delete_cache (nntp_data);
5328 + hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5329 + while (l && l->data != (void *) nntp_data) l = l->next;
5339 + sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5340 + &nntp_data->lastMessage, buf);
5342 + nntp_data->deleted = 0;
5344 + time (&serv->check_time);
5347 + * Check for max adding context. If it is greater than $nntp_context,
5348 + * strip off extra articles
5350 + first = nntp_data->firstMessage;
5351 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5352 + first = nntp_data->lastMessage - NntpContext + 1;
5354 + nntp_data->lastLoaded = first - 1;
5355 + return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5358 +int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5360 + char buf[LONG_STRING];
5361 + char path[_POSIX_PATH_MAX];
5362 + NNTP_CACHE *cache;
5363 + char *m = _("Fetching message...");
5366 + /* see if we already have the message in our cache */
5367 + cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5369 + /* if everything is fine, assign msg->fp and return */
5370 + if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5371 + (msg->fp = fopen (cache->path, "r")))
5374 + /* clear the previous entry */
5375 + unlink (cache->path);
5376 + free (cache->path);
5380 + cache->index = ctx->hdrs[msgno]->index;
5381 + mutt_mktemp (path);
5382 + cache->path = safe_strdup (path);
5383 + if (!(msg->fp = safe_fopen (path, "w+")))
5385 + FREE (&cache->path);
5389 + if (ctx->hdrs[msgno]->article_num == 0)
5390 + snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5391 + ctx->hdrs[msgno]->env->message_id);
5393 + snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5394 + ctx->hdrs[msgno]->article_num);
5396 + ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5397 + msg->fp, ctx->tagged);
5400 + mutt_error (_("Article %d not found on server"),
5401 + ctx->hdrs[msgno]->article_num);
5402 + dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5409 + FREE (&cache->path);
5413 + mutt_free_envelope (&ctx->hdrs[msgno]->env);
5414 + ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5415 + /* fix content length */
5416 + fseek(msg->fp, 0, SEEK_END);
5417 + ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5418 + ctx->hdrs[msgno]->content->offset;
5420 + /* this is called in mutt before the open which fetches the message,
5421 + * which is probably wrong, but we just call it again here to handle
5422 + * the problem instead of fixing it.
5424 + mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5426 + /* These would normally be updated in mx_update_context(), but the
5427 + * full headers aren't parsed with XOVER, so the information wasn't
5430 +#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5431 + ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5432 +#endif /* HAVE_PGP || HAVE_SMIME */
5434 + mutt_clear_error();
5441 +int nntp_post (const char *msg) {
5442 + char buf[LONG_STRING];
5445 + NNTP_DATA *nntp_data;
5447 + if (Context && Context->magic == M_NNTP)
5448 + nntp_data = (NNTP_DATA *)Context->data;
5451 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5452 + !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5454 + mutt_error (_("Can't post article. No connection to news server."));
5457 + nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5460 + if (!(f = safe_fopen (msg, "r")))
5462 + mutt_error (_("Can't post article. Unable to open %s"), msg);
5466 + strfcpy (buf, "POST\r\n", sizeof (buf));
5467 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5469 + mutt_error (_("Can't post article. Connection to %s lost."),
5470 + nntp_data->nserv->conn->account.host);
5473 + if (buf[0] != '3')
5475 + mutt_error (_("Can't post article: %s"), buf);
5481 + while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5483 + len = strlen (buf);
5484 + if (buf[len - 1] == '\n')
5486 + buf[len - 1] = '\r';
5491 + if (buf[1] == '.')
5492 + mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5494 + mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5498 + if (buf[strlen (buf) - 1] != '\n')
5499 + mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5500 + mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5501 + if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5503 + mutt_error (_("Can't post article. Connection to %s lost."),
5504 + nntp_data->nserv->conn->account.host);
5507 + if (buf[0] != '2')
5509 + mutt_error (_("Can't post article: %s"), buf);
5516 +/* nntp_logout_all: close all open connections. */
5517 +void nntp_logout_all (void)
5519 + char buf[LONG_STRING];
5522 + conn = mutt_socket_head ();
5526 + CONNECTION *next = conn->next;
5528 + if (conn->account.type == M_ACCT_TYPE_NNTP)
5530 + mutt_message (_("Closing connection to %s..."), conn->account.host);
5531 + mutt_socket_write (conn, "QUIT\r\n");
5532 + mutt_socket_readln (buf, sizeof (buf), conn);
5533 + mutt_clear_error ();
5534 + mutt_socket_close (conn);
5535 + mutt_socket_free (conn);
5542 +static void nntp_free_acache (NNTP_DATA *data)
5546 + for (i = 0; i < NNTP_CACHE_LEN; i++)
5548 + if (data->acache[i].path)
5550 + unlink (data->acache[i].path);
5551 + FREE (&data->acache[i].path);
5556 +void nntp_delete_data (void *p)
5558 + NNTP_DATA *data = (NNTP_DATA *)p;
5562 + FREE (&data->entries);
5563 + FREE (&data->desc);
5564 + FREE (&data->cache);
5565 + nntp_free_acache (data);
5569 +int nntp_sync_mailbox (CONTEXT *ctx)
5571 + NNTP_DATA *data = ctx->data;
5573 + /* CACHE: update cache and .index files */
5574 + if ((option (OPTSAVEUNSUB) || data->subscribed))
5575 + nntp_save_cache_group (ctx);
5576 + nntp_free_acache (data);
5578 + data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
5582 +int nntp_fastclose_mailbox (CONTEXT *ctx)
5584 + NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
5588 + nntp_free_acache (data);
5589 + if (!data->nserv || !data->nserv->newsgroups || !data->group)
5591 + nntp_save_cache_index (data->nserv);
5592 + if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
5594 + nntp_delete_data (data);
5598 +/* commit changes and terminate connection */
5599 +int nntp_close_mailbox (CONTEXT *ctx)
5603 + mutt_message _("Quitting newsgroup...");
5606 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
5609 + if (data->nserv && data->nserv->conn && ctx->unread)
5611 + ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
5613 + mutt_newsgroup_catchup (data->nserv, data->group);
5618 + nntp_sync_mailbox (ctx);
5619 + if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
5621 + NNTP_SERVER *news;
5623 + news = ((NNTP_DATA *)ctx->data)->nserv;
5624 + newsrc_gen_entries (ctx);
5625 + ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
5626 + mutt_newsrc_update (news);
5628 + mutt_clear_error();
5632 +/* use the GROUP command to poll for new mail */
5633 +static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
5635 + char buf[LONG_STRING];
5638 + if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
5642 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5645 + nntp_error ("nntp_check_mailbox()", buf);
5649 + if (mutt_strncmp ("211", buf, 3))
5652 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5655 + nntp_error ("nntp_check_mailbox()", buf);
5660 + if (!mutt_strncmp ("211", buf, 3))
5665 + sscanf (buf + 4, "%d %d %d", &count, &first, &last);
5666 + nntp_data->firstMessage = first;
5667 + nntp_data->lastMessage = last;
5668 + if (ctx && last > nntp_data->lastLoaded)
5670 + nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
5671 + time (&nntp_data->nserv->check_time);
5674 + if (!last || (!nntp_data->rc && !nntp_data->lastCached))
5675 + nntp_data->unread = count;
5677 + mutt_newsgroup_stat (nntp_data);
5678 + /* active was renumbered? */
5679 + if (last < nntp_data->lastLoaded)
5681 + if (!nntp_data->max)
5683 + nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
5684 + nntp_data->max = 5;
5686 + nntp_data->lastCached = 0;
5687 + nntp_data->num = 1;
5688 + nntp_data->entries[0].first = 1;
5689 + nntp_data->entries[0].last = 0;
5693 + time (&nntp_data->nserv->check_time);
5697 +int nntp_check_mailbox (CONTEXT *ctx)
5699 + return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
5702 +static int add_group (char *buf, void *serv)
5704 +#define s ((NNTP_SERVER *) serv)
5705 + char group[LONG_STRING], mod, desc[HUGE_STRING];
5707 + NNTP_DATA *nntp_data;
5710 + _checked = n; /* _checked have N, where N = number of groups */
5711 + if (!buf) /* at EOF must be zerouth */
5718 + sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
5721 + if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
5724 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
5725 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5726 + strcpy (nntp_data->group, group);
5727 + nntp_data->nserv = s;
5728 + if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
5729 + s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2, 0);
5730 + hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
5731 + nntp_add_to_list (s, nntp_data);
5733 + nntp_data->deleted = 0;
5734 + nntp_data->firstMessage = first;
5735 + nntp_data->lastMessage = last;
5737 + nntp_data->allowed = 1;
5739 + nntp_data->allowed = 0;
5740 + if (nntp_data->desc)
5741 + FREE (&nntp_data->desc);
5743 + nntp_data->desc = safe_strdup (desc);
5744 + if (nntp_data->rc || nntp_data->lastCached)
5745 + mutt_newsgroup_stat (nntp_data);
5746 + else if (nntp_data->lastMessage &&
5747 + nntp_data->firstMessage <= nntp_data->lastMessage)
5748 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
5750 + nntp_data->unread = 0;
5756 +int nntp_check_newgroups (NNTP_SERVER *serv, int force)
5758 + char buf[LONG_STRING];
5759 + char msg[SHORT_STRING];
5760 + NNTP_DATA nntp_data;
5765 + unsigned int count = 0;
5766 + unsigned int total = 0;
5768 + if (!serv || !serv->newgroups_time)
5771 + if (nntp_open_connection (serv) < 0)
5774 + /* check subscribed groups for new news */
5775 + if (option (OPTSHOWNEWNEWS))
5777 + mutt_message _("Checking for new messages...");
5778 + for (l = serv->list; l; l = l->next)
5780 + serv->check_time = 0; /* really check! */
5781 + if (l->data && ((NNTP_DATA *) l->data)->subscribed)
5782 + _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
5788 + mutt_message _("Checking for new newsgroups...");
5789 + now = serv->newgroups_time;
5790 + time (&serv->newgroups_time);
5791 + t = gmtime (&now);
5792 + snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
5793 + (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
5795 + nntp_data.nserv = serv;
5796 + if (Context && Context->magic == M_NNTP)
5797 + nntp_data.group = ((NNTP_DATA *)Context->data)->group;
5799 + nntp_data.group = NULL;
5801 + if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
5802 + add_group, serv, 0) != 0)
5805 + nntp_error ("nntp_check_newgroups()", buf);
5810 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5811 + mutt_message (msg);
5813 + emp.next = l->next;
5815 + emp.next = serv->list;
5820 + ((NNTP_DATA *) l->data)->new = 1;
5827 + nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
5829 + if (ReadInc && (count % ReadInc == 0))
5830 + mutt_message ("%s %d/%d", msg, count, total);
5833 + nntp_save_cache_index (serv);
5834 + mutt_clear_error ();
5838 +/* Load list of all newsgroups from cache ALL */
5839 +int nntp_get_cache_all (NNTP_SERVER *serv)
5841 + char buf[HUGE_STRING];
5844 + nntp_cache_expand (buf, serv->cache);
5845 + if ((f = safe_fopen (buf, "r")))
5849 + while (fgets (buf, sizeof(buf), f) != NULL)
5851 + if (ReadInc && (i % ReadInc == 0))
5852 + mutt_message (_("Loading list from cache... %d"), i);
5853 + add_group (buf, serv);
5856 + add_group (NULL, NULL);
5858 + mutt_clear_error ();
5863 + FREE (&serv->cache);
5868 +/* Load list of all newsgroups from active */
5869 +int nntp_get_active (NNTP_SERVER *serv)
5871 + char msg[SHORT_STRING];
5872 + NNTP_DATA nntp_data;
5875 + if (nntp_open_connection (serv) < 0)
5878 + snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
5879 + serv->conn->account.host);
5880 + mutt_message (msg);
5881 + time (&serv->newgroups_time);
5882 + nntp_data.nserv = serv;
5883 + nntp_data.group = NULL;
5885 + if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
5888 + nntp_error ("nntp_get_active()", "LIST\r\n");
5893 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5894 + mutt_message (msg);
5895 + nntp_get_desc (&nntp_data, "*", msg);
5897 + for (tmp = serv->list; tmp; tmp = tmp->next)
5899 + NNTP_DATA *data = (NNTP_DATA *)tmp->data;
5901 + if (data && data->deleted && !data->rc)
5903 + nntp_delete_cache (data);
5904 + hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
5908 + nntp_save_cache_index (serv);
5910 + mutt_clear_error ();
5915 + * returns -1 if error ocurred while retrieving header,
5916 + * number of articles which ones exist in context on success.
5918 +int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
5922 + /* if msgid is already in context, don't reload them */
5923 + if (hash_find (ctx->id_hash, msgid))
5925 + if (ctx->msgcount == ctx->hdrmax)
5926 + mx_alloc_memory (ctx);
5927 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5928 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5930 + mutt_message (_("Fetching %s from server..."), msgid);
5931 + ret = nntp_read_header (ctx, msgid, 0);
5932 + /* since nntp_read_header() may set read flag, we must reset it */
5933 + ctx->hdrs[ctx->msgcount]->read = 0;
5935 + mutt_free_header (&ctx->hdrs[ctx->msgcount]);
5939 + mx_update_context (ctx, 1);
5950 + unsigned int *child;
5953 +static int check_children (char *s, void *c)
5955 +#define cc ((CHILD_CONTEXT *) c)
5956 + unsigned int i, n;
5958 + if (!s || (n = atoi (s)) == 0)
5960 + for (i = 0; i < cc->ctx->msgcount; i++)
5961 + if (cc->ctx->hdrs[i]->article_num == n)
5963 + if (cc->num >= cc->max)
5964 + safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
5965 + cc->child[cc->num++] = n;
5971 +int nntp_check_children (CONTEXT *ctx, const char *msgid)
5973 + NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
5975 + int i, ret = 0, tmp = 0;
5978 + if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
5979 + !nntp_data->nserv->conn->account.host)
5981 + if (nntp_data->firstMessage > nntp_data->lastLoaded)
5983 + if (!nntp_data->nserv->hasXPAT)
5985 + mutt_error (_("Server %s does not support this operation!"),
5986 + nntp_data->nserv->conn->account.host);
5990 + snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
5991 + nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
5996 + cc.child = safe_malloc (sizeof (unsigned int) * 25);
5997 + if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
6002 + /* dont try to read the xover cache. check_children() already
6003 + * made sure that we dont have the article, so we need to visit
6004 + * the server. Reading the cache at this point is also bad
6005 + * because it would duplicate messages */
6006 + if (option (OPTNEWSCACHE))
6009 + unset_option (OPTNEWSCACHE);
6011 + for (i = 0; i < cc.num; i++)
6013 + if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
6015 + if (ctx->msgcount &&
6016 + ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
6017 + ctx->hdrs[ctx->msgcount - 1]->read = 0;
6020 + set_option (OPTNEWSCACHE);
6024 diff -udprP mutt-1.5.20.orig/nntp.h mutt-1.5.20/nntp.h
6025 --- mutt-1.5.20.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
6026 +++ mutt-1.5.20/nntp.h 2009-06-15 21:05:24.000000000 +0300
6029 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
6030 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
6031 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
6033 + * This program is free software; you can redistribute it and/or modify
6034 + * it under the terms of the GNU General Public License as published by
6035 + * the Free Software Foundation; either version 2 of the License, or
6036 + * (at your option) any later version.
6038 + * This program is distributed in the hope that it will be useful,
6039 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6040 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6041 + * GNU General Public License for more details.
6043 + * You should have received a copy of the GNU General Public License
6044 + * along with this program; if not, write to the Free Software
6045 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6051 +#include "mutt_socket.h"
6052 +#include "mailbox.h"
6056 +#define NNTP_PORT 119
6057 +#define NNTP_SSL_PORT 563
6059 +/* number of entries in the hash table */
6060 +#define NNTP_CACHE_LEN 10
6077 + unsigned int hasXPAT : 1;
6078 + unsigned int hasXGTITLE : 1;
6079 + unsigned int hasXOVER : 1;
6080 + unsigned int hasLISTGROUP : 1;
6081 + unsigned int status : 3;
6087 + time_t newgroups_time;
6088 + time_t check_time;
6090 + LIST *list; /* list of newsgroups */
6091 + LIST *tail; /* last entry of list */
6097 + unsigned int index;
6103 + NEWSRC_ENTRY *entries;
6104 + unsigned int num; /* number of used entries */
6105 + unsigned int max; /* number of allocated entries */
6106 + unsigned int unread;
6107 + unsigned int firstMessage;
6108 + unsigned int lastMessage;
6109 + unsigned int lastLoaded;
6110 + unsigned int lastCached;
6111 + unsigned int subscribed : 1;
6112 + unsigned int rc : 1;
6113 + unsigned int new : 1;
6114 + unsigned int allowed : 1;
6115 + unsigned int deleted : 1;
6119 + NNTP_SERVER *nserv;
6120 + NNTP_CACHE acache[NNTP_CACHE_LEN];
6123 +/* internal functions */
6124 +int nntp_get_active (NNTP_SERVER *);
6125 +int nntp_get_cache_all (NNTP_SERVER *);
6126 +int nntp_save_cache_index (NNTP_SERVER *);
6127 +int nntp_check_newgroups (NNTP_SERVER *, int);
6128 +int nntp_save_cache_group (CONTEXT *);
6129 +int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6130 +void newsrc_gen_entries (CONTEXT *);
6131 +void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6132 +void mutt_newsgroup_stat (NNTP_DATA *);
6133 +void nntp_delete_cache (NNTP_DATA *);
6134 +void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6135 +void nntp_cache_expand (char *, const char *);
6136 +void nntp_delete_data (void *);
6138 +/* exposed interface */
6139 +NNTP_SERVER *mutt_select_newsserver (char *);
6140 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6141 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6142 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6143 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6144 +void nntp_clear_cacheindex (NNTP_SERVER *);
6145 +int mutt_newsrc_update (NNTP_SERVER *);
6146 +int nntp_open_mailbox (CONTEXT *);
6147 +int nntp_sync_mailbox (CONTEXT *);
6148 +int nntp_check_mailbox (CONTEXT *);
6149 +int nntp_close_mailbox (CONTEXT *);
6150 +int nntp_fastclose_mailbox (CONTEXT *);
6151 +int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6152 +int nntp_post (const char *);
6153 +int nntp_check_msgid (CONTEXT *, const char *);
6154 +int nntp_check_children (CONTEXT *, const char *);
6155 +void nntp_buffy (char *);
6156 +void nntp_expand_path (char *, size_t, ACCOUNT *);
6157 +void nntp_logout_all ();
6158 +const char *nntp_format_str (char *, size_t, size_t, char, const char *, const char *,
6159 + const char *, const char *, unsigned long, format_flag);
6161 +NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6163 +#endif /* _NNTP_H_ */
6164 diff -udprP mutt-1.5.20.orig/pager.c mutt-1.5.20/pager.c
6165 --- mutt-1.5.20.orig/pager.c 2009-06-03 23:48:31.000000000 +0300
6166 +++ mutt-1.5.20/pager.c 2009-06-15 21:05:24.000000000 +0300
6167 @@ -1059,6 +1059,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
6177 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6178 int flags, ansi_attr *pa, int cnt,
6179 @@ -1512,6 +1517,16 @@ static struct mapping_t PagerHelpExtra[]
6184 +static struct mapping_t PagerNewsHelpExtra[] = {
6185 + { N_("Post"), OP_POST },
6186 + { N_("Followup"), OP_FOLLOWUP },
6187 + { N_("Del"), OP_DELETE },
6188 + { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6195 /* This pager is actually not so simple as it once was. It now operates in
6196 @@ -1553,6 +1568,10 @@ mutt_pager (const char *banner, const ch
6197 int old_PagerIndexLines; /* some people want to resize it
6198 * while inside the pager... */
6201 + char *followup_to;
6204 if (!(flags & M_SHOWCOLOR))
6205 flags |= M_SHOWFLAT;
6207 @@ -1592,7 +1611,11 @@ mutt_pager (const char *banner, const ch
6208 if (IsHeader (extra))
6210 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6211 - mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6212 + mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6214 + (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6217 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6220 @@ -2465,6 +2488,15 @@ search_next:
6222 CHECK_ACL(M_ACL_WRITE, "flag message");
6225 + if (Context->magic == M_NNTP)
6228 + mutt_error _("Can't change 'important' flag on NNTP server.");
6233 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6234 redraw = REDRAW_STATUS | REDRAW_INDEX;
6235 if (option (OPTRESOLVE))
6236 @@ -2498,6 +2530,60 @@ search_next:
6237 redraw = REDRAW_FULL;
6242 + CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6244 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6245 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6246 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6248 + ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6249 + redraw = REDRAW_FULL;
6252 + case OP_FORWARD_TO_GROUP:
6253 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6255 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6256 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6257 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6259 + if (IsMsgAttach (extra))
6260 + mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6261 + extra->idxlen, extra->bdy, SENDNEWS);
6263 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6264 + redraw = REDRAW_FULL;
6268 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6271 + if (IsMsgAttach (extra))
6272 + followup_to = extra->bdy->hdr->env->followup_to;
6274 + followup_to = extra->hdr->env->followup_to;
6276 + if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6277 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6279 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6280 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6281 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6283 + if (IsMsgAttach (extra))
6284 + mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6285 + extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6287 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6288 + extra->ctx, extra->hdr);
6289 + redraw = REDRAW_FULL;
6295 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6297 @@ -2544,7 +2630,7 @@ search_next:
6299 if (IsMsgAttach (extra))
6300 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6301 - extra->idxlen, extra->bdy);
6302 + extra->idxlen, extra->bdy, 0);
6304 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6305 redraw = REDRAW_FULL;
6306 diff -udprP mutt-1.5.20.orig/parse.c mutt-1.5.20/parse.c
6307 --- mutt-1.5.20.orig/parse.c 2009-06-01 19:29:32.000000000 +0300
6308 +++ mutt-1.5.20/parse.c 2009-06-15 21:05:24.000000000 +0300
6309 @@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
6313 -static LIST *mutt_parse_references (char *s, int in_reply_to)
6314 +LIST *mutt_parse_references (char *s, int in_reply_to)
6316 LIST *t, *lst = NULL;
6318 @@ -1067,6 +1067,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6319 e->from = rfc822_parse_adrlist (e->from, p);
6323 + else if (!mutt_strcasecmp (line+1, "ollowup-to"))
6325 + if (!e->followup_to)
6327 + mutt_remove_trailing_ws (p);
6328 + e->followup_to = safe_strdup (mutt_skip_whitespace (p));
6336 @@ -1149,6 +1160,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6342 + if (!mutt_strcasecmp (line + 1, "ewsgroups"))
6344 + FREE (&e->newsgroups);
6345 + mutt_remove_trailing_ws (p);
6346 + e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
6353 + /* field `Organization:' saves only for pager! */
6354 + if (!mutt_strcasecmp (line + 1, "rganization"))
6356 + if (!e->organization && mutt_strcasecmp (p, "unknown"))
6357 + e->organization = safe_strdup (p);
6362 if (!ascii_strcasecmp (line + 1, "eferences"))
6364 @@ -1257,6 +1289,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6365 e->x_label = safe_strdup(p);
6369 + else if (!mutt_strcasecmp (line + 1, "-comment-to"))
6371 + if (!e->x_comment_to)
6372 + e->x_comment_to = safe_strdup (p);
6375 + else if (!mutt_strcasecmp (line + 1, "ref"))
6378 + e->xref = safe_strdup (p);
6385 diff -udprP mutt-1.5.20.orig/pattern.c mutt-1.5.20/pattern.c
6386 --- mutt-1.5.20.orig/pattern.c 2009-06-03 23:48:31.000000000 +0300
6387 +++ mutt-1.5.20/pattern.c 2009-06-15 21:05:24.000000000 +0300
6388 @@ -91,6 +91,9 @@ Flags[] =
6389 { 'U', M_UNREAD, 0, NULL },
6390 { 'v', M_COLLAPSED, 0, NULL },
6391 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6393 + { 'w', M_NEWSGROUPS, 0, eat_regexp },
6395 { 'x', M_REFERENCE, 0, eat_regexp },
6396 { 'X', M_MIMEATTACH, 0, eat_range },
6397 { 'y', M_XLABEL, 0, eat_regexp },
6398 @@ -1204,6 +1207,10 @@ mutt_pattern_exec (struct pattern_t *pat
6400 case M_UNREFERENCED:
6401 return (pat->not ^ (h->thread && !h->thread->child));
6403 + case M_NEWSGROUPS:
6404 + return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6407 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6409 @@ -1285,6 +1292,7 @@ int mutt_pattern_func (int op, char *pro
6410 progress_t progress;
6412 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6413 + if (prompt || op != M_LIMIT)
6414 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6417 diff -udprP mutt-1.5.20.orig/po/POTFILES.in mutt-1.5.20/po/POTFILES.in
6418 --- mutt-1.5.20.orig/po/POTFILES.in 2008-11-11 21:55:47.000000000 +0200
6419 +++ mutt-1.5.20/po/POTFILES.in 2009-06-15 21:05:24.000000000 +0300
6420 @@ -46,6 +46,8 @@ mutt_ssl_gnutls.c
6429 diff -udprP mutt-1.5.20.orig/postpone.c mutt-1.5.20/postpone.c
6430 --- mutt-1.5.20.orig/postpone.c 2009-06-14 00:28:37.000000000 +0300
6431 +++ mutt-1.5.20/postpone.c 2009-06-15 21:05:24.000000000 +0300
6432 @@ -124,15 +124,26 @@ int mutt_num_postponed (int force)
6434 if (LastModify < st.st_mtime)
6437 + int optnews = option (OPTNEWS);
6439 LastModify = st.st_mtime;
6441 if (access (Postponed, R_OK | F_OK) != 0)
6442 return (PostCount = 0);
6445 + unset_option (OPTNEWS);
6447 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6450 PostCount = ctx.msgcount;
6451 mx_fastclose_mailbox (&ctx);
6454 + set_option (OPTNEWS);
6459 diff -udprP mutt-1.5.20.orig/protos.h mutt-1.5.20/protos.h
6460 --- mutt-1.5.20.orig/protos.h 2009-06-13 02:38:52.000000000 +0300
6461 +++ mutt-1.5.20/protos.h 2009-06-15 21:05:24.000000000 +0300
6462 @@ -115,6 +115,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
6463 HASH *mutt_make_subj_hash (CONTEXT *);
6465 LIST *mutt_make_references(ENVELOPE *e);
6466 +LIST *mutt_parse_references (char *, int);
6468 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6469 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
6470 diff -udprP mutt-1.5.20.orig/recvattach.c mutt-1.5.20/recvattach.c
6471 --- mutt-1.5.20.orig/recvattach.c 2009-05-19 03:11:35.000000000 +0300
6472 +++ mutt-1.5.20/recvattach.c 2009-06-15 21:05:24.000000000 +0300
6473 @@ -1110,6 +1110,15 @@ void mutt_view_attachments (HEADER *hdr)
6478 + if (Context->magic == M_NNTP)
6481 + mutt_error _("Can't delete attachment from newsserver.");
6486 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6489 @@ -1201,10 +1210,33 @@ void mutt_view_attachments (HEADER *hdr)
6490 case OP_FORWARD_MESSAGE:
6492 mutt_attach_forward (fp, hdr, idx, idxlen,
6493 - menu->tagprefix ? NULL : idx[menu->current]->content);
6494 + menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6495 menu->redraw = REDRAW_FULL;
6499 + case OP_FORWARD_TO_GROUP:
6501 + mutt_attach_forward (fp, hdr, idx, idxlen,
6502 + menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6503 + menu->redraw = REDRAW_FULL;
6509 + if (!idx[menu->current]->content->hdr->env->followup_to ||
6510 + mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6511 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6513 + mutt_attach_reply (fp, hdr, idx, idxlen,
6514 + menu->tagprefix ? NULL : idx[menu->current]->content,
6515 + SENDNEWS|SENDREPLY);
6516 + menu->redraw = REDRAW_FULL;
6522 case OP_GROUP_REPLY:
6524 diff -udprP mutt-1.5.20.orig/recvcmd.c mutt-1.5.20/recvcmd.c
6525 --- mutt-1.5.20.orig/recvcmd.c 2009-06-12 20:24:17.000000000 +0300
6526 +++ mutt-1.5.20/recvcmd.c 2009-06-15 21:05:24.000000000 +0300
6527 @@ -401,7 +401,7 @@ static BODY ** copy_problematic_attachme
6528 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6529 ATTACHPTR ** idx, short idxlen,
6532 + short nattach, int flags)
6535 short mime_fwd_all = 0;
6536 @@ -547,7 +547,7 @@ _("Can't decode all tagged attachments.
6539 /* now that we have the template, send it. */
6540 - ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6541 + ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6545 @@ -574,7 +574,7 @@ _("Can't decode all tagged attachments.
6548 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6549 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6550 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6552 HEADER *curhdr = NULL;
6554 @@ -679,23 +679,23 @@ static void attach_forward_msgs (FILE *
6556 mutt_free_header (&tmphdr);
6558 - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6559 + ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
6564 void mutt_attach_forward (FILE * fp, HEADER * hdr,
6565 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6566 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6571 if (check_all_msg (idx, idxlen, cur, 0) == 0)
6572 - attach_forward_msgs (fp, hdr, idx, idxlen, cur);
6573 + attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
6576 nattach = count_tagged (idx, idxlen);
6577 - attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
6578 + attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
6582 @@ -753,28 +753,40 @@ attach_reply_envelope_defaults (ENVELOPE
6588 + if ((flags & SENDNEWS))
6590 - if (mutt_fetch_recips (env, curenv, flags) == -1)
6592 + /* in case followup set Newsgroups: with Followup-To: if it present */
6593 + if (!env->newsgroups && curenv &&
6594 + mutt_strcasecmp (curenv->followup_to, "poster"))
6595 + env->newsgroups = safe_strdup (curenv->followup_to);
6600 - for (i = 0; i < idxlen; i++)
6603 - if (idx[i]->content->tagged
6604 - && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6605 + if (mutt_fetch_recips (env, curenv, flags) == -1)
6610 + for (i = 0; i < idxlen; i++)
6612 + if (idx[i]->content->tagged
6613 + && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6618 + if ((flags & SENDLISTREPLY) && !env->to)
6620 + mutt_error _("No mailing lists found!");
6624 + mutt_fix_reply_recipients (env);
6627 - if ((flags & SENDLISTREPLY) && !env->to)
6629 - mutt_error _("No mailing lists found!");
6633 - mutt_fix_reply_recipients (env);
6634 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
6637 @@ -835,6 +847,13 @@ void mutt_attach_reply (FILE * fp, HEADE
6638 char prefix[SHORT_STRING];
6642 + if (flags & SENDNEWS)
6643 + set_option (OPTNEWSSEND);
6645 + unset_option (OPTNEWSSEND);
6648 if (check_all_msg (idx, idxlen, cur, 0) == -1)
6650 nattach = count_tagged (idx, idxlen);
6651 diff -udprP mutt-1.5.20.orig/rfc1524.c mutt-1.5.20/rfc1524.c
6652 --- mutt-1.5.20.orig/rfc1524.c 2009-05-30 20:20:08.000000000 +0300
6653 +++ mutt-1.5.20/rfc1524.c 2009-06-15 21:05:24.000000000 +0300
6654 @@ -569,13 +569,13 @@ int rfc1524_expand_filename (char *namet
6658 -int mutt_rename_file (char *oldfile, char *newfile)
6659 +int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
6663 if (access (oldfile, F_OK) != 0)
6665 - if (access (newfile, F_OK) == 0)
6666 + if (!overwrite && access (newfile, F_OK) == 0)
6668 if ((ofp = fopen (oldfile,"r")) == NULL)
6670 @@ -590,3 +590,8 @@ int mutt_rename_file (char *oldfile, cha
6671 mutt_unlink (oldfile);
6675 +int mutt_rename_file (char *oldfile, char *newfile)
6677 + return _mutt_rename_file (oldfile, newfile, 0);
6679 diff -udprP mutt-1.5.20.orig/rfc1524.h mutt-1.5.20/rfc1524.h
6680 --- mutt-1.5.20.orig/rfc1524.h 2008-11-11 21:55:47.000000000 +0200
6681 +++ mutt-1.5.20/rfc1524.h 2009-06-15 21:05:24.000000000 +0300
6682 @@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char
6683 int rfc1524_expand_filename (char *, char *, char *, size_t);
6684 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
6685 int mutt_rename_file (char *, char *);
6686 +int _mutt_rename_file (char *, char *, int);
6688 #endif /* _RFC1524_H */
6689 diff -udprP mutt-1.5.20.orig/send.c mutt-1.5.20/send.c
6690 --- mutt-1.5.20.orig/send.c 2009-06-13 02:38:52.000000000 +0300
6691 +++ mutt-1.5.20/send.c 2009-06-15 21:13:13.000000000 +0300
6693 #include <sys/types.h>
6702 #include "remailer.h"
6704 @@ -213,17 +218,51 @@ static int edit_address (ADDRESS **a, /*
6708 -static int edit_envelope (ENVELOPE *en)
6709 +static int edit_envelope (ENVELOPE *en, int flags)
6711 char buf[HUGE_STRING];
6712 LIST *uh = UserHeader;
6714 - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6716 - if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6718 - if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6721 + if (option (OPTNEWSSEND))
6723 + if (en->newsgroups)
6724 + strfcpy (buf, en->newsgroups, sizeof (buf));
6727 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
6729 + FREE (&en->newsgroups);
6730 + en->newsgroups = safe_strdup (buf);
6732 + if (en->followup_to)
6733 + strfcpy (buf, en->followup_to, sizeof (buf));
6736 + if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
6738 + FREE (&en->followup_to);
6739 + en->followup_to = safe_strdup (buf);
6741 + if (en->x_comment_to)
6742 + strfcpy (buf, en->x_comment_to, sizeof (buf));
6745 + if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
6747 + FREE (&en->x_comment_to);
6748 + en->x_comment_to = safe_strdup (buf);
6753 + if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6755 + if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6757 + if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6763 @@ -259,6 +298,14 @@ static int edit_envelope (ENVELOPE *en)
6768 +char *nntp_get_header (const char *s)
6771 + return safe_strdup (s);
6775 static void process_user_recips (ENVELOPE *env)
6777 LIST *uh = UserHeader;
6778 @@ -271,6 +318,14 @@ static void process_user_recips (ENVELOP
6779 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
6780 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
6781 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
6783 + else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
6784 + env->newsgroups = nntp_get_header (uh->data + 11);
6785 + else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
6786 + env->followup_to = nntp_get_header (uh->data + 12);
6787 + else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
6788 + env->x_comment_to = nntp_get_header (uh->data + 13);
6793 @@ -309,6 +364,12 @@ static void process_user_header (ENVELOP
6794 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
6795 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
6796 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
6798 + ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
6799 + ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
6800 + ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
6802 + ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
6803 ascii_strncasecmp ("subject:", uh->data, 8) != 0 &&
6804 ascii_strncasecmp ("return-path:", uh->data, 12) != 0)
6806 @@ -657,6 +718,10 @@ void mutt_add_to_reference_headers (ENVE
6811 + if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
6812 + env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
6817 @@ -719,6 +784,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
6819 if (flags & SENDREPLY)
6822 + if ((flags & SENDNEWS))
6824 + /* in case followup set Newsgroups: with Followup-To: if it present */
6825 + if (!env->newsgroups && curenv &&
6826 + mutt_strcasecmp (curenv->followup_to, "poster"))
6827 + env->newsgroups = safe_strdup (curenv->followup_to);
6834 @@ -865,7 +940,18 @@ void mutt_set_followup_to (ENVELOPE *e)
6835 * it hasn't already been set
6838 - if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
6839 + if (!option (OPTFOLLOWUPTO))
6842 + if (option (OPTNEWSSEND))
6844 + if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
6845 + e->followup_to = safe_strdup (e->newsgroups);
6850 + if (!e->mail_followup_to)
6852 if (mutt_is_list_cc (0, e->to, e->cc))
6854 @@ -1026,6 +1112,9 @@ static int send_message (HEADER *msg)
6859 + if (!option (OPTNEWSSEND))
6860 +#endif /* USE_NNTP */
6862 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
6863 msg->env->bcc, tempfile,
6864 @@ -1137,6 +1226,13 @@ ci_send_message (int flags, /* send mod
6869 + if (flags & SENDNEWS)
6870 + set_option (OPTNEWSSEND);
6872 + unset_option (OPTNEWSSEND);
6875 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
6876 mutt_num_postponed (1))
6878 @@ -1167,6 +1263,22 @@ ci_send_message (int flags, /* send mod
6880 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
6884 + * If postponed message is a news article, it have
6885 + * a "Newsgroups:" header line, then set appropriate flag.
6887 + if (msg->env->newsgroups)
6889 + flags |= SENDNEWS;
6890 + set_option (OPTNEWSSEND);
6894 + flags &= ~SENDNEWS;
6895 + unset_option (OPTNEWSSEND);
6900 if (flags & (SENDPOSTPONED|SENDRESEND))
6901 @@ -1278,11 +1390,16 @@ ci_send_message (int flags, /* send mod
6902 if (flags & SENDREPLY)
6903 mutt_fix_reply_recipients (msg->env);
6906 + if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
6907 + msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
6910 if (! (flags & SENDMAILX) &&
6911 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
6912 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
6914 - if (edit_envelope (msg->env) == -1)
6915 + if (edit_envelope (msg->env, flags) == -1)
6919 @@ -1539,6 +1656,11 @@ main_loop:
6924 + if (flags & SENDNEWS)
6925 + mutt_message _("Article not posted.");
6928 mutt_message _("Mail not sent.");
6931 @@ -1571,6 +1693,9 @@ main_loop:
6936 + if (!(flags & SENDNEWS))
6938 if (!has_recips (msg->env->to) && !has_recips (msg->env->cc) &&
6939 !has_recips (msg->env->bcc))
6941 @@ -1604,6 +1729,19 @@ main_loop:
6942 mutt_error _("No subject specified.");
6946 + if ((flags & SENDNEWS) && !msg->env->subject)
6948 + mutt_error _("No subject specified.");
6952 + if ((flags & SENDNEWS) && !msg->env->newsgroups)
6954 + mutt_error _("No newsgroup specified.");
6959 if (msg->content->next)
6960 msg->content = mutt_make_multipart (msg->content);
6961 @@ -1810,7 +1948,12 @@ full_fcc:
6964 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
6965 - mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
6966 + mutt_message (i != 0 ? _("Sending in background.") :
6968 + (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
6973 if (WithCrypto && (msg->security & ENCRYPT))
6975 diff -udprP mutt-1.5.20.orig/sendlib.c mutt-1.5.20/sendlib.c
6976 --- mutt-1.5.20.orig/sendlib.c 2009-06-14 18:46:11.000000000 +0300
6977 +++ mutt-1.5.20/sendlib.c 2009-06-15 21:51:17.000000000 +0300
6979 #include <sys/wait.h>
6986 #ifdef HAVE_SYSEXITS_H
6987 #include <sysexits.h>
6988 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
6989 @@ -1868,6 +1872,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 @@ -1876,6 +1883,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 @@ -1887,8 +1897,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, 0);
7038 @@ -1907,6 +1937,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 @@ -2245,11 +2278,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 @@ -2273,6 +2325,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7085 + if (!option (OPTNEWSSEND))
7088 if (eightbit && option (OPTUSE8BITMIME))
7089 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7091 @@ -2304,6 +2360,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 @@ -2384,6 +2443,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 @@ -2504,6 +2566,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.20.orig/sort.c mutt-1.5.20/sort.c
7123 --- mutt-1.5.20.orig/sort.c 2008-11-11 21:55:47.000000000 +0200
7124 +++ mutt-1.5.20/sort.c 2009-06-15 21:05:24.000000000 +0300
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.20.orig/url.c mutt-1.5.20/url.c
7142 --- mutt-1.5.20.orig/url.c 2009-06-01 19:29:32.000000000 +0300
7143 +++ mutt-1.5.20/url.c 2009-06-15 21:05:24.000000000 +0300
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.20.orig/url.h mutt-1.5.20/url.h
7154 --- mutt-1.5.20.orig/url.h 2008-11-11 21:55:47.000000000 +0200
7155 +++ mutt-1.5.20/url.h 2009-06-15 21:05:24.000000000 +0300
7156 @@ -8,6 +8,8 @@ typedef enum url_scheme
7165 diff -udprP mutt-1.5.20.orig/Makefile.am mutt-1.5.20/Makefile.am
7166 --- mutt-1.5.20.orig/Makefile.am 2009-01-05 04:11:29.000000000 +0200
7167 +++ mutt-1.5.20/Makefile.am 2009-06-15 21:05:24.000000000 +0300
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.20.orig/Makefile.in mutt-1.5.20/Makefile.in
7185 --- mutt-1.5.20.orig/Makefile.in 2009-06-09 09:50:44.000000000 +0300
7186 +++ mutt-1.5.20/Makefile.in 2009-06-15 21:05:24.000000000 +0300
7187 @@ -372,6 +372,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 @@ -383,6 +384,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 @@ -637,6 +639,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.20.orig/configure mutt-1.5.20/configure
7213 --- mutt-1.5.20.orig/configure 2009-06-09 09:50:42.000000000 +0300
7214 +++ mutt-1.5.20/configure 2009-06-15 21:05:24.000000000 +0300
7215 @@ -1478,6 +1478,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 @@ -14198,6 +14199,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.20.orig/doc/Muttrc mutt-1.5.20/doc/Muttrc
7245 --- mutt-1.5.20.orig/doc/Muttrc 2009-06-14 21:53:24.000000000 +0300
7246 +++ mutt-1.5.20/doc/Muttrc 2009-06-15 21:05:24.000000000 +0300
7247 @@ -281,6 +281,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 @@ -466,6 +488,17 @@ attachments -I message/external-body
7277 # set certificate_file=~/.mutt/certificates
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 @@ -1121,6 +1154,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 @@ -1231,6 +1277,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 @@ -1779,6 +1847,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 @@ -1794,12 +1863,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 @@ -1835,6 +1906,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 @@ -2188,6 +2275,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 @@ -2254,6 +2353,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 @@ -2969,6 +3180,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 @@ -3543,6 +3767,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 @@ -4748,3 +5007,14 @@ attachments -I message/external-body
7590 # ``tuning'' section of the manual for performance considerations.
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.