1 WARNING: Run the following script before configure:
9 Vsevolod Volkov <vvv@mutt.org.ua>
12 diff -udprP mutt-1.5.15.orig/ChangeLog.nntp mutt-1.5.15/ChangeLog.nntp
13 --- mutt-1.5.15.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14 +++ mutt-1.5.15/ChangeLog.nntp 2007-04-11 17:33:57.000000000 +0300
16 +* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
17 +- fixed posting error if $smtp_url is set
18 +- added support of print-style sequence %R (x-comment-to)
20 +* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
22 +- nntp://... url changed to news://...
23 +- added indicator of fetching descriptions progress
25 +* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
28 +* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
31 +* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
33 +- fixed reading empty .newsrc
35 +* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
38 +* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
41 +* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
44 +* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
47 +* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
49 +- function mutt_update_list_file() moved to newsrc.c and changed algorithm
51 +* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
52 +- fixed error in nntp_logout_all()
54 +* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
55 +- fixed debug output in mutt_newsrc_update()
56 +- added optional support of LISTGROUP command
57 +- fixed typo in nntp_parse_xref()
59 +* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
62 +* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
65 +* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
68 +* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
70 +- added space after newsgroup name in .newsrc file
72 +* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
73 +- nntp patch: fixed SIGSEGV when posting article
75 +* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
78 +* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
80 +- replace safe_free calls by the FREE macro
82 +* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
84 +- nntp authentication can be passed after any command
86 +* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
89 +* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
92 +* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
94 +- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
95 + <reconstruct-thread> functions
96 +- fixed message about nntp reconnect
97 +- fixed <attach-news-message> function using browser
98 +- added support of Followup-To: poster
99 +- added %n (new articles) in group_index_format
100 +- posting articles without inews by default
102 +* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
105 +* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
108 +* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
110 +- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
111 +- added default content disposition
113 +* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
116 +* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
117 +- update to 1.3.23.2
118 +- fixed segfault if mutt_conn_find() returns null
120 +* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
121 +- update to 1.3.23.1
122 +- added support of LISTGROUP command
123 +- added support for servers with broken overview
124 +- disabled <flag-message> function on news server
125 +- fixed error storing bad authentication information
127 +* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
129 +- fixed typo in buffy.c
130 +- added substitution of %s parameter in $inews variable
132 +* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
133 +- update to 1.3.22.1
136 +* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
139 +* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
141 +- removed 'server-hook', use 'account-hook' instead
142 +- fixed error opening NNTP server without newsgroup using -f option
144 +* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
147 +* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
149 +- fixed typo in nntp_attempt_features()
150 +- changed algorithm of XGTITLE command testing
151 +- disabled writing of NNTP password in debug file
152 +- fixed reading and writing of long newsrc lines
153 +- changed checking of last line while reading lines from server
154 +- fixed possible buffer overrun in nntp_parse_newsrc_line()
155 +- removed checking of XHDR command
156 +- compare NNTP return codes without trailing space
158 +* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
160 +- support for 'LIST NEWSGROUPS' command to read descriptions
162 +* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
165 +* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
168 +* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
170 +- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
172 +* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
175 +* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
176 +- Fixed problem if last article in group is deleted
178 +* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
179 +- Fixed checking of XGTITLE command on some servers
181 +* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
182 +- Added \r in AUTHINFO commands
184 +* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
187 +* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
189 +- fixed error opening newsgroup from mutt started with -g or -G
191 +* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
193 +- hotkey 'G' (get-message) replaced with '^G'
195 +* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
197 +- changed delay displaying error messages from 1 to 2 seconds
198 +- fixed error compiling with nntp and without imap
200 +* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
201 +- fixed catchup in index
202 +- fixed nntp_open_mailbox()
204 +* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
205 +- functions <edit> and <delete-entry> disabled
206 +- format of news mailbox names changed to url form
207 +- option nntp_attempts removed
208 +- option reconnect_news renamed to nntp_reconnect
209 +- default value of nntp_poll changed from 30 to 60
210 +- error handling improved
212 +* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
214 +- new option show_only_unread
215 +- add newsgroup completion
217 +* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
220 +* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
223 +* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
225 +- authentication code update
226 +- fix for changing to newsgroup from mailbox with read messages
227 +- socket code optimization
229 +* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
232 +* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
233 +- don't substitute current newsgroup with deleted new messages
235 +* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
237 +- fix for substitution of newsgroup after reconnection
238 +- fix for loading newsgroups with very long names
239 +- fix for loading more than 32768 newsgroups
241 +* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
244 +* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
247 +* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
250 +* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
253 +* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
256 +* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
259 +* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
260 +- add substitution of newsgroup with new messages by default
262 +* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
263 +- add attach message from newsgroup
264 +- add one-line help in newsreader mode
265 +- disable 'change-dir' command in newsgroups browser
268 +* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
269 +- get default newsserver name from file /etc/nntpserver
270 +- use case insensitive server names
271 +- add print-style sequence %s to $newsrc
274 +* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
275 +- remove 'X-FTN-Origin' header processing
277 +* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
281 +* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
282 +- fix mutt_select_newsserver()
283 +- remove 'toggle-mode' function
284 +- add 'change-newsgroup' function
286 +* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
289 +* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
290 +- fix error 'bounce' function after 'post'
291 +- add 'forward to newsgroup' function
293 +* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
294 +- 'forward' function works in newsreader mode
295 +- add 'post' and 'followup' functions to pager and attachment menu
296 +- fix active descriptions and allowed flag reload
298 +* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
300 +- remove deleted newsgroups from list
302 +* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
303 +- update .newsrc in browser
305 +* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
306 +- reload .newsrc if externally modified
307 +- fix active cache update
309 +* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
312 +* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
313 +- patch *.update_list_file is not required
314 +- count lines when loading descriptions
315 +- remove cache of unsubscribed newsgroups
317 +* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
318 +- load list of newsgroups from cache faster
320 +* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
323 +* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
324 +- fix unread messages in browser
325 +- fix newsrc_gen_entries()
327 +* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
328 +- fix mutt_newsgroup_stat()
329 +- fix nntp_delete_cache()
330 +- fix nntp_get_status()
331 +- fix check_children()
332 +- fix nntp_fetch_headers()
334 +* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
337 +* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
338 +- fix updating new messages in cache
340 +* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
341 +- change default cache filenames
342 +- fix updating new messages in cache
344 +* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
345 +- fix segmentation fault in news groups browser
347 +* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
350 +* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
353 +* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
354 +- add X-Comment-To editing
355 +- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
356 +- add variables $ask_followup_to and $ask_x_comment_to
358 +* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
360 diff -udprP mutt-1.5.15.orig/OPS mutt-1.5.15/OPS
361 --- mutt-1.5.15.orig/OPS 2007-04-02 00:58:55.000000000 +0300
362 +++ mutt-1.5.15/OPS 2007-04-11 17:25:15.000000000 +0300
363 @@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
364 OP_BROWSER_NEW_FILE "select a new file in this directory"
365 OP_BROWSER_VIEW_FILE "view file"
366 OP_BROWSER_TELL "display the currently selected file's name"
367 -OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
368 -OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
369 +OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
370 +OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
371 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
372 OP_BUFFY_LIST "list mailboxes with new mail"
373 +OP_CATCHUP "mark all articles in newsgroup as read"
374 OP_CHANGE_DIRECTORY "change directories"
375 OP_CHECK_NEW "check mailboxes for new mail"
376 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
377 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
378 +OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message"
379 OP_COMPOSE_EDIT_BCC "edit the BCC list"
380 OP_COMPOSE_EDIT_CC "edit the CC list"
381 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
382 @@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
383 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
384 OP_COMPOSE_EDIT_MESSAGE "edit the message"
385 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
386 +OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
387 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
388 +OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
389 +OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
390 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
391 OP_COMPOSE_EDIT_TO "edit the TO list"
392 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
393 @@ -85,8 +90,13 @@ OP_EXIT "exit this menu"
394 OP_FILTER "filter attachment through a shell command"
395 OP_FIRST_ENTRY "move to the first entry"
396 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
397 +OP_FOLLOWUP "followup to newsgroup"
398 +OP_FORWARD_TO_GROUP "forward to newsgroup"
399 OP_FORWARD_MESSAGE "forward a message with comments"
400 OP_GENERIC_SELECT_ENTRY "select the current entry"
401 +OP_GET_CHILDREN "get all children of the current message"
402 +OP_GET_MESSAGE "get message with Message-Id"
403 +OP_GET_PARENT "get parent of the current message"
404 OP_GROUP_REPLY "reply to all recipients"
405 OP_HALF_DOWN "scroll down 1/2 page"
406 OP_HALF_UP "scroll up 1/2 page"
407 @@ -94,11 +104,14 @@ OP_HELP "this screen"
408 OP_JUMP "jump to an index number"
409 OP_LAST_ENTRY "move to the last entry"
410 OP_LIST_REPLY "reply to specified mailing list"
411 +OP_LOAD_ACTIVE "load active file from NNTP server"
412 OP_MACRO "execute a macro"
413 OP_MAIL "compose a new mail message"
414 OP_MAIN_BREAK_THREAD "break the thread in two"
415 OP_MAIN_CHANGE_FOLDER "open a different folder"
416 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
417 +OP_MAIN_CHANGE_GROUP "open a different newsgroup"
418 +OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
419 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
420 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
421 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
422 @@ -136,6 +149,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
423 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
424 OP_PAGER_TOP "jump to the top of the message"
425 OP_PIPE "pipe message/attachment to a shell command"
426 +OP_POST "post message to newsgroup"
427 OP_PREV_ENTRY "move to the previous entry"
428 OP_PREV_LINE "scroll up one line"
429 OP_PREV_PAGE "move to the previous page"
430 @@ -144,6 +158,7 @@ OP_QUERY "query external program for add
431 OP_QUERY_APPEND "append new query results to current results"
432 OP_QUIT "save changes to mailbox and quit"
433 OP_RECALL_MESSAGE "recall a postponed message"
434 +OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
435 OP_REDRAW "clear and redraw the screen"
436 OP_REFORMAT_WINCH "{internal}"
437 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
438 @@ -158,18 +173,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
439 OP_SHELL_ESCAPE "invoke a command in a subshell"
440 OP_SORT "sort messages"
441 OP_SORT_REVERSE "sort messages in reverse order"
442 +OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
443 OP_TAG "tag the current entry"
444 OP_TAG_PREFIX "apply next function to tagged messages"
445 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
446 OP_TAG_SUBTHREAD "tag the current subthread"
447 OP_TAG_THREAD "tag the current thread"
448 OP_TOGGLE_NEW "toggle a message's 'new' flag"
449 +OP_TOGGLE_READ "toggle view of read messages"
450 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
451 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
452 OP_TOP_PAGE "move to the top of the page"
453 +OP_UNCATCHUP "mark all articles in newsgroup as unread"
454 OP_UNDELETE "undelete the current entry"
455 OP_UNDELETE_THREAD "undelete all messages in thread"
456 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
457 +OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
458 OP_VERSION "show the Mutt version number and date"
459 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
460 OP_VIEW_ATTACHMENTS "show MIME attachments"
461 diff -udprP mutt-1.5.15.orig/PATCHES mutt-1.5.15/PATCHES
462 --- mutt-1.5.15.orig/PATCHES 2007-03-15 17:49:37.000000000 +0200
463 +++ mutt-1.5.15/PATCHES 2007-04-11 17:25:15.000000000 +0300
466 diff -udprP mutt-1.5.15.orig/account.c mutt-1.5.15/account.c
467 --- mutt-1.5.15.orig/account.c 2007-04-02 00:58:55.000000000 +0300
468 +++ mutt-1.5.15/account.c 2007-04-11 17:25:15.000000000 +0300
469 @@ -54,6 +54,11 @@ int mutt_account_match (const ACCOUNT* a
474 + if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
478 if (a1->flags & a2->flags & M_ACCT_USER)
479 return (!strcmp (a1->user, a2->user));
480 if (a1->flags & M_ACCT_USER)
481 @@ -133,6 +138,16 @@ void mutt_account_tourl (ACCOUNT* accoun
486 + if (account->type == M_ACCT_TYPE_NNTP)
488 + if (account->flags & M_ACCT_SSL)
489 + url->scheme = U_NNTPS;
491 + url->scheme = U_NNTP;
495 url->host = account->host;
496 if (account->flags & M_ACCT_PORT)
497 url->port = account->port;
498 @@ -158,6 +173,10 @@ int mutt_account_getuser (ACCOUNT* accou
499 else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
500 strfcpy (account->user, PopUser, sizeof (account->user));
503 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
504 + strfcpy (account->user, NntpUser, sizeof (account->user));
506 /* prompt (defaults to unix username), copy into account->user */
509 @@ -214,6 +233,10 @@ int mutt_account_getpass (ACCOUNT* accou
510 else if ((account->type == M_ACCT_TYPE_POP) && PopPass)
511 strfcpy (account->pass, PopPass, sizeof (account->pass));
514 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
515 + strfcpy (account->pass, NntpPass, sizeof (account->pass));
519 snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
520 diff -udprP mutt-1.5.15.orig/account.h mutt-1.5.15/account.h
521 --- mutt-1.5.15.orig/account.h 2007-04-02 00:58:55.000000000 +0300
522 +++ mutt-1.5.15/account.h 2007-04-11 17:25:15.000000000 +0300
523 @@ -29,7 +29,8 @@ enum
524 M_ACCT_TYPE_NONE = 0,
533 diff -udprP mutt-1.5.15.orig/attach.h mutt-1.5.15/attach.h
534 --- mutt-1.5.15.orig/attach.h 2007-04-02 00:58:55.000000000 +0300
535 +++ mutt-1.5.15/attach.h 2007-04-11 17:25:15.000000000 +0300
536 @@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f
538 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
539 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
540 -void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
541 +void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
542 void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
544 #endif /* _ATTACH_H_ */
545 diff -udprP mutt-1.5.15.orig/browser.c mutt-1.5.15/browser.c
546 --- mutt-1.5.15.orig/browser.c 2007-04-03 07:57:21.000000000 +0300
547 +++ mutt-1.5.15/browser.c 2007-04-11 17:25:15.000000000 +0300
558 @@ -49,6 +52,19 @@ static struct mapping_t FolderHelp[] = {
563 +static struct mapping_t FolderNewsHelp[] = {
564 + { N_("Exit"), OP_EXIT },
565 + { N_("List"), OP_TOGGLE_MAILBOXES },
566 + { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
567 + { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
568 + { N_("Catchup"), OP_CATCHUP },
569 + { N_("Mask"), OP_ENTER_MASK },
570 + { N_("Help"), OP_HELP },
575 typedef struct folder_t
577 struct folder_file *ff;
578 @@ -114,9 +130,17 @@ static void browser_sort (struct browser
583 + if (option (OPTNEWS))
586 f = browser_compare_date;
590 + if (option (OPTNEWS))
593 f = browser_compare_size;
596 @@ -306,8 +330,106 @@ folder_format_str (char *dest, size_t de
602 +newsgroup_format_str (char *dest, size_t destlen, char op, const char *src,
603 + const char *fmt, const char *ifstring, const char *elsestring,
604 + unsigned long data, format_flag flags)
606 + char fn[SHORT_STRING], tmp[SHORT_STRING];
607 + FOLDER *folder = (FOLDER *) data;
612 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
613 + snprintf (dest, destlen, tmp, folder->num + 1);
617 + strncpy (fn, folder->ff->name, sizeof(fn) - 1);
618 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
619 + snprintf (dest, destlen, tmp, fn);
623 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
624 + if (folder->ff->nd->subscribed)
625 + snprintf (dest, destlen, tmp, ' ');
627 + snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
631 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
632 + if (folder->ff->nd->deleted)
633 + snprintf (dest, destlen, tmp, 'D');
635 + snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
639 + if (flags & M_FORMAT_OPTIONAL)
641 + if (folder->ff->nd->unread != 0)
642 + mutt_FormatString (dest, destlen, ifstring, newsgroup_format_str,
645 + mutt_FormatString (dest, destlen, elsestring, newsgroup_format_str,
648 + else if (Context && Context->data == folder->ff->nd)
650 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
651 + snprintf (dest, destlen, tmp, Context->unread);
655 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
656 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
661 + if (Context && Context->data == folder->ff->nd)
663 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
664 + snprintf (dest, destlen, tmp, Context->new);
666 + else if (option (OPTMARKOLD) &&
667 + folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
668 + folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
670 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
671 + snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
675 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
676 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
681 + if (folder->ff->nd->desc != NULL)
683 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
684 + snprintf (dest, destlen, tmp, folder->ff->nd->desc);
688 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
689 + snprintf (dest, destlen, tmp, "");
695 +#endif /* USE_NNTP */
697 static void add_folder (MUTTMENU *m, struct browser_state *state,
698 - const char *name, const struct stat *s, int new)
699 + const char *name, const struct stat *s,
700 + void *data, int new)
702 if (state->entrylen == state->entrymax)
704 @@ -336,6 +458,10 @@ static void add_folder (MUTTMENU *m, str
706 (state->entry)[state->entrylen].imap = 0;
709 + if (option (OPTNEWS))
710 + (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
715 @@ -351,9 +477,35 @@ static void init_state (struct browser_s
716 menu->data = state->entry;
719 +/* get list of all files/newsgroups with mask */
720 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
721 char *d, const char *prefix)
724 + if (option (OPTNEWS))
728 + NNTP_SERVER *news = CurrentNewsSrv;
730 +/* mutt_buffy_check (0); */
731 + init_state (state, menu);
733 + for (tmp = news->list; tmp; tmp = tmp->next)
735 + if (!(data = (NNTP_DATA *)tmp->data))
737 + if (prefix && *prefix && strncmp (prefix, data->group,
738 + strlen (prefix)) != 0)
740 + if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
742 + add_folder (menu, state, data->group, NULL, data, data->new);
746 +#endif /* USE_NNTP */
751 @@ -414,17 +566,40 @@ static int examine_directory (MUTTMENU *
753 while (tmp && mutt_strcmp (buffer, tmp->path))
755 - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
756 + add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
761 browser_sort (state);
765 +/* get list of mailboxes/subscribed newsgroups */
766 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
769 char buffer[LONG_STRING];
772 + if (option (OPTNEWS))
776 + NNTP_SERVER *news = CurrentNewsSrv;
778 +/* mutt_buffy_check (0); */
779 + init_state (state, menu);
781 + for (tmp = news->list; tmp; tmp = tmp->next)
783 + if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
784 + (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
785 + add_folder (menu, state, data->group, NULL, data, data->new);
791 BUFFY *tmp = Incoming;
793 struct mailbox_state mbox;
794 @@ -442,14 +617,21 @@ static int examine_mailboxes (MUTTMENU *
795 if (mx_is_imap (tmp->path))
797 imap_mailbox_state (tmp->path, &mbox);
798 - add_folder (menu, state, tmp->path, NULL, mbox.new);
799 + add_folder (menu, state, tmp->path, NULL, NULL, mbox.new);
804 if (mx_is_pop (tmp->path))
806 - add_folder (menu, state, tmp->path, NULL, tmp->new);
807 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
812 + if (mx_is_nntp (tmp->path))
814 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
818 @@ -463,15 +645,20 @@ static int examine_mailboxes (MUTTMENU *
819 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
820 mutt_pretty_mailbox (buffer);
822 - add_folder (menu, state, buffer, &s, tmp->new);
823 + add_folder (menu, state, buffer, &s, NULL, tmp->new);
825 while ((tmp = tmp->next));
827 browser_sort (state);
831 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
834 + if (option (OPTNEWS))
835 + return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
837 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
840 @@ -482,7 +669,13 @@ static void folder_entry (char *s, size_
841 folder.ff = &((struct folder_file *) menu->data)[num];
844 - mutt_FormatString (s, slen, NONULL(FolderFormat), folder_format_str,
846 + if (option (OPTNEWS))
847 + mutt_FormatString (s, slen, NONULL(GroupFormat), newsgroup_format_str,
848 + (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
851 + mutt_FormatString (s, slen, NONULL(FolderFormat), folder_format_str,
852 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
855 @@ -502,6 +695,17 @@ static void init_menu (struct browser_st
860 + if (option (OPTNEWS))
863 + snprintf (title, titlelen, _("Subscribed newsgroups"));
865 + snprintf (title, titlelen, _("Newsgroups on server [%s]"),
866 + CurrentNewsSrv->conn->account.host);
871 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
873 @@ -557,6 +761,31 @@ void _mutt_select_file (char *f, size_t
875 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
878 + if (option (OPTNEWS))
881 + strfcpy (prefix, f, sizeof (prefix));
886 + /* default state for news reader mode is browse subscribed newsgroups */
888 + for (list = CurrentNewsSrv->list; list; list = list->next)
890 + NNTP_DATA *data = (NNTP_DATA *) list->data;
892 + if (data && data->subscribed)
904 mutt_expand_path (f, flen);
905 @@ -646,6 +875,9 @@ void _mutt_select_file (char *f, size_t
906 menu->tag = file_tag;
908 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
910 + (option (OPTNEWS)) ? FolderNewsHelp :
914 init_menu (&state, menu, title, sizeof (title), buffy);
915 @@ -784,7 +1016,11 @@ void _mutt_select_file (char *f, size_t
920 + if (buffy || option (OPTNEWS)) /* news have not path */
925 strfcpy (f, state.entry[menu->current].name, flen);
926 mutt_expand_path (f, flen);
927 @@ -842,14 +1078,6 @@ void _mutt_select_file (char *f, size_t
931 - case OP_BROWSER_SUBSCRIBE:
932 - imap_subscribe (state.entry[menu->current].name, 1);
935 - case OP_BROWSER_UNSUBSCRIBE:
936 - imap_subscribe (state.entry[menu->current].name, 0);
939 case OP_BROWSER_TOGGLE_LSUB:
940 if (option (OPTIMAPLSUB))
942 @@ -948,6 +1176,11 @@ void _mutt_select_file (char *f, size_t
944 case OP_CHANGE_DIRECTORY:
947 + if (option (OPTNEWS))
951 strfcpy (buf, LastDir, sizeof (buf));
953 if (!state.imap_browse)
954 @@ -1204,6 +1437,190 @@ void _mutt_select_file (char *f, size_t
956 mutt_error _("Error trying to view file");
963 + if (option (OPTNEWS))
965 + struct folder_file *f = &state.entry[menu->current];
968 + if (i == OP_CATCHUP)
969 + nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
971 + nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
976 + struct folder_file ff;
977 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
980 + folder.ff->name = f->name;
981 + folder.ff->st = NULL;
982 + folder.ff->is_new = nd->new;
983 + folder.ff->nd = nd;
985 + mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
986 + newsgroup_format_str, (unsigned long) &folder,
987 + M_FORMAT_ARROWCURSOR);
988 + f->desc = safe_strdup (buffer); */
989 + if (menu->current + 1 < menu->max)
991 + menu->redraw = REDRAW_MOTION_RESYNCH;
996 + case OP_LOAD_ACTIVE:
997 + if (!option (OPTNEWS))
1004 + for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
1006 + if ((data = (NNTP_DATA *)tmp->data))
1007 + data->deleted = 1;
1010 + nntp_get_active (CurrentNewsSrv);
1012 + destroy_state (&state);
1014 + examine_mailboxes (menu, &state);
1016 + examine_directory (menu, &state, NULL, NULL);
1017 + init_menu (&state, menu, title, sizeof (title), buffy);
1019 +#endif /* USE_NNTP */
1021 +#if defined USE_IMAP || defined USE_NNTP
1022 + case OP_BROWSER_SUBSCRIBE:
1023 + case OP_BROWSER_UNSUBSCRIBE:
1026 + case OP_SUBSCRIBE_PATTERN:
1027 + case OP_UNSUBSCRIBE_PATTERN:
1028 + if (option (OPTNEWS))
1030 + regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1032 + int j = menu->current;
1034 + NNTP_SERVER *news = CurrentNewsSrv;
1036 + if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1042 + if (i == OP_SUBSCRIBE_PATTERN)
1043 + snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1045 + snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1046 + if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1052 + if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1054 + regerror (err, rx, buf, sizeof (buf));
1057 + mutt_error ("%s", buf);
1060 + menu->redraw = REDRAW_FULL;
1063 + else if (!state.entrylen)
1065 + mutt_error _("No newsgroups match the mask");
1069 + for ( ; j < state.entrylen; j++)
1071 + struct folder_file *f = &state.entry[j];
1073 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1074 + regexec (rx, f->name, 0, NULL, 0) == 0)
1076 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1077 + nd = mutt_newsgroup_subscribe (news, f->name);
1079 + nd = mutt_newsgroup_unsubscribe (news, f->name);
1083 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1085 + folder.name = f->name;
1087 + folder.new = nd->new;
1090 + mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
1091 + newsgroup_format_str, (unsigned long) &folder,
1092 + M_FORMAT_ARROWCURSOR);
1093 + f->desc = safe_strdup (buffer);
1096 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1098 + if (menu->current + 1 < menu->max)
1100 + menu->redraw = REDRAW_MOTION_RESYNCH;
1104 + if (i == OP_SUBSCRIBE_PATTERN)
1106 + LIST *grouplist = NULL;
1109 + grouplist = news->list;
1110 + for (; grouplist; grouplist = grouplist->next)
1112 + nd = (NNTP_DATA *) grouplist->data;
1113 + if (nd && nd->group && !nd->subscribed)
1115 + if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1117 + mutt_newsgroup_subscribe (news, nd->group);
1118 + add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1122 + init_menu (&state, menu, title, sizeof (title), buffy);
1124 + mutt_newsrc_update (news);
1125 + nntp_clear_cacheindex (news);
1126 + if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1132 +#endif /* USE_IMAP && USE_NNTP */
1133 +#endif /* USE_NNTP */
1136 + if (i == OP_BROWSER_SUBSCRIBE)
1137 + imap_subscribe (state.entry[menu->current].name, 1);
1139 + imap_subscribe (state.entry[menu->current].name, 0);
1141 +#endif /* USE_IMAP */
1145 diff -udprP mutt-1.5.15.orig/browser.h mutt-1.5.15/browser.h
1146 --- mutt-1.5.15.orig/browser.h 2007-04-03 07:57:21.000000000 +0300
1147 +++ mutt-1.5.15/browser.h 2007-04-11 17:25:15.000000000 +0300
1150 #define _BROWSER_H 1
1159 @@ -38,14 +42,17 @@ struct folder_file
1160 unsigned selectable : 1;
1161 unsigned inferiors : 1;
1166 unsigned tagged : 1;
1169 struct browser_state
1171 struct folder_file *entry;
1172 - short entrylen; /* number of real entries */
1173 - short entrymax; /* max entry */
1174 + unsigned int entrylen; /* number of real entries */
1175 + unsigned int entrymax; /* max entry */
1179 diff -udprP mutt-1.5.15.orig/buffy.c mutt-1.5.15/buffy.c
1180 --- mutt-1.5.15.orig/buffy.c 2007-04-02 00:58:55.000000000 +0300
1181 +++ mutt-1.5.15/buffy.c 2007-04-11 17:25:15.000000000 +0300
1182 @@ -285,6 +285,9 @@ int mutt_buffy_check (int force)
1184 if (!Context || Context->magic != M_POP)
1187 + if (!Context || Context->magic != M_NNTP)
1189 /* check device ID and serial number instead of comparing paths */
1190 if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0)
1192 @@ -308,6 +311,11 @@ int mutt_buffy_check (int force)
1197 + if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1198 + tmp->magic = M_NNTP;
1201 if (stat (tmp->path, &sb) != 0 || sb.st_size == 0 ||
1202 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1204 @@ -325,25 +333,21 @@ int mutt_buffy_check (int force)
1205 /* check to see if the folder is the currently selected folder
1207 if (!Context || !Context->path ||
1208 -#if defined USE_IMAP || defined USE_POP
1213 - tmp->magic == M_IMAP
1214 + || tmp->magic == M_IMAP
1220 - tmp->magic == M_POP
1222 - ) ? mutt_strcmp (tmp->path, Context->path) :
1223 + || tmp->magic == M_POP
1225 - (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1226 -#if defined USE_IMAP || defined USE_POP
1229 + || tmp->magic == M_NNTP
1233 + ) ? mutt_strcmp (tmp->path, Context->path) :
1234 + (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1240 diff -udprP mutt-1.5.15.orig/complete.c mutt-1.5.15/complete.c
1241 --- mutt-1.5.15.orig/complete.c 2007-04-02 00:58:55.000000000 +0300
1242 +++ mutt-1.5.15/complete.c 2007-04-11 17:25:15.000000000 +0300
1244 #include "mailbox.h"
1253 @@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen)
1254 char filepart[_POSIX_PATH_MAX];
1256 char imap_path[LONG_STRING];
1259 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1262 + if (option (OPTNEWS))
1264 + LIST *l = CurrentNewsSrv->list;
1266 + strfcpy (filepart, s, sizeof (filepart));
1269 + * special case to handle when there is no filepart yet.
1270 + * find the first subscribed newsgroup
1272 + if ((len = mutt_strlen (filepart)) == 0)
1274 + for (; l; l = l->next)
1276 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1278 + if (data && data->subscribed)
1280 + strfcpy (filepart, data->group, sizeof (filepart));
1288 + for (; l; l = l->next)
1290 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1292 + if (data && data->subscribed &&
1293 + mutt_strncmp (data->group, filepart, len) == 0)
1297 + for (i = 0; filepart[i] && data->group[i]; i++)
1299 + if (filepart[i] != data->group[i])
1309 + strfcpy (filepart, data->group, sizeof (filepart));
1315 + strcpy (s, filepart);
1317 + return (init ? 0 : -1);
1322 /* we can use '/' as a delimiter, imap_complete rewrites it */
1323 if (*s == '=' || *s == '+' || *s == '!')
1325 diff -udprP mutt-1.5.15.orig/compose.c mutt-1.5.15/compose.c
1326 --- mutt-1.5.15.orig/compose.c 2007-04-02 00:58:55.000000000 +0300
1327 +++ mutt-1.5.15/compose.c 2007-04-11 17:25:15.000000000 +0300
1329 #include "mailbox.h"
1331 #include "charset.h"
1335 #include "remailer.h"
1344 @@ -67,11 +72,17 @@ enum
1354 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1357 -#define HDR_XOFFSET 10
1358 -#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1359 +#define HDR_XOFFSET 14
1360 +#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1361 #define W (COLS - HDR_XOFFSET)
1363 static char *Prompts[] =
1364 @@ -83,6 +91,16 @@ static char *Prompts[] =
1380 static struct mapping_t ComposeHelp[] = {
1381 @@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] =
1386 +static struct mapping_t ComposeNewsHelp[] = {
1387 + { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1388 + { N_("Abort"), OP_EXIT },
1389 + { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1390 + { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1391 + { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1392 + { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1393 + { N_("Help"), OP_HELP },
1398 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1400 mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
1401 @@ -115,16 +146,16 @@ static void redraw_crypt_lines (HEADER *
1402 if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
1405 - mvaddstr (HDR_CRYPT, 0, "Security: ");
1406 + mvaddstr (HDR_CRYPT, 0, " Security: ");
1407 else if (msg->security & APPLICATION_SMIME)
1408 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1409 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1410 else if (msg->security & APPLICATION_PGP)
1411 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1412 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1414 else if ((WithCrypto & APPLICATION_SMIME))
1415 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1416 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1417 else if ((WithCrypto & APPLICATION_PGP))
1418 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1419 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1423 @@ -252,9 +283,28 @@ static void draw_envelope_addr (int line
1424 static void draw_envelope (HEADER *msg, char *fcc)
1426 draw_envelope_addr (HDR_FROM, msg->env->from);
1428 + if (!option (OPTNEWSSEND))
1431 draw_envelope_addr (HDR_TO, msg->env->to);
1432 draw_envelope_addr (HDR_CC, msg->env->cc);
1433 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1438 + mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1439 + mutt_paddstr (W, NONULL (msg->env->newsgroups));
1440 + mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1441 + mutt_paddstr (W, NONULL (msg->env->followup_to));
1442 + if (option (OPTXCOMMENTTO))
1444 + mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1445 + mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1449 mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1450 mutt_paddstr (W, NONULL (msg->env->subject));
1451 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1452 @@ -507,6 +557,12 @@ int mutt_compose_menu (HEADER *msg, /*
1453 /* Sort, SortAux could be changed in mutt_index_menu() */
1454 int oldSort, oldSortAux;
1457 + int news = 0; /* is it a news article ? */
1459 + if (option (OPTNEWSSEND))
1463 mutt_attach_init (msg->content);
1464 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
1465 @@ -518,10 +574,18 @@ int mutt_compose_menu (HEADER *msg, /*
1466 menu->make_entry = snd_entry;
1467 menu->tag = mutt_tag_attach;
1471 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1474 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1479 + unset_option (OPTNEWS); /* for any case */
1481 switch (op = mutt_menuLoop (menu))
1484 @@ -534,17 +598,87 @@ int mutt_compose_menu (HEADER *msg, /*
1485 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1487 case OP_COMPOSE_EDIT_TO:
1492 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1493 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1495 case OP_COMPOSE_EDIT_BCC:
1500 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1501 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1503 case OP_COMPOSE_EDIT_CC:
1508 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1509 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1512 + case OP_COMPOSE_EDIT_NEWSGROUPS:
1515 + if (msg->env->newsgroups)
1516 + strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1519 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1521 + FREE (&msg->env->newsgroups);
1522 + mutt_remove_trailing_ws (buf);
1523 + msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1524 + move (HDR_TO, HDR_XOFFSET);
1526 + if (msg->env->newsgroups)
1527 + printw ("%-*.*s", W, W, msg->env->newsgroups);
1532 + case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1536 + if (msg->env->followup_to)
1537 + strfcpy (buf, msg->env->followup_to, sizeof (buf));
1538 + if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1540 + FREE (&msg->env->followup_to);
1541 + mutt_remove_trailing_ws (buf);
1542 + msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1543 + move (HDR_CC, HDR_XOFFSET);
1545 + if (msg->env->followup_to)
1546 + printw ("%-*.*s", W, W, msg->env->followup_to);
1551 + case OP_COMPOSE_EDIT_X_COMMENT_TO:
1552 + if (news && option (OPTXCOMMENTTO))
1555 + if (msg->env->x_comment_to)
1556 + strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1557 + if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1559 + FREE (&msg->env->x_comment_to);
1560 + msg->env->x_comment_to = safe_strdup (buf);
1561 + move (HDR_BCC, HDR_XOFFSET);
1563 + if (msg->env->x_comment_to)
1564 + printw ("%-*.*s", W, W, msg->env->x_comment_to);
1569 case OP_COMPOSE_EDIT_SUBJECT:
1570 if (msg->env->subject)
1571 strfcpy (buf, msg->env->subject, sizeof (buf));
1572 @@ -707,6 +841,9 @@ int mutt_compose_menu (HEADER *msg, /*
1575 case OP_COMPOSE_ATTACH_MESSAGE:
1577 + case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1582 @@ -714,7 +851,22 @@ int mutt_compose_menu (HEADER *msg, /*
1584 prompt = _("Open mailbox to attach message from");
1587 + unset_option (OPTNEWS);
1588 + if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1590 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1593 + prompt = _("Open newsgroup to attach message from");
1594 + set_option (OPTNEWS);
1600 + if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1603 strfcpy (fname, NONULL (Context->path), sizeof (fname));
1604 mutt_pretty_mailbox (fname);
1605 @@ -723,6 +875,11 @@ int mutt_compose_menu (HEADER *msg, /*
1606 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1610 + if (option (OPTNEWS))
1611 + nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1614 mutt_expand_path (fname, sizeof (fname));
1616 if (!mx_is_imap (fname))
1617 @@ -730,6 +887,9 @@ int mutt_compose_menu (HEADER *msg, /*
1619 if (!mx_is_pop (fname))
1622 + if (!mx_is_nntp (fname) && !option (OPTNEWS))
1624 /* check to make sure the file exists and is readable */
1625 if (access (fname, R_OK) == -1)
1627 diff -udprP mutt-1.5.15.orig/config.h.in mutt-1.5.15/config.h.in
1628 --- mutt-1.5.15.orig/config.h.in 2007-04-06 10:18:47.000000000 +0300
1629 +++ mutt-1.5.15/config.h.in 2007-04-11 17:25:15.000000000 +0300
1631 significant more memory when defined. */
1632 #undef EXACT_ADDRESS
1634 +/* Compiling with newsreading support with NNTP */
1637 /* program to use for shell commands */
1640 diff -udprP mutt-1.5.15.orig/configure.ac mutt-1.5.15/configure.ac
1641 --- mutt-1.5.15.orig/configure.ac 2007-04-06 10:11:53.000000000 +0300
1642 +++ mutt-1.5.15/configure.ac 2007-04-11 17:25:15.000000000 +0300
1643 @@ -584,6 +584,14 @@ if test x"$need_imap" = xyes -o x"$need_
1644 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1647 +AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1648 +[ if test x$enableval = xyes ; then
1649 + AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1650 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1655 dnl -- end socket dependencies --
1657 if test "$need_socket" = "yes"
1658 diff -udprP mutt-1.5.15.orig/curs_main.c mutt-1.5.15/curs_main.c
1659 --- mutt-1.5.15.orig/curs_main.c 2007-04-03 20:41:14.000000000 +0300
1660 +++ mutt-1.5.15/curs_main.c 2007-04-11 17:25:15.000000000 +0300
1664 #include "mutt_curses.h"
1666 #include "mutt_menu.h"
1668 #include "mailbox.h"
1671 #include "mutt_crypt.h"
1680 @@ -415,12 +420,27 @@ struct mapping_t IndexHelp[] = {
1685 +struct mapping_t IndexNewsHelp[] = {
1686 + { N_("Quit"), OP_QUIT },
1687 + { N_("Del"), OP_DELETE },
1688 + { N_("Undel"), OP_UNDELETE },
1689 + { N_("Save"), OP_SAVE },
1690 + { N_("Post"), OP_POST },
1691 + { N_("Followup"), OP_FOLLOWUP },
1692 + { N_("Catchup"), OP_CATCHUP },
1693 + { N_("Help"), OP_HELP },
1698 /* This function handles the message index window as well as commands returned
1699 * from the pager (MENU_PAGER).
1701 int mutt_index_menu (void)
1703 char buf[LONG_STRING], helpstr[LONG_STRING];
1706 int done = 0; /* controls when to exit the "event" loop */
1708 @@ -442,7 +462,11 @@ int mutt_index_menu (void)
1709 menu->make_entry = index_make_entry;
1710 menu->color = index_color;
1711 menu->current = ci_first_message ();
1712 - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1713 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1715 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1720 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
1721 @@ -694,6 +718,9 @@ int mutt_index_menu (void)
1722 mutt_curs_set (1); /* fallback from the pager */
1726 + unset_option (OPTNEWS); /* for any case */
1731 @@ -744,6 +771,120 @@ int mutt_index_menu (void)
1732 menu_current_bottom (menu);
1736 + case OP_GET_MESSAGE:
1737 + case OP_GET_PARENT:
1739 + if (Context->magic == M_NNTP)
1743 + if (op == OP_GET_MESSAGE)
1746 + if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1752 + LIST *ref = CURHDR->env->references;
1755 + mutt_error _("Article has no parent reference!");
1758 + strfcpy (buf, ref->data, sizeof (buf));
1760 + if (!Context->id_hash)
1761 + Context->id_hash = mutt_make_id_hash (Context);
1762 + if ((h = hash_find (Context->id_hash, buf)))
1764 + if (h->virtual != -1)
1766 + menu->current = h->virtual;
1767 + menu->redraw = REDRAW_MOTION_RESYNCH;
1769 + else if (h->collapsed)
1771 + mutt_uncollapse_thread (Context, h);
1772 + mutt_set_virtual (Context);
1773 + menu->current = h->virtual;
1774 + menu->redraw = REDRAW_MOTION_RESYNCH;
1777 + mutt_error _("Message not visible in limited view.");
1781 + if (nntp_check_msgid (Context, buf) == 0)
1783 + h = Context->hdrs[Context->msgcount-1];
1784 + mutt_sort_headers (Context, 0);
1785 + menu->current = h->virtual;
1786 + menu->redraw = REDRAW_FULL;
1789 + mutt_error (_("Article %s not found on server"), buf);
1794 + case OP_GET_CHILDREN:
1795 + case OP_RECONSTRUCT_THREAD:
1797 + if (Context->magic == M_NNTP)
1800 + int old = CURHDR->index, i;
1802 + if (!CURHDR->env->message_id)
1804 + mutt_error _("No Message-Id. Unable to perform operation");
1808 + if (!Context->id_hash)
1809 + Context->id_hash = mutt_make_id_hash (Context);
1810 + strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1812 + if (op == OP_RECONSTRUCT_THREAD)
1814 + LIST *ref = CURHDR->env->references;
1817 + nntp_check_msgid (Context, ref->data);
1818 + /* the last msgid in References is the root message */
1820 + strfcpy (buf, ref->data, sizeof (buf));
1824 + mutt_message _("Check for children of message...");
1825 + if (nntp_check_children (Context, buf) == 0)
1827 + mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1828 + h = hash_find (Context->id_hash, buf);
1829 + /* if the root message was retrieved, move to it */
1831 + menu->current = h->virtual;
1832 + else /* try to restore old position */
1833 + for (i = 0; i < Context->msgcount; i++)
1834 + if (Context->hdrs[i]->index == old)
1836 + menu->current = Context->hdrs[i]->virtual;
1837 + /* As an added courtesy, recenter the menu
1838 + * with the current entry at the middle of the screen */
1839 + menu_check_recenter (menu);
1840 + menu_current_middle (menu);
1843 + menu->redraw = REDRAW_FULL;
1844 + mutt_clear_error ();
1852 @@ -841,11 +982,33 @@ int mutt_index_menu (void)
1856 + case OP_TOGGLE_READ:
1859 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1861 - if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1862 + if (op == OP_TOGGLE_READ)
1864 + char buf[LONG_STRING];
1866 + if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1868 + snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1869 + Context->pattern ? Context->pattern : ".*");
1870 + set_option (OPTHIDEREAD);
1874 + strfcpy (buf, Context->pattern + 8, sizeof(buf));
1875 + if (!*buf || strncmp (buf, ".*", 2) == 0)
1876 + snprintf (buf, sizeof(buf), "~A");
1877 + unset_option (OPTHIDEREAD);
1879 + FREE (&Context->pattern);
1880 + Context->pattern = safe_strdup (buf);
1882 + if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1883 + mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1885 if (menu->oldcurrent >= 0)
1887 @@ -1052,20 +1215,43 @@ int mutt_index_menu (void)
1890 case OP_MAIN_CHANGE_FOLDER:
1893 - op = OP_MAIN_CHANGE_FOLDER_READONLY;
1895 - /* fallback to the readonly case */
1897 case OP_MAIN_CHANGE_FOLDER_READONLY:
1899 + case OP_MAIN_CHANGE_GROUP:
1900 + case OP_MAIN_CHANGE_GROUP_READONLY:
1903 - if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1904 + if (attach_msg || option (OPTREADONLY) ||
1906 + op == OP_MAIN_CHANGE_GROUP_READONLY ||
1908 + op == OP_MAIN_CHANGE_FOLDER_READONLY)
1909 + flags = M_READONLY;
1914 cp = _("Open mailbox in read-only mode");
1916 cp = _("Open mailbox");
1920 + unset_option (OPTNEWS);
1921 + if (op == OP_MAIN_CHANGE_GROUP ||
1922 + op == OP_MAIN_CHANGE_GROUP_READONLY)
1924 + set_option (OPTNEWS);
1925 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1928 + cp = _("Open newsgroup in read-only mode");
1930 + cp = _("Open newsgroup");
1935 mutt_buffy (buf, sizeof (buf));
1937 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1938 @@ -1084,6 +1270,14 @@ int mutt_index_menu (void)
1943 + if (option (OPTNEWS))
1945 + unset_option (OPTNEWS);
1946 + nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1950 mutt_expand_path (buf, sizeof (buf));
1951 if (mx_get_magic (buf) <= 0)
1953 @@ -1121,15 +1315,18 @@ int mutt_index_menu (void)
1954 CurrentMenu = MENU_MAIN;
1955 mutt_folder_hook (buf);
1957 - if ((Context = mx_open_mailbox (buf,
1958 - (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1959 - M_READONLY : 0, NULL)) != NULL)
1960 + if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1962 menu->current = ci_first_message ();
1968 + /* mutt_buffy_check() must be done with mail-reader mode! */
1969 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1970 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1972 mutt_clear_error ();
1973 mutt_buffy_check(1); /* force the buffy check after we have changed
1975 @@ -1500,6 +1697,15 @@ int mutt_index_menu (void)
1977 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1980 + if (Context->magic == M_NNTP)
1983 + mutt_error _("Can't change 'important' flag on NNTP server.");
1990 for (j = 0; j < Context->vcount; j++)
1991 @@ -1847,6 +2053,17 @@ int mutt_index_menu (void)
1997 + if (Context && Context->magic == M_NNTP)
1999 + if (mutt_newsgroup_catchup (CurrentNewsSrv,
2000 + ((NNTP_DATA *)Context->data)->group))
2001 + menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2006 case OP_DISPLAY_ADDRESS:
2009 @@ -1974,6 +2191,15 @@ int mutt_index_menu (void)
2010 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2015 + if (Context->magic == M_NNTP)
2018 + mutt_error _("Can't edit message on newsserver.");
2023 MAYBE_REDRAW (menu->redraw);
2025 @@ -2045,6 +2271,37 @@ int mutt_index_menu (void)
2027 menu->redraw = REDRAW_FULL;
2033 + case OP_FORWARD_TO_GROUP:
2036 + if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2037 + mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2038 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2040 + if (Context && Context->magic == M_NNTP &&
2041 + !((NNTP_DATA *)Context->data)->allowed &&
2042 + query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2044 + if (op == OP_POST)
2045 + ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2049 + if (op == OP_FOLLOWUP)
2050 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2051 + tag ? NULL : CURHDR);
2053 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2054 + tag ? NULL : CURHDR);
2056 + menu->redraw = REDRAW_FULL;
2063 @@ -2118,6 +2375,12 @@ int mutt_index_menu (void)
2065 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2068 + /* Close all open NNTP connections */
2070 + nntp_logout_all ();
2073 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2074 op == OP_UNDELETE_THREAD ? 0 : 1);
2076 diff -udprP mutt-1.5.15.orig/doc/manual.xml.head mutt-1.5.15/doc/manual.xml.head
2077 --- mutt-1.5.15.orig/doc/manual.xml.head 2007-04-04 08:37:13.000000000 +0300
2078 +++ mutt-1.5.15/doc/manual.xml.head 2007-04-11 17:25:15.000000000 +0300
2079 @@ -1295,6 +1295,22 @@ fo-table</literal> for details.
2084 +<title>Reading news via NNTP</title>
2087 +If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2088 +read news from newsserver via NNTP. You can open a newsgroup with
2089 +function ``change-newsgroup'' (default: ``i''). Default newsserver
2090 +can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2091 +variable. Like other news readers, info about subscribed newsgroups
2092 +is saved in file by <link linkend="newsrc">$newsrc</link>
2093 +variable. Article headers are cached and can be loaded from file when
2094 +newsgroup entered instead loading from newsserver.
2101 <sect1 id="forwarding-mail">
2102 diff -udprP mutt-1.5.15.orig/doc/mutt.man mutt-1.5.15/doc/mutt.man
2103 --- mutt-1.5.15.orig/doc/mutt.man 2007-04-04 08:37:13.000000000 +0300
2104 +++ mutt-1.5.15/doc/mutt.man 2007-04-11 17:25:15.000000000 +0300
2105 @@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2110 -[-e \fIcmd\fP] [-F \fIfile\fP] [-m \fItype\fP] [-f \fIfile\fP]
2112 +[-e \fIcmd\fP] [-F \fIfile\fP] [-g \fIserver\fP] [-m \fItype\fP] [-f \fIfile\fP]
2116 @@ -83,6 +83,10 @@ files.
2117 Specify which mailbox to load.
2118 .IP "-F \fImuttrc\fP"
2119 Specify an initialization file to read instead of ~/.muttrc
2120 +.IP "-g \fIserver\fP"
2121 +Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2123 +Start Mutt with a listing of subscribed newsgroups.
2126 .IP "-H \fIdraft\fP"
2127 diff -udprP mutt-1.5.15.orig/functions.h mutt-1.5.15/functions.h
2128 --- mutt-1.5.15.orig/functions.h 2007-04-02 00:58:55.000000000 +0300
2129 +++ mutt-1.5.15/functions.h 2007-04-11 17:25:15.000000000 +0300
2130 @@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in
2131 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2132 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2133 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2135 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2136 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2138 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2139 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
2140 { "copy-message", OP_COPY_MESSAGE, "C" },
2141 @@ -100,7 +104,15 @@ struct binding_t OpMain[] = { /* map: in
2142 { "edit", OP_EDIT_MESSAGE, "e" },
2143 { "edit-type", OP_EDIT_TYPE, "\005" },
2144 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2145 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2147 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2148 + { "followup-message", OP_FOLLOWUP, "F" },
2149 + { "get-children", OP_GET_CHILDREN, NULL },
2150 + { "get-message", OP_GET_MESSAGE, "\007" },
2151 + { "get-parent", OP_GET_PARENT, "\033G" },
2152 + { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2154 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2155 { "group-reply", OP_GROUP_REPLY, "g" },
2157 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2158 @@ -126,6 +138,9 @@ struct binding_t OpMain[] = { /* map: in
2159 { "sort-mailbox", OP_SORT, "o" },
2160 { "sort-reverse", OP_SORT_REVERSE, "O" },
2161 { "print-message", OP_PRINT, "p" },
2163 + { "post-message", OP_POST, "P" },
2165 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2166 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2167 { "recall-message", OP_RECALL_MESSAGE, "R" },
2168 @@ -145,6 +160,10 @@ struct binding_t OpMain[] = { /* map: in
2169 { "show-version", OP_VERSION, "V" },
2170 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2171 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2172 + { "toggle-read", OP_TOGGLE_READ, "X" },
2174 + { "catchup", OP_CATCHUP, "y" },
2176 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2177 { "buffy-list", OP_BUFFY_LIST, "." },
2178 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
2179 @@ -156,7 +175,7 @@ struct binding_t OpMain[] = { /* map: in
2180 { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" },
2181 { "next-unread", OP_MAIN_NEXT_UNREAD, NULL },
2182 { "previous-unread", OP_MAIN_PREV_UNREAD, NULL },
2183 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2184 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2187 { "extract-keys", OP_EXTRACT_KEYS, "\013" },
2188 @@ -176,6 +195,10 @@ struct binding_t OpPager[] = { /* map: p
2189 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2190 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2191 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2193 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2194 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2196 { "copy-message", OP_COPY_MESSAGE, "C" },
2197 { "decode-copy", OP_DECODE_COPY, "\033C" },
2198 { "delete-message", OP_DELETE, "d" },
2199 @@ -183,8 +206,12 @@ struct binding_t OpPager[] = { /* map: p
2200 { "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" },
2201 { "edit", OP_EDIT_MESSAGE, "e" },
2202 { "edit-type", OP_EDIT_TYPE, "\005" },
2204 + { "followup-message", OP_FOLLOWUP, "F" },
2205 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2207 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2208 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2209 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2210 { "group-reply", OP_GROUP_REPLY, "g" },
2212 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
2213 @@ -203,6 +230,9 @@ struct binding_t OpPager[] = { /* map: p
2214 { "next-thread", OP_MAIN_NEXT_THREAD, "\016" },
2215 { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" },
2216 { "print-message", OP_PRINT, "p" },
2218 + { "post-message", OP_POST, "P" },
2220 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2221 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2222 { "quit", OP_QUIT, "Q" },
2223 @@ -250,7 +280,7 @@ struct binding_t OpPager[] = { /* map: p
2224 { "half-down", OP_HALF_DOWN, NULL },
2225 { "previous-line", OP_PREV_LINE, NULL },
2226 { "bottom", OP_PAGER_BOTTOM, NULL },
2227 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2228 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2232 @@ -270,6 +300,10 @@ struct binding_t OpAttach[] = { /* map:
2233 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2234 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2235 { "edit-type", OP_EDIT_TYPE, "\005" },
2237 + { "followup-message", OP_FOLLOWUP, "F" },
2238 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2240 { "print-entry", OP_PRINT, "p" },
2241 { "save-entry", OP_SAVE, "s" },
2242 { "pipe-entry", OP_PIPE, "|" },
2243 @@ -295,6 +329,7 @@ struct binding_t OpAttach[] = { /* map:
2244 struct binding_t OpCompose[] = { /* map: compose */
2245 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2246 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2247 + { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2248 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2249 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2250 { "copy-file", OP_SAVE, "C" },
2251 @@ -314,6 +349,11 @@ struct binding_t OpCompose[] = { /* map:
2252 { "print-entry", OP_PRINT, "l" },
2253 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2254 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2256 + { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2257 + { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2258 + { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2260 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2261 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2262 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
2263 @@ -365,14 +405,25 @@ struct binding_t OpBrowser[] = { /* map:
2264 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2265 { "check-new", OP_CHECK_NEW, NULL },
2266 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2268 + { "reload-active", OP_LOAD_ACTIVE, "g" },
2269 + { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2270 + { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2271 + { "catchup", OP_CATCHUP, "y" },
2272 + { "uncatchup", OP_UNCATCHUP, "Y" },
2274 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2275 { "buffy-list", OP_BUFFY_LIST, "." },
2277 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2278 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2279 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2281 +#if defined USE_IMAP || defined USE_NNTP
2282 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2283 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2286 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2289 diff -udprP mutt-1.5.15.orig/globals.h mutt-1.5.15/globals.h
2290 --- mutt-1.5.15.orig/globals.h 2007-04-05 19:04:56.000000000 +0300
2291 +++ mutt-1.5.15/globals.h 2007-04-11 17:25:15.000000000 +0300
2292 @@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
2295 WHERE char *Muttrc INITVAL (NULL);
2297 +WHERE char *NewsCacheDir;
2298 +WHERE char *GroupFormat;
2300 +WHERE char *NewsServer;
2301 +WHERE char *NntpUser;
2302 +WHERE char *NntpPass;
2303 +WHERE char *NewsRc;
2307 WHERE char *PagerFmt;
2308 @@ -189,6 +198,11 @@ extern unsigned char QuadOptions[];
2310 WHERE unsigned short Counter INITVAL (0);
2313 +WHERE short NewsPollTimeout;
2314 +WHERE short NntpContext;
2317 WHERE short ConnectTimeout;
2318 WHERE short HistSize;
2319 WHERE short MenuContext;
2320 diff -udprP mutt-1.5.15.orig/hash.c mutt-1.5.15/hash.c
2321 --- mutt-1.5.15.orig/hash.c 2007-04-02 00:58:56.000000000 +0300
2322 +++ mutt-1.5.15/hash.c 2007-04-11 17:25:15.000000000 +0300
2323 @@ -51,10 +51,35 @@ HASH *hash_create (int nelem)
2326 table->nelem = nelem;
2327 + table->curnelem = 0;
2328 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2332 +HASH *hash_resize (HASH *ptr, int nelem)
2335 + struct hash_elem *elem, *tmp;
2338 + table = hash_create (nelem);
2340 + for (i = 0; i < ptr->nelem; i++)
2342 + for (elem = ptr->table[i]; elem; )
2345 + elem = elem->next;
2346 + hash_insert (table, tmp->key, tmp->data, 1);
2350 + FREE (&ptr->table);
2356 /* table hash table to update
2357 * key key to hash on
2358 * data data to associate with `key'
2359 @@ -74,6 +99,7 @@ int hash_insert (HASH * table, const cha
2361 ptr->next = table->table[h];
2362 table->table[h] = ptr;
2363 + table->curnelem++;
2367 @@ -96,6 +122,7 @@ int hash_insert (HASH * table, const cha
2369 table->table[h] = ptr;
2371 + table->curnelem++;
2375 @@ -126,6 +153,7 @@ void hash_delete_hash (HASH * table, int
2377 destroy (ptr->data);
2379 + table->curnelem--;
2383 diff -udprP mutt-1.5.15.orig/hash.h mutt-1.5.15/hash.h
2384 --- mutt-1.5.15.orig/hash.h 2007-04-02 00:58:56.000000000 +0300
2385 +++ mutt-1.5.15/hash.h 2007-04-11 17:25:15.000000000 +0300
2386 @@ -28,7 +28,7 @@ struct hash_elem
2391 + int nelem, curnelem;
2392 struct hash_elem **table;
2395 @@ -40,6 +40,7 @@ HASH;
2396 HASH *hash_create (int nelem);
2397 int hash_string (const unsigned char *s, int n);
2398 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2399 +HASH *hash_resize (HASH * table, int nelem);
2400 void *hash_find_hash (const HASH * table, int hash, const char *key);
2401 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2402 void (*destroy) (void *));
2403 diff -udprP mutt-1.5.15.orig/hdrline.c mutt-1.5.15/hdrline.c
2404 --- mutt-1.5.15.orig/hdrline.c 2007-04-03 20:52:56.000000000 +0300
2405 +++ mutt-1.5.15/hdrline.c 2007-04-11 17:29:25.000000000 +0300
2406 @@ -209,6 +209,7 @@ int mutt_user_is_recipient (HEADER *h)
2407 * %E = number of messages in current thread
2408 * %f = entire from line
2409 * %F = like %n, unless from self
2410 + * %g = newsgroup name (if compiled with nntp support)
2412 * %l = number of lines in the message
2413 * %L = like %F, except `lists' are displayed first
2414 @@ -216,12 +217,14 @@ int mutt_user_is_recipient (HEADER *h)
2415 * %n = name of author
2417 * %O = like %L, except using address instead of name
2418 + * %R = `x-comment-to:' field (if present and compiled with nntp support)
2420 * %S = short message status (e.g., N/O/D/!/r/-)
2421 * %t = `to:' field (recipients)
2423 * %u = user (login) name of author
2424 * %v = first name of author, unless from self
2425 + * %W = where user is (organization)
2426 * %X = number of MIME attachments
2427 * %y = `x-label:' field (if present)
2428 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2429 @@ -459,6 +462,12 @@ hdr_format_str (char *dest,
2435 + mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2440 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2442 @@ -546,6 +555,15 @@ hdr_format_str (char *dest,
2449 + mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2450 + else if (!hdr->env->x_comment_to)
2457 if (flags & M_FORMAT_TREE && !hdr->collapsed)
2458 @@ -635,6 +653,13 @@ hdr_format_str (char *dest,
2459 mutt_format_s (dest, destlen, prefix, buf2);
2464 + mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2465 + else if (!hdr->env->organization)
2472 diff -udprP mutt-1.5.15.orig/headers.c mutt-1.5.15/headers.c
2473 --- mutt-1.5.15.orig/headers.c 2007-04-02 00:58:56.000000000 +0300
2474 +++ mutt-1.5.15/headers.c 2007-04-11 17:25:15.000000000 +0300
2475 @@ -118,6 +118,9 @@ void mutt_edit_headers (const char *edit
2476 msg->env = n; n = NULL;
2478 if (!msg->env->in_reply_to)
2480 + if (!option (OPTNEWSSEND))
2482 mutt_free_list (&msg->env->references);
2484 mutt_expand_aliases_env (msg->env);
2485 diff -udprP mutt-1.5.15.orig/init.c mutt-1.5.15/init.c
2486 --- mutt-1.5.15.orig/init.c 2007-04-02 00:58:56.000000000 +0300
2487 +++ mutt-1.5.15/init.c 2007-04-11 17:25:15.000000000 +0300
2488 @@ -2859,6 +2859,28 @@ void mutt_init (int skip_sys_rc, LIST *c
2490 Fqdn = safe_strdup(NONULL(Hostname));
2497 + if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2500 + fgets (buffer, sizeof (buffer), f);
2504 + while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2506 + NewsServer = safe_strdup (p);
2510 + if ((p = getenv ("NNTPSERVER")))
2511 + NewsServer = safe_strdup (p);
2514 if ((p = getenv ("MAIL")))
2515 Spoolfile = safe_strdup (p);
2516 else if ((p = getenv ("MAILDIR")))
2517 diff -udprP mutt-1.5.15.orig/init.h mutt-1.5.15/init.h
2518 --- mutt-1.5.15.orig/init.h 2007-04-05 19:03:55.000000000 +0300
2519 +++ mutt-1.5.15/init.h 2007-04-11 17:29:25.000000000 +0300
2520 @@ -169,6 +169,20 @@ struct option_t MuttVars[] = {
2521 ** If set, Mutt will prompt you for carbon-copy (Cc) recipients before
2522 ** editing the body of an outgoing message.
2525 + { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2528 + ** If set, Mutt will prompt you for follow-up groups before editing
2529 + ** the body of an outgoing message.
2531 + { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2534 + ** If set, Mutt will prompt you for x-comment-to field before editing
2535 + ** the body of an outgoing message.
2538 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2541 @@ -308,6 +322,14 @@ struct option_t MuttVars[] = {
2542 ** When this variable is set, mutt will use file size attribute instead of
2543 ** access time when checking for new mail.
2546 + { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2549 + ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2550 + ** as read when you quit the newsgroup (catchup newsgroup).
2553 { "charset", DT_STR, R_NONE, UL &Charset, UL 0 },
2556 @@ -635,6 +657,16 @@ struct option_t MuttVars[] = {
2557 ** sent to both the list and your address, resulting in two copies
2558 ** of the same email for you.
2561 + { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2564 + ** If this variable is \fIset\fP and the keyword "poster" is present in
2565 + ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2566 + ** permitted. The message will be mailed to the submitter of the
2567 + ** message via mail.
2570 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2573 @@ -706,6 +738,27 @@ struct option_t MuttVars[] = {
2574 ** a regular expression that will match the whole name so mutt will expand
2575 ** "Franklin" to "Franklin, Steve".
2578 + { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2581 + ** This variable allows you to customize the newsgroup browser display to
2582 + ** your personal taste. This string is similar to ``$index_format'', but
2583 + ** has its own set of printf()-like sequences:
2586 + ** %C current newsgroup number
2587 + ** %d description of newsgroup (becomes from server)
2588 + ** %f newsgroup name
2589 + ** %M - if newsgroup not allowed for direct post (moderated for example)
2590 + ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2591 + ** %n number of new articles in newsgroup
2592 + ** %s number of unread articles in newsgroup
2593 + ** %>X right justify the rest of the string and pad with character "X"
2594 + ** %|X pad to the end of the line with character "X"
2598 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2601 @@ -996,6 +1049,7 @@ struct option_t MuttVars[] = {
2602 ** .dt %E .dd number of messages in current thread
2603 ** .dt %f .dd entire From: line (address + real name)
2604 ** .dt %F .dd author name, or recipient name if the message is from you
2605 + ** .dt %g .dd newsgroup name (if compiled with nntp support)
2606 ** .dt %H .dd spam attribute(s) of this message
2607 ** .dt %i .dd message-id of the current message
2608 ** .dt %l .dd number of lines in the message (does not work with maildir,
2609 @@ -1009,12 +1063,14 @@ struct option_t MuttVars[] = {
2610 ** .dt %n .dd author's real name (or address if missing)
2611 ** .dt %O .dd (_O_riginal save folder) Where mutt would formerly have
2612 ** stashed the message: list name or recipient name if no list
2613 + ** .dt %R .dd `x-comment-to:' field (if present and compiled with nntp support)
2614 ** .dt %s .dd subject of the message
2615 ** .dt %S .dd status of the message (N/D/d/!/r/\(as)
2616 ** .dt %t .dd `to:' field (recipients)
2617 ** .dt %T .dd the appropriate character from the $$to_chars string
2618 ** .dt %u .dd user (login) name of the author
2619 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2620 + ** .dt %W .dd name of organization of author (`organization:' field)
2621 ** .dt %X .dd number of attachments
2622 ** (please see the ``$attachments'' section for possible speed effects)
2623 ** .dt %y .dd `x-label:' field, if present
2624 @@ -1039,6 +1095,21 @@ struct option_t MuttVars[] = {
2626 ** See also: ``$$to_chars''.
2629 + { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2632 + ** If set, specifies the program and arguments used to deliver news posted
2633 + ** by Mutt. Otherwise, mutt posts article using current connection to
2634 + ** news server. The following printf-style sequence is understood:
2637 + ** %s newsserver name
2640 + ** Example: set inews="/usr/local/bin/inews -hS"
2643 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2646 @@ -1253,6 +1324,16 @@ struct option_t MuttVars[] = {
2647 ** be attached to the newly composed message if this option is set.
2651 + { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2654 + ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2655 + ** encoded according to RFC2047 to base64. This is useful when message
2656 + ** is Usenet article, because MIME for news is nonstandard feature.
2661 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2663 @@ -1323,6 +1404,77 @@ struct option_t MuttVars[] = {
2664 ** See also ``$$read_inc'' and ``$$write_inc''.
2668 + { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2671 + ** This variable pointing to directory where Mutt will save cached news
2672 + ** articles headers in. If \fIunset\fP, headers will not be saved at all
2673 + ** and will be reloaded each time when you enter to newsgroup.
2675 + { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2678 + ** This variable specifies domain name or address of NNTP server. It
2679 + ** defaults to the newsserver specified in the environment variable
2680 + ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2681 + ** specify username and an alternative port for each newsserver, ie:
2683 + ** [news[s]://][username[:password]@]newsserver[:port]
2685 + { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2688 + ** The file, containing info about subscribed newsgroups - names and
2689 + ** indexes of read articles. The following printf-style sequence
2693 + ** %s newsserver name
2696 + { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2699 + ** This variable defines number of articles which will be in index when
2700 + ** newsgroup entered. If active newsgroup have more articles than this
2701 + ** number, oldest articles will be ignored. Also controls how many
2702 + ** articles headers will be saved in cache when you quit newsgroup.
2704 + { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2707 + ** This variable controls whether or not descriptions for each newsgroup
2708 + ** must be loaded when newsgroup is added to list (first time list
2709 + ** loading or new newsgroup adding).
2711 + { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2714 + ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2715 + ** authentification, Mutt will prompt you for your account name when you
2716 + ** connect to newsserver.
2718 + { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2721 + ** Your password for NNTP account.
2723 + { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2726 + ** The time in seconds until any operations on newsgroup except post new
2727 + ** article will cause recheck for new news. If set to 0, Mutt will
2728 + ** recheck newsgroup on each operation in index (stepping, read article,
2731 + { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2734 + ** Controls whether or not Mutt will try to reconnect to newsserver when
2735 + ** connection lost.
2738 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2741 @@ -2133,6 +2285,16 @@ struct option_t MuttVars[] = {
2742 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2746 + { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2749 + ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2750 + ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2751 + ** does not support posting to that newsgroup or totally read-only, that
2752 + ** posting will not have an effect.
2755 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2758 @@ -2489,6 +2651,28 @@ struct option_t MuttVars[] = {
2759 ** Command to use when spawning a subshell. By default, the user's login
2760 ** shell from /etc/passwd is used.
2763 + { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2766 + ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2767 + ** ``newsrc'' file and into cache.
2769 + { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2772 + ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2773 + ** the browser. Otherwise, it will be done only once for a newsserver.
2774 + ** Also controls whether or not number of new articles of subscribed
2775 + ** newsgroups will be then checked.
2777 + { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2780 + ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2781 + ** will be displayed in browser.
2784 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2787 @@ -2987,6 +3171,14 @@ struct option_t MuttVars[] = {
2788 ** option does nothing: mutt will never write out the BCC header
2792 + { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2795 + ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2796 + ** name of original article author) to article that followuped to newsgroup.
2802 diff -udprP mutt-1.5.15.orig/keymap.c mutt-1.5.15/keymap.c
2803 --- mutt-1.5.15.orig/keymap.c 2007-04-02 00:58:56.000000000 +0300
2804 +++ mutt-1.5.15/keymap.c 2007-04-11 17:25:15.000000000 +0300
2805 @@ -629,7 +629,6 @@ void km_init (void)
2806 km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE);
2808 km_bindkey ("x", MENU_PAGER, OP_EXIT);
2809 - km_bindkey ("i", MENU_PAGER, OP_EXIT);
2810 km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE);
2811 km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE);
2812 km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE);
2813 diff -udprP mutt-1.5.15.orig/mailbox.h mutt-1.5.15/mailbox.h
2814 --- mutt-1.5.15.orig/mailbox.h 2007-04-02 00:58:56.000000000 +0300
2815 +++ mutt-1.5.15/mailbox.h 2007-04-11 17:25:15.000000000 +0300
2816 @@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2818 int mx_is_pop (const char *);
2821 +int mx_is_nntp (const char *);
2824 int mx_access (const char*, int);
2825 int mx_check_empty (const char *);
2826 diff -udprP mutt-1.5.15.orig/main.c mutt-1.5.15/main.c
2827 --- mutt-1.5.15.orig/main.c 2007-04-04 08:37:13.000000000 +0300
2828 +++ mutt-1.5.15/main.c 2007-04-11 17:25:15.000000000 +0300
2830 #include <stringprep.h>
2837 static const char *ReachingUs = N_("\
2838 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2839 To report a bug, please visit http://bugs.mutt.org/.\n");
2840 @@ -127,6 +131,8 @@ options:\n\
2841 " -e <command>\tspecify a command to be executed after initialization\n\
2842 -f <file>\tspecify which mailbox to read\n\
2843 -F <file>\tspecify an alternate muttrc file\n\
2844 + -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2845 + -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2846 -H <file>\tspecify a draft file to read header and body from\n\
2847 -i <file>\tspecify a file which Mutt should include in the body\n\
2848 -m <type>\tspecify a default mailbox type\n\
2849 @@ -253,6 +259,12 @@ static void show_version (void)
2862 @@ -521,6 +533,9 @@ static void start_curses (void)
2863 #define M_NOSYSRC (1<<2) /* -n */
2864 #define M_RO (1<<3) /* -R */
2865 #define M_SELECT (1<<4) /* -y */
2867 +#define M_NEWS (1<<5) /* -g and -G */
2870 int main (int argc, char **argv)
2872 @@ -577,7 +592,11 @@ int main (int argc, char **argv)
2877 + while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2879 while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2884 @@ -670,6 +689,20 @@ int main (int argc, char **argv)
2889 + case 'g': /* Specify a newsserver */
2891 + char buf[LONG_STRING];
2893 + snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2894 + commands = mutt_add_list (commands, buf);
2897 + case 'G': /* List of newsgroups */
2898 + flags |= M_SELECT | M_NEWS;
2905 @@ -943,6 +976,18 @@ int main (int argc, char **argv)
2907 else if (flags & M_SELECT)
2910 + if (flags & M_NEWS)
2912 + set_option (OPTNEWS);
2913 + if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2915 + mutt_endwin (Errorbuf);
2922 mutt_endwin _("No incoming mailboxes defined.");
2924 @@ -958,6 +1003,15 @@ int main (int argc, char **argv)
2927 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2930 + if (option (OPTNEWS))
2932 + unset_option (OPTNEWS);
2933 + nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2937 mutt_expand_path (folder, sizeof (folder));
2939 mutt_str_replace (&CurrentFolder, folder);
2940 diff -udprP mutt-1.5.15.orig/mutt.h mutt-1.5.15/mutt.h
2941 --- mutt-1.5.15.orig/mutt.h 2007-04-02 21:04:35.000000000 +0300
2942 +++ mutt-1.5.15/mutt.h 2007-04-11 17:25:15.000000000 +0300
2943 @@ -243,6 +243,9 @@ enum
2951 /* Options for Mailcap lookup */
2953 @@ -298,6 +301,12 @@ enum
2956 OPT_VERIFYSIG, /* verify PGP signatures */
2959 + OPT_NNTPRECONNECT,
2961 + OPT_FOLLOWUPTOPOSTER,
2962 +#endif /* USE_NNTP */
2964 /* THIS MUST BE THE LAST VALUE. */
2966 @@ -313,6 +322,7 @@ enum
2967 #define SENDMAILX (1<<6)
2968 #define SENDKEY (1<<7)
2969 #define SENDRESEND (1<<8)
2970 +#define SENDNEWS (1<<9)
2972 /* flags to _mutt_select_file() */
2973 #define M_SEL_BUFFY (1<<0)
2974 @@ -332,6 +342,8 @@ enum
2983 @@ -404,6 +416,9 @@ enum
2988 + OPTMIMESUBJECT, /* encode subject line with RFC2047 */
2993 @@ -485,6 +500,16 @@ enum
2997 + /* news options */
3001 + OPTSHOWONLYUNREAD,
3005 +#endif /* USE_NNTP */
3007 /* pseudo options */
3009 OPTAUXSORT, /* (pseudo) using auxillary sort function */
3010 @@ -505,6 +530,7 @@ enum
3011 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
3012 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3013 OPTATTACHMSG, /* (pseudo) used by attach-message */
3014 + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3015 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3016 * functions while we are executing an
3018 @@ -515,6 +541,12 @@ enum
3019 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3020 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
3023 + OPTNEWS, /* (pseudo) used to change reader mode */
3024 + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3025 + OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
3031 @@ -592,6 +624,13 @@ typedef struct envelope
3035 + char *organization;
3039 + char *followup_to;
3040 + char *x_comment_to;
3043 LIST *references; /* message references (in reverse order) */
3044 LIST *in_reply_to; /* in-reply-to header content */
3045 @@ -758,6 +797,9 @@ typedef struct header
3046 ENVELOPE *env; /* envelope information */
3047 BODY *content; /* list of MIME parts */
3053 char *tree; /* character string to print thread tree */
3054 struct thread *thread;
3055 @@ -773,7 +815,7 @@ typedef struct header
3056 int refno; /* message number on server */
3059 -#if defined USE_POP || defined USE_IMAP
3060 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3061 void *data; /* driver-specific data */
3064 diff -udprP mutt-1.5.15.orig/muttlib.c mutt-1.5.15/muttlib.c
3065 --- mutt-1.5.15.orig/muttlib.c 2007-04-03 20:52:56.000000000 +0300
3066 +++ mutt-1.5.15/muttlib.c 2007-04-11 17:25:15.000000000 +0300
3067 @@ -286,7 +286,7 @@ void mutt_free_header (HEADER **h)
3069 mutt_free_list (&(*h)->chain);
3071 -#if defined USE_POP || defined USE_IMAP
3072 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3075 FREE (h); /* __FREE_CHECKED__ */
3076 @@ -674,6 +674,13 @@ void mutt_free_envelope (ENVELOPE **p)
3077 FREE (&(*p)->supersedes);
3079 FREE (&(*p)->x_label);
3080 + FREE (&(*p)->organization);
3082 + FREE (&(*p)->newsgroups);
3083 + FREE (&(*p)->xref);
3084 + FREE (&(*p)->followup_to);
3085 + FREE (&(*p)->x_comment_to);
3088 mutt_buffer_free (&(*p)->spam);
3090 @@ -1392,6 +1399,14 @@ int mutt_save_confirm (const char *s, st
3095 + if (magic == M_NNTP)
3097 + mutt_error _("Can't save message to newsserver.");
3102 if (stat (s, st) != -1)
3105 diff -udprP mutt-1.5.15.orig/mx.c mutt-1.5.15/mx.c
3106 --- mutt-1.5.15.orig/mx.c 2007-04-03 20:41:14.000000000 +0300
3107 +++ mutt-1.5.15/mx.c 2007-04-11 17:25:15.000000000 +0300
3108 @@ -348,6 +348,22 @@ int mx_is_pop (const char *p)
3113 +int mx_is_nntp (const char *p)
3115 + url_scheme_t scheme;
3120 + scheme = url_check_scheme (p);
3121 + if (scheme == U_NNTP || scheme == U_NNTPS)
3128 int mx_get_magic (const char *path)
3131 @@ -365,6 +381,11 @@ int mx_get_magic (const char *path)
3133 #endif /* USE_POP */
3136 + if (mx_is_nntp (path))
3138 +#endif /* USE_NNTP */
3140 if (stat (path, &st) == -1)
3142 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
3143 @@ -704,6 +725,12 @@ CONTEXT *mx_open_mailbox (const char *pa
3145 #endif /* USE_POP */
3149 + rc = nntp_open_mailbox (ctx);
3151 +#endif /* USE_NNTP */
3156 @@ -796,6 +823,12 @@ static int sync_mailbox (CONTEXT *ctx, i
3157 rc = pop_sync_mailbox (ctx, index_hint);
3159 #endif /* USE_POP */
3163 + rc = nntp_sync_mailbox (ctx);
3165 +#endif /* USE_NNTP */
3169 @@ -822,6 +855,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
3174 + if (ctx->magic == M_NNTP)
3178 + ret = nntp_close_mailbox (ctx);
3179 + mx_fastclose_mailbox (ctx);
3183 if (ctx->readonly || ctx->dontwrite)
3185 /* mailbox is readonly or we don't want to write */
3186 @@ -1359,6 +1402,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
3188 return (pop_check_mailbox (ctx, index_hint));
3189 #endif /* USE_POP */
3193 + return (nntp_check_mailbox (ctx));
3194 +#endif /* USE_NNTP */
3198 @@ -1419,6 +1467,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
3200 #endif /* USE_POP */
3205 + if (nntp_fetch_message (msg, ctx, msgno) != 0)
3209 +#endif /* USE_NNTP */
3212 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3214 @@ -1500,6 +1557,9 @@ int mx_close_message (MESSAGE **msg)
3216 || (*msg)->magic == M_POP
3219 + || (*msg)->magic == M_NNTP
3223 r = safe_fclose (&(*msg)->fp);
3224 diff -udprP mutt-1.5.15.orig/mx.h mutt-1.5.15/mx.h
3225 --- mutt-1.5.15.orig/mx.h 2007-04-02 00:58:56.000000000 +0300
3226 +++ mutt-1.5.15/mx.h 2007-04-11 17:25:15.000000000 +0300
3227 @@ -40,6 +40,9 @@ enum
3236 WHERE short DefaultMagic INITVAL (M_MBOX);
3237 diff -udprP mutt-1.5.15.orig/newsrc.c mutt-1.5.15/newsrc.c
3238 --- mutt-1.5.15.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3239 +++ mutt-1.5.15/newsrc.c 2007-04-11 18:13:00.000000000 +0300
3242 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3243 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
3244 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
3246 + * This program is free software; you can redistribute it and/or modify
3247 + * it under the terms of the GNU General Public License as published by
3248 + * the Free Software Foundation; either version 2 of the License, or
3249 + * (at your option) any later version.
3251 + * This program is distributed in the hope that it will be useful,
3252 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3253 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3254 + * GNU General Public License for more details.
3256 + * You should have received a copy of the GNU General Public License
3257 + * along with this program; if not, write to the Free Software
3258 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3262 +# include "config.h"
3266 +#include "mutt_curses.h"
3270 +#include "mailbox.h"
3272 +#include "rfc822.h"
3273 +#include "rfc1524.h"
3274 +#include "rfc2047.h"
3276 +#include <unistd.h>
3277 +#include <string.h>
3279 +#include <stdlib.h>
3280 +#include <sys/stat.h>
3282 +void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3289 + l = safe_calloc (1, sizeof (LIST));
3291 + s->tail->next = l;
3295 + l->data = (void *) d;
3298 +static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3301 + char group[LONG_STRING];
3303 + char *p = line, *b, *h;
3313 + while (*p && (*p != ':' && *p != '!')) p++;
3316 + len = p + 1 - line;
3317 + if (len > sizeof (group))
3318 + len = sizeof (group);
3319 + strfcpy (group, line, len);
3320 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3322 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3323 + data->group = (char *) data + sizeof (NNTP_DATA);
3324 + strcpy (data->group, group);
3325 + data->nserv = news;
3326 + data->deleted = 1;
3327 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3328 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3329 + hash_insert (news->newsgroups, data->group, data, 0);
3330 + nntp_add_to_list (news, data);
3333 + FREE ((void **) &data->entries);
3336 + data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3340 + data->subscribed = 1;
3342 + data->subscribed = 0;
3349 + while (*p && *p != ',' && *p != '\n') p++;
3355 + if ((h = strchr(b, '-')))
3359 + data->entries[x].first = atoi(b);
3360 + data->entries[x].last = atoi(h);
3364 + data->entries[x].first = atoi(b);
3365 + data->entries[x].last = data->entries[x].first;
3368 + if (data->entries[x].last != 0)
3371 + if (x && !data->lastMessage)
3372 + data->lastMessage = data->entries[x-1].last;
3374 + mutt_newsgroup_stat (data);
3375 + dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3380 +static int slurp_newsrc (NNTP_SERVER *news)
3386 + news->stat = stat (news->newsrc, &sb);
3387 + news->size = sb.st_size;
3388 + news->mtime = sb.st_mtime;
3390 + if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3392 + /* hmm, should we use dotlock? */
3393 + if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3399 + buf = safe_malloc (sb.st_size + 1);
3400 + while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3401 + nntp_parse_newsrc_line (news, buf);
3404 + mx_unlock_file (news->newsrc, fileno (fp), 0);
3409 +void nntp_cache_expand (char *dst, const char *src)
3411 + snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3412 + mutt_expand_path (dst, _POSIX_PATH_MAX);
3415 +/* Loads $news_cache_dir/.index into memory, loads newsserver data
3416 + * and newsgroup cache names */
3417 +static int nntp_parse_cacheindex (NNTP_SERVER *news)
3420 + char buf[HUGE_STRING], *cp;
3421 + char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3426 + /* check is server name defined or not */
3427 + if (!news || !news->conn || !news->conn->account.host)
3429 + unset_option (OPTNEWSCACHE);
3430 + if (!NewsCacheDir || !*NewsCacheDir)
3433 + strfcpy (dir, NewsCacheDir, sizeof (dir));
3434 + mutt_expand_path (dir, sizeof(dir));
3436 + if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3438 + snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3439 + if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3442 + mutt_error _("Cache directory not created!");
3445 + mutt_clear_error();
3448 + set_option (OPTNEWSCACHE);
3450 + FREE (&news->cache);
3451 + snprintf (buf, sizeof(buf), "%s/.index", dir);
3452 + if (!(index = safe_fopen (buf, "a+")))
3455 + while (fgets (buf, sizeof(buf), index))
3457 + buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3458 + if (!mutt_strncmp (buf, "#: ", 3) &&
3459 + !mutt_strcasecmp (buf+3, news->conn->account.host))
3462 + while (fgets (buf, sizeof(buf), index))
3465 + while (*cp && *cp != ' ') cp++;
3466 + if (!*cp) continue;
3468 + if (!mutt_strcmp (buf, "#:"))
3470 + sscanf (cp + 1, "%s %d %d", file, &l, &m);
3471 + if (!mutt_strcmp (buf, "ALL"))
3473 + news->cache = safe_strdup (file);
3474 + news->newgroups_time = m;
3476 + else if (news->newsgroups)
3478 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3480 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3481 + data->group = (char *) data + sizeof (NNTP_DATA);
3482 + strcpy(data->group, buf);
3483 + data->nserv = news;
3484 + data->deleted = 1;
3485 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3486 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3487 + hash_insert (news->newsgroups, data->group, data, 0);
3488 + nntp_add_to_list (news, data);
3490 + data->cache = safe_strdup (file);
3492 + if (!data->firstMessage || data->lastMessage < m)
3494 + if (!data->firstMessage)
3495 + data->firstMessage = l;
3496 + if (data->lastMessage < m)
3497 + data->lastMessage = m;
3498 + data->lastCached = m;
3499 + if (t || !data->unread)
3500 + mutt_newsgroup_stat (data);
3508 +nntp_format_str (char *dest, size_t destlen, char op, const char *src,
3509 + const char *fmt, const char *ifstring, const char *elsestring,
3510 + unsigned long data, format_flag flags)
3512 + char fn[SHORT_STRING], tmp[SHORT_STRING];
3517 + strncpy (fn, NewsServer, sizeof(fn) - 1);
3518 + mutt_strlower (fn);
3519 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3520 + snprintf (dest, destlen, tmp, fn);
3526 +/* nntp_parse_url: given an NNPT URL, return host, port,
3527 + * username, password and newsgroup will recognise. */
3528 +int nntp_parse_url (const char *server, ACCOUNT *acct,
3529 + char *group, size_t group_len)
3537 + acct->port = NNTP_PORT;
3538 + acct->type = M_ACCT_TYPE_NNTP;
3540 + c = safe_strdup (server);
3541 + url_parse_ciss (&url, c);
3543 + if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3545 + if (url.scheme == U_NNTPS)
3547 + acct->flags |= M_ACCT_SSL;
3548 + acct->port = NNTP_SSL_PORT;
3553 + strfcpy (group, url.path, group_len);
3555 + ret = mutt_account_fromurl (acct, &url);
3562 +void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3566 + url.path = safe_strdup (line);
3567 + mutt_account_tourl (acct, &url);
3568 + url_ciss_tostring (&url, line, len, 0);
3573 + * Automatically loads a newsrc into memory, if necessary.
3574 + * Checks the size/mtime of a newsrc file, if it doesn't match, load
3575 + * again. Hmm, if a system has broken mtimes, this might mean the file
3576 + * is reloaded every time, which we'd have to fix.
3578 + * a newsrc file is a line per newsgroup, with the newsgroup, then a
3579 + * ':' denoting subscribed or '!' denoting unsubscribed, then a
3580 + * comma separated list of article numbers and ranges.
3582 +NNTP_SERVER *mutt_select_newsserver (char *server)
3584 + char file[_POSIX_PATH_MAX];
3588 + NNTP_SERVER *serv;
3591 + if (!server || !*server)
3593 + mutt_error _("No newsserver defined!");
3597 + buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3598 + if (url_check_scheme (server) == U_UNKNOWN)
3600 + strcpy (buf, "news://");
3601 + p = strchr (buf, '\0');
3603 + strcpy (p, server);
3605 + if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3608 + mutt_error (_("%s is an invalid newsserver specification!"), server);
3613 + conn = mutt_conn_find (NULL, &acct);
3617 + mutt_FormatString (file, sizeof (file), NONULL (NewsRc), nntp_format_str, 0, 0);
3618 + mutt_expand_path (file, sizeof (file));
3620 + serv = (NNTP_SERVER *)conn->data;
3625 + /* externally modified? */
3626 + if (serv->stat != stat (file, &sb) || (!serv->stat &&
3627 + (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3629 + for (list = serv->list; list; list = list->next)
3631 + NNTP_DATA *data = (NNTP_DATA *) list->data;
3635 + data->subscribed = 0;
3640 + slurp_newsrc (serv);
3641 + nntp_clear_cacheindex (serv);
3644 + if (serv->status == NNTP_BYE)
3645 + serv->status = NNTP_NONE;
3646 + nntp_check_newgroups (serv, 0);
3650 + /* New newsserver */
3651 + serv = safe_calloc (1, sizeof (NNTP_SERVER));
3652 + serv->conn = conn;
3653 + serv->newsrc = safe_strdup (file);
3654 + serv->newsgroups = hash_create (1009);
3655 + slurp_newsrc (serv); /* load .newsrc */
3656 + nntp_parse_cacheindex (serv); /* load .index */
3657 + if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3658 + nntp_check_newgroups (serv, 1);
3659 + else if (nntp_get_active (serv) < 0)
3661 + hash_destroy (&serv->newsgroups, nntp_delete_data);
3662 + for (list = serv->list; list; list = list->next)
3663 + list->data = NULL;
3664 + mutt_free_list (&serv->list);
3665 + FREE (&serv->newsrc);
3666 + FREE (&serv->cache);
3670 + nntp_clear_cacheindex (serv);
3671 + conn->data = (void *)serv;
3677 + * full status flags are not supported by nntp, but we can fake some
3678 + * of them. This is how:
3679 + * Read = a read message number is in the .newsrc
3680 + * New = a message is new since we last read this newsgroup
3681 + * Old = anything else
3682 + * So, Read is marked as such in the newsrc, old is anything that is
3683 + * "skipped" in the newsrc, and new is anything not in the newsrc nor
3684 + * in the cache. By skipped, I mean before the last unread message
3686 +void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3688 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3692 + data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3698 + dprint (3, (debugfile, "newsgroup %s not found\n", group));
3703 + for (x = 0; x < data->num; x++)
3705 + if ((article >= data->entries[x].first) &&
3706 + (article <= data->entries[x].last))
3708 + /* we cannot use mutt_set_flag() because mx_update_context()
3709 + didn't called yet */
3714 + /* If article was not cached yet, it is new! :) */
3715 + if (!data->cache || article > data->lastCached)
3717 + /* Old articles are articles which aren't read but an article after them
3718 + * has been cached */
3719 + if (option (OPTMARKOLD))
3723 +void mutt_newsgroup_stat (NNTP_DATA *data)
3726 + unsigned int first, last;
3729 + if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3732 + data->unread = data->lastMessage - data->firstMessage + 1;
3733 + for (i = 0; i < data->num; i++)
3735 + first = data->entries[i].first;
3736 + if (first < data->firstMessage)
3737 + first = data->firstMessage;
3738 + last = data->entries[i].last;
3739 + if (last > data->lastMessage)
3740 + last = data->lastMessage;
3741 + if (first <= last)
3742 + data->unread -= last - first + 1;
3746 +static int puti (char *line, int num)
3750 + for (p = s; num; )
3752 + *p++ = '0' + num % 10;
3756 + *line++ = *--p, num++;
3761 +static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3763 + char *line = *pline;
3764 + size_t len = *buflen - (*pline - *buf);
3767 + if (len < LONG_STRING * 10)
3772 + safe_realloc (buf, *buflen);
3773 + line = *buf + (*pline - line);
3775 + strcpy (line, data->group);
3776 + len -= strlen (line) + 1;
3777 + line += strlen (line);
3778 + *line++ = data->subscribed ? ':' : '!';
3782 + for (x = 0; x < data->num; x++)
3784 + if (len < LONG_STRING)
3790 + safe_realloc (buf, *buflen);
3791 + line = *buf + (*pline - line);
3800 + if (data->entries[x].first == data->entries[x].last)
3801 + snprintf (line, len, "%d%n", data->entries[x].first, &i);
3803 + snprintf (line, len, "%d-%d%n",
3804 + data->entries[x].first, data->entries[x].last, &i);
3808 + i = puti (line, data->entries[x].first);
3809 + line +=i; len -= i;
3810 + if (data->entries[x].first != data->entries[x].last)
3814 + i = puti (line, data->entries[x].last);
3815 + line +=i; len -= i;
3824 +void newsrc_gen_entries (CONTEXT *ctx)
3826 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3828 + unsigned int last = 0, first = 1;
3829 + int save_sort = SORT_ORDER;
3831 + if (Sort != SORT_ORDER)
3834 + Sort = SORT_ORDER;
3835 + mutt_sort_headers (ctx, 0);
3840 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3845 + * Set up to fake initial sequence from 1 to the article before the
3846 + * first article in our list
3851 + for (x = 0; x < ctx->msgcount; x++)
3853 + if (series) /* search for first unread */
3856 + * We don't actually check sequential order, since we mark
3857 + * "missing" entries as read/deleted
3859 + last = ctx->hdrs[x]->article_num;
3860 + if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3861 + !ctx->hdrs[x]->read)
3863 + if (data->num >= data->max)
3865 + data->max = data->max * 2;
3866 + safe_realloc (&data->entries,
3867 + data->max * sizeof (NEWSRC_ENTRY));
3869 + data->entries[data->num].first = first;
3870 + data->entries[data->num].last = last - 1;
3875 + else /* search for first read */
3877 + if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3882 + last = ctx->hdrs[x]->article_num;
3885 + if (series && first <= data->lastLoaded)
3887 + if (data->num >= data->max)
3889 + data->max = data->max * 2;
3890 + safe_realloc (&data->entries,
3891 + data->max * sizeof (NEWSRC_ENTRY));
3893 + data->entries[data->num].first = first;
3894 + data->entries[data->num].last = data->lastLoaded;
3898 + if (save_sort != Sort)
3901 + mutt_sort_headers (ctx, 0);
3905 +static int mutt_update_list_file (char *filename, char *section,
3906 + char *key, char *line)
3910 + char buf[HUGE_STRING];
3911 + char tmpfile[_POSIX_PATH_MAX];
3913 + int ext = 0, done = 0, r = 0;
3915 + /* if file not exist, create it */
3916 + if ((ifp = safe_fopen (filename, "a")))
3918 + dprint (1, (debugfile, "Opening %s\n", filename));
3919 + if (!(ifp = safe_fopen (filename, "r")))
3921 + mutt_error (_("Unable to open %s for reading"), filename);
3924 + if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3927 + mutt_error (_("Unable to lock %s"), filename);
3930 + snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3931 + dprint (1, (debugfile, "Opening %s\n", tmpfile));
3932 + if (!(ofp = fopen (tmpfile, "w")))
3935 + mutt_error (_("Unable to open %s for writing"), tmpfile);
3941 + while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3943 + r = fputs (buf, ofp);
3945 + while (*c && *c != '\n') c++;
3946 + c[0] = 0; /* strip EOL */
3947 + if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3950 + if (r != EOF && !done)
3952 + snprintf (buf, sizeof(buf), "#: %s\n", section);
3953 + r = fputs (buf, ofp);
3958 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3963 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3965 + if (*c != '\\') ext = 0;
3967 + else if ((section && !strncmp (buf, "#: ", 3)))
3969 + if (!done && line)
3971 + fputs (line, ofp);
3972 + fputc ('\n', ofp);
3974 + r = fputs (buf, ofp);
3978 + else if (key && !strncmp (buf, key, strlen(key)) &&
3979 + (!*key || buf[strlen(key)] == ' '))
3983 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3985 + if (*c == '\\') ext = 1;
3986 + if (!done && line)
3988 + r = fputs (line, ofp);
3990 + r = fputc ('\n', ofp);
3996 + r = fputs (buf, ofp);
4000 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
4001 + r = fputs (buf, ofp);
4003 + /* If there wasn't a line to replace, put it on the end of the file */
4004 + if (r != EOF && !done && line)
4006 + fputs (line, ofp);
4007 + r = fputc ('\n', ofp);
4009 + mx_unlock_file (filename, fileno (ifp), 0);
4015 + mutt_error (_("Can't write %s"), tmpfile);
4018 + if (rename (tmpfile, filename) < 0)
4021 + mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
4027 +int mutt_newsrc_update (NNTP_SERVER *news)
4037 + llen = len = 10 * LONG_STRING;
4038 + line = buf = safe_calloc (1, len);
4039 + /* we will generate full newsrc here */
4040 + for (tmp = news->list; tmp; tmp = tmp->next)
4042 + data = (NNTP_DATA *) tmp->data;
4043 + if (!data || !data->rc)
4045 + nntp_create_newsrc_line (data, &buf, &line, &llen);
4047 + dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4048 + line += strlen (line);
4050 + /* newrc being fully rewritten */
4051 + if (news->newsrc &&
4052 + (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4056 + stat (news->newsrc, &st);
4057 + news->size = st.st_size;
4058 + news->mtime = st.st_mtime;
4064 +static FILE *mutt_mkname (char *s)
4066 + char buf[_POSIX_PATH_MAX], *pc;
4070 + nntp_cache_expand (buf, s);
4071 + if ((fp = safe_fopen (buf, "w")))
4074 + nntp_cache_expand (buf, "cache-XXXXXX");
4075 + pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4076 + if ((fd = mkstemp (buf)) == -1)
4078 + strcpy (s, pc); /* generated name */
4079 + return fdopen (fd, "w");
4082 +/* Updates info into .index file: ALL or about selected newsgroup */
4083 +static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4085 + char buf[LONG_STRING], *key = "ALL";
4086 + char file[_POSIX_PATH_MAX];
4088 + if (!serv || !serv->conn || !serv->conn->account.host)
4091 + if (data && data->group)
4093 + key = data->group;
4094 + snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4095 + data->firstMessage, data->lastLoaded);
4099 + strfcpy (file, serv->cache, sizeof (file));
4100 + snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4102 + nntp_cache_expand (file, ".index");
4103 + return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4106 +/* Remove cache files of unsubscribed newsgroups */
4107 +void nntp_clear_cacheindex (NNTP_SERVER *news)
4112 + if (option (OPTSAVEUNSUB) || !news)
4115 + for (tmp = news->list; tmp; tmp = tmp->next)
4117 + data = (NNTP_DATA *) tmp->data;
4118 + if (!data || data->subscribed || !data->cache)
4120 + nntp_delete_cache (data);
4121 + dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4126 +int nntp_save_cache_index (NNTP_SERVER *news)
4128 + char buf[HUGE_STRING];
4129 + char file[_POSIX_PATH_MAX];
4134 + if (!news || !news->newsgroups)
4136 + if (!option (OPTNEWSCACHE))
4141 + nntp_cache_expand (file, news->cache);
4143 + f = safe_fopen (file, "w");
4147 + strfcpy (buf, news->conn->account.host, sizeof(buf));
4148 + f = mutt_mkname (buf);
4149 + news->cache = safe_strdup (buf);
4150 + nntp_cache_expand (file, buf);
4155 + for (l = news->list; l; l = l->next)
4157 + if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4160 + snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4161 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4164 + snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4165 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4166 + if (fputs (buf, f) == EOF)
4176 + if (nntp_update_cacheindex (news, NULL))
4184 +int nntp_save_cache_group (CONTEXT *ctx)
4186 + char buf[HUGE_STRING], addr[STRING];
4187 + char file[_POSIX_PATH_MAX];
4191 + int i = 0, save = SORT_ORDER;
4194 + if (!option (OPTNEWSCACHE))
4196 + if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4199 + if (((NNTP_DATA *)ctx->data)->cache)
4201 + nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4203 + f = safe_fopen (file, "w");
4207 + snprintf (buf, sizeof(buf), "%s-%s",
4208 + ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4209 + ((NNTP_DATA *)ctx->data)->group);
4210 + f = mutt_mkname (buf);
4211 + ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4212 + nntp_cache_expand (file, buf);
4217 + if (Sort != SORT_ORDER)
4220 + Sort = SORT_ORDER;
4221 + mutt_sort_headers (ctx, 0);
4224 + /* Save only $nntp_context messages... */
4225 + ((NNTP_DATA *)ctx->data)->lastCached = 0;
4226 + if (NntpContext && ctx->msgcount > NntpContext)
4227 + i = ctx->msgcount - NntpContext;
4228 + for (; i < ctx->msgcount; i++)
4230 + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4234 + rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4235 + tm = gmtime (&h->date_sent);
4236 + snprintf (buf, sizeof(buf),
4237 + "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4238 + h->article_num, h->env->subject, addr, tm->tm_mday,
4239 + Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4240 + tm->tm_sec, h->env->message_id);
4242 + if (h->env->references)
4243 + mutt_write_references (h->env->references, f);
4244 + snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length,
4245 + (int) h->lines, NONULL(h->env->xref));
4246 + if (fputs (buf, f) == EOF)
4253 + prev = ctx->hdrs[i]->article_num;
4259 + mutt_sort_headers (ctx, 0);
4263 + if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4264 + (NNTP_DATA *)ctx->data))
4269 + ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4273 +void nntp_delete_cache (NNTP_DATA *data)
4275 + char buf[_POSIX_PATH_MAX];
4277 + if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4280 + nntp_cache_expand (buf, data->cache);
4282 + FREE (&data->cache);
4283 + data->lastCached = 0;
4284 + nntp_cache_expand (buf, ".index");
4285 + mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4288 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4292 + if (!news || !news->newsgroups || !group || !*group)
4294 + if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4296 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4297 + data->group = (char *) data + sizeof (NNTP_DATA);
4298 + strcpy (data->group, group);
4299 + data->nserv = news;
4300 + data->deleted = 1;
4301 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4302 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
4303 + hash_insert (news->newsgroups, data->group, data, 0);
4304 + nntp_add_to_list (news, data);
4306 + if (!data->subscribed)
4308 + data->subscribed = 1;
4314 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4318 + if (!news || !news->newsgroups || !group || !*group ||
4319 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4321 + if (data->subscribed)
4323 + data->subscribed = 0;
4324 + if (!option (OPTSAVEUNSUB))
4330 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4334 + if (!news || !news->newsgroups || !group || !*group ||
4335 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4339 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4343 + data->entries[0].first = 1;
4345 + data->entries[0].last = data->lastMessage;
4346 + if (Context && Context->data == data)
4350 + for (x = 0; x < Context->msgcount; x++)
4351 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4356 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4360 + if (!news || !news->newsgroups || !group || !*group ||
4361 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4365 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4369 + data->entries[0].first = 1;
4370 + data->entries[0].last = data->firstMessage - 1;
4371 + if (Context && Context->data == data)
4375 + data->unread = Context->msgcount;
4376 + for (x = 0; x < Context->msgcount; x++)
4377 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4380 + data->unread = data->lastMessage - data->entries[0].last;
4384 +/* this routine gives the first newsgroup with new messages */
4385 +void nntp_buffy (char *s)
4389 + for (list = CurrentNewsSrv->list; list; list = list->next)
4391 + NNTP_DATA *data = (NNTP_DATA *) list->data;
4393 + if (data && data->subscribed && data->unread)
4395 + if (Context && Context->magic == M_NNTP &&
4396 + !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4398 + unsigned int i, unread = 0;
4400 + for (i = 0; i < Context->msgcount; i++)
4401 + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4406 + strcpy (s, data->group);
4411 diff -udprP mutt-1.5.15.orig/nntp.c mutt-1.5.15/nntp.c
4412 --- mutt-1.5.15.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4413 +++ mutt-1.5.15/nntp.c 2007-04-11 17:48:16.000000000 +0300
4416 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4417 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4418 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
4420 + * This program is free software; you can redistribute it and/or modify
4421 + * it under the terms of the GNU General Public License as published by
4422 + * the Free Software Foundation; either version 2 of the License, or
4423 + * (at your option) any later version.
4425 + * This program is distributed in the hope that it will be useful,
4426 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4427 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4428 + * GNU General Public License for more details.
4430 + * You should have received a copy of the GNU General Public License
4431 + * along with this program; if not, write to the Free Software
4432 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4436 +# include "config.h"
4440 +#include "mutt_curses.h"
4444 +#include "rfc1524.h"
4445 +#include "rfc2047.h"
4446 +#include "mailbox.h"
4457 +#include <unistd.h>
4458 +#include <string.h>
4460 +#include <stdlib.h>
4462 +static unsigned int _checked = 0;
4465 +static void nntp_error (const char *where, const char *msg)
4467 + dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4471 +static int nntp_auth (NNTP_SERVER *serv)
4473 + CONNECTION *conn = serv->conn;
4475 + unsigned char flags = conn->account.flags;
4477 + if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4478 + mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4480 + conn->account.flags = flags;
4484 + mutt_message _("Logging in...");
4486 + snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4487 + mutt_socket_write (conn, buf);
4488 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4490 + conn->account.flags = flags;
4495 + /* don't print the password unless we're at the ungodly debugging level */
4496 + if (debuglevel < M_SOCK_LOG_FULL)
4497 + dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4499 + snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4500 + mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4501 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4503 + conn->account.flags = flags;
4507 + if (mutt_strncmp ("281", buf, 3))
4509 + conn->account.flags = flags;
4510 + mutt_error _("Login failed.");
4518 +static int nntp_connect_error (NNTP_SERVER *serv)
4520 + serv->status = NNTP_NONE;
4521 + mutt_socket_close (serv->conn);
4522 + mutt_error _("Server closed connection!");
4527 +static int nntp_connect_and_auth (NNTP_SERVER *serv)
4529 + CONNECTION *conn = serv->conn;
4533 + serv->status = NNTP_NONE;
4535 + if (mutt_socket_open (conn) < 0)
4538 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4539 + return nntp_connect_error (serv);
4541 + if (!mutt_strncmp ("200", buf, 3))
4542 + mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4543 + else if (!mutt_strncmp ("201", buf, 3))
4544 + mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4547 + mutt_socket_close (conn);
4548 + mutt_remove_trailing_ws (buf);
4549 + mutt_error ("%s", buf);
4556 + /* Tell INN to switch to mode reader if it isn't so. Ignore all
4557 + returned codes and messages. */
4558 + mutt_socket_write (conn, "MODE READER\r\n");
4559 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4560 + return nntp_connect_error (serv);
4562 + mutt_socket_write (conn, "STAT\r\n");
4563 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4564 + return nntp_connect_error (serv);
4566 + if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
4568 + serv->status = NNTP_OK;
4572 + rc = nntp_auth (serv);
4574 + return nntp_connect_error (serv);
4577 + mutt_socket_close (conn);
4578 + serv->status = NNTP_BYE;
4583 + mutt_socket_close (conn);
4584 + mutt_error _("Login failed.");
4588 + serv->status = NNTP_OK;
4592 +static int nntp_attempt_features (NNTP_SERVER *serv)
4594 + char buf[LONG_STRING];
4595 + CONNECTION *conn = serv->conn;
4597 + mutt_socket_write (conn, "XOVER\r\n");
4598 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4599 + return nntp_connect_error (serv);
4600 + if (mutt_strncmp ("500", buf, 3))
4601 + serv->hasXOVER = 1;
4603 + mutt_socket_write (conn, "XPAT\r\n");
4604 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4605 + return nntp_connect_error (serv);
4606 + if (mutt_strncmp ("500", buf, 3))
4607 + serv->hasXPAT = 1;
4609 + mutt_socket_write (conn, "LISTGROUP\r\n");
4610 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4611 + return nntp_connect_error (serv);
4612 + if (mutt_strncmp ("500", buf, 3))
4613 + serv->hasLISTGROUP = 1;
4615 + mutt_socket_write (conn, "XGTITLE +\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->hasXGTITLE = 1;
4621 + if (!mutt_strncmp ("282", buf, 3))
4625 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4626 + return nntp_connect_error (serv);
4627 + } while (!(buf[0] == '.' && buf[1] == '\0'));
4633 +static int nntp_open_connection (NNTP_SERVER *serv)
4635 + if (serv->status == NNTP_OK)
4637 + if (serv->status == NNTP_BYE)
4639 + if (nntp_connect_and_auth (serv) < 0)
4641 + if (nntp_attempt_features (serv) < 0)
4646 +static int nntp_reconnect (NNTP_SERVER *serv)
4648 + char buf[SHORT_STRING];
4650 + mutt_socket_close (serv->conn);
4654 + if (nntp_connect_and_auth (serv) == 0)
4657 + snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
4658 + serv->conn->account.host);
4659 + if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
4661 + serv->status = NNTP_BYE;
4667 +/* Send data from line[LONG_STRING] and receive answer to same line */
4668 +static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
4670 + char buf[LONG_STRING];
4673 + if (data->nserv->status == NNTP_BYE)
4680 + mutt_socket_write (data->nserv->conn, line);
4682 + else if (data->group)
4684 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4685 + mutt_socket_write (data->nserv->conn, buf);
4689 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4691 + if (nntp_reconnect (data->nserv) < 0)
4696 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4697 + mutt_socket_write (data->nserv->conn, buf);
4698 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4704 + else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
4708 + strfcpy (line, buf, linelen);
4713 + * This function calls funct(*line, *data) for each received line,
4714 + * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
4717 + * 1 - correct but not performed (may be, have to be continued),
4718 + * -1 - conection lost,
4719 + * -2 - invalid command or execution error,
4720 + * -3 - error in funct(*line, *data).
4722 +static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
4723 + int (*funct) (char *, void *), void *data, int tagged)
4725 + char buf[LONG_STRING];
4729 + size_t lenbuf = 0;
4734 + strfcpy (buf, query, sizeof (buf));
4735 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
4737 + if (buf[0] == '5')
4739 + if (buf[0] != '2')
4744 + inbuf = safe_malloc (sizeof (buf));
4748 + chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
4754 + if (!lenbuf && buf[0] == '.')
4756 + if (buf[1] == '\0')
4761 + if (buf[1] == '.')
4765 + strfcpy (inbuf + lenbuf, p, sizeof (buf));
4767 + if (chunk >= sizeof (buf))
4769 + lenbuf += strlen (p);
4774 + if (msg && ReadInc && (line % ReadInc == 0)) {
4776 + mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
4778 + mutt_message ("%s %d", msg, line);
4781 + if (ret == 0 && funct (inbuf, data) < 0)
4786 + safe_realloc (&inbuf, lenbuf + sizeof (buf));
4789 + funct (NULL, data);
4795 +static int nntp_read_tempfile (char *line, void *file)
4797 + FILE *f = (FILE *)file;
4804 + if (fputc ('\n', f) == EOF)
4810 +static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
4812 + register char *p, *b;
4813 + register char *colon = NULL;
4818 + /* skip to next word */
4820 + while (*b && ((*b == ' ') || (*b == '\t'))) b++;
4823 + /* skip to end of word */
4824 + while (*p && (*p != ' ') && (*p != '\t'))
4839 + nntp_get_status (ctx, h, b, atoi(colon));
4840 + if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
4841 + h->article_num = atoi(colon);
4849 + * 1 if article not found
4850 + * -1 if read or write error on tempfile or socket
4852 +static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
4854 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
4856 + char buf[LONG_STRING];
4857 + char tempfile[_POSIX_PATH_MAX];
4859 + HEADER *h = ctx->hdrs[ctx->msgcount];
4861 + mutt_mktemp (tempfile);
4862 + if (!(f = safe_fopen (tempfile, "w+")))
4866 + snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
4868 + snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
4870 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
4875 + dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
4878 + unlink (tempfile);
4879 + return (ret == -1 ? -1 : 1);
4882 + h->article_num = article_num;
4883 + h->env = mutt_read_rfc822_header (f, h, 0, 0);
4885 + unlink (tempfile);
4887 + if (h->env->xref != NULL)
4888 + nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
4889 + else if (h->article_num == 0 && msgid)
4891 + snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
4892 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
4893 + h->article_num = atoi (buf + 4);
4899 +static int parse_description (char *line, void *n)
4901 +#define news ((NNTP_SERVER *) n)
4902 + register char *d = line;
4907 + while (*d && *d != '\t' && *d != ' ') d++;
4910 + while (*d && (*d == '\t' || *d == ' ')) d++;
4911 + dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
4912 + if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
4913 + mutt_strcmp (d, data->desc))
4915 + FREE (&data->desc);
4916 + data->desc = safe_strdup (d);
4922 +static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
4926 + if (!option (OPTLOADDESC) || !data || !data->nserv)
4929 + /* Get newsgroup description, if we can */
4930 + if (data->nserv->hasXGTITLE)
4931 + snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
4933 + snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
4934 + if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
4937 + nntp_error ("nntp_get_desc()", buf);
4943 + * XOVER returns a tab separated list of:
4944 + * id|subject|from|date|Msgid|references|bytes|lines|xref
4946 + * This has to duplicate some of the functionality of
4947 + * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
4948 + * a limited number of headers which are "parsed" by placement in the list)
4950 +static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
4952 + NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
4956 + hdr->env = mutt_new_envelope();
4957 + hdr->env->newsgroups = safe_strdup (nntp_data->group);
4958 + hdr->content = mutt_new_body();
4959 + hdr->content->type = TYPETEXT;
4960 + hdr->content->subtype = safe_strdup ("plain");
4961 + hdr->content->encoding = ENC7BIT;
4962 + hdr->content->disposition = DISPINLINE;
4963 + hdr->content->length = -1;
4966 + for (x = 0; !done && x < 9; x++)
4968 + /* if from file, need to skip newline character */
4969 + while (*p && *p != '\n' && *p != '\t') p++;
4977 + hdr->article_num = atoi (b);
4978 + nntp_get_status (ctx, hdr, NULL, hdr->article_num);
4981 + hdr->env->subject = safe_strdup (b);
4982 + /* Now we need to do the things which would normally be done in
4983 + * mutt_read_rfc822_header() */
4984 + if (hdr->env->subject)
4986 + regmatch_t pmatch[1];
4988 + rfc2047_decode (&hdr->env->subject);
4990 + if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
4991 + hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
4993 + hdr->env->real_subj = hdr->env->subject;
4997 + rfc822_free_address (&hdr->env->from);
4998 + hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
4999 + rfc2047_decode_adrlist (hdr->env->from);
5002 + hdr->date_sent = mutt_parse_date (b, hdr);
5003 + hdr->received = hdr->date_sent;
5006 + FREE (&hdr->env->message_id);
5007 + hdr->env->message_id = safe_strdup (b);
5010 + mutt_free_list (&hdr->env->references);
5011 + hdr->env->references = mutt_parse_references (b, 0);
5014 + hdr->content->length = atoi (b);
5017 + hdr->lines = atoi (b);
5021 + FREE (&hdr->env->xref);
5022 + b = b + 6; /* skips the "Xref: " */
5023 + hdr->env->xref = safe_strdup (b);
5024 + nntp_parse_xref (ctx, nntp_data->group, b, hdr);
5036 + unsigned int base;
5037 + unsigned int first;
5038 + unsigned int last;
5039 + unsigned short *messages;
5043 +#define fc ((FETCH_CONTEXT *) c)
5044 +static int nntp_fetch_numbers (char *line, void *c)
5050 + num = atoi (line);
5051 + if (num < fc->base || num > fc->last)
5053 + fc->messages[num - fc->base] = 1;
5057 +static int add_xover_line (char *line, void *c)
5059 + unsigned int num, total;
5060 + CONTEXT *ctx = fc->ctx;
5061 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5066 + if (ctx->msgcount >= ctx->hdrmax)
5067 + mx_alloc_memory (ctx);
5068 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5069 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5071 + nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5072 + num = ctx->hdrs[ctx->msgcount]->article_num;
5074 + if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5077 + if (num > data->lastLoaded)
5078 + data->lastLoaded = num;
5079 + num = num - fc->first + 1;
5080 + total = fc->last - fc->first + 1;
5081 + if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5082 + mutt_message ("%s %d/%d", fc->msg, num, total);
5085 + mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5091 +static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5092 + unsigned int last)
5094 + char buf[HUGE_STRING];
5095 + char *msg = _("Fetching message headers...");
5096 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5100 + unsigned int current;
5104 + /* if empty group or nothing to do */
5105 + if (!last || first > last)
5108 + /* fetch list of articles */
5112 + fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5113 + if (nntp_data->nserv->hasLISTGROUP)
5115 + mutt_message _("Fetching list of articles...");
5116 + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5117 + if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5119 + mutt_error (_("LISTGROUP command failed: %s"), buf);
5121 + nntp_error ("nntp_fetch_headers()", buf);
5123 + FREE (&fc.messages);
5129 + for (num = 0; num < last - first + 1; num++)
5130 + fc.messages[num] = 1;
5133 + /* CACHE: must be loaded xover cache here */
5134 + num = nntp_data->lastCached - first + 1;
5135 + if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5137 + nntp_cache_expand (buf, nntp_data->cache);
5138 + mutt_message _("Fetching headers from cache...");
5139 + if ((f = safe_fopen (buf, "r")))
5143 + /* counting number of lines */
5144 + while (fgets (buf, sizeof (buf), f) != NULL)
5147 + while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5149 + oldmsgcount = ctx->msgcount;
5151 + fc.last = first + num - 1;
5153 + while (fgets (buf, sizeof (buf), f) != NULL)
5154 + add_xover_line (buf, &fc);
5156 + nntp_data->lastLoaded = fc.last;
5157 + first = fc.last + 1;
5158 + if (ctx->msgcount > oldmsgcount)
5159 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5162 + nntp_delete_cache (nntp_data);
5164 + num = last - first + 1;
5167 + FREE (&fc.messages);
5172 + * Without XOVER, we have to fetch each article header and parse
5173 + * it. With XOVER, we ask for all of them
5175 + mutt_message (msg);
5176 + if (nntp_data->nserv->hasXOVER)
5178 + oldmsgcount = ctx->msgcount;
5182 + snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5183 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5184 + if (ctx->msgcount > oldmsgcount)
5185 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5188 + mutt_error (_("XOVER command failed: %s"), buf);
5190 + nntp_error ("nntp_fetch_headers()", buf);
5192 + FREE (&fc.messages);
5198 + for (current = first; current <= last; current++)
5202 + ret = current - first + 1;
5203 + mutt_message ("%s %d/%d", msg, ret, num);
5205 + if (!fc.messages[current - fc.base])
5208 + if (ctx->msgcount >= ctx->hdrmax)
5209 + mx_alloc_memory (ctx);
5210 + h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5211 + h->index = ctx->msgcount;
5213 + ret = nntp_read_header (ctx, NULL, current);
5214 + if (ret == 0) /* Got article. Fetch next header */
5216 + nntp_get_status (ctx, h, NULL, h->article_num);
5218 + mx_update_context (ctx, 1);
5221 + mutt_free_header (&h); /* skip it */
5224 + FREE (&fc.messages);
5228 + if (current > nntp_data->lastLoaded)
5229 + nntp_data->lastLoaded = current;
5231 + FREE (&fc.messages);
5232 + nntp_data->lastLoaded = last;
5233 + mutt_clear_error ();
5238 + * currently, nntp "mailbox" is "newsgroup"
5240 +int nntp_open_mailbox (CONTEXT *ctx)
5242 + NNTP_DATA *nntp_data;
5243 + NNTP_SERVER *serv;
5244 + char buf[HUGE_STRING];
5245 + char server[LONG_STRING];
5247 + unsigned int first;
5250 + if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5252 + mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5258 + nntp_expand_path (server, sizeof (server), &acct);
5259 + if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5262 + CurrentNewsSrv = serv;
5264 + /* create NNTP-specific state struct if nof found in list */
5265 + if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5267 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5268 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5269 + strcpy (nntp_data->group, buf);
5270 + hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5271 + nntp_add_to_list (serv, nntp_data);
5273 + ctx->data = nntp_data;
5274 + ctx->mx_close = nntp_fastclose_mailbox;
5275 + nntp_data->nserv = serv;
5277 + mutt_message (_("Selecting %s..."), nntp_data->group);
5279 + if (!nntp_data->desc)
5281 + nntp_get_desc (nntp_data, nntp_data->group, NULL);
5282 + if (nntp_data->desc)
5283 + nntp_save_cache_index (serv);
5287 + if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5290 + nntp_error ("nntp_open_mailbox()", buf);
5295 + if (mutt_strncmp ("211", buf, 3))
5297 + LIST *l = serv->list;
5299 + /* GROUP command failed */
5300 + if (!mutt_strncmp ("411", buf, 3))
5302 + mutt_error (_("Newsgroup %s not found on server %s"),
5303 + nntp_data->group, serv->conn->account.host);
5305 + /* CACHE: delete cache and line from .index */
5306 + nntp_delete_cache (nntp_data);
5307 + hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5308 + while (l && l->data != (void *) nntp_data) l = l->next;
5318 + sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5319 + &nntp_data->lastMessage, buf);
5321 + nntp_data->deleted = 0;
5323 + time (&serv->check_time);
5326 + * Check for max adding context. If it is greater than $nntp_context,
5327 + * strip off extra articles
5329 + first = nntp_data->firstMessage;
5330 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5331 + first = nntp_data->lastMessage - NntpContext + 1;
5333 + nntp_data->lastLoaded = first - 1;
5334 + return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5337 +int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5339 + char buf[LONG_STRING];
5340 + char path[_POSIX_PATH_MAX];
5341 + NNTP_CACHE *cache;
5342 + char *m = _("Fetching message...");
5345 + /* see if we already have the message in our cache */
5346 + cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5348 + /* if everything is fine, assign msg->fp and return */
5349 + if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5350 + (msg->fp = fopen (cache->path, "r")))
5353 + /* clear the previous entry */
5354 + unlink (cache->path);
5355 + free (cache->path);
5359 + cache->index = ctx->hdrs[msgno]->index;
5360 + mutt_mktemp (path);
5361 + cache->path = safe_strdup (path);
5362 + if (!(msg->fp = safe_fopen (path, "w+")))
5364 + FREE (&cache->path);
5368 + if (ctx->hdrs[msgno]->article_num == 0)
5369 + snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5370 + ctx->hdrs[msgno]->env->message_id);
5372 + snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5373 + ctx->hdrs[msgno]->article_num);
5375 + ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5376 + msg->fp, ctx->tagged);
5379 + mutt_error (_("Article %d not found on server"),
5380 + ctx->hdrs[msgno]->article_num);
5381 + dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5388 + FREE (&cache->path);
5392 + mutt_free_envelope (&ctx->hdrs[msgno]->env);
5393 + ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5394 + /* fix content length */
5395 + fseek(msg->fp, 0, SEEK_END);
5396 + ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5397 + ctx->hdrs[msgno]->content->offset;
5399 + /* this is called in mutt before the open which fetches the message,
5400 + * which is probably wrong, but we just call it again here to handle
5401 + * the problem instead of fixing it.
5403 + mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5405 + /* These would normally be updated in mx_update_context(), but the
5406 + * full headers aren't parsed with XOVER, so the information wasn't
5409 +#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5410 + ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5411 +#endif /* HAVE_PGP || HAVE_SMIME */
5413 + mutt_clear_error();
5420 +int nntp_post (const char *msg) {
5421 + char buf[LONG_STRING];
5424 + NNTP_DATA *nntp_data;
5426 + if (Context && Context->magic == M_NNTP)
5427 + nntp_data = (NNTP_DATA *)Context->data;
5430 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5431 + !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5433 + mutt_error (_("Can't post article. No connection to news server."));
5436 + nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5439 + if (!(f = safe_fopen (msg, "r")))
5441 + mutt_error (_("Can't post article. Unable to open %s"), msg);
5445 + strfcpy (buf, "POST\r\n", sizeof (buf));
5446 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5448 + mutt_error (_("Can't post article. Connection to %s lost."),
5449 + nntp_data->nserv->conn->account.host);
5452 + if (buf[0] != '3')
5454 + mutt_error (_("Can't post article: %s"), buf);
5460 + while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5462 + len = strlen (buf);
5463 + if (buf[len - 1] == '\n')
5465 + buf[len - 1] = '\r';
5470 + if (buf[1] == '.')
5471 + mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5473 + mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5477 + if (buf[strlen (buf) - 1] != '\n')
5478 + mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5479 + mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5480 + if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5482 + mutt_error (_("Can't post article. Connection to %s lost."),
5483 + nntp_data->nserv->conn->account.host);
5486 + if (buf[0] != '2')
5488 + mutt_error (_("Can't post article: %s"), buf);
5495 +/* nntp_logout_all: close all open connections. */
5496 +void nntp_logout_all (void)
5498 + char buf[LONG_STRING];
5501 + conn = mutt_socket_head ();
5505 + CONNECTION *next = conn->next;
5507 + if (conn->account.type == M_ACCT_TYPE_NNTP)
5509 + mutt_message (_("Closing connection to %s..."), conn->account.host);
5510 + mutt_socket_write (conn, "QUIT\r\n");
5511 + mutt_socket_readln (buf, sizeof (buf), conn);
5512 + mutt_clear_error ();
5513 + mutt_socket_close (conn);
5514 + mutt_socket_free (conn);
5521 +static void nntp_free_acache (NNTP_DATA *data)
5525 + for (i = 0; i < NNTP_CACHE_LEN; i++)
5527 + if (data->acache[i].path)
5529 + unlink (data->acache[i].path);
5530 + FREE (&data->acache[i].path);
5535 +void nntp_delete_data (void *p)
5537 + NNTP_DATA *data = (NNTP_DATA *)p;
5541 + FREE (&data->entries);
5542 + FREE (&data->desc);
5543 + FREE (&data->cache);
5544 + nntp_free_acache (data);
5548 +int nntp_sync_mailbox (CONTEXT *ctx)
5550 + NNTP_DATA *data = ctx->data;
5552 + /* CACHE: update cache and .index files */
5553 + if ((option (OPTSAVEUNSUB) || data->subscribed))
5554 + nntp_save_cache_group (ctx);
5555 + nntp_free_acache (data);
5557 + data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
5561 +int nntp_fastclose_mailbox (CONTEXT *ctx)
5563 + NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
5567 + nntp_free_acache (data);
5568 + if (!data->nserv || !data->nserv->newsgroups || !data->group)
5570 + nntp_save_cache_index (data->nserv);
5571 + if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
5573 + nntp_delete_data (data);
5577 +/* commit changes and terminate connection */
5578 +int nntp_close_mailbox (CONTEXT *ctx)
5582 + mutt_message _("Quitting newsgroup...");
5585 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
5588 + if (data->nserv && data->nserv->conn && ctx->unread)
5590 + ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
5592 + mutt_newsgroup_catchup (data->nserv, data->group);
5597 + nntp_sync_mailbox (ctx);
5598 + if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
5600 + NNTP_SERVER *news;
5602 + news = ((NNTP_DATA *)ctx->data)->nserv;
5603 + newsrc_gen_entries (ctx);
5604 + ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
5605 + mutt_newsrc_update (news);
5607 + mutt_clear_error();
5611 +/* use the GROUP command to poll for new mail */
5612 +static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
5614 + char buf[LONG_STRING];
5617 + if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
5621 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5624 + nntp_error ("nntp_check_mailbox()", buf);
5628 + if (mutt_strncmp ("211", buf, 3))
5631 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5634 + nntp_error ("nntp_check_mailbox()", buf);
5639 + if (!mutt_strncmp ("211", buf, 3))
5644 + sscanf (buf + 4, "%d %d %d", &count, &first, &last);
5645 + nntp_data->firstMessage = first;
5646 + nntp_data->lastMessage = last;
5647 + if (ctx && last > nntp_data->lastLoaded)
5649 + nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
5650 + time (&nntp_data->nserv->check_time);
5653 + if (!last || (!nntp_data->rc && !nntp_data->lastCached))
5654 + nntp_data->unread = count;
5656 + mutt_newsgroup_stat (nntp_data);
5657 + /* active was renumbered? */
5658 + if (last < nntp_data->lastLoaded)
5660 + if (!nntp_data->max)
5662 + nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
5663 + nntp_data->max = 5;
5665 + nntp_data->lastCached = 0;
5666 + nntp_data->num = 1;
5667 + nntp_data->entries[0].first = 1;
5668 + nntp_data->entries[0].last = 0;
5672 + time (&nntp_data->nserv->check_time);
5676 +int nntp_check_mailbox (CONTEXT *ctx)
5678 + return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
5681 +static int add_group (char *buf, void *serv)
5683 +#define s ((NNTP_SERVER *) serv)
5684 + char group[LONG_STRING], mod, desc[HUGE_STRING];
5686 + NNTP_DATA *nntp_data;
5689 + _checked = n; /* _checked have N, where N = number of groups */
5690 + if (!buf) /* at EOF must be zerouth */
5697 + sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
5700 + if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
5703 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
5704 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5705 + strcpy (nntp_data->group, group);
5706 + nntp_data->nserv = s;
5707 + if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
5708 + s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2);
5709 + hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
5710 + nntp_add_to_list (s, nntp_data);
5712 + nntp_data->deleted = 0;
5713 + nntp_data->firstMessage = first;
5714 + nntp_data->lastMessage = last;
5716 + nntp_data->allowed = 1;
5718 + nntp_data->allowed = 0;
5719 + if (nntp_data->desc)
5720 + FREE (&nntp_data->desc);
5722 + nntp_data->desc = safe_strdup (desc);
5723 + if (nntp_data->rc || nntp_data->lastCached)
5724 + mutt_newsgroup_stat (nntp_data);
5725 + else if (nntp_data->lastMessage &&
5726 + nntp_data->firstMessage <= nntp_data->lastMessage)
5727 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
5729 + nntp_data->unread = 0;
5735 +int nntp_check_newgroups (NNTP_SERVER *serv, int force)
5737 + char buf[LONG_STRING];
5738 + char msg[SHORT_STRING];
5739 + NNTP_DATA nntp_data;
5744 + unsigned int count = 0;
5745 + unsigned int total = 0;
5747 + if (!serv || !serv->newgroups_time)
5750 + if (nntp_open_connection (serv) < 0)
5753 + /* check subscribed groups for new news */
5754 + if (option (OPTSHOWNEWNEWS))
5756 + mutt_message _("Checking for new messages...");
5757 + for (l = serv->list; l; l = l->next)
5759 + serv->check_time = 0; /* really check! */
5760 + if (l->data && ((NNTP_DATA *) l->data)->subscribed)
5761 + _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
5767 + mutt_message _("Checking for new newsgroups...");
5768 + now = serv->newgroups_time;
5769 + time (&serv->newgroups_time);
5770 + t = gmtime (&now);
5771 + snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
5772 + (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
5774 + nntp_data.nserv = serv;
5775 + if (Context && Context->magic == M_NNTP)
5776 + nntp_data.group = ((NNTP_DATA *)Context->data)->group;
5778 + nntp_data.group = NULL;
5780 + if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
5781 + add_group, serv, 0) != 0)
5784 + nntp_error ("nntp_check_newgroups()", buf);
5789 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5790 + mutt_message (msg);
5792 + emp.next = l->next;
5794 + emp.next = serv->list;
5799 + ((NNTP_DATA *) l->data)->new = 1;
5806 + nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
5808 + if (ReadInc && (count % ReadInc == 0))
5809 + mutt_message ("%s %d/%d", msg, count, total);
5812 + nntp_save_cache_index (serv);
5813 + mutt_clear_error ();
5817 +/* Load list of all newsgroups from cache ALL */
5818 +int nntp_get_cache_all (NNTP_SERVER *serv)
5820 + char buf[HUGE_STRING];
5823 + nntp_cache_expand (buf, serv->cache);
5824 + if ((f = safe_fopen (buf, "r")))
5828 + while (fgets (buf, sizeof(buf), f) != NULL)
5830 + if (ReadInc && (i % ReadInc == 0))
5831 + mutt_message (_("Loading list from cache... %d"), i);
5832 + add_group (buf, serv);
5835 + add_group (NULL, NULL);
5837 + mutt_clear_error ();
5842 + FREE (&serv->cache);
5847 +/* Load list of all newsgroups from active */
5848 +int nntp_get_active (NNTP_SERVER *serv)
5850 + char msg[SHORT_STRING];
5851 + NNTP_DATA nntp_data;
5854 + if (nntp_open_connection (serv) < 0)
5857 + snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
5858 + serv->conn->account.host);
5859 + mutt_message (msg);
5860 + time (&serv->newgroups_time);
5861 + nntp_data.nserv = serv;
5862 + nntp_data.group = NULL;
5864 + if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
5867 + nntp_error ("nntp_get_active()", "LIST\r\n");
5872 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5873 + mutt_message (msg);
5874 + nntp_get_desc (&nntp_data, "*", msg);
5876 + for (tmp = serv->list; tmp; tmp = tmp->next)
5878 + NNTP_DATA *data = (NNTP_DATA *)tmp->data;
5880 + if (data && data->deleted && !data->rc)
5882 + nntp_delete_cache (data);
5883 + hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
5887 + nntp_save_cache_index (serv);
5889 + mutt_clear_error ();
5894 + * returns -1 if error ocurred while retrieving header,
5895 + * number of articles which ones exist in context on success.
5897 +int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
5901 + /* if msgid is already in context, don't reload them */
5902 + if (hash_find (ctx->id_hash, msgid))
5904 + if (ctx->msgcount == ctx->hdrmax)
5905 + mx_alloc_memory (ctx);
5906 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5907 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5909 + mutt_message (_("Fetching %s from server..."), msgid);
5910 + ret = nntp_read_header (ctx, msgid, 0);
5911 + /* since nntp_read_header() may set read flag, we must reset it */
5912 + ctx->hdrs[ctx->msgcount]->read = 0;
5914 + mutt_free_header (&ctx->hdrs[ctx->msgcount]);
5918 + mx_update_context (ctx, 1);
5929 + unsigned int *child;
5932 +static int check_children (char *s, void *c)
5934 +#define cc ((CHILD_CONTEXT *) c)
5935 + unsigned int i, n;
5937 + if (!s || (n = atoi (s)) == 0)
5939 + for (i = 0; i < cc->ctx->msgcount; i++)
5940 + if (cc->ctx->hdrs[i]->article_num == n)
5942 + if (cc->num >= cc->max)
5943 + safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
5944 + cc->child[cc->num++] = n;
5950 +int nntp_check_children (CONTEXT *ctx, const char *msgid)
5952 + NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
5954 + int i, ret = 0, tmp = 0;
5957 + if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
5958 + !nntp_data->nserv->conn->account.host)
5960 + if (nntp_data->firstMessage > nntp_data->lastLoaded)
5962 + if (!nntp_data->nserv->hasXPAT)
5964 + mutt_error (_("Server %s does not support this operation!"),
5965 + nntp_data->nserv->conn->account.host);
5969 + snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
5970 + nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
5975 + cc.child = safe_malloc (sizeof (unsigned int) * 25);
5976 + if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
5981 + /* dont try to read the xover cache. check_children() already
5982 + * made sure that we dont have the article, so we need to visit
5983 + * the server. Reading the cache at this point is also bad
5984 + * because it would duplicate messages */
5985 + if (option (OPTNEWSCACHE))
5988 + unset_option (OPTNEWSCACHE);
5990 + for (i = 0; i < cc.num; i++)
5992 + if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
5994 + if (ctx->msgcount &&
5995 + ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
5996 + ctx->hdrs[ctx->msgcount - 1]->read = 0;
5999 + set_option (OPTNEWSCACHE);
6003 diff -udprP mutt-1.5.15.orig/nntp.h mutt-1.5.15/nntp.h
6004 --- mutt-1.5.15.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
6005 +++ mutt-1.5.15/nntp.h 2007-04-11 17:46:58.000000000 +0300
6008 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
6009 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
6010 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
6012 + * This program is free software; you can redistribute it and/or modify
6013 + * it under the terms of the GNU General Public License as published by
6014 + * the Free Software Foundation; either version 2 of the License, or
6015 + * (at your option) any later version.
6017 + * This program is distributed in the hope that it will be useful,
6018 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6019 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6020 + * GNU General Public License for more details.
6022 + * You should have received a copy of the GNU General Public License
6023 + * along with this program; if not, write to the Free Software
6024 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6030 +#include "mutt_socket.h"
6031 +#include "mailbox.h"
6035 +#define NNTP_PORT 119
6036 +#define NNTP_SSL_PORT 563
6038 +/* number of entries in the hash table */
6039 +#define NNTP_CACHE_LEN 10
6056 + unsigned int hasXPAT : 1;
6057 + unsigned int hasXGTITLE : 1;
6058 + unsigned int hasXOVER : 1;
6059 + unsigned int hasLISTGROUP : 1;
6060 + unsigned int status : 3;
6066 + time_t newgroups_time;
6067 + time_t check_time;
6069 + LIST *list; /* list of newsgroups */
6070 + LIST *tail; /* last entry of list */
6076 + unsigned int index;
6082 + NEWSRC_ENTRY *entries;
6083 + unsigned int num; /* number of used entries */
6084 + unsigned int max; /* number of allocated entries */
6085 + unsigned int unread;
6086 + unsigned int firstMessage;
6087 + unsigned int lastMessage;
6088 + unsigned int lastLoaded;
6089 + unsigned int lastCached;
6090 + unsigned int subscribed : 1;
6091 + unsigned int rc : 1;
6092 + unsigned int new : 1;
6093 + unsigned int allowed : 1;
6094 + unsigned int deleted : 1;
6098 + NNTP_SERVER *nserv;
6099 + NNTP_CACHE acache[NNTP_CACHE_LEN];
6102 +/* internal functions */
6103 +int nntp_get_active (NNTP_SERVER *);
6104 +int nntp_get_cache_all (NNTP_SERVER *);
6105 +int nntp_save_cache_index (NNTP_SERVER *);
6106 +int nntp_check_newgroups (NNTP_SERVER *, int);
6107 +int nntp_save_cache_group (CONTEXT *);
6108 +int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6109 +void newsrc_gen_entries (CONTEXT *);
6110 +void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6111 +void mutt_newsgroup_stat (NNTP_DATA *);
6112 +void nntp_delete_cache (NNTP_DATA *);
6113 +void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6114 +void nntp_cache_expand (char *, const char *);
6115 +void nntp_delete_data (void *);
6117 +/* exposed interface */
6118 +NNTP_SERVER *mutt_select_newsserver (char *);
6119 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6120 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6121 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6122 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6123 +void nntp_clear_cacheindex (NNTP_SERVER *);
6124 +int mutt_newsrc_update (NNTP_SERVER *);
6125 +int nntp_open_mailbox (CONTEXT *);
6126 +int nntp_sync_mailbox (CONTEXT *);
6127 +int nntp_check_mailbox (CONTEXT *);
6128 +int nntp_close_mailbox (CONTEXT *);
6129 +int nntp_fastclose_mailbox (CONTEXT *);
6130 +int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6131 +int nntp_post (const char *);
6132 +int nntp_check_msgid (CONTEXT *, const char *);
6133 +int nntp_check_children (CONTEXT *, const char *);
6134 +void nntp_buffy (char *);
6135 +void nntp_expand_path (char *, size_t, ACCOUNT *);
6136 +void nntp_logout_all ();
6137 +const char *nntp_format_str (char *, size_t, char, const char *, const char *,
6138 + const char *, const char *, unsigned long, format_flag);
6140 +NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6142 +#endif /* _NNTP_H_ */
6143 diff -udprP mutt-1.5.15.orig/pager.c mutt-1.5.15/pager.c
6144 --- mutt-1.5.15.orig/pager.c 2007-04-02 00:58:56.000000000 +0300
6145 +++ mutt-1.5.15/pager.c 2007-04-11 17:25:15.000000000 +0300
6146 @@ -1055,6 +1055,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
6156 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6157 int flags, ansi_attr *pa, int cnt,
6158 @@ -1490,6 +1495,16 @@ static struct mapping_t PagerHelpExtra[]
6163 +static struct mapping_t PagerNewsHelpExtra[] = {
6164 + { N_("Post"), OP_POST },
6165 + { N_("Followup"), OP_FOLLOWUP },
6166 + { N_("Del"), OP_DELETE },
6167 + { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6174 /* This pager is actually not so simple as it once was. It now operates in
6175 @@ -1531,6 +1546,10 @@ mutt_pager (const char *banner, const ch
6176 int old_PagerIndexLines; /* some people want to resize it
6177 * while inside the pager... */
6180 + char *followup_to;
6183 if (!(flags & M_SHOWCOLOR))
6184 flags |= M_SHOWFLAT;
6186 @@ -1570,7 +1589,11 @@ mutt_pager (const char *banner, const ch
6187 if (IsHeader (extra))
6189 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6190 - mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6191 + mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6193 + (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6196 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6199 @@ -2393,6 +2416,15 @@ search_next:
6201 CHECK_ACL(M_ACL_WRITE, "flag message");
6204 + if (Context->magic == M_NNTP)
6207 + mutt_error _("Can't change 'important' flag on NNTP server.");
6212 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6213 redraw = REDRAW_STATUS | REDRAW_INDEX;
6214 if (option (OPTRESOLVE))
6215 @@ -2426,6 +2458,60 @@ search_next:
6216 redraw = REDRAW_FULL;
6221 + CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6223 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6224 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6225 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6227 + ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6228 + redraw = REDRAW_FULL;
6231 + case OP_FORWARD_TO_GROUP:
6232 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6234 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6235 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6236 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6238 + if (IsMsgAttach (extra))
6239 + mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6240 + extra->idxlen, extra->bdy, SENDNEWS);
6242 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6243 + redraw = REDRAW_FULL;
6247 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6250 + if (IsMsgAttach (extra))
6251 + followup_to = extra->bdy->hdr->env->followup_to;
6253 + followup_to = extra->hdr->env->followup_to;
6255 + if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6256 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6258 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6259 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6260 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6262 + if (IsMsgAttach (extra))
6263 + mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6264 + extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6266 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6267 + extra->ctx, extra->hdr);
6268 + redraw = REDRAW_FULL;
6274 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6276 @@ -2472,7 +2558,7 @@ search_next:
6278 if (IsMsgAttach (extra))
6279 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6280 - extra->idxlen, extra->bdy);
6281 + extra->idxlen, extra->bdy, 0);
6283 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6284 redraw = REDRAW_FULL;
6285 diff -udprP mutt-1.5.15.orig/parse.c mutt-1.5.15/parse.c
6286 --- mutt-1.5.15.orig/parse.c 2007-04-02 00:58:56.000000000 +0300
6287 +++ mutt-1.5.15/parse.c 2007-04-11 17:25:15.000000000 +0300
6288 @@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
6292 -static LIST *mutt_parse_references (char *s, int in_reply_to)
6293 +LIST *mutt_parse_references (char *s, int in_reply_to)
6295 LIST *t, *lst = NULL;
6297 @@ -1068,6 +1068,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6298 e->from = rfc822_parse_adrlist (e->from, p);
6302 + else if (!mutt_strcasecmp (line+1, "ollowup-to"))
6304 + if (!e->followup_to)
6306 + mutt_remove_trailing_ws (p);
6307 + e->followup_to = safe_strdup (mutt_skip_whitespace (p));
6315 @@ -1152,6 +1163,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6321 + if (!mutt_strcasecmp (line + 1, "ewsgroups"))
6323 + FREE (&e->newsgroups);
6324 + mutt_remove_trailing_ws (p);
6325 + e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
6332 + /* field `Organization:' saves only for pager! */
6333 + if (!mutt_strcasecmp (line + 1, "rganization"))
6335 + if (!e->organization && mutt_strcasecmp (p, "unknown"))
6336 + e->organization = safe_strdup (p);
6341 if (!ascii_strcasecmp (line + 1, "eferences"))
6343 @@ -1260,6 +1292,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6344 e->x_label = safe_strdup(p);
6348 + else if (!mutt_strcasecmp (line + 1, "-comment-to"))
6350 + if (!e->x_comment_to)
6351 + e->x_comment_to = safe_strdup (p);
6354 + else if (!mutt_strcasecmp (line + 1, "ref"))
6357 + e->xref = safe_strdup (p);
6364 diff -udprP mutt-1.5.15.orig/pattern.c mutt-1.5.15/pattern.c
6365 --- mutt-1.5.15.orig/pattern.c 2007-04-02 00:58:56.000000000 +0300
6366 +++ mutt-1.5.15/pattern.c 2007-04-11 17:25:15.000000000 +0300
6367 @@ -91,6 +91,9 @@ Flags[] =
6368 { 'U', M_UNREAD, 0, NULL },
6369 { 'v', M_COLLAPSED, 0, NULL },
6370 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6372 + { 'w', M_NEWSGROUPS, 0, eat_regexp },
6374 { 'x', M_REFERENCE, 0, eat_regexp },
6375 { 'X', M_MIMEATTACH, 0, eat_range },
6376 { 'y', M_XLABEL, 0, eat_regexp },
6377 @@ -1208,6 +1211,10 @@ mutt_pattern_exec (struct pattern_t *pat
6379 case M_UNREFERENCED:
6380 return (pat->not ^ (h->thread && !h->thread->child));
6382 + case M_NEWSGROUPS:
6383 + return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6386 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6388 @@ -1276,6 +1283,7 @@ int mutt_pattern_func (int op, char *pro
6389 progress_t progress;
6391 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6392 + if (prompt || op != M_LIMIT)
6393 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6396 diff -udprP mutt-1.5.15.orig/po/POTFILES.in mutt-1.5.15/po/POTFILES.in
6397 --- mutt-1.5.15.orig/po/POTFILES.in 2007-04-02 00:58:57.000000000 +0300
6398 +++ mutt-1.5.15/po/POTFILES.in 2007-04-11 17:25:15.000000000 +0300
6399 @@ -47,6 +47,8 @@ mutt_ssl_gnutls.c
6408 diff -udprP mutt-1.5.15.orig/postpone.c mutt-1.5.15/postpone.c
6409 --- mutt-1.5.15.orig/postpone.c 2007-04-02 00:58:57.000000000 +0300
6410 +++ mutt-1.5.15/postpone.c 2007-04-11 17:25:15.000000000 +0300
6411 @@ -126,15 +126,26 @@ int mutt_num_postponed (int force)
6413 if (LastModify < st.st_mtime)
6416 + int optnews = option (OPTNEWS);
6418 LastModify = st.st_mtime;
6420 if (access (Postponed, R_OK | F_OK) != 0)
6421 return (PostCount = 0);
6424 + unset_option (OPTNEWS);
6426 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6429 PostCount = ctx.msgcount;
6430 mx_fastclose_mailbox (&ctx);
6433 + set_option (OPTNEWS);
6438 diff -udprP mutt-1.5.15.orig/protos.h mutt-1.5.15/protos.h
6439 --- mutt-1.5.15.orig/protos.h 2007-04-02 00:58:57.000000000 +0300
6440 +++ mutt-1.5.15/protos.h 2007-04-11 17:25:15.000000000 +0300
6441 @@ -104,6 +104,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
6442 HASH *mutt_make_subj_hash (CONTEXT *);
6444 LIST *mutt_make_references(ENVELOPE *e);
6445 +LIST *mutt_parse_references (char *, int);
6447 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6448 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
6449 @@ -246,6 +247,7 @@ void mutt_unblock_signals_system (int);
6450 void mutt_update_encoding (BODY *a);
6451 void mutt_version (void);
6452 void mutt_view_attachments (HEADER *);
6453 +void mutt_write_references (LIST *, FILE *);
6454 void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen, int display);
6455 void mutt_set_virtual (CONTEXT *);
6457 diff -udprP mutt-1.5.15.orig/recvattach.c mutt-1.5.15/recvattach.c
6458 --- mutt-1.5.15.orig/recvattach.c 2007-04-02 00:58:57.000000000 +0300
6459 +++ mutt-1.5.15/recvattach.c 2007-04-11 17:25:15.000000000 +0300
6460 @@ -1087,6 +1087,15 @@ void mutt_view_attachments (HEADER *hdr)
6465 + if (Context->magic == M_NNTP)
6468 + mutt_error _("Can't delete attachment from newsserver.");
6473 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6476 @@ -1178,10 +1187,33 @@ void mutt_view_attachments (HEADER *hdr)
6477 case OP_FORWARD_MESSAGE:
6479 mutt_attach_forward (fp, hdr, idx, idxlen,
6480 - menu->tagprefix ? NULL : idx[menu->current]->content);
6481 + menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6482 menu->redraw = REDRAW_FULL;
6486 + case OP_FORWARD_TO_GROUP:
6488 + mutt_attach_forward (fp, hdr, idx, idxlen,
6489 + menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6490 + menu->redraw = REDRAW_FULL;
6496 + if (!idx[menu->current]->content->hdr->env->followup_to ||
6497 + mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6498 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6500 + mutt_attach_reply (fp, hdr, idx, idxlen,
6501 + menu->tagprefix ? NULL : idx[menu->current]->content,
6502 + SENDNEWS|SENDREPLY);
6503 + menu->redraw = REDRAW_FULL;
6509 case OP_GROUP_REPLY:
6511 diff -udprP mutt-1.5.15.orig/recvcmd.c mutt-1.5.15/recvcmd.c
6512 --- mutt-1.5.15.orig/recvcmd.c 2007-04-02 00:58:57.000000000 +0300
6513 +++ mutt-1.5.15/recvcmd.c 2007-04-11 17:25:15.000000000 +0300
6514 @@ -377,7 +377,7 @@ static BODY ** copy_problematic_attachme
6515 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6516 ATTACHPTR ** idx, short idxlen,
6519 + short nattach, int flags)
6522 short mime_fwd_all = 0;
6523 @@ -523,7 +523,7 @@ _("Can't decode all tagged attachments.
6526 /* now that we have the template, send it. */
6527 - ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6528 + ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6532 @@ -550,7 +550,7 @@ _("Can't decode all tagged attachments.
6535 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6536 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6537 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6539 HEADER *curhdr = NULL;
6541 @@ -655,23 +655,23 @@ static void attach_forward_msgs (FILE *
6543 mutt_free_header (&tmphdr);
6545 - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6546 + ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
6551 void mutt_attach_forward (FILE * fp, HEADER * hdr,
6552 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6553 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6558 if (check_all_msg (idx, idxlen, cur, 0) == 0)
6559 - attach_forward_msgs (fp, hdr, idx, idxlen, cur);
6560 + attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
6563 nattach = count_tagged (idx, idxlen);
6564 - attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
6565 + attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
6569 @@ -729,28 +729,40 @@ attach_reply_envelope_defaults (ENVELOPE
6575 + if ((flags & SENDNEWS))
6577 - if (mutt_fetch_recips (env, curenv, flags) == -1)
6579 + /* in case followup set Newsgroups: with Followup-To: if it present */
6580 + if (!env->newsgroups && curenv &&
6581 + mutt_strcasecmp (curenv->followup_to, "poster"))
6582 + env->newsgroups = safe_strdup (curenv->followup_to);
6587 - for (i = 0; i < idxlen; i++)
6590 - if (idx[i]->content->tagged
6591 - && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6592 + if (mutt_fetch_recips (env, curenv, flags) == -1)
6597 + for (i = 0; i < idxlen; i++)
6599 + if (idx[i]->content->tagged
6600 + && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6605 + if ((flags & SENDLISTREPLY) && !env->to)
6607 + mutt_error _("No mailing lists found!");
6611 + mutt_fix_reply_recipients (env);
6614 - if ((flags & SENDLISTREPLY) && !env->to)
6616 - mutt_error _("No mailing lists found!");
6620 - mutt_fix_reply_recipients (env);
6621 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
6624 @@ -811,6 +823,13 @@ void mutt_attach_reply (FILE * fp, HEADE
6625 char prefix[SHORT_STRING];
6629 + if (flags & SENDNEWS)
6630 + set_option (OPTNEWSSEND);
6632 + unset_option (OPTNEWSSEND);
6635 if (check_all_msg (idx, idxlen, cur, 0) == -1)
6637 nattach = count_tagged (idx, idxlen);
6638 diff -udprP mutt-1.5.15.orig/rfc1524.c mutt-1.5.15/rfc1524.c
6639 --- mutt-1.5.15.orig/rfc1524.c 2007-04-02 00:58:58.000000000 +0300
6640 +++ mutt-1.5.15/rfc1524.c 2007-04-11 17:25:15.000000000 +0300
6641 @@ -569,13 +569,13 @@ int rfc1524_expand_filename (char *namet
6645 -int mutt_rename_file (char *oldfile, char *newfile)
6646 +int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
6650 if (access (oldfile, F_OK) != 0)
6652 - if (access (newfile, F_OK) == 0)
6653 + if (!overwrite && access (newfile, F_OK) == 0)
6655 if ((ofp = fopen (oldfile,"r")) == NULL)
6657 @@ -590,3 +590,8 @@ int mutt_rename_file (char *oldfile, cha
6658 mutt_unlink (oldfile);
6662 +int mutt_rename_file (char *oldfile, char *newfile)
6664 + return _mutt_rename_file (oldfile, newfile, 0);
6666 diff -udprP mutt-1.5.15.orig/rfc1524.h mutt-1.5.15/rfc1524.h
6667 --- mutt-1.5.15.orig/rfc1524.h 2007-04-02 00:58:58.000000000 +0300
6668 +++ mutt-1.5.15/rfc1524.h 2007-04-11 17:25:15.000000000 +0300
6669 @@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char
6670 int rfc1524_expand_filename (char *, char *, char *, size_t);
6671 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
6672 int mutt_rename_file (char *, char *);
6673 +int _mutt_rename_file (char *, char *, int);
6675 #endif /* _RFC1524_H */
6676 diff -udprP mutt-1.5.15.orig/send.c mutt-1.5.15/send.c
6677 --- mutt-1.5.15.orig/send.c 2007-04-02 00:58:58.000000000 +0300
6678 +++ mutt-1.5.15/send.c 2007-04-11 16:07:11.000000000 +0300
6680 #include <sys/types.h>
6688 #include "remailer.h"
6690 @@ -214,17 +218,51 @@ static int edit_address (ADDRESS **a, /*
6694 -static int edit_envelope (ENVELOPE *en)
6695 +static int edit_envelope (ENVELOPE *en, int flags)
6697 char buf[HUGE_STRING];
6698 LIST *uh = UserHeader;
6700 - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6702 - if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6704 - if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6707 + if (option (OPTNEWSSEND))
6709 + if (en->newsgroups)
6710 + strfcpy (buf, en->newsgroups, sizeof (buf));
6713 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
6715 + FREE (&en->newsgroups);
6716 + en->newsgroups = safe_strdup (buf);
6718 + if (en->followup_to)
6719 + strfcpy (buf, en->followup_to, sizeof (buf));
6722 + if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
6724 + FREE (&en->followup_to);
6725 + en->followup_to = safe_strdup (buf);
6727 + if (en->x_comment_to)
6728 + strfcpy (buf, en->x_comment_to, sizeof (buf));
6731 + if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
6733 + FREE (&en->x_comment_to);
6734 + en->x_comment_to = safe_strdup (buf);
6739 + if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6741 + if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6743 + if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6749 @@ -260,6 +298,14 @@ static int edit_envelope (ENVELOPE *en)
6754 +char *nntp_get_header (const char *s)
6757 + return safe_strdup (s);
6761 static void process_user_recips (ENVELOPE *env)
6763 LIST *uh = UserHeader;
6764 @@ -272,6 +318,14 @@ static void process_user_recips (ENVELOP
6765 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
6766 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
6767 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
6769 + else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
6770 + env->newsgroups = nntp_get_header (uh->data + 11);
6771 + else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
6772 + env->followup_to = nntp_get_header (uh->data + 12);
6773 + else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
6774 + env->x_comment_to = nntp_get_header (uh->data + 13);
6779 @@ -302,6 +356,12 @@ static void process_user_header (ENVELOP
6780 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
6781 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
6782 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
6784 + ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
6785 + ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
6786 + ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
6788 + ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
6789 ascii_strncasecmp ("subject:", uh->data, 8) != 0)
6792 @@ -645,6 +705,10 @@ void mutt_add_to_reference_headers (ENVE
6797 + if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
6798 + env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
6803 @@ -701,6 +765,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
6805 if (flags & SENDREPLY)
6808 + if ((flags & SENDNEWS))
6810 + /* in case followup set Newsgroups: with Followup-To: if it present */
6811 + if (!env->newsgroups && curenv &&
6812 + mutt_strcasecmp (curenv->followup_to, "poster"))
6813 + env->newsgroups = safe_strdup (curenv->followup_to);
6820 @@ -847,7 +921,18 @@ void mutt_set_followup_to (ENVELOPE *e)
6821 * it hasn't already been set
6824 - if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
6825 + if (!option (OPTFOLLOWUPTO))
6828 + if (option (OPTNEWSSEND))
6830 + if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
6831 + e->followup_to = safe_strdup (e->newsgroups);
6836 + if (!e->mail_followup_to)
6838 if (mutt_is_list_cc (0, e->to, e->cc))
6840 @@ -1008,6 +1093,9 @@ static int send_message (HEADER *msg)
6845 + if (!option (OPTNEWSSEND))
6846 +#endif /* USE_NNTP */
6848 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
6849 msg->env->bcc, tempfile,
6850 @@ -1100,6 +1188,13 @@ ci_send_message (int flags, /* send mod
6855 + if (flags & SENDNEWS)
6856 + set_option (OPTNEWSSEND);
6858 + unset_option (OPTNEWSSEND);
6861 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
6862 mutt_num_postponed (1))
6864 @@ -1130,6 +1225,22 @@ ci_send_message (int flags, /* send mod
6866 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
6870 + * If postponed message is a news article, it have
6871 + * a "Newsgroups:" header line, then set appropriate flag.
6873 + if (msg->env->newsgroups)
6875 + flags |= SENDNEWS;
6876 + set_option (OPTNEWSSEND);
6880 + flags &= ~SENDNEWS;
6881 + unset_option (OPTNEWSSEND);
6886 if (flags & (SENDPOSTPONED|SENDRESEND))
6887 @@ -1237,11 +1348,16 @@ ci_send_message (int flags, /* send mod
6888 if (flags & SENDREPLY)
6889 mutt_fix_reply_recipients (msg->env);
6892 + if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
6893 + msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
6896 if (! (flags & SENDMAILX) &&
6897 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
6898 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
6900 - if (edit_envelope (msg->env) == -1)
6901 + if (edit_envelope (msg->env, flags) == -1)
6905 @@ -1495,6 +1611,11 @@ main_loop:
6910 + if (flags & SENDNEWS)
6911 + mutt_message _("Article not posted.");
6914 mutt_message _("Mail not sent.");
6917 @@ -1527,6 +1648,9 @@ main_loop:
6922 + if (!(flags & SENDNEWS))
6924 if (!msg->env->to && !msg->env->cc && !msg->env->bcc)
6926 if (! (flags & SENDBATCH))
6927 @@ -1559,6 +1683,19 @@ main_loop:
6928 mutt_error _("No subject specified.");
6932 + if ((flags & SENDNEWS) && !msg->env->subject)
6934 + mutt_error _("No subject specified.");
6938 + if ((flags & SENDNEWS) && !msg->env->newsgroups)
6940 + mutt_error _("No newsgroup specified.");
6945 if (msg->content->next)
6946 msg->content = mutt_make_multipart (msg->content);
6947 @@ -1764,7 +1901,12 @@ full_fcc:
6950 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
6951 - mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
6952 + mutt_message (i != 0 ? _("Sending in background.") :
6954 + (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
6959 if (WithCrypto && (msg->security & ENCRYPT))
6961 diff -udprP mutt-1.5.15.orig/sendlib.c mutt-1.5.15/sendlib.c
6962 --- mutt-1.5.15.orig/sendlib.c 2007-04-03 20:52:56.000000000 +0300
6963 +++ mutt-1.5.15/sendlib.c 2007-04-11 17:25:15.000000000 +0300
6965 #include <sys/wait.h>
6972 #ifdef HAVE_SYSEXITS_H
6973 #include <sysexits.h>
6974 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
6975 @@ -1525,7 +1529,7 @@ void mutt_write_address_list (ADDRESS *a
6976 /* need to write the list in reverse because they are stored in reverse order
6977 * when parsed to speed up threading
6979 -static void write_references (LIST *r, FILE *f)
6980 +void mutt_write_references (LIST *r, FILE *f)
6983 int refcnt = 0, refmax = 0;
6984 @@ -1742,6 +1746,9 @@ int mutt_write_rfc822_header (FILE *fp,
6985 LIST *tmp = env->userhdrs;
6986 int has_agent = 0; /* user defined user-agent header field exists */
6989 + if (!option (OPTNEWSSEND))
6991 if (mode == 0 && !privacy)
6992 fputs (mutt_make_date (buffer, sizeof(buffer)), fp);
6994 @@ -1768,6 +1775,9 @@ int mutt_write_rfc822_header (FILE *fp,
6995 mutt_write_address_list (env->to, fp, 4, 0);
6999 + if (!option (OPTNEWSSEND))
7001 fputs ("To: \n", fp);
7004 @@ -1776,6 +1786,9 @@ int mutt_write_rfc822_header (FILE *fp,
7005 mutt_write_address_list (env->cc, fp, 4, 0);
7009 + if (!option (OPTNEWSSEND))
7011 fputs ("Cc: \n", fp);
7014 @@ -1787,8 +1800,28 @@ int mutt_write_rfc822_header (FILE *fp,
7019 + if (!option (OPTNEWSSEND))
7021 fputs ("Bcc: \n", fp);
7024 + if (env->newsgroups)
7025 + fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
7026 + else if (mode == 1 && option (OPTNEWSSEND))
7027 + fputs ("Newsgroups: \n", fp);
7029 + if (env->followup_to)
7030 + fprintf (fp, "Followup-To: %s\n", env->followup_to);
7031 + else if (mode == 1 && option (OPTNEWSSEND))
7032 + fputs ("Followup-To: \n", fp);
7034 + if (env->x_comment_to)
7035 + fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
7036 + else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
7037 + fputs ("X-Comment-To: \n", fp);
7041 mutt_write_one_header (fp, "Subject", env->subject, NULL, 0);
7043 @@ -1807,6 +1840,9 @@ int mutt_write_rfc822_header (FILE *fp,
7044 fputs ("Reply-To: \n", fp);
7046 if (env->mail_followup_to)
7048 + if (!option (OPTNEWSSEND))
7051 fputs ("Mail-Followup-To: ", fp);
7052 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
7053 @@ -1817,7 +1853,7 @@ int mutt_write_rfc822_header (FILE *fp,
7054 if (env->references)
7056 fputs ("References:", fp);
7057 - write_references (env->references, fp);
7058 + mutt_write_references (env->references, fp);
7062 @@ -1829,7 +1865,7 @@ int mutt_write_rfc822_header (FILE *fp,
7063 if (env->in_reply_to)
7065 fputs ("In-Reply-To:", fp);
7066 - write_references (env->in_reply_to, fp);
7067 + mutt_write_references (env->in_reply_to, fp);
7071 @@ -2145,11 +2181,30 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7072 const char *msg, /* file containing message */
7073 int eightbit) /* message contains 8bit chars */
7075 - char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
7076 + char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
7078 size_t argslen = 0, argsmax = 0;
7082 + if (option (OPTNEWSSEND))
7084 + char cmd[LONG_STRING];
7086 + mutt_FormatString (cmd, sizeof (cmd), NONULL (Inews), nntp_format_str, 0, 0);
7089 + i = nntp_post (msg);
7094 + s = safe_strdup (cmd);
7098 + s = safe_strdup (Sendmail);
7102 while ((ps = strtok (ps, " ")))
7103 @@ -2173,6 +2228,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7108 + if (!option (OPTNEWSSEND))
7111 if (eightbit && option (OPTUSE8BITMIME))
7112 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7114 @@ -2204,6 +2263,9 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7115 args = add_args (args, &argslen, &argsmax, to);
7116 args = add_args (args, &argslen, &argsmax, cc);
7117 args = add_args (args, &argslen, &argsmax, bcc);
7122 if (argslen == argsmax)
7123 safe_realloc (&args, sizeof (char *) * (++argsmax));
7124 @@ -2336,6 +2398,9 @@ void mutt_prepare_envelope (ENVELOPE *en
7125 rfc2047_encode_adrlist (env->reply_to, "Reply-To");
7129 + if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
7132 rfc2047_encode_string (&env->subject);
7134 @@ -2441,6 +2506,10 @@ int mutt_bounce_message (FILE *fp, HEADE
7136 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
7139 + unset_option (OPTNEWSSEND);
7142 ret = _mutt_bounce_message (fp, h, to, resent_from, from);
7144 rfc822_free_address (&from);
7145 diff -udprP mutt-1.5.15.orig/sort.c mutt-1.5.15/sort.c
7146 --- mutt-1.5.15.orig/sort.c 2007-04-02 00:58:58.000000000 +0300
7147 +++ mutt-1.5.15/sort.c 2007-04-11 17:25:15.000000000 +0300
7148 @@ -149,6 +149,15 @@ int compare_order (const void *a, const
7149 HEADER **ha = (HEADER **) a;
7150 HEADER **hb = (HEADER **) b;
7153 + if ((*ha)->article_num && (*hb)->article_num)
7155 + int result = (*ha)->article_num - (*hb)->article_num;
7156 + AUXSORT(result,a,b);
7157 + return (SORTCODE (result));
7161 /* no need to auxsort because you will never have equality here */
7162 return (SORTCODE ((*ha)->index - (*hb)->index));
7164 diff -udprP mutt-1.5.15.orig/url.c mutt-1.5.15/url.c
7165 --- mutt-1.5.15.orig/url.c 2007-04-02 00:58:58.000000000 +0300
7166 +++ mutt-1.5.15/url.c 2007-04-11 17:25:15.000000000 +0300
7167 @@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] =
7168 { "imaps", U_IMAPS },
7171 + { "news", U_NNTP },
7172 + { "newss", U_NNTPS },
7173 { "mailto", U_MAILTO },
7175 { "smtps", U_SMTPS },
7176 diff -udprP mutt-1.5.15.orig/url.h mutt-1.5.15/url.h
7177 --- mutt-1.5.15.orig/url.h 2007-04-02 00:58:58.000000000 +0300
7178 +++ mutt-1.5.15/url.h 2007-04-11 17:25:15.000000000 +0300
7179 @@ -8,6 +8,8 @@ typedef enum url_scheme
7188 diff -udprP mutt-1.5.15.orig/Makefile.am mutt-1.5.15/Makefile.am
7189 --- mutt-1.5.15.orig/Makefile.am 2007-04-06 23:04:45.000000000 +0300
7190 +++ mutt-1.5.15/Makefile.am 2007-04-11 17:25:15.000000000 +0300
7191 @@ -62,6 +62,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
7192 smtp.c browser.h mbyte.h remailer.h url.h \
7193 crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
7194 pgppacket.c mutt_idna.h hcache.h hcache.c bcache.c bcache.h mutt_ssl_gnutls.c \
7196 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c \
7199 @@ -73,6 +74,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7200 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7201 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7202 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7203 + nntp.h ChangeLog.nntp \
7204 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7205 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
7206 makedoc.c makedoc-defs.h stamp-doc-rc README.SSL smime.h \
7207 diff -udprP mutt-1.5.15.orig/Makefile.in mutt-1.5.15/Makefile.in
7208 --- mutt-1.5.15.orig/Makefile.in 2007-04-06 23:05:40.000000000 +0300
7209 +++ mutt-1.5.15/Makefile.in 2007-04-11 17:25:15.000000000 +0300
7210 @@ -330,6 +330,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
7211 smtp.c browser.h mbyte.h remailer.h url.h \
7212 crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
7213 pgppacket.c mutt_idna.h hcache.h hcache.c bcache.c bcache.h mutt_ssl_gnutls.c \
7215 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c \
7218 @@ -341,6 +342,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7219 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7220 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7221 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7222 + nntp.h ChangeLog.nntp \
7223 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7224 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
7225 makedoc.c makedoc-defs.h stamp-doc-rc README.SSL smime.h \
7226 @@ -554,6 +556,8 @@ distclean-compile:
7227 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@
7228 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@
7229 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@
7230 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@
7231 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@
7232 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@
7233 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
7234 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@
7235 diff -udprP mutt-1.5.15.orig/Muttrc mutt-1.5.15/Muttrc
7236 --- mutt-1.5.15.orig/Muttrc 2007-04-06 23:34:36.000000000 +0300
7237 +++ mutt-1.5.15/Muttrc 2007-04-11 18:20:29.000000000 +0300
7238 @@ -263,6 +263,28 @@ attachments -I message/external-body
7242 +# set ask_follow_up=no
7244 +# Name: ask_follow_up
7249 +# If set, Mutt will prompt you for follow-up groups before editing
7250 +# the body of an outgoing message.
7253 +# set ask_x_comment_to=no
7255 +# Name: ask_x_comment_to
7260 +# If set, Mutt will prompt you for x-comment-to field before editing
7261 +# the body of an outgoing message.
7264 # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
7266 # Name: attach_format
7267 @@ -430,6 +452,17 @@ attachments -I message/external-body
7268 # access time when checking for new mail.
7271 +# set catchup_newsgroup=ask-yes
7273 +# Name: catchup_newsgroup
7278 +# If this variable is set, Mutt will mark all articles in newsgroup
7279 +# as read when you quit the newsgroup (catchup newsgroup).
7285 @@ -927,6 +960,19 @@ attachments -I message/external-body
7286 # of the same email for you.
7289 +# set followup_to_poster=ask-yes
7291 +# Name: followup_to_poster
7296 +# If this variable is set and the keyword "poster" is present in
7297 +# Followup-To header, follow-up to newsgroup function is not
7298 +# permitted. The message will be mailed to the submitter of the
7299 +# message via mail.
7305 @@ -1024,6 +1070,28 @@ attachments -I message/external-body
7306 # "Franklin" to "Franklin, Steve".
7309 +# set group_index_format="%4C %M%N %5s %-45.45f %d"
7311 +# Name: group_index_format
7313 +# Default: "%4C %M%N %5s %-45.45f %d"
7316 +# This variable allows you to customize the newsgroup browser display to
7317 +# your personal taste. This string is similar to ``index_format'', but
7318 +# has its own set of printf()-like sequences:
7320 +# %C current newsgroup number
7321 +# %d description of newsgroup (becomes from server)
7322 +# %f newsgroup name
7323 +# %M - if newsgroup not allowed for direct post (moderated for example)
7324 +# %N N if newsgroup is new, u if unsubscribed, blank otherwise
7325 +# %n number of new articles in newsgroup
7326 +# %s number of unread articles in newsgroup
7327 +# %>X right justify the rest of the string and pad with character "X"
7328 +# %|X pad to the end of the line with character "X"
7334 @@ -1469,6 +1537,7 @@ attachments -I message/external-body
7335 # %E number of messages in current thread
7336 # %f entire From: line (address + real name)
7337 # %F author name, or recipient name if the message is from you
7338 +# %g newsgroup name (if compiled with nntp support)
7339 # %H spam attribute(s) of this message
7340 # %i message-id of the current message
7341 # %l number of lines in the message (does not work with maildir,
7342 @@ -1482,12 +1551,14 @@ attachments -I message/external-body
7343 # %n author's real name (or address if missing)
7344 # %O (_O_riginal save folder) Where mutt would formerly have
7345 # stashed the message: list name or recipient name if no list
7346 +# %R `x-comment-to:' field (if present and compiled with nntp support)
7347 # %s subject of the message
7348 # %S status of the message (N/D/d/!/r/*)
7349 # %t `to:' field (recipients)
7350 # %T the appropriate character from the $to_chars string
7351 # %u user (login) name of the author
7352 # %v first name of the author, or the recipient if the message is from you
7353 +# %W name of organization of author (`organization:' field)
7354 # %X number of attachments
7355 # (please see the ``attachments'' section for possible speed effects)
7356 # %y `x-label:' field, if present
7357 @@ -1513,6 +1584,22 @@ attachments -I message/external-body
7358 # See also: ``$to_chars''.
7368 +# If set, specifies the program and arguments used to deliver news posted
7369 +# by Mutt. Otherwise, mutt posts article using current connection to
7370 +# news server. The following printf-style sequence is understood:
7372 +# %s newsserver name
7374 +# Example: set inews="/usr/local/bin/inews -hS"
7377 # set ispell="ispell"
7380 @@ -1856,6 +1943,18 @@ attachments -I message/external-body
7381 # be attached to the newly composed message if this option is set.
7384 +# set mime_subject=yes
7386 +# Name: mime_subject
7391 +# If unset, 8-bit ``subject:'' line in article header will not be
7392 +# encoded according to RFC2047 to base64. This is useful when message
7393 +# is Usenet article, because MIME for news is nonstandard feature.
7396 # set mix_entry_format="%4n %c %-16s %a"
7398 # Name: mix_entry_format
7399 @@ -1948,6 +2047,118 @@ attachments -I message/external-body
7400 # See also ``$read_inc'' and ``$write_inc''.
7403 +# set news_cache_dir="~/.mutt"
7405 +# Name: news_cache_dir
7407 +# Default: "~/.mutt"
7410 +# This variable pointing to directory where Mutt will save cached news
7411 +# articles headers in. If unset, headers will not be saved at all
7412 +# and will be reloaded each time when you enter to newsgroup.
7415 +# set news_server=""
7417 +# Name: news_server
7422 +# This variable specifies domain name or address of NNTP server. It
7423 +# defaults to the newsserver specified in the environment variable
7424 +# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
7425 +# specify username and an alternative port for each newsserver, ie:
7427 +# [news[s]://][username[:password]@]newsserver[:port]
7430 +# set newsrc="~/.newsrc"
7434 +# Default: "~/.newsrc"
7437 +# The file, containing info about subscribed newsgroups - names and
7438 +# indexes of read articles. The following printf-style sequence
7441 +# %s newsserver name
7444 +# set nntp_context=1000
7446 +# Name: nntp_context
7451 +# This variable defines number of articles which will be in index when
7452 +# newsgroup entered. If active newsgroup have more articles than this
7453 +# number, oldest articles will be ignored. Also controls how many
7454 +# articles headers will be saved in cache when you quit newsgroup.
7457 +# set nntp_load_description=yes
7459 +# Name: nntp_load_description
7464 +# This variable controls whether or not descriptions for each newsgroup
7465 +# must be loaded when newsgroup is added to list (first time list
7466 +# loading or new newsgroup adding).
7476 +# Your login name on the NNTP server. If unset and NNTP server requires
7477 +# authentification, Mutt will prompt you for your account name when you
7478 +# connect to newsserver.
7488 +# Your password for NNTP account.
7498 +# The time in seconds until any operations on newsgroup except post new
7499 +# article will cause recheck for new news. If set to 0, Mutt will
7500 +# recheck newsgroup on each operation in index (stepping, read article,
7504 +# set nntp_reconnect=ask-yes
7506 +# Name: nntp_reconnect
7511 +# Controls whether or not Mutt will try to reconnect to newsserver when
7515 # set pager="builtin"
7518 @@ -3151,6 +3362,19 @@ attachments -I message/external-body
7519 # string after the inclusion of a message which is being replied to.
7522 +# set post_moderated=ask-yes
7524 +# Name: post_moderated
7529 +# If set to yes, Mutt will post article to newsgroup that have
7530 +# not permissions to posting (e.g. moderated). Note: if newsserver
7531 +# does not support posting to that newsgroup or totally read-only, that
7532 +# posting will not have an effect.
7535 # set postpone=ask-yes
7538 @@ -3676,6 +3900,41 @@ attachments -I message/external-body
7539 # shell from /etc/passwd is used.
7542 +# set save_unsubscribed=no
7544 +# Name: save_unsubscribed
7549 +# When set, info about unsubscribed newsgroups will be saved into
7550 +# ``newsrc'' file and into cache.
7553 +# set show_new_news=yes
7555 +# Name: show_new_news
7560 +# If set, newsserver will be asked for new newsgroups on entering
7561 +# the browser. Otherwise, it will be done only once for a newsserver.
7562 +# Also controls whether or not number of new articles of subscribed
7563 +# newsgroups will be then checked.
7566 +# set show_only_unread=no
7568 +# Name: show_only_unread
7573 +# If set, only subscribed newsgroups that contain unread articles
7574 +# will be displayed in browser.
7577 # set sig_dashes=yes
7580 @@ -4374,3 +4633,14 @@ attachments -I message/external-body
7584 +# set x_comment_to=no
7586 +# Name: x_comment_to
7591 +# If set, Mutt will add ``X-Comment-To:'' field (that contains full
7592 +# name of original article author) to article that followuped to newsgroup.
7595 diff -udprP mutt-1.5.15.orig/configure mutt-1.5.15/configure
7596 --- mutt-1.5.15.orig/configure 2007-04-06 10:17:16.000000000 +0300
7597 +++ mutt-1.5.15/configure 2007-04-11 17:25:15.000000000 +0300
7598 @@ -1341,6 +1341,7 @@ Optional Features:
7599 Force use of an external dotlock program
7600 --enable-pop Enable POP3 support
7601 --enable-imap Enable IMAP support
7602 + --enable-nntp Enable NNTP support
7603 --enable-smtp include internal SMTP relay support
7604 --enable-debug Enable debugging support
7605 --enable-flock Use flock() to lock files
7606 @@ -13918,6 +13919,20 @@ fi
7610 +# Check whether --enable-nntp or --disable-nntp was given.
7611 +if test "${enable_nntp+set}" = set; then
7612 + enableval="$enable_nntp"
7613 + if test x$enableval = xyes ; then
7614 + cat >>confdefs.h <<\_ACEOF
7618 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
7626 for ac_func in strftime