1 WARNING: Run the following script before configure:
9 Vsevolod Volkov <vvv@mutt.org.ua>
12 Index: mutt/ChangeLog.nntp
13 ===================================================================
14 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
15 +++ mutt/ChangeLog.nntp 2011-01-19 02:29:05.161033056 -0300
17 +* Wed Sep 16 2010 Vsevolod Volkov <vvv@mutt.org.ua>
20 +* Thu Aug 13 2009 Vsevolod Volkov <vvv@mutt.org.ua>
21 +- fixed writting references in nntp_save_cache_group()
23 +* Tue Jun 15 2009 Vsevolod Volkov <vvv@mutt.org.ua>
26 +* Tue Mar 20 2009 Vsevolod Volkov <vvv@mutt.org.ua>
27 +- save Date: header of recorded outgoing articles
29 +* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua>
32 +* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua>
34 +- fixed SIGSEGV when followup or forward to newsgroup
36 +* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua>
39 +* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua>
40 +- fixed arguments of nntp_format_str()
42 +* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua>
43 +- fixed error selecting news group
45 +* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua>
48 +* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
49 +- fixed posting error if $smtp_url is set
50 +- added support of print-style sequence %R (x-comment-to)
52 +* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
54 +- nntp://... url changed to news://...
55 +- added indicator of fetching descriptions progress
57 +* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
60 +* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
63 +* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
65 +- fixed reading empty .newsrc
67 +* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
70 +* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
73 +* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
76 +* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
79 +* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
81 +- function mutt_update_list_file() moved to newsrc.c and changed algorithm
83 +* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
84 +- fixed error in nntp_logout_all()
86 +* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
87 +- fixed debug output in mutt_newsrc_update()
88 +- added optional support of LISTGROUP command
89 +- fixed typo in nntp_parse_xref()
91 +* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
94 +* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
97 +* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
100 +* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
102 +- added space after newsgroup name in .newsrc file
104 +* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
105 +- nntp patch: fixed SIGSEGV when posting article
107 +* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
110 +* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
112 +- replace safe_free calls by the FREE macro
114 +* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
116 +- nntp authentication can be passed after any command
118 +* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
121 +* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
124 +* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
126 +- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
127 + <reconstruct-thread> functions
128 +- fixed message about nntp reconnect
129 +- fixed <attach-news-message> function using browser
130 +- added support of Followup-To: poster
131 +- added %n (new articles) in group_index_format
132 +- posting articles without inews by default
134 +* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
137 +* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
140 +* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
142 +- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
143 +- added default content disposition
145 +* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
148 +* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
149 +- update to 1.3.23.2
150 +- fixed segfault if mutt_conn_find() returns null
152 +* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
153 +- update to 1.3.23.1
154 +- added support of LISTGROUP command
155 +- added support for servers with broken overview
156 +- disabled <flag-message> function on news server
157 +- fixed error storing bad authentication information
159 +* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
161 +- fixed typo in buffy.c
162 +- added substitution of %s parameter in $inews variable
164 +* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
165 +- update to 1.3.22.1
168 +* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
171 +* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
173 +- removed 'server-hook', use 'account-hook' instead
174 +- fixed error opening NNTP server without newsgroup using -f option
176 +* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
179 +* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
181 +- fixed typo in nntp_attempt_features()
182 +- changed algorithm of XGTITLE command testing
183 +- disabled writing of NNTP password in debug file
184 +- fixed reading and writing of long newsrc lines
185 +- changed checking of last line while reading lines from server
186 +- fixed possible buffer overrun in nntp_parse_newsrc_line()
187 +- removed checking of XHDR command
188 +- compare NNTP return codes without trailing space
190 +* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
192 +- support for 'LIST NEWSGROUPS' command to read descriptions
194 +* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
197 +* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
200 +* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
202 +- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
204 +* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
207 +* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
208 +- Fixed problem if last article in group is deleted
210 +* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
211 +- Fixed checking of XGTITLE command on some servers
213 +* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
214 +- Added \r in AUTHINFO commands
216 +* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
219 +* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
221 +- fixed error opening newsgroup from mutt started with -g or -G
223 +* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
225 +- hotkey 'G' (get-message) replaced with '^G'
227 +* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
229 +- changed delay displaying error messages from 1 to 2 seconds
230 +- fixed error compiling with nntp and without imap
232 +* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
233 +- fixed catchup in index
234 +- fixed nntp_open_mailbox()
236 +* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
237 +- functions <edit> and <delete-entry> disabled
238 +- format of news mailbox names changed to url form
239 +- option nntp_attempts removed
240 +- option reconnect_news renamed to nntp_reconnect
241 +- default value of nntp_poll changed from 30 to 60
242 +- error handling improved
244 +* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
246 +- new option show_only_unread
247 +- add newsgroup completion
249 +* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
252 +* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
255 +* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
257 +- authentication code update
258 +- fix for changing to newsgroup from mailbox with read messages
259 +- socket code optimization
261 +* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
264 +* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
265 +- don't substitute current newsgroup with deleted new messages
267 +* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
269 +- fix for substitution of newsgroup after reconnection
270 +- fix for loading newsgroups with very long names
271 +- fix for loading more than 32768 newsgroups
273 +* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
276 +* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
279 +* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
282 +* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
285 +* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
288 +* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
291 +* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
292 +- add substitution of newsgroup with new messages by default
294 +* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
295 +- add attach message from newsgroup
296 +- add one-line help in newsreader mode
297 +- disable 'change-dir' command in newsgroups browser
300 +* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
301 +- get default newsserver name from file /etc/nntpserver
302 +- use case insensitive server names
303 +- add print-style sequence %s to $newsrc
306 +* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
307 +- remove 'X-FTN-Origin' header processing
309 +* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
313 +* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
314 +- fix mutt_select_newsserver()
315 +- remove 'toggle-mode' function
316 +- add 'change-newsgroup' function
318 +* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
321 +* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
322 +- fix error 'bounce' function after 'post'
323 +- add 'forward to newsgroup' function
325 +* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
326 +- 'forward' function works in newsreader mode
327 +- add 'post' and 'followup' functions to pager and attachment menu
328 +- fix active descriptions and allowed flag reload
330 +* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
332 +- remove deleted newsgroups from list
334 +* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
335 +- update .newsrc in browser
337 +* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
338 +- reload .newsrc if externally modified
339 +- fix active cache update
341 +* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
344 +* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
345 +- patch *.update_list_file is not required
346 +- count lines when loading descriptions
347 +- remove cache of unsubscribed newsgroups
349 +* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
350 +- load list of newsgroups from cache faster
352 +* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
355 +* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
356 +- fix unread messages in browser
357 +- fix newsrc_gen_entries()
359 +* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
360 +- fix mutt_newsgroup_stat()
361 +- fix nntp_delete_cache()
362 +- fix nntp_get_status()
363 +- fix check_children()
364 +- fix nntp_fetch_headers()
366 +* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
369 +* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
370 +- fix updating new messages in cache
372 +* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
373 +- change default cache filenames
374 +- fix updating new messages in cache
376 +* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
377 +- fix segmentation fault in news groups browser
379 +* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
382 +* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
385 +* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
386 +- add X-Comment-To editing
387 +- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
388 +- add variables $ask_followup_to and $ask_x_comment_to
390 +* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
393 ===================================================================
394 --- mutt.orig/OPS 2011-01-19 02:29:05.114041704 -0300
395 +++ mutt/OPS 2011-01-19 02:29:05.161033056 -0300
397 OP_BROWSER_NEW_FILE "select a new file in this directory"
398 OP_BROWSER_VIEW_FILE "view file"
399 OP_BROWSER_TELL "display the currently selected file's name"
400 -OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
401 -OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
402 +OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
403 +OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
404 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
405 OP_BUFFY_LIST "list mailboxes with new mail"
406 +OP_CATCHUP "mark all articles in newsgroup as read"
407 OP_CHANGE_DIRECTORY "change directories"
408 OP_CHECK_NEW "check mailboxes for new mail"
409 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
410 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
411 +OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message"
412 OP_COMPOSE_EDIT_BCC "edit the BCC list"
413 OP_COMPOSE_EDIT_CC "edit the CC list"
414 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
416 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
417 OP_COMPOSE_EDIT_MESSAGE "edit the message"
418 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
419 +OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
420 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
421 +OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
422 +OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
423 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
424 OP_COMPOSE_EDIT_TO "edit the TO list"
425 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
427 OP_FILTER "filter attachment through a shell command"
428 OP_FIRST_ENTRY "move to the first entry"
429 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
430 +OP_FOLLOWUP "followup to newsgroup"
431 +OP_FORWARD_TO_GROUP "forward to newsgroup"
432 OP_FORWARD_MESSAGE "forward a message with comments"
433 OP_GENERIC_SELECT_ENTRY "select the current entry"
434 +OP_GET_CHILDREN "get all children of the current message"
435 +OP_GET_MESSAGE "get message with Message-Id"
436 +OP_GET_PARENT "get parent of the current message"
437 OP_GROUP_REPLY "reply to all recipients"
438 OP_HALF_DOWN "scroll down 1/2 page"
439 OP_HALF_UP "scroll up 1/2 page"
441 OP_JUMP "jump to an index number"
442 OP_LAST_ENTRY "move to the last entry"
443 OP_LIST_REPLY "reply to specified mailing list"
444 +OP_LOAD_ACTIVE "load active file from NNTP server"
445 OP_MACRO "execute a macro"
446 OP_MAIL "compose a new mail message"
447 OP_MAIN_BREAK_THREAD "break the thread in two"
448 OP_MAIN_CHANGE_FOLDER "open a different folder"
449 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
450 +OP_MAIN_CHANGE_GROUP "open a different newsgroup"
451 +OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
452 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
453 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
454 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
456 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
457 OP_PAGER_TOP "jump to the top of the message"
458 OP_PIPE "pipe message/attachment to a shell command"
459 +OP_POST "post message to newsgroup"
460 OP_PREV_ENTRY "move to the previous entry"
461 OP_PREV_LINE "scroll up one line"
462 OP_PREV_PAGE "move to the previous page"
464 OP_QUERY_APPEND "append new query results to current results"
465 OP_QUIT "save changes to mailbox and quit"
466 OP_RECALL_MESSAGE "recall a postponed message"
467 +OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
468 OP_REDRAW "clear and redraw the screen"
469 OP_REFORMAT_WINCH "{internal}"
470 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
471 @@ -161,18 +176,22 @@
472 OP_SHELL_ESCAPE "invoke a command in a subshell"
473 OP_SORT "sort messages"
474 OP_SORT_REVERSE "sort messages in reverse order"
475 +OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
476 OP_TAG "tag the current entry"
477 OP_TAG_PREFIX "apply next function to tagged messages"
478 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
479 OP_TAG_SUBTHREAD "tag the current subthread"
480 OP_TAG_THREAD "tag the current thread"
481 OP_TOGGLE_NEW "toggle a message's 'new' flag"
482 +OP_TOGGLE_READ "toggle view of read messages"
483 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
484 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
485 OP_TOP_PAGE "move to the top of the page"
486 +OP_UNCATCHUP "mark all articles in newsgroup as unread"
487 OP_UNDELETE "undelete the current entry"
488 OP_UNDELETE_THREAD "undelete all messages in thread"
489 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
490 +OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
491 OP_VERSION "show the Mutt version number and date"
492 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
493 OP_VIEW_ATTACHMENTS "show MIME attachments"
494 Index: mutt/account.c
495 ===================================================================
496 --- mutt.orig/account.c 2011-01-19 02:29:04.836092850 -0300
497 +++ mutt/account.c 2011-01-19 02:29:05.162032872 -0300
503 + if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
507 if (a1->flags & a2->flags & M_ACCT_USER)
508 return (!strcmp (a1->user, a2->user));
509 if (a1->flags & M_ACCT_USER)
515 + if (account->type == M_ACCT_TYPE_NNTP)
517 + if (account->flags & M_ACCT_SSL)
518 + url->scheme = U_NNTPS;
520 + url->scheme = U_NNTP;
524 url->host = account->host;
525 if (account->flags & M_ACCT_PORT)
526 url->port = account->port;
528 else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
529 strfcpy (account->user, PopUser, sizeof (account->user));
532 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
533 + strfcpy (account->user, NntpUser, sizeof (account->user));
535 else if (option (OPTNOCURSES))
537 /* prompt (defaults to unix username), copy into account->user */
539 else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass)
540 strfcpy (account->pass, SmtpPass, sizeof (account->pass));
543 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
544 + strfcpy (account->pass, NntpPass, sizeof (account->pass));
546 else if (option (OPTNOCURSES))
549 Index: mutt/account.h
550 ===================================================================
551 --- mutt.orig/account.h 2011-01-19 02:28:26.196202678 -0300
552 +++ mutt/account.h 2011-01-19 02:29:05.162032872 -0300
554 M_ACCT_TYPE_NONE = 0,
564 ===================================================================
565 --- mutt.orig/attach.h 2011-01-19 02:28:26.166208196 -0300
566 +++ mutt/attach.h 2011-01-19 02:29:05.163032688 -0300
569 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
570 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
571 -void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
572 +void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
573 void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
575 #endif /* _ATTACH_H_ */
576 Index: mutt/browser.c
577 ===================================================================
578 --- mutt.orig/browser.c 2011-01-19 02:29:04.633130198 -0300
579 +++ mutt/browser.c 2011-01-19 02:29:05.164032504 -0300
595 +static struct mapping_t FolderNewsHelp[] = {
596 + { N_("Exit"), OP_EXIT },
597 + { N_("List"), OP_TOGGLE_MAILBOXES },
598 + { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
599 + { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
600 + { N_("Catchup"), OP_CATCHUP },
601 + { N_("Mask"), OP_ENTER_MASK },
602 + { N_("Help"), OP_HELP },
607 typedef struct folder_t
609 struct folder_file *ff;
615 + if (option (OPTNEWS))
618 f = browser_compare_date;
622 + if (option (OPTNEWS))
625 f = browser_compare_size;
628 @@ -325,8 +349,106 @@
634 +newsgroup_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
635 + const char *fmt, const char *ifstring, const char *elsestring,
636 + unsigned long data, format_flag flags)
638 + char fn[SHORT_STRING], tmp[SHORT_STRING];
639 + FOLDER *folder = (FOLDER *) data;
644 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
645 + snprintf (dest, destlen, tmp, folder->num + 1);
649 + strncpy (fn, folder->ff->name, sizeof(fn) - 1);
650 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
651 + snprintf (dest, destlen, tmp, fn);
655 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
656 + if (folder->ff->nd->subscribed)
657 + snprintf (dest, destlen, tmp, ' ');
659 + snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
663 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
664 + if (folder->ff->nd->deleted)
665 + snprintf (dest, destlen, tmp, 'D');
667 + snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
671 + if (flags & M_FORMAT_OPTIONAL)
673 + if (folder->ff->nd->unread != 0)
674 + mutt_FormatString (dest, destlen, col, ifstring, newsgroup_format_str,
677 + mutt_FormatString (dest, destlen, col, elsestring, newsgroup_format_str,
680 + else if (Context && Context->data == folder->ff->nd)
682 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
683 + snprintf (dest, destlen, tmp, Context->unread);
687 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
688 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
693 + if (Context && Context->data == folder->ff->nd)
695 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
696 + snprintf (dest, destlen, tmp, Context->new);
698 + else if (option (OPTMARKOLD) &&
699 + folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
700 + folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
702 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
703 + snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
707 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
708 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
713 + if (folder->ff->nd->desc != NULL)
715 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
716 + snprintf (dest, destlen, tmp, folder->ff->nd->desc);
720 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
721 + snprintf (dest, destlen, tmp, "");
727 +#endif /* USE_NNTP */
729 static void add_folder (MUTTMENU *m, struct browser_state *state,
730 - const char *name, const struct stat *s, int new)
731 + const char *name, const struct stat *s,
732 + void *data, int new)
734 if (state->entrylen == state->entrymax)
738 (state->entry)[state->entrylen].imap = 0;
741 + if (option (OPTNEWS))
742 + (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
748 menu->data = state->entry;
751 +/* get list of all files/newsgroups with mask */
752 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
753 char *d, const char *prefix)
756 + if (option (OPTNEWS))
760 + NNTP_SERVER *news = CurrentNewsSrv;
762 +/* mutt_buffy_check (0); */
763 + init_state (state, menu);
765 + for (tmp = news->list; tmp; tmp = tmp->next)
767 + if (!(data = (NNTP_DATA *)tmp->data))
769 + if (prefix && *prefix && strncmp (prefix, data->group,
770 + strlen (prefix)) != 0)
772 + if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
774 + add_folder (menu, state, data->group, NULL, data, data->new);
778 +#endif /* USE_NNTP */
783 @@ -433,17 +585,40 @@
785 while (tmp && mutt_strcmp (buffer, tmp->path))
787 - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
788 + add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
793 browser_sort (state);
797 +/* get list of mailboxes/subscribed newsgroups */
798 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
801 char buffer[LONG_STRING];
804 + if (option (OPTNEWS))
808 + NNTP_SERVER *news = CurrentNewsSrv;
810 +/* mutt_buffy_check (0); */
811 + init_state (state, menu);
813 + for (tmp = news->list; tmp; tmp = tmp->next)
815 + if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
816 + (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
817 + add_folder (menu, state, data->group, NULL, data, data->new);
823 BUFFY *tmp = Incoming;
825 struct mailbox_state mbox;
826 @@ -461,14 +636,21 @@
827 if (mx_is_imap (tmp->path))
829 imap_mailbox_state (tmp->path, &mbox);
830 - add_folder (menu, state, tmp->path, NULL, mbox.new);
831 + add_folder (menu, state, tmp->path, NULL, NULL, mbox.new);
836 if (mx_is_pop (tmp->path))
838 - add_folder (menu, state, tmp->path, NULL, tmp->new);
839 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
844 + if (mx_is_nntp (tmp->path))
846 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
850 @@ -497,15 +679,20 @@
851 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
852 mutt_pretty_mailbox (buffer, sizeof (buffer));
854 - add_folder (menu, state, buffer, &s, tmp->new);
855 + add_folder (menu, state, buffer, &s, NULL, tmp->new);
857 while ((tmp = tmp->next));
859 browser_sort (state);
863 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
866 + if (option (OPTNEWS))
867 + return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
869 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
873 folder.ff = &((struct folder_file *) menu->data)[num];
877 + if (option (OPTNEWS))
878 + mutt_FormatString (s, slen, 0, NONULL(GroupFormat), newsgroup_format_str,
879 + (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
882 mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str,
883 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
890 + if (option (OPTNEWS))
893 + snprintf (title, titlelen, _("Subscribed newsgroups"));
895 + snprintf (title, titlelen, _("Newsgroups on server [%s]"),
896 + CurrentNewsSrv->conn->account.host);
902 menu->is_mailbox_list = 1;
905 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
908 + if (option (OPTNEWS))
911 + strfcpy (prefix, f, sizeof (prefix));
916 + /* default state for news reader mode is browse subscribed newsgroups */
918 + for (list = CurrentNewsSrv->list; list; list = list->next)
920 + NNTP_DATA *data = (NNTP_DATA *) list->data;
922 + if (data && data->subscribed)
934 mutt_expand_path (f, flen);
936 menu->tag = file_tag;
938 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
940 + (option (OPTNEWS)) ? FolderNewsHelp :
944 init_menu (&state, menu, title, sizeof (title), buffy);
945 @@ -842,7 +1074,11 @@
950 + if (buffy || option (OPTNEWS)) /* news have not path */
955 strfcpy (f, state.entry[menu->current].name, flen);
956 mutt_expand_path (f, flen);
957 @@ -900,14 +1136,6 @@
961 - case OP_BROWSER_SUBSCRIBE:
962 - imap_subscribe (state.entry[menu->current].name, 1);
965 - case OP_BROWSER_UNSUBSCRIBE:
966 - imap_subscribe (state.entry[menu->current].name, 0);
969 case OP_BROWSER_TOGGLE_LSUB:
970 if (option (OPTIMAPLSUB))
971 unset_option (OPTIMAPLSUB);
972 @@ -1008,6 +1236,11 @@
974 case OP_CHANGE_DIRECTORY:
977 + if (option (OPTNEWS))
981 strfcpy (buf, LastDir, sizeof (buf));
983 if (!state.imap_browse)
984 @@ -1273,6 +1506,190 @@
986 mutt_error _("Error trying to view file");
993 + if (option (OPTNEWS))
995 + struct folder_file *f = &state.entry[menu->current];
998 + if (i == OP_CATCHUP)
999 + nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
1001 + nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
1006 + struct folder_file ff;
1007 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1010 + folder.ff->name = f->name;
1011 + folder.ff->st = NULL;
1012 + folder.ff->is_new = nd->new;
1013 + folder.ff->nd = nd;
1015 + mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1016 + newsgroup_format_str, (unsigned long) &folder,
1017 + M_FORMAT_ARROWCURSOR);
1018 + f->desc = safe_strdup (buffer); */
1019 + if (menu->current + 1 < menu->max)
1021 + menu->redraw = REDRAW_MOTION_RESYNCH;
1026 + case OP_LOAD_ACTIVE:
1027 + if (!option (OPTNEWS))
1034 + for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
1036 + if ((data = (NNTP_DATA *)tmp->data))
1037 + data->deleted = 1;
1040 + nntp_get_active (CurrentNewsSrv);
1042 + destroy_state (&state);
1044 + examine_mailboxes (menu, &state);
1046 + examine_directory (menu, &state, NULL, NULL);
1047 + init_menu (&state, menu, title, sizeof (title), buffy);
1049 +#endif /* USE_NNTP */
1051 +#if defined USE_IMAP || defined USE_NNTP
1052 + case OP_BROWSER_SUBSCRIBE:
1053 + case OP_BROWSER_UNSUBSCRIBE:
1056 + case OP_SUBSCRIBE_PATTERN:
1057 + case OP_UNSUBSCRIBE_PATTERN:
1058 + if (option (OPTNEWS))
1060 + regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1062 + int j = menu->current;
1064 + NNTP_SERVER *news = CurrentNewsSrv;
1066 + if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1072 + if (i == OP_SUBSCRIBE_PATTERN)
1073 + snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1075 + snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1076 + if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1082 + if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1084 + regerror (err, rx, buf, sizeof (buf));
1087 + mutt_error ("%s", buf);
1090 + menu->redraw = REDRAW_FULL;
1093 + else if (!state.entrylen)
1095 + mutt_error _("No newsgroups match the mask");
1099 + for ( ; j < state.entrylen; j++)
1101 + struct folder_file *f = &state.entry[j];
1103 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1104 + regexec (rx, f->name, 0, NULL, 0) == 0)
1106 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1107 + nd = mutt_newsgroup_subscribe (news, f->name);
1109 + nd = mutt_newsgroup_unsubscribe (news, f->name);
1113 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1115 + folder.name = f->name;
1117 + folder.new = nd->new;
1120 + mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1121 + newsgroup_format_str, (unsigned long) &folder,
1122 + M_FORMAT_ARROWCURSOR);
1123 + f->desc = safe_strdup (buffer);
1126 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1128 + if (menu->current + 1 < menu->max)
1130 + menu->redraw = REDRAW_MOTION_RESYNCH;
1134 + if (i == OP_SUBSCRIBE_PATTERN)
1136 + LIST *grouplist = NULL;
1139 + grouplist = news->list;
1140 + for (; grouplist; grouplist = grouplist->next)
1142 + nd = (NNTP_DATA *) grouplist->data;
1143 + if (nd && nd->group && !nd->subscribed)
1145 + if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1147 + mutt_newsgroup_subscribe (news, nd->group);
1148 + add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1152 + init_menu (&state, menu, title, sizeof (title), buffy);
1154 + mutt_newsrc_update (news);
1155 + nntp_clear_cacheindex (news);
1156 + if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1162 +#endif /* USE_IMAP && USE_NNTP */
1163 +#endif /* USE_NNTP */
1166 + if (i == OP_BROWSER_SUBSCRIBE)
1167 + imap_subscribe (state.entry[menu->current].name, 1);
1169 + imap_subscribe (state.entry[menu->current].name, 0);
1171 +#endif /* USE_IMAP */
1175 Index: mutt/browser.h
1176 ===================================================================
1177 --- mutt.orig/browser.h 2011-01-19 02:28:26.016235790 -0300
1178 +++ mutt/browser.h 2011-01-19 02:29:05.164032504 -0300
1181 #define _BROWSER_H 1
1191 unsigned selectable : 1;
1192 unsigned inferiors : 1;
1197 unsigned tagged : 1;
1201 ===================================================================
1202 --- mutt.orig/buffy.c 2011-01-19 02:29:05.101044096 -0300
1203 +++ mutt/buffy.c 2011-01-19 02:29:05.165032320 -0300
1206 /* check device ID and serial number instead of comparing paths */
1207 if (!Context || Context->magic == M_IMAP || Context->magic == M_POP
1209 + || Context->magic == M_NNTP
1211 || stat (Context->path, &contex_sb) != 0)
1214 @@ -497,6 +500,11 @@
1219 + if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1220 + tmp->magic = M_NNTP;
1223 if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
1224 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1226 @@ -512,8 +520,11 @@
1227 /* check to see if the folder is the currently selected folder
1229 if (!Context || !Context->path ||
1230 - (( tmp->magic == M_IMAP || tmp->magic == M_POP )
1231 - ? mutt_strcmp (tmp->path, Context->path) :
1232 + (( tmp->magic == M_IMAP || tmp->magic == M_POP
1234 + || tmp->magic == M_NNTP
1236 + ) ? mutt_strcmp (tmp->path, Context->path) :
1237 (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)))
1240 Index: mutt/complete.c
1241 ===================================================================
1242 --- mutt.orig/complete.c 2011-01-19 02:28:25.975243332 -0300
1243 +++ mutt/complete.c 2011-01-19 02:29:05.165032320 -0300
1245 #include "mailbox.h"
1255 char filepart[_POSIX_PATH_MAX];
1257 char imap_path[LONG_STRING];
1260 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1263 + if (option (OPTNEWS))
1265 + LIST *l = CurrentNewsSrv->list;
1267 + strfcpy (filepart, s, sizeof (filepart));
1270 + * special case to handle when there is no filepart yet.
1271 + * find the first subscribed newsgroup
1273 + if ((len = mutt_strlen (filepart)) == 0)
1275 + for (; l; l = l->next)
1277 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1279 + if (data && data->subscribed)
1281 + strfcpy (filepart, data->group, sizeof (filepart));
1289 + for (; l; l = l->next)
1291 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1293 + if (data && data->subscribed &&
1294 + mutt_strncmp (data->group, filepart, len) == 0)
1298 + for (i = 0; filepart[i] && data->group[i]; i++)
1300 + if (filepart[i] != data->group[i])
1310 + strfcpy (filepart, data->group, sizeof (filepart));
1316 + strcpy (s, filepart);
1318 + return (init ? 0 : -1);
1323 /* we can use '/' as a delimiter, imap_complete rewrites it */
1324 if (*s == '=' || *s == '+' || *s == '!')
1326 Index: mutt/compose.c
1327 ===================================================================
1328 --- mutt.orig/compose.c 2011-01-19 02:29:05.103043728 -0300
1329 +++ mutt/compose.c 2011-01-19 02:29:05.166032136 -0300
1331 #include "mailbox.h"
1333 #include "charset.h"
1337 #include "remailer.h"
1346 #include <sys/stat.h>
1357 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1360 -#define HDR_XOFFSET 10
1361 -#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1362 +#define HDR_XOFFSET 14
1363 +#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1364 #define W (COLS - HDR_XOFFSET - SidebarWidth)
1366 static char *Prompts[] =
1383 static struct mapping_t ComposeHelp[] = {
1389 +static struct mapping_t ComposeNewsHelp[] = {
1390 + { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1391 + { N_("Abort"), OP_EXIT },
1392 + { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1393 + { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1394 + { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1395 + { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1396 + { N_("Help"), OP_HELP },
1401 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1403 mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt,
1408 - mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
1409 + mvprintw (HDR_CRYPT, SidebarWidth, TITLE_FMT, "Security: ");
1411 if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
1413 @@ -148,12 +182,15 @@
1416 if ((WithCrypto & APPLICATION_PGP)
1417 - && msg->security & APPLICATION_PGP && msg->security & SIGN)
1418 - printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>"));
1419 + && msg->security & APPLICATION_PGP && msg->security & SIGN) {
1420 + printw (TITLE_FMT, _(" sign as: "));
1421 + printw ("%s", PgpSignAs ? PgpSignAs : _("<default>"));
1424 if ((WithCrypto & APPLICATION_SMIME)
1425 && msg->security & APPLICATION_SMIME && msg->security & SIGN) {
1426 - printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
1427 + printw (TITLE_FMT, _(" sign as: "));
1428 + printw ("%s", SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
1431 if ((WithCrypto & APPLICATION_SMIME)
1436 - mvaddstr (HDR_MIX, SidebarWidth, " Mix: ");
1437 + mvprintw (HDR_MIX, SidebarWidth, TITLE_FMT, "Mix: ");
1441 @@ -249,9 +286,28 @@
1442 static void draw_envelope (HEADER *msg, char *fcc)
1444 draw_envelope_addr (HDR_FROM, msg->env->from);
1446 + if (!option (OPTNEWSSEND))
1449 draw_envelope_addr (HDR_TO, msg->env->to);
1450 draw_envelope_addr (HDR_CC, msg->env->cc);
1451 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1456 + mvprintw (HDR_TO, SidebarWidth, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1457 + mutt_paddstr (W, NONULL (msg->env->newsgroups));
1458 + mvprintw (HDR_CC, SidebarWidth, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1459 + mutt_paddstr (W, NONULL (msg->env->followup_to));
1460 + if (option (OPTXCOMMENTTO))
1462 + mvprintw (HDR_BCC, SidebarWidth, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1463 + mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1467 mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1468 mutt_paddstr (W, NONULL (msg->env->subject));
1469 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1470 @@ -504,6 +560,12 @@
1471 /* Sort, SortAux could be changed in mutt_index_menu() */
1472 int oldSort, oldSortAux;
1475 + int news = 0; /* is it a news article ? */
1477 + if (option (OPTNEWSSEND))
1481 mutt_attach_init (msg->content);
1482 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
1483 @@ -514,10 +576,18 @@
1484 menu->make_entry = snd_entry;
1485 menu->tag = mutt_tag_attach;
1489 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1492 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1497 + unset_option (OPTNEWS); /* for any case */
1499 switch (op = mutt_menuLoop (menu))
1502 @@ -530,17 +600,87 @@
1503 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1505 case OP_COMPOSE_EDIT_TO:
1510 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1511 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1513 case OP_COMPOSE_EDIT_BCC:
1518 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1519 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1521 case OP_COMPOSE_EDIT_CC:
1526 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1527 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1530 + case OP_COMPOSE_EDIT_NEWSGROUPS:
1533 + if (msg->env->newsgroups)
1534 + strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1537 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1539 + FREE (&msg->env->newsgroups);
1540 + mutt_remove_trailing_ws (buf);
1541 + msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1542 + move (HDR_TO, HDR_XOFFSET);
1544 + if (msg->env->newsgroups)
1545 + printw ("%-*.*s", W, W, msg->env->newsgroups);
1550 + case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1554 + if (msg->env->followup_to)
1555 + strfcpy (buf, msg->env->followup_to, sizeof (buf));
1556 + if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1558 + FREE (&msg->env->followup_to);
1559 + mutt_remove_trailing_ws (buf);
1560 + msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1561 + move (HDR_CC, HDR_XOFFSET);
1563 + if (msg->env->followup_to)
1564 + printw ("%-*.*s", W, W, msg->env->followup_to);
1569 + case OP_COMPOSE_EDIT_X_COMMENT_TO:
1570 + if (news && option (OPTXCOMMENTTO))
1573 + if (msg->env->x_comment_to)
1574 + strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1575 + if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1577 + FREE (&msg->env->x_comment_to);
1578 + msg->env->x_comment_to = safe_strdup (buf);
1579 + move (HDR_BCC, HDR_XOFFSET);
1581 + if (msg->env->x_comment_to)
1582 + printw ("%-*.*s", W, W, msg->env->x_comment_to);
1587 case OP_COMPOSE_EDIT_SUBJECT:
1588 if (msg->env->subject)
1589 strfcpy (buf, msg->env->subject, sizeof (buf));
1593 case OP_COMPOSE_ATTACH_MESSAGE:
1595 + case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1600 @@ -710,7 +853,22 @@
1602 prompt = _("Open mailbox to attach message from");
1605 + unset_option (OPTNEWS);
1606 + if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1608 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1611 + prompt = _("Open newsgroup to attach message from");
1612 + set_option (OPTNEWS);
1618 + if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1621 strfcpy (fname, NONULL (Context->path), sizeof (fname));
1622 mutt_pretty_mailbox (fname, sizeof (fname));
1623 @@ -719,6 +877,11 @@
1624 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1628 + if (option (OPTNEWS))
1629 + nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1632 mutt_expand_path (fname, sizeof (fname));
1634 if (!mx_is_imap (fname))
1637 if (!mx_is_pop (fname))
1640 + if (!mx_is_nntp (fname) && !option (OPTNEWS))
1642 /* check to make sure the file exists and is readable */
1643 if (access (fname, R_OK) == -1)
1645 Index: mutt/configure.ac
1646 ===================================================================
1647 --- mutt.orig/configure.ac 2011-01-19 02:29:04.660125230 -0300
1648 +++ mutt/configure.ac 2011-01-19 02:29:05.167031952 -0300
1649 @@ -603,6 +603,14 @@
1650 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1653 +AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1654 +[ if test x$enableval = xyes ; then
1655 + AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1656 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1661 dnl -- end socket dependencies --
1663 if test "$need_socket" = "yes"
1664 Index: mutt/curs_main.c
1665 ===================================================================
1666 --- mutt.orig/curs_main.c 2011-01-19 02:29:05.104043544 -0300
1667 +++ mutt/curs_main.c 2011-01-19 02:29:05.168031768 -0300
1671 #include "mutt_curses.h"
1673 #include "mutt_menu.h"
1674 #include "mailbox.h"
1675 #include "mapping.h"
1678 #include "mutt_crypt.h"
1687 @@ -428,12 +433,27 @@
1692 +struct mapping_t IndexNewsHelp[] = {
1693 + { N_("Quit"), OP_QUIT },
1694 + { N_("Del"), OP_DELETE },
1695 + { N_("Undel"), OP_UNDELETE },
1696 + { N_("Save"), OP_SAVE },
1697 + { N_("Post"), OP_POST },
1698 + { N_("Followup"), OP_FOLLOWUP },
1699 + { N_("Catchup"), OP_CATCHUP },
1700 + { N_("Help"), OP_HELP },
1705 /* This function handles the message index window as well as commands returned
1706 * from the pager (MENU_PAGER).
1708 int mutt_index_menu (void)
1710 char buf[LONG_STRING], helpstr[LONG_STRING];
1713 int done = 0; /* controls when to exit the "event" loop */
1715 @@ -454,7 +474,11 @@
1716 menu->make_entry = index_make_entry;
1717 menu->color = index_color;
1718 menu->current = ci_first_message ();
1719 - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1720 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1722 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1727 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
1729 mutt_curs_set (1); /* fallback from the pager */
1733 + unset_option (OPTNEWS); /* for any case */
1738 @@ -762,6 +789,120 @@
1739 menu_current_bottom (menu);
1743 + case OP_GET_MESSAGE:
1744 + case OP_GET_PARENT:
1746 + if (Context->magic == M_NNTP)
1750 + if (op == OP_GET_MESSAGE)
1753 + if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1759 + LIST *ref = CURHDR->env->references;
1762 + mutt_error _("Article has no parent reference!");
1765 + strfcpy (buf, ref->data, sizeof (buf));
1767 + if (!Context->id_hash)
1768 + Context->id_hash = mutt_make_id_hash (Context);
1769 + if ((h = hash_find (Context->id_hash, buf)))
1771 + if (h->virtual != -1)
1773 + menu->current = h->virtual;
1774 + menu->redraw = REDRAW_MOTION_RESYNCH;
1776 + else if (h->collapsed)
1778 + mutt_uncollapse_thread (Context, h);
1779 + mutt_set_virtual (Context);
1780 + menu->current = h->virtual;
1781 + menu->redraw = REDRAW_MOTION_RESYNCH;
1784 + mutt_error _("Message not visible in limited view.");
1788 + if (nntp_check_msgid (Context, buf) == 0)
1790 + h = Context->hdrs[Context->msgcount-1];
1791 + mutt_sort_headers (Context, 0);
1792 + menu->current = h->virtual;
1793 + menu->redraw = REDRAW_FULL;
1796 + mutt_error (_("Article %s not found on server"), buf);
1801 + case OP_GET_CHILDREN:
1802 + case OP_RECONSTRUCT_THREAD:
1804 + if (Context->magic == M_NNTP)
1807 + int old = CURHDR->index, i;
1809 + if (!CURHDR->env->message_id)
1811 + mutt_error _("No Message-Id. Unable to perform operation");
1815 + if (!Context->id_hash)
1816 + Context->id_hash = mutt_make_id_hash (Context);
1817 + strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1819 + if (op == OP_RECONSTRUCT_THREAD)
1821 + LIST *ref = CURHDR->env->references;
1824 + nntp_check_msgid (Context, ref->data);
1825 + /* the last msgid in References is the root message */
1827 + strfcpy (buf, ref->data, sizeof (buf));
1831 + mutt_message _("Check for children of message...");
1832 + if (nntp_check_children (Context, buf) == 0)
1834 + mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1835 + h = hash_find (Context->id_hash, buf);
1836 + /* if the root message was retrieved, move to it */
1838 + menu->current = h->virtual;
1839 + else /* try to restore old position */
1840 + for (i = 0; i < Context->msgcount; i++)
1841 + if (Context->hdrs[i]->index == old)
1843 + menu->current = Context->hdrs[i]->virtual;
1844 + /* As an added courtesy, recenter the menu
1845 + * with the current entry at the middle of the screen */
1846 + menu_check_recenter (menu);
1847 + menu_current_middle (menu);
1850 + menu->redraw = REDRAW_FULL;
1851 + mutt_clear_error ();
1859 @@ -858,11 +999,33 @@
1863 + case OP_TOGGLE_READ:
1866 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1868 - if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1869 + if (op == OP_TOGGLE_READ)
1871 + char buf[LONG_STRING];
1873 + if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1875 + snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1876 + Context->pattern ? Context->pattern : ".*");
1877 + set_option (OPTHIDEREAD);
1881 + strfcpy (buf, Context->pattern + 8, sizeof(buf));
1882 + if (!*buf || strncmp (buf, ".*", 2) == 0)
1883 + snprintf (buf, sizeof(buf), "~A");
1884 + unset_option (OPTHIDEREAD);
1886 + FREE (&Context->pattern);
1887 + Context->pattern = safe_strdup (buf);
1889 + if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1890 + mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1892 if (menu->oldcurrent >= 0)
1894 @@ -1102,15 +1265,22 @@
1895 case OP_SIDEBAR_OPEN:
1896 case OP_MAIN_CHANGE_FOLDER:
1897 case OP_MAIN_NEXT_UNREAD_MAILBOX:
1900 - op = OP_MAIN_CHANGE_FOLDER_READONLY;
1902 - /* fallback to the readonly case */
1904 case OP_MAIN_CHANGE_FOLDER_READONLY:
1906 + case OP_MAIN_CHANGE_GROUP:
1907 + case OP_MAIN_CHANGE_GROUP_READONLY:
1908 + unset_option (OPTNEWS);
1910 + if (attach_msg || option (OPTREADONLY) ||
1912 + op == OP_MAIN_CHANGE_GROUP_READONLY ||
1914 + op == OP_MAIN_CHANGE_FOLDER_READONLY)
1915 + flags = M_READONLY;
1919 - if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1921 cp = _("Open mailbox in read-only mode");
1923 cp = _("Open mailbox");
1924 @@ -1129,6 +1299,21 @@
1929 + if (op == OP_MAIN_CHANGE_GROUP ||
1930 + op == OP_MAIN_CHANGE_GROUP_READONLY)
1932 + set_option (OPTNEWS);
1933 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1936 + cp = _("Open newsgroup in read-only mode");
1938 + cp = _("Open newsgroup");
1943 mutt_buffy (buf, sizeof (buf));
1945 if ( op == OP_SIDEBAR_OPEN ) {
1946 @@ -1152,6 +1337,14 @@
1951 + if (option (OPTNEWS))
1953 + unset_option (OPTNEWS);
1954 + nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1958 mutt_expand_path (buf, sizeof (buf));
1960 if (mx_get_magic (buf) <= 0)
1961 @@ -1199,15 +1392,18 @@
1962 CurrentMenu = MENU_MAIN;
1963 mutt_folder_hook (buf);
1965 - if ((Context = mx_open_mailbox (buf,
1966 - (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1967 - M_READONLY : 0, NULL)) != NULL)
1968 + if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1970 menu->current = ci_first_message ();
1976 + /* mutt_buffy_check() must be done with mail-reader mode! */
1977 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1978 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1980 mutt_clear_error ();
1981 mutt_buffy_check(1); /* force the buffy check after we have changed
1983 @@ -1580,6 +1776,15 @@
1985 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1988 + if (Context->magic == M_NNTP)
1991 + mutt_error _("Can't change 'important' flag on NNTP server.");
1998 for (j = 0; j < Context->vcount; j++)
1999 @@ -1931,6 +2136,17 @@
2005 + if (Context && Context->magic == M_NNTP)
2007 + if (mutt_newsgroup_catchup (CurrentNewsSrv,
2008 + ((NNTP_DATA *)Context->data)->group))
2009 + menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2014 case OP_DISPLAY_ADDRESS:
2017 @@ -2059,6 +2275,15 @@
2022 + if (Context->magic == M_NNTP)
2025 + mutt_error _("Can't edit message on newsserver.");
2030 MAYBE_REDRAW (menu->redraw);
2033 @@ -2135,6 +2360,41 @@
2034 menu->redraw = REDRAW_FULL;
2039 + case OP_FORWARD_TO_GROUP:
2047 + if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2048 + mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2049 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2051 + if (Context && Context->magic == M_NNTP &&
2052 + !((NNTP_DATA *)Context->data)->allowed &&
2053 + query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2055 + if (op == OP_POST)
2056 + ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2060 + if (op == OP_FOLLOWUP)
2061 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2062 + tag ? NULL : CURHDR);
2064 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2065 + tag ? NULL : CURHDR);
2067 + menu->redraw = REDRAW_FULL;
2075 @@ -2212,6 +2472,12 @@
2077 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2080 + /* Close all open NNTP connections */
2082 + nntp_logout_all ();
2085 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2086 op == OP_UNDELETE_THREAD ? 0 : 1)
2087 + mutt_thread_set_flag (CURHDR, M_PURGED, 0,
2088 Index: mutt/doc/manual.xml.head
2089 ===================================================================
2090 --- mutt.orig/doc/manual.xml.head 2011-01-19 02:29:04.663124678 -0300
2091 +++ mutt/doc/manual.xml.head 2011-01-19 02:29:05.171031216 -0300
2092 @@ -1611,6 +1611,22 @@
2097 +<title>Reading news via NNTP</title>
2100 +If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2101 +read news from newsserver via NNTP. You can open a newsgroup with
2102 +function ``change-newsgroup'' (default: ``i''). Default newsserver
2103 +can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2104 +variable. Like other news readers, info about subscribed newsgroups
2105 +is saved in file by <link linkend="newsrc">$newsrc</link>
2106 +variable. Article headers are cached and can be loaded from file when
2107 +newsgroup entered instead loading from newsserver.
2114 <sect1 id="forwarding-mail">
2115 Index: mutt/doc/mutt.man
2116 ===================================================================
2117 --- mutt.orig/doc/mutt.man 2011-01-19 02:29:04.732111984 -0300
2118 +++ mutt/doc/mutt.man 2011-01-19 02:29:05.173030848 -0300
2124 -[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2126 +[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-g \fIserver\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2130 @@ -101,6 +101,10 @@
2131 Specify which mailbox to load.
2132 .IP "-F \fImuttrc\fP"
2133 Specify an initialization file to read instead of ~/.muttrc
2134 +.IP "-g \fIserver\fP"
2135 +Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2137 +Start Mutt with a listing of subscribed newsgroups.
2140 .IP "-H \fIdraft\fP"
2141 Index: mutt/functions.h
2142 ===================================================================
2143 --- mutt.orig/functions.h 2011-01-19 02:29:05.105043360 -0300
2144 +++ mutt/functions.h 2011-01-19 02:29:05.174030664 -0300
2146 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2147 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2148 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2150 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2151 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2153 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2154 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2155 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
2156 @@ -101,7 +105,15 @@
2157 { "edit", OP_EDIT_MESSAGE, "e" },
2158 { "edit-type", OP_EDIT_TYPE, "\005" },
2159 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2160 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2162 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2163 + { "followup-message", OP_FOLLOWUP, "F" },
2164 + { "get-children", OP_GET_CHILDREN, NULL },
2165 + { "get-message", OP_GET_MESSAGE, "\007" },
2166 + { "get-parent", OP_GET_PARENT, "\033G" },
2167 + { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2169 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2170 { "group-reply", OP_GROUP_REPLY, "g" },
2172 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2174 { "sort-mailbox", OP_SORT, "o" },
2175 { "sort-reverse", OP_SORT_REVERSE, "O" },
2176 { "print-message", OP_PRINT, "p" },
2178 + { "post-message", OP_POST, "P" },
2180 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2181 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2182 { "recall-message", OP_RECALL_MESSAGE, "R" },
2183 @@ -148,6 +163,10 @@
2184 { "show-version", OP_VERSION, "V" },
2185 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2186 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2187 + { "toggle-read", OP_TOGGLE_READ, "X" },
2189 + { "catchup", OP_CATCHUP, "y" },
2191 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2192 { "buffy-list", OP_BUFFY_LIST, "." },
2193 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
2195 { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" },
2196 { "next-unread", OP_MAIN_NEXT_UNREAD, NULL },
2197 { "previous-unread", OP_MAIN_PREV_UNREAD, NULL },
2198 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2199 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2202 { "extract-keys", OP_EXTRACT_KEYS, "\013" },
2203 @@ -184,6 +203,10 @@
2204 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2205 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2206 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2208 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2209 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2211 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2212 { "copy-message", OP_COPY_MESSAGE, "C" },
2213 { "decode-copy", OP_DECODE_COPY, "\033C" },
2214 @@ -194,8 +217,12 @@
2215 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2216 { "edit", OP_EDIT_MESSAGE, "e" },
2217 { "edit-type", OP_EDIT_TYPE, "\005" },
2219 + { "followup-message", OP_FOLLOWUP, "F" },
2220 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2222 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2223 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2224 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2225 { "group-reply", OP_GROUP_REPLY, "g" },
2227 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
2229 { "sort-mailbox", OP_SORT, "o" },
2230 { "sort-reverse", OP_SORT_REVERSE, "O" },
2231 { "print-message", OP_PRINT, "p" },
2233 + { "post-message", OP_POST, "P" },
2235 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2236 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2237 { "purge-message", OP_PURGE_MESSAGE, NULL },
2239 { "half-down", OP_HALF_DOWN, NULL },
2240 { "previous-line", OP_PREV_LINE, NULL },
2241 { "bottom", OP_PAGER_BOTTOM, NULL },
2242 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2243 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2247 @@ -291,6 +321,10 @@
2248 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2249 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2250 { "edit-type", OP_EDIT_TYPE, "\005" },
2252 + { "followup-message", OP_FOLLOWUP, "F" },
2253 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2255 { "print-entry", OP_PRINT, "p" },
2256 { "save-entry", OP_SAVE, "s" },
2257 { "pipe-entry", OP_PIPE, "|" },
2259 struct binding_t OpCompose[] = { /* map: compose */
2260 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2261 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2262 + { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2263 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2264 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2265 { "copy-file", OP_SAVE, "C" },
2266 @@ -335,6 +370,11 @@
2267 { "print-entry", OP_PRINT, "l" },
2268 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2269 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2271 + { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2272 + { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2273 + { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2275 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2276 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2277 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
2278 @@ -386,14 +426,25 @@
2279 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2280 { "check-new", OP_CHECK_NEW, NULL },
2281 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2283 + { "reload-active", OP_LOAD_ACTIVE, "g" },
2284 + { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2285 + { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2286 + { "catchup", OP_CATCHUP, "y" },
2287 + { "uncatchup", OP_UNCATCHUP, "Y" },
2289 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2290 { "buffy-list", OP_BUFFY_LIST, "." },
2292 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2293 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2294 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2296 +#if defined USE_IMAP || defined USE_NNTP
2297 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2298 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2301 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2304 Index: mutt/globals.h
2305 ===================================================================
2306 --- mutt.orig/globals.h 2011-01-19 02:29:05.105043360 -0300
2307 +++ mutt/globals.h 2011-01-19 02:29:05.174030664 -0300
2311 WHERE char *Muttrc INITVAL (NULL);
2313 +WHERE char *NewsCacheDir;
2314 +WHERE char *GroupFormat;
2316 +WHERE char *NewsServer;
2317 +WHERE char *NntpUser;
2318 +WHERE char *NntpPass;
2319 +WHERE char *NewsRc;
2323 WHERE char *PagerFmt;
2324 @@ -192,6 +201,11 @@
2326 WHERE unsigned short Counter INITVAL (0);
2329 +WHERE short NewsPollTimeout;
2330 +WHERE short NntpContext;
2333 WHERE short ConnectTimeout;
2334 WHERE short HistSize;
2335 WHERE short MenuContext;
2337 ===================================================================
2338 --- mutt.orig/hash.c 2011-01-19 02:28:26.220198262 -0300
2339 +++ mutt/hash.c 2011-01-19 02:29:05.175030480 -0300
2343 table->nelem = nelem;
2344 + table->curnelem = 0;
2345 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2352 +HASH *hash_resize (HASH *ptr, int nelem, int lower)
2355 + struct hash_elem *elem, *tmp;
2358 + table = hash_create (nelem, lower);
2360 + for (i = 0; i < ptr->nelem; i++)
2362 + for (elem = ptr->table[i]; elem; )
2365 + elem = elem->next;
2366 + hash_insert (table, tmp->key, tmp->data, 1);
2370 + FREE (&ptr->table);
2375 /* table hash table to update
2376 * key key to hash on
2377 * data data to associate with `key'
2380 ptr->next = table->table[h];
2381 table->table[h] = ptr;
2382 + table->curnelem++;
2388 table->table[h] = ptr;
2390 + table->curnelem++;
2396 destroy (ptr->data);
2398 + table->curnelem--;
2403 ===================================================================
2404 --- mutt.orig/hash.h 2011-01-19 02:28:26.318180235 -0300
2405 +++ mutt/hash.h 2011-01-19 02:29:05.175030480 -0300
2411 + int nelem, curnelem;
2412 struct hash_elem **table;
2413 unsigned int (*hash_string)(const unsigned char *, unsigned int);
2414 int (*cmp_string)(const char *, const char *);
2417 HASH *hash_create (int nelem, int lower);
2418 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2419 +HASH *hash_resize (HASH * table, int nelem, int lower);
2420 void *hash_find_hash (const HASH * table, int hash, const char *key);
2421 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2422 void (*destroy) (void *));
2423 Index: mutt/hdrline.c
2424 ===================================================================
2425 --- mutt.orig/hdrline.c 2011-01-19 02:28:26.114217762 -0300
2426 +++ mutt/hdrline.c 2011-01-19 02:29:05.176030296 -0300
2428 * %E = number of messages in current thread
2429 * %f = entire from line
2430 * %F = like %n, unless from self
2431 + * %g = newsgroup name (if compiled with nntp support)
2433 * %l = number of lines in the message
2434 * %L = like %F, except `lists' are displayed first
2435 @@ -219,12 +220,14 @@
2437 * %O = like %L, except using address instead of name
2438 * %P = progress indicator for builtin pager
2439 + * %R = `x-comment-to:' field (if present and compiled with nntp support)
2441 * %S = short message status (e.g., N/O/D/!/r/-)
2442 * %t = `to:' field (recipients)
2444 * %u = user (login) name of author
2445 * %v = first name of author, unless from self
2446 + * %W = where user is (organization)
2447 * %X = number of MIME attachments
2448 * %y = `x-label:' field (if present)
2449 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2450 @@ -457,6 +460,12 @@
2456 + mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2461 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2463 @@ -548,6 +557,15 @@
2464 strfcpy(dest, NONULL(hfi->pager_progress), destlen);
2470 + mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2471 + else if (!hdr->env->x_comment_to)
2478 if (flags & M_FORMAT_TREE && !hdr->collapsed)
2479 @@ -637,6 +655,13 @@
2480 mutt_format_s (dest, destlen, prefix, buf2);
2485 + mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2486 + else if (!hdr->env->organization)
2494 ===================================================================
2495 --- mutt.orig/init.c 2011-01-19 02:29:05.001062494 -0300
2496 +++ mutt/init.c 2011-01-19 02:29:05.177030112 -0300
2497 @@ -3093,6 +3093,28 @@
2499 Fqdn = safe_strdup(NONULL(Hostname));
2506 + if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2509 + fgets (buffer, sizeof (buffer), f);
2513 + while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2515 + NewsServer = safe_strdup (p);
2519 + if ((p = getenv ("NNTPSERVER")))
2520 + NewsServer = safe_strdup (p);
2523 if ((p = getenv ("MAIL")))
2524 Spoolfile = safe_strdup (p);
2525 else if ((p = getenv ("MAILDIR")))
2527 ===================================================================
2528 --- mutt.orig/init.h 2011-01-19 02:29:05.147035632 -0300
2529 +++ mutt/init.h 2011-01-19 02:29:05.179029744 -0300
2530 @@ -176,6 +176,20 @@
2531 ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before
2532 ** editing the body of an outgoing message.
2535 + { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2538 + ** If set, Mutt will prompt you for follow-up groups before editing
2539 + ** the body of an outgoing message.
2541 + { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2544 + ** If set, Mutt will prompt you for x-comment-to field before editing
2545 + ** the body of an outgoing message.
2548 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2551 @@ -328,6 +342,14 @@
2552 ** follow these menus. The option is \fIunset\fP by default because many
2553 ** visual terminals don't permit making the cursor invisible.
2556 + { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2559 + ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2560 + ** as read when you quit the newsgroup (catchup newsgroup).
2563 #if defined(USE_SSL)
2564 { "certificate_file", DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" },
2566 @@ -804,6 +826,16 @@
2567 ** sent to both the list and your address, resulting in two copies
2568 ** of the same email for you.
2571 + { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2574 + ** If this variable is \fIset\fP and the keyword "poster" is present in
2575 + ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2576 + ** permitted. The message will be mailed to the submitter of the
2577 + ** message via mail.
2580 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2583 @@ -886,6 +918,27 @@
2584 ** a regular expression that will match the whole name so mutt will expand
2585 ** ``Franklin'' to ``Franklin, Steve''.
2588 + { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2591 + ** This variable allows you to customize the newsgroup browser display to
2592 + ** your personal taste. This string is similar to ``$index_format'', but
2593 + ** has its own set of printf()-like sequences:
2596 + ** %C current newsgroup number
2597 + ** %d description of newsgroup (becomes from server)
2598 + ** %f newsgroup name
2599 + ** %M - if newsgroup not allowed for direct post (moderated for example)
2600 + ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2601 + ** %n number of new articles in newsgroup
2602 + ** %s number of unread articles in newsgroup
2603 + ** %>X right justify the rest of the string and pad with character "X"
2604 + ** %|X pad to the end of the line with character "X"
2608 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2611 @@ -1267,6 +1320,7 @@
2612 ** .dt %E .dd number of messages in current thread
2613 ** .dt %f .dd sender (address + real name), either From: or Return-Path:
2614 ** .dt %F .dd author name, or recipient name if the message is from you
2615 + ** .dt %g .dd newsgroup name (if compiled with nntp support)
2616 ** .dt %H .dd spam attribute(s) of this message
2617 ** .dt %i .dd message-id of the current message
2618 ** .dt %l .dd number of lines in the message (does not work with maildir,
2619 @@ -1282,12 +1336,14 @@
2620 ** stashed the message: list name or recipient name
2621 ** if not sent to a list
2622 ** .dt %P .dd progress indicator for the built-in pager (how much of the file has been displayed)
2623 + ** .dt %R .dd ``x-comment-to:'' field (if present and compiled with nntp support)
2624 ** .dt %s .dd subject of the message
2625 ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as)
2626 ** .dt %t .dd ``To:'' field (recipients)
2627 ** .dt %T .dd the appropriate character from the $$to_chars string
2628 ** .dt %u .dd user (login) name of the author
2629 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2630 + ** .dt %W .dd name of organization of author (``organization:'' field)
2631 ** .dt %X .dd number of attachments
2632 ** (please see the ``$attachments'' section for possible speed effects)
2633 ** .dt %y .dd ``X-Label:'' field, if present
2634 @@ -1322,6 +1378,21 @@
2635 ** Note that these expandos are supported in
2636 ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too.
2639 + { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2642 + ** If set, specifies the program and arguments used to deliver news posted
2643 + ** by Mutt. Otherwise, mutt posts article using current connection to
2644 + ** news server. The following printf-style sequence is understood:
2647 + ** %s newsserver name
2650 + ** Example: set inews="/usr/local/bin/inews -hS"
2653 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2656 @@ -1556,6 +1627,15 @@
2657 ** menu, attachments which cannot be decoded in a reasonable manner will
2658 ** be attached to the newly composed message if this option is \fIset\fP.
2661 + { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2664 + ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2665 + ** encoded according to RFC2047 to base64. This is useful when message
2666 + ** is Usenet article, because MIME for news is nonstandard feature.
2670 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2672 @@ -1606,6 +1686,77 @@
2673 ** See also $$read_inc, $$write_inc and $$net_inc.
2677 + { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2680 + ** This variable pointing to directory where Mutt will save cached news
2681 + ** articles headers in. If \fIunset\fP, headers will not be saved at all
2682 + ** and will be reloaded each time when you enter to newsgroup.
2684 + { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2687 + ** This variable specifies domain name or address of NNTP server. It
2688 + ** defaults to the newsserver specified in the environment variable
2689 + ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2690 + ** specify username and an alternative port for each newsserver, ie:
2692 + ** [news[s]://][username[:password]@]newsserver[:port]
2694 + { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2697 + ** The file, containing info about subscribed newsgroups - names and
2698 + ** indexes of read articles. The following printf-style sequence
2702 + ** %s newsserver name
2705 + { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2708 + ** This variable defines number of articles which will be in index when
2709 + ** newsgroup entered. If active newsgroup have more articles than this
2710 + ** number, oldest articles will be ignored. Also controls how many
2711 + ** articles headers will be saved in cache when you quit newsgroup.
2713 + { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2716 + ** This variable controls whether or not descriptions for each newsgroup
2717 + ** must be loaded when newsgroup is added to list (first time list
2718 + ** loading or new newsgroup adding).
2720 + { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2723 + ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2724 + ** authentification, Mutt will prompt you for your account name when you
2725 + ** connect to newsserver.
2727 + { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2730 + ** Your password for NNTP account.
2732 + { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2735 + ** The time in seconds until any operations on newsgroup except post new
2736 + ** article will cause recheck for new news. If set to 0, Mutt will
2737 + ** recheck newsgroup on each operation in index (stepping, read article,
2740 + { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2743 + ** Controls whether or not Mutt will try to reconnect to newsserver when
2744 + ** connection lost.
2747 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2750 @@ -2131,6 +2282,16 @@
2751 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2755 + { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2758 + ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2759 + ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2760 + ** does not support posting to that newsgroup or totally read-only, that
2761 + ** posting will not have an effect.
2764 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2767 @@ -2534,6 +2695,28 @@
2768 ** Command to use when spawning a subshell. By default, the user's login
2769 ** shell from \fC/etc/passwd\fP is used.
2772 + { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2775 + ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2776 + ** ``newsrc'' file and into cache.
2778 + { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2781 + ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2782 + ** the browser. Otherwise, it will be done only once for a newsserver.
2783 + ** Also controls whether or not number of new articles of subscribed
2784 + ** newsgroups will be then checked.
2786 + { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2789 + ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2790 + ** will be displayed in browser.
2793 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2796 @@ -3455,6 +3638,14 @@
2797 ** xterm_set_titles has been set. This string is identical in formatting
2798 ** to the one used by ``$$status_format''.
2801 + { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2804 + ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2805 + ** name of original article author) to article that followuped to newsgroup.
2809 { NULL, 0, 0, 0, 0 }
2811 Index: mutt/keymap.c
2812 ===================================================================
2813 --- mutt.orig/keymap.c 2011-01-19 02:28:26.107219050 -0300
2814 +++ mutt/keymap.c 2011-01-19 02:29:05.180029560 -0300
2816 km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE);
2818 km_bindkey ("x", MENU_PAGER, OP_EXIT);
2819 - km_bindkey ("i", MENU_PAGER, OP_EXIT);
2820 km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE);
2821 km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE);
2822 km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE);
2823 Index: mutt/mailbox.h
2824 ===================================================================
2825 --- mutt.orig/mailbox.h 2011-01-19 02:29:05.107042992 -0300
2826 +++ mutt/mailbox.h 2011-01-19 02:29:05.180029560 -0300
2829 int mx_is_pop (const char *);
2832 +int mx_is_nntp (const char *);
2835 int mx_access (const char*, int);
2836 int mx_check_empty (const char *);
2838 ===================================================================
2839 --- mutt.orig/main.c 2011-01-19 02:29:04.669123574 -0300
2840 +++ mutt/main.c 2011-01-19 02:29:05.181029376 -0300
2842 #include <stringprep.h>
2849 static const char *ReachingUs = N_("\
2850 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2851 To report a bug, please visit http://bugs.mutt.org/.\n");
2853 " -e <command>\tspecify a command to be executed after initialization\n\
2854 -f <file>\tspecify which mailbox to read\n\
2855 -F <file>\tspecify an alternate muttrc file\n\
2856 + -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2857 + -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2858 -H <file>\tspecify a draft file to read header and body from\n\
2859 -i <file>\tspecify a file which Mutt should include in the body\n\
2860 -m <type>\tspecify a default mailbox type\n\
2861 @@ -254,6 +260,12 @@
2875 #define M_NOSYSRC (1<<2) /* -n */
2876 #define M_RO (1<<3) /* -R */
2877 #define M_SELECT (1<<4) /* -y */
2879 +#define M_NEWS (1<<5) /* -g and -G */
2882 int main (int argc, char **argv)
2884 @@ -600,7 +615,11 @@
2885 argv[nargc++] = argv[optind];
2889 + if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2891 if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2896 @@ -697,6 +716,20 @@
2901 + case 'g': /* Specify a newsserver */
2903 + char buf[LONG_STRING];
2905 + snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2906 + commands = mutt_add_list (commands, buf);
2909 + case 'G': /* List of newsgroups */
2910 + flags |= M_SELECT | M_NEWS;
2917 @@ -984,6 +1017,18 @@
2919 else if (flags & M_SELECT)
2922 + if (flags & M_NEWS)
2924 + set_option (OPTNEWS);
2925 + if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2927 + mutt_endwin (Errorbuf);
2934 mutt_endwin _("No incoming mailboxes defined.");
2936 @@ -999,6 +1044,15 @@
2939 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2942 + if (option (OPTNEWS))
2944 + unset_option (OPTNEWS);
2945 + nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2949 mutt_expand_path (folder, sizeof (folder));
2951 mutt_str_replace (&CurrentFolder, folder);
2953 ===================================================================
2954 --- mutt.orig/mutt.h 2011-01-19 02:29:05.149035264 -0300
2955 +++ mutt/mutt.h 2011-01-19 02:29:05.181029376 -0300
2964 /* Options for Mailcap lookup */
2966 @@ -297,6 +300,12 @@
2969 OPT_VERIFYSIG, /* verify PGP signatures */
2972 + OPT_NNTPRECONNECT,
2974 + OPT_FOLLOWUPTOPOSTER,
2975 +#endif /* USE_NNTP */
2977 /* THIS MUST BE THE LAST VALUE. */
2980 #define SENDMAILX (1<<6)
2981 #define SENDKEY (1<<7)
2982 #define SENDRESEND (1<<8)
2983 +#define SENDNEWS (1<<9)
2985 /* flags to _mutt_select_file() */
2986 #define M_SEL_BUFFY (1<<0)
3001 + OPTMIMESUBJECT, /* encode subject line with RFC2047 */
3006 @@ -494,6 +509,16 @@
3010 + /* news options */
3014 + OPTSHOWONLYUNREAD,
3018 +#endif /* USE_NNTP */
3020 /* pseudo options */
3022 OPTAUXSORT, /* (pseudo) using auxillary sort function */
3024 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
3025 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3026 OPTATTACHMSG, /* (pseudo) used by attach-message */
3027 + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3028 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3029 * functions while we are executing an
3031 @@ -524,6 +550,12 @@
3032 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3033 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
3036 + OPTNEWS, /* (pseudo) used to change reader mode */
3037 + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3038 + OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
3044 @@ -603,6 +635,13 @@
3048 + char *organization;
3052 + char *followup_to;
3053 + char *x_comment_to;
3056 LIST *references; /* message references (in reverse order) */
3057 LIST *in_reply_to; /* in-reply-to header content */
3059 ENVELOPE *env; /* envelope information */
3060 BODY *content; /* list of MIME parts */
3066 char *tree; /* character string to print thread tree */
3069 int refno; /* message number on server */
3072 -#if defined USE_POP || defined USE_IMAP
3073 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3074 void *data; /* driver-specific data */
3077 Index: mutt/muttlib.c
3078 ===================================================================
3079 --- mutt.orig/muttlib.c 2011-01-19 02:29:05.111042256 -0300
3080 +++ mutt/muttlib.c 2011-01-19 02:29:05.182029192 -0300
3083 mutt_free_list (&(*h)->chain);
3085 -#if defined USE_POP || defined USE_IMAP
3086 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3089 FREE (h); /* __FREE_CHECKED__ */
3090 @@ -725,6 +725,13 @@
3091 FREE (&(*p)->supersedes);
3093 FREE (&(*p)->x_label);
3094 + FREE (&(*p)->organization);
3096 + FREE (&(*p)->newsgroups);
3097 + FREE (&(*p)->xref);
3098 + FREE (&(*p)->followup_to);
3099 + FREE (&(*p)->x_comment_to);
3102 mutt_buffer_free (&(*p)->spam);
3104 @@ -1578,6 +1585,14 @@
3109 + if (magic == M_NNTP)
3111 + mutt_error _("Can't save message to newsserver.");
3116 if (stat (s, st) != -1)
3120 ===================================================================
3121 --- mutt.orig/mx.c 2011-01-19 02:29:05.112042072 -0300
3122 +++ mutt/mx.c 2011-01-19 02:29:05.183029008 -0300
3123 @@ -347,6 +347,22 @@
3128 +int mx_is_nntp (const char *p)
3130 + url_scheme_t scheme;
3135 + scheme = url_check_scheme (p);
3136 + if (scheme == U_NNTP || scheme == U_NNTPS)
3143 int mx_get_magic (const char *path)
3146 @@ -364,6 +380,11 @@
3148 #endif /* USE_POP */
3151 + if (mx_is_nntp (path))
3153 +#endif /* USE_NNTP */
3155 if (stat (path, &st) == -1)
3157 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
3158 @@ -691,6 +712,12 @@
3160 #endif /* USE_POP */
3164 + rc = nntp_open_mailbox (ctx);
3166 +#endif /* USE_NNTP */
3171 @@ -803,6 +830,12 @@
3172 rc = pop_sync_mailbox (ctx, index_hint);
3174 #endif /* USE_POP */
3178 + rc = nntp_sync_mailbox (ctx);
3180 +#endif /* USE_NNTP */
3184 @@ -888,6 +921,16 @@
3189 + if (ctx->magic == M_NNTP)
3193 + ret = nntp_close_mailbox (ctx);
3194 + mx_fastclose_mailbox (ctx);
3198 if (ctx->readonly || ctx->dontwrite)
3200 /* mailbox is readonly or we don't want to write */
3201 @@ -1464,6 +1507,11 @@
3203 return (pop_check_mailbox (ctx, index_hint));
3204 #endif /* USE_POP */
3208 + return (nntp_check_mailbox (ctx));
3209 +#endif /* USE_NNTP */
3213 @@ -1524,6 +1572,15 @@
3215 #endif /* USE_POP */
3220 + if (nntp_fetch_message (msg, ctx, msgno) != 0)
3224 +#endif /* USE_NNTP */
3227 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3229 @@ -1599,6 +1656,9 @@
3232 if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR
3234 + || (*msg)->magic == M_NNTP
3236 || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP)
3238 r = safe_fclose (&(*msg)->fp);
3240 ===================================================================
3241 --- mutt.orig/mx.h 2011-01-19 02:29:04.672123022 -0300
3242 +++ mutt/mx.h 2011-01-19 02:29:05.184028824 -0300
3252 #ifdef USE_COMPRESSED
3253 Index: mutt/newsrc.c
3254 ===================================================================
3255 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3256 +++ mutt/newsrc.c 2011-01-19 02:29:05.185028640 -0300
3259 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3260 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
3261 + * Copyright (C) 2000-2009 Vsevolod Volkov <vvv@mutt.org.ua>
3263 + * This program is free software; you can redistribute it and/or modify
3264 + * it under the terms of the GNU General Public License as published by
3265 + * the Free Software Foundation; either version 2 of the License, or
3266 + * (at your option) any later version.
3268 + * This program is distributed in the hope that it will be useful,
3269 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3270 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3271 + * GNU General Public License for more details.
3273 + * You should have received a copy of the GNU General Public License
3274 + * along with this program; if not, write to the Free Software
3275 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3279 +# include "config.h"
3283 +#include "mutt_curses.h"
3287 +#include "mailbox.h"
3289 +#include "rfc822.h"
3290 +#include "rfc1524.h"
3291 +#include "rfc2047.h"
3293 +#include <unistd.h>
3294 +#include <string.h>
3296 +#include <stdlib.h>
3297 +#include <sys/stat.h>
3299 +void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3306 + l = safe_calloc (1, sizeof (LIST));
3308 + s->tail->next = l;
3312 + l->data = (void *) d;
3315 +static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3318 + char group[LONG_STRING];
3320 + char *p = line, *b, *h;
3330 + while (*p && (*p != ':' && *p != '!')) p++;
3333 + len = p + 1 - line;
3334 + if (len > sizeof (group))
3335 + len = sizeof (group);
3336 + strfcpy (group, line, len);
3337 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3339 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3340 + data->group = (char *) data + sizeof (NNTP_DATA);
3341 + strcpy (data->group, group);
3342 + data->nserv = news;
3343 + data->deleted = 1;
3344 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3345 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
3346 + hash_insert (news->newsgroups, data->group, data, 0);
3347 + nntp_add_to_list (news, data);
3350 + FREE ((void **) &data->entries);
3353 + data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3357 + data->subscribed = 1;
3359 + data->subscribed = 0;
3366 + while (*p && *p != ',' && *p != '\n') p++;
3372 + if ((h = strchr(b, '-')))
3376 + data->entries[x].first = atoi(b);
3377 + data->entries[x].last = atoi(h);
3381 + data->entries[x].first = atoi(b);
3382 + data->entries[x].last = data->entries[x].first;
3385 + if (data->entries[x].last != 0)
3388 + if (x && !data->lastMessage)
3389 + data->lastMessage = data->entries[x-1].last;
3391 + mutt_newsgroup_stat (data);
3392 + dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3397 +static int slurp_newsrc (NNTP_SERVER *news)
3403 + news->stat = stat (news->newsrc, &sb);
3404 + news->size = sb.st_size;
3405 + news->mtime = sb.st_mtime;
3407 + if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3409 + /* hmm, should we use dotlock? */
3410 + if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3416 + buf = safe_malloc (sb.st_size + 1);
3417 + while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3418 + nntp_parse_newsrc_line (news, buf);
3421 + mx_unlock_file (news->newsrc, fileno (fp), 0);
3426 +void nntp_cache_expand (char *dst, const char *src)
3428 + snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3429 + mutt_expand_path (dst, _POSIX_PATH_MAX);
3432 +/* Loads $news_cache_dir/.index into memory, loads newsserver data
3433 + * and newsgroup cache names */
3434 +static int nntp_parse_cacheindex (NNTP_SERVER *news)
3437 + char buf[HUGE_STRING], *cp;
3438 + char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3443 + /* check is server name defined or not */
3444 + if (!news || !news->conn || !news->conn->account.host)
3446 + unset_option (OPTNEWSCACHE);
3447 + if (!NewsCacheDir || !*NewsCacheDir)
3450 + strfcpy (dir, NewsCacheDir, sizeof (dir));
3451 + mutt_expand_path (dir, sizeof(dir));
3453 + if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3455 + snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3456 + if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3459 + mutt_error _("Cache directory not created!");
3462 + mutt_clear_error();
3465 + set_option (OPTNEWSCACHE);
3467 + FREE (&news->cache);
3468 + snprintf (buf, sizeof(buf), "%s/.index", dir);
3469 + if (!(index = safe_fopen (buf, "a+")))
3472 + while (fgets (buf, sizeof(buf), index))
3474 + buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3475 + if (!mutt_strncmp (buf, "#: ", 3) &&
3476 + !mutt_strcasecmp (buf+3, news->conn->account.host))
3479 + while (fgets (buf, sizeof(buf), index))
3482 + while (*cp && *cp != ' ') cp++;
3483 + if (!*cp) continue;
3485 + if (!mutt_strcmp (buf, "#:"))
3487 + sscanf (cp + 1, "%s %d %d", file, &l, &m);
3488 + if (!mutt_strcmp (buf, "ALL"))
3490 + news->cache = safe_strdup (file);
3491 + news->newgroups_time = m;
3493 + else if (news->newsgroups)
3495 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3497 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3498 + data->group = (char *) data + sizeof (NNTP_DATA);
3499 + strcpy(data->group, buf);
3500 + data->nserv = news;
3501 + data->deleted = 1;
3502 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3503 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
3504 + hash_insert (news->newsgroups, data->group, data, 0);
3505 + nntp_add_to_list (news, data);
3507 + data->cache = safe_strdup (file);
3509 + if (!data->firstMessage || data->lastMessage < m)
3511 + if (!data->firstMessage)
3512 + data->firstMessage = l;
3513 + if (data->lastMessage < m)
3514 + data->lastMessage = m;
3515 + data->lastCached = m;
3516 + if (t || !data->unread)
3517 + mutt_newsgroup_stat (data);
3525 +nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
3526 + const char *fmt, const char *ifstring, const char *elsestring,
3527 + unsigned long data, format_flag flags)
3529 + char fn[SHORT_STRING], tmp[SHORT_STRING];
3534 + strncpy (fn, NewsServer, sizeof(fn) - 1);
3535 + mutt_strlower (fn);
3536 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3537 + snprintf (dest, destlen, tmp, fn);
3543 +/* nntp_parse_url: given an NNPT URL, return host, port,
3544 + * username, password and newsgroup will recognise. */
3545 +int nntp_parse_url (const char *server, ACCOUNT *acct,
3546 + char *group, size_t group_len)
3554 + acct->port = NNTP_PORT;
3555 + acct->type = M_ACCT_TYPE_NNTP;
3557 + c = safe_strdup (server);
3558 + url_parse_ciss (&url, c);
3560 + if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3562 + if (url.scheme == U_NNTPS)
3564 + acct->flags |= M_ACCT_SSL;
3565 + acct->port = NNTP_SSL_PORT;
3570 + strfcpy (group, url.path, group_len);
3572 + ret = mutt_account_fromurl (acct, &url);
3579 +void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3583 + url.path = safe_strdup (line);
3584 + mutt_account_tourl (acct, &url);
3585 + url_ciss_tostring (&url, line, len, 0);
3590 + * Automatically loads a newsrc into memory, if necessary.
3591 + * Checks the size/mtime of a newsrc file, if it doesn't match, load
3592 + * again. Hmm, if a system has broken mtimes, this might mean the file
3593 + * is reloaded every time, which we'd have to fix.
3595 + * a newsrc file is a line per newsgroup, with the newsgroup, then a
3596 + * ':' denoting subscribed or '!' denoting unsubscribed, then a
3597 + * comma separated list of article numbers and ranges.
3599 +NNTP_SERVER *mutt_select_newsserver (char *server)
3601 + char file[_POSIX_PATH_MAX];
3605 + NNTP_SERVER *serv;
3608 + if (!server || !*server)
3610 + mutt_error _("No newsserver defined!");
3614 + buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3615 + if (url_check_scheme (server) == U_UNKNOWN)
3617 + strcpy (buf, "news://");
3618 + p = strchr (buf, '\0');
3620 + strcpy (p, server);
3622 + if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3625 + mutt_error (_("%s is an invalid newsserver specification!"), server);
3630 + conn = mutt_conn_find (NULL, &acct);
3634 + mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), nntp_format_str, 0, 0);
3635 + mutt_expand_path (file, sizeof (file));
3637 + serv = (NNTP_SERVER *)conn->data;
3642 + /* externally modified? */
3643 + if (serv->stat != stat (file, &sb) || (!serv->stat &&
3644 + (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3646 + for (list = serv->list; list; list = list->next)
3648 + NNTP_DATA *data = (NNTP_DATA *) list->data;
3652 + data->subscribed = 0;
3657 + slurp_newsrc (serv);
3658 + nntp_clear_cacheindex (serv);
3661 + if (serv->status == NNTP_BYE)
3662 + serv->status = NNTP_NONE;
3663 + nntp_check_newgroups (serv, 0);
3667 + /* New newsserver */
3668 + serv = safe_calloc (1, sizeof (NNTP_SERVER));
3669 + serv->conn = conn;
3670 + serv->newsrc = safe_strdup (file);
3671 + serv->newsgroups = hash_create (1009, 0);
3672 + slurp_newsrc (serv); /* load .newsrc */
3673 + nntp_parse_cacheindex (serv); /* load .index */
3674 + if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3675 + nntp_check_newgroups (serv, 1);
3676 + else if (nntp_get_active (serv) < 0)
3678 + hash_destroy (&serv->newsgroups, nntp_delete_data);
3679 + for (list = serv->list; list; list = list->next)
3680 + list->data = NULL;
3681 + mutt_free_list (&serv->list);
3682 + FREE (&serv->newsrc);
3683 + FREE (&serv->cache);
3687 + nntp_clear_cacheindex (serv);
3688 + conn->data = (void *)serv;
3694 + * full status flags are not supported by nntp, but we can fake some
3695 + * of them. This is how:
3696 + * Read = a read message number is in the .newsrc
3697 + * New = a message is new since we last read this newsgroup
3698 + * Old = anything else
3699 + * So, Read is marked as such in the newsrc, old is anything that is
3700 + * "skipped" in the newsrc, and new is anything not in the newsrc nor
3701 + * in the cache. By skipped, I mean before the last unread message
3703 +void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3705 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3709 + data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3715 + dprint (3, (debugfile, "newsgroup %s not found\n", group));
3720 + for (x = 0; x < data->num; x++)
3722 + if ((article >= data->entries[x].first) &&
3723 + (article <= data->entries[x].last))
3725 + /* we cannot use mutt_set_flag() because mx_update_context()
3726 + didn't called yet */
3731 + /* If article was not cached yet, it is new! :) */
3732 + if (!data->cache || article > data->lastCached)
3734 + /* Old articles are articles which aren't read but an article after them
3735 + * has been cached */
3736 + if (option (OPTMARKOLD))
3740 +void mutt_newsgroup_stat (NNTP_DATA *data)
3743 + unsigned int first, last;
3746 + if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3749 + data->unread = data->lastMessage - data->firstMessage + 1;
3750 + for (i = 0; i < data->num; i++)
3752 + first = data->entries[i].first;
3753 + if (first < data->firstMessage)
3754 + first = data->firstMessage;
3755 + last = data->entries[i].last;
3756 + if (last > data->lastMessage)
3757 + last = data->lastMessage;
3758 + if (first <= last)
3759 + data->unread -= last - first + 1;
3763 +static int puti (char *line, int num)
3767 + for (p = s; num; )
3769 + *p++ = '0' + num % 10;
3773 + *line++ = *--p, num++;
3778 +static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3780 + char *line = *pline;
3781 + size_t len = *buflen - (*pline - *buf);
3784 + if (len < LONG_STRING * 10)
3789 + safe_realloc (buf, *buflen);
3790 + line = *buf + (*pline - line);
3792 + strcpy (line, data->group);
3793 + len -= strlen (line) + 1;
3794 + line += strlen (line);
3795 + *line++ = data->subscribed ? ':' : '!';
3799 + for (x = 0; x < data->num; x++)
3801 + if (len < LONG_STRING)
3807 + safe_realloc (buf, *buflen);
3808 + line = *buf + (*pline - line);
3817 + if (data->entries[x].first == data->entries[x].last)
3818 + snprintf (line, len, "%d%n", data->entries[x].first, &i);
3820 + snprintf (line, len, "%d-%d%n",
3821 + data->entries[x].first, data->entries[x].last, &i);
3825 + i = puti (line, data->entries[x].first);
3826 + line +=i; len -= i;
3827 + if (data->entries[x].first != data->entries[x].last)
3831 + i = puti (line, data->entries[x].last);
3832 + line +=i; len -= i;
3841 +void newsrc_gen_entries (CONTEXT *ctx)
3843 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3845 + unsigned int last = 0, first = 1;
3846 + int save_sort = SORT_ORDER;
3848 + if (Sort != SORT_ORDER)
3851 + Sort = SORT_ORDER;
3852 + mutt_sort_headers (ctx, 0);
3857 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3862 + * Set up to fake initial sequence from 1 to the article before the
3863 + * first article in our list
3868 + for (x = 0; x < ctx->msgcount; x++)
3870 + if (series) /* search for first unread */
3873 + * We don't actually check sequential order, since we mark
3874 + * "missing" entries as read/deleted
3876 + last = ctx->hdrs[x]->article_num;
3877 + if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3878 + !ctx->hdrs[x]->read)
3880 + if (data->num >= data->max)
3882 + data->max = data->max * 2;
3883 + safe_realloc (&data->entries,
3884 + data->max * sizeof (NEWSRC_ENTRY));
3886 + data->entries[data->num].first = first;
3887 + data->entries[data->num].last = last - 1;
3892 + else /* search for first read */
3894 + if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3899 + last = ctx->hdrs[x]->article_num;
3902 + if (series && first <= data->lastLoaded)
3904 + if (data->num >= data->max)
3906 + data->max = data->max * 2;
3907 + safe_realloc (&data->entries,
3908 + data->max * sizeof (NEWSRC_ENTRY));
3910 + data->entries[data->num].first = first;
3911 + data->entries[data->num].last = data->lastLoaded;
3915 + if (save_sort != Sort)
3918 + mutt_sort_headers (ctx, 0);
3922 +static int mutt_update_list_file (char *filename, char *section,
3923 + char *key, char *line)
3927 + char buf[HUGE_STRING];
3928 + char tmpfile[_POSIX_PATH_MAX];
3930 + int ext = 0, done = 0, r = 0;
3932 + /* if file not exist, create it */
3933 + if ((ifp = safe_fopen (filename, "a")))
3935 + dprint (1, (debugfile, "Opening %s\n", filename));
3936 + if (!(ifp = safe_fopen (filename, "r")))
3938 + mutt_error (_("Unable to open %s for reading"), filename);
3941 + if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3944 + mutt_error (_("Unable to lock %s"), filename);
3947 + snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3948 + dprint (1, (debugfile, "Opening %s\n", tmpfile));
3949 + if (!(ofp = fopen (tmpfile, "w")))
3952 + mutt_error (_("Unable to open %s for writing"), tmpfile);
3958 + while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3960 + r = fputs (buf, ofp);
3962 + while (*c && *c != '\n') c++;
3963 + c[0] = 0; /* strip EOL */
3964 + if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3967 + if (r != EOF && !done)
3969 + snprintf (buf, sizeof(buf), "#: %s\n", section);
3970 + r = fputs (buf, ofp);
3975 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3980 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3982 + if (*c != '\\') ext = 0;
3984 + else if ((section && !strncmp (buf, "#: ", 3)))
3986 + if (!done && line)
3988 + fputs (line, ofp);
3989 + fputc ('\n', ofp);
3991 + r = fputs (buf, ofp);
3995 + else if (key && !strncmp (buf, key, strlen(key)) &&
3996 + (!*key || buf[strlen(key)] == ' '))
4000 + while (*c && (*c != '\r') && (*c != '\n')) c++;
4002 + if (*c == '\\') ext = 1;
4003 + if (!done && line)
4005 + r = fputs (line, ofp);
4007 + r = fputc ('\n', ofp);
4013 + r = fputs (buf, ofp);
4017 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
4018 + r = fputs (buf, ofp);
4020 + /* If there wasn't a line to replace, put it on the end of the file */
4021 + if (r != EOF && !done && line)
4023 + fputs (line, ofp);
4024 + r = fputc ('\n', ofp);
4026 + mx_unlock_file (filename, fileno (ifp), 0);
4032 + mutt_error (_("Can't write %s"), tmpfile);
4035 + if (rename (tmpfile, filename) < 0)
4038 + mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
4044 +int mutt_newsrc_update (NNTP_SERVER *news)
4054 + llen = len = 10 * LONG_STRING;
4055 + line = buf = safe_calloc (1, len);
4056 + /* we will generate full newsrc here */
4057 + for (tmp = news->list; tmp; tmp = tmp->next)
4059 + data = (NNTP_DATA *) tmp->data;
4060 + if (!data || !data->rc)
4062 + nntp_create_newsrc_line (data, &buf, &line, &llen);
4064 + dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4065 + line += strlen (line);
4067 + /* newrc being fully rewritten */
4068 + if (news->newsrc &&
4069 + (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4073 + stat (news->newsrc, &st);
4074 + news->size = st.st_size;
4075 + news->mtime = st.st_mtime;
4081 +static FILE *mutt_mkname (char *s)
4083 + char buf[_POSIX_PATH_MAX], *pc;
4087 + nntp_cache_expand (buf, s);
4088 + if ((fp = safe_fopen (buf, "w")))
4091 + nntp_cache_expand (buf, "cache-XXXXXX");
4092 + pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4093 + if ((fd = mkstemp (buf)) == -1)
4095 + strcpy (s, pc); /* generated name */
4096 + return fdopen (fd, "w");
4099 +/* Updates info into .index file: ALL or about selected newsgroup */
4100 +static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4102 + char buf[LONG_STRING], *key = "ALL";
4103 + char file[_POSIX_PATH_MAX];
4105 + if (!serv || !serv->conn || !serv->conn->account.host)
4108 + if (data && data->group)
4110 + key = data->group;
4111 + snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4112 + data->firstMessage, data->lastLoaded);
4116 + strfcpy (file, serv->cache, sizeof (file));
4117 + snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4119 + nntp_cache_expand (file, ".index");
4120 + return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4123 +/* Remove cache files of unsubscribed newsgroups */
4124 +void nntp_clear_cacheindex (NNTP_SERVER *news)
4129 + if (option (OPTSAVEUNSUB) || !news)
4132 + for (tmp = news->list; tmp; tmp = tmp->next)
4134 + data = (NNTP_DATA *) tmp->data;
4135 + if (!data || data->subscribed || !data->cache)
4137 + nntp_delete_cache (data);
4138 + dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4143 +int nntp_save_cache_index (NNTP_SERVER *news)
4145 + char buf[HUGE_STRING];
4146 + char file[_POSIX_PATH_MAX];
4151 + if (!news || !news->newsgroups)
4153 + if (!option (OPTNEWSCACHE))
4158 + nntp_cache_expand (file, news->cache);
4160 + f = safe_fopen (file, "w");
4164 + strfcpy (buf, news->conn->account.host, sizeof(buf));
4165 + f = mutt_mkname (buf);
4166 + news->cache = safe_strdup (buf);
4167 + nntp_cache_expand (file, buf);
4172 + for (l = news->list; l; l = l->next)
4174 + if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4177 + snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4178 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4181 + snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4182 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4183 + if (fputs (buf, f) == EOF)
4193 + if (nntp_update_cacheindex (news, NULL))
4201 +int nntp_save_cache_group (CONTEXT *ctx)
4203 + char buf[HUGE_STRING], addr[STRING];
4204 + char file[_POSIX_PATH_MAX];
4208 + int i = 0, save = SORT_ORDER;
4211 + if (!option (OPTNEWSCACHE))
4213 + if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4216 + if (((NNTP_DATA *)ctx->data)->cache)
4218 + nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4220 + f = safe_fopen (file, "w");
4224 + snprintf (buf, sizeof(buf), "%s-%s",
4225 + ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4226 + ((NNTP_DATA *)ctx->data)->group);
4227 + f = mutt_mkname (buf);
4228 + ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4229 + nntp_cache_expand (file, buf);
4234 + if (Sort != SORT_ORDER)
4237 + Sort = SORT_ORDER;
4238 + mutt_sort_headers (ctx, 0);
4241 + /* Save only $nntp_context messages... */
4242 + ((NNTP_DATA *)ctx->data)->lastCached = 0;
4243 + if (NntpContext && ctx->msgcount > NntpContext)
4244 + i = ctx->msgcount - NntpContext;
4245 + for (; i < ctx->msgcount; i++)
4247 + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4251 + rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4252 + tm = gmtime (&h->date_sent);
4253 + snprintf (buf, sizeof(buf),
4254 + "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4255 + h->article_num, h->env->subject, addr, tm->tm_mday,
4256 + Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4257 + tm->tm_sec, h->env->message_id);
4259 + if (h->env->references)
4260 + mutt_write_references (h->env->references, f, -10);
4261 + snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length,
4262 + (int) h->lines, NONULL(h->env->xref));
4263 + if (fputs (buf, f) == EOF)
4270 + prev = ctx->hdrs[i]->article_num;
4276 + mutt_sort_headers (ctx, 0);
4280 + if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4281 + (NNTP_DATA *)ctx->data))
4286 + ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4290 +void nntp_delete_cache (NNTP_DATA *data)
4292 + char buf[_POSIX_PATH_MAX];
4294 + if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4297 + nntp_cache_expand (buf, data->cache);
4299 + FREE (&data->cache);
4300 + data->lastCached = 0;
4301 + nntp_cache_expand (buf, ".index");
4302 + mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4305 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4309 + if (!news || !news->newsgroups || !group || !*group)
4311 + if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4313 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4314 + data->group = (char *) data + sizeof (NNTP_DATA);
4315 + strcpy (data->group, group);
4316 + data->nserv = news;
4317 + data->deleted = 1;
4318 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4319 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
4320 + hash_insert (news->newsgroups, data->group, data, 0);
4321 + nntp_add_to_list (news, data);
4323 + if (!data->subscribed)
4325 + data->subscribed = 1;
4331 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4335 + if (!news || !news->newsgroups || !group || !*group ||
4336 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4338 + if (data->subscribed)
4340 + data->subscribed = 0;
4341 + if (!option (OPTSAVEUNSUB))
4347 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4351 + if (!news || !news->newsgroups || !group || !*group ||
4352 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4356 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4360 + data->entries[0].first = 1;
4362 + data->entries[0].last = data->lastMessage;
4363 + if (Context && Context->data == data)
4367 + for (x = 0; x < Context->msgcount; x++)
4368 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4373 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4377 + if (!news || !news->newsgroups || !group || !*group ||
4378 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4382 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4386 + data->entries[0].first = 1;
4387 + data->entries[0].last = data->firstMessage - 1;
4388 + if (Context && Context->data == data)
4392 + data->unread = Context->msgcount;
4393 + for (x = 0; x < Context->msgcount; x++)
4394 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4397 + data->unread = data->lastMessage - data->entries[0].last;
4401 +/* this routine gives the first newsgroup with new messages */
4402 +void nntp_buffy (char *s)
4406 + for (list = CurrentNewsSrv->list; list; list = list->next)
4408 + NNTP_DATA *data = (NNTP_DATA *) list->data;
4410 + if (data && data->subscribed && data->unread)
4412 + if (Context && Context->magic == M_NNTP &&
4413 + !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4415 + unsigned int i, unread = 0;
4417 + for (i = 0; i < Context->msgcount; i++)
4418 + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4423 + strcpy (s, data->group);
4429 ===================================================================
4430 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4431 +++ mutt/nntp.c 2011-01-19 02:29:05.186028456 -0300
4434 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4435 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4436 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
4438 + * This program is free software; you can redistribute it and/or modify
4439 + * it under the terms of the GNU General Public License as published by
4440 + * the Free Software Foundation; either version 2 of the License, or
4441 + * (at your option) any later version.
4443 + * This program is distributed in the hope that it will be useful,
4444 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4445 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4446 + * GNU General Public License for more details.
4448 + * You should have received a copy of the GNU General Public License
4449 + * along with this program; if not, write to the Free Software
4450 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4454 +# include "config.h"
4458 +#include "mutt_curses.h"
4462 +#include "rfc1524.h"
4463 +#include "rfc2047.h"
4464 +#include "mailbox.h"
4475 +#include <unistd.h>
4476 +#include <string.h>
4478 +#include <stdlib.h>
4480 +static unsigned int _checked = 0;
4483 +static void nntp_error (const char *where, const char *msg)
4485 + dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4489 +static int nntp_auth (NNTP_SERVER *serv)
4491 + CONNECTION *conn = serv->conn;
4493 + unsigned char flags = conn->account.flags;
4495 + if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4496 + mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4498 + conn->account.flags = flags;
4502 + mutt_message _("Logging in...");
4504 + snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4505 + mutt_socket_write (conn, buf);
4506 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4508 + conn->account.flags = flags;
4513 + /* don't print the password unless we're at the ungodly debugging level */
4514 + if (debuglevel < M_SOCK_LOG_FULL)
4515 + dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4517 + snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4518 + mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4519 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4521 + conn->account.flags = flags;
4525 + if (mutt_strncmp ("281", buf, 3))
4527 + conn->account.flags = flags;
4528 + mutt_error _("Login failed.");
4536 +static int nntp_connect_error (NNTP_SERVER *serv)
4538 + serv->status = NNTP_NONE;
4539 + mutt_socket_close (serv->conn);
4540 + mutt_error _("Server closed connection!");
4545 +static int nntp_connect_and_auth (NNTP_SERVER *serv)
4547 + CONNECTION *conn = serv->conn;
4551 + serv->status = NNTP_NONE;
4553 + if (mutt_socket_open (conn) < 0)
4556 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4557 + return nntp_connect_error (serv);
4559 + if (!mutt_strncmp ("200", buf, 3))
4560 + mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4561 + else if (!mutt_strncmp ("201", buf, 3))
4562 + mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4565 + mutt_socket_close (conn);
4566 + mutt_remove_trailing_ws (buf);
4567 + mutt_error ("%s", buf);
4574 + /* Tell INN to switch to mode reader if it isn't so. Ignore all
4575 + returned codes and messages. */
4576 + mutt_socket_write (conn, "MODE READER\r\n");
4577 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4578 + return nntp_connect_error (serv);
4580 + mutt_socket_write (conn, "STAT\r\n");
4581 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4582 + return nntp_connect_error (serv);
4584 + if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
4586 + serv->status = NNTP_OK;
4590 + rc = nntp_auth (serv);
4592 + return nntp_connect_error (serv);
4595 + mutt_socket_close (conn);
4596 + serv->status = NNTP_BYE;
4601 + mutt_socket_close (conn);
4602 + mutt_error _("Login failed.");
4606 + serv->status = NNTP_OK;
4610 +static int nntp_attempt_features (NNTP_SERVER *serv)
4612 + char buf[LONG_STRING];
4613 + CONNECTION *conn = serv->conn;
4615 + mutt_socket_write (conn, "XOVER\r\n");
4616 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4617 + return nntp_connect_error (serv);
4618 + if (mutt_strncmp ("500", buf, 3))
4619 + serv->hasXOVER = 1;
4621 + mutt_socket_write (conn, "XPAT\r\n");
4622 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4623 + return nntp_connect_error (serv);
4624 + if (mutt_strncmp ("500", buf, 3))
4625 + serv->hasXPAT = 1;
4627 + mutt_socket_write (conn, "LISTGROUP\r\n");
4628 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4629 + return nntp_connect_error (serv);
4630 + if (mutt_strncmp ("500", buf, 3))
4631 + serv->hasLISTGROUP = 1;
4633 + mutt_socket_write (conn, "XGTITLE +\r\n");
4634 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4635 + return nntp_connect_error (serv);
4636 + if (mutt_strncmp ("500", buf, 3))
4637 + serv->hasXGTITLE = 1;
4639 + if (!mutt_strncmp ("282", buf, 3))
4643 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4644 + return nntp_connect_error (serv);
4645 + } while (!(buf[0] == '.' && buf[1] == '\0'));
4651 +static int nntp_open_connection (NNTP_SERVER *serv)
4653 + if (serv->status == NNTP_OK)
4655 + if (serv->status == NNTP_BYE)
4657 + if (nntp_connect_and_auth (serv) < 0)
4659 + if (nntp_attempt_features (serv) < 0)
4664 +static int nntp_reconnect (NNTP_SERVER *serv)
4666 + char buf[SHORT_STRING];
4668 + mutt_socket_close (serv->conn);
4672 + if (nntp_connect_and_auth (serv) == 0)
4675 + snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
4676 + serv->conn->account.host);
4677 + if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
4679 + serv->status = NNTP_BYE;
4685 +/* Send data from line[LONG_STRING] and receive answer to same line */
4686 +static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
4688 + char buf[LONG_STRING];
4691 + if (data->nserv->status == NNTP_BYE)
4698 + mutt_socket_write (data->nserv->conn, line);
4700 + else if (data->group)
4702 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4703 + mutt_socket_write (data->nserv->conn, buf);
4707 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4709 + if (nntp_reconnect (data->nserv) < 0)
4714 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4715 + mutt_socket_write (data->nserv->conn, buf);
4716 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4722 + else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
4726 + strfcpy (line, buf, linelen);
4731 + * This function calls funct(*line, *data) for each received line,
4732 + * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
4735 + * 1 - correct but not performed (may be, have to be continued),
4736 + * -1 - conection lost,
4737 + * -2 - invalid command or execution error,
4738 + * -3 - error in funct(*line, *data).
4740 +static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
4741 + int (*funct) (char *, void *), void *data, int tagged)
4743 + char buf[LONG_STRING];
4747 + size_t lenbuf = 0;
4752 + strfcpy (buf, query, sizeof (buf));
4753 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
4755 + if (buf[0] == '5')
4757 + if (buf[0] != '2')
4762 + inbuf = safe_malloc (sizeof (buf));
4766 + chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
4772 + if (!lenbuf && buf[0] == '.')
4774 + if (buf[1] == '\0')
4779 + if (buf[1] == '.')
4783 + strfcpy (inbuf + lenbuf, p, sizeof (buf));
4785 + if (chunk >= sizeof (buf))
4787 + lenbuf += strlen (p);
4792 + if (msg && ReadInc && (line % ReadInc == 0)) {
4794 + mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
4796 + mutt_message ("%s %d", msg, line);
4799 + if (ret == 0 && funct (inbuf, data) < 0)
4804 + safe_realloc (&inbuf, lenbuf + sizeof (buf));
4807 + funct (NULL, data);
4813 +static int nntp_read_tempfile (char *line, void *file)
4815 + FILE *f = (FILE *)file;
4822 + if (fputc ('\n', f) == EOF)
4828 +static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
4830 + register char *p, *b;
4831 + register char *colon = NULL;
4836 + /* skip to next word */
4838 + while (*b && ((*b == ' ') || (*b == '\t'))) b++;
4841 + /* skip to end of word */
4842 + while (*p && (*p != ' ') && (*p != '\t'))
4857 + nntp_get_status (ctx, h, b, atoi(colon));
4858 + if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
4859 + h->article_num = atoi(colon);
4867 + * 1 if article not found
4868 + * -1 if read or write error on tempfile or socket
4870 +static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
4872 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
4874 + char buf[LONG_STRING];
4875 + char tempfile[_POSIX_PATH_MAX];
4877 + HEADER *h = ctx->hdrs[ctx->msgcount];
4879 + mutt_mktemp (tempfile, sizeof(tempfile));
4880 + if (!(f = safe_fopen (tempfile, "w+")))
4884 + snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
4886 + snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
4888 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
4893 + dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
4896 + unlink (tempfile);
4897 + return (ret == -1 ? -1 : 1);
4900 + h->article_num = article_num;
4901 + h->env = mutt_read_rfc822_header (f, h, 0, 0);
4903 + unlink (tempfile);
4905 + if (h->env->xref != NULL)
4906 + nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
4907 + else if (h->article_num == 0 && msgid)
4909 + snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
4910 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
4911 + h->article_num = atoi (buf + 4);
4917 +static int parse_description (char *line, void *n)
4919 +#define news ((NNTP_SERVER *) n)
4920 + register char *d = line;
4925 + while (*d && *d != '\t' && *d != ' ') d++;
4928 + while (*d && (*d == '\t' || *d == ' ')) d++;
4929 + dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
4930 + if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
4931 + mutt_strcmp (d, data->desc))
4933 + FREE (&data->desc);
4934 + data->desc = safe_strdup (d);
4940 +static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
4944 + if (!option (OPTLOADDESC) || !data || !data->nserv)
4947 + /* Get newsgroup description, if we can */
4948 + if (data->nserv->hasXGTITLE)
4949 + snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
4951 + snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
4952 + if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
4955 + nntp_error ("nntp_get_desc()", buf);
4961 + * XOVER returns a tab separated list of:
4962 + * id|subject|from|date|Msgid|references|bytes|lines|xref
4964 + * This has to duplicate some of the functionality of
4965 + * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
4966 + * a limited number of headers which are "parsed" by placement in the list)
4968 +static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
4970 + NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
4974 + hdr->env = mutt_new_envelope();
4975 + hdr->env->newsgroups = safe_strdup (nntp_data->group);
4976 + hdr->content = mutt_new_body();
4977 + hdr->content->type = TYPETEXT;
4978 + hdr->content->subtype = safe_strdup ("plain");
4979 + hdr->content->encoding = ENC7BIT;
4980 + hdr->content->disposition = DISPINLINE;
4981 + hdr->content->length = -1;
4984 + for (x = 0; !done && x < 9; x++)
4986 + /* if from file, need to skip newline character */
4987 + while (*p && *p != '\n' && *p != '\t') p++;
4995 + hdr->article_num = atoi (b);
4996 + nntp_get_status (ctx, hdr, NULL, hdr->article_num);
4999 + hdr->env->subject = safe_strdup (b);
5000 + /* Now we need to do the things which would normally be done in
5001 + * mutt_read_rfc822_header() */
5002 + if (hdr->env->subject)
5004 + regmatch_t pmatch[1];
5006 + rfc2047_decode (&hdr->env->subject);
5008 + if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
5009 + hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
5011 + hdr->env->real_subj = hdr->env->subject;
5015 + rfc822_free_address (&hdr->env->from);
5016 + hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
5017 + rfc2047_decode_adrlist (hdr->env->from);
5020 + hdr->date_sent = mutt_parse_date (b, hdr);
5021 + hdr->received = hdr->date_sent;
5024 + FREE (&hdr->env->message_id);
5025 + hdr->env->message_id = safe_strdup (b);
5028 + mutt_free_list (&hdr->env->references);
5029 + hdr->env->references = mutt_parse_references (b, 0);
5032 + hdr->content->length = atoi (b);
5035 + hdr->lines = atoi (b);
5039 + FREE (&hdr->env->xref);
5040 + b = b + 6; /* skips the "Xref: " */
5041 + hdr->env->xref = safe_strdup (b);
5042 + nntp_parse_xref (ctx, nntp_data->group, b, hdr);
5054 + unsigned int base;
5055 + unsigned int first;
5056 + unsigned int last;
5057 + unsigned short *messages;
5061 +#define fc ((FETCH_CONTEXT *) c)
5062 +static int nntp_fetch_numbers (char *line, void *c)
5068 + num = atoi (line);
5069 + if (num < fc->base || num > fc->last)
5071 + fc->messages[num - fc->base] = 1;
5075 +static int add_xover_line (char *line, void *c)
5077 + unsigned int num, total;
5078 + CONTEXT *ctx = fc->ctx;
5079 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5084 + if (ctx->msgcount >= ctx->hdrmax)
5085 + mx_alloc_memory (ctx);
5086 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5087 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5089 + nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5090 + num = ctx->hdrs[ctx->msgcount]->article_num;
5092 + if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5095 + if (num > data->lastLoaded)
5096 + data->lastLoaded = num;
5097 + num = num - fc->first + 1;
5098 + total = fc->last - fc->first + 1;
5099 + if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5100 + mutt_message ("%s %d/%d", fc->msg, num, total);
5103 + mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5109 +static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5110 + unsigned int last)
5112 + char buf[HUGE_STRING];
5113 + char *msg = _("Fetching message headers...");
5114 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5118 + unsigned int current;
5122 + /* if empty group or nothing to do */
5123 + if (!last || first > last)
5126 + /* fetch list of articles */
5130 + fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5131 + if (nntp_data->nserv->hasLISTGROUP)
5133 + mutt_message _("Fetching list of articles...");
5134 + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5135 + if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5137 + mutt_error (_("LISTGROUP command failed: %s"), buf);
5139 + nntp_error ("nntp_fetch_headers()", buf);
5141 + FREE (&fc.messages);
5147 + for (num = 0; num < last - first + 1; num++)
5148 + fc.messages[num] = 1;
5151 + /* CACHE: must be loaded xover cache here */
5152 + num = nntp_data->lastCached - first + 1;
5153 + if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5155 + nntp_cache_expand (buf, nntp_data->cache);
5156 + mutt_message _("Fetching headers from cache...");
5157 + if ((f = safe_fopen (buf, "r")))
5161 + /* counting number of lines */
5162 + while (fgets (buf, sizeof (buf), f) != NULL)
5165 + while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5167 + oldmsgcount = ctx->msgcount;
5169 + fc.last = first + num - 1;
5171 + while (fgets (buf, sizeof (buf), f) != NULL)
5172 + add_xover_line (buf, &fc);
5174 + nntp_data->lastLoaded = fc.last;
5175 + first = fc.last + 1;
5176 + if (ctx->msgcount > oldmsgcount)
5177 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5180 + nntp_delete_cache (nntp_data);
5182 + num = last - first + 1;
5185 + FREE (&fc.messages);
5190 + * Without XOVER, we have to fetch each article header and parse
5191 + * it. With XOVER, we ask for all of them
5193 + mutt_message (msg);
5194 + if (nntp_data->nserv->hasXOVER)
5196 + oldmsgcount = ctx->msgcount;
5200 + snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5201 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5202 + if (ctx->msgcount > oldmsgcount)
5203 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5206 + mutt_error (_("XOVER command failed: %s"), buf);
5208 + nntp_error ("nntp_fetch_headers()", buf);
5210 + FREE (&fc.messages);
5216 + for (current = first; current <= last; current++)
5220 + ret = current - first + 1;
5221 + mutt_message ("%s %d/%d", msg, ret, num);
5223 + if (!fc.messages[current - fc.base])
5226 + if (ctx->msgcount >= ctx->hdrmax)
5227 + mx_alloc_memory (ctx);
5228 + h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5229 + h->index = ctx->msgcount;
5231 + ret = nntp_read_header (ctx, NULL, current);
5232 + if (ret == 0) /* Got article. Fetch next header */
5234 + nntp_get_status (ctx, h, NULL, h->article_num);
5236 + mx_update_context (ctx, 1);
5239 + mutt_free_header (&h); /* skip it */
5242 + FREE (&fc.messages);
5246 + if (current > nntp_data->lastLoaded)
5247 + nntp_data->lastLoaded = current;
5249 + FREE (&fc.messages);
5250 + nntp_data->lastLoaded = last;
5251 + mutt_clear_error ();
5256 + * currently, nntp "mailbox" is "newsgroup"
5258 +int nntp_open_mailbox (CONTEXT *ctx)
5260 + NNTP_DATA *nntp_data;
5261 + NNTP_SERVER *serv;
5262 + char buf[HUGE_STRING];
5263 + char server[LONG_STRING];
5265 + unsigned int first;
5268 + if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5270 + mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5276 + nntp_expand_path (server, sizeof (server), &acct);
5277 + if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5280 + CurrentNewsSrv = serv;
5282 + /* create NNTP-specific state struct if nof found in list */
5283 + if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5285 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5286 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5287 + strcpy (nntp_data->group, buf);
5288 + hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5289 + nntp_add_to_list (serv, nntp_data);
5291 + ctx->data = nntp_data;
5292 + ctx->mx_close = nntp_fastclose_mailbox;
5293 + nntp_data->nserv = serv;
5295 + mutt_message (_("Selecting %s..."), nntp_data->group);
5297 + if (!nntp_data->desc)
5299 + nntp_get_desc (nntp_data, nntp_data->group, NULL);
5300 + if (nntp_data->desc)
5301 + nntp_save_cache_index (serv);
5305 + if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5308 + nntp_error ("nntp_open_mailbox()", buf);
5313 + if (mutt_strncmp ("211", buf, 3))
5315 + LIST *l = serv->list;
5317 + /* GROUP command failed */
5318 + if (!mutt_strncmp ("411", buf, 3))
5320 + mutt_error (_("Newsgroup %s not found on server %s"),
5321 + nntp_data->group, serv->conn->account.host);
5323 + /* CACHE: delete cache and line from .index */
5324 + nntp_delete_cache (nntp_data);
5325 + hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5326 + while (l && l->data != (void *) nntp_data) l = l->next;
5336 + sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5337 + &nntp_data->lastMessage, buf);
5339 + nntp_data->deleted = 0;
5341 + time (&serv->check_time);
5344 + * Check for max adding context. If it is greater than $nntp_context,
5345 + * strip off extra articles
5347 + first = nntp_data->firstMessage;
5348 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5349 + first = nntp_data->lastMessage - NntpContext + 1;
5351 + nntp_data->lastLoaded = first - 1;
5352 + return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5355 +int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5357 + char buf[LONG_STRING];
5358 + char path[_POSIX_PATH_MAX];
5359 + NNTP_CACHE *cache;
5360 + char *m = _("Fetching message...");
5363 + /* see if we already have the message in our cache */
5364 + cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5366 + /* if everything is fine, assign msg->fp and return */
5367 + if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5368 + (msg->fp = fopen (cache->path, "r")))
5371 + /* clear the previous entry */
5372 + unlink (cache->path);
5373 + free (cache->path);
5377 + cache->index = ctx->hdrs[msgno]->index;
5378 + mutt_mktemp (path, sizeof(path));
5379 + cache->path = safe_strdup (path);
5380 + if (!(msg->fp = safe_fopen (path, "w+")))
5382 + FREE (&cache->path);
5386 + if (ctx->hdrs[msgno]->article_num == 0)
5387 + snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5388 + ctx->hdrs[msgno]->env->message_id);
5390 + snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5391 + ctx->hdrs[msgno]->article_num);
5393 + ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5394 + msg->fp, ctx->tagged);
5397 + mutt_error (_("Article %d not found on server"),
5398 + ctx->hdrs[msgno]->article_num);
5399 + dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5406 + FREE (&cache->path);
5410 + mutt_free_envelope (&ctx->hdrs[msgno]->env);
5411 + ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5412 + /* fix content length */
5413 + fseek(msg->fp, 0, SEEK_END);
5414 + ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5415 + ctx->hdrs[msgno]->content->offset;
5417 + /* this is called in mutt before the open which fetches the message,
5418 + * which is probably wrong, but we just call it again here to handle
5419 + * the problem instead of fixing it.
5421 + mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5423 + /* These would normally be updated in mx_update_context(), but the
5424 + * full headers aren't parsed with XOVER, so the information wasn't
5427 +#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5428 + ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5429 +#endif /* HAVE_PGP || HAVE_SMIME */
5431 + mutt_clear_error();
5438 +int nntp_post (const char *msg) {
5439 + char buf[LONG_STRING];
5442 + NNTP_DATA *nntp_data;
5444 + if (Context && Context->magic == M_NNTP)
5445 + nntp_data = (NNTP_DATA *)Context->data;
5448 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5449 + !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5451 + mutt_error (_("Can't post article. No connection to news server."));
5454 + nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5457 + if (!(f = safe_fopen (msg, "r")))
5459 + mutt_error (_("Can't post article. Unable to open %s"), msg);
5463 + strfcpy (buf, "POST\r\n", sizeof (buf));
5464 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5466 + mutt_error (_("Can't post article. Connection to %s lost."),
5467 + nntp_data->nserv->conn->account.host);
5470 + if (buf[0] != '3')
5472 + mutt_error (_("Can't post article: %s"), buf);
5478 + while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5480 + len = strlen (buf);
5481 + if (buf[len - 1] == '\n')
5483 + buf[len - 1] = '\r';
5488 + if (buf[1] == '.')
5489 + mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5491 + mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5495 + if (buf[strlen (buf) - 1] != '\n')
5496 + mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5497 + mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5498 + if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5500 + mutt_error (_("Can't post article. Connection to %s lost."),
5501 + nntp_data->nserv->conn->account.host);
5504 + if (buf[0] != '2')
5506 + mutt_error (_("Can't post article: %s"), buf);
5513 +/* nntp_logout_all: close all open connections. */
5514 +void nntp_logout_all (void)
5516 + char buf[LONG_STRING];
5519 + conn = mutt_socket_head ();
5523 + CONNECTION *next = conn->next;
5525 + if (conn->account.type == M_ACCT_TYPE_NNTP)
5527 + mutt_message (_("Closing connection to %s..."), conn->account.host);
5528 + mutt_socket_write (conn, "QUIT\r\n");
5529 + mutt_socket_readln (buf, sizeof (buf), conn);
5530 + mutt_clear_error ();
5531 + mutt_socket_close (conn);
5532 + mutt_socket_free (conn);
5539 +static void nntp_free_acache (NNTP_DATA *data)
5543 + for (i = 0; i < NNTP_CACHE_LEN; i++)
5545 + if (data->acache[i].path)
5547 + unlink (data->acache[i].path);
5548 + FREE (&data->acache[i].path);
5553 +void nntp_delete_data (void *p)
5555 + NNTP_DATA *data = (NNTP_DATA *)p;
5559 + FREE (&data->entries);
5560 + FREE (&data->desc);
5561 + FREE (&data->cache);
5562 + nntp_free_acache (data);
5566 +int nntp_sync_mailbox (CONTEXT *ctx)
5568 + NNTP_DATA *data = ctx->data;
5570 + /* CACHE: update cache and .index files */
5571 + if ((option (OPTSAVEUNSUB) || data->subscribed))
5572 + nntp_save_cache_group (ctx);
5573 + nntp_free_acache (data);
5575 + data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
5579 +int nntp_fastclose_mailbox (CONTEXT *ctx)
5581 + NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
5585 + nntp_free_acache (data);
5586 + if (!data->nserv || !data->nserv->newsgroups || !data->group)
5588 + nntp_save_cache_index (data->nserv);
5589 + if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
5591 + nntp_delete_data (data);
5595 +/* commit changes and terminate connection */
5596 +int nntp_close_mailbox (CONTEXT *ctx)
5600 + mutt_message _("Quitting newsgroup...");
5603 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
5606 + if (data->nserv && data->nserv->conn && ctx->unread)
5608 + ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
5610 + mutt_newsgroup_catchup (data->nserv, data->group);
5615 + nntp_sync_mailbox (ctx);
5616 + if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
5618 + NNTP_SERVER *news;
5620 + news = ((NNTP_DATA *)ctx->data)->nserv;
5621 + newsrc_gen_entries (ctx);
5622 + ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
5623 + mutt_newsrc_update (news);
5625 + mutt_clear_error();
5629 +/* use the GROUP command to poll for new mail */
5630 +static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
5632 + char buf[LONG_STRING];
5635 + if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
5639 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5642 + nntp_error ("nntp_check_mailbox()", buf);
5646 + if (mutt_strncmp ("211", buf, 3))
5649 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5652 + nntp_error ("nntp_check_mailbox()", buf);
5657 + if (!mutt_strncmp ("211", buf, 3))
5662 + sscanf (buf + 4, "%d %d %d", &count, &first, &last);
5663 + nntp_data->firstMessage = first;
5664 + nntp_data->lastMessage = last;
5665 + if (ctx && last > nntp_data->lastLoaded)
5667 + nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
5668 + time (&nntp_data->nserv->check_time);
5671 + if (!last || (!nntp_data->rc && !nntp_data->lastCached))
5672 + nntp_data->unread = count;
5674 + mutt_newsgroup_stat (nntp_data);
5675 + /* active was renumbered? */
5676 + if (last < nntp_data->lastLoaded)
5678 + if (!nntp_data->max)
5680 + nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
5681 + nntp_data->max = 5;
5683 + nntp_data->lastCached = 0;
5684 + nntp_data->num = 1;
5685 + nntp_data->entries[0].first = 1;
5686 + nntp_data->entries[0].last = 0;
5690 + time (&nntp_data->nserv->check_time);
5694 +int nntp_check_mailbox (CONTEXT *ctx)
5696 + return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
5699 +static int add_group (char *buf, void *serv)
5701 +#define s ((NNTP_SERVER *) serv)
5702 + char group[LONG_STRING], mod, desc[HUGE_STRING];
5704 + NNTP_DATA *nntp_data;
5707 + _checked = n; /* _checked have N, where N = number of groups */
5708 + if (!buf) /* at EOF must be zerouth */
5715 + sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
5718 + if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
5721 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
5722 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5723 + strcpy (nntp_data->group, group);
5724 + nntp_data->nserv = s;
5725 + if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
5726 + s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2, 0);
5727 + hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
5728 + nntp_add_to_list (s, nntp_data);
5730 + nntp_data->deleted = 0;
5731 + nntp_data->firstMessage = first;
5732 + nntp_data->lastMessage = last;
5734 + nntp_data->allowed = 1;
5736 + nntp_data->allowed = 0;
5737 + if (nntp_data->desc)
5738 + FREE (&nntp_data->desc);
5740 + nntp_data->desc = safe_strdup (desc);
5741 + if (nntp_data->rc || nntp_data->lastCached)
5742 + mutt_newsgroup_stat (nntp_data);
5743 + else if (nntp_data->lastMessage &&
5744 + nntp_data->firstMessage <= nntp_data->lastMessage)
5745 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
5747 + nntp_data->unread = 0;
5753 +int nntp_check_newgroups (NNTP_SERVER *serv, int force)
5755 + char buf[LONG_STRING];
5756 + char msg[SHORT_STRING];
5757 + NNTP_DATA nntp_data;
5762 + unsigned int count = 0;
5763 + unsigned int total = 0;
5765 + if (!serv || !serv->newgroups_time)
5768 + if (nntp_open_connection (serv) < 0)
5771 + /* check subscribed groups for new news */
5772 + if (option (OPTSHOWNEWNEWS))
5774 + mutt_message _("Checking for new messages...");
5775 + for (l = serv->list; l; l = l->next)
5777 + serv->check_time = 0; /* really check! */
5778 + if (l->data && ((NNTP_DATA *) l->data)->subscribed)
5779 + _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
5785 + mutt_message _("Checking for new newsgroups...");
5786 + now = serv->newgroups_time;
5787 + time (&serv->newgroups_time);
5788 + t = gmtime (&now);
5789 + snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
5790 + (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
5792 + nntp_data.nserv = serv;
5793 + if (Context && Context->magic == M_NNTP)
5794 + nntp_data.group = ((NNTP_DATA *)Context->data)->group;
5796 + nntp_data.group = NULL;
5798 + if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
5799 + add_group, serv, 0) != 0)
5802 + nntp_error ("nntp_check_newgroups()", buf);
5807 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5808 + mutt_message (msg);
5810 + emp.next = l->next;
5812 + emp.next = serv->list;
5817 + ((NNTP_DATA *) l->data)->new = 1;
5824 + nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
5826 + if (ReadInc && (count % ReadInc == 0))
5827 + mutt_message ("%s %d/%d", msg, count, total);
5830 + nntp_save_cache_index (serv);
5831 + mutt_clear_error ();
5835 +/* Load list of all newsgroups from cache ALL */
5836 +int nntp_get_cache_all (NNTP_SERVER *serv)
5838 + char buf[HUGE_STRING];
5841 + nntp_cache_expand (buf, serv->cache);
5842 + if ((f = safe_fopen (buf, "r")))
5846 + while (fgets (buf, sizeof(buf), f) != NULL)
5848 + if (ReadInc && (i % ReadInc == 0))
5849 + mutt_message (_("Loading list from cache... %d"), i);
5850 + add_group (buf, serv);
5853 + add_group (NULL, NULL);
5855 + mutt_clear_error ();
5860 + FREE (&serv->cache);
5865 +/* Load list of all newsgroups from active */
5866 +int nntp_get_active (NNTP_SERVER *serv)
5868 + char msg[SHORT_STRING];
5869 + NNTP_DATA nntp_data;
5872 + if (nntp_open_connection (serv) < 0)
5875 + snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
5876 + serv->conn->account.host);
5877 + mutt_message (msg);
5878 + time (&serv->newgroups_time);
5879 + nntp_data.nserv = serv;
5880 + nntp_data.group = NULL;
5882 + if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
5885 + nntp_error ("nntp_get_active()", "LIST\r\n");
5890 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5891 + mutt_message (msg);
5892 + nntp_get_desc (&nntp_data, "*", msg);
5894 + for (tmp = serv->list; tmp; tmp = tmp->next)
5896 + NNTP_DATA *data = (NNTP_DATA *)tmp->data;
5898 + if (data && data->deleted && !data->rc)
5900 + nntp_delete_cache (data);
5901 + hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
5905 + nntp_save_cache_index (serv);
5907 + mutt_clear_error ();
5912 + * returns -1 if error ocurred while retrieving header,
5913 + * number of articles which ones exist in context on success.
5915 +int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
5919 + /* if msgid is already in context, don't reload them */
5920 + if (hash_find (ctx->id_hash, msgid))
5922 + if (ctx->msgcount == ctx->hdrmax)
5923 + mx_alloc_memory (ctx);
5924 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5925 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5927 + mutt_message (_("Fetching %s from server..."), msgid);
5928 + ret = nntp_read_header (ctx, msgid, 0);
5929 + /* since nntp_read_header() may set read flag, we must reset it */
5930 + ctx->hdrs[ctx->msgcount]->read = 0;
5932 + mutt_free_header (&ctx->hdrs[ctx->msgcount]);
5936 + mx_update_context (ctx, 1);
5947 + unsigned int *child;
5950 +static int check_children (char *s, void *c)
5952 +#define cc ((CHILD_CONTEXT *) c)
5953 + unsigned int i, n;
5955 + if (!s || (n = atoi (s)) == 0)
5957 + for (i = 0; i < cc->ctx->msgcount; i++)
5958 + if (cc->ctx->hdrs[i]->article_num == n)
5960 + if (cc->num >= cc->max)
5961 + safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
5962 + cc->child[cc->num++] = n;
5968 +int nntp_check_children (CONTEXT *ctx, const char *msgid)
5970 + NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
5972 + int i, ret = 0, tmp = 0;
5975 + if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
5976 + !nntp_data->nserv->conn->account.host)
5978 + if (nntp_data->firstMessage > nntp_data->lastLoaded)
5980 + if (!nntp_data->nserv->hasXPAT)
5982 + mutt_error (_("Server %s does not support this operation!"),
5983 + nntp_data->nserv->conn->account.host);
5987 + snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
5988 + nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
5993 + cc.child = safe_malloc (sizeof (unsigned int) * 25);
5994 + if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
5999 + /* dont try to read the xover cache. check_children() already
6000 + * made sure that we dont have the article, so we need to visit
6001 + * the server. Reading the cache at this point is also bad
6002 + * because it would duplicate messages */
6003 + if (option (OPTNEWSCACHE))
6006 + unset_option (OPTNEWSCACHE);
6008 + for (i = 0; i < cc.num; i++)
6010 + if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
6012 + if (ctx->msgcount &&
6013 + ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
6014 + ctx->hdrs[ctx->msgcount - 1]->read = 0;
6017 + set_option (OPTNEWSCACHE);
6022 ===================================================================
6023 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
6024 +++ mutt/nntp.h 2011-01-19 02:29:05.187028272 -0300
6027 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
6028 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
6029 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
6031 + * This program is free software; you can redistribute it and/or modify
6032 + * it under the terms of the GNU General Public License as published by
6033 + * the Free Software Foundation; either version 2 of the License, or
6034 + * (at your option) any later version.
6036 + * This program is distributed in the hope that it will be useful,
6037 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6038 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6039 + * GNU General Public License for more details.
6041 + * You should have received a copy of the GNU General Public License
6042 + * along with this program; if not, write to the Free Software
6043 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6049 +#include "mutt_socket.h"
6050 +#include "mailbox.h"
6054 +#define NNTP_PORT 119
6055 +#define NNTP_SSL_PORT 563
6057 +/* number of entries in the hash table */
6058 +#define NNTP_CACHE_LEN 10
6075 + unsigned int hasXPAT : 1;
6076 + unsigned int hasXGTITLE : 1;
6077 + unsigned int hasXOVER : 1;
6078 + unsigned int hasLISTGROUP : 1;
6079 + unsigned int status : 3;
6085 + time_t newgroups_time;
6086 + time_t check_time;
6088 + LIST *list; /* list of newsgroups */
6089 + LIST *tail; /* last entry of list */
6095 + unsigned int index;
6101 + NEWSRC_ENTRY *entries;
6102 + unsigned int num; /* number of used entries */
6103 + unsigned int max; /* number of allocated entries */
6104 + unsigned int unread;
6105 + unsigned int firstMessage;
6106 + unsigned int lastMessage;
6107 + unsigned int lastLoaded;
6108 + unsigned int lastCached;
6109 + unsigned int subscribed : 1;
6110 + unsigned int rc : 1;
6111 + unsigned int new : 1;
6112 + unsigned int allowed : 1;
6113 + unsigned int deleted : 1;
6117 + NNTP_SERVER *nserv;
6118 + NNTP_CACHE acache[NNTP_CACHE_LEN];
6121 +/* internal functions */
6122 +int nntp_get_active (NNTP_SERVER *);
6123 +int nntp_get_cache_all (NNTP_SERVER *);
6124 +int nntp_save_cache_index (NNTP_SERVER *);
6125 +int nntp_check_newgroups (NNTP_SERVER *, int);
6126 +int nntp_save_cache_group (CONTEXT *);
6127 +int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6128 +void newsrc_gen_entries (CONTEXT *);
6129 +void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6130 +void mutt_newsgroup_stat (NNTP_DATA *);
6131 +void nntp_delete_cache (NNTP_DATA *);
6132 +void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6133 +void nntp_cache_expand (char *, const char *);
6134 +void nntp_delete_data (void *);
6136 +/* exposed interface */
6137 +NNTP_SERVER *mutt_select_newsserver (char *);
6138 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6139 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6140 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6141 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6142 +void nntp_clear_cacheindex (NNTP_SERVER *);
6143 +int mutt_newsrc_update (NNTP_SERVER *);
6144 +int nntp_open_mailbox (CONTEXT *);
6145 +int nntp_sync_mailbox (CONTEXT *);
6146 +int nntp_check_mailbox (CONTEXT *);
6147 +int nntp_close_mailbox (CONTEXT *);
6148 +int nntp_fastclose_mailbox (CONTEXT *);
6149 +int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6150 +int nntp_post (const char *);
6151 +int nntp_check_msgid (CONTEXT *, const char *);
6152 +int nntp_check_children (CONTEXT *, const char *);
6153 +void nntp_buffy (char *);
6154 +void nntp_expand_path (char *, size_t, ACCOUNT *);
6155 +void nntp_logout_all ();
6156 +const char *nntp_format_str (char *, size_t, size_t, char, const char *, const char *,
6157 + const char *, const char *, unsigned long, format_flag);
6159 +NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6161 +#endif /* _NNTP_H_ */
6163 ===================================================================
6164 --- mutt.orig/pager.c 2011-01-19 02:29:05.115041520 -0300
6165 +++ mutt/pager.c 2011-01-19 02:29:05.189027904 -0300
6166 @@ -1085,6 +1085,11 @@
6176 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6177 int flags, ansi_attr *pa, int cnt,
6178 @@ -1542,6 +1547,16 @@
6183 +static struct mapping_t PagerNewsHelpExtra[] = {
6184 + { N_("Post"), OP_POST },
6185 + { N_("Followup"), OP_FOLLOWUP },
6186 + { N_("Del"), OP_DELETE },
6187 + { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6194 /* This pager is actually not so simple as it once was. It now operates in
6195 @@ -1583,6 +1598,10 @@
6196 int old_PagerIndexLines; /* some people want to resize it
6197 * while inside the pager... */
6200 + char *followup_to;
6203 if (!(flags & M_SHOWCOLOR))
6204 flags |= M_SHOWFLAT;
6206 @@ -1622,7 +1641,11 @@
6207 if (IsHeader (extra))
6209 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6210 - mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6211 + mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6213 + (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6216 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6219 @@ -2511,6 +2534,15 @@
6221 CHECK_ACL(M_ACL_WRITE, "flag message");
6224 + if (Context->magic == M_NNTP)
6227 + mutt_error _("Can't change 'important' flag on NNTP server.");
6232 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6233 redraw = REDRAW_STATUS | REDRAW_INDEX;
6234 if (option (OPTRESOLVE))
6235 @@ -2544,6 +2576,60 @@
6236 redraw = REDRAW_FULL;
6241 + CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6243 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6244 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6245 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6247 + ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6248 + redraw = REDRAW_FULL;
6251 + case OP_FORWARD_TO_GROUP:
6252 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6254 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6255 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6256 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6258 + if (IsMsgAttach (extra))
6259 + mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6260 + extra->idxlen, extra->bdy, SENDNEWS);
6262 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6263 + redraw = REDRAW_FULL;
6267 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6270 + if (IsMsgAttach (extra))
6271 + followup_to = extra->bdy->hdr->env->followup_to;
6273 + followup_to = extra->hdr->env->followup_to;
6275 + if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6276 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6278 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6279 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6280 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6282 + if (IsMsgAttach (extra))
6283 + mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6284 + extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6286 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6287 + extra->ctx, extra->hdr);
6288 + redraw = REDRAW_FULL;
6294 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6296 @@ -2590,7 +2676,7 @@
6298 if (IsMsgAttach (extra))
6299 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6300 - extra->idxlen, extra->bdy);
6301 + extra->idxlen, extra->bdy, 0);
6303 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6304 redraw = REDRAW_FULL;
6306 ===================================================================
6307 --- mutt.orig/parse.c 2011-01-19 02:28:25.988240940 -0300
6308 +++ mutt/parse.c 2011-01-19 02:29:05.194026984 -0300
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 @@
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 @@
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 @@
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 Index: mutt/pattern.c
6386 ===================================================================
6387 --- mutt.orig/pattern.c 2011-01-19 02:29:04.609134614 -0300
6388 +++ mutt/pattern.c 2011-01-19 02:29:05.195026800 -0300
6390 { 'U', M_UNREAD, 0, NULL },
6391 { 'v', M_COLLAPSED, 0, NULL },
6392 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6394 + { 'w', M_NEWSGROUPS, 0, eat_regexp },
6396 { 'x', M_REFERENCE, 0, eat_regexp },
6397 { 'X', M_MIMEATTACH, 0, eat_range },
6398 { 'y', M_XLABEL, 0, eat_regexp },
6399 @@ -1213,6 +1216,10 @@
6401 case M_UNREFERENCED:
6402 return (pat->not ^ (h->thread && !h->thread->child));
6404 + case M_NEWSGROUPS:
6405 + return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6408 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6410 @@ -1294,6 +1301,7 @@
6411 progress_t progress;
6413 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6414 + if (prompt || op != M_LIMIT)
6415 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6418 Index: mutt/po/POTFILES.in
6419 ===================================================================
6420 --- mutt.orig/po/POTFILES.in 2011-01-19 02:29:04.672123022 -0300
6421 +++ mutt/po/POTFILES.in 2011-01-19 02:29:05.195026800 -0300
6431 Index: mutt/postpone.c
6432 ===================================================================
6433 --- mutt.orig/postpone.c 2011-01-19 02:29:04.593137558 -0300
6434 +++ mutt/postpone.c 2011-01-19 02:29:05.196026616 -0300
6435 @@ -125,15 +125,26 @@
6437 if (LastModify < st.st_mtime)
6440 + int optnews = option (OPTNEWS);
6442 LastModify = st.st_mtime;
6444 if (access (Postponed, R_OK | F_OK) != 0)
6445 return (PostCount = 0);
6448 + unset_option (OPTNEWS);
6450 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6453 PostCount = ctx.msgcount;
6454 mx_fastclose_mailbox (&ctx);
6457 + set_option (OPTNEWS);
6462 Index: mutt/protos.h
6463 ===================================================================
6464 --- mutt.orig/protos.h 2011-01-19 02:29:04.780103152 -0300
6465 +++ mutt/protos.h 2011-01-19 02:29:05.197026432 -0300
6467 HASH *mutt_make_subj_hash (CONTEXT *);
6469 LIST *mutt_make_references(ENVELOPE *e);
6470 +LIST *mutt_parse_references (char *, int);
6472 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6473 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
6474 Index: mutt/recvattach.c
6475 ===================================================================
6476 --- mutt.orig/recvattach.c 2011-01-19 02:29:05.005061758 -0300
6477 +++ mutt/recvattach.c 2011-01-19 02:29:05.197026432 -0300
6478 @@ -1119,6 +1119,15 @@
6483 + if (Context->magic == M_NNTP)
6486 + mutt_error _("Can't delete attachment from newsserver.");
6491 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6494 @@ -1210,10 +1219,33 @@
6495 case OP_FORWARD_MESSAGE:
6497 mutt_attach_forward (fp, hdr, idx, idxlen,
6498 - menu->tagprefix ? NULL : idx[menu->current]->content);
6499 + menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6500 menu->redraw = REDRAW_FULL;
6504 + case OP_FORWARD_TO_GROUP:
6506 + mutt_attach_forward (fp, hdr, idx, idxlen,
6507 + menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6508 + menu->redraw = REDRAW_FULL;
6514 + if (!idx[menu->current]->content->hdr->env->followup_to ||
6515 + mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6516 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6518 + mutt_attach_reply (fp, hdr, idx, idxlen,
6519 + menu->tagprefix ? NULL : idx[menu->current]->content,
6520 + SENDNEWS|SENDREPLY);
6521 + menu->redraw = REDRAW_FULL;
6527 case OP_GROUP_REPLY:
6529 Index: mutt/recvcmd.c
6530 ===================================================================
6531 --- mutt.orig/recvcmd.c 2011-01-19 02:28:26.270189064 -0300
6532 +++ mutt/recvcmd.c 2011-01-19 02:29:05.198026248 -0300
6534 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6535 ATTACHPTR ** idx, short idxlen,
6538 + short nattach, int flags)
6541 short mime_fwd_all = 0;
6545 /* now that we have the template, send it. */
6546 - ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6547 + ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6554 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6555 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6556 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6558 HEADER *curhdr = NULL;
6560 @@ -679,23 +679,23 @@
6562 mutt_free_header (&tmphdr);
6564 - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6565 + ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
6570 void mutt_attach_forward (FILE * fp, HEADER * hdr,
6571 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6572 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6577 if (check_all_msg (idx, idxlen, cur, 0) == 0)
6578 - attach_forward_msgs (fp, hdr, idx, idxlen, cur);
6579 + attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
6582 nattach = count_tagged (idx, idxlen);
6583 - attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
6584 + attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
6588 @@ -753,28 +753,40 @@
6594 + if ((flags & SENDNEWS))
6596 - if (mutt_fetch_recips (env, curenv, flags) == -1)
6598 + /* in case followup set Newsgroups: with Followup-To: if it present */
6599 + if (!env->newsgroups && curenv &&
6600 + mutt_strcasecmp (curenv->followup_to, "poster"))
6601 + env->newsgroups = safe_strdup (curenv->followup_to);
6606 - for (i = 0; i < idxlen; i++)
6609 - if (idx[i]->content->tagged
6610 - && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6611 + if (mutt_fetch_recips (env, curenv, flags) == -1)
6616 + for (i = 0; i < idxlen; i++)
6618 + if (idx[i]->content->tagged
6619 + && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6624 + if ((flags & SENDLISTREPLY) && !env->to)
6626 + mutt_error _("No mailing lists found!");
6630 + mutt_fix_reply_recipients (env);
6633 - if ((flags & SENDLISTREPLY) && !env->to)
6635 - mutt_error _("No mailing lists found!");
6639 - mutt_fix_reply_recipients (env);
6640 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
6643 @@ -835,6 +847,13 @@
6644 char prefix[SHORT_STRING];
6648 + if (flags & SENDNEWS)
6649 + set_option (OPTNEWSSEND);
6651 + unset_option (OPTNEWSSEND);
6654 if (check_all_msg (idx, idxlen, cur, 0) == -1)
6656 nattach = count_tagged (idx, idxlen);
6657 Index: mutt/rfc1524.c
6658 ===================================================================
6659 --- mutt.orig/rfc1524.c 2011-01-19 02:28:26.009237078 -0300
6660 +++ mutt/rfc1524.c 2011-01-19 02:29:05.199026064 -0300
6661 @@ -570,13 +570,13 @@
6665 -int mutt_rename_file (char *oldfile, char *newfile)
6666 +int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
6670 if (access (oldfile, F_OK) != 0)
6672 - if (access (newfile, F_OK) == 0)
6673 + if (!overwrite && access (newfile, F_OK) == 0)
6675 if ((ofp = fopen (oldfile,"r")) == NULL)
6678 mutt_unlink (oldfile);
6682 +int mutt_rename_file (char *oldfile, char *newfile)
6684 + return _mutt_rename_file (oldfile, newfile, 0);
6686 Index: mutt/rfc1524.h
6687 ===================================================================
6688 --- mutt.orig/rfc1524.h 2011-01-19 02:28:26.302183178 -0300
6689 +++ mutt/rfc1524.h 2011-01-19 02:29:05.199026064 -0300
6691 int rfc1524_expand_filename (char *, char *, char *, size_t);
6692 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
6693 int mutt_rename_file (char *, char *);
6694 +int _mutt_rename_file (char *, char *, int);
6696 #endif /* _RFC1524_H */
6698 ===================================================================
6699 --- mutt.orig/send.c 2011-01-19 02:29:04.781102968 -0300
6700 +++ mutt/send.c 2011-01-19 02:29:05.200025881 -0300
6702 #include <sys/types.h>
6711 #include "remailer.h"
6713 @@ -213,17 +218,51 @@
6717 -static int edit_envelope (ENVELOPE *en)
6718 +static int edit_envelope (ENVELOPE *en, int flags)
6720 char buf[HUGE_STRING];
6721 LIST *uh = UserHeader;
6723 - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6725 - if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6727 - if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6730 + if (option (OPTNEWSSEND))
6732 + if (en->newsgroups)
6733 + strfcpy (buf, en->newsgroups, sizeof (buf));
6736 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
6738 + FREE (&en->newsgroups);
6739 + en->newsgroups = safe_strdup (buf);
6741 + if (en->followup_to)
6742 + strfcpy (buf, en->followup_to, sizeof (buf));
6745 + if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
6747 + FREE (&en->followup_to);
6748 + en->followup_to = safe_strdup (buf);
6750 + if (en->x_comment_to)
6751 + strfcpy (buf, en->x_comment_to, sizeof (buf));
6754 + if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
6756 + FREE (&en->x_comment_to);
6757 + en->x_comment_to = safe_strdup (buf);
6762 + if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6764 + if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6766 + if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6772 @@ -259,6 +298,14 @@
6777 +char *nntp_get_header (const char *s)
6780 + return safe_strdup (s);
6784 static void process_user_recips (ENVELOPE *env)
6786 LIST *uh = UserHeader;
6787 @@ -271,6 +318,14 @@
6788 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
6789 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
6790 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
6792 + else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
6793 + env->newsgroups = nntp_get_header (uh->data + 11);
6794 + else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
6795 + env->followup_to = nntp_get_header (uh->data + 12);
6796 + else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
6797 + env->x_comment_to = nntp_get_header (uh->data + 13);
6802 @@ -309,6 +364,12 @@
6803 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
6804 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
6805 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
6807 + ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
6808 + ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
6809 + ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
6811 + ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
6812 ascii_strncasecmp ("subject:", uh->data, 8) != 0 &&
6813 ascii_strncasecmp ("return-path:", uh->data, 12) != 0)
6815 @@ -657,6 +718,10 @@
6820 + if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
6821 + env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
6826 @@ -719,6 +784,16 @@
6828 if (flags & SENDREPLY)
6831 + if ((flags & SENDNEWS))
6833 + /* in case followup set Newsgroups: with Followup-To: if it present */
6834 + if (!env->newsgroups && curenv &&
6835 + mutt_strcasecmp (curenv->followup_to, "poster"))
6836 + env->newsgroups = safe_strdup (curenv->followup_to);
6843 @@ -865,7 +940,18 @@
6844 * it hasn't already been set
6847 - if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
6848 + if (!option (OPTFOLLOWUPTO))
6851 + if (option (OPTNEWSSEND))
6853 + if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
6854 + e->followup_to = safe_strdup (e->newsgroups);
6859 + if (!e->mail_followup_to)
6861 if (mutt_is_list_cc (0, e->to, e->cc))
6863 @@ -1027,6 +1113,9 @@
6868 + if (!option (OPTNEWSSEND))
6869 +#endif /* USE_NNTP */
6871 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
6872 msg->env->bcc, tempfile,
6873 @@ -1138,6 +1227,13 @@
6878 + if (flags & SENDNEWS)
6879 + set_option (OPTNEWSSEND);
6881 + unset_option (OPTNEWSSEND);
6884 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
6885 mutt_num_postponed (1))
6887 @@ -1168,6 +1264,22 @@
6889 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
6893 + * If postponed message is a news article, it have
6894 + * a "Newsgroups:" header line, then set appropriate flag.
6896 + if (msg->env->newsgroups)
6898 + flags |= SENDNEWS;
6899 + set_option (OPTNEWSSEND);
6903 + flags &= ~SENDNEWS;
6904 + unset_option (OPTNEWSSEND);
6909 if (flags & (SENDPOSTPONED|SENDRESEND))
6910 @@ -1262,11 +1374,16 @@
6911 if (flags & SENDREPLY)
6912 mutt_fix_reply_recipients (msg->env);
6915 + if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
6916 + msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
6919 if (! (flags & (SENDMAILX|SENDBATCH)) &&
6920 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
6921 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
6923 - if (edit_envelope (msg->env) == -1)
6924 + if (edit_envelope (msg->env, flags) == -1)
6928 @@ -1534,6 +1651,11 @@
6933 + if (flags & SENDNEWS)
6934 + mutt_message _("Article not posted.");
6937 mutt_message _("Mail not sent.");
6940 @@ -1566,6 +1688,9 @@
6945 + if (!(flags & SENDNEWS))
6947 if (!has_recips (msg->env->to) && !has_recips (msg->env->cc) &&
6948 !has_recips (msg->env->bcc))
6950 @@ -1599,6 +1724,19 @@
6951 mutt_error _("No subject specified.");
6955 + if ((flags & SENDNEWS) && !msg->env->subject)
6957 + mutt_error _("No subject specified.");
6961 + if ((flags & SENDNEWS) && !msg->env->newsgroups)
6963 + mutt_error _("No newsgroup specified.");
6968 if (msg->content->next)
6969 msg->content = mutt_make_multipart (msg->content);
6970 @@ -1805,7 +1943,12 @@
6973 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
6974 - mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
6975 + mutt_message (i != 0 ? _("Sending in background.") :
6977 + (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
6982 if (WithCrypto && (msg->security & ENCRYPT))
6984 Index: mutt/sendlib.c
6985 ===================================================================
6986 --- mutt.orig/sendlib.c 2011-01-19 02:29:04.966068932 -0300
6987 +++ mutt/sendlib.c 2011-01-19 02:29:05.201025698 -0300
6989 #include <sys/wait.h>
6996 #ifdef HAVE_SYSEXITS_H
6997 #include <sysexits.h>
6998 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
6999 @@ -1543,6 +1547,14 @@
7002 int refcnt = 0, refmax = 0;
7003 + int multiline = 1;
7012 for ( ; (trim == 0 || refcnt < trim) && r ; r = r->next)
7014 @@ -1553,9 +1565,11 @@
7016 while (refcnt-- > 0)
7019 + if (multiline || space)
7022 fputs (ref[refcnt]->data, f);
7024 + if (multiline && refcnt >= 1)
7028 @@ -1962,6 +1976,9 @@
7029 mutt_write_address_list (env->to, fp, 4, 0);
7033 + if (!option (OPTNEWSSEND))
7035 fputs ("To: \n", fp);
7038 @@ -1970,6 +1987,9 @@
7039 mutt_write_address_list (env->cc, fp, 4, 0);
7043 + if (!option (OPTNEWSSEND))
7045 fputs ("Cc: \n", fp);
7047 if (env->bcc && should_write_bcc)
7048 @@ -1981,8 +2001,28 @@
7053 + if (!option (OPTNEWSSEND))
7055 fputs ("Bcc: \n", fp);
7058 + if (env->newsgroups)
7059 + fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
7060 + else if (mode == 1 && option (OPTNEWSSEND))
7061 + fputs ("Newsgroups: \n", fp);
7063 + if (env->followup_to)
7064 + fprintf (fp, "Followup-To: %s\n", env->followup_to);
7065 + else if (mode == 1 && option (OPTNEWSSEND))
7066 + fputs ("Followup-To: \n", fp);
7068 + if (env->x_comment_to)
7069 + fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
7070 + else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
7071 + fputs ("X-Comment-To: \n", fp);
7075 mutt_write_one_header (fp, "Subject", env->subject, NULL, 0, 0);
7077 @@ -2001,6 +2041,9 @@
7078 fputs ("Reply-To: \n", fp);
7080 if (env->mail_followup_to)
7082 + if (!option (OPTNEWSSEND))
7085 fputs ("Mail-Followup-To: ", fp);
7086 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
7087 @@ -2339,11 +2382,30 @@
7088 const char *msg, /* file containing message */
7089 int eightbit) /* message contains 8bit chars */
7091 - char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
7092 + char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
7094 size_t argslen = 0, argsmax = 0;
7098 + if (option (OPTNEWSSEND))
7100 + char cmd[LONG_STRING];
7102 + mutt_FormatString (cmd, sizeof (cmd), 0, NONULL (Inews), nntp_format_str, 0, 0);
7105 + i = nntp_post (msg);
7110 + s = safe_strdup (cmd);
7114 + s = safe_strdup (Sendmail);
7118 while ((ps = strtok (ps, " ")))
7119 @@ -2367,6 +2429,10 @@
7124 + if (!option (OPTNEWSSEND))
7127 if (eightbit && option (OPTUSE8BITMIME))
7128 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7130 @@ -2398,6 +2464,9 @@
7131 args = add_args (args, &argslen, &argsmax, to);
7132 args = add_args (args, &argslen, &argsmax, cc);
7133 args = add_args (args, &argslen, &argsmax, bcc);
7138 if (argslen == argsmax)
7139 safe_realloc (&args, sizeof (char *) * (++argsmax));
7140 @@ -2478,6 +2547,9 @@
7141 rfc2047_encode_string (&env->x_label);
7145 + if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
7148 rfc2047_encode_string (&env->subject);
7150 @@ -2598,6 +2670,10 @@
7152 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
7155 + unset_option (OPTNEWSSEND);
7158 ret = _mutt_bounce_message (fp, h, to, resent_from, from);
7160 rfc822_free_address (&from);
7162 ===================================================================
7163 --- mutt.orig/sort.c 2011-01-19 02:28:25.957246644 -0300
7164 +++ mutt/sort.c 2011-01-19 02:29:05.202025514 -0300
7165 @@ -151,6 +151,15 @@
7166 HEADER **ha = (HEADER **) a;
7167 HEADER **hb = (HEADER **) b;
7170 + if ((*ha)->article_num && (*hb)->article_num)
7172 + int result = (*ha)->article_num - (*hb)->article_num;
7173 + AUXSORT(result,a,b);
7174 + return (SORTCODE (result));
7178 /* no need to auxsort because you will never have equality here */
7179 return (SORTCODE ((*ha)->index - (*hb)->index));
7182 ===================================================================
7183 --- mutt.orig/url.c 2011-01-19 02:28:25.981242228 -0300
7184 +++ mutt/url.c 2011-01-19 02:29:05.203025330 -0300
7186 { "imaps", U_IMAPS },
7189 + { "news", U_NNTP },
7190 + { "newss", U_NNTPS },
7191 { "mailto", U_MAILTO },
7193 { "smtps", U_SMTPS },
7195 ===================================================================
7196 --- mutt.orig/url.h 2011-01-19 02:28:25.966244988 -0300
7197 +++ mutt/url.h 2011-01-19 02:29:05.203025330 -0300
7207 Index: mutt/Makefile.am
7208 ===================================================================
7209 --- mutt.orig/Makefile.am 2011-01-19 02:29:05.108042808 -0300
7210 +++ mutt/Makefile.am 2011-01-19 02:29:05.203025330 -0300
7212 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
7213 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
7214 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
7216 smime.c smtp.c utf8.c wcwidth.c \
7217 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
7220 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7221 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7222 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7223 + nntp.h ChangeLog.nntp \
7224 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7225 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
7226 README.SSL smime.h group.h \
7227 Index: mutt/doc/Muttrc
7228 ===================================================================
7229 --- mutt.orig/doc/Muttrc 2011-01-19 02:29:05.117041152 -0300
7230 +++ mutt/doc/Muttrc 2011-01-19 02:29:05.205024962 -0300
7231 @@ -281,6 +281,28 @@
7232 # of the value as shown above if included.
7235 +# set ask_follow_up=no
7237 +# Name: ask_follow_up
7242 +# If set, Mutt will prompt you for follow-up groups before editing
7243 +# the body of an outgoing message.
7246 +# set ask_x_comment_to=no
7248 +# Name: ask_x_comment_to
7253 +# If set, Mutt will prompt you for x-comment-to field before editing
7254 +# the body of an outgoing message.
7257 # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
7259 # Name: attach_format
7260 @@ -466,6 +488,17 @@
7261 # set certificate_file=~/.mutt/certificates
7264 +# set catchup_newsgroup=ask-yes
7266 +# Name: catchup_newsgroup
7271 +# If this variable is set, Mutt will mark all articles in newsgroup
7272 +# as read when you quit the newsgroup (catchup newsgroup).
7278 @@ -1122,6 +1155,19 @@
7279 # of the same email for you.
7282 +# set followup_to_poster=ask-yes
7284 +# Name: followup_to_poster
7289 +# If this variable is set and the keyword "poster" is present in
7290 +# Followup-To header, follow-up to newsgroup function is not
7291 +# permitted. The message will be mailed to the submitter of the
7292 +# message via mail.
7298 @@ -1232,6 +1278,28 @@
7299 # ``Franklin'' to ``Franklin, Steve''.
7302 +# set group_index_format="%4C %M%N %5s %-45.45f %d"
7304 +# Name: group_index_format
7306 +# Default: "%4C %M%N %5s %-45.45f %d"
7309 +# This variable allows you to customize the newsgroup browser display to
7310 +# your personal taste. This string is similar to ``index_format'', but
7311 +# has its own set of printf()-like sequences:
7313 +# %C current newsgroup number
7314 +# %d description of newsgroup (becomes from server)
7315 +# %f newsgroup name
7316 +# %M - if newsgroup not allowed for direct post (moderated for example)
7317 +# %N N if newsgroup is new, u if unsubscribed, blank otherwise
7318 +# %n number of new articles in newsgroup
7319 +# %s number of unread articles in newsgroup
7320 +# %>X right justify the rest of the string and pad with character "X"
7321 +# %|X pad to the end of the line with character "X"
7327 @@ -1780,6 +1848,7 @@
7328 # %E number of messages in current thread
7329 # %f sender (address + real name), either From: or Return-Path:
7330 # %F author name, or recipient name if the message is from you
7331 +# %g newsgroup name (if compiled with nntp support)
7332 # %H spam attribute(s) of this message
7333 # %i message-id of the current message
7334 # %l number of lines in the message (does not work with maildir,
7335 @@ -1795,12 +1864,14 @@
7336 # stashed the message: list name or recipient name
7337 # if not sent to a list
7338 # %P progress indicator for the built-in pager (how much of the file has been displayed)
7339 +# %R ``x-comment-to:'' field (if present and compiled with nntp support)
7340 # %s subject of the message
7341 # %S status of the message (``N''/``D''/``d''/``!''/``r''/*)
7342 # %t ``To:'' field (recipients)
7343 # %T the appropriate character from the $to_chars string
7344 # %u user (login) name of the author
7345 # %v first name of the author, or the recipient if the message is from you
7346 +# %W name of organization of author (``organization:'' field)
7347 # %X number of attachments
7348 # (please see the ``attachments'' section for possible speed effects)
7349 # %y ``X-Label:'' field, if present
7350 @@ -1836,6 +1907,22 @@
7351 # ``save-hook'', ``fcc-hook'' and ``fcc-save-hook'', too.
7361 +# If set, specifies the program and arguments used to deliver news posted
7362 +# by Mutt. Otherwise, mutt posts article using current connection to
7363 +# news server. The following printf-style sequence is understood:
7365 +# %s newsserver name
7367 +# Example: set inews="/usr/local/bin/inews -hS"
7370 # set ispell="ispell"
7373 @@ -2205,6 +2292,18 @@
7374 # be attached to the newly composed message if this option is set.
7377 +# set mime_subject=yes
7379 +# Name: mime_subject
7384 +# If unset, 8-bit ``subject:'' line in article header will not be
7385 +# encoded according to RFC2047 to base64. This is useful when message
7386 +# is Usenet article, because MIME for news is nonstandard feature.
7389 # set mix_entry_format="%4n %c %-16s %a"
7391 # Name: mix_entry_format
7392 @@ -2271,6 +2370,118 @@
7393 # See also $read_inc, $write_inc and $net_inc.
7396 +# set news_cache_dir="~/.mutt"
7398 +# Name: news_cache_dir
7400 +# Default: "~/.mutt"
7403 +# This variable pointing to directory where Mutt will save cached news
7404 +# articles headers in. If unset, headers will not be saved at all
7405 +# and will be reloaded each time when you enter to newsgroup.
7408 +# set news_server=""
7410 +# Name: news_server
7415 +# This variable specifies domain name or address of NNTP server. It
7416 +# defaults to the newsserver specified in the environment variable
7417 +# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
7418 +# specify username and an alternative port for each newsserver, ie:
7420 +# [news[s]://][username[:password]@]newsserver[:port]
7423 +# set newsrc="~/.newsrc"
7427 +# Default: "~/.newsrc"
7430 +# The file, containing info about subscribed newsgroups - names and
7431 +# indexes of read articles. The following printf-style sequence
7434 +# %s newsserver name
7437 +# set nntp_context=1000
7439 +# Name: nntp_context
7444 +# This variable defines number of articles which will be in index when
7445 +# newsgroup entered. If active newsgroup have more articles than this
7446 +# number, oldest articles will be ignored. Also controls how many
7447 +# articles headers will be saved in cache when you quit newsgroup.
7450 +# set nntp_load_description=yes
7452 +# Name: nntp_load_description
7457 +# This variable controls whether or not descriptions for each newsgroup
7458 +# must be loaded when newsgroup is added to list (first time list
7459 +# loading or new newsgroup adding).
7469 +# Your login name on the NNTP server. If unset and NNTP server requires
7470 +# authentification, Mutt will prompt you for your account name when you
7471 +# connect to newsserver.
7481 +# Your password for NNTP account.
7491 +# The time in seconds until any operations on newsgroup except post new
7492 +# article will cause recheck for new news. If set to 0, Mutt will
7493 +# recheck newsgroup on each operation in index (stepping, read article,
7497 +# set nntp_reconnect=ask-yes
7499 +# Name: nntp_reconnect
7504 +# Controls whether or not Mutt will try to reconnect to newsserver when
7508 # set pager="builtin"
7511 @@ -2986,6 +3197,19 @@
7512 # string after the inclusion of a message which is being replied to.
7515 +# set post_moderated=ask-yes
7517 +# Name: post_moderated
7522 +# If set to yes, Mutt will post article to newsgroup that have
7523 +# not permissions to posting (e.g. moderated). Note: if newsserver
7524 +# does not support posting to that newsgroup or totally read-only, that
7525 +# posting will not have an effect.
7528 # set postpone=ask-yes
7531 @@ -3563,6 +3787,41 @@
7532 # shell from /etc/passwd is used.
7535 +# set save_unsubscribed=no
7537 +# Name: save_unsubscribed
7542 +# When set, info about unsubscribed newsgroups will be saved into
7543 +# ``newsrc'' file and into cache.
7546 +# set show_new_news=yes
7548 +# Name: show_new_news
7553 +# If set, newsserver will be asked for new newsgroups on entering
7554 +# the browser. Otherwise, it will be done only once for a newsserver.
7555 +# Also controls whether or not number of new articles of subscribed
7556 +# newsgroups will be then checked.
7559 +# set show_only_unread=no
7561 +# Name: show_only_unread
7566 +# If set, only subscribed newsgroups that contain unread articles
7567 +# will be displayed in browser.
7570 # set sig_dashes=yes
7573 @@ -4785,3 +5044,14 @@
7574 # ``tuning'' section of the manual for performance considerations.
7577 +# set x_comment_to=no
7579 +# Name: x_comment_to
7584 +# If set, Mutt will add ``X-Comment-To:'' field (that contains full
7585 +# name of original article author) to article that followuped to newsgroup.
7588 Index: mutt/headers.c
7589 ===================================================================
7590 --- mutt.orig/headers.c 2011-01-19 02:29:04.912078868 -0300
7591 +++ mutt/headers.c 2011-01-19 02:29:05.206024778 -0300
7593 $edit_headers set, we remove References: as they're likely invalid;
7594 we can simply compare strings as we don't generate References for
7595 multiple Message-Ids in IRT anyways */
7597 + if (!option (OPTNEWSSEND))
7599 if (msg->env->in_reply_to &&
7600 (!n->in_reply_to || mutt_strcmp (n->in_reply_to->data,
7601 msg->env->in_reply_to->data) != 0))