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 @@ -101,6 +105,14 @@ struct binding_t OpMain[] = { /* map: in
2142 { "edit-type", OP_EDIT_TYPE, "\005" },
2143 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2144 { "flag-message", OP_FLAG_MESSAGE, "F" },
2146 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2147 + { "followup-message", OP_FOLLOWUP, "\033f" },
2148 + { "get-children", OP_GET_CHILDREN, NULL },
2149 + { "get-message", OP_GET_MESSAGE, "\007" },
2150 + { "get-parent", OP_GET_PARENT, "\033G" },
2151 + { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2153 { "group-reply", OP_GROUP_REPLY, "g" },
2155 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2156 @@ -126,6 +138,9 @@ struct binding_t OpMain[] = { /* map: in
2157 { "sort-mailbox", OP_SORT, "o" },
2158 { "sort-reverse", OP_SORT_REVERSE, "O" },
2159 { "print-message", OP_PRINT, "p" },
2161 + { "post-message", OP_POST, "\033m" },
2163 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2164 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2165 { "recall-message", OP_RECALL_MESSAGE, "R" },
2166 @@ -145,6 +160,10 @@ struct binding_t OpMain[] = { /* map: in
2167 { "show-version", OP_VERSION, "V" },
2168 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2169 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2170 + { "toggle-read", OP_TOGGLE_READ, "X" },
2172 + { "catchup", OP_CATCHUP, "y" },
2174 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2175 { "buffy-list", OP_BUFFY_LIST, "." },
2176 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
2177 @@ -176,6 +195,10 @@ struct binding_t OpPager[] = { /* map: p
2178 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2179 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2180 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2182 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2183 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2185 { "copy-message", OP_COPY_MESSAGE, "C" },
2186 { "decode-copy", OP_DECODE_COPY, "\033C" },
2187 { "delete-message", OP_DELETE, "d" },
2188 @@ -183,6 +206,10 @@ struct binding_t OpPager[] = { /* map: p
2189 { "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" },
2190 { "edit", OP_EDIT_MESSAGE, "e" },
2191 { "edit-type", OP_EDIT_TYPE, "\005" },
2193 + { "followup-message", OP_FOLLOWUP, "\033f" },
2194 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2196 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2197 { "flag-message", OP_FLAG_MESSAGE, "F" },
2198 { "group-reply", OP_GROUP_REPLY, "g" },
2199 @@ -203,6 +230,9 @@ struct binding_t OpPager[] = { /* map: p
2200 { "next-thread", OP_MAIN_NEXT_THREAD, "\016" },
2201 { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" },
2202 { "print-message", OP_PRINT, "p" },
2204 + { "post-message", OP_POST, "\033m" },
2206 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2207 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2208 { "quit", OP_QUIT, "Q" },
2209 @@ -270,6 +300,10 @@ struct binding_t OpAttach[] = { /* map:
2210 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2211 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2212 { "edit-type", OP_EDIT_TYPE, "\005" },
2214 + { "followup-message", OP_FOLLOWUP, "F" },
2215 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2217 { "print-entry", OP_PRINT, "p" },
2218 { "save-entry", OP_SAVE, "s" },
2219 { "pipe-entry", OP_PIPE, "|" },
2220 @@ -295,6 +329,7 @@ struct binding_t OpAttach[] = { /* map:
2221 struct binding_t OpCompose[] = { /* map: compose */
2222 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2223 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2224 + { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2225 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2226 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2227 { "copy-file", OP_SAVE, "C" },
2228 @@ -314,6 +349,11 @@ struct binding_t OpCompose[] = { /* map:
2229 { "print-entry", OP_PRINT, "l" },
2230 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2231 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2233 + { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2234 + { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2235 + { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2237 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2238 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2239 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
2240 @@ -365,14 +405,25 @@ struct binding_t OpBrowser[] = { /* map:
2241 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2242 { "check-new", OP_CHECK_NEW, NULL },
2243 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2245 + { "reload-active", OP_LOAD_ACTIVE, "g" },
2246 + { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2247 + { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2248 + { "catchup", OP_CATCHUP, "y" },
2249 + { "uncatchup", OP_UNCATCHUP, "Y" },
2251 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2252 { "buffy-list", OP_BUFFY_LIST, "." },
2254 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2255 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2256 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2258 +#if defined USE_IMAP || defined USE_NNTP
2259 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2260 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2263 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2266 diff -udprP mutt-1.5.15.orig/globals.h mutt-1.5.15/globals.h
2267 --- mutt-1.5.15.orig/globals.h 2007-04-05 19:04:56.000000000 +0300
2268 +++ mutt-1.5.15/globals.h 2007-04-11 17:25:15.000000000 +0300
2269 @@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
2272 WHERE char *Muttrc INITVAL (NULL);
2274 +WHERE char *NewsCacheDir;
2275 +WHERE char *GroupFormat;
2277 +WHERE char *NewsServer;
2278 +WHERE char *NntpUser;
2279 +WHERE char *NntpPass;
2280 +WHERE char *NewsRc;
2284 WHERE char *PagerFmt;
2285 @@ -189,6 +198,11 @@ extern unsigned char QuadOptions[];
2287 WHERE unsigned short Counter INITVAL (0);
2290 +WHERE short NewsPollTimeout;
2291 +WHERE short NntpContext;
2294 WHERE short ConnectTimeout;
2295 WHERE short HistSize;
2296 WHERE short MenuContext;
2297 diff -udprP mutt-1.5.15.orig/hash.c mutt-1.5.15/hash.c
2298 --- mutt-1.5.15.orig/hash.c 2007-04-02 00:58:56.000000000 +0300
2299 +++ mutt-1.5.15/hash.c 2007-04-11 17:25:15.000000000 +0300
2300 @@ -51,10 +51,35 @@ HASH *hash_create (int nelem)
2303 table->nelem = nelem;
2304 + table->curnelem = 0;
2305 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2309 +HASH *hash_resize (HASH *ptr, int nelem)
2312 + struct hash_elem *elem, *tmp;
2315 + table = hash_create (nelem);
2317 + for (i = 0; i < ptr->nelem; i++)
2319 + for (elem = ptr->table[i]; elem; )
2322 + elem = elem->next;
2323 + hash_insert (table, tmp->key, tmp->data, 1);
2327 + FREE (&ptr->table);
2333 /* table hash table to update
2334 * key key to hash on
2335 * data data to associate with `key'
2336 @@ -74,6 +99,7 @@ int hash_insert (HASH * table, const cha
2338 ptr->next = table->table[h];
2339 table->table[h] = ptr;
2340 + table->curnelem++;
2344 @@ -96,6 +122,7 @@ int hash_insert (HASH * table, const cha
2346 table->table[h] = ptr;
2348 + table->curnelem++;
2352 @@ -126,6 +153,7 @@ void hash_delete_hash (HASH * table, int
2354 destroy (ptr->data);
2356 + table->curnelem--;
2360 diff -udprP mutt-1.5.15.orig/hash.h mutt-1.5.15/hash.h
2361 --- mutt-1.5.15.orig/hash.h 2007-04-02 00:58:56.000000000 +0300
2362 +++ mutt-1.5.15/hash.h 2007-04-11 17:25:15.000000000 +0300
2363 @@ -28,7 +28,7 @@ struct hash_elem
2368 + int nelem, curnelem;
2369 struct hash_elem **table;
2372 @@ -40,6 +40,7 @@ HASH;
2373 HASH *hash_create (int nelem);
2374 int hash_string (const unsigned char *s, int n);
2375 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2376 +HASH *hash_resize (HASH * table, int nelem);
2377 void *hash_find_hash (const HASH * table, int hash, const char *key);
2378 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2379 void (*destroy) (void *));
2380 diff -udprP mutt-1.5.15.orig/hdrline.c mutt-1.5.15/hdrline.c
2381 --- mutt-1.5.15.orig/hdrline.c 2007-04-03 20:52:56.000000000 +0300
2382 +++ mutt-1.5.15/hdrline.c 2007-04-11 17:29:25.000000000 +0300
2383 @@ -209,6 +209,7 @@ int mutt_user_is_recipient (HEADER *h)
2384 * %E = number of messages in current thread
2385 * %f = entire from line
2386 * %F = like %n, unless from self
2387 + * %g = newsgroup name (if compiled with nntp support)
2389 * %l = number of lines in the message
2390 * %L = like %F, except `lists' are displayed first
2391 @@ -216,12 +217,14 @@ int mutt_user_is_recipient (HEADER *h)
2392 * %n = name of author
2394 * %O = like %L, except using address instead of name
2395 + * %R = `x-comment-to:' field (if present and compiled with nntp support)
2397 * %S = short message status (e.g., N/O/D/!/r/-)
2398 * %t = `to:' field (recipients)
2400 * %u = user (login) name of author
2401 * %v = first name of author, unless from self
2402 + * %W = where user is (organization)
2403 * %X = number of MIME attachments
2404 * %y = `x-label:' field (if present)
2405 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2406 @@ -459,6 +462,12 @@ hdr_format_str (char *dest,
2412 + mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2417 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2419 @@ -546,6 +555,15 @@ hdr_format_str (char *dest,
2426 + mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2427 + else if (!hdr->env->x_comment_to)
2434 if (flags & M_FORMAT_TREE && !hdr->collapsed)
2435 @@ -635,6 +653,13 @@ hdr_format_str (char *dest,
2436 mutt_format_s (dest, destlen, prefix, buf2);
2441 + mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2442 + else if (!hdr->env->organization)
2449 diff -udprP mutt-1.5.15.orig/headers.c mutt-1.5.15/headers.c
2450 --- mutt-1.5.15.orig/headers.c 2007-04-02 00:58:56.000000000 +0300
2451 +++ mutt-1.5.15/headers.c 2007-04-11 17:25:15.000000000 +0300
2452 @@ -118,6 +118,9 @@ void mutt_edit_headers (const char *edit
2453 msg->env = n; n = NULL;
2455 if (!msg->env->in_reply_to)
2457 + if (!option (OPTNEWSSEND))
2459 mutt_free_list (&msg->env->references);
2461 mutt_expand_aliases_env (msg->env);
2462 diff -udprP mutt-1.5.15.orig/init.c mutt-1.5.15/init.c
2463 --- mutt-1.5.15.orig/init.c 2007-04-02 00:58:56.000000000 +0300
2464 +++ mutt-1.5.15/init.c 2007-04-11 17:25:15.000000000 +0300
2465 @@ -2859,6 +2859,28 @@ void mutt_init (int skip_sys_rc, LIST *c
2467 Fqdn = safe_strdup(NONULL(Hostname));
2474 + if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2477 + fgets (buffer, sizeof (buffer), f);
2481 + while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2483 + NewsServer = safe_strdup (p);
2487 + if ((p = getenv ("NNTPSERVER")))
2488 + NewsServer = safe_strdup (p);
2491 if ((p = getenv ("MAIL")))
2492 Spoolfile = safe_strdup (p);
2493 else if ((p = getenv ("MAILDIR")))
2494 diff -udprP mutt-1.5.15.orig/init.h mutt-1.5.15/init.h
2495 --- mutt-1.5.15.orig/init.h 2007-04-05 19:03:55.000000000 +0300
2496 +++ mutt-1.5.15/init.h 2007-04-11 17:29:25.000000000 +0300
2497 @@ -169,6 +169,20 @@ struct option_t MuttVars[] = {
2498 ** If set, Mutt will prompt you for carbon-copy (Cc) recipients before
2499 ** editing the body of an outgoing message.
2502 + { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2505 + ** If set, Mutt will prompt you for follow-up groups before editing
2506 + ** the body of an outgoing message.
2508 + { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2511 + ** If set, Mutt will prompt you for x-comment-to field before editing
2512 + ** the body of an outgoing message.
2515 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2518 @@ -308,6 +322,14 @@ struct option_t MuttVars[] = {
2519 ** When this variable is set, mutt will use file size attribute instead of
2520 ** access time when checking for new mail.
2523 + { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2526 + ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2527 + ** as read when you quit the newsgroup (catchup newsgroup).
2530 { "charset", DT_STR, R_NONE, UL &Charset, UL 0 },
2533 @@ -635,6 +657,16 @@ struct option_t MuttVars[] = {
2534 ** sent to both the list and your address, resulting in two copies
2535 ** of the same email for you.
2538 + { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2541 + ** If this variable is \fIset\fP and the keyword "poster" is present in
2542 + ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2543 + ** permitted. The message will be mailed to the submitter of the
2544 + ** message via mail.
2547 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2550 @@ -706,6 +738,27 @@ struct option_t MuttVars[] = {
2551 ** a regular expression that will match the whole name so mutt will expand
2552 ** "Franklin" to "Franklin, Steve".
2555 + { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2558 + ** This variable allows you to customize the newsgroup browser display to
2559 + ** your personal taste. This string is similar to ``$index_format'', but
2560 + ** has its own set of printf()-like sequences:
2563 + ** %C current newsgroup number
2564 + ** %d description of newsgroup (becomes from server)
2565 + ** %f newsgroup name
2566 + ** %M - if newsgroup not allowed for direct post (moderated for example)
2567 + ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2568 + ** %n number of new articles in newsgroup
2569 + ** %s number of unread articles in newsgroup
2570 + ** %>X right justify the rest of the string and pad with character "X"
2571 + ** %|X pad to the end of the line with character "X"
2575 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2578 @@ -996,6 +1049,7 @@ struct option_t MuttVars[] = {
2579 ** .dt %E .dd number of messages in current thread
2580 ** .dt %f .dd entire From: line (address + real name)
2581 ** .dt %F .dd author name, or recipient name if the message is from you
2582 + ** .dt %g .dd newsgroup name (if compiled with nntp support)
2583 ** .dt %H .dd spam attribute(s) of this message
2584 ** .dt %i .dd message-id of the current message
2585 ** .dt %l .dd number of lines in the message (does not work with maildir,
2586 @@ -1009,12 +1063,14 @@ struct option_t MuttVars[] = {
2587 ** .dt %n .dd author's real name (or address if missing)
2588 ** .dt %O .dd (_O_riginal save folder) Where mutt would formerly have
2589 ** stashed the message: list name or recipient name if no list
2590 + ** .dt %R .dd `x-comment-to:' field (if present and compiled with nntp support)
2591 ** .dt %s .dd subject of the message
2592 ** .dt %S .dd status of the message (N/D/d/!/r/\(as)
2593 ** .dt %t .dd `to:' field (recipients)
2594 ** .dt %T .dd the appropriate character from the $$to_chars string
2595 ** .dt %u .dd user (login) name of the author
2596 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2597 + ** .dt %W .dd name of organization of author (`organization:' field)
2598 ** .dt %X .dd number of attachments
2599 ** (please see the ``$attachments'' section for possible speed effects)
2600 ** .dt %y .dd `x-label:' field, if present
2601 @@ -1039,6 +1095,21 @@ struct option_t MuttVars[] = {
2603 ** See also: ``$$to_chars''.
2606 + { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2609 + ** If set, specifies the program and arguments used to deliver news posted
2610 + ** by Mutt. Otherwise, mutt posts article using current connection to
2611 + ** news server. The following printf-style sequence is understood:
2614 + ** %s newsserver name
2617 + ** Example: set inews="/usr/local/bin/inews -hS"
2620 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2623 @@ -1253,6 +1324,16 @@ struct option_t MuttVars[] = {
2624 ** be attached to the newly composed message if this option is set.
2628 + { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2631 + ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2632 + ** encoded according to RFC2047 to base64. This is useful when message
2633 + ** is Usenet article, because MIME for news is nonstandard feature.
2638 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2640 @@ -1323,6 +1404,77 @@ struct option_t MuttVars[] = {
2641 ** See also ``$$read_inc'' and ``$$write_inc''.
2645 + { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2648 + ** This variable pointing to directory where Mutt will save cached news
2649 + ** articles headers in. If \fIunset\fP, headers will not be saved at all
2650 + ** and will be reloaded each time when you enter to newsgroup.
2652 + { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2655 + ** This variable specifies domain name or address of NNTP server. It
2656 + ** defaults to the newsserver specified in the environment variable
2657 + ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2658 + ** specify username and an alternative port for each newsserver, ie:
2660 + ** [news[s]://][username[:password]@]newsserver[:port]
2662 + { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2665 + ** The file, containing info about subscribed newsgroups - names and
2666 + ** indexes of read articles. The following printf-style sequence
2670 + ** %s newsserver name
2673 + { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2676 + ** This variable defines number of articles which will be in index when
2677 + ** newsgroup entered. If active newsgroup have more articles than this
2678 + ** number, oldest articles will be ignored. Also controls how many
2679 + ** articles headers will be saved in cache when you quit newsgroup.
2681 + { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2684 + ** This variable controls whether or not descriptions for each newsgroup
2685 + ** must be loaded when newsgroup is added to list (first time list
2686 + ** loading or new newsgroup adding).
2688 + { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2691 + ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2692 + ** authentification, Mutt will prompt you for your account name when you
2693 + ** connect to newsserver.
2695 + { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2698 + ** Your password for NNTP account.
2700 + { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2703 + ** The time in seconds until any operations on newsgroup except post new
2704 + ** article will cause recheck for new news. If set to 0, Mutt will
2705 + ** recheck newsgroup on each operation in index (stepping, read article,
2708 + { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2711 + ** Controls whether or not Mutt will try to reconnect to newsserver when
2712 + ** connection lost.
2715 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2718 @@ -2133,6 +2285,16 @@ struct option_t MuttVars[] = {
2719 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2723 + { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2726 + ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2727 + ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2728 + ** does not support posting to that newsgroup or totally read-only, that
2729 + ** posting will not have an effect.
2732 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2735 @@ -2489,6 +2651,28 @@ struct option_t MuttVars[] = {
2736 ** Command to use when spawning a subshell. By default, the user's login
2737 ** shell from /etc/passwd is used.
2740 + { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2743 + ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2744 + ** ``newsrc'' file and into cache.
2746 + { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2749 + ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2750 + ** the browser. Otherwise, it will be done only once for a newsserver.
2751 + ** Also controls whether or not number of new articles of subscribed
2752 + ** newsgroups will be then checked.
2754 + { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2757 + ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2758 + ** will be displayed in browser.
2761 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2764 @@ -2987,6 +3171,14 @@ struct option_t MuttVars[] = {
2765 ** option does nothing: mutt will never write out the BCC header
2769 + { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2772 + ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2773 + ** name of original article author) to article that followuped to newsgroup.
2779 diff -udprP mutt-1.5.15.orig/mailbox.h mutt-1.5.15/mailbox.h
2780 --- mutt-1.5.15.orig/mailbox.h 2007-04-02 00:58:56.000000000 +0300
2781 +++ mutt-1.5.15/mailbox.h 2007-04-11 17:25:15.000000000 +0300
2782 @@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2784 int mx_is_pop (const char *);
2787 +int mx_is_nntp (const char *);
2790 int mx_access (const char*, int);
2791 int mx_check_empty (const char *);
2792 diff -udprP mutt-1.5.15.orig/main.c mutt-1.5.15/main.c
2793 --- mutt-1.5.15.orig/main.c 2007-04-04 08:37:13.000000000 +0300
2794 +++ mutt-1.5.15/main.c 2007-04-11 17:25:15.000000000 +0300
2796 #include <stringprep.h>
2803 static const char *ReachingUs = N_("\
2804 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2805 To report a bug, please visit http://bugs.mutt.org/.\n");
2806 @@ -127,6 +131,8 @@ options:\n\
2807 " -e <command>\tspecify a command to be executed after initialization\n\
2808 -f <file>\tspecify which mailbox to read\n\
2809 -F <file>\tspecify an alternate muttrc file\n\
2810 + -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2811 + -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2812 -H <file>\tspecify a draft file to read header and body from\n\
2813 -i <file>\tspecify a file which Mutt should include in the body\n\
2814 -m <type>\tspecify a default mailbox type\n\
2815 @@ -253,6 +259,12 @@ static void show_version (void)
2828 @@ -521,6 +533,9 @@ static void start_curses (void)
2829 #define M_NOSYSRC (1<<2) /* -n */
2830 #define M_RO (1<<3) /* -R */
2831 #define M_SELECT (1<<4) /* -y */
2833 +#define M_NEWS (1<<5) /* -g and -G */
2836 int main (int argc, char **argv)
2838 @@ -577,7 +592,11 @@ int main (int argc, char **argv)
2843 + while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2845 while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2850 @@ -670,6 +689,20 @@ int main (int argc, char **argv)
2855 + case 'g': /* Specify a newsserver */
2857 + char buf[LONG_STRING];
2859 + snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2860 + commands = mutt_add_list (commands, buf);
2863 + case 'G': /* List of newsgroups */
2864 + flags |= M_SELECT | M_NEWS;
2871 @@ -943,6 +976,18 @@ int main (int argc, char **argv)
2873 else if (flags & M_SELECT)
2876 + if (flags & M_NEWS)
2878 + set_option (OPTNEWS);
2879 + if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2881 + mutt_endwin (Errorbuf);
2888 mutt_endwin _("No incoming mailboxes defined.");
2890 @@ -958,6 +1003,15 @@ int main (int argc, char **argv)
2893 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2896 + if (option (OPTNEWS))
2898 + unset_option (OPTNEWS);
2899 + nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2903 mutt_expand_path (folder, sizeof (folder));
2905 mutt_str_replace (&CurrentFolder, folder);
2906 diff -udprP mutt-1.5.15.orig/mutt.h mutt-1.5.15/mutt.h
2907 --- mutt-1.5.15.orig/mutt.h 2007-04-02 21:04:35.000000000 +0300
2908 +++ mutt-1.5.15/mutt.h 2007-04-11 17:25:15.000000000 +0300
2909 @@ -243,6 +243,9 @@ enum
2917 /* Options for Mailcap lookup */
2919 @@ -298,6 +301,12 @@ enum
2922 OPT_VERIFYSIG, /* verify PGP signatures */
2925 + OPT_NNTPRECONNECT,
2927 + OPT_FOLLOWUPTOPOSTER,
2928 +#endif /* USE_NNTP */
2930 /* THIS MUST BE THE LAST VALUE. */
2932 @@ -313,6 +322,7 @@ enum
2933 #define SENDMAILX (1<<6)
2934 #define SENDKEY (1<<7)
2935 #define SENDRESEND (1<<8)
2936 +#define SENDNEWS (1<<9)
2938 /* flags to _mutt_select_file() */
2939 #define M_SEL_BUFFY (1<<0)
2940 @@ -332,6 +342,8 @@ enum
2949 @@ -404,6 +416,9 @@ enum
2954 + OPTMIMESUBJECT, /* encode subject line with RFC2047 */
2959 @@ -485,6 +500,16 @@ enum
2963 + /* news options */
2967 + OPTSHOWONLYUNREAD,
2971 +#endif /* USE_NNTP */
2973 /* pseudo options */
2975 OPTAUXSORT, /* (pseudo) using auxillary sort function */
2976 @@ -505,6 +530,7 @@ enum
2977 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
2978 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
2979 OPTATTACHMSG, /* (pseudo) used by attach-message */
2980 + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
2981 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
2982 * functions while we are executing an
2984 @@ -515,6 +541,12 @@ enum
2985 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
2986 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
2989 + OPTNEWS, /* (pseudo) used to change reader mode */
2990 + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
2991 + OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
2997 @@ -592,6 +624,13 @@ typedef struct envelope
3001 + char *organization;
3005 + char *followup_to;
3006 + char *x_comment_to;
3009 LIST *references; /* message references (in reverse order) */
3010 LIST *in_reply_to; /* in-reply-to header content */
3011 @@ -758,6 +797,9 @@ typedef struct header
3012 ENVELOPE *env; /* envelope information */
3013 BODY *content; /* list of MIME parts */
3019 char *tree; /* character string to print thread tree */
3020 struct thread *thread;
3021 @@ -773,7 +815,7 @@ typedef struct header
3022 int refno; /* message number on server */
3025 -#if defined USE_POP || defined USE_IMAP
3026 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3027 void *data; /* driver-specific data */
3030 diff -udprP mutt-1.5.15.orig/muttlib.c mutt-1.5.15/muttlib.c
3031 --- mutt-1.5.15.orig/muttlib.c 2007-04-03 20:52:56.000000000 +0300
3032 +++ mutt-1.5.15/muttlib.c 2007-04-11 17:25:15.000000000 +0300
3033 @@ -286,7 +286,7 @@ void mutt_free_header (HEADER **h)
3035 mutt_free_list (&(*h)->chain);
3037 -#if defined USE_POP || defined USE_IMAP
3038 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3041 FREE (h); /* __FREE_CHECKED__ */
3042 @@ -674,6 +674,13 @@ void mutt_free_envelope (ENVELOPE **p)
3043 FREE (&(*p)->supersedes);
3045 FREE (&(*p)->x_label);
3046 + FREE (&(*p)->organization);
3048 + FREE (&(*p)->newsgroups);
3049 + FREE (&(*p)->xref);
3050 + FREE (&(*p)->followup_to);
3051 + FREE (&(*p)->x_comment_to);
3054 mutt_buffer_free (&(*p)->spam);
3056 @@ -1392,6 +1399,14 @@ int mutt_save_confirm (const char *s, st
3061 + if (magic == M_NNTP)
3063 + mutt_error _("Can't save message to newsserver.");
3068 if (stat (s, st) != -1)
3071 diff -udprP mutt-1.5.15.orig/mx.c mutt-1.5.15/mx.c
3072 --- mutt-1.5.15.orig/mx.c 2007-04-03 20:41:14.000000000 +0300
3073 +++ mutt-1.5.15/mx.c 2007-04-11 17:25:15.000000000 +0300
3074 @@ -348,6 +348,22 @@ int mx_is_pop (const char *p)
3079 +int mx_is_nntp (const char *p)
3081 + url_scheme_t scheme;
3086 + scheme = url_check_scheme (p);
3087 + if (scheme == U_NNTP || scheme == U_NNTPS)
3094 int mx_get_magic (const char *path)
3097 @@ -365,6 +381,11 @@ int mx_get_magic (const char *path)
3099 #endif /* USE_POP */
3102 + if (mx_is_nntp (path))
3104 +#endif /* USE_NNTP */
3106 if (stat (path, &st) == -1)
3108 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
3109 @@ -704,6 +725,12 @@ CONTEXT *mx_open_mailbox (const char *pa
3111 #endif /* USE_POP */
3115 + rc = nntp_open_mailbox (ctx);
3117 +#endif /* USE_NNTP */
3122 @@ -796,6 +823,12 @@ static int sync_mailbox (CONTEXT *ctx, i
3123 rc = pop_sync_mailbox (ctx, index_hint);
3125 #endif /* USE_POP */
3129 + rc = nntp_sync_mailbox (ctx);
3131 +#endif /* USE_NNTP */
3135 @@ -822,6 +855,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
3140 + if (ctx->magic == M_NNTP)
3144 + ret = nntp_close_mailbox (ctx);
3145 + mx_fastclose_mailbox (ctx);
3149 if (ctx->readonly || ctx->dontwrite)
3151 /* mailbox is readonly or we don't want to write */
3152 @@ -1359,6 +1402,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
3154 return (pop_check_mailbox (ctx, index_hint));
3155 #endif /* USE_POP */
3159 + return (nntp_check_mailbox (ctx));
3160 +#endif /* USE_NNTP */
3164 @@ -1419,6 +1467,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
3166 #endif /* USE_POP */
3171 + if (nntp_fetch_message (msg, ctx, msgno) != 0)
3175 +#endif /* USE_NNTP */
3178 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3180 @@ -1500,6 +1557,9 @@ int mx_close_message (MESSAGE **msg)
3182 || (*msg)->magic == M_POP
3185 + || (*msg)->magic == M_NNTP
3189 r = safe_fclose (&(*msg)->fp);
3190 diff -udprP mutt-1.5.15.orig/mx.h mutt-1.5.15/mx.h
3191 --- mutt-1.5.15.orig/mx.h 2007-04-02 00:58:56.000000000 +0300
3192 +++ mutt-1.5.15/mx.h 2007-04-11 17:25:15.000000000 +0300
3193 @@ -40,6 +40,9 @@ enum
3202 WHERE short DefaultMagic INITVAL (M_MBOX);
3203 diff -udprP mutt-1.5.15.orig/newsrc.c mutt-1.5.15/newsrc.c
3204 --- mutt-1.5.15.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3205 +++ mutt-1.5.15/newsrc.c 2007-04-11 18:13:00.000000000 +0300
3208 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3209 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
3210 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
3212 + * This program is free software; you can redistribute it and/or modify
3213 + * it under the terms of the GNU General Public License as published by
3214 + * the Free Software Foundation; either version 2 of the License, or
3215 + * (at your option) any later version.
3217 + * This program is distributed in the hope that it will be useful,
3218 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3219 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3220 + * GNU General Public License for more details.
3222 + * You should have received a copy of the GNU General Public License
3223 + * along with this program; if not, write to the Free Software
3224 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3228 +# include "config.h"
3232 +#include "mutt_curses.h"
3236 +#include "mailbox.h"
3238 +#include "rfc822.h"
3239 +#include "rfc1524.h"
3240 +#include "rfc2047.h"
3242 +#include <unistd.h>
3243 +#include <string.h>
3245 +#include <stdlib.h>
3246 +#include <sys/stat.h>
3248 +void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3255 + l = safe_calloc (1, sizeof (LIST));
3257 + s->tail->next = l;
3261 + l->data = (void *) d;
3264 +static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3267 + char group[LONG_STRING];
3269 + char *p = line, *b, *h;
3279 + while (*p && (*p != ':' && *p != '!')) p++;
3282 + len = p + 1 - line;
3283 + if (len > sizeof (group))
3284 + len = sizeof (group);
3285 + strfcpy (group, line, len);
3286 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3288 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3289 + data->group = (char *) data + sizeof (NNTP_DATA);
3290 + strcpy (data->group, group);
3291 + data->nserv = news;
3292 + data->deleted = 1;
3293 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3294 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3295 + hash_insert (news->newsgroups, data->group, data, 0);
3296 + nntp_add_to_list (news, data);
3299 + FREE ((void **) &data->entries);
3302 + data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3306 + data->subscribed = 1;
3308 + data->subscribed = 0;
3315 + while (*p && *p != ',' && *p != '\n') p++;
3321 + if ((h = strchr(b, '-')))
3325 + data->entries[x].first = atoi(b);
3326 + data->entries[x].last = atoi(h);
3330 + data->entries[x].first = atoi(b);
3331 + data->entries[x].last = data->entries[x].first;
3334 + if (data->entries[x].last != 0)
3337 + if (x && !data->lastMessage)
3338 + data->lastMessage = data->entries[x-1].last;
3340 + mutt_newsgroup_stat (data);
3341 + dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3346 +static int slurp_newsrc (NNTP_SERVER *news)
3352 + news->stat = stat (news->newsrc, &sb);
3353 + news->size = sb.st_size;
3354 + news->mtime = sb.st_mtime;
3356 + if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3358 + /* hmm, should we use dotlock? */
3359 + if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3365 + buf = safe_malloc (sb.st_size + 1);
3366 + while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3367 + nntp_parse_newsrc_line (news, buf);
3370 + mx_unlock_file (news->newsrc, fileno (fp), 0);
3375 +void nntp_cache_expand (char *dst, const char *src)
3377 + snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3378 + mutt_expand_path (dst, _POSIX_PATH_MAX);
3381 +/* Loads $news_cache_dir/.index into memory, loads newsserver data
3382 + * and newsgroup cache names */
3383 +static int nntp_parse_cacheindex (NNTP_SERVER *news)
3386 + char buf[HUGE_STRING], *cp;
3387 + char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3392 + /* check is server name defined or not */
3393 + if (!news || !news->conn || !news->conn->account.host)
3395 + unset_option (OPTNEWSCACHE);
3396 + if (!NewsCacheDir || !*NewsCacheDir)
3399 + strfcpy (dir, NewsCacheDir, sizeof (dir));
3400 + mutt_expand_path (dir, sizeof(dir));
3402 + if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3404 + snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3405 + if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3408 + mutt_error _("Cache directory not created!");
3411 + mutt_clear_error();
3414 + set_option (OPTNEWSCACHE);
3416 + FREE (&news->cache);
3417 + snprintf (buf, sizeof(buf), "%s/.index", dir);
3418 + if (!(index = safe_fopen (buf, "a+")))
3421 + while (fgets (buf, sizeof(buf), index))
3423 + buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3424 + if (!mutt_strncmp (buf, "#: ", 3) &&
3425 + !mutt_strcasecmp (buf+3, news->conn->account.host))
3428 + while (fgets (buf, sizeof(buf), index))
3431 + while (*cp && *cp != ' ') cp++;
3432 + if (!*cp) continue;
3434 + if (!mutt_strcmp (buf, "#:"))
3436 + sscanf (cp + 1, "%s %d %d", file, &l, &m);
3437 + if (!mutt_strcmp (buf, "ALL"))
3439 + news->cache = safe_strdup (file);
3440 + news->newgroups_time = m;
3442 + else if (news->newsgroups)
3444 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3446 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3447 + data->group = (char *) data + sizeof (NNTP_DATA);
3448 + strcpy(data->group, buf);
3449 + data->nserv = news;
3450 + data->deleted = 1;
3451 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3452 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3453 + hash_insert (news->newsgroups, data->group, data, 0);
3454 + nntp_add_to_list (news, data);
3456 + data->cache = safe_strdup (file);
3458 + if (!data->firstMessage || data->lastMessage < m)
3460 + if (!data->firstMessage)
3461 + data->firstMessage = l;
3462 + if (data->lastMessage < m)
3463 + data->lastMessage = m;
3464 + data->lastCached = m;
3465 + if (t || !data->unread)
3466 + mutt_newsgroup_stat (data);
3474 +nntp_format_str (char *dest, size_t destlen, char op, const char *src,
3475 + const char *fmt, const char *ifstring, const char *elsestring,
3476 + unsigned long data, format_flag flags)
3478 + char fn[SHORT_STRING], tmp[SHORT_STRING];
3483 + strncpy (fn, NewsServer, sizeof(fn) - 1);
3484 + mutt_strlower (fn);
3485 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3486 + snprintf (dest, destlen, tmp, fn);
3492 +/* nntp_parse_url: given an NNPT URL, return host, port,
3493 + * username, password and newsgroup will recognise. */
3494 +int nntp_parse_url (const char *server, ACCOUNT *acct,
3495 + char *group, size_t group_len)
3503 + acct->port = NNTP_PORT;
3504 + acct->type = M_ACCT_TYPE_NNTP;
3506 + c = safe_strdup (server);
3507 + url_parse_ciss (&url, c);
3509 + if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3511 + if (url.scheme == U_NNTPS)
3513 + acct->flags |= M_ACCT_SSL;
3514 + acct->port = NNTP_SSL_PORT;
3519 + strfcpy (group, url.path, group_len);
3521 + ret = mutt_account_fromurl (acct, &url);
3528 +void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3532 + url.path = safe_strdup (line);
3533 + mutt_account_tourl (acct, &url);
3534 + url_ciss_tostring (&url, line, len, 0);
3539 + * Automatically loads a newsrc into memory, if necessary.
3540 + * Checks the size/mtime of a newsrc file, if it doesn't match, load
3541 + * again. Hmm, if a system has broken mtimes, this might mean the file
3542 + * is reloaded every time, which we'd have to fix.
3544 + * a newsrc file is a line per newsgroup, with the newsgroup, then a
3545 + * ':' denoting subscribed or '!' denoting unsubscribed, then a
3546 + * comma separated list of article numbers and ranges.
3548 +NNTP_SERVER *mutt_select_newsserver (char *server)
3550 + char file[_POSIX_PATH_MAX];
3554 + NNTP_SERVER *serv;
3557 + if (!server || !*server)
3559 + mutt_error _("No newsserver defined!");
3563 + buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3564 + if (url_check_scheme (server) == U_UNKNOWN)
3566 + strcpy (buf, "news://");
3567 + p = strchr (buf, '\0');
3569 + strcpy (p, server);
3571 + if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3574 + mutt_error (_("%s is an invalid newsserver specification!"), server);
3579 + conn = mutt_conn_find (NULL, &acct);
3583 + mutt_FormatString (file, sizeof (file), NONULL (NewsRc), nntp_format_str, 0, 0);
3584 + mutt_expand_path (file, sizeof (file));
3586 + serv = (NNTP_SERVER *)conn->data;
3591 + /* externally modified? */
3592 + if (serv->stat != stat (file, &sb) || (!serv->stat &&
3593 + (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3595 + for (list = serv->list; list; list = list->next)
3597 + NNTP_DATA *data = (NNTP_DATA *) list->data;
3601 + data->subscribed = 0;
3606 + slurp_newsrc (serv);
3607 + nntp_clear_cacheindex (serv);
3610 + if (serv->status == NNTP_BYE)
3611 + serv->status = NNTP_NONE;
3612 + nntp_check_newgroups (serv, 0);
3616 + /* New newsserver */
3617 + serv = safe_calloc (1, sizeof (NNTP_SERVER));
3618 + serv->conn = conn;
3619 + serv->newsrc = safe_strdup (file);
3620 + serv->newsgroups = hash_create (1009);
3621 + slurp_newsrc (serv); /* load .newsrc */
3622 + nntp_parse_cacheindex (serv); /* load .index */
3623 + if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3624 + nntp_check_newgroups (serv, 1);
3625 + else if (nntp_get_active (serv) < 0)
3627 + hash_destroy (&serv->newsgroups, nntp_delete_data);
3628 + for (list = serv->list; list; list = list->next)
3629 + list->data = NULL;
3630 + mutt_free_list (&serv->list);
3631 + FREE (&serv->newsrc);
3632 + FREE (&serv->cache);
3636 + nntp_clear_cacheindex (serv);
3637 + conn->data = (void *)serv;
3643 + * full status flags are not supported by nntp, but we can fake some
3644 + * of them. This is how:
3645 + * Read = a read message number is in the .newsrc
3646 + * New = a message is new since we last read this newsgroup
3647 + * Old = anything else
3648 + * So, Read is marked as such in the newsrc, old is anything that is
3649 + * "skipped" in the newsrc, and new is anything not in the newsrc nor
3650 + * in the cache. By skipped, I mean before the last unread message
3652 +void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3654 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3658 + data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3664 + dprint (3, (debugfile, "newsgroup %s not found\n", group));
3669 + for (x = 0; x < data->num; x++)
3671 + if ((article >= data->entries[x].first) &&
3672 + (article <= data->entries[x].last))
3674 + /* we cannot use mutt_set_flag() because mx_update_context()
3675 + didn't called yet */
3680 + /* If article was not cached yet, it is new! :) */
3681 + if (!data->cache || article > data->lastCached)
3683 + /* Old articles are articles which aren't read but an article after them
3684 + * has been cached */
3685 + if (option (OPTMARKOLD))
3689 +void mutt_newsgroup_stat (NNTP_DATA *data)
3692 + unsigned int first, last;
3695 + if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3698 + data->unread = data->lastMessage - data->firstMessage + 1;
3699 + for (i = 0; i < data->num; i++)
3701 + first = data->entries[i].first;
3702 + if (first < data->firstMessage)
3703 + first = data->firstMessage;
3704 + last = data->entries[i].last;
3705 + if (last > data->lastMessage)
3706 + last = data->lastMessage;
3707 + if (first <= last)
3708 + data->unread -= last - first + 1;
3712 +static int puti (char *line, int num)
3716 + for (p = s; num; )
3718 + *p++ = '0' + num % 10;
3722 + *line++ = *--p, num++;
3727 +static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3729 + char *line = *pline;
3730 + size_t len = *buflen - (*pline - *buf);
3733 + if (len < LONG_STRING * 10)
3738 + safe_realloc (buf, *buflen);
3739 + line = *buf + (*pline - line);
3741 + strcpy (line, data->group);
3742 + len -= strlen (line) + 1;
3743 + line += strlen (line);
3744 + *line++ = data->subscribed ? ':' : '!';
3748 + for (x = 0; x < data->num; x++)
3750 + if (len < LONG_STRING)
3756 + safe_realloc (buf, *buflen);
3757 + line = *buf + (*pline - line);
3766 + if (data->entries[x].first == data->entries[x].last)
3767 + snprintf (line, len, "%d%n", data->entries[x].first, &i);
3769 + snprintf (line, len, "%d-%d%n",
3770 + data->entries[x].first, data->entries[x].last, &i);
3774 + i = puti (line, data->entries[x].first);
3775 + line +=i; len -= i;
3776 + if (data->entries[x].first != data->entries[x].last)
3780 + i = puti (line, data->entries[x].last);
3781 + line +=i; len -= i;
3790 +void newsrc_gen_entries (CONTEXT *ctx)
3792 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3794 + unsigned int last = 0, first = 1;
3795 + int save_sort = SORT_ORDER;
3797 + if (Sort != SORT_ORDER)
3800 + Sort = SORT_ORDER;
3801 + mutt_sort_headers (ctx, 0);
3806 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3811 + * Set up to fake initial sequence from 1 to the article before the
3812 + * first article in our list
3817 + for (x = 0; x < ctx->msgcount; x++)
3819 + if (series) /* search for first unread */
3822 + * We don't actually check sequential order, since we mark
3823 + * "missing" entries as read/deleted
3825 + last = ctx->hdrs[x]->article_num;
3826 + if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3827 + !ctx->hdrs[x]->read)
3829 + if (data->num >= data->max)
3831 + data->max = data->max * 2;
3832 + safe_realloc (&data->entries,
3833 + data->max * sizeof (NEWSRC_ENTRY));
3835 + data->entries[data->num].first = first;
3836 + data->entries[data->num].last = last - 1;
3841 + else /* search for first read */
3843 + if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3848 + last = ctx->hdrs[x]->article_num;
3851 + if (series && first <= data->lastLoaded)
3853 + if (data->num >= data->max)
3855 + data->max = data->max * 2;
3856 + safe_realloc (&data->entries,
3857 + data->max * sizeof (NEWSRC_ENTRY));
3859 + data->entries[data->num].first = first;
3860 + data->entries[data->num].last = data->lastLoaded;
3864 + if (save_sort != Sort)
3867 + mutt_sort_headers (ctx, 0);
3871 +static int mutt_update_list_file (char *filename, char *section,
3872 + char *key, char *line)
3876 + char buf[HUGE_STRING];
3877 + char tmpfile[_POSIX_PATH_MAX];
3879 + int ext = 0, done = 0, r = 0;
3881 + /* if file not exist, create it */
3882 + if ((ifp = safe_fopen (filename, "a")))
3884 + dprint (1, (debugfile, "Opening %s\n", filename));
3885 + if (!(ifp = safe_fopen (filename, "r")))
3887 + mutt_error (_("Unable to open %s for reading"), filename);
3890 + if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3893 + mutt_error (_("Unable to lock %s"), filename);
3896 + snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3897 + dprint (1, (debugfile, "Opening %s\n", tmpfile));
3898 + if (!(ofp = fopen (tmpfile, "w")))
3901 + mutt_error (_("Unable to open %s for writing"), tmpfile);
3907 + while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3909 + r = fputs (buf, ofp);
3911 + while (*c && *c != '\n') c++;
3912 + c[0] = 0; /* strip EOL */
3913 + if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3916 + if (r != EOF && !done)
3918 + snprintf (buf, sizeof(buf), "#: %s\n", section);
3919 + r = fputs (buf, ofp);
3924 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3929 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3931 + if (*c != '\\') ext = 0;
3933 + else if ((section && !strncmp (buf, "#: ", 3)))
3935 + if (!done && line)
3937 + fputs (line, ofp);
3938 + fputc ('\n', ofp);
3940 + r = fputs (buf, ofp);
3944 + else if (key && !strncmp (buf, key, strlen(key)) &&
3945 + (!*key || buf[strlen(key)] == ' '))
3949 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3951 + if (*c == '\\') ext = 1;
3952 + if (!done && line)
3954 + r = fputs (line, ofp);
3956 + r = fputc ('\n', ofp);
3962 + r = fputs (buf, ofp);
3966 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3967 + r = fputs (buf, ofp);
3969 + /* If there wasn't a line to replace, put it on the end of the file */
3970 + if (r != EOF && !done && line)
3972 + fputs (line, ofp);
3973 + r = fputc ('\n', ofp);
3975 + mx_unlock_file (filename, fileno (ifp), 0);
3981 + mutt_error (_("Can't write %s"), tmpfile);
3984 + if (rename (tmpfile, filename) < 0)
3987 + mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
3993 +int mutt_newsrc_update (NNTP_SERVER *news)
4003 + llen = len = 10 * LONG_STRING;
4004 + line = buf = safe_calloc (1, len);
4005 + /* we will generate full newsrc here */
4006 + for (tmp = news->list; tmp; tmp = tmp->next)
4008 + data = (NNTP_DATA *) tmp->data;
4009 + if (!data || !data->rc)
4011 + nntp_create_newsrc_line (data, &buf, &line, &llen);
4013 + dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4014 + line += strlen (line);
4016 + /* newrc being fully rewritten */
4017 + if (news->newsrc &&
4018 + (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4022 + stat (news->newsrc, &st);
4023 + news->size = st.st_size;
4024 + news->mtime = st.st_mtime;
4030 +static FILE *mutt_mkname (char *s)
4032 + char buf[_POSIX_PATH_MAX], *pc;
4036 + nntp_cache_expand (buf, s);
4037 + if ((fp = safe_fopen (buf, "w")))
4040 + nntp_cache_expand (buf, "cache-XXXXXX");
4041 + pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4042 + if ((fd = mkstemp (buf)) == -1)
4044 + strcpy (s, pc); /* generated name */
4045 + return fdopen (fd, "w");
4048 +/* Updates info into .index file: ALL or about selected newsgroup */
4049 +static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4051 + char buf[LONG_STRING], *key = "ALL";
4052 + char file[_POSIX_PATH_MAX];
4054 + if (!serv || !serv->conn || !serv->conn->account.host)
4057 + if (data && data->group)
4059 + key = data->group;
4060 + snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4061 + data->firstMessage, data->lastLoaded);
4065 + strfcpy (file, serv->cache, sizeof (file));
4066 + snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4068 + nntp_cache_expand (file, ".index");
4069 + return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4072 +/* Remove cache files of unsubscribed newsgroups */
4073 +void nntp_clear_cacheindex (NNTP_SERVER *news)
4078 + if (option (OPTSAVEUNSUB) || !news)
4081 + for (tmp = news->list; tmp; tmp = tmp->next)
4083 + data = (NNTP_DATA *) tmp->data;
4084 + if (!data || data->subscribed || !data->cache)
4086 + nntp_delete_cache (data);
4087 + dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4092 +int nntp_save_cache_index (NNTP_SERVER *news)
4094 + char buf[HUGE_STRING];
4095 + char file[_POSIX_PATH_MAX];
4100 + if (!news || !news->newsgroups)
4102 + if (!option (OPTNEWSCACHE))
4107 + nntp_cache_expand (file, news->cache);
4109 + f = safe_fopen (file, "w");
4113 + strfcpy (buf, news->conn->account.host, sizeof(buf));
4114 + f = mutt_mkname (buf);
4115 + news->cache = safe_strdup (buf);
4116 + nntp_cache_expand (file, buf);
4121 + for (l = news->list; l; l = l->next)
4123 + if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4126 + snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4127 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4130 + snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4131 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4132 + if (fputs (buf, f) == EOF)
4142 + if (nntp_update_cacheindex (news, NULL))
4150 +int nntp_save_cache_group (CONTEXT *ctx)
4152 + char buf[HUGE_STRING], addr[STRING];
4153 + char file[_POSIX_PATH_MAX];
4157 + int i = 0, save = SORT_ORDER;
4160 + if (!option (OPTNEWSCACHE))
4162 + if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4165 + if (((NNTP_DATA *)ctx->data)->cache)
4167 + nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4169 + f = safe_fopen (file, "w");
4173 + snprintf (buf, sizeof(buf), "%s-%s",
4174 + ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4175 + ((NNTP_DATA *)ctx->data)->group);
4176 + f = mutt_mkname (buf);
4177 + ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4178 + nntp_cache_expand (file, buf);
4183 + if (Sort != SORT_ORDER)
4186 + Sort = SORT_ORDER;
4187 + mutt_sort_headers (ctx, 0);
4190 + /* Save only $nntp_context messages... */
4191 + ((NNTP_DATA *)ctx->data)->lastCached = 0;
4192 + if (NntpContext && ctx->msgcount > NntpContext)
4193 + i = ctx->msgcount - NntpContext;
4194 + for (; i < ctx->msgcount; i++)
4196 + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4200 + rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4201 + tm = gmtime (&h->date_sent);
4202 + snprintf (buf, sizeof(buf),
4203 + "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4204 + h->article_num, h->env->subject, addr, tm->tm_mday,
4205 + Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4206 + tm->tm_sec, h->env->message_id);
4208 + if (h->env->references)
4209 + mutt_write_references (h->env->references, f);
4210 + snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length,
4211 + (int) h->lines, NONULL(h->env->xref));
4212 + if (fputs (buf, f) == EOF)
4219 + prev = ctx->hdrs[i]->article_num;
4225 + mutt_sort_headers (ctx, 0);
4229 + if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4230 + (NNTP_DATA *)ctx->data))
4235 + ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4239 +void nntp_delete_cache (NNTP_DATA *data)
4241 + char buf[_POSIX_PATH_MAX];
4243 + if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4246 + nntp_cache_expand (buf, data->cache);
4248 + FREE (&data->cache);
4249 + data->lastCached = 0;
4250 + nntp_cache_expand (buf, ".index");
4251 + mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4254 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4258 + if (!news || !news->newsgroups || !group || !*group)
4260 + if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4262 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4263 + data->group = (char *) data + sizeof (NNTP_DATA);
4264 + strcpy (data->group, group);
4265 + data->nserv = news;
4266 + data->deleted = 1;
4267 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4268 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
4269 + hash_insert (news->newsgroups, data->group, data, 0);
4270 + nntp_add_to_list (news, data);
4272 + if (!data->subscribed)
4274 + data->subscribed = 1;
4280 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4284 + if (!news || !news->newsgroups || !group || !*group ||
4285 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4287 + if (data->subscribed)
4289 + data->subscribed = 0;
4290 + if (!option (OPTSAVEUNSUB))
4296 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4300 + if (!news || !news->newsgroups || !group || !*group ||
4301 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4305 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4309 + data->entries[0].first = 1;
4311 + data->entries[0].last = data->lastMessage;
4312 + if (Context && Context->data == data)
4316 + for (x = 0; x < Context->msgcount; x++)
4317 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4322 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4326 + if (!news || !news->newsgroups || !group || !*group ||
4327 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4331 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4335 + data->entries[0].first = 1;
4336 + data->entries[0].last = data->firstMessage - 1;
4337 + if (Context && Context->data == data)
4341 + data->unread = Context->msgcount;
4342 + for (x = 0; x < Context->msgcount; x++)
4343 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4346 + data->unread = data->lastMessage - data->entries[0].last;
4350 +/* this routine gives the first newsgroup with new messages */
4351 +void nntp_buffy (char *s)
4355 + for (list = CurrentNewsSrv->list; list; list = list->next)
4357 + NNTP_DATA *data = (NNTP_DATA *) list->data;
4359 + if (data && data->subscribed && data->unread)
4361 + if (Context && Context->magic == M_NNTP &&
4362 + !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4364 + unsigned int i, unread = 0;
4366 + for (i = 0; i < Context->msgcount; i++)
4367 + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4372 + strcpy (s, data->group);
4377 diff -udprP mutt-1.5.15.orig/nntp.c mutt-1.5.15/nntp.c
4378 --- mutt-1.5.15.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4379 +++ mutt-1.5.15/nntp.c 2007-04-11 17:48:16.000000000 +0300
4382 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4383 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4384 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
4386 + * This program is free software; you can redistribute it and/or modify
4387 + * it under the terms of the GNU General Public License as published by
4388 + * the Free Software Foundation; either version 2 of the License, or
4389 + * (at your option) any later version.
4391 + * This program is distributed in the hope that it will be useful,
4392 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4393 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4394 + * GNU General Public License for more details.
4396 + * You should have received a copy of the GNU General Public License
4397 + * along with this program; if not, write to the Free Software
4398 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4402 +# include "config.h"
4406 +#include "mutt_curses.h"
4410 +#include "rfc1524.h"
4411 +#include "rfc2047.h"
4412 +#include "mailbox.h"
4423 +#include <unistd.h>
4424 +#include <string.h>
4426 +#include <stdlib.h>
4428 +static unsigned int _checked = 0;
4431 +static void nntp_error (const char *where, const char *msg)
4433 + dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4437 +static int nntp_auth (NNTP_SERVER *serv)
4439 + CONNECTION *conn = serv->conn;
4441 + unsigned char flags = conn->account.flags;
4443 + if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4444 + mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4446 + conn->account.flags = flags;
4450 + mutt_message _("Logging in...");
4452 + snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4453 + mutt_socket_write (conn, buf);
4454 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4456 + conn->account.flags = flags;
4461 + /* don't print the password unless we're at the ungodly debugging level */
4462 + if (debuglevel < M_SOCK_LOG_FULL)
4463 + dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4465 + snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4466 + mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4467 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4469 + conn->account.flags = flags;
4473 + if (mutt_strncmp ("281", buf, 3))
4475 + conn->account.flags = flags;
4476 + mutt_error _("Login failed.");
4484 +static int nntp_connect_error (NNTP_SERVER *serv)
4486 + serv->status = NNTP_NONE;
4487 + mutt_socket_close (serv->conn);
4488 + mutt_error _("Server closed connection!");
4493 +static int nntp_connect_and_auth (NNTP_SERVER *serv)
4495 + CONNECTION *conn = serv->conn;
4499 + serv->status = NNTP_NONE;
4501 + if (mutt_socket_open (conn) < 0)
4504 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4505 + return nntp_connect_error (serv);
4507 + if (!mutt_strncmp ("200", buf, 3))
4508 + mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4509 + else if (!mutt_strncmp ("201", buf, 3))
4510 + mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4513 + mutt_socket_close (conn);
4514 + mutt_remove_trailing_ws (buf);
4515 + mutt_error ("%s", buf);
4522 + /* Tell INN to switch to mode reader if it isn't so. Ignore all
4523 + returned codes and messages. */
4524 + mutt_socket_write (conn, "MODE READER\r\n");
4525 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4526 + return nntp_connect_error (serv);
4528 + mutt_socket_write (conn, "STAT\r\n");
4529 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4530 + return nntp_connect_error (serv);
4532 + if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
4534 + serv->status = NNTP_OK;
4538 + rc = nntp_auth (serv);
4540 + return nntp_connect_error (serv);
4543 + mutt_socket_close (conn);
4544 + serv->status = NNTP_BYE;
4549 + mutt_socket_close (conn);
4550 + mutt_error _("Login failed.");
4554 + serv->status = NNTP_OK;
4558 +static int nntp_attempt_features (NNTP_SERVER *serv)
4560 + char buf[LONG_STRING];
4561 + CONNECTION *conn = serv->conn;
4563 + mutt_socket_write (conn, "XOVER\r\n");
4564 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4565 + return nntp_connect_error (serv);
4566 + if (mutt_strncmp ("500", buf, 3))
4567 + serv->hasXOVER = 1;
4569 + mutt_socket_write (conn, "XPAT\r\n");
4570 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4571 + return nntp_connect_error (serv);
4572 + if (mutt_strncmp ("500", buf, 3))
4573 + serv->hasXPAT = 1;
4575 + mutt_socket_write (conn, "LISTGROUP\r\n");
4576 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4577 + return nntp_connect_error (serv);
4578 + if (mutt_strncmp ("500", buf, 3))
4579 + serv->hasLISTGROUP = 1;
4581 + mutt_socket_write (conn, "XGTITLE +\r\n");
4582 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4583 + return nntp_connect_error (serv);
4584 + if (mutt_strncmp ("500", buf, 3))
4585 + serv->hasXGTITLE = 1;
4587 + if (!mutt_strncmp ("282", buf, 3))
4591 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4592 + return nntp_connect_error (serv);
4593 + } while (!(buf[0] == '.' && buf[1] == '\0'));
4599 +static int nntp_open_connection (NNTP_SERVER *serv)
4601 + if (serv->status == NNTP_OK)
4603 + if (serv->status == NNTP_BYE)
4605 + if (nntp_connect_and_auth (serv) < 0)
4607 + if (nntp_attempt_features (serv) < 0)
4612 +static int nntp_reconnect (NNTP_SERVER *serv)
4614 + char buf[SHORT_STRING];
4616 + mutt_socket_close (serv->conn);
4620 + if (nntp_connect_and_auth (serv) == 0)
4623 + snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
4624 + serv->conn->account.host);
4625 + if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
4627 + serv->status = NNTP_BYE;
4633 +/* Send data from line[LONG_STRING] and receive answer to same line */
4634 +static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
4636 + char buf[LONG_STRING];
4639 + if (data->nserv->status == NNTP_BYE)
4646 + mutt_socket_write (data->nserv->conn, line);
4648 + else if (data->group)
4650 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4651 + mutt_socket_write (data->nserv->conn, buf);
4655 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4657 + if (nntp_reconnect (data->nserv) < 0)
4662 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4663 + mutt_socket_write (data->nserv->conn, buf);
4664 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4670 + else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
4674 + strfcpy (line, buf, linelen);
4679 + * This function calls funct(*line, *data) for each received line,
4680 + * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
4683 + * 1 - correct but not performed (may be, have to be continued),
4684 + * -1 - conection lost,
4685 + * -2 - invalid command or execution error,
4686 + * -3 - error in funct(*line, *data).
4688 +static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
4689 + int (*funct) (char *, void *), void *data, int tagged)
4691 + char buf[LONG_STRING];
4695 + size_t lenbuf = 0;
4700 + strfcpy (buf, query, sizeof (buf));
4701 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
4703 + if (buf[0] == '5')
4705 + if (buf[0] != '2')
4710 + inbuf = safe_malloc (sizeof (buf));
4714 + chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
4720 + if (!lenbuf && buf[0] == '.')
4722 + if (buf[1] == '\0')
4727 + if (buf[1] == '.')
4731 + strfcpy (inbuf + lenbuf, p, sizeof (buf));
4733 + if (chunk >= sizeof (buf))
4735 + lenbuf += strlen (p);
4740 + if (msg && ReadInc && (line % ReadInc == 0)) {
4742 + mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
4744 + mutt_message ("%s %d", msg, line);
4747 + if (ret == 0 && funct (inbuf, data) < 0)
4752 + safe_realloc (&inbuf, lenbuf + sizeof (buf));
4755 + funct (NULL, data);
4761 +static int nntp_read_tempfile (char *line, void *file)
4763 + FILE *f = (FILE *)file;
4770 + if (fputc ('\n', f) == EOF)
4776 +static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
4778 + register char *p, *b;
4779 + register char *colon = NULL;
4784 + /* skip to next word */
4786 + while (*b && ((*b == ' ') || (*b == '\t'))) b++;
4789 + /* skip to end of word */
4790 + while (*p && (*p != ' ') && (*p != '\t'))
4805 + nntp_get_status (ctx, h, b, atoi(colon));
4806 + if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
4807 + h->article_num = atoi(colon);
4815 + * 1 if article not found
4816 + * -1 if read or write error on tempfile or socket
4818 +static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
4820 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
4822 + char buf[LONG_STRING];
4823 + char tempfile[_POSIX_PATH_MAX];
4825 + HEADER *h = ctx->hdrs[ctx->msgcount];
4827 + mutt_mktemp (tempfile);
4828 + if (!(f = safe_fopen (tempfile, "w+")))
4832 + snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
4834 + snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
4836 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
4841 + dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
4844 + unlink (tempfile);
4845 + return (ret == -1 ? -1 : 1);
4848 + h->article_num = article_num;
4849 + h->env = mutt_read_rfc822_header (f, h, 0, 0);
4851 + unlink (tempfile);
4853 + if (h->env->xref != NULL)
4854 + nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
4855 + else if (h->article_num == 0 && msgid)
4857 + snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
4858 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
4859 + h->article_num = atoi (buf + 4);
4865 +static int parse_description (char *line, void *n)
4867 +#define news ((NNTP_SERVER *) n)
4868 + register char *d = line;
4873 + while (*d && *d != '\t' && *d != ' ') d++;
4876 + while (*d && (*d == '\t' || *d == ' ')) d++;
4877 + dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
4878 + if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
4879 + mutt_strcmp (d, data->desc))
4881 + FREE (&data->desc);
4882 + data->desc = safe_strdup (d);
4888 +static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
4892 + if (!option (OPTLOADDESC) || !data || !data->nserv)
4895 + /* Get newsgroup description, if we can */
4896 + if (data->nserv->hasXGTITLE)
4897 + snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
4899 + snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
4900 + if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
4903 + nntp_error ("nntp_get_desc()", buf);
4909 + * XOVER returns a tab separated list of:
4910 + * id|subject|from|date|Msgid|references|bytes|lines|xref
4912 + * This has to duplicate some of the functionality of
4913 + * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
4914 + * a limited number of headers which are "parsed" by placement in the list)
4916 +static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
4918 + NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
4922 + hdr->env = mutt_new_envelope();
4923 + hdr->env->newsgroups = safe_strdup (nntp_data->group);
4924 + hdr->content = mutt_new_body();
4925 + hdr->content->type = TYPETEXT;
4926 + hdr->content->subtype = safe_strdup ("plain");
4927 + hdr->content->encoding = ENC7BIT;
4928 + hdr->content->disposition = DISPINLINE;
4929 + hdr->content->length = -1;
4932 + for (x = 0; !done && x < 9; x++)
4934 + /* if from file, need to skip newline character */
4935 + while (*p && *p != '\n' && *p != '\t') p++;
4943 + hdr->article_num = atoi (b);
4944 + nntp_get_status (ctx, hdr, NULL, hdr->article_num);
4947 + hdr->env->subject = safe_strdup (b);
4948 + /* Now we need to do the things which would normally be done in
4949 + * mutt_read_rfc822_header() */
4950 + if (hdr->env->subject)
4952 + regmatch_t pmatch[1];
4954 + rfc2047_decode (&hdr->env->subject);
4956 + if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
4957 + hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
4959 + hdr->env->real_subj = hdr->env->subject;
4963 + rfc822_free_address (&hdr->env->from);
4964 + hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
4965 + rfc2047_decode_adrlist (hdr->env->from);
4968 + hdr->date_sent = mutt_parse_date (b, hdr);
4969 + hdr->received = hdr->date_sent;
4972 + FREE (&hdr->env->message_id);
4973 + hdr->env->message_id = safe_strdup (b);
4976 + mutt_free_list (&hdr->env->references);
4977 + hdr->env->references = mutt_parse_references (b, 0);
4980 + hdr->content->length = atoi (b);
4983 + hdr->lines = atoi (b);
4987 + FREE (&hdr->env->xref);
4988 + b = b + 6; /* skips the "Xref: " */
4989 + hdr->env->xref = safe_strdup (b);
4990 + nntp_parse_xref (ctx, nntp_data->group, b, hdr);
5002 + unsigned int base;
5003 + unsigned int first;
5004 + unsigned int last;
5005 + unsigned short *messages;
5009 +#define fc ((FETCH_CONTEXT *) c)
5010 +static int nntp_fetch_numbers (char *line, void *c)
5016 + num = atoi (line);
5017 + if (num < fc->base || num > fc->last)
5019 + fc->messages[num - fc->base] = 1;
5023 +static int add_xover_line (char *line, void *c)
5025 + unsigned int num, total;
5026 + CONTEXT *ctx = fc->ctx;
5027 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5032 + if (ctx->msgcount >= ctx->hdrmax)
5033 + mx_alloc_memory (ctx);
5034 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5035 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5037 + nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5038 + num = ctx->hdrs[ctx->msgcount]->article_num;
5040 + if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5043 + if (num > data->lastLoaded)
5044 + data->lastLoaded = num;
5045 + num = num - fc->first + 1;
5046 + total = fc->last - fc->first + 1;
5047 + if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5048 + mutt_message ("%s %d/%d", fc->msg, num, total);
5051 + mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5057 +static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5058 + unsigned int last)
5060 + char buf[HUGE_STRING];
5061 + char *msg = _("Fetching message headers...");
5062 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5066 + unsigned int current;
5070 + /* if empty group or nothing to do */
5071 + if (!last || first > last)
5074 + /* fetch list of articles */
5078 + fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5079 + if (nntp_data->nserv->hasLISTGROUP)
5081 + mutt_message _("Fetching list of articles...");
5082 + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5083 + if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5085 + mutt_error (_("LISTGROUP command failed: %s"), buf);
5087 + nntp_error ("nntp_fetch_headers()", buf);
5089 + FREE (&fc.messages);
5095 + for (num = 0; num < last - first + 1; num++)
5096 + fc.messages[num] = 1;
5099 + /* CACHE: must be loaded xover cache here */
5100 + num = nntp_data->lastCached - first + 1;
5101 + if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5103 + nntp_cache_expand (buf, nntp_data->cache);
5104 + mutt_message _("Fetching headers from cache...");
5105 + if ((f = safe_fopen (buf, "r")))
5109 + /* counting number of lines */
5110 + while (fgets (buf, sizeof (buf), f) != NULL)
5113 + while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5115 + oldmsgcount = ctx->msgcount;
5117 + fc.last = first + num - 1;
5119 + while (fgets (buf, sizeof (buf), f) != NULL)
5120 + add_xover_line (buf, &fc);
5122 + nntp_data->lastLoaded = fc.last;
5123 + first = fc.last + 1;
5124 + if (ctx->msgcount > oldmsgcount)
5125 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5128 + nntp_delete_cache (nntp_data);
5130 + num = last - first + 1;
5133 + FREE (&fc.messages);
5138 + * Without XOVER, we have to fetch each article header and parse
5139 + * it. With XOVER, we ask for all of them
5141 + mutt_message (msg);
5142 + if (nntp_data->nserv->hasXOVER)
5144 + oldmsgcount = ctx->msgcount;
5148 + snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5149 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5150 + if (ctx->msgcount > oldmsgcount)
5151 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5154 + mutt_error (_("XOVER command failed: %s"), buf);
5156 + nntp_error ("nntp_fetch_headers()", buf);
5158 + FREE (&fc.messages);
5164 + for (current = first; current <= last; current++)
5168 + ret = current - first + 1;
5169 + mutt_message ("%s %d/%d", msg, ret, num);
5171 + if (!fc.messages[current - fc.base])
5174 + if (ctx->msgcount >= ctx->hdrmax)
5175 + mx_alloc_memory (ctx);
5176 + h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5177 + h->index = ctx->msgcount;
5179 + ret = nntp_read_header (ctx, NULL, current);
5180 + if (ret == 0) /* Got article. Fetch next header */
5182 + nntp_get_status (ctx, h, NULL, h->article_num);
5184 + mx_update_context (ctx, 1);
5187 + mutt_free_header (&h); /* skip it */
5190 + FREE (&fc.messages);
5194 + if (current > nntp_data->lastLoaded)
5195 + nntp_data->lastLoaded = current;
5197 + FREE (&fc.messages);
5198 + nntp_data->lastLoaded = last;
5199 + mutt_clear_error ();
5204 + * currently, nntp "mailbox" is "newsgroup"
5206 +int nntp_open_mailbox (CONTEXT *ctx)
5208 + NNTP_DATA *nntp_data;
5209 + NNTP_SERVER *serv;
5210 + char buf[HUGE_STRING];
5211 + char server[LONG_STRING];
5213 + unsigned int first;
5216 + if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5218 + mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5224 + nntp_expand_path (server, sizeof (server), &acct);
5225 + if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5228 + CurrentNewsSrv = serv;
5230 + /* create NNTP-specific state struct if nof found in list */
5231 + if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5233 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5234 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5235 + strcpy (nntp_data->group, buf);
5236 + hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5237 + nntp_add_to_list (serv, nntp_data);
5239 + ctx->data = nntp_data;
5240 + ctx->mx_close = nntp_fastclose_mailbox;
5241 + nntp_data->nserv = serv;
5243 + mutt_message (_("Selecting %s..."), nntp_data->group);
5245 + if (!nntp_data->desc)
5247 + nntp_get_desc (nntp_data, nntp_data->group, NULL);
5248 + if (nntp_data->desc)
5249 + nntp_save_cache_index (serv);
5253 + if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5256 + nntp_error ("nntp_open_mailbox()", buf);
5261 + if (mutt_strncmp ("211", buf, 3))
5263 + LIST *l = serv->list;
5265 + /* GROUP command failed */
5266 + if (!mutt_strncmp ("411", buf, 3))
5268 + mutt_error (_("Newsgroup %s not found on server %s"),
5269 + nntp_data->group, serv->conn->account.host);
5271 + /* CACHE: delete cache and line from .index */
5272 + nntp_delete_cache (nntp_data);
5273 + hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5274 + while (l && l->data != (void *) nntp_data) l = l->next;
5284 + sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5285 + &nntp_data->lastMessage, buf);
5287 + nntp_data->deleted = 0;
5289 + time (&serv->check_time);
5292 + * Check for max adding context. If it is greater than $nntp_context,
5293 + * strip off extra articles
5295 + first = nntp_data->firstMessage;
5296 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5297 + first = nntp_data->lastMessage - NntpContext + 1;
5299 + nntp_data->lastLoaded = first - 1;
5300 + return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5303 +int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5305 + char buf[LONG_STRING];
5306 + char path[_POSIX_PATH_MAX];
5307 + NNTP_CACHE *cache;
5308 + char *m = _("Fetching message...");
5311 + /* see if we already have the message in our cache */
5312 + cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5314 + /* if everything is fine, assign msg->fp and return */
5315 + if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5316 + (msg->fp = fopen (cache->path, "r")))
5319 + /* clear the previous entry */
5320 + unlink (cache->path);
5321 + free (cache->path);
5325 + cache->index = ctx->hdrs[msgno]->index;
5326 + mutt_mktemp (path);
5327 + cache->path = safe_strdup (path);
5328 + if (!(msg->fp = safe_fopen (path, "w+")))
5330 + FREE (&cache->path);
5334 + if (ctx->hdrs[msgno]->article_num == 0)
5335 + snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5336 + ctx->hdrs[msgno]->env->message_id);
5338 + snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5339 + ctx->hdrs[msgno]->article_num);
5341 + ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5342 + msg->fp, ctx->tagged);
5345 + mutt_error (_("Article %d not found on server"),
5346 + ctx->hdrs[msgno]->article_num);
5347 + dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5354 + FREE (&cache->path);
5358 + mutt_free_envelope (&ctx->hdrs[msgno]->env);
5359 + ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5360 + /* fix content length */
5361 + fseek(msg->fp, 0, SEEK_END);
5362 + ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5363 + ctx->hdrs[msgno]->content->offset;
5365 + /* this is called in mutt before the open which fetches the message,
5366 + * which is probably wrong, but we just call it again here to handle
5367 + * the problem instead of fixing it.
5369 + mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5371 + /* These would normally be updated in mx_update_context(), but the
5372 + * full headers aren't parsed with XOVER, so the information wasn't
5375 +#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5376 + ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5377 +#endif /* HAVE_PGP || HAVE_SMIME */
5379 + mutt_clear_error();
5386 +int nntp_post (const char *msg) {
5387 + char buf[LONG_STRING];
5390 + NNTP_DATA *nntp_data;
5392 + if (Context && Context->magic == M_NNTP)
5393 + nntp_data = (NNTP_DATA *)Context->data;
5396 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5397 + !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5399 + mutt_error (_("Can't post article. No connection to news server."));
5402 + nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5405 + if (!(f = safe_fopen (msg, "r")))
5407 + mutt_error (_("Can't post article. Unable to open %s"), msg);
5411 + strfcpy (buf, "POST\r\n", sizeof (buf));
5412 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5414 + mutt_error (_("Can't post article. Connection to %s lost."),
5415 + nntp_data->nserv->conn->account.host);
5418 + if (buf[0] != '3')
5420 + mutt_error (_("Can't post article: %s"), buf);
5426 + while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5428 + len = strlen (buf);
5429 + if (buf[len - 1] == '\n')
5431 + buf[len - 1] = '\r';
5436 + if (buf[1] == '.')
5437 + mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5439 + mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5443 + if (buf[strlen (buf) - 1] != '\n')
5444 + mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5445 + mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5446 + if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5448 + mutt_error (_("Can't post article. Connection to %s lost."),
5449 + nntp_data->nserv->conn->account.host);
5452 + if (buf[0] != '2')
5454 + mutt_error (_("Can't post article: %s"), buf);
5461 +/* nntp_logout_all: close all open connections. */
5462 +void nntp_logout_all (void)
5464 + char buf[LONG_STRING];
5467 + conn = mutt_socket_head ();
5471 + CONNECTION *next = conn->next;
5473 + if (conn->account.type == M_ACCT_TYPE_NNTP)
5475 + mutt_message (_("Closing connection to %s..."), conn->account.host);
5476 + mutt_socket_write (conn, "QUIT\r\n");
5477 + mutt_socket_readln (buf, sizeof (buf), conn);
5478 + mutt_clear_error ();
5479 + mutt_socket_close (conn);
5480 + mutt_socket_free (conn);
5487 +static void nntp_free_acache (NNTP_DATA *data)
5491 + for (i = 0; i < NNTP_CACHE_LEN; i++)
5493 + if (data->acache[i].path)
5495 + unlink (data->acache[i].path);
5496 + FREE (&data->acache[i].path);
5501 +void nntp_delete_data (void *p)
5503 + NNTP_DATA *data = (NNTP_DATA *)p;
5507 + FREE (&data->entries);
5508 + FREE (&data->desc);
5509 + FREE (&data->cache);
5510 + nntp_free_acache (data);
5514 +int nntp_sync_mailbox (CONTEXT *ctx)
5516 + NNTP_DATA *data = ctx->data;
5518 + /* CACHE: update cache and .index files */
5519 + if ((option (OPTSAVEUNSUB) || data->subscribed))
5520 + nntp_save_cache_group (ctx);
5521 + nntp_free_acache (data);
5523 + data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
5527 +int nntp_fastclose_mailbox (CONTEXT *ctx)
5529 + NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
5533 + nntp_free_acache (data);
5534 + if (!data->nserv || !data->nserv->newsgroups || !data->group)
5536 + nntp_save_cache_index (data->nserv);
5537 + if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
5539 + nntp_delete_data (data);
5543 +/* commit changes and terminate connection */
5544 +int nntp_close_mailbox (CONTEXT *ctx)
5548 + mutt_message _("Quitting newsgroup...");
5551 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
5554 + if (data->nserv && data->nserv->conn && ctx->unread)
5556 + ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
5558 + mutt_newsgroup_catchup (data->nserv, data->group);
5563 + nntp_sync_mailbox (ctx);
5564 + if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
5566 + NNTP_SERVER *news;
5568 + news = ((NNTP_DATA *)ctx->data)->nserv;
5569 + newsrc_gen_entries (ctx);
5570 + ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
5571 + mutt_newsrc_update (news);
5573 + mutt_clear_error();
5577 +/* use the GROUP command to poll for new mail */
5578 +static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
5580 + char buf[LONG_STRING];
5583 + if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
5587 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5590 + nntp_error ("nntp_check_mailbox()", buf);
5594 + if (mutt_strncmp ("211", buf, 3))
5597 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5600 + nntp_error ("nntp_check_mailbox()", buf);
5605 + if (!mutt_strncmp ("211", buf, 3))
5610 + sscanf (buf + 4, "%d %d %d", &count, &first, &last);
5611 + nntp_data->firstMessage = first;
5612 + nntp_data->lastMessage = last;
5613 + if (ctx && last > nntp_data->lastLoaded)
5615 + nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
5616 + time (&nntp_data->nserv->check_time);
5619 + if (!last || (!nntp_data->rc && !nntp_data->lastCached))
5620 + nntp_data->unread = count;
5622 + mutt_newsgroup_stat (nntp_data);
5623 + /* active was renumbered? */
5624 + if (last < nntp_data->lastLoaded)
5626 + if (!nntp_data->max)
5628 + nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
5629 + nntp_data->max = 5;
5631 + nntp_data->lastCached = 0;
5632 + nntp_data->num = 1;
5633 + nntp_data->entries[0].first = 1;
5634 + nntp_data->entries[0].last = 0;
5638 + time (&nntp_data->nserv->check_time);
5642 +int nntp_check_mailbox (CONTEXT *ctx)
5644 + return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
5647 +static int add_group (char *buf, void *serv)
5649 +#define s ((NNTP_SERVER *) serv)
5650 + char group[LONG_STRING], mod, desc[HUGE_STRING];
5652 + NNTP_DATA *nntp_data;
5655 + _checked = n; /* _checked have N, where N = number of groups */
5656 + if (!buf) /* at EOF must be zerouth */
5663 + sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
5666 + if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
5669 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
5670 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5671 + strcpy (nntp_data->group, group);
5672 + nntp_data->nserv = s;
5673 + if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
5674 + s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2);
5675 + hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
5676 + nntp_add_to_list (s, nntp_data);
5678 + nntp_data->deleted = 0;
5679 + nntp_data->firstMessage = first;
5680 + nntp_data->lastMessage = last;
5682 + nntp_data->allowed = 1;
5684 + nntp_data->allowed = 0;
5685 + if (nntp_data->desc)
5686 + FREE (&nntp_data->desc);
5688 + nntp_data->desc = safe_strdup (desc);
5689 + if (nntp_data->rc || nntp_data->lastCached)
5690 + mutt_newsgroup_stat (nntp_data);
5691 + else if (nntp_data->lastMessage &&
5692 + nntp_data->firstMessage <= nntp_data->lastMessage)
5693 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
5695 + nntp_data->unread = 0;
5701 +int nntp_check_newgroups (NNTP_SERVER *serv, int force)
5703 + char buf[LONG_STRING];
5704 + char msg[SHORT_STRING];
5705 + NNTP_DATA nntp_data;
5710 + unsigned int count = 0;
5711 + unsigned int total = 0;
5713 + if (!serv || !serv->newgroups_time)
5716 + if (nntp_open_connection (serv) < 0)
5719 + /* check subscribed groups for new news */
5720 + if (option (OPTSHOWNEWNEWS))
5722 + mutt_message _("Checking for new messages...");
5723 + for (l = serv->list; l; l = l->next)
5725 + serv->check_time = 0; /* really check! */
5726 + if (l->data && ((NNTP_DATA *) l->data)->subscribed)
5727 + _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
5733 + mutt_message _("Checking for new newsgroups...");
5734 + now = serv->newgroups_time;
5735 + time (&serv->newgroups_time);
5736 + t = gmtime (&now);
5737 + snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
5738 + (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
5740 + nntp_data.nserv = serv;
5741 + if (Context && Context->magic == M_NNTP)
5742 + nntp_data.group = ((NNTP_DATA *)Context->data)->group;
5744 + nntp_data.group = NULL;
5746 + if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
5747 + add_group, serv, 0) != 0)
5750 + nntp_error ("nntp_check_newgroups()", buf);
5755 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5756 + mutt_message (msg);
5758 + emp.next = l->next;
5760 + emp.next = serv->list;
5765 + ((NNTP_DATA *) l->data)->new = 1;
5772 + nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
5774 + if (ReadInc && (count % ReadInc == 0))
5775 + mutt_message ("%s %d/%d", msg, count, total);
5778 + nntp_save_cache_index (serv);
5779 + mutt_clear_error ();
5783 +/* Load list of all newsgroups from cache ALL */
5784 +int nntp_get_cache_all (NNTP_SERVER *serv)
5786 + char buf[HUGE_STRING];
5789 + nntp_cache_expand (buf, serv->cache);
5790 + if ((f = safe_fopen (buf, "r")))
5794 + while (fgets (buf, sizeof(buf), f) != NULL)
5796 + if (ReadInc && (i % ReadInc == 0))
5797 + mutt_message (_("Loading list from cache... %d"), i);
5798 + add_group (buf, serv);
5801 + add_group (NULL, NULL);
5803 + mutt_clear_error ();
5808 + FREE (&serv->cache);
5813 +/* Load list of all newsgroups from active */
5814 +int nntp_get_active (NNTP_SERVER *serv)
5816 + char msg[SHORT_STRING];
5817 + NNTP_DATA nntp_data;
5820 + if (nntp_open_connection (serv) < 0)
5823 + snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
5824 + serv->conn->account.host);
5825 + mutt_message (msg);
5826 + time (&serv->newgroups_time);
5827 + nntp_data.nserv = serv;
5828 + nntp_data.group = NULL;
5830 + if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
5833 + nntp_error ("nntp_get_active()", "LIST\r\n");
5838 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5839 + mutt_message (msg);
5840 + nntp_get_desc (&nntp_data, "*", msg);
5842 + for (tmp = serv->list; tmp; tmp = tmp->next)
5844 + NNTP_DATA *data = (NNTP_DATA *)tmp->data;
5846 + if (data && data->deleted && !data->rc)
5848 + nntp_delete_cache (data);
5849 + hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
5853 + nntp_save_cache_index (serv);
5855 + mutt_clear_error ();
5860 + * returns -1 if error ocurred while retrieving header,
5861 + * number of articles which ones exist in context on success.
5863 +int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
5867 + /* if msgid is already in context, don't reload them */
5868 + if (hash_find (ctx->id_hash, msgid))
5870 + if (ctx->msgcount == ctx->hdrmax)
5871 + mx_alloc_memory (ctx);
5872 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5873 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5875 + mutt_message (_("Fetching %s from server..."), msgid);
5876 + ret = nntp_read_header (ctx, msgid, 0);
5877 + /* since nntp_read_header() may set read flag, we must reset it */
5878 + ctx->hdrs[ctx->msgcount]->read = 0;
5880 + mutt_free_header (&ctx->hdrs[ctx->msgcount]);
5884 + mx_update_context (ctx, 1);
5895 + unsigned int *child;
5898 +static int check_children (char *s, void *c)
5900 +#define cc ((CHILD_CONTEXT *) c)
5901 + unsigned int i, n;
5903 + if (!s || (n = atoi (s)) == 0)
5905 + for (i = 0; i < cc->ctx->msgcount; i++)
5906 + if (cc->ctx->hdrs[i]->article_num == n)
5908 + if (cc->num >= cc->max)
5909 + safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
5910 + cc->child[cc->num++] = n;
5916 +int nntp_check_children (CONTEXT *ctx, const char *msgid)
5918 + NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
5920 + int i, ret = 0, tmp = 0;
5923 + if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
5924 + !nntp_data->nserv->conn->account.host)
5926 + if (nntp_data->firstMessage > nntp_data->lastLoaded)
5928 + if (!nntp_data->nserv->hasXPAT)
5930 + mutt_error (_("Server %s does not support this operation!"),
5931 + nntp_data->nserv->conn->account.host);
5935 + snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
5936 + nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
5941 + cc.child = safe_malloc (sizeof (unsigned int) * 25);
5942 + if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
5947 + /* dont try to read the xover cache. check_children() already
5948 + * made sure that we dont have the article, so we need to visit
5949 + * the server. Reading the cache at this point is also bad
5950 + * because it would duplicate messages */
5951 + if (option (OPTNEWSCACHE))
5954 + unset_option (OPTNEWSCACHE);
5956 + for (i = 0; i < cc.num; i++)
5958 + if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
5960 + if (ctx->msgcount &&
5961 + ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
5962 + ctx->hdrs[ctx->msgcount - 1]->read = 0;
5965 + set_option (OPTNEWSCACHE);
5969 diff -udprP mutt-1.5.15.orig/nntp.h mutt-1.5.15/nntp.h
5970 --- mutt-1.5.15.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
5971 +++ mutt-1.5.15/nntp.h 2007-04-11 17:46:58.000000000 +0300
5974 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
5975 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
5976 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
5978 + * This program is free software; you can redistribute it and/or modify
5979 + * it under the terms of the GNU General Public License as published by
5980 + * the Free Software Foundation; either version 2 of the License, or
5981 + * (at your option) any later version.
5983 + * This program is distributed in the hope that it will be useful,
5984 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5985 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5986 + * GNU General Public License for more details.
5988 + * You should have received a copy of the GNU General Public License
5989 + * along with this program; if not, write to the Free Software
5990 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5996 +#include "mutt_socket.h"
5997 +#include "mailbox.h"
6001 +#define NNTP_PORT 119
6002 +#define NNTP_SSL_PORT 563
6004 +/* number of entries in the hash table */
6005 +#define NNTP_CACHE_LEN 10
6022 + unsigned int hasXPAT : 1;
6023 + unsigned int hasXGTITLE : 1;
6024 + unsigned int hasXOVER : 1;
6025 + unsigned int hasLISTGROUP : 1;
6026 + unsigned int status : 3;
6032 + time_t newgroups_time;
6033 + time_t check_time;
6035 + LIST *list; /* list of newsgroups */
6036 + LIST *tail; /* last entry of list */
6042 + unsigned int index;
6048 + NEWSRC_ENTRY *entries;
6049 + unsigned int num; /* number of used entries */
6050 + unsigned int max; /* number of allocated entries */
6051 + unsigned int unread;
6052 + unsigned int firstMessage;
6053 + unsigned int lastMessage;
6054 + unsigned int lastLoaded;
6055 + unsigned int lastCached;
6056 + unsigned int subscribed : 1;
6057 + unsigned int rc : 1;
6058 + unsigned int new : 1;
6059 + unsigned int allowed : 1;
6060 + unsigned int deleted : 1;
6064 + NNTP_SERVER *nserv;
6065 + NNTP_CACHE acache[NNTP_CACHE_LEN];
6068 +/* internal functions */
6069 +int nntp_get_active (NNTP_SERVER *);
6070 +int nntp_get_cache_all (NNTP_SERVER *);
6071 +int nntp_save_cache_index (NNTP_SERVER *);
6072 +int nntp_check_newgroups (NNTP_SERVER *, int);
6073 +int nntp_save_cache_group (CONTEXT *);
6074 +int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6075 +void newsrc_gen_entries (CONTEXT *);
6076 +void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6077 +void mutt_newsgroup_stat (NNTP_DATA *);
6078 +void nntp_delete_cache (NNTP_DATA *);
6079 +void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6080 +void nntp_cache_expand (char *, const char *);
6081 +void nntp_delete_data (void *);
6083 +/* exposed interface */
6084 +NNTP_SERVER *mutt_select_newsserver (char *);
6085 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6086 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6087 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6088 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6089 +void nntp_clear_cacheindex (NNTP_SERVER *);
6090 +int mutt_newsrc_update (NNTP_SERVER *);
6091 +int nntp_open_mailbox (CONTEXT *);
6092 +int nntp_sync_mailbox (CONTEXT *);
6093 +int nntp_check_mailbox (CONTEXT *);
6094 +int nntp_close_mailbox (CONTEXT *);
6095 +int nntp_fastclose_mailbox (CONTEXT *);
6096 +int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6097 +int nntp_post (const char *);
6098 +int nntp_check_msgid (CONTEXT *, const char *);
6099 +int nntp_check_children (CONTEXT *, const char *);
6100 +void nntp_buffy (char *);
6101 +void nntp_expand_path (char *, size_t, ACCOUNT *);
6102 +void nntp_logout_all ();
6103 +const char *nntp_format_str (char *, size_t, char, const char *, const char *,
6104 + const char *, const char *, unsigned long, format_flag);
6106 +NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6108 +#endif /* _NNTP_H_ */
6109 diff -udprP mutt-1.5.15.orig/pager.c mutt-1.5.15/pager.c
6110 --- mutt-1.5.15.orig/pager.c 2007-04-02 00:58:56.000000000 +0300
6111 +++ mutt-1.5.15/pager.c 2007-04-11 17:25:15.000000000 +0300
6112 @@ -1055,6 +1055,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
6122 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6123 int flags, ansi_attr *pa, int cnt,
6124 @@ -1490,6 +1495,16 @@ static struct mapping_t PagerHelpExtra[]
6129 +static struct mapping_t PagerNewsHelpExtra[] = {
6130 + { N_("Post"), OP_POST },
6131 + { N_("Followup"), OP_FOLLOWUP },
6132 + { N_("Del"), OP_DELETE },
6133 + { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6140 /* This pager is actually not so simple as it once was. It now operates in
6141 @@ -1531,6 +1546,10 @@ mutt_pager (const char *banner, const ch
6142 int old_PagerIndexLines; /* some people want to resize it
6143 * while inside the pager... */
6146 + char *followup_to;
6149 if (!(flags & M_SHOWCOLOR))
6150 flags |= M_SHOWFLAT;
6152 @@ -1570,7 +1589,11 @@ mutt_pager (const char *banner, const ch
6153 if (IsHeader (extra))
6155 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6156 - mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6157 + mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6159 + (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6162 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6165 @@ -2393,6 +2416,15 @@ search_next:
6167 CHECK_ACL(M_ACL_WRITE, "flag message");
6170 + if (Context->magic == M_NNTP)
6173 + mutt_error _("Can't change 'important' flag on NNTP server.");
6178 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6179 redraw = REDRAW_STATUS | REDRAW_INDEX;
6180 if (option (OPTRESOLVE))
6181 @@ -2426,6 +2458,60 @@ search_next:
6182 redraw = REDRAW_FULL;
6187 + CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6189 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6190 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6191 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6193 + ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6194 + redraw = REDRAW_FULL;
6197 + case OP_FORWARD_TO_GROUP:
6198 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6200 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6201 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6202 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6204 + if (IsMsgAttach (extra))
6205 + mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6206 + extra->idxlen, extra->bdy, SENDNEWS);
6208 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6209 + redraw = REDRAW_FULL;
6213 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6216 + if (IsMsgAttach (extra))
6217 + followup_to = extra->bdy->hdr->env->followup_to;
6219 + followup_to = extra->hdr->env->followup_to;
6221 + if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6222 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6224 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6225 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6226 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6228 + if (IsMsgAttach (extra))
6229 + mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6230 + extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6232 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6233 + extra->ctx, extra->hdr);
6234 + redraw = REDRAW_FULL;
6240 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6242 @@ -2472,7 +2558,7 @@ search_next:
6244 if (IsMsgAttach (extra))
6245 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6246 - extra->idxlen, extra->bdy);
6247 + extra->idxlen, extra->bdy, 0);
6249 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6250 redraw = REDRAW_FULL;
6251 diff -udprP mutt-1.5.15.orig/parse.c mutt-1.5.15/parse.c
6252 --- mutt-1.5.15.orig/parse.c 2007-04-02 00:58:56.000000000 +0300
6253 +++ mutt-1.5.15/parse.c 2007-04-11 17:25:15.000000000 +0300
6254 @@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
6258 -static LIST *mutt_parse_references (char *s, int in_reply_to)
6259 +LIST *mutt_parse_references (char *s, int in_reply_to)
6261 LIST *t, *lst = NULL;
6263 @@ -1068,6 +1068,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6264 e->from = rfc822_parse_adrlist (e->from, p);
6268 + else if (!mutt_strcasecmp (line+1, "ollowup-to"))
6270 + if (!e->followup_to)
6272 + mutt_remove_trailing_ws (p);
6273 + e->followup_to = safe_strdup (mutt_skip_whitespace (p));
6281 @@ -1152,6 +1163,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6287 + if (!mutt_strcasecmp (line + 1, "ewsgroups"))
6289 + FREE (&e->newsgroups);
6290 + mutt_remove_trailing_ws (p);
6291 + e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
6298 + /* field `Organization:' saves only for pager! */
6299 + if (!mutt_strcasecmp (line + 1, "rganization"))
6301 + if (!e->organization && mutt_strcasecmp (p, "unknown"))
6302 + e->organization = safe_strdup (p);
6307 if (!ascii_strcasecmp (line + 1, "eferences"))
6309 @@ -1260,6 +1292,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6310 e->x_label = safe_strdup(p);
6314 + else if (!mutt_strcasecmp (line + 1, "-comment-to"))
6316 + if (!e->x_comment_to)
6317 + e->x_comment_to = safe_strdup (p);
6320 + else if (!mutt_strcasecmp (line + 1, "ref"))
6323 + e->xref = safe_strdup (p);
6330 diff -udprP mutt-1.5.15.orig/pattern.c mutt-1.5.15/pattern.c
6331 --- mutt-1.5.15.orig/pattern.c 2007-04-02 00:58:56.000000000 +0300
6332 +++ mutt-1.5.15/pattern.c 2007-04-11 17:25:15.000000000 +0300
6333 @@ -91,6 +91,9 @@ Flags[] =
6334 { 'U', M_UNREAD, 0, NULL },
6335 { 'v', M_COLLAPSED, 0, NULL },
6336 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6338 + { 'w', M_NEWSGROUPS, 0, eat_regexp },
6340 { 'x', M_REFERENCE, 0, eat_regexp },
6341 { 'X', M_MIMEATTACH, 0, eat_range },
6342 { 'y', M_XLABEL, 0, eat_regexp },
6343 @@ -1208,6 +1211,10 @@ mutt_pattern_exec (struct pattern_t *pat
6345 case M_UNREFERENCED:
6346 return (pat->not ^ (h->thread && !h->thread->child));
6348 + case M_NEWSGROUPS:
6349 + return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6352 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6354 @@ -1276,6 +1283,7 @@ int mutt_pattern_func (int op, char *pro
6355 progress_t progress;
6357 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6358 + if (prompt || op != M_LIMIT)
6359 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6362 diff -udprP mutt-1.5.15.orig/po/POTFILES.in mutt-1.5.15/po/POTFILES.in
6363 --- mutt-1.5.15.orig/po/POTFILES.in 2007-04-02 00:58:57.000000000 +0300
6364 +++ mutt-1.5.15/po/POTFILES.in 2007-04-11 17:25:15.000000000 +0300
6365 @@ -47,6 +47,8 @@ mutt_ssl_gnutls.c
6374 diff -udprP mutt-1.5.15.orig/postpone.c mutt-1.5.15/postpone.c
6375 --- mutt-1.5.15.orig/postpone.c 2007-04-02 00:58:57.000000000 +0300
6376 +++ mutt-1.5.15/postpone.c 2007-04-11 17:25:15.000000000 +0300
6377 @@ -126,15 +126,26 @@ int mutt_num_postponed (int force)
6379 if (LastModify < st.st_mtime)
6382 + int optnews = option (OPTNEWS);
6384 LastModify = st.st_mtime;
6386 if (access (Postponed, R_OK | F_OK) != 0)
6387 return (PostCount = 0);
6390 + unset_option (OPTNEWS);
6392 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6395 PostCount = ctx.msgcount;
6396 mx_fastclose_mailbox (&ctx);
6399 + set_option (OPTNEWS);
6404 diff -udprP mutt-1.5.15.orig/protos.h mutt-1.5.15/protos.h
6405 --- mutt-1.5.15.orig/protos.h 2007-04-02 00:58:57.000000000 +0300
6406 +++ mutt-1.5.15/protos.h 2007-04-11 17:25:15.000000000 +0300
6407 @@ -104,6 +104,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
6408 HASH *mutt_make_subj_hash (CONTEXT *);
6410 LIST *mutt_make_references(ENVELOPE *e);
6411 +LIST *mutt_parse_references (char *, int);
6413 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6414 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
6415 @@ -246,6 +247,7 @@ void mutt_unblock_signals_system (int);
6416 void mutt_update_encoding (BODY *a);
6417 void mutt_version (void);
6418 void mutt_view_attachments (HEADER *);
6419 +void mutt_write_references (LIST *, FILE *);
6420 void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen, int display);
6421 void mutt_set_virtual (CONTEXT *);
6423 diff -udprP mutt-1.5.15.orig/recvattach.c mutt-1.5.15/recvattach.c
6424 --- mutt-1.5.15.orig/recvattach.c 2007-04-02 00:58:57.000000000 +0300
6425 +++ mutt-1.5.15/recvattach.c 2007-04-11 17:25:15.000000000 +0300
6426 @@ -1087,6 +1087,15 @@ void mutt_view_attachments (HEADER *hdr)
6431 + if (Context->magic == M_NNTP)
6434 + mutt_error _("Can't delete attachment from newsserver.");
6439 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6442 @@ -1178,10 +1187,33 @@ void mutt_view_attachments (HEADER *hdr)
6443 case OP_FORWARD_MESSAGE:
6445 mutt_attach_forward (fp, hdr, idx, idxlen,
6446 - menu->tagprefix ? NULL : idx[menu->current]->content);
6447 + menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6448 menu->redraw = REDRAW_FULL;
6452 + case OP_FORWARD_TO_GROUP:
6454 + mutt_attach_forward (fp, hdr, idx, idxlen,
6455 + menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6456 + menu->redraw = REDRAW_FULL;
6462 + if (!idx[menu->current]->content->hdr->env->followup_to ||
6463 + mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6464 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6466 + mutt_attach_reply (fp, hdr, idx, idxlen,
6467 + menu->tagprefix ? NULL : idx[menu->current]->content,
6468 + SENDNEWS|SENDREPLY);
6469 + menu->redraw = REDRAW_FULL;
6475 case OP_GROUP_REPLY:
6477 diff -udprP mutt-1.5.15.orig/recvcmd.c mutt-1.5.15/recvcmd.c
6478 --- mutt-1.5.15.orig/recvcmd.c 2007-04-02 00:58:57.000000000 +0300
6479 +++ mutt-1.5.15/recvcmd.c 2007-04-11 17:25:15.000000000 +0300
6480 @@ -377,7 +377,7 @@ static BODY ** copy_problematic_attachme
6481 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6482 ATTACHPTR ** idx, short idxlen,
6485 + short nattach, int flags)
6488 short mime_fwd_all = 0;
6489 @@ -523,7 +523,7 @@ _("Can't decode all tagged attachments.
6492 /* now that we have the template, send it. */
6493 - ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6494 + ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6498 @@ -550,7 +550,7 @@ _("Can't decode all tagged attachments.
6501 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6502 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6503 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6505 HEADER *curhdr = NULL;
6507 @@ -655,23 +655,23 @@ static void attach_forward_msgs (FILE *
6509 mutt_free_header (&tmphdr);
6511 - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6512 + ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
6517 void mutt_attach_forward (FILE * fp, HEADER * hdr,
6518 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6519 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6524 if (check_all_msg (idx, idxlen, cur, 0) == 0)
6525 - attach_forward_msgs (fp, hdr, idx, idxlen, cur);
6526 + attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
6529 nattach = count_tagged (idx, idxlen);
6530 - attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
6531 + attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
6535 @@ -729,28 +729,40 @@ attach_reply_envelope_defaults (ENVELOPE
6541 + if ((flags & SENDNEWS))
6543 - if (mutt_fetch_recips (env, curenv, flags) == -1)
6545 + /* in case followup set Newsgroups: with Followup-To: if it present */
6546 + if (!env->newsgroups && curenv &&
6547 + mutt_strcasecmp (curenv->followup_to, "poster"))
6548 + env->newsgroups = safe_strdup (curenv->followup_to);
6553 - for (i = 0; i < idxlen; i++)
6556 - if (idx[i]->content->tagged
6557 - && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6558 + if (mutt_fetch_recips (env, curenv, flags) == -1)
6563 + for (i = 0; i < idxlen; i++)
6565 + if (idx[i]->content->tagged
6566 + && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6571 + if ((flags & SENDLISTREPLY) && !env->to)
6573 + mutt_error _("No mailing lists found!");
6577 + mutt_fix_reply_recipients (env);
6580 - if ((flags & SENDLISTREPLY) && !env->to)
6582 - mutt_error _("No mailing lists found!");
6586 - mutt_fix_reply_recipients (env);
6587 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
6590 @@ -811,6 +823,13 @@ void mutt_attach_reply (FILE * fp, HEADE
6591 char prefix[SHORT_STRING];
6595 + if (flags & SENDNEWS)
6596 + set_option (OPTNEWSSEND);
6598 + unset_option (OPTNEWSSEND);
6601 if (check_all_msg (idx, idxlen, cur, 0) == -1)
6603 nattach = count_tagged (idx, idxlen);
6604 diff -udprP mutt-1.5.15.orig/rfc1524.c mutt-1.5.15/rfc1524.c
6605 --- mutt-1.5.15.orig/rfc1524.c 2007-04-02 00:58:58.000000000 +0300
6606 +++ mutt-1.5.15/rfc1524.c 2007-04-11 17:25:15.000000000 +0300
6607 @@ -569,13 +569,13 @@ int rfc1524_expand_filename (char *namet
6611 -int mutt_rename_file (char *oldfile, char *newfile)
6612 +int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
6616 if (access (oldfile, F_OK) != 0)
6618 - if (access (newfile, F_OK) == 0)
6619 + if (!overwrite && access (newfile, F_OK) == 0)
6621 if ((ofp = fopen (oldfile,"r")) == NULL)
6623 @@ -590,3 +590,8 @@ int mutt_rename_file (char *oldfile, cha
6624 mutt_unlink (oldfile);
6628 +int mutt_rename_file (char *oldfile, char *newfile)
6630 + return _mutt_rename_file (oldfile, newfile, 0);
6632 diff -udprP mutt-1.5.15.orig/rfc1524.h mutt-1.5.15/rfc1524.h
6633 --- mutt-1.5.15.orig/rfc1524.h 2007-04-02 00:58:58.000000000 +0300
6634 +++ mutt-1.5.15/rfc1524.h 2007-04-11 17:25:15.000000000 +0300
6635 @@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char
6636 int rfc1524_expand_filename (char *, char *, char *, size_t);
6637 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
6638 int mutt_rename_file (char *, char *);
6639 +int _mutt_rename_file (char *, char *, int);
6641 #endif /* _RFC1524_H */
6642 diff -udprP mutt-1.5.15.orig/send.c mutt-1.5.15/send.c
6643 --- mutt-1.5.15.orig/send.c 2007-04-02 00:58:58.000000000 +0300
6644 +++ mutt-1.5.15/send.c 2007-04-11 16:07:11.000000000 +0300
6646 #include <sys/types.h>
6654 #include "remailer.h"
6656 @@ -214,17 +218,51 @@ static int edit_address (ADDRESS **a, /*
6660 -static int edit_envelope (ENVELOPE *en)
6661 +static int edit_envelope (ENVELOPE *en, int flags)
6663 char buf[HUGE_STRING];
6664 LIST *uh = UserHeader;
6666 - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6668 - if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6670 - if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6673 + if (option (OPTNEWSSEND))
6675 + if (en->newsgroups)
6676 + strfcpy (buf, en->newsgroups, sizeof (buf));
6679 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
6681 + FREE (&en->newsgroups);
6682 + en->newsgroups = safe_strdup (buf);
6684 + if (en->followup_to)
6685 + strfcpy (buf, en->followup_to, sizeof (buf));
6688 + if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
6690 + FREE (&en->followup_to);
6691 + en->followup_to = safe_strdup (buf);
6693 + if (en->x_comment_to)
6694 + strfcpy (buf, en->x_comment_to, sizeof (buf));
6697 + if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
6699 + FREE (&en->x_comment_to);
6700 + en->x_comment_to = safe_strdup (buf);
6705 + if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6707 + if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6709 + if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6715 @@ -260,6 +298,14 @@ static int edit_envelope (ENVELOPE *en)
6720 +char *nntp_get_header (const char *s)
6723 + return safe_strdup (s);
6727 static void process_user_recips (ENVELOPE *env)
6729 LIST *uh = UserHeader;
6730 @@ -272,6 +318,14 @@ static void process_user_recips (ENVELOP
6731 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
6732 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
6733 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
6735 + else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
6736 + env->newsgroups = nntp_get_header (uh->data + 11);
6737 + else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
6738 + env->followup_to = nntp_get_header (uh->data + 12);
6739 + else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
6740 + env->x_comment_to = nntp_get_header (uh->data + 13);
6745 @@ -302,6 +356,12 @@ static void process_user_header (ENVELOP
6746 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
6747 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
6748 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
6750 + ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
6751 + ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
6752 + ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
6754 + ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
6755 ascii_strncasecmp ("subject:", uh->data, 8) != 0)
6758 @@ -645,6 +705,10 @@ void mutt_add_to_reference_headers (ENVE
6763 + if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
6764 + env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
6769 @@ -701,6 +765,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
6771 if (flags & SENDREPLY)
6774 + if ((flags & SENDNEWS))
6776 + /* in case followup set Newsgroups: with Followup-To: if it present */
6777 + if (!env->newsgroups && curenv &&
6778 + mutt_strcasecmp (curenv->followup_to, "poster"))
6779 + env->newsgroups = safe_strdup (curenv->followup_to);
6786 @@ -847,7 +921,18 @@ void mutt_set_followup_to (ENVELOPE *e)
6787 * it hasn't already been set
6790 - if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
6791 + if (!option (OPTFOLLOWUPTO))
6794 + if (option (OPTNEWSSEND))
6796 + if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
6797 + e->followup_to = safe_strdup (e->newsgroups);
6802 + if (!e->mail_followup_to)
6804 if (mutt_is_list_cc (0, e->to, e->cc))
6806 @@ -1008,6 +1093,9 @@ static int send_message (HEADER *msg)
6811 + if (!option (OPTNEWSSEND))
6812 +#endif /* USE_NNTP */
6814 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
6815 msg->env->bcc, tempfile,
6816 @@ -1100,6 +1188,13 @@ ci_send_message (int flags, /* send mod
6821 + if (flags & SENDNEWS)
6822 + set_option (OPTNEWSSEND);
6824 + unset_option (OPTNEWSSEND);
6827 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
6828 mutt_num_postponed (1))
6830 @@ -1130,6 +1225,22 @@ ci_send_message (int flags, /* send mod
6832 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
6836 + * If postponed message is a news article, it have
6837 + * a "Newsgroups:" header line, then set appropriate flag.
6839 + if (msg->env->newsgroups)
6841 + flags |= SENDNEWS;
6842 + set_option (OPTNEWSSEND);
6846 + flags &= ~SENDNEWS;
6847 + unset_option (OPTNEWSSEND);
6852 if (flags & (SENDPOSTPONED|SENDRESEND))
6853 @@ -1237,11 +1348,16 @@ ci_send_message (int flags, /* send mod
6854 if (flags & SENDREPLY)
6855 mutt_fix_reply_recipients (msg->env);
6858 + if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
6859 + msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
6862 if (! (flags & SENDMAILX) &&
6863 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
6864 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
6866 - if (edit_envelope (msg->env) == -1)
6867 + if (edit_envelope (msg->env, flags) == -1)
6871 @@ -1495,6 +1611,11 @@ main_loop:
6876 + if (flags & SENDNEWS)
6877 + mutt_message _("Article not posted.");
6880 mutt_message _("Mail not sent.");
6883 @@ -1527,6 +1648,9 @@ main_loop:
6888 + if (!(flags & SENDNEWS))
6890 if (!msg->env->to && !msg->env->cc && !msg->env->bcc)
6892 if (! (flags & SENDBATCH))
6893 @@ -1559,6 +1683,19 @@ main_loop:
6894 mutt_error _("No subject specified.");
6898 + if ((flags & SENDNEWS) && !msg->env->subject)
6900 + mutt_error _("No subject specified.");
6904 + if ((flags & SENDNEWS) && !msg->env->newsgroups)
6906 + mutt_error _("No newsgroup specified.");
6911 if (msg->content->next)
6912 msg->content = mutt_make_multipart (msg->content);
6913 @@ -1764,7 +1901,12 @@ full_fcc:
6916 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
6917 - mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
6918 + mutt_message (i != 0 ? _("Sending in background.") :
6920 + (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
6925 if (WithCrypto && (msg->security & ENCRYPT))
6927 diff -udprP mutt-1.5.15.orig/sendlib.c mutt-1.5.15/sendlib.c
6928 --- mutt-1.5.15.orig/sendlib.c 2007-04-03 20:52:56.000000000 +0300
6929 +++ mutt-1.5.15/sendlib.c 2007-04-11 17:25:15.000000000 +0300
6931 #include <sys/wait.h>
6938 #ifdef HAVE_SYSEXITS_H
6939 #include <sysexits.h>
6940 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
6941 @@ -1525,7 +1529,7 @@ void mutt_write_address_list (ADDRESS *a
6942 /* need to write the list in reverse because they are stored in reverse order
6943 * when parsed to speed up threading
6945 -static void write_references (LIST *r, FILE *f)
6946 +void mutt_write_references (LIST *r, FILE *f)
6949 int refcnt = 0, refmax = 0;
6950 @@ -1742,6 +1746,9 @@ int mutt_write_rfc822_header (FILE *fp,
6951 LIST *tmp = env->userhdrs;
6952 int has_agent = 0; /* user defined user-agent header field exists */
6955 + if (!option (OPTNEWSSEND))
6957 if (mode == 0 && !privacy)
6958 fputs (mutt_make_date (buffer, sizeof(buffer)), fp);
6960 @@ -1768,6 +1775,9 @@ int mutt_write_rfc822_header (FILE *fp,
6961 mutt_write_address_list (env->to, fp, 4, 0);
6965 + if (!option (OPTNEWSSEND))
6967 fputs ("To: \n", fp);
6970 @@ -1776,6 +1786,9 @@ int mutt_write_rfc822_header (FILE *fp,
6971 mutt_write_address_list (env->cc, fp, 4, 0);
6975 + if (!option (OPTNEWSSEND))
6977 fputs ("Cc: \n", fp);
6980 @@ -1787,8 +1800,28 @@ int mutt_write_rfc822_header (FILE *fp,
6985 + if (!option (OPTNEWSSEND))
6987 fputs ("Bcc: \n", fp);
6990 + if (env->newsgroups)
6991 + fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
6992 + else if (mode == 1 && option (OPTNEWSSEND))
6993 + fputs ("Newsgroups: \n", fp);
6995 + if (env->followup_to)
6996 + fprintf (fp, "Followup-To: %s\n", env->followup_to);
6997 + else if (mode == 1 && option (OPTNEWSSEND))
6998 + fputs ("Followup-To: \n", fp);
7000 + if (env->x_comment_to)
7001 + fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
7002 + else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
7003 + fputs ("X-Comment-To: \n", fp);
7007 mutt_write_one_header (fp, "Subject", env->subject, NULL, 0);
7009 @@ -1807,6 +1840,9 @@ int mutt_write_rfc822_header (FILE *fp,
7010 fputs ("Reply-To: \n", fp);
7012 if (env->mail_followup_to)
7014 + if (!option (OPTNEWSSEND))
7017 fputs ("Mail-Followup-To: ", fp);
7018 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
7019 @@ -1817,7 +1853,7 @@ int mutt_write_rfc822_header (FILE *fp,
7020 if (env->references)
7022 fputs ("References:", fp);
7023 - write_references (env->references, fp);
7024 + mutt_write_references (env->references, fp);
7028 @@ -1829,7 +1865,7 @@ int mutt_write_rfc822_header (FILE *fp,
7029 if (env->in_reply_to)
7031 fputs ("In-Reply-To:", fp);
7032 - write_references (env->in_reply_to, fp);
7033 + mutt_write_references (env->in_reply_to, fp);
7037 @@ -2145,11 +2181,30 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7038 const char *msg, /* file containing message */
7039 int eightbit) /* message contains 8bit chars */
7041 - char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
7042 + char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
7044 size_t argslen = 0, argsmax = 0;
7048 + if (option (OPTNEWSSEND))
7050 + char cmd[LONG_STRING];
7052 + mutt_FormatString (cmd, sizeof (cmd), NONULL (Inews), nntp_format_str, 0, 0);
7055 + i = nntp_post (msg);
7060 + s = safe_strdup (cmd);
7064 + s = safe_strdup (Sendmail);
7068 while ((ps = strtok (ps, " ")))
7069 @@ -2173,6 +2228,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7074 + if (!option (OPTNEWSSEND))
7077 if (eightbit && option (OPTUSE8BITMIME))
7078 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7080 @@ -2204,6 +2263,9 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7081 args = add_args (args, &argslen, &argsmax, to);
7082 args = add_args (args, &argslen, &argsmax, cc);
7083 args = add_args (args, &argslen, &argsmax, bcc);
7088 if (argslen == argsmax)
7089 safe_realloc (&args, sizeof (char *) * (++argsmax));
7090 @@ -2336,6 +2398,9 @@ void mutt_prepare_envelope (ENVELOPE *en
7091 rfc2047_encode_adrlist (env->reply_to, "Reply-To");
7095 + if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
7098 rfc2047_encode_string (&env->subject);
7100 @@ -2441,6 +2506,10 @@ int mutt_bounce_message (FILE *fp, HEADE
7102 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
7105 + unset_option (OPTNEWSSEND);
7108 ret = _mutt_bounce_message (fp, h, to, resent_from, from);
7110 rfc822_free_address (&from);
7111 diff -udprP mutt-1.5.15.orig/sort.c mutt-1.5.15/sort.c
7112 --- mutt-1.5.15.orig/sort.c 2007-04-02 00:58:58.000000000 +0300
7113 +++ mutt-1.5.15/sort.c 2007-04-11 17:25:15.000000000 +0300
7114 @@ -149,6 +149,15 @@ int compare_order (const void *a, const
7115 HEADER **ha = (HEADER **) a;
7116 HEADER **hb = (HEADER **) b;
7119 + if ((*ha)->article_num && (*hb)->article_num)
7121 + int result = (*ha)->article_num - (*hb)->article_num;
7122 + AUXSORT(result,a,b);
7123 + return (SORTCODE (result));
7127 /* no need to auxsort because you will never have equality here */
7128 return (SORTCODE ((*ha)->index - (*hb)->index));
7130 diff -udprP mutt-1.5.15.orig/url.c mutt-1.5.15/url.c
7131 --- mutt-1.5.15.orig/url.c 2007-04-02 00:58:58.000000000 +0300
7132 +++ mutt-1.5.15/url.c 2007-04-11 17:25:15.000000000 +0300
7133 @@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] =
7134 { "imaps", U_IMAPS },
7137 + { "news", U_NNTP },
7138 + { "newss", U_NNTPS },
7139 { "mailto", U_MAILTO },
7141 { "smtps", U_SMTPS },
7142 diff -udprP mutt-1.5.15.orig/url.h mutt-1.5.15/url.h
7143 --- mutt-1.5.15.orig/url.h 2007-04-02 00:58:58.000000000 +0300
7144 +++ mutt-1.5.15/url.h 2007-04-11 17:25:15.000000000 +0300
7145 @@ -8,6 +8,8 @@ typedef enum url_scheme
7154 diff -udprP mutt-1.5.15.orig/Makefile.am mutt-1.5.15/Makefile.am
7155 --- mutt-1.5.15.orig/Makefile.am 2007-04-06 23:04:45.000000000 +0300
7156 +++ mutt-1.5.15/Makefile.am 2007-04-11 17:25:15.000000000 +0300
7157 @@ -62,6 +62,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
7158 smtp.c browser.h mbyte.h remailer.h url.h \
7159 crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
7160 pgppacket.c mutt_idna.h hcache.h hcache.c bcache.c bcache.h mutt_ssl_gnutls.c \
7162 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c \
7165 @@ -73,6 +74,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7166 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7167 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7168 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7169 + nntp.h ChangeLog.nntp \
7170 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7171 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
7172 makedoc.c makedoc-defs.h stamp-doc-rc README.SSL smime.h \
7173 diff -udprP mutt-1.5.15.orig/Makefile.in mutt-1.5.15/Makefile.in
7174 --- mutt-1.5.15.orig/Makefile.in 2007-04-06 23:05:40.000000000 +0300
7175 +++ mutt-1.5.15/Makefile.in 2007-04-11 17:25:15.000000000 +0300
7176 @@ -330,6 +330,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
7177 smtp.c browser.h mbyte.h remailer.h url.h \
7178 crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
7179 pgppacket.c mutt_idna.h hcache.h hcache.c bcache.c bcache.h mutt_ssl_gnutls.c \
7181 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c \
7184 @@ -341,6 +342,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7185 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7186 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7187 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
7188 + nntp.h ChangeLog.nntp \
7189 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7190 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
7191 makedoc.c makedoc-defs.h stamp-doc-rc README.SSL smime.h \
7192 @@ -554,6 +556,8 @@ distclean-compile:
7193 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@
7194 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@
7195 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@
7196 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@
7197 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@
7198 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@
7199 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
7200 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@
7201 diff -udprP mutt-1.5.15.orig/Muttrc mutt-1.5.15/Muttrc
7202 --- mutt-1.5.15.orig/Muttrc 2007-04-06 23:34:36.000000000 +0300
7203 +++ mutt-1.5.15/Muttrc 2007-04-11 18:20:29.000000000 +0300
7204 @@ -263,6 +263,28 @@ attachments -I message/external-body
7208 +# set ask_follow_up=no
7210 +# Name: ask_follow_up
7215 +# If set, Mutt will prompt you for follow-up groups before editing
7216 +# the body of an outgoing message.
7219 +# set ask_x_comment_to=no
7221 +# Name: ask_x_comment_to
7226 +# If set, Mutt will prompt you for x-comment-to field before editing
7227 +# the body of an outgoing message.
7230 # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
7232 # Name: attach_format
7233 @@ -430,6 +452,17 @@ attachments -I message/external-body
7234 # access time when checking for new mail.
7237 +# set catchup_newsgroup=ask-yes
7239 +# Name: catchup_newsgroup
7244 +# If this variable is set, Mutt will mark all articles in newsgroup
7245 +# as read when you quit the newsgroup (catchup newsgroup).
7251 @@ -927,6 +960,19 @@ attachments -I message/external-body
7252 # of the same email for you.
7255 +# set followup_to_poster=ask-yes
7257 +# Name: followup_to_poster
7262 +# If this variable is set and the keyword "poster" is present in
7263 +# Followup-To header, follow-up to newsgroup function is not
7264 +# permitted. The message will be mailed to the submitter of the
7265 +# message via mail.
7271 @@ -1024,6 +1070,28 @@ attachments -I message/external-body
7272 # "Franklin" to "Franklin, Steve".
7275 +# set group_index_format="%4C %M%N %5s %-45.45f %d"
7277 +# Name: group_index_format
7279 +# Default: "%4C %M%N %5s %-45.45f %d"
7282 +# This variable allows you to customize the newsgroup browser display to
7283 +# your personal taste. This string is similar to ``index_format'', but
7284 +# has its own set of printf()-like sequences:
7286 +# %C current newsgroup number
7287 +# %d description of newsgroup (becomes from server)
7288 +# %f newsgroup name
7289 +# %M - if newsgroup not allowed for direct post (moderated for example)
7290 +# %N N if newsgroup is new, u if unsubscribed, blank otherwise
7291 +# %n number of new articles in newsgroup
7292 +# %s number of unread articles in newsgroup
7293 +# %>X right justify the rest of the string and pad with character "X"
7294 +# %|X pad to the end of the line with character "X"
7300 @@ -1469,6 +1537,7 @@ attachments -I message/external-body
7301 # %E number of messages in current thread
7302 # %f entire From: line (address + real name)
7303 # %F author name, or recipient name if the message is from you
7304 +# %g newsgroup name (if compiled with nntp support)
7305 # %H spam attribute(s) of this message
7306 # %i message-id of the current message
7307 # %l number of lines in the message (does not work with maildir,
7308 @@ -1482,12 +1551,14 @@ attachments -I message/external-body
7309 # %n author's real name (or address if missing)
7310 # %O (_O_riginal save folder) Where mutt would formerly have
7311 # stashed the message: list name or recipient name if no list
7312 +# %R `x-comment-to:' field (if present and compiled with nntp support)
7313 # %s subject of the message
7314 # %S status of the message (N/D/d/!/r/*)
7315 # %t `to:' field (recipients)
7316 # %T the appropriate character from the $to_chars string
7317 # %u user (login) name of the author
7318 # %v first name of the author, or the recipient if the message is from you
7319 +# %W name of organization of author (`organization:' field)
7320 # %X number of attachments
7321 # (please see the ``attachments'' section for possible speed effects)
7322 # %y `x-label:' field, if present
7323 @@ -1513,6 +1584,22 @@ attachments -I message/external-body
7324 # See also: ``$to_chars''.
7334 +# If set, specifies the program and arguments used to deliver news posted
7335 +# by Mutt. Otherwise, mutt posts article using current connection to
7336 +# news server. The following printf-style sequence is understood:
7338 +# %s newsserver name
7340 +# Example: set inews="/usr/local/bin/inews -hS"
7343 # set ispell="ispell"
7346 @@ -1856,6 +1943,18 @@ attachments -I message/external-body
7347 # be attached to the newly composed message if this option is set.
7350 +# set mime_subject=yes
7352 +# Name: mime_subject
7357 +# If unset, 8-bit ``subject:'' line in article header will not be
7358 +# encoded according to RFC2047 to base64. This is useful when message
7359 +# is Usenet article, because MIME for news is nonstandard feature.
7362 # set mix_entry_format="%4n %c %-16s %a"
7364 # Name: mix_entry_format
7365 @@ -1948,6 +2047,118 @@ attachments -I message/external-body
7366 # See also ``$read_inc'' and ``$write_inc''.
7369 +# set news_cache_dir="~/.mutt"
7371 +# Name: news_cache_dir
7373 +# Default: "~/.mutt"
7376 +# This variable pointing to directory where Mutt will save cached news
7377 +# articles headers in. If unset, headers will not be saved at all
7378 +# and will be reloaded each time when you enter to newsgroup.
7381 +# set news_server=""
7383 +# Name: news_server
7388 +# This variable specifies domain name or address of NNTP server. It
7389 +# defaults to the newsserver specified in the environment variable
7390 +# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
7391 +# specify username and an alternative port for each newsserver, ie:
7393 +# [news[s]://][username[:password]@]newsserver[:port]
7396 +# set newsrc="~/.newsrc"
7400 +# Default: "~/.newsrc"
7403 +# The file, containing info about subscribed newsgroups - names and
7404 +# indexes of read articles. The following printf-style sequence
7407 +# %s newsserver name
7410 +# set nntp_context=1000
7412 +# Name: nntp_context
7417 +# This variable defines number of articles which will be in index when
7418 +# newsgroup entered. If active newsgroup have more articles than this
7419 +# number, oldest articles will be ignored. Also controls how many
7420 +# articles headers will be saved in cache when you quit newsgroup.
7423 +# set nntp_load_description=yes
7425 +# Name: nntp_load_description
7430 +# This variable controls whether or not descriptions for each newsgroup
7431 +# must be loaded when newsgroup is added to list (first time list
7432 +# loading or new newsgroup adding).
7442 +# Your login name on the NNTP server. If unset and NNTP server requires
7443 +# authentification, Mutt will prompt you for your account name when you
7444 +# connect to newsserver.
7454 +# Your password for NNTP account.
7464 +# The time in seconds until any operations on newsgroup except post new
7465 +# article will cause recheck for new news. If set to 0, Mutt will
7466 +# recheck newsgroup on each operation in index (stepping, read article,
7470 +# set nntp_reconnect=ask-yes
7472 +# Name: nntp_reconnect
7477 +# Controls whether or not Mutt will try to reconnect to newsserver when
7481 # set pager="builtin"
7484 @@ -3151,6 +3362,19 @@ attachments -I message/external-body
7485 # string after the inclusion of a message which is being replied to.
7488 +# set post_moderated=ask-yes
7490 +# Name: post_moderated
7495 +# If set to yes, Mutt will post article to newsgroup that have
7496 +# not permissions to posting (e.g. moderated). Note: if newsserver
7497 +# does not support posting to that newsgroup or totally read-only, that
7498 +# posting will not have an effect.
7501 # set postpone=ask-yes
7504 @@ -3676,6 +3900,41 @@ attachments -I message/external-body
7505 # shell from /etc/passwd is used.
7508 +# set save_unsubscribed=no
7510 +# Name: save_unsubscribed
7515 +# When set, info about unsubscribed newsgroups will be saved into
7516 +# ``newsrc'' file and into cache.
7519 +# set show_new_news=yes
7521 +# Name: show_new_news
7526 +# If set, newsserver will be asked for new newsgroups on entering
7527 +# the browser. Otherwise, it will be done only once for a newsserver.
7528 +# Also controls whether or not number of new articles of subscribed
7529 +# newsgroups will be then checked.
7532 +# set show_only_unread=no
7534 +# Name: show_only_unread
7539 +# If set, only subscribed newsgroups that contain unread articles
7540 +# will be displayed in browser.
7543 # set sig_dashes=yes
7546 @@ -4374,3 +4633,14 @@ attachments -I message/external-body
7550 +# set x_comment_to=no
7552 +# Name: x_comment_to
7557 +# If set, Mutt will add ``X-Comment-To:'' field (that contains full
7558 +# name of original article author) to article that followuped to newsgroup.
7561 diff -udprP mutt-1.5.15.orig/configure mutt-1.5.15/configure
7562 --- mutt-1.5.15.orig/configure 2007-04-06 10:17:16.000000000 +0300
7563 +++ mutt-1.5.15/configure 2007-04-11 17:25:15.000000000 +0300
7564 @@ -1341,6 +1341,7 @@ Optional Features:
7565 Force use of an external dotlock program
7566 --enable-pop Enable POP3 support
7567 --enable-imap Enable IMAP support
7568 + --enable-nntp Enable NNTP support
7569 --enable-smtp include internal SMTP relay support
7570 --enable-debug Enable debugging support
7571 --enable-flock Use flock() to lock files
7572 @@ -13918,6 +13919,20 @@ fi
7576 +# Check whether --enable-nntp or --disable-nntp was given.
7577 +if test "${enable_nntp+set}" = set; then
7578 + enableval="$enable_nntp"
7579 + if test x$enableval = xyes ; then
7580 + cat >>confdefs.h <<\_ACEOF
7584 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
7592 for ac_func in strftime