1 WARNING: Run the following script before configure:
9 Vsevolod Volkov <vvv@mutt.org.ua>
12 diff -udprP mutt-1.5.13.orig/ChangeLog.nntp mutt-1.5.13/ChangeLog.nntp
13 --- mutt-1.5.13.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14 +++ mutt-1.5.13/ChangeLog.nntp 2006-08-15 13:12:32.000000000 +0300
16 +* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
19 +* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
21 +- fixed reading empty .newsrc
23 +* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
26 +* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
29 +* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
32 +* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
35 +* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
37 +- function mutt_update_list_file() moved to newsrc.c and changed algorithm
39 +* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
40 +- fixed error in nntp_logout_all()
42 +* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
43 +- fixed debug output in mutt_newsrc_update()
44 +- added optional support of LISTGROUP command
45 +- fixed typo in nntp_parse_xref()
47 +* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
50 +* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
53 +* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
56 +* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
58 +- added space after newsgroup name in .newsrc file
60 +* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
61 +- nntp patch: fixed SIGSEGV when posting article
63 +* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
66 +* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
68 +- replace safe_free calls by the FREE macro
70 +* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
72 +- nntp authentication can be passed after any command
74 +* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
77 +* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
80 +* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
82 +- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
83 + <reconstruct-thread> functions
84 +- fixed message about nntp reconnect
85 +- fixed <attach-news-message> function using browser
86 +- added support of Followup-To: poster
87 +- added %n (new articles) in group_index_format
88 +- posting articles without inews by default
90 +* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
93 +* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
96 +* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
98 +- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
99 +- added default content disposition
101 +* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
104 +* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
105 +- update to 1.3.23.2
106 +- fixed segfault if mutt_conn_find() returns null
108 +* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
109 +- update to 1.3.23.1
110 +- added support of LISTGROUP command
111 +- added support for servers with broken overview
112 +- disabled <flag-message> function on news server
113 +- fixed error storing bad authentication information
115 +* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
117 +- fixed typo in buffy.c
118 +- added substitution of %s parameter in $inews variable
120 +* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
121 +- update to 1.3.22.1
124 +* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
127 +* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
129 +- removed 'server-hook', use 'account-hook' instead
130 +- fixed error opening NNTP server without newsgroup using -f option
132 +* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
135 +* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
137 +- fixed typo in nntp_attempt_features()
138 +- changed algorithm of XGTITLE command testing
139 +- disabled writing of NNTP password in debug file
140 +- fixed reading and writing of long newsrc lines
141 +- changed checking of last line while reading lines from server
142 +- fixed possible buffer overrun in nntp_parse_newsrc_line()
143 +- removed checking of XHDR command
144 +- compare NNTP return codes without trailing space
146 +* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
148 +- support for 'LIST NEWSGROUPS' command to read descriptions
150 +* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
153 +* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
156 +* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
158 +- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
160 +* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
163 +* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
164 +- Fixed problem if last article in group is deleted
166 +* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
167 +- Fixed checking of XGTITLE command on some servers
169 +* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
170 +- Added \r in AUTHINFO commands
172 +* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
175 +* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
177 +- fixed error opening newsgroup from mutt started with -g or -G
179 +* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
181 +- hotkey 'G' (get-message) replaced with '^G'
183 +* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
185 +- changed delay displaying error messages from 1 to 2 seconds
186 +- fixed error compiling with nntp and without imap
188 +* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
189 +- fixed catchup in index
190 +- fixed nntp_open_mailbox()
192 +* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
193 +- functions <edit> and <delete-entry> disabled
194 +- format of news mailbox names changed to url form
195 +- option nntp_attempts removed
196 +- option reconnect_news renamed to nntp_reconnect
197 +- default value of nntp_poll changed from 30 to 60
198 +- error handling improved
200 +* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
202 +- new option show_only_unread
203 +- add newsgroup completion
205 +* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
208 +* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
211 +* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
213 +- authentication code update
214 +- fix for changing to newsgroup from mailbox with read messages
215 +- socket code optimization
217 +* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
220 +* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
221 +- don't substitute current newsgroup with deleted new messages
223 +* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
225 +- fix for substitution of newsgroup after reconnection
226 +- fix for loading newsgroups with very long names
227 +- fix for loading more than 32768 newsgroups
229 +* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
232 +* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
235 +* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
238 +* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
241 +* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
244 +* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
247 +* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
248 +- add substitution of newsgroup with new messages by default
250 +* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
251 +- add attach message from newsgroup
252 +- add one-line help in newsreader mode
253 +- disable 'change-dir' command in newsgroups browser
256 +* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
257 +- get default newsserver name from file /etc/nntpserver
258 +- use case insensitive server names
259 +- add print-style sequence %s to $newsrc
262 +* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
263 +- remove 'X-FTN-Origin' header processing
265 +* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
269 +* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
270 +- fix mutt_select_newsserver()
271 +- remove 'toggle-mode' function
272 +- add 'change-newsgroup' function
274 +* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
277 +* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
278 +- fix error 'bounce' function after 'post'
279 +- add 'forward to newsgroup' function
281 +* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
282 +- 'forward' function works in newsreader mode
283 +- add 'post' and 'followup' functions to pager and attachment menu
284 +- fix active descriptions and allowed flag reload
286 +* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
288 +- remove deleted newsgroups from list
290 +* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
291 +- update .newsrc in browser
293 +* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
294 +- reload .newsrc if externally modified
295 +- fix active cache update
297 +* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
300 +* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
301 +- patch *.update_list_file is not required
302 +- count lines when loading descriptions
303 +- remove cache of unsubscribed newsgroups
305 +* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
306 +- load list of newsgroups from cache faster
308 +* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
311 +* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
312 +- fix unread messages in browser
313 +- fix newsrc_gen_entries()
315 +* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
316 +- fix mutt_newsgroup_stat()
317 +- fix nntp_delete_cache()
318 +- fix nntp_get_status()
319 +- fix check_children()
320 +- fix nntp_fetch_headers()
322 +* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
325 +* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
326 +- fix updating new messages in cache
328 +* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
329 +- change default cache filenames
330 +- fix updating new messages in cache
332 +* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
333 +- fix segmentation fault in news groups browser
335 +* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
338 +* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
341 +* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
342 +- add X-Comment-To editing
343 +- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
344 +- add variables $ask_followup_to and $ask_x_comment_to
346 +* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
348 diff -udprP mutt-1.5.13.orig/OPS mutt-1.5.13/OPS
349 --- mutt-1.5.13.orig/OPS 2005-07-24 19:56:42.000000000 +0300
350 +++ mutt-1.5.13/OPS 2006-08-15 13:04:56.000000000 +0300
351 @@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
352 OP_BROWSER_NEW_FILE "select a new file in this directory"
353 OP_BROWSER_VIEW_FILE "view file"
354 OP_BROWSER_TELL "display the currently selected file's name"
355 -OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
356 -OP_BROWSER_UNSUBSCRIBE "unsubscribe to current mailbox (IMAP only)"
357 +OP_BROWSER_SUBSCRIBE "subscribe to current (IMAP/NNTP only)"
358 +OP_BROWSER_UNSUBSCRIBE "unsubscribe to current (IMAP/NNTP only)"
359 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
360 OP_BUFFY_LIST "list mailboxes with new mail"
361 +OP_CATCHUP "mark all articles in newsgroup as read"
362 OP_CHANGE_DIRECTORY "change directories"
363 OP_CHECK_NEW "check mailboxes for new mail"
364 OP_COMPOSE_ATTACH_FILE "attach a file(s) to this message"
365 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
366 +OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message"
367 OP_COMPOSE_EDIT_BCC "edit the BCC list"
368 OP_COMPOSE_EDIT_CC "edit the CC list"
369 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
370 @@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
371 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
372 OP_COMPOSE_EDIT_MESSAGE "edit the message"
373 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
374 +OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
375 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
376 +OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
377 +OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
378 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
379 OP_COMPOSE_EDIT_TO "edit the TO list"
380 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
381 @@ -85,8 +90,13 @@ OP_EXIT "exit this menu"
382 OP_FILTER "filter attachment through a shell command"
383 OP_FIRST_ENTRY "move to the first entry"
384 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
385 +OP_FOLLOWUP "followup to newsgroup"
386 +OP_FORWARD_TO_GROUP "forward to newsgroup"
387 OP_FORWARD_MESSAGE "forward a message with comments"
388 OP_GENERIC_SELECT_ENTRY "select the current entry"
389 +OP_GET_CHILDREN "get all children of the current message"
390 +OP_GET_MESSAGE "get message with Message-Id"
391 +OP_GET_PARENT "get parent of the current message"
392 OP_GROUP_REPLY "reply to all recipients"
393 OP_HALF_DOWN "scroll down 1/2 page"
394 OP_HALF_UP "scroll up 1/2 page"
395 @@ -94,11 +104,14 @@ OP_HELP "this screen"
396 OP_JUMP "jump to an index number"
397 OP_LAST_ENTRY "move to the last entry"
398 OP_LIST_REPLY "reply to specified mailing list"
399 +OP_LOAD_ACTIVE "load active file from NNTP server"
400 OP_MACRO "execute a macro"
401 OP_MAIL "compose a new mail message"
402 OP_MAIN_BREAK_THREAD "break the thread in two"
403 OP_MAIN_CHANGE_FOLDER "open a different folder"
404 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
405 +OP_MAIN_CHANGE_GROUP "open a different newsgroup"
406 +OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
407 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
408 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
409 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
410 @@ -136,6 +149,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
411 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
412 OP_PAGER_TOP "jump to the top of the message"
413 OP_PIPE "pipe message/attachment to a shell command"
414 +OP_POST "post message to newsgroup"
415 OP_PREV_ENTRY "move to the previous entry"
416 OP_PREV_LINE "scroll up one line"
417 OP_PREV_PAGE "move to the previous page"
418 @@ -144,6 +158,7 @@ OP_QUERY "query external program for add
419 OP_QUERY_APPEND "append new query results to current results"
420 OP_QUIT "save changes to mailbox and quit"
421 OP_RECALL_MESSAGE "recall a postponed message"
422 +OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
423 OP_REDRAW "clear and redraw the screen"
424 OP_REFORMAT_WINCH "{internal}"
425 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
426 @@ -158,18 +173,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
427 OP_SHELL_ESCAPE "invoke a command in a subshell"
428 OP_SORT "sort messages"
429 OP_SORT_REVERSE "sort messages in reverse order"
430 +OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
431 OP_TAG "tag the current entry"
432 OP_TAG_PREFIX "apply next function to tagged messages"
433 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
434 OP_TAG_SUBTHREAD "tag the current subthread"
435 OP_TAG_THREAD "tag the current thread"
436 OP_TOGGLE_NEW "toggle a message's 'new' flag"
437 +OP_TOGGLE_READ "toggle view of read messages"
438 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
439 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
440 OP_TOP_PAGE "move to the top of the page"
441 +OP_UNCATCHUP "mark all articles in newsgroup as unread"
442 OP_UNDELETE "undelete the current entry"
443 OP_UNDELETE_THREAD "undelete all messages in thread"
444 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
445 +OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
446 OP_VERSION "show the Mutt version number and date"
447 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
448 OP_VIEW_ATTACHMENTS "show MIME attachments"
449 diff -udprP mutt-1.5.13.orig/PATCHES mutt-1.5.13/PATCHES
450 --- mutt-1.5.13.orig/PATCHES 2006-08-11 13:55:43.000000000 +0300
451 +++ mutt-1.5.13/PATCHES 2006-08-15 13:04:56.000000000 +0300
454 diff -udprP mutt-1.5.13.orig/account.c mutt-1.5.13/account.c
455 --- mutt-1.5.13.orig/account.c 2005-09-18 11:22:21.000000000 +0300
456 +++ mutt-1.5.13/account.c 2006-08-15 13:04:56.000000000 +0300
457 @@ -54,6 +54,11 @@ int mutt_account_match (const ACCOUNT* a
462 + if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
466 if (a1->flags & a2->flags & M_ACCT_USER)
467 return (!strcmp (a1->user, a2->user));
468 if (a1->flags & M_ACCT_USER)
469 @@ -123,6 +128,16 @@ void mutt_account_tourl (ACCOUNT* accoun
474 + if (account->type == M_ACCT_TYPE_NNTP)
476 + if (account->flags & M_ACCT_SSL)
477 + url->scheme = U_NNTPS;
479 + url->scheme = U_NNTP;
483 url->host = account->host;
484 if (account->flags & M_ACCT_PORT)
485 url->port = account->port;
486 @@ -148,6 +163,10 @@ int mutt_account_getuser (ACCOUNT* accou
487 else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
488 strfcpy (account->user, PopUser, sizeof (account->user));
491 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
492 + strfcpy (account->user, NntpUser, sizeof (account->user));
494 /* prompt (defaults to unix username), copy into account->user */
497 @@ -204,6 +223,10 @@ int mutt_account_getpass (ACCOUNT* accou
498 else if ((account->type == M_ACCT_TYPE_POP) && PopPass)
499 strfcpy (account->pass, PopPass, sizeof (account->pass));
502 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
503 + strfcpy (account->pass, NntpPass, sizeof (account->pass));
507 snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
508 diff -udprP mutt-1.5.13.orig/account.h mutt-1.5.13/account.h
509 --- mutt-1.5.13.orig/account.h 2005-09-18 11:22:21.000000000 +0300
510 +++ mutt-1.5.13/account.h 2006-08-15 13:04:56.000000000 +0300
511 @@ -28,6 +28,7 @@ enum
513 M_ACCT_TYPE_NONE = 0,
519 diff -udprP mutt-1.5.13.orig/attach.h mutt-1.5.13/attach.h
520 --- mutt-1.5.13.orig/attach.h 2005-09-18 11:22:21.000000000 +0300
521 +++ mutt-1.5.13/attach.h 2006-08-15 13:04:56.000000000 +0300
522 @@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f
524 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
525 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
526 -void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
527 +void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
528 void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
530 #endif /* _ATTACH_H_ */
531 diff -udprP mutt-1.5.13.orig/browser.c mutt-1.5.13/browser.c
532 --- mutt-1.5.13.orig/browser.c 2006-08-06 01:17:37.000000000 +0300
533 +++ mutt-1.5.13/browser.c 2006-08-15 13:04:56.000000000 +0300
544 @@ -49,6 +52,19 @@ static struct mapping_t FolderHelp[] = {
549 +static struct mapping_t FolderNewsHelp[] = {
550 + { N_("Exit"), OP_EXIT },
551 + { N_("List"), OP_TOGGLE_MAILBOXES },
552 + { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
553 + { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
554 + { N_("Catchup"), OP_CATCHUP },
555 + { N_("Mask"), OP_ENTER_MASK },
556 + { N_("Help"), OP_HELP },
561 typedef struct folder_t
563 struct folder_file *ff;
564 @@ -114,9 +130,17 @@ static void browser_sort (struct browser
569 + if (option (OPTNEWS))
572 f = browser_compare_date;
576 + if (option (OPTNEWS))
579 f = browser_compare_size;
582 @@ -306,8 +330,106 @@ folder_format_str (char *dest, size_t de
588 +newsgroup_format_str (char *dest, size_t destlen, char op, const char *src,
589 + const char *fmt, const char *ifstring, const char *elsestring,
590 + unsigned long data, format_flag flags)
592 + char fn[SHORT_STRING], tmp[SHORT_STRING];
593 + FOLDER *folder = (FOLDER *) data;
598 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
599 + snprintf (dest, destlen, tmp, folder->num + 1);
603 + strncpy (fn, folder->ff->name, sizeof(fn) - 1);
604 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
605 + snprintf (dest, destlen, tmp, fn);
609 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
610 + if (folder->ff->nd->subscribed)
611 + snprintf (dest, destlen, tmp, ' ');
613 + snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
617 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
618 + if (folder->ff->nd->deleted)
619 + snprintf (dest, destlen, tmp, 'D');
621 + snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
625 + if (flags & M_FORMAT_OPTIONAL)
627 + if (folder->ff->nd->unread != 0)
628 + mutt_FormatString (dest, destlen, ifstring, newsgroup_format_str,
631 + mutt_FormatString (dest, destlen, elsestring, newsgroup_format_str,
634 + else if (Context && Context->data == folder->ff->nd)
636 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
637 + snprintf (dest, destlen, tmp, Context->unread);
641 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
642 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
647 + if (Context && Context->data == folder->ff->nd)
649 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
650 + snprintf (dest, destlen, tmp, Context->new);
652 + else if (option (OPTMARKOLD) &&
653 + folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
654 + folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
656 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
657 + snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
661 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
662 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
667 + if (folder->ff->nd->desc != NULL)
669 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
670 + snprintf (dest, destlen, tmp, folder->ff->nd->desc);
674 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
675 + snprintf (dest, destlen, tmp, "");
681 +#endif /* USE_NNTP */
683 static void add_folder (MUTTMENU *m, struct browser_state *state,
684 - const char *name, const struct stat *s, int new)
685 + const char *name, const struct stat *s,
686 + void *data, int new)
688 if (state->entrylen == state->entrymax)
690 @@ -336,6 +458,10 @@ static void add_folder (MUTTMENU *m, str
692 (state->entry)[state->entrylen].imap = 0;
695 + if (option (OPTNEWS))
696 + (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
701 @@ -351,9 +477,35 @@ static void init_state (struct browser_s
702 menu->data = state->entry;
705 +/* get list of all files/newsgroups with mask */
706 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
707 char *d, const char *prefix)
710 + if (option (OPTNEWS))
714 + NNTP_SERVER *news = CurrentNewsSrv;
716 +/* mutt_buffy_check (0); */
717 + init_state (state, menu);
719 + for (tmp = news->list; tmp; tmp = tmp->next)
721 + if (!(data = (NNTP_DATA *)tmp->data))
723 + if (prefix && *prefix && strncmp (prefix, data->group,
724 + strlen (prefix)) != 0)
726 + if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
728 + add_folder (menu, state, data->group, NULL, data, data->new);
732 +#endif /* USE_NNTP */
737 @@ -414,17 +566,40 @@ static int examine_directory (MUTTMENU *
739 while (tmp && mutt_strcmp (buffer, tmp->path))
741 - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
742 + add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
747 browser_sort (state);
751 +/* get list of mailboxes/subscribed newsgroups */
752 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
755 char buffer[LONG_STRING];
758 + if (option (OPTNEWS))
762 + NNTP_SERVER *news = CurrentNewsSrv;
764 +/* mutt_buffy_check (0); */
765 + init_state (state, menu);
767 + for (tmp = news->list; tmp; tmp = tmp->next)
769 + if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
770 + (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
771 + add_folder (menu, state, data->group, NULL, data, data->new);
777 BUFFY *tmp = Incoming;
780 @@ -438,14 +613,21 @@ static int examine_mailboxes (MUTTMENU *
782 if (mx_is_imap (tmp->path))
784 - add_folder (menu, state, tmp->path, NULL, tmp->new);
785 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
790 if (mx_is_pop (tmp->path))
792 - add_folder (menu, state, tmp->path, NULL, tmp->new);
793 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
798 + if (mx_is_nntp (tmp->path))
800 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
804 @@ -459,15 +641,20 @@ static int examine_mailboxes (MUTTMENU *
805 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
806 mutt_pretty_mailbox (buffer);
808 - add_folder (menu, state, buffer, &s, tmp->new);
809 + add_folder (menu, state, buffer, &s, NULL, tmp->new);
811 while ((tmp = tmp->next));
813 browser_sort (state);
817 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
820 + if (option (OPTNEWS))
821 + return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
823 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
826 @@ -478,7 +665,13 @@ static void folder_entry (char *s, size_
827 folder.ff = &((struct folder_file *) menu->data)[num];
830 - mutt_FormatString (s, slen, NONULL(FolderFormat), folder_format_str,
832 + if (option (OPTNEWS))
833 + mutt_FormatString (s, slen, NONULL(GroupFormat), newsgroup_format_str,
834 + (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
837 + mutt_FormatString (s, slen, NONULL(FolderFormat), folder_format_str,
838 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
841 @@ -498,6 +691,17 @@ static void init_menu (struct browser_st
846 + if (option (OPTNEWS))
849 + snprintf (title, titlelen, _("Subscribed newsgroups"));
851 + snprintf (title, titlelen, _("Newsgroups on server [%s]"),
852 + CurrentNewsSrv->conn->account.host);
857 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
859 @@ -553,6 +757,31 @@ void _mutt_select_file (char *f, size_t
861 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
864 + if (option (OPTNEWS))
867 + strfcpy (prefix, f, sizeof (prefix));
872 + /* default state for news reader mode is browse subscribed newsgroups */
874 + for (list = CurrentNewsSrv->list; list; list = list->next)
876 + NNTP_DATA *data = (NNTP_DATA *) list->data;
878 + if (data && data->subscribed)
890 mutt_expand_path (f, flen);
891 @@ -642,6 +871,9 @@ void _mutt_select_file (char *f, size_t
892 menu->tag = file_tag;
894 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
896 + (option (OPTNEWS)) ? FolderNewsHelp :
900 init_menu (&state, menu, title, sizeof (title), buffy);
901 @@ -780,7 +1012,11 @@ void _mutt_select_file (char *f, size_t
906 + if (buffy || option (OPTNEWS)) /* news have not path */
911 strfcpy (f, state.entry[menu->current].name, flen);
912 mutt_expand_path (f, flen);
913 @@ -838,14 +1074,6 @@ void _mutt_select_file (char *f, size_t
917 - case OP_BROWSER_SUBSCRIBE:
918 - imap_subscribe (state.entry[menu->current].name, 1);
921 - case OP_BROWSER_UNSUBSCRIBE:
922 - imap_subscribe (state.entry[menu->current].name, 0);
925 case OP_BROWSER_TOGGLE_LSUB:
926 if (option (OPTIMAPLSUB))
928 @@ -944,6 +1172,11 @@ void _mutt_select_file (char *f, size_t
930 case OP_CHANGE_DIRECTORY:
933 + if (option (OPTNEWS))
937 strfcpy (buf, LastDir, sizeof (buf));
939 if (!state.imap_browse)
940 @@ -1200,6 +1433,190 @@ void _mutt_select_file (char *f, size_t
942 mutt_error _("Error trying to view file");
949 + if (option (OPTNEWS))
951 + struct folder_file *f = &state.entry[menu->current];
954 + if (i == OP_CATCHUP)
955 + nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
957 + nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
962 + struct folder_file ff;
963 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
966 + folder.ff->name = f->name;
967 + folder.ff->st = NULL;
968 + folder.ff->is_new = nd->new;
969 + folder.ff->nd = nd;
971 + mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
972 + newsgroup_format_str, (unsigned long) &folder,
973 + M_FORMAT_ARROWCURSOR);
974 + f->desc = safe_strdup (buffer); */
975 + if (menu->current + 1 < menu->max)
977 + menu->redraw = REDRAW_MOTION_RESYNCH;
982 + case OP_LOAD_ACTIVE:
983 + if (!option (OPTNEWS))
990 + for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
992 + if ((data = (NNTP_DATA *)tmp->data))
996 + nntp_get_active (CurrentNewsSrv);
998 + destroy_state (&state);
1000 + examine_mailboxes (menu, &state);
1002 + examine_directory (menu, &state, NULL, NULL);
1003 + init_menu (&state, menu, title, sizeof (title), buffy);
1005 +#endif /* USE_NNTP */
1007 +#if defined USE_IMAP || defined USE_NNTP
1008 + case OP_BROWSER_SUBSCRIBE:
1009 + case OP_BROWSER_UNSUBSCRIBE:
1012 + case OP_SUBSCRIBE_PATTERN:
1013 + case OP_UNSUBSCRIBE_PATTERN:
1014 + if (option (OPTNEWS))
1016 + regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1018 + int j = menu->current;
1020 + NNTP_SERVER *news = CurrentNewsSrv;
1022 + if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1028 + if (i == OP_SUBSCRIBE_PATTERN)
1029 + snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1031 + snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1032 + if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1038 + if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1040 + regerror (err, rx, buf, sizeof (buf));
1043 + mutt_error ("%s", buf);
1046 + menu->redraw = REDRAW_FULL;
1049 + else if (!state.entrylen)
1051 + mutt_error _("No newsgroups match the mask");
1055 + for ( ; j < state.entrylen; j++)
1057 + struct folder_file *f = &state.entry[j];
1059 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1060 + regexec (rx, f->name, 0, NULL, 0) == 0)
1062 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1063 + nd = mutt_newsgroup_subscribe (news, f->name);
1065 + nd = mutt_newsgroup_unsubscribe (news, f->name);
1069 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1071 + folder.name = f->name;
1073 + folder.new = nd->new;
1076 + mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
1077 + newsgroup_format_str, (unsigned long) &folder,
1078 + M_FORMAT_ARROWCURSOR);
1079 + f->desc = safe_strdup (buffer);
1082 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1084 + if (menu->current + 1 < menu->max)
1086 + menu->redraw = REDRAW_MOTION_RESYNCH;
1090 + if (i == OP_SUBSCRIBE_PATTERN)
1092 + LIST *grouplist = NULL;
1095 + grouplist = news->list;
1096 + for (; grouplist; grouplist = grouplist->next)
1098 + nd = (NNTP_DATA *) grouplist->data;
1099 + if (nd && nd->group && !nd->subscribed)
1101 + if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1103 + mutt_newsgroup_subscribe (news, nd->group);
1104 + add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1108 + init_menu (&state, menu, title, sizeof (title), buffy);
1110 + mutt_newsrc_update (news);
1111 + nntp_clear_cacheindex (news);
1112 + if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1118 +#endif /* USE_IMAP && USE_NNTP */
1119 +#endif /* USE_NNTP */
1122 + if (i == OP_BROWSER_SUBSCRIBE)
1123 + imap_subscribe (state.entry[menu->current].name, 1);
1125 + imap_subscribe (state.entry[menu->current].name, 0);
1127 +#endif /* USE_IMAP */
1131 diff -udprP mutt-1.5.13.orig/browser.h mutt-1.5.13/browser.h
1132 --- mutt-1.5.13.orig/browser.h 2005-09-18 11:22:21.000000000 +0300
1133 +++ mutt-1.5.13/browser.h 2006-08-15 13:04:56.000000000 +0300
1136 #define _BROWSER_H 1
1145 @@ -38,14 +42,17 @@ struct folder_file
1146 unsigned selectable : 1;
1147 unsigned inferiors : 1;
1152 unsigned tagged : 1;
1155 struct browser_state
1157 struct folder_file *entry;
1158 - short entrylen; /* number of real entries */
1159 - short entrymax; /* max entry */
1160 + unsigned int entrylen; /* number of real entries */
1161 + unsigned int entrymax; /* max entry */
1165 diff -udprP mutt-1.5.13.orig/buffy.c mutt-1.5.13/buffy.c
1166 --- mutt-1.5.13.orig/buffy.c 2006-05-18 21:44:28.000000000 +0300
1167 +++ mutt-1.5.13/buffy.c 2006-08-15 13:04:56.000000000 +0300
1168 @@ -293,6 +293,9 @@ int mutt_buffy_check (int force)
1170 if (!Context || Context->magic != M_POP)
1173 + if (!Context || Context->magic != M_NNTP)
1175 /* check device ID and serial number instead of comparing paths */
1176 if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0)
1178 @@ -316,6 +319,11 @@ int mutt_buffy_check (int force)
1183 + if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1184 + tmp->magic = M_NNTP;
1187 if (stat (tmp->path, &sb) != 0 || sb.st_size == 0 ||
1188 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1190 @@ -335,25 +343,21 @@ int mutt_buffy_check (int force)
1191 /* check to see if the folder is the currently selected folder
1193 if (!Context || !Context->path ||
1194 -#if defined USE_IMAP || defined USE_POP
1199 - tmp->magic == M_IMAP
1200 + || tmp->magic == M_IMAP
1206 - tmp->magic == M_POP
1208 - ) ? mutt_strcmp (tmp->path, Context->path) :
1209 + || tmp->magic == M_POP
1211 - (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1212 -#if defined USE_IMAP || defined USE_POP
1215 + || tmp->magic == M_NNTP
1219 + ) ? mutt_strcmp (tmp->path, Context->path) :
1220 + (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1226 diff -udprP mutt-1.5.13.orig/complete.c mutt-1.5.13/complete.c
1227 --- mutt-1.5.13.orig/complete.c 2005-09-18 11:22:21.000000000 +0300
1228 +++ mutt-1.5.13/complete.c 2006-08-15 13:04:56.000000000 +0300
1230 #include "mailbox.h"
1239 @@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen)
1240 char filepart[_POSIX_PATH_MAX];
1242 char imap_path[LONG_STRING];
1245 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1248 + if (option (OPTNEWS))
1250 + LIST *l = CurrentNewsSrv->list;
1252 + strfcpy (filepart, s, sizeof (filepart));
1255 + * special case to handle when there is no filepart yet.
1256 + * find the first subscribed newsgroup
1258 + if ((len = mutt_strlen (filepart)) == 0)
1260 + for (; l; l = l->next)
1262 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1264 + if (data && data->subscribed)
1266 + strfcpy (filepart, data->group, sizeof (filepart));
1274 + for (; l; l = l->next)
1276 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1278 + if (data && data->subscribed &&
1279 + mutt_strncmp (data->group, filepart, len) == 0)
1283 + for (i = 0; filepart[i] && data->group[i]; i++)
1285 + if (filepart[i] != data->group[i])
1295 + strfcpy (filepart, data->group, sizeof (filepart));
1301 + strcpy (s, filepart);
1303 + return (init ? 0 : -1);
1308 /* we can use '/' as a delimiter, imap_complete rewrites it */
1309 if (*s == '=' || *s == '+' || *s == '!')
1311 diff -udprP mutt-1.5.13.orig/compose.c mutt-1.5.13/compose.c
1312 --- mutt-1.5.13.orig/compose.c 2005-09-18 11:22:21.000000000 +0300
1313 +++ mutt-1.5.13/compose.c 2006-08-15 13:04:56.000000000 +0300
1315 #include "mailbox.h"
1317 #include "charset.h"
1321 #include "remailer.h"
1330 @@ -60,18 +65,21 @@ enum
1347 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1350 -#define HDR_XOFFSET 10
1351 -#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1352 +#define HDR_XOFFSET 14
1353 +#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1354 #define W (COLS - HDR_XOFFSET)
1356 static char *Prompts[] =
1357 @@ -83,6 +91,16 @@ static char *Prompts[] =
1373 static struct mapping_t ComposeHelp[] = {
1374 @@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] =
1379 +static struct mapping_t ComposeNewsHelp[] = {
1380 + { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1381 + { N_("Abort"), OP_EXIT },
1382 + { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1383 + { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1384 + { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1385 + { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1386 + { N_("Help"), OP_HELP },
1391 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1393 mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
1394 @@ -115,16 +146,16 @@ static void redraw_crypt_lines (HEADER *
1395 if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
1398 - mvaddstr (HDR_CRYPT, 0, "Security: ");
1399 + mvaddstr (HDR_CRYPT, 0, " Security: ");
1400 else if (msg->security & APPLICATION_SMIME)
1401 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1402 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1403 else if (msg->security & APPLICATION_PGP)
1404 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1405 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1407 else if ((WithCrypto & APPLICATION_SMIME))
1408 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1409 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1410 else if ((WithCrypto & APPLICATION_PGP))
1411 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1412 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1416 @@ -252,9 +283,28 @@ static void draw_envelope_addr (int line
1417 static void draw_envelope (HEADER *msg, char *fcc)
1419 draw_envelope_addr (HDR_FROM, msg->env->from);
1421 + if (!option (OPTNEWSSEND))
1424 draw_envelope_addr (HDR_TO, msg->env->to);
1425 draw_envelope_addr (HDR_CC, msg->env->cc);
1426 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1431 + mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1432 + mutt_paddstr (W, NONULL (msg->env->newsgroups));
1433 + mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1434 + mutt_paddstr (W, NONULL (msg->env->followup_to));
1435 + if (option (OPTXCOMMENTTO))
1437 + mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1438 + mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1442 mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1443 mutt_paddstr (W, NONULL (msg->env->subject));
1444 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1445 @@ -507,6 +557,12 @@ int mutt_compose_menu (HEADER *msg, /*
1446 /* Sort, SortAux could be changed in mutt_index_menu() */
1447 int oldSort, oldSortAux;
1450 + int news = 0; /* is it a news article ? */
1452 + if (option (OPTNEWSSEND))
1456 mutt_attach_init (msg->content);
1457 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
1458 @@ -518,10 +574,18 @@ int mutt_compose_menu (HEADER *msg, /*
1459 menu->make_entry = snd_entry;
1460 menu->tag = mutt_tag_attach;
1464 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1467 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1472 + unset_option (OPTNEWS); /* for any case */
1474 switch (op = mutt_menuLoop (menu))
1477 @@ -534,17 +598,87 @@ int mutt_compose_menu (HEADER *msg, /*
1478 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1480 case OP_COMPOSE_EDIT_TO:
1485 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1486 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1488 case OP_COMPOSE_EDIT_BCC:
1493 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1494 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1496 case OP_COMPOSE_EDIT_CC:
1501 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1502 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1505 + case OP_COMPOSE_EDIT_NEWSGROUPS:
1508 + if (msg->env->newsgroups)
1509 + strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1512 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1514 + FREE (&msg->env->newsgroups);
1515 + mutt_remove_trailing_ws (buf);
1516 + msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1517 + move (HDR_TO, HDR_XOFFSET);
1519 + if (msg->env->newsgroups)
1520 + printw ("%-*.*s", W, W, msg->env->newsgroups);
1525 + case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1529 + if (msg->env->followup_to)
1530 + strfcpy (buf, msg->env->followup_to, sizeof (buf));
1531 + if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1533 + FREE (&msg->env->followup_to);
1534 + mutt_remove_trailing_ws (buf);
1535 + msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1536 + move (HDR_CC, HDR_XOFFSET);
1538 + if (msg->env->followup_to)
1539 + printw ("%-*.*s", W, W, msg->env->followup_to);
1544 + case OP_COMPOSE_EDIT_X_COMMENT_TO:
1545 + if (news && option (OPTXCOMMENTTO))
1548 + if (msg->env->x_comment_to)
1549 + strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1550 + if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1552 + FREE (&msg->env->x_comment_to);
1553 + msg->env->x_comment_to = safe_strdup (buf);
1554 + move (HDR_BCC, HDR_XOFFSET);
1556 + if (msg->env->x_comment_to)
1557 + printw ("%-*.*s", W, W, msg->env->x_comment_to);
1562 case OP_COMPOSE_EDIT_SUBJECT:
1563 if (msg->env->subject)
1564 strfcpy (buf, msg->env->subject, sizeof (buf));
1565 @@ -707,6 +841,9 @@ int mutt_compose_menu (HEADER *msg, /*
1568 case OP_COMPOSE_ATTACH_MESSAGE:
1570 + case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1575 @@ -714,7 +851,22 @@ int mutt_compose_menu (HEADER *msg, /*
1577 prompt = _("Open mailbox to attach message from");
1580 + unset_option (OPTNEWS);
1581 + if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1583 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1586 + prompt = _("Open newsgroup to attach message from");
1587 + set_option (OPTNEWS);
1593 + if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1596 strfcpy (fname, NONULL (Context->path), sizeof (fname));
1597 mutt_pretty_mailbox (fname);
1598 @@ -723,6 +875,11 @@ int mutt_compose_menu (HEADER *msg, /*
1599 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1603 + if (option (OPTNEWS))
1604 + nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1607 mutt_expand_path (fname, sizeof (fname));
1609 if (!mx_is_imap (fname))
1610 @@ -730,6 +887,9 @@ int mutt_compose_menu (HEADER *msg, /*
1612 if (!mx_is_pop (fname))
1615 + if (!mx_is_nntp (fname) && !option (OPTNEWS))
1617 /* check to make sure the file exists and is readable */
1618 if (access (fname, R_OK) == -1)
1620 diff -udprP mutt-1.5.13.orig/config.h.in mutt-1.5.13/config.h.in
1621 --- mutt-1.5.13.orig/config.h.in 2006-08-14 17:09:46.000000000 +0300
1622 +++ mutt-1.5.13/config.h.in 2006-08-15 13:04:56.000000000 +0300
1624 significant more memory when defined. */
1625 #undef EXACT_ADDRESS
1627 +/* Compiling with newsreading support with NNTP */
1630 /* program to use for shell commands */
1633 diff -udprP mutt-1.5.13.orig/configure.in mutt-1.5.13/configure.in
1634 --- mutt-1.5.13.orig/configure.in 2006-08-14 17:09:18.000000000 +0300
1635 +++ mutt-1.5.13/configure.in 2006-08-15 13:04:56.000000000 +0300
1636 @@ -574,6 +574,14 @@ if test x"$need_imap" = xyes -o x"$need_
1637 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1640 +AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1641 +[ if test x$enableval = xyes ; then
1642 + AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1643 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1648 dnl -- end socket dependencies --
1650 if test "$need_socket" = "yes"
1651 diff -udprP mutt-1.5.13.orig/curs_main.c mutt-1.5.13/curs_main.c
1652 --- mutt-1.5.13.orig/curs_main.c 2006-06-08 14:50:29.000000000 +0300
1653 +++ mutt-1.5.13/curs_main.c 2006-08-15 13:04:56.000000000 +0300
1657 #include "mutt_curses.h"
1659 #include "mutt_menu.h"
1661 #include "mailbox.h"
1664 #include "mutt_crypt.h"
1673 @@ -415,12 +420,27 @@ struct mapping_t IndexHelp[] = {
1678 +struct mapping_t IndexNewsHelp[] = {
1679 + { N_("Quit"), OP_QUIT },
1680 + { N_("Del"), OP_DELETE },
1681 + { N_("Undel"), OP_UNDELETE },
1682 + { N_("Save"), OP_SAVE },
1683 + { N_("Post"), OP_POST },
1684 + { N_("Followup"), OP_FOLLOWUP },
1685 + { N_("Catchup"), OP_CATCHUP },
1686 + { N_("Help"), OP_HELP },
1691 /* This function handles the message index window as well as commands returned
1692 * from the pager (MENU_PAGER).
1694 int mutt_index_menu (void)
1696 char buf[LONG_STRING], helpstr[SHORT_STRING];
1699 int done = 0; /* controls when to exit the "event" loop */
1701 @@ -442,7 +462,11 @@ int mutt_index_menu (void)
1702 menu->make_entry = index_make_entry;
1703 menu->color = index_color;
1704 menu->current = ci_first_message ();
1705 - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1706 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1708 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1713 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
1714 @@ -694,6 +718,9 @@ int mutt_index_menu (void)
1715 mutt_curs_set (1); /* fallback from the pager */
1719 + unset_option (OPTNEWS); /* for any case */
1724 @@ -744,6 +771,120 @@ int mutt_index_menu (void)
1725 menu_current_bottom (menu);
1729 + case OP_GET_MESSAGE:
1730 + case OP_GET_PARENT:
1732 + if (Context->magic == M_NNTP)
1736 + if (op == OP_GET_MESSAGE)
1739 + if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1745 + LIST *ref = CURHDR->env->references;
1748 + mutt_error _("Article has no parent reference!");
1751 + strfcpy (buf, ref->data, sizeof (buf));
1753 + if (!Context->id_hash)
1754 + Context->id_hash = mutt_make_id_hash (Context);
1755 + if ((h = hash_find (Context->id_hash, buf)))
1757 + if (h->virtual != -1)
1759 + menu->current = h->virtual;
1760 + menu->redraw = REDRAW_MOTION_RESYNCH;
1762 + else if (h->collapsed)
1764 + mutt_uncollapse_thread (Context, h);
1765 + mutt_set_virtual (Context);
1766 + menu->current = h->virtual;
1767 + menu->redraw = REDRAW_MOTION_RESYNCH;
1770 + mutt_error _("Message not visible in limited view.");
1774 + if (nntp_check_msgid (Context, buf) == 0)
1776 + h = Context->hdrs[Context->msgcount-1];
1777 + mutt_sort_headers (Context, 0);
1778 + menu->current = h->virtual;
1779 + menu->redraw = REDRAW_FULL;
1782 + mutt_error (_("Article %s not found on server"), buf);
1787 + case OP_GET_CHILDREN:
1788 + case OP_RECONSTRUCT_THREAD:
1790 + if (Context->magic == M_NNTP)
1793 + int old = CURHDR->index, i;
1795 + if (!CURHDR->env->message_id)
1797 + mutt_error _("No Message-Id. Unable to perform operation");
1801 + if (!Context->id_hash)
1802 + Context->id_hash = mutt_make_id_hash (Context);
1803 + strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1805 + if (op == OP_RECONSTRUCT_THREAD)
1807 + LIST *ref = CURHDR->env->references;
1810 + nntp_check_msgid (Context, ref->data);
1811 + /* the last msgid in References is the root message */
1813 + strfcpy (buf, ref->data, sizeof (buf));
1817 + mutt_message _("Check for children of message...");
1818 + if (nntp_check_children (Context, buf) == 0)
1820 + mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1821 + h = hash_find (Context->id_hash, buf);
1822 + /* if the root message was retrieved, move to it */
1824 + menu->current = h->virtual;
1825 + else /* try to restore old position */
1826 + for (i = 0; i < Context->msgcount; i++)
1827 + if (Context->hdrs[i]->index == old)
1829 + menu->current = Context->hdrs[i]->virtual;
1830 + /* As an added courtesy, recenter the menu
1831 + * with the current entry at the middle of the screen */
1832 + menu_check_recenter (menu);
1833 + menu_current_middle (menu);
1836 + menu->redraw = REDRAW_FULL;
1837 + mutt_clear_error ();
1845 @@ -841,11 +982,33 @@ int mutt_index_menu (void)
1849 + case OP_TOGGLE_READ:
1852 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1854 - if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1855 + if (op == OP_TOGGLE_READ)
1857 + char buf[LONG_STRING];
1859 + if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1861 + snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1862 + Context->pattern ? Context->pattern : ".*");
1863 + set_option (OPTHIDEREAD);
1867 + strfcpy (buf, Context->pattern + 8, sizeof(buf));
1868 + if (!*buf || strncmp (buf, ".*", 2) == 0)
1869 + snprintf (buf, sizeof(buf), "~A");
1870 + unset_option (OPTHIDEREAD);
1872 + FREE (&Context->pattern);
1873 + Context->pattern = safe_strdup (buf);
1875 + if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1876 + mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1878 if (menu->oldcurrent >= 0)
1880 @@ -1052,20 +1215,43 @@ int mutt_index_menu (void)
1883 case OP_MAIN_CHANGE_FOLDER:
1886 - op = OP_MAIN_CHANGE_FOLDER_READONLY;
1888 - /* fallback to the readonly case */
1890 case OP_MAIN_CHANGE_FOLDER_READONLY:
1892 + case OP_MAIN_CHANGE_GROUP:
1893 + case OP_MAIN_CHANGE_GROUP_READONLY:
1896 - if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1897 + if (attach_msg || option (OPTREADONLY) ||
1899 + op == OP_MAIN_CHANGE_GROUP_READONLY ||
1901 + op == OP_MAIN_CHANGE_FOLDER_READONLY)
1902 + flags = M_READONLY;
1907 cp = _("Open mailbox in read-only mode");
1909 cp = _("Open mailbox");
1913 + unset_option (OPTNEWS);
1914 + if (op == OP_MAIN_CHANGE_GROUP ||
1915 + op == OP_MAIN_CHANGE_GROUP_READONLY)
1917 + set_option (OPTNEWS);
1918 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1921 + cp = _("Open newsgroup in read-only mode");
1923 + cp = _("Open newsgroup");
1928 mutt_buffy (buf, sizeof (buf));
1930 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1931 @@ -1084,6 +1270,14 @@ int mutt_index_menu (void)
1936 + if (option (OPTNEWS))
1938 + unset_option (OPTNEWS);
1939 + nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1943 mutt_expand_path (buf, sizeof (buf));
1944 if (mx_get_magic (buf) <= 0)
1946 @@ -1121,15 +1315,18 @@ int mutt_index_menu (void)
1947 CurrentMenu = MENU_MAIN;
1948 mutt_folder_hook (buf);
1950 - if ((Context = mx_open_mailbox (buf,
1951 - (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1952 - M_READONLY : 0, NULL)) != NULL)
1953 + if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1955 menu->current = ci_first_message ();
1961 + /* mutt_buffy_check() must be done with mail-reader mode! */
1962 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1963 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1965 mutt_clear_error ();
1966 mutt_buffy_check(1); /* force the buffy check after we have changed
1968 @@ -1509,6 +1706,15 @@ int mutt_index_menu (void)
1973 + if (Context->magic == M_NNTP)
1976 + mutt_error _("Can't change 'important' flag on NNTP server.");
1983 for (j = 0; j < Context->vcount; j++)
1984 @@ -1856,6 +2062,17 @@ int mutt_index_menu (void)
1990 + if (Context && Context->magic == M_NNTP)
1992 + if (mutt_newsgroup_catchup (CurrentNewsSrv,
1993 + ((NNTP_DATA *)Context->data)->group))
1994 + menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1999 case OP_DISPLAY_ADDRESS:
2002 @@ -1890,6 +2107,15 @@ int mutt_index_menu (void)
2008 + if (Context->magic == M_NNTP)
2011 + mutt_error _("Can't edit message on newsserver.");
2016 if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
2017 mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
2018 @@ -2063,6 +2289,37 @@ int mutt_index_menu (void)
2020 menu->redraw = REDRAW_FULL;
2026 + case OP_FORWARD_TO_GROUP:
2029 + if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2030 + mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2031 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2033 + if (Context && Context->magic == M_NNTP &&
2034 + !((NNTP_DATA *)Context->data)->allowed &&
2035 + query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2037 + if (op == OP_POST)
2038 + ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2042 + if (op == OP_FOLLOWUP)
2043 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2044 + tag ? NULL : CURHDR);
2046 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2047 + tag ? NULL : CURHDR);
2049 + menu->redraw = REDRAW_FULL;
2056 @@ -2136,6 +2393,12 @@ int mutt_index_menu (void)
2058 CHECK_IMAP_ACL(IMAP_ACL_DELETE);
2061 + /* Close all open NNTP connections */
2063 + nntp_logout_all ();
2066 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2067 op == OP_UNDELETE_THREAD ? 0 : 1);
2069 diff -udprP mutt-1.5.13.orig/doc/manual.xml.head mutt-1.5.13/doc/manual.xml.head
2070 --- mutt-1.5.13.orig/doc/manual.xml.head 2006-08-11 12:23:28.000000000 +0300
2071 +++ mutt-1.5.13/doc/manual.xml.head 2006-08-15 13:04:56.000000000 +0300
2072 @@ -1204,6 +1204,22 @@ have a look at the mixmaster documentati
2077 +<title>Reading news via NNTP</title>
2080 +If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2081 +read news from newsserver via NNTP. You can open a newsgroup with
2082 +function ``change-newsgroup'' (default: ``i''). Default newsserver
2083 +can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2084 +variable. Like other news readers, info about subscribed newsgroups
2085 +is saved in file by <link linkend="newsrc">$newsrc</link>
2086 +variable. Article headers are cached and can be loaded from file when
2087 +newsgroup entered instead loading from newsserver.
2094 <sect1 id="forwarding-mail">
2095 diff -udprP mutt-1.5.13.orig/doc/mutt.man mutt-1.5.13/doc/mutt.man
2096 --- mutt-1.5.13.orig/doc/mutt.man 2005-09-18 11:22:22.000000000 +0300
2097 +++ mutt-1.5.13/doc/mutt.man 2006-08-15 13:04:56.000000000 +0300
2098 @@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2103 -[-e \fIcmd\fP] [-F \fIfile\fP] [-m \fItype\fP] [-f \fIfile\fP]
2105 +[-e \fIcmd\fP] [-F \fIfile\fP] [-g \fIserver\fP] [-m \fItype\fP] [-f \fIfile\fP]
2109 @@ -75,6 +75,10 @@ files.
2110 Specify which mailbox to load.
2111 .IP "-F \fImuttrc\fP"
2112 Specify an initialization file to read instead of ~/.muttrc
2113 +.IP "-g \fIserver\fP"
2114 +Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2116 +Start Mutt with a listing of subscribed newsgroups.
2119 .IP "-H \fIdraft\fP"
2120 diff -udprP mutt-1.5.13.orig/functions.h mutt-1.5.13/functions.h
2121 --- mutt-1.5.13.orig/functions.h 2005-09-18 11:22:21.000000000 +0300
2122 +++ mutt-1.5.13/functions.h 2006-08-15 13:04:56.000000000 +0300
2123 @@ -72,6 +72,10 @@ struct binding_t OpMain[] = {
2124 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2125 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2126 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2128 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2129 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2131 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2132 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
2133 { "copy-message", OP_COPY_MESSAGE, "C" },
2134 @@ -84,7 +88,15 @@ struct binding_t OpMain[] = {
2135 { "edit", OP_EDIT_MESSAGE, "e" },
2136 { "edit-type", OP_EDIT_TYPE, "\005" },
2137 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2138 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2140 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2141 + { "followup-message", OP_FOLLOWUP, "F" },
2142 + { "get-children", OP_GET_CHILDREN, NULL },
2143 + { "get-message", OP_GET_MESSAGE, "\007" },
2144 + { "get-parent", OP_GET_PARENT, "\033G" },
2145 + { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2147 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2148 { "group-reply", OP_GROUP_REPLY, "g" },
2150 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2151 @@ -110,6 +122,9 @@ struct binding_t OpMain[] = {
2152 { "sort-mailbox", OP_SORT, "o" },
2153 { "sort-reverse", OP_SORT_REVERSE, "O" },
2154 { "print-message", OP_PRINT, "p" },
2156 + { "post-message", OP_POST, "P" },
2158 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2159 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2160 { "recall-message", OP_RECALL_MESSAGE, "R" },
2161 @@ -129,6 +144,10 @@ struct binding_t OpMain[] = {
2162 { "show-version", OP_VERSION, "V" },
2163 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2164 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2165 + { "toggle-read", OP_TOGGLE_READ, "X" },
2167 + { "catchup", OP_CATCHUP, "y" },
2169 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2170 { "buffy-list", OP_BUFFY_LIST, "." },
2171 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
2172 @@ -140,7 +159,7 @@ struct binding_t OpMain[] = {
2173 { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" },
2174 { "next-unread", OP_MAIN_NEXT_UNREAD, NULL },
2175 { "previous-unread", OP_MAIN_PREV_UNREAD, NULL },
2176 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2177 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2180 { "extract-keys", OP_EXTRACT_KEYS, "\013" },
2181 @@ -160,6 +179,10 @@ struct binding_t OpPager[] = {
2182 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2183 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2184 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2186 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2187 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2189 { "copy-message", OP_COPY_MESSAGE, "C" },
2190 { "decode-copy", OP_DECODE_COPY, "\033C" },
2191 { "delete-message", OP_DELETE, "d" },
2192 @@ -167,8 +190,12 @@ struct binding_t OpPager[] = {
2193 { "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" },
2194 { "edit", OP_EDIT_MESSAGE, "e" },
2195 { "edit-type", OP_EDIT_TYPE, "\005" },
2197 + { "followup-message", OP_FOLLOWUP, "F" },
2198 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2200 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2201 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2202 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2203 { "group-reply", OP_GROUP_REPLY, "g" },
2205 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
2206 @@ -187,6 +214,9 @@ struct binding_t OpPager[] = {
2207 { "next-thread", OP_MAIN_NEXT_THREAD, "\016" },
2208 { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" },
2209 { "print-message", OP_PRINT, "p" },
2211 + { "post-message", OP_POST, "P" },
2213 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2214 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2215 { "quit", OP_QUIT, "Q" },
2216 @@ -234,7 +264,7 @@ struct binding_t OpPager[] = {
2217 { "half-down", OP_HALF_DOWN, NULL },
2218 { "previous-line", OP_PREV_LINE, NULL },
2219 { "bottom", OP_PAGER_BOTTOM, NULL },
2220 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2221 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2225 @@ -254,6 +284,10 @@ struct binding_t OpAttach[] = {
2226 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2227 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2228 { "edit-type", OP_EDIT_TYPE, "\005" },
2230 + { "followup-message", OP_FOLLOWUP, "F" },
2231 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2233 { "print-entry", OP_PRINT, "p" },
2234 { "save-entry", OP_SAVE, "s" },
2235 { "pipe-entry", OP_PIPE, "|" },
2236 @@ -279,6 +313,7 @@ struct binding_t OpAttach[] = {
2237 struct binding_t OpCompose[] = {
2238 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2239 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2240 + { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2241 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2242 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2243 { "copy-file", OP_SAVE, "C" },
2244 @@ -298,6 +333,11 @@ struct binding_t OpCompose[] = {
2245 { "print-entry", OP_PRINT, "l" },
2246 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2247 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2249 + { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2250 + { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2251 + { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2253 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2254 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2255 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
2256 @@ -349,14 +389,25 @@ struct binding_t OpBrowser[] = {
2257 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2258 { "check-new", OP_CHECK_NEW, NULL },
2259 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2261 + { "reload-active", OP_LOAD_ACTIVE, "g" },
2262 + { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2263 + { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2264 + { "catchup", OP_CATCHUP, "y" },
2265 + { "uncatchup", OP_UNCATCHUP, "Y" },
2267 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2268 { "buffy-list", OP_BUFFY_LIST, "." },
2270 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2271 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2272 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2274 +#if defined USE_IMAP || defined USE_NNTP
2275 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2276 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2279 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2282 diff -udprP mutt-1.5.13.orig/globals.h mutt-1.5.13/globals.h
2283 --- mutt-1.5.13.orig/globals.h 2006-08-11 12:07:12.000000000 +0300
2284 +++ mutt-1.5.13/globals.h 2006-08-15 13:04:56.000000000 +0300
2285 @@ -93,6 +93,15 @@ WHERE char *MixEntryFormat;
2288 WHERE char *Muttrc INITVAL (NULL);
2290 +WHERE char *NewsCacheDir;
2291 +WHERE char *GroupFormat;
2293 +WHERE char *NewsServer;
2294 +WHERE char *NntpUser;
2295 +WHERE char *NntpPass;
2296 +WHERE char *NewsRc;
2300 WHERE char *PagerFmt;
2301 @@ -183,6 +192,11 @@ extern unsigned char QuadOptions[];
2303 WHERE unsigned short Counter INITVAL (0);
2306 +WHERE short NewsPollTimeout;
2307 +WHERE short NntpContext;
2310 WHERE short ConnectTimeout;
2311 WHERE short HistSize;
2312 WHERE short MenuContext;
2313 diff -udprP mutt-1.5.13.orig/hash.c mutt-1.5.13/hash.c
2314 --- mutt-1.5.13.orig/hash.c 2006-05-18 21:44:29.000000000 +0300
2315 +++ mutt-1.5.13/hash.c 2006-08-15 13:04:56.000000000 +0300
2316 @@ -51,10 +51,35 @@ HASH *hash_create (int nelem)
2319 table->nelem = nelem;
2320 + table->curnelem = 0;
2321 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2325 +HASH *hash_resize (HASH *ptr, int nelem)
2328 + struct hash_elem *elem, *tmp;
2331 + table = hash_create (nelem);
2333 + for (i = 0; i < ptr->nelem; i++)
2335 + for (elem = ptr->table[i]; elem; )
2338 + elem = elem->next;
2339 + hash_insert (table, tmp->key, tmp->data, 1);
2343 + FREE (&ptr->table);
2349 /* table hash table to update
2350 * key key to hash on
2351 * data data to associate with `key'
2352 @@ -74,6 +99,7 @@ int hash_insert (HASH * table, const cha
2354 ptr->next = table->table[h];
2355 table->table[h] = ptr;
2356 + table->curnelem++;
2360 @@ -96,6 +122,7 @@ int hash_insert (HASH * table, const cha
2362 table->table[h] = ptr;
2364 + table->curnelem++;
2368 @@ -126,6 +153,7 @@ void hash_delete_hash (HASH * table, int
2370 destroy (ptr->data);
2372 + table->curnelem--;
2376 diff -udprP mutt-1.5.13.orig/hash.h mutt-1.5.13/hash.h
2377 --- mutt-1.5.13.orig/hash.h 2005-09-18 11:22:22.000000000 +0300
2378 +++ mutt-1.5.13/hash.h 2006-08-15 13:04:56.000000000 +0300
2379 @@ -28,7 +28,7 @@ struct hash_elem
2384 + int nelem, curnelem;
2385 struct hash_elem **table;
2388 @@ -40,6 +40,7 @@ HASH;
2389 HASH *hash_create (int nelem);
2390 int hash_string (const unsigned char *s, int n);
2391 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2392 +HASH *hash_resize (HASH * table, int nelem);
2393 void *hash_find_hash (const HASH * table, int hash, const char *key);
2394 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2395 void (*destroy) (void *));
2396 diff -udprP mutt-1.5.13.orig/hdrline.c mutt-1.5.13/hdrline.c
2397 --- mutt-1.5.13.orig/hdrline.c 2006-04-28 22:43:51.000000000 +0300
2398 +++ mutt-1.5.13/hdrline.c 2006-08-15 13:04:56.000000000 +0300
2399 @@ -205,6 +205,7 @@ int mutt_user_is_recipient (HEADER *h)
2400 * %E = number of messages in current thread
2401 * %f = entire from line
2402 * %F = like %n, unless from self
2403 + * %g = newsgroup name (if compiled with nntp support)
2405 * %l = number of lines in the message
2406 * %L = like %F, except `lists' are displayed first
2407 @@ -218,6 +219,7 @@ int mutt_user_is_recipient (HEADER *h)
2409 * %u = user (login) name of author
2410 * %v = first name of author, unless from self
2411 + * %W = where user is (organization)
2412 * %X = number of MIME attachments
2413 * %y = `x-label:' field (if present)
2414 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2415 @@ -455,6 +457,12 @@ hdr_format_str (char *dest,
2421 + mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2426 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2428 @@ -631,6 +639,13 @@ hdr_format_str (char *dest,
2429 mutt_format_s (dest, destlen, prefix, buf2);
2434 + mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2435 + else if (!hdr->env->organization)
2442 diff -udprP mutt-1.5.13.orig/headers.c mutt-1.5.13/headers.c
2443 --- mutt-1.5.13.orig/headers.c 2006-04-20 19:46:28.000000000 +0300
2444 +++ mutt-1.5.13/headers.c 2006-08-15 13:04:56.000000000 +0300
2445 @@ -118,6 +118,9 @@ void mutt_edit_headers (const char *edit
2446 msg->env = n; n = NULL;
2448 if (!msg->env->in_reply_to)
2450 + if (!option (OPTNEWSSEND))
2452 mutt_free_list (&msg->env->references);
2454 mutt_expand_aliases_env (msg->env);
2455 diff -udprP mutt-1.5.13.orig/init.c mutt-1.5.13/init.c
2456 --- mutt-1.5.13.orig/init.c 2006-07-05 11:40:05.000000000 +0300
2457 +++ mutt-1.5.13/init.c 2006-08-15 13:04:56.000000000 +0300
2458 @@ -2839,6 +2839,28 @@ void mutt_init (int skip_sys_rc, LIST *c
2460 Fqdn = safe_strdup(NONULL(Hostname));
2467 + if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2470 + fgets (buffer, sizeof (buffer), f);
2474 + while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2476 + NewsServer = safe_strdup (p);
2480 + if ((p = getenv ("NNTPSERVER")))
2481 + NewsServer = safe_strdup (p);
2484 if ((p = getenv ("MAIL")))
2485 Spoolfile = safe_strdup (p);
2486 else if ((p = getenv ("MAILDIR")))
2487 diff -udprP mutt-1.5.13.orig/init.h mutt-1.5.13/init.h
2488 --- mutt-1.5.13.orig/init.h 2006-08-11 12:04:04.000000000 +0300
2489 +++ mutt-1.5.13/init.h 2006-08-15 13:04:56.000000000 +0300
2490 @@ -215,6 +215,20 @@ struct option_t MuttVars[] = {
2491 ** If set, Mutt will prompt you for carbon-copy (Cc) recipients before
2492 ** editing the body of an outgoing message.
2495 + { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2498 + ** If set, Mutt will prompt you for follow-up groups before editing
2499 + ** the body of an outgoing message.
2501 + { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2504 + ** If set, Mutt will prompt you for x-comment-to field before editing
2505 + ** the body of an outgoing message.
2508 { "attach_format", DT_STR, R_NONE, UL &AttachFormat, UL "%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] " },
2511 @@ -318,6 +332,14 @@ struct option_t MuttVars[] = {
2512 ** follow these menus. The option is disabled by default because many
2513 ** visual terminals don't permit making the cursor invisible.
2516 + { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2519 + ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2520 + ** as read when you quit the newsgroup (catchup newsgroup).
2523 { "charset", DT_STR, R_NONE, UL &Charset, UL 0 },
2526 @@ -639,6 +661,16 @@ struct option_t MuttVars[] = {
2527 ** sent to both the list and your address, resulting in two copies
2528 ** of the same email for you.
2531 + { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2534 + ** If this variable is \fIset\fP and the keyword "poster" is present in
2535 + ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2536 + ** permitted. The message will be mailed to the submitter of the
2537 + ** message via mail.
2540 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2543 @@ -710,6 +742,27 @@ struct option_t MuttVars[] = {
2544 ** a regular expression that will match the whole name so mutt will expand
2545 ** "Franklin" to "Franklin, Steve".
2548 + { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2551 + ** This variable allows you to customize the newsgroup browser display to
2552 + ** your personal taste. This string is similar to ``$index_format'', but
2553 + ** has its own set of printf()-like sequences:
2556 + ** %C current newsgroup number
2557 + ** %d description of newsgroup (becomes from server)
2558 + ** %f newsgroup name
2559 + ** %M - if newsgroup not allowed for direct post (moderated for example)
2560 + ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2561 + ** %n number of new articles in newsgroup
2562 + ** %s number of unread articles in newsgroup
2563 + ** %>X right justify the rest of the string and pad with character "X"
2564 + ** %|X pad to the end of the line with character "X"
2568 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2571 @@ -995,6 +1048,7 @@ struct option_t MuttVars[] = {
2572 ** .dt %E .dd number of messages in current thread
2573 ** .dt %f .dd entire From: line (address + real name)
2574 ** .dt %F .dd author name, or recipient name if the message is from you
2575 + ** .dt %g .dd newsgroup name (if compiled with nntp support)
2576 ** .dt %H .dd spam attribute(s) of this message
2577 ** .dt %i .dd message-id of the current message
2578 ** .dt %l .dd number of lines in the message (does not work with maildir,
2579 @@ -1014,6 +1068,7 @@ struct option_t MuttVars[] = {
2580 ** .dt %T .dd the appropriate character from the $$to_chars string
2581 ** .dt %u .dd user (login) name of the author
2582 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2583 + ** .dt %W .dd name of organization of author (`organization:' field)
2584 ** .dt %X .dd number of attachments
2585 ** (please see the ``$attachments'' section for possible speed effects)
2586 ** .dt %y .dd `x-label:' field, if present
2587 @@ -1038,6 +1093,21 @@ struct option_t MuttVars[] = {
2589 ** See also: ``$$to_chars''.
2592 + { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2595 + ** If set, specifies the program and arguments used to deliver news posted
2596 + ** by Mutt. Otherwise, mutt posts article using current connection to
2597 + ** news server. The following printf-style sequence is understood:
2600 + ** %s newsserver name
2603 + ** Example: set inews="/usr/local/bin/inews -hS"
2606 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2609 @@ -1252,6 +1322,16 @@ struct option_t MuttVars[] = {
2610 ** be attached to the newly composed message if this option is set.
2614 + { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2617 + ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2618 + ** encoded according to RFC2047 to base64. This is useful when message
2619 + ** is Usenet article, because MIME for news is nonstandard feature.
2624 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2626 @@ -1322,6 +1402,77 @@ struct option_t MuttVars[] = {
2627 ** See also ``$$read_inc'' and ``$$write_inc''.
2631 + { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2634 + ** This variable pointing to directory where Mutt will save cached news
2635 + ** articles headers in. If \fIunset\fP, headers will not be saved at all
2636 + ** and will be reloaded each time when you enter to newsgroup.
2638 + { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2641 + ** This variable specifies domain name or address of NNTP server. It
2642 + ** defaults to the newsserver specified in the environment variable
2643 + ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2644 + ** specify username and an alternative port for each newsserver, ie:
2646 + ** [nntp[s]://][username[:password]@]newsserver[:port]
2648 + { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2651 + ** The file, containing info about subscribed newsgroups - names and
2652 + ** indexes of read articles. The following printf-style sequence
2656 + ** %s newsserver name
2659 + { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2662 + ** This variable defines number of articles which will be in index when
2663 + ** newsgroup entered. If active newsgroup have more articles than this
2664 + ** number, oldest articles will be ignored. Also controls how many
2665 + ** articles headers will be saved in cache when you quit newsgroup.
2667 + { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2670 + ** This variable controls whether or not descriptions for each newsgroup
2671 + ** must be loaded when newsgroup is added to list (first time list
2672 + ** loading or new newsgroup adding).
2674 + { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2677 + ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2678 + ** authentification, Mutt will prompt you for your account name when you
2679 + ** connect to newsserver.
2681 + { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2684 + ** Your password for NNTP account.
2686 + { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2689 + ** The time in seconds until any operations on newsgroup except post new
2690 + ** article will cause recheck for new news. If set to 0, Mutt will
2691 + ** recheck newsgroup on each operation in index (stepping, read article,
2694 + { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2697 + ** Controls whether or not Mutt will try to reconnect to newsserver when
2698 + ** connection lost.
2701 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2704 @@ -2132,6 +2283,16 @@ struct option_t MuttVars[] = {
2705 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2709 + { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2712 + ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2713 + ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2714 + ** does not support posting to that newsgroup or totally read-only, that
2715 + ** posting will not have an effect.
2718 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2721 @@ -2480,6 +2641,28 @@ struct option_t MuttVars[] = {
2722 ** Command to use when spawning a subshell. By default, the user's login
2723 ** shell from /etc/passwd is used.
2726 + { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2729 + ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2730 + ** ``newsrc'' file and into cache.
2732 + { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2735 + ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2736 + ** the browser. Otherwise, it will be done only once for a newsserver.
2737 + ** Also controls whether or not number of new articles of subscribed
2738 + ** newsgroups will be then checked.
2740 + { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2743 + ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2744 + ** will be displayed in browser.
2747 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2750 @@ -2939,6 +3122,14 @@ struct option_t MuttVars[] = {
2751 ** Controls whether mutt writes out the Bcc header when preparing
2752 ** messages to be sent. Exim users may wish to unset this.
2755 + { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2758 + ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2759 + ** name of original article author) to article that followuped to newsgroup.
2765 diff -udprP mutt-1.5.13.orig/keymap.c mutt-1.5.13/keymap.c
2766 --- mutt-1.5.13.orig/keymap.c 2005-09-18 11:22:22.000000000 +0300
2767 +++ mutt-1.5.13/keymap.c 2006-08-15 13:04:56.000000000 +0300
2768 @@ -629,7 +629,6 @@ void km_init (void)
2769 km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE);
2771 km_bindkey ("x", MENU_PAGER, OP_EXIT);
2772 - km_bindkey ("i", MENU_PAGER, OP_EXIT);
2773 km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE);
2774 km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE);
2775 km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE);
2776 diff -udprP mutt-1.5.13.orig/mailbox.h mutt-1.5.13/mailbox.h
2777 --- mutt-1.5.13.orig/mailbox.h 2005-09-18 11:22:22.000000000 +0300
2778 +++ mutt-1.5.13/mailbox.h 2006-08-15 13:04:56.000000000 +0300
2779 @@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2781 int mx_is_pop (const char *);
2784 +int mx_is_nntp (const char *);
2787 int mx_access (const char*, int);
2788 int mx_check_empty (const char *);
2789 diff -udprP mutt-1.5.13.orig/main.c mutt-1.5.13/main.c
2790 --- mutt-1.5.13.orig/main.c 2006-08-11 12:07:12.000000000 +0300
2791 +++ mutt-1.5.13/main.c 2006-08-15 13:04:56.000000000 +0300
2793 #include <stringprep.h>
2800 static const char *ReachingUs = N_("\
2801 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2802 To report a bug, please visit http://bugs.mutt.org/.\n");
2803 @@ -127,6 +131,8 @@ options:\n\
2804 " -e <command>\tspecify a command to be executed after initialization\n\
2805 -f <file>\tspecify which mailbox to read\n\
2806 -F <file>\tspecify an alternate muttrc file\n\
2807 + -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2808 + -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2809 -H <file>\tspecify a draft file to read header and body from\n\
2810 -i <file>\tspecify a file which Mutt should include in the body\n\
2811 -m <type>\tspecify a default mailbox type\n\
2812 @@ -251,6 +257,12 @@ static void show_version (void)
2825 @@ -518,6 +530,9 @@ static void start_curses (void)
2826 #define M_NOSYSRC (1<<2) /* -n */
2827 #define M_RO (1<<3) /* -R */
2828 #define M_SELECT (1<<4) /* -y */
2830 +#define M_NEWS (1<<5) /* -g and -G */
2833 int main (int argc, char **argv)
2835 @@ -566,7 +581,11 @@ int main (int argc, char **argv)
2836 memset (Options, 0, sizeof (Options));
2837 memset (QuadOptions, 0, sizeof (QuadOptions));
2840 + while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2842 while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2847 @@ -659,6 +678,20 @@ int main (int argc, char **argv)
2852 + case 'g': /* Specify a newsserver */
2854 + char buf[LONG_STRING];
2856 + snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2857 + commands = mutt_add_list (commands, buf);
2860 + case 'G': /* List of newsgroups */
2861 + flags |= M_SELECT | M_NEWS;
2868 @@ -921,6 +954,18 @@ int main (int argc, char **argv)
2870 else if (flags & M_SELECT)
2873 + if (flags & M_NEWS)
2875 + set_option (OPTNEWS);
2876 + if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2878 + mutt_endwin (Errorbuf);
2885 mutt_endwin _("No incoming mailboxes defined.");
2887 @@ -936,6 +981,15 @@ int main (int argc, char **argv)
2890 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2893 + if (option (OPTNEWS))
2895 + unset_option (OPTNEWS);
2896 + nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2900 mutt_expand_path (folder, sizeof (folder));
2902 mutt_str_replace (&CurrentFolder, folder);
2903 diff -udprP mutt-1.5.13.orig/mutt.h mutt-1.5.13/mutt.h
2904 --- mutt-1.5.13.orig/mutt.h 2006-08-11 12:22:15.000000000 +0300
2905 +++ mutt-1.5.13/mutt.h 2006-08-15 13:04:56.000000000 +0300
2906 @@ -240,6 +240,9 @@ enum
2914 /* Options for Mailcap lookup */
2916 @@ -295,6 +298,12 @@ enum
2919 OPT_VERIFYSIG, /* verify PGP signatures */
2922 + OPT_NNTPRECONNECT,
2924 + OPT_FOLLOWUPTOPOSTER,
2925 +#endif /* USE_NNTP */
2927 /* THIS MUST BE THE LAST VALUE. */
2929 @@ -310,6 +319,7 @@ enum
2930 #define SENDMAILX (1<<6)
2931 #define SENDKEY (1<<7)
2932 #define SENDRESEND (1<<8)
2933 +#define SENDNEWS (1<<9)
2935 /* flags to _mutt_select_file() */
2936 #define M_SEL_BUFFY (1<<0)
2937 @@ -329,6 +339,8 @@ enum
2946 @@ -399,6 +411,9 @@ enum
2951 + OPTMIMESUBJECT, /* encode subject line with RFC2047 */
2956 @@ -479,6 +494,16 @@ enum
2960 + /* news options */
2964 + OPTSHOWONLYUNREAD,
2968 +#endif /* USE_NNTP */
2970 /* pseudo options */
2972 OPTAUXSORT, /* (pseudo) using auxillary sort function */
2973 @@ -499,6 +524,7 @@ enum
2974 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
2975 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
2976 OPTATTACHMSG, /* (pseudo) used by attach-message */
2977 + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
2978 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
2979 * functions while we are executing an
2981 @@ -509,6 +535,12 @@ enum
2982 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
2983 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
2986 + OPTNEWS, /* (pseudo) used to change reader mode */
2987 + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
2988 + OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
2994 @@ -586,6 +618,13 @@ typedef struct envelope
2998 + char *organization;
3002 + char *followup_to;
3003 + char *x_comment_to;
3006 LIST *references; /* message references (in reverse order) */
3007 LIST *in_reply_to; /* in-reply-to header content */
3008 @@ -751,6 +790,9 @@ typedef struct header
3009 ENVELOPE *env; /* envelope information */
3010 BODY *content; /* list of MIME parts */
3016 char *tree; /* character string to print thread tree */
3017 struct thread *thread;
3018 @@ -766,7 +808,7 @@ typedef struct header
3019 int refno; /* message number on server */
3022 -#if defined USE_POP || defined USE_IMAP
3023 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3024 void *data; /* driver-specific data */
3027 @@ -857,7 +899,7 @@ typedef struct
3028 int deleted; /* how many deleted messages */
3029 int flagged; /* how many flagged messages */
3030 int msgnotreadyet; /* which msg "new" in pager, -1 if none */
3031 -#if defined USE_POP || defined USE_IMAP
3032 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3033 void *data; /* driver specific data */
3034 #endif /* USE_IMAP */
3036 diff -udprP mutt-1.5.13.orig/muttlib.c mutt-1.5.13/muttlib.c
3037 --- mutt-1.5.13.orig/muttlib.c 2006-06-08 14:51:03.000000000 +0300
3038 +++ mutt-1.5.13/muttlib.c 2006-08-15 13:04:56.000000000 +0300
3039 @@ -286,7 +286,7 @@ void mutt_free_header (HEADER **h)
3041 mutt_free_list (&(*h)->chain);
3043 -#if defined USE_POP || defined USE_IMAP
3044 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3047 FREE (h); /* __FREE_CHECKED__ */
3048 @@ -671,6 +671,13 @@ void mutt_free_envelope (ENVELOPE **p)
3049 FREE (&(*p)->supersedes);
3051 FREE (&(*p)->x_label);
3052 + FREE (&(*p)->organization);
3054 + FREE (&(*p)->newsgroups);
3055 + FREE (&(*p)->xref);
3056 + FREE (&(*p)->followup_to);
3057 + FREE (&(*p)->x_comment_to);
3060 mutt_buffer_free (&(*p)->spam);
3062 @@ -1275,6 +1282,14 @@ int mutt_save_confirm (const char *s, st
3067 + if (magic == M_NNTP)
3069 + mutt_error _("Can't save message to newsserver.");
3074 if (stat (s, st) != -1)
3077 diff -udprP mutt-1.5.13.orig/mx.c mutt-1.5.13/mx.c
3078 --- mutt-1.5.13.orig/mx.c 2006-05-18 21:44:29.000000000 +0300
3079 +++ mutt-1.5.13/mx.c 2006-08-15 13:04:56.000000000 +0300
3091 @@ -352,6 +356,22 @@ int mx_is_pop (const char *p)
3096 +int mx_is_nntp (const char *p)
3098 + url_scheme_t scheme;
3103 + scheme = url_check_scheme (p);
3104 + if (scheme == U_NNTP || scheme == U_NNTPS)
3111 int mx_get_magic (const char *path)
3114 @@ -369,6 +389,11 @@ int mx_get_magic (const char *path)
3116 #endif /* USE_POP */
3119 + if (mx_is_nntp (path))
3121 +#endif /* USE_NNTP */
3123 if (stat (path, &st) == -1)
3125 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
3126 @@ -705,6 +730,12 @@ CONTEXT *mx_open_mailbox (const char *pa
3128 #endif /* USE_POP */
3132 + rc = nntp_open_mailbox (ctx);
3134 +#endif /* USE_NNTP */
3139 @@ -750,6 +781,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
3140 if (ctx->magic == M_POP)
3141 pop_close_mailbox (ctx);
3142 #endif /* USE_POP */
3144 + if (ctx->magic == M_NNTP)
3145 + nntp_fastclose_mailbox (ctx);
3146 +#endif /* USE_NNTP */
3148 hash_destroy (&ctx->subj_hash, NULL);
3150 @@ -805,6 +840,12 @@ static int sync_mailbox (CONTEXT *ctx, i
3151 rc = pop_sync_mailbox (ctx, index_hint);
3153 #endif /* USE_POP */
3157 + rc = nntp_sync_mailbox (ctx);
3159 +#endif /* USE_NNTP */
3163 @@ -833,6 +874,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
3168 + if (ctx->magic == M_NNTP)
3172 + ret = nntp_close_mailbox (ctx);
3173 + mx_fastclose_mailbox (ctx);
3177 if (ctx->readonly || ctx->dontwrite)
3179 /* mailbox is readonly or we don't want to write */
3180 @@ -1370,6 +1421,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
3182 return (pop_check_mailbox (ctx, index_hint));
3183 #endif /* USE_POP */
3187 + return (nntp_check_mailbox (ctx));
3188 +#endif /* USE_NNTP */
3192 @@ -1430,6 +1486,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
3194 #endif /* USE_POP */
3199 + if (nntp_fetch_message (msg, ctx, msgno) != 0)
3203 +#endif /* USE_NNTP */
3206 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3208 @@ -1511,6 +1576,9 @@ int mx_close_message (MESSAGE **msg)
3210 || (*msg)->magic == M_POP
3213 + || (*msg)->magic == M_NNTP
3217 r = safe_fclose (&(*msg)->fp);
3218 diff -udprP mutt-1.5.13.orig/mx.h mutt-1.5.13/mx.h
3219 --- mutt-1.5.13.orig/mx.h 2005-09-18 11:22:22.000000000 +0300
3220 +++ mutt-1.5.13/mx.h 2006-08-15 13:04:56.000000000 +0300
3221 @@ -40,6 +40,9 @@ enum
3230 WHERE short DefaultMagic INITVAL (M_MBOX);
3231 diff -udprP mutt-1.5.13.orig/newsrc.c mutt-1.5.13/newsrc.c
3232 --- mutt-1.5.13.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3233 +++ mutt-1.5.13/newsrc.c 2006-08-15 13:04:56.000000000 +0300
3236 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3237 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
3238 + * Copyright (C) 2000-2006 Vsevolod Volkov <vvv@mutt.org.ua>
3240 + * This program is free software; you can redistribute it and/or modify
3241 + * it under the terms of the GNU General Public License as published by
3242 + * the Free Software Foundation; either version 2 of the License, or
3243 + * (at your option) any later version.
3245 + * This program is distributed in the hope that it will be useful,
3246 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3247 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3248 + * GNU General Public License for more details.
3250 + * You should have received a copy of the GNU General Public License
3251 + * along with this program; if not, write to the Free Software
3252 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3256 +# include "config.h"
3260 +#include "mutt_curses.h"
3264 +#include "mailbox.h"
3266 +#include "rfc822.h"
3267 +#include "rfc1524.h"
3268 +#include "rfc2047.h"
3270 +#include <unistd.h>
3271 +#include <string.h>
3273 +#include <stdlib.h>
3274 +#include <sys/stat.h>
3276 +void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3283 + l = safe_calloc (1, sizeof (LIST));
3285 + s->tail->next = l;
3289 + l->data = (void *) d;
3292 +static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3295 + char group[LONG_STRING];
3297 + char *p = line, *b, *h;
3307 + while (*p && (*p != ':' && *p != '!')) p++;
3310 + len = p + 1 - line;
3311 + if (len > sizeof (group))
3312 + len = sizeof (group);
3313 + strfcpy (group, line, len);
3314 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3316 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3317 + data->group = (char *) data + sizeof (NNTP_DATA);
3318 + strcpy (data->group, group);
3319 + data->nserv = news;
3320 + data->deleted = 1;
3321 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3322 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3323 + hash_insert (news->newsgroups, data->group, data, 0);
3324 + nntp_add_to_list (news, data);
3327 + FREE ((void **) &data->entries);
3330 + data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3334 + data->subscribed = 1;
3336 + data->subscribed = 0;
3343 + while (*p && *p != ',' && *p != '\n') p++;
3349 + if ((h = strchr(b, '-')))
3353 + data->entries[x].first = atoi(b);
3354 + data->entries[x].last = atoi(h);
3358 + data->entries[x].first = atoi(b);
3359 + data->entries[x].last = data->entries[x].first;
3362 + if (data->entries[x].last != 0)
3365 + if (x && !data->lastMessage)
3366 + data->lastMessage = data->entries[x-1].last;
3368 + mutt_newsgroup_stat (data);
3369 + dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3374 +static int slurp_newsrc (NNTP_SERVER *news)
3380 + news->stat = stat (news->newsrc, &sb);
3381 + news->size = sb.st_size;
3382 + news->mtime = sb.st_mtime;
3384 + if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3386 + /* hmm, should we use dotlock? */
3387 + if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3393 + buf = safe_malloc (sb.st_size + 1);
3394 + while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3395 + nntp_parse_newsrc_line (news, buf);
3398 + mx_unlock_file (news->newsrc, fileno (fp), 0);
3403 +void nntp_cache_expand (char *dst, const char *src)
3405 + snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3406 + mutt_expand_path (dst, _POSIX_PATH_MAX);
3409 +/* Loads $news_cache_dir/.index into memory, loads newsserver data
3410 + * and newsgroup cache names */
3411 +static int nntp_parse_cacheindex (NNTP_SERVER *news)
3414 + char buf[HUGE_STRING], *cp;
3415 + char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3420 + /* check is server name defined or not */
3421 + if (!news || !news->conn || !news->conn->account.host)
3423 + unset_option (OPTNEWSCACHE);
3424 + if (!NewsCacheDir || !*NewsCacheDir)
3427 + strfcpy (dir, NewsCacheDir, sizeof (dir));
3428 + mutt_expand_path (dir, sizeof(dir));
3430 + if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3432 + snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3433 + if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3436 + mutt_error _("Cache directory not created!");
3439 + mutt_clear_error();
3442 + set_option (OPTNEWSCACHE);
3444 + FREE (&news->cache);
3445 + snprintf (buf, sizeof(buf), "%s/.index", dir);
3446 + if (!(index = safe_fopen (buf, "a+")))
3449 + while (fgets (buf, sizeof(buf), index))
3451 + buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3452 + if (!mutt_strncmp (buf, "#: ", 3) &&
3453 + !mutt_strcasecmp (buf+3, news->conn->account.host))
3456 + while (fgets (buf, sizeof(buf), index))
3459 + while (*cp && *cp != ' ') cp++;
3460 + if (!*cp) continue;
3462 + if (!mutt_strcmp (buf, "#:"))
3464 + sscanf (cp + 1, "%s %d %d", file, &l, &m);
3465 + if (!mutt_strcmp (buf, "ALL"))
3467 + news->cache = safe_strdup (file);
3468 + news->newgroups_time = m;
3470 + else if (news->newsgroups)
3472 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3474 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3475 + data->group = (char *) data + sizeof (NNTP_DATA);
3476 + strcpy(data->group, buf);
3477 + data->nserv = news;
3478 + data->deleted = 1;
3479 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3480 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3481 + hash_insert (news->newsgroups, data->group, data, 0);
3482 + nntp_add_to_list (news, data);
3484 + data->cache = safe_strdup (file);
3486 + if (!data->firstMessage || data->lastMessage < m)
3488 + if (!data->firstMessage)
3489 + data->firstMessage = l;
3490 + if (data->lastMessage < m)
3491 + data->lastMessage = m;
3492 + data->lastCached = m;
3493 + if (t || !data->unread)
3494 + mutt_newsgroup_stat (data);
3502 +nntp_format_str (char *dest, size_t destlen, char op, const char *src,
3503 + const char *fmt, const char *ifstring, const char *elsestring,
3504 + unsigned long data, format_flag flags)
3506 + char fn[SHORT_STRING], tmp[SHORT_STRING];
3511 + strncpy (fn, NewsServer, sizeof(fn) - 1);
3512 + mutt_strlower (fn);
3513 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3514 + snprintf (dest, destlen, tmp, fn);
3520 +/* nntp_parse_url: given an NNPT URL, return host, port,
3521 + * username, password and newsgroup will recognise. */
3522 +int nntp_parse_url (const char *server, ACCOUNT *acct,
3523 + char *group, size_t group_len)
3531 + acct->port = NNTP_PORT;
3532 + acct->type = M_ACCT_TYPE_NNTP;
3534 + c = safe_strdup (server);
3535 + url_parse_ciss (&url, c);
3537 + if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3539 + if (url.scheme == U_NNTPS)
3541 + acct->flags |= M_ACCT_SSL;
3542 + acct->port = NNTP_SSL_PORT;
3547 + strfcpy (group, url.path, group_len);
3549 + ret = mutt_account_fromurl (acct, &url);
3556 +void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3560 + url.path = safe_strdup (line);
3561 + mutt_account_tourl (acct, &url);
3562 + url_ciss_tostring (&url, line, len, 0);
3567 + * Automatically loads a newsrc into memory, if necessary.
3568 + * Checks the size/mtime of a newsrc file, if it doesn't match, load
3569 + * again. Hmm, if a system has broken mtimes, this might mean the file
3570 + * is reloaded every time, which we'd have to fix.
3572 + * a newsrc file is a line per newsgroup, with the newsgroup, then a
3573 + * ':' denoting subscribed or '!' denoting unsubscribed, then a
3574 + * comma separated list of article numbers and ranges.
3576 +NNTP_SERVER *mutt_select_newsserver (char *server)
3578 + char file[_POSIX_PATH_MAX];
3582 + NNTP_SERVER *serv;
3585 + if (!server || !*server)
3587 + mutt_error _("No newsserver defined!");
3591 + buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3592 + if (url_check_scheme (server) == U_UNKNOWN)
3594 + strcpy (buf, "nntp://");
3595 + p = strchr (buf, '\0');
3597 + strcpy (p, server);
3599 + if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3602 + mutt_error (_("%s is an invalid newsserver specification!"), server);
3607 + conn = mutt_conn_find (NULL, &acct);
3611 + mutt_FormatString (file, sizeof (file), NONULL (NewsRc), nntp_format_str, 0, 0);
3612 + mutt_expand_path (file, sizeof (file));
3614 + serv = (NNTP_SERVER *)conn->data;
3619 + /* externally modified? */
3620 + if (serv->stat != stat (file, &sb) || (!serv->stat &&
3621 + (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3623 + for (list = serv->list; list; list = list->next)
3625 + NNTP_DATA *data = (NNTP_DATA *) list->data;
3629 + data->subscribed = 0;
3634 + slurp_newsrc (serv);
3635 + nntp_clear_cacheindex (serv);
3638 + if (serv->status == NNTP_BYE)
3639 + serv->status = NNTP_NONE;
3640 + nntp_check_newgroups (serv, 0);
3644 + /* New newsserver */
3645 + serv = safe_calloc (1, sizeof (NNTP_SERVER));
3646 + serv->conn = conn;
3647 + serv->newsrc = safe_strdup (file);
3648 + serv->newsgroups = hash_create (1009);
3649 + slurp_newsrc (serv); /* load .newsrc */
3650 + nntp_parse_cacheindex (serv); /* load .index */
3651 + if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3652 + nntp_check_newgroups (serv, 1);
3653 + else if (nntp_get_active (serv) < 0)
3655 + hash_destroy (&serv->newsgroups, nntp_delete_data);
3656 + for (list = serv->list; list; list = list->next)
3657 + list->data = NULL;
3658 + mutt_free_list (&serv->list);
3659 + FREE (&serv->newsrc);
3660 + FREE (&serv->cache);
3664 + nntp_clear_cacheindex (serv);
3665 + conn->data = (void *)serv;
3671 + * full status flags are not supported by nntp, but we can fake some
3672 + * of them. This is how:
3673 + * Read = a read message number is in the .newsrc
3674 + * New = a message is new since we last read this newsgroup
3675 + * Old = anything else
3676 + * So, Read is marked as such in the newsrc, old is anything that is
3677 + * "skipped" in the newsrc, and new is anything not in the newsrc nor
3678 + * in the cache. By skipped, I mean before the last unread message
3680 +void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3682 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3686 + data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3692 + dprint (3, (debugfile, "newsgroup %s not found\n", group));
3697 + for (x = 0; x < data->num; x++)
3699 + if ((article >= data->entries[x].first) &&
3700 + (article <= data->entries[x].last))
3702 + /* we cannot use mutt_set_flag() because mx_update_context()
3703 + didn't called yet */
3708 + /* If article was not cached yet, it is new! :) */
3709 + if (!data->cache || article > data->lastCached)
3711 + /* Old articles are articles which aren't read but an article after them
3712 + * has been cached */
3713 + if (option (OPTMARKOLD))
3717 +void mutt_newsgroup_stat (NNTP_DATA *data)
3720 + unsigned int first, last;
3723 + if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3726 + data->unread = data->lastMessage - data->firstMessage + 1;
3727 + for (i = 0; i < data->num; i++)
3729 + first = data->entries[i].first;
3730 + if (first < data->firstMessage)
3731 + first = data->firstMessage;
3732 + last = data->entries[i].last;
3733 + if (last > data->lastMessage)
3734 + last = data->lastMessage;
3735 + if (first <= last)
3736 + data->unread -= last - first + 1;
3740 +static int puti (char *line, int num)
3744 + for (p = s; num; )
3746 + *p++ = '0' + num % 10;
3750 + *line++ = *--p, num++;
3755 +static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3757 + char *line = *pline;
3758 + size_t len = *buflen - (*pline - *buf);
3761 + if (len < LONG_STRING * 10)
3766 + safe_realloc (buf, *buflen);
3767 + line = *buf + (*pline - line);
3769 + strcpy (line, data->group);
3770 + len -= strlen (line) + 1;
3771 + line += strlen (line);
3772 + *line++ = data->subscribed ? ':' : '!';
3776 + for (x = 0; x < data->num; x++)
3778 + if (len < LONG_STRING)
3784 + safe_realloc (buf, *buflen);
3785 + line = *buf + (*pline - line);
3794 + if (data->entries[x].first == data->entries[x].last)
3795 + snprintf (line, len, "%d%n", data->entries[x].first, &i);
3797 + snprintf (line, len, "%d-%d%n",
3798 + data->entries[x].first, data->entries[x].last, &i);
3802 + i = puti (line, data->entries[x].first);
3803 + line +=i; len -= i;
3804 + if (data->entries[x].first != data->entries[x].last)
3808 + i = puti (line, data->entries[x].last);
3809 + line +=i; len -= i;
3818 +void newsrc_gen_entries (CONTEXT *ctx)
3820 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3822 + unsigned int last = 0, first = 1;
3823 + int save_sort = SORT_ORDER;
3825 + if (Sort != SORT_ORDER)
3828 + Sort = SORT_ORDER;
3829 + mutt_sort_headers (ctx, 0);
3834 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3839 + * Set up to fake initial sequence from 1 to the article before the
3840 + * first article in our list
3845 + for (x = 0; x < ctx->msgcount; x++)
3847 + if (series) /* search for first unread */
3850 + * We don't actually check sequential order, since we mark
3851 + * "missing" entries as read/deleted
3853 + last = ctx->hdrs[x]->article_num;
3854 + if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3855 + !ctx->hdrs[x]->read)
3857 + if (data->num >= data->max)
3859 + data->max = data->max * 2;
3860 + safe_realloc (&data->entries,
3861 + data->max * sizeof (NEWSRC_ENTRY));
3863 + data->entries[data->num].first = first;
3864 + data->entries[data->num].last = last - 1;
3869 + else /* search for first read */
3871 + if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3876 + last = ctx->hdrs[x]->article_num;
3879 + if (series && first <= data->lastLoaded)
3881 + if (data->num >= data->max)
3883 + data->max = data->max * 2;
3884 + safe_realloc (&data->entries,
3885 + data->max * sizeof (NEWSRC_ENTRY));
3887 + data->entries[data->num].first = first;
3888 + data->entries[data->num].last = data->lastLoaded;
3892 + if (save_sort != Sort)
3895 + mutt_sort_headers (ctx, 0);
3899 +static int mutt_update_list_file (char *filename, char *section,
3900 + char *key, char *line)
3904 + char buf[HUGE_STRING];
3905 + char tmpfile[_POSIX_PATH_MAX];
3907 + int ext = 0, done = 0, r = 0;
3909 + /* if file not exist, create it */
3910 + if ((ifp = safe_fopen (filename, "a")))
3912 + dprint (1, (debugfile, "Opening %s\n", filename));
3913 + if (!(ifp = safe_fopen (filename, "r")))
3915 + mutt_error (_("Unable to open %s for reading"), filename);
3918 + if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3921 + mutt_error (_("Unable to lock %s"), filename);
3924 + snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3925 + dprint (1, (debugfile, "Opening %s\n", tmpfile));
3926 + if (!(ofp = fopen (tmpfile, "w")))
3929 + mutt_error (_("Unable to open %s for writing"), tmpfile);
3935 + while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3937 + r = fputs (buf, ofp);
3939 + while (*c && *c != '\n') c++;
3940 + c[0] = 0; /* strip EOL */
3941 + if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3944 + if (r != EOF && !done)
3946 + snprintf (buf, sizeof(buf), "#: %s\n", section);
3947 + r = fputs (buf, ofp);
3952 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3957 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3959 + if (*c != '\\') ext = 0;
3961 + else if ((section && !strncmp (buf, "#: ", 3)))
3963 + if (!done && line)
3965 + fputs (line, ofp);
3966 + fputc ('\n', ofp);
3968 + r = fputs (buf, ofp);
3972 + else if (key && !strncmp (buf, key, strlen(key)) &&
3973 + (!*key || buf[strlen(key)] == ' '))
3977 + while (*c && (*c != '\r') && (*c != '\n')) c++;
3979 + if (*c == '\\') ext = 1;
3980 + if (!done && line)
3982 + r = fputs (line, ofp);
3984 + r = fputc ('\n', ofp);
3990 + r = fputs (buf, ofp);
3994 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
3995 + r = fputs (buf, ofp);
3997 + /* If there wasn't a line to replace, put it on the end of the file */
3998 + if (r != EOF && !done && line)
4000 + fputs (line, ofp);
4001 + r = fputc ('\n', ofp);
4003 + mx_unlock_file (filename, fileno (ifp), 0);
4009 + mutt_error (_("Can't write %s"), tmpfile);
4012 + if (rename (tmpfile, filename) < 0)
4015 + mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
4021 +int mutt_newsrc_update (NNTP_SERVER *news)
4031 + llen = len = 10 * LONG_STRING;
4032 + line = buf = safe_calloc (1, len);
4033 + /* we will generate full newsrc here */
4034 + for (tmp = news->list; tmp; tmp = tmp->next)
4036 + data = (NNTP_DATA *) tmp->data;
4037 + if (!data || !data->rc)
4039 + nntp_create_newsrc_line (data, &buf, &line, &llen);
4041 + dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4042 + line += strlen (line);
4044 + /* newrc being fully rewritten */
4045 + if (news->newsrc &&
4046 + (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4050 + stat (news->newsrc, &st);
4051 + news->size = st.st_size;
4052 + news->mtime = st.st_mtime;
4058 +static FILE *mutt_mkname (char *s)
4060 + char buf[_POSIX_PATH_MAX], *pc;
4064 + nntp_cache_expand (buf, s);
4065 + if ((fp = safe_fopen (buf, "w")))
4068 + nntp_cache_expand (buf, "cache-XXXXXX");
4069 + pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4070 + if ((fd = mkstemp (buf)) == -1)
4072 + strcpy (s, pc); /* generated name */
4073 + return fdopen (fd, "w");
4076 +/* Updates info into .index file: ALL or about selected newsgroup */
4077 +static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4079 + char buf[LONG_STRING], *key = "ALL";
4080 + char file[_POSIX_PATH_MAX];
4082 + if (!serv || !serv->conn || !serv->conn->account.host)
4085 + if (data && data->group)
4087 + key = data->group;
4088 + snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4089 + data->firstMessage, data->lastLoaded);
4093 + strfcpy (file, serv->cache, sizeof (file));
4094 + snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4096 + nntp_cache_expand (file, ".index");
4097 + return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4100 +/* Remove cache files of unsubscribed newsgroups */
4101 +void nntp_clear_cacheindex (NNTP_SERVER *news)
4106 + if (option (OPTSAVEUNSUB) || !news)
4109 + for (tmp = news->list; tmp; tmp = tmp->next)
4111 + data = (NNTP_DATA *) tmp->data;
4112 + if (!data || data->subscribed || !data->cache)
4114 + nntp_delete_cache (data);
4115 + dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4120 +int nntp_save_cache_index (NNTP_SERVER *news)
4122 + char buf[HUGE_STRING];
4123 + char file[_POSIX_PATH_MAX];
4128 + if (!news || !news->newsgroups)
4130 + if (!option (OPTNEWSCACHE))
4135 + nntp_cache_expand (file, news->cache);
4137 + f = safe_fopen (file, "w");
4141 + strfcpy (buf, news->conn->account.host, sizeof(buf));
4142 + f = mutt_mkname (buf);
4143 + news->cache = safe_strdup (buf);
4144 + nntp_cache_expand (file, buf);
4149 + for (l = news->list; l; l = l->next)
4151 + if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4154 + snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4155 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4158 + snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4159 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4160 + if (fputs (buf, f) == EOF)
4170 + if (nntp_update_cacheindex (news, NULL))
4178 +int nntp_save_cache_group (CONTEXT *ctx)
4180 + char buf[HUGE_STRING], addr[STRING];
4181 + char file[_POSIX_PATH_MAX];
4185 + int i = 0, save = SORT_ORDER;
4188 + if (!option (OPTNEWSCACHE))
4190 + if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4193 + if (((NNTP_DATA *)ctx->data)->cache)
4195 + nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4197 + f = safe_fopen (file, "w");
4201 + snprintf (buf, sizeof(buf), "%s-%s",
4202 + ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4203 + ((NNTP_DATA *)ctx->data)->group);
4204 + f = mutt_mkname (buf);
4205 + ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4206 + nntp_cache_expand (file, buf);
4211 + if (Sort != SORT_ORDER)
4214 + Sort = SORT_ORDER;
4215 + mutt_sort_headers (ctx, 0);
4218 + /* Save only $nntp_context messages... */
4219 + ((NNTP_DATA *)ctx->data)->lastCached = 0;
4220 + if (NntpContext && ctx->msgcount > NntpContext)
4221 + i = ctx->msgcount - NntpContext;
4222 + for (; i < ctx->msgcount; i++)
4224 + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4228 + rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4229 + tm = gmtime (&h->date_sent);
4230 + snprintf (buf, sizeof(buf),
4231 + "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4232 + h->article_num, h->env->subject, addr, tm->tm_mday,
4233 + Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4234 + tm->tm_sec, h->env->message_id);
4236 + if (h->env->references)
4237 + mutt_write_references (h->env->references, f);
4238 + snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", NONULL(h->content->length),
4239 + NONULL(h->lines), NONULL(h->env->xref));
4240 + if (fputs (buf, f) == EOF)
4247 + prev = ctx->hdrs[i]->article_num;
4253 + mutt_sort_headers (ctx, 0);
4257 + if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4258 + (NNTP_DATA *)ctx->data))
4263 + ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4267 +void nntp_delete_cache (NNTP_DATA *data)
4269 + char buf[_POSIX_PATH_MAX];
4271 + if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4274 + nntp_cache_expand (buf, data->cache);
4276 + FREE (&data->cache);
4277 + data->lastCached = 0;
4278 + nntp_cache_expand (buf, ".index");
4279 + mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4282 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4286 + if (!news || !news->newsgroups || !group || !*group)
4288 + if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4290 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4291 + data->group = (char *) data + sizeof (NNTP_DATA);
4292 + strcpy (data->group, group);
4293 + data->nserv = news;
4294 + data->deleted = 1;
4295 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4296 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
4297 + hash_insert (news->newsgroups, data->group, data, 0);
4298 + nntp_add_to_list (news, data);
4300 + if (!data->subscribed)
4302 + data->subscribed = 1;
4308 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4312 + if (!news || !news->newsgroups || !group || !*group ||
4313 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4315 + if (data->subscribed)
4317 + data->subscribed = 0;
4318 + if (!option (OPTSAVEUNSUB))
4324 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4328 + if (!news || !news->newsgroups || !group || !*group ||
4329 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4333 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4337 + data->entries[0].first = 1;
4339 + data->entries[0].last = data->lastMessage;
4340 + if (Context && Context->data == data)
4344 + for (x = 0; x < Context->msgcount; x++)
4345 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4350 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4354 + if (!news || !news->newsgroups || !group || !*group ||
4355 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4359 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4363 + data->entries[0].first = 1;
4364 + data->entries[0].last = data->firstMessage - 1;
4365 + if (Context && Context->data == data)
4369 + data->unread = Context->msgcount;
4370 + for (x = 0; x < Context->msgcount; x++)
4371 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4374 + data->unread = data->lastMessage - data->entries[0].last;
4378 +/* this routine gives the first newsgroup with new messages */
4379 +void nntp_buffy (char *s)
4383 + for (list = CurrentNewsSrv->list; list; list = list->next)
4385 + NNTP_DATA *data = (NNTP_DATA *) list->data;
4387 + if (data && data->subscribed && data->unread)
4389 + if (Context && Context->magic == M_NNTP &&
4390 + !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4392 + unsigned int i, unread = 0;
4394 + for (i = 0; i < Context->msgcount; i++)
4395 + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4400 + strcpy (s, data->group);
4405 diff -udprP mutt-1.5.13.orig/nntp.c mutt-1.5.13/nntp.c
4406 --- mutt-1.5.13.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4407 +++ mutt-1.5.13/nntp.c 2006-08-15 13:04:56.000000000 +0300
4410 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4411 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4412 + * Copyright (C) 2000-2004 Vsevolod Volkov <vvv@mutt.org.ua>
4414 + * This program is free software; you can redistribute it and/or modify
4415 + * it under the terms of the GNU General Public License as published by
4416 + * the Free Software Foundation; either version 2 of the License, or
4417 + * (at your option) any later version.
4419 + * This program is distributed in the hope that it will be useful,
4420 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4421 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4422 + * GNU General Public License for more details.
4424 + * You should have received a copy of the GNU General Public License
4425 + * along with this program; if not, write to the Free Software
4426 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4430 +# include "config.h"
4434 +#include "mutt_curses.h"
4438 +#include "rfc1524.h"
4439 +#include "rfc2047.h"
4440 +#include "mailbox.h"
4451 +#include <unistd.h>
4452 +#include <string.h>
4454 +#include <stdlib.h>
4456 +static unsigned int _checked = 0;
4459 +static void nntp_error (const char *where, const char *msg)
4461 + dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4465 +static int nntp_auth (NNTP_SERVER *serv)
4467 + CONNECTION *conn = serv->conn;
4469 + unsigned char flags = conn->account.flags;
4471 + if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4472 + mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4474 + conn->account.flags = flags;
4478 + mutt_message _("Logging in...");
4480 + snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4481 + mutt_socket_write (conn, buf);
4482 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4484 + conn->account.flags = flags;
4489 + /* don't print the password unless we're at the ungodly debugging level */
4490 + if (debuglevel < M_SOCK_LOG_FULL)
4491 + dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4493 + snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4494 + mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4495 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4497 + conn->account.flags = flags;
4501 + if (mutt_strncmp ("281", buf, 3))
4503 + conn->account.flags = flags;
4504 + mutt_error _("Login failed.");
4512 +static int nntp_connect_error (NNTP_SERVER *serv)
4514 + serv->status = NNTP_NONE;
4515 + mutt_socket_close (serv->conn);
4516 + mutt_error _("Server closed connection!");
4521 +static int nntp_connect_and_auth (NNTP_SERVER *serv)
4523 + CONNECTION *conn = serv->conn;
4527 + serv->status = NNTP_NONE;
4529 + if (mutt_socket_open (conn) < 0)
4532 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4533 + return nntp_connect_error (serv);
4535 + if (!mutt_strncmp ("200", buf, 3))
4536 + mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4537 + else if (!mutt_strncmp ("201", buf, 3))
4538 + mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4541 + mutt_socket_close (conn);
4542 + mutt_remove_trailing_ws (buf);
4543 + mutt_error ("%s", buf);
4550 + /* Tell INN to switch to mode reader if it isn't so. Ignore all
4551 + returned codes and messages. */
4552 + mutt_socket_write (conn, "MODE READER\r\n");
4553 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4554 + return nntp_connect_error (serv);
4556 + mutt_socket_write (conn, "STAT\r\n");
4557 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4558 + return nntp_connect_error (serv);
4560 + if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
4562 + serv->status = NNTP_OK;
4566 + rc = nntp_auth (serv);
4568 + return nntp_connect_error (serv);
4571 + mutt_socket_close (conn);
4572 + serv->status = NNTP_BYE;
4577 + mutt_socket_close (conn);
4578 + mutt_error _("Login failed.");
4582 + serv->status = NNTP_OK;
4586 +static int nntp_attempt_features (NNTP_SERVER *serv)
4588 + char buf[LONG_STRING];
4589 + CONNECTION *conn = serv->conn;
4591 + mutt_socket_write (conn, "XOVER\r\n");
4592 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4593 + return nntp_connect_error (serv);
4594 + if (mutt_strncmp ("500", buf, 3))
4595 + serv->hasXOVER = 1;
4597 + mutt_socket_write (conn, "XPAT\r\n");
4598 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4599 + return nntp_connect_error (serv);
4600 + if (mutt_strncmp ("500", buf, 3))
4601 + serv->hasXPAT = 1;
4603 + mutt_socket_write (conn, "LISTGROUP\r\n");
4604 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4605 + return nntp_connect_error (serv);
4606 + if (mutt_strncmp ("500", buf, 3))
4607 + serv->hasLISTGROUP = 1;
4609 + mutt_socket_write (conn, "XGTITLE +\r\n");
4610 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4611 + return nntp_connect_error (serv);
4612 + if (mutt_strncmp ("500", buf, 3))
4613 + serv->hasXGTITLE = 1;
4615 + if (!mutt_strncmp ("282", buf, 3))
4619 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4620 + return nntp_connect_error (serv);
4621 + } while (!(buf[0] == '.' && buf[1] == '\0'));
4627 +static int nntp_open_connection (NNTP_SERVER *serv)
4629 + if (serv->status == NNTP_OK)
4631 + if (serv->status == NNTP_BYE)
4633 + if (nntp_connect_and_auth (serv) < 0)
4635 + if (nntp_attempt_features (serv) < 0)
4640 +static int nntp_reconnect (NNTP_SERVER *serv)
4642 + char buf[SHORT_STRING];
4644 + mutt_socket_close (serv->conn);
4648 + if (nntp_connect_and_auth (serv) == 0)
4651 + snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
4652 + serv->conn->account.host);
4653 + if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
4655 + serv->status = NNTP_BYE;
4661 +/* Send data from line[LONG_STRING] and receive answer to same line */
4662 +static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
4664 + char buf[LONG_STRING];
4667 + if (data->nserv->status == NNTP_BYE)
4674 + mutt_socket_write (data->nserv->conn, line);
4676 + else if (data->group)
4678 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4679 + mutt_socket_write (data->nserv->conn, buf);
4683 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4685 + if (nntp_reconnect (data->nserv) < 0)
4690 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4691 + mutt_socket_write (data->nserv->conn, buf);
4692 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4698 + else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
4702 + strfcpy (line, buf, linelen);
4707 + * This function calls funct(*line, *data) for each received line,
4708 + * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
4711 + * 1 - correct but not performed (may be, have to be continued),
4712 + * -1 - conection lost,
4713 + * -2 - invalid command or execution error,
4714 + * -3 - error in funct(*line, *data).
4716 +static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
4717 + int (*funct) (char *, void *), void *data, int tagged)
4719 + char buf[LONG_STRING];
4723 + size_t lenbuf = 0;
4728 + strfcpy (buf, query, sizeof (buf));
4729 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
4731 + if (buf[0] == '5')
4733 + if (buf[0] != '2')
4738 + inbuf = safe_malloc (sizeof (buf));
4742 + chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
4748 + if (!lenbuf && buf[0] == '.')
4750 + if (buf[1] == '\0')
4755 + if (buf[1] == '.')
4759 + strfcpy (inbuf + lenbuf, p, sizeof (buf));
4761 + if (chunk >= sizeof (buf))
4763 + lenbuf += strlen (p);
4768 + if (msg && ReadInc && (line % ReadInc == 0)) {
4770 + mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
4772 + mutt_message ("%s %d", msg, line);
4775 + if (ret == 0 && funct (inbuf, data) < 0)
4780 + safe_realloc (&inbuf, lenbuf + sizeof (buf));
4783 + funct (NULL, data);
4789 +static int nntp_read_tempfile (char *line, void *file)
4791 + FILE *f = (FILE *)file;
4798 + if (fputc ('\n', f) == EOF)
4804 +static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
4806 + register char *p, *b;
4807 + register char *colon = NULL;
4812 + /* skip to next word */
4814 + while (*b && ((*b == ' ') || (*b == '\t'))) b++;
4817 + /* skip to end of word */
4818 + while (*p && (*p != ' ') && (*p != '\t'))
4833 + nntp_get_status (ctx, h, b, atoi(colon));
4834 + if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
4835 + h->article_num = atoi(colon);
4843 + * 1 if article not found
4844 + * -1 if read or write error on tempfile or socket
4846 +static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
4848 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
4850 + char buf[LONG_STRING];
4851 + char tempfile[_POSIX_PATH_MAX];
4853 + HEADER *h = ctx->hdrs[ctx->msgcount];
4855 + mutt_mktemp (tempfile);
4856 + if (!(f = safe_fopen (tempfile, "w+")))
4860 + snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
4862 + snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
4864 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
4869 + dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
4872 + unlink (tempfile);
4873 + return (ret == -1 ? -1 : 1);
4876 + h->article_num = article_num;
4877 + h->env = mutt_read_rfc822_header (f, h, 0, 0);
4879 + unlink (tempfile);
4881 + if (h->env->xref != NULL)
4882 + nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
4883 + else if (h->article_num == 0 && msgid)
4885 + snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
4886 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
4887 + h->article_num = atoi (buf + 4);
4893 +static int parse_description (char *line, void *n)
4895 +#define news ((NNTP_SERVER *) n)
4896 + register char *d = line;
4901 + while (*d && *d != '\t' && *d != ' ') d++;
4904 + while (*d && (*d == '\t' || *d == ' ')) d++;
4905 + dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
4906 + if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
4907 + mutt_strcmp (d, data->desc))
4909 + FREE (&data->desc);
4910 + data->desc = safe_strdup (d);
4916 +static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
4920 + if (!option (OPTLOADDESC) || !data || !data->nserv)
4923 + /* Get newsgroup description, if we can */
4924 + if (data->nserv->hasXGTITLE)
4925 + snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
4927 + snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
4928 + if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
4931 + nntp_error ("nntp_get_desc()", buf);
4937 + * XOVER returns a tab separated list of:
4938 + * id|subject|from|date|Msgid|references|bytes|lines|xref
4940 + * This has to duplicate some of the functionality of
4941 + * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
4942 + * a limited number of headers which are "parsed" by placement in the list)
4944 +static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
4946 + NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
4950 + hdr->env = mutt_new_envelope();
4951 + hdr->env->newsgroups = safe_strdup (nntp_data->group);
4952 + hdr->content = mutt_new_body();
4953 + hdr->content->type = TYPETEXT;
4954 + hdr->content->subtype = safe_strdup ("plain");
4955 + hdr->content->encoding = ENC7BIT;
4956 + hdr->content->disposition = DISPINLINE;
4957 + hdr->content->length = -1;
4960 + for (x = 0; !done && x < 9; x++)
4962 + /* if from file, need to skip newline character */
4963 + while (*p && *p != '\n' && *p != '\t') p++;
4971 + hdr->article_num = atoi (b);
4972 + nntp_get_status (ctx, hdr, NULL, hdr->article_num);
4975 + hdr->env->subject = safe_strdup (b);
4976 + /* Now we need to do the things which would normally be done in
4977 + * mutt_read_rfc822_header() */
4978 + if (hdr->env->subject)
4980 + regmatch_t pmatch[1];
4982 + rfc2047_decode (&hdr->env->subject);
4984 + if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
4985 + hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
4987 + hdr->env->real_subj = hdr->env->subject;
4991 + rfc822_free_address (&hdr->env->from);
4992 + hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
4993 + rfc2047_decode_adrlist (hdr->env->from);
4996 + hdr->date_sent = mutt_parse_date (b, hdr);
4997 + hdr->received = hdr->date_sent;
5000 + FREE (&hdr->env->message_id);
5001 + hdr->env->message_id = safe_strdup (b);
5004 + mutt_free_list (&hdr->env->references);
5005 + hdr->env->references = mutt_parse_references (b, 0);
5008 + hdr->content->length = atoi (b);
5011 + hdr->lines = atoi (b);
5015 + FREE (&hdr->env->xref);
5016 + b = b + 6; /* skips the "Xref: " */
5017 + hdr->env->xref = safe_strdup (b);
5018 + nntp_parse_xref (ctx, nntp_data->group, b, hdr);
5030 + unsigned int base;
5031 + unsigned int first;
5032 + unsigned int last;
5033 + unsigned short *messages;
5037 +#define fc ((FETCH_CONTEXT *) c)
5038 +static int nntp_fetch_numbers (char *line, void *c)
5044 + num = atoi (line);
5045 + if (num < fc->base || num > fc->last)
5047 + fc->messages[num - fc->base] = 1;
5051 +static int add_xover_line (char *line, void *c)
5053 + unsigned int num, total;
5054 + CONTEXT *ctx = fc->ctx;
5055 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5060 + if (ctx->msgcount >= ctx->hdrmax)
5061 + mx_alloc_memory (ctx);
5062 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5063 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5065 + nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5066 + num = ctx->hdrs[ctx->msgcount]->article_num;
5068 + if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5071 + if (num > data->lastLoaded)
5072 + data->lastLoaded = num;
5073 + num = num - fc->first + 1;
5074 + total = fc->last - fc->first + 1;
5075 + if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5076 + mutt_message ("%s %d/%d", fc->msg, num, total);
5079 + mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5085 +static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5086 + unsigned int last)
5088 + char buf[HUGE_STRING];
5089 + char *msg = _("Fetching message headers...");
5090 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5094 + unsigned int current;
5098 + /* if empty group or nothing to do */
5099 + if (!last || first > last)
5102 + /* fetch list of articles */
5106 + fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5107 + if (nntp_data->nserv->hasLISTGROUP)
5109 + mutt_message _("Fetching list of articles...");
5110 + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5111 + if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5113 + mutt_error (_("LISTGROUP command failed: %s"), buf);
5115 + nntp_error ("nntp_fetch_headers()", buf);
5117 + FREE (&fc.messages);
5123 + for (num = 0; num < last - first + 1; num++)
5124 + fc.messages[num] = 1;
5127 + /* CACHE: must be loaded xover cache here */
5128 + num = nntp_data->lastCached - first + 1;
5129 + if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5131 + nntp_cache_expand (buf, nntp_data->cache);
5132 + mutt_message _("Fetching headers from cache...");
5133 + if ((f = safe_fopen (buf, "r")))
5137 + /* counting number of lines */
5138 + while (fgets (buf, sizeof (buf), f) != NULL)
5141 + while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5143 + oldmsgcount = ctx->msgcount;
5145 + fc.last = first + num - 1;
5147 + while (fgets (buf, sizeof (buf), f) != NULL)
5148 + add_xover_line (buf, &fc);
5150 + nntp_data->lastLoaded = fc.last;
5151 + first = fc.last + 1;
5152 + if (ctx->msgcount > oldmsgcount)
5153 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5156 + nntp_delete_cache (nntp_data);
5158 + num = last - first + 1;
5161 + FREE (&fc.messages);
5166 + * Without XOVER, we have to fetch each article header and parse
5167 + * it. With XOVER, we ask for all of them
5169 + mutt_message (msg);
5170 + if (nntp_data->nserv->hasXOVER)
5172 + oldmsgcount = ctx->msgcount;
5176 + snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5177 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5178 + if (ctx->msgcount > oldmsgcount)
5179 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5182 + mutt_error (_("XOVER command failed: %s"), buf);
5184 + nntp_error ("nntp_fetch_headers()", buf);
5186 + FREE (&fc.messages);
5192 + for (current = first; current <= last; current++)
5196 + ret = current - first + 1;
5197 + mutt_message ("%s %d/%d", msg, ret, num);
5199 + if (!fc.messages[current - fc.base])
5202 + if (ctx->msgcount >= ctx->hdrmax)
5203 + mx_alloc_memory (ctx);
5204 + h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5205 + h->index = ctx->msgcount;
5207 + ret = nntp_read_header (ctx, NULL, current);
5208 + if (ret == 0) /* Got article. Fetch next header */
5210 + nntp_get_status (ctx, h, NULL, h->article_num);
5212 + mx_update_context (ctx, 1);
5215 + mutt_free_header (&h); /* skip it */
5218 + FREE (&fc.messages);
5222 + if (current > nntp_data->lastLoaded)
5223 + nntp_data->lastLoaded = current;
5225 + FREE (&fc.messages);
5226 + nntp_data->lastLoaded = last;
5227 + mutt_clear_error ();
5232 + * currently, nntp "mailbox" is "newsgroup"
5234 +int nntp_open_mailbox (CONTEXT *ctx)
5236 + NNTP_DATA *nntp_data;
5237 + NNTP_SERVER *serv;
5238 + char buf[HUGE_STRING];
5239 + char server[LONG_STRING];
5241 + unsigned int first;
5244 + if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5246 + mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5252 + nntp_expand_path (server, sizeof (server), &acct);
5253 + if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5256 + CurrentNewsSrv = serv;
5258 + /* create NNTP-specific state struct if nof found in list */
5259 + if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5261 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5262 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5263 + strcpy (nntp_data->group, buf);
5264 + hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5265 + nntp_add_to_list (serv, nntp_data);
5267 + ctx->data = nntp_data;
5268 + nntp_data->nserv = serv;
5270 + mutt_message (_("Selecting %s..."), nntp_data->group);
5272 + if (!nntp_data->desc)
5274 + nntp_get_desc (nntp_data, nntp_data->group, NULL);
5275 + if (nntp_data->desc)
5276 + nntp_save_cache_index (serv);
5280 + if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5283 + nntp_error ("nntp_open_mailbox()", buf);
5288 + if (mutt_strncmp ("211", buf, 3))
5290 + LIST *l = serv->list;
5292 + /* GROUP command failed */
5293 + if (!mutt_strncmp ("411", buf, 3))
5295 + mutt_error (_("Newsgroup %s not found on server %s"),
5296 + nntp_data->group, serv->conn->account.host);
5298 + /* CACHE: delete cache and line from .index */
5299 + nntp_delete_cache (nntp_data);
5300 + hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5301 + while (l && l->data != (void *) nntp_data) l = l->next;
5311 + sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5312 + &nntp_data->lastMessage, buf);
5314 + nntp_data->deleted = 0;
5316 + time (&serv->check_time);
5319 + * Check for max adding context. If it is greater than $nntp_context,
5320 + * strip off extra articles
5322 + first = nntp_data->firstMessage;
5323 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5324 + first = nntp_data->lastMessage - NntpContext + 1;
5326 + nntp_data->lastLoaded = first - 1;
5327 + return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5330 +int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5332 + char buf[LONG_STRING];
5333 + char path[_POSIX_PATH_MAX];
5334 + NNTP_CACHE *cache;
5335 + char *m = _("Fetching message...");
5338 + /* see if we already have the message in our cache */
5339 + cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5341 + /* if everything is fine, assign msg->fp and return */
5342 + if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5343 + (msg->fp = fopen (cache->path, "r")))
5346 + /* clear the previous entry */
5347 + unlink (cache->path);
5348 + free (cache->path);
5352 + cache->index = ctx->hdrs[msgno]->index;
5353 + mutt_mktemp (path);
5354 + cache->path = safe_strdup (path);
5355 + if (!(msg->fp = safe_fopen (path, "w+")))
5357 + FREE (&cache->path);
5361 + if (ctx->hdrs[msgno]->article_num == 0)
5362 + snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5363 + ctx->hdrs[msgno]->env->message_id);
5365 + snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5366 + ctx->hdrs[msgno]->article_num);
5368 + ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5369 + msg->fp, ctx->tagged);
5372 + mutt_error (_("Article %d not found on server"),
5373 + ctx->hdrs[msgno]->article_num);
5374 + dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5381 + FREE (&cache->path);
5385 + mutt_free_envelope (&ctx->hdrs[msgno]->env);
5386 + ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5387 + /* fix content length */
5388 + fseek(msg->fp, 0, SEEK_END);
5389 + ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5390 + ctx->hdrs[msgno]->content->offset;
5392 + /* this is called in mutt before the open which fetches the message,
5393 + * which is probably wrong, but we just call it again here to handle
5394 + * the problem instead of fixing it.
5396 + mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5398 + /* These would normally be updated in mx_update_context(), but the
5399 + * full headers aren't parsed with XOVER, so the information wasn't
5402 +#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5403 + ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5404 +#endif /* HAVE_PGP || HAVE_SMIME */
5406 + mutt_clear_error();
5413 +int nntp_post (const char *msg) {
5414 + char buf[LONG_STRING];
5417 + NNTP_DATA *nntp_data;
5419 + if (Context && Context->magic == M_NNTP)
5420 + nntp_data = (NNTP_DATA *)Context->data;
5423 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5424 + !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5426 + mutt_error (_("Can't post article. No connection to news server."));
5429 + nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5432 + if (!(f = safe_fopen (msg, "r")))
5434 + mutt_error (_("Can't post article. Unable to open %s"), msg);
5438 + strfcpy (buf, "POST\r\n", sizeof (buf));
5439 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5441 + mutt_error (_("Can't post article. Connection to %s lost."),
5442 + nntp_data->nserv->conn->account.host);
5445 + if (buf[0] != '3')
5447 + mutt_error (_("Can't post article: %s"), buf);
5453 + while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5455 + len = strlen (buf);
5456 + if (buf[len - 1] == '\n')
5458 + buf[len - 1] = '\r';
5463 + if (buf[1] == '.')
5464 + mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5466 + mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5470 + if (buf[strlen (buf) - 1] != '\n')
5471 + mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5472 + mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5473 + if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5475 + mutt_error (_("Can't post article. Connection to %s lost."),
5476 + nntp_data->nserv->conn->account.host);
5479 + if (buf[0] != '2')
5481 + mutt_error (_("Can't post article: %s"), buf);
5488 +/* nntp_logout_all: close all open connections. */
5489 +void nntp_logout_all (void)
5491 + char buf[LONG_STRING];
5494 + conn = mutt_socket_head ();
5498 + CONNECTION *next = conn->next;
5500 + if (conn->account.type == M_ACCT_TYPE_NNTP)
5502 + mutt_message (_("Closing connection to %s..."), conn->account.host);
5503 + mutt_socket_write (conn, "QUIT\r\n");
5504 + mutt_socket_readln (buf, sizeof (buf), conn);
5505 + mutt_clear_error ();
5506 + mutt_socket_close (conn);
5507 + mutt_socket_free (conn);
5514 +static void nntp_free_acache (NNTP_DATA *data)
5518 + for (i = 0; i < NNTP_CACHE_LEN; i++)
5520 + if (data->acache[i].path)
5522 + unlink (data->acache[i].path);
5523 + FREE (&data->acache[i].path);
5528 +void nntp_delete_data (void *p)
5530 + NNTP_DATA *data = (NNTP_DATA *)p;
5534 + FREE (&data->entries);
5535 + FREE (&data->desc);
5536 + FREE (&data->cache);
5537 + nntp_free_acache (data);
5541 +int nntp_sync_mailbox (CONTEXT *ctx)
5543 + NNTP_DATA *data = ctx->data;
5545 + /* CACHE: update cache and .index files */
5546 + if ((option (OPTSAVEUNSUB) || data->subscribed))
5547 + nntp_save_cache_group (ctx);
5548 + nntp_free_acache (data);
5550 + data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
5554 +void nntp_fastclose_mailbox (CONTEXT *ctx)
5556 + NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
5560 + nntp_free_acache (data);
5561 + if (!data->nserv || !data->nserv->newsgroups || !data->group)
5563 + nntp_save_cache_index (data->nserv);
5564 + if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
5566 + nntp_delete_data (data);
5569 +/* commit changes and terminate connection */
5570 +int nntp_close_mailbox (CONTEXT *ctx)
5574 + mutt_message _("Quitting newsgroup...");
5577 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
5580 + if (data->nserv && data->nserv->conn && ctx->unread)
5582 + ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
5584 + mutt_newsgroup_catchup (data->nserv, data->group);
5589 + nntp_sync_mailbox (ctx);
5590 + if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
5592 + NNTP_SERVER *news;
5594 + news = ((NNTP_DATA *)ctx->data)->nserv;
5595 + newsrc_gen_entries (ctx);
5596 + ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
5597 + mutt_newsrc_update (news);
5599 + mutt_clear_error();
5603 +/* use the GROUP command to poll for new mail */
5604 +static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
5606 + char buf[LONG_STRING];
5609 + if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
5613 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5616 + nntp_error ("nntp_check_mailbox()", buf);
5620 + if (mutt_strncmp ("211", buf, 3))
5623 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5626 + nntp_error ("nntp_check_mailbox()", buf);
5631 + if (!mutt_strncmp ("211", buf, 3))
5636 + sscanf (buf + 4, "%d %d %d", &count, &first, &last);
5637 + nntp_data->firstMessage = first;
5638 + nntp_data->lastMessage = last;
5639 + if (ctx && last > nntp_data->lastLoaded)
5641 + nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
5642 + time (&nntp_data->nserv->check_time);
5645 + if (!last || (!nntp_data->rc && !nntp_data->lastCached))
5646 + nntp_data->unread = count;
5648 + mutt_newsgroup_stat (nntp_data);
5649 + /* active was renumbered? */
5650 + if (last < nntp_data->lastLoaded)
5652 + if (!nntp_data->max)
5654 + nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
5655 + nntp_data->max = 5;
5657 + nntp_data->lastCached = 0;
5658 + nntp_data->num = 1;
5659 + nntp_data->entries[0].first = 1;
5660 + nntp_data->entries[0].last = 0;
5664 + time (&nntp_data->nserv->check_time);
5668 +int nntp_check_mailbox (CONTEXT *ctx)
5670 + return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
5673 +static int add_group (char *buf, void *serv)
5675 +#define s ((NNTP_SERVER *) serv)
5676 + char group[LONG_STRING], mod, desc[HUGE_STRING];
5678 + NNTP_DATA *nntp_data;
5681 + _checked = n; /* _checked have N, where N = number of groups */
5682 + if (!buf) /* at EOF must be zerouth */
5689 + sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
5692 + if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
5695 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
5696 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5697 + strcpy (nntp_data->group, group);
5698 + nntp_data->nserv = s;
5699 + if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
5700 + s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2);
5701 + hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
5702 + nntp_add_to_list (s, nntp_data);
5704 + nntp_data->deleted = 0;
5705 + nntp_data->firstMessage = first;
5706 + nntp_data->lastMessage = last;
5708 + nntp_data->allowed = 1;
5710 + nntp_data->allowed = 0;
5711 + if (nntp_data->desc)
5712 + FREE (&nntp_data->desc);
5714 + nntp_data->desc = safe_strdup (desc);
5715 + if (nntp_data->rc || nntp_data->lastCached)
5716 + mutt_newsgroup_stat (nntp_data);
5717 + else if (nntp_data->lastMessage &&
5718 + nntp_data->firstMessage <= nntp_data->lastMessage)
5719 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
5721 + nntp_data->unread = 0;
5727 +int nntp_check_newgroups (NNTP_SERVER *serv, int force)
5729 + char buf[LONG_STRING];
5730 + NNTP_DATA nntp_data;
5736 + if (!serv || !serv->newgroups_time)
5739 + if (nntp_open_connection (serv) < 0)
5742 + /* check subscribed groups for new news */
5743 + if (option (OPTSHOWNEWNEWS))
5745 + mutt_message _("Checking for new messages...");
5746 + for (l = serv->list; l; l = l->next)
5748 + serv->check_time = 0; /* really check! */
5749 + if (l->data && ((NNTP_DATA *) l->data)->subscribed)
5750 + _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
5756 + mutt_message _("Checking for new newsgroups...");
5757 + now = serv->newgroups_time;
5758 + time (&serv->newgroups_time);
5759 + t = gmtime (&now);
5760 + snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
5761 + (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
5763 + nntp_data.nserv = serv;
5764 + if (Context && Context->magic == M_NNTP)
5765 + nntp_data.group = ((NNTP_DATA *)Context->data)->group;
5767 + nntp_data.group = NULL;
5769 + if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
5770 + add_group, serv, 0) != 0)
5773 + nntp_error ("nntp_check_newgroups()", buf);
5778 + mutt_message _("Loading descriptions...");
5780 + emp.next = l->next;
5782 + emp.next = serv->list;
5787 + ((NNTP_DATA *) l->data)->new = 1;
5788 + nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
5791 + nntp_save_cache_index (serv);
5792 + mutt_clear_error ();
5796 +/* Load list of all newsgroups from cache ALL */
5797 +int nntp_get_cache_all (NNTP_SERVER *serv)
5799 + char buf[HUGE_STRING];
5802 + nntp_cache_expand (buf, serv->cache);
5803 + if ((f = safe_fopen (buf, "r")))
5807 + while (fgets (buf, sizeof(buf), f) != NULL)
5809 + if (ReadInc && (i % ReadInc == 0))
5810 + mutt_message (_("Loading list from cache... %d"), i);
5811 + add_group (buf, serv);
5814 + add_group (NULL, NULL);
5816 + mutt_clear_error ();
5821 + FREE (&serv->cache);
5826 +/* Load list of all newsgroups from active */
5827 +int nntp_get_active (NNTP_SERVER *serv)
5829 + char msg[SHORT_STRING];
5830 + NNTP_DATA nntp_data;
5833 + if (nntp_open_connection (serv) < 0)
5836 + snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
5837 + serv->conn->account.host);
5838 + mutt_message (msg);
5839 + time (&serv->newgroups_time);
5840 + nntp_data.nserv = serv;
5841 + nntp_data.group = NULL;
5843 + if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
5846 + nntp_error ("nntp_get_active()", "LIST\r\n");
5851 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5852 + mutt_message (msg);
5853 + nntp_get_desc (&nntp_data, "*", msg);
5855 + for (tmp = serv->list; tmp; tmp = tmp->next)
5857 + NNTP_DATA *data = (NNTP_DATA *)tmp->data;
5859 + if (data && data->deleted && !data->rc)
5861 + nntp_delete_cache (data);
5862 + hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
5866 + nntp_save_cache_index (serv);
5868 + mutt_clear_error ();
5873 + * returns -1 if error ocurred while retrieving header,
5874 + * number of articles which ones exist in context on success.
5876 +int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
5880 + /* if msgid is already in context, don't reload them */
5881 + if (hash_find (ctx->id_hash, msgid))
5883 + if (ctx->msgcount == ctx->hdrmax)
5884 + mx_alloc_memory (ctx);
5885 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5886 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5888 + mutt_message (_("Fetching %s from server..."), msgid);
5889 + ret = nntp_read_header (ctx, msgid, 0);
5890 + /* since nntp_read_header() may set read flag, we must reset it */
5891 + ctx->hdrs[ctx->msgcount]->read = 0;
5893 + mutt_free_header (&ctx->hdrs[ctx->msgcount]);
5897 + mx_update_context (ctx, 1);
5908 + unsigned int *child;
5911 +static int check_children (char *s, void *c)
5913 +#define cc ((CHILD_CONTEXT *) c)
5914 + unsigned int i, n;
5916 + if (!s || (n = atoi (s)) == 0)
5918 + for (i = 0; i < cc->ctx->msgcount; i++)
5919 + if (cc->ctx->hdrs[i]->article_num == n)
5921 + if (cc->num >= cc->max)
5922 + safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
5923 + cc->child[cc->num++] = n;
5929 +int nntp_check_children (CONTEXT *ctx, const char *msgid)
5931 + NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
5933 + int i, ret = 0, tmp = 0;
5936 + if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
5937 + !nntp_data->nserv->conn->account.host)
5939 + if (nntp_data->firstMessage > nntp_data->lastLoaded)
5941 + if (!nntp_data->nserv->hasXPAT)
5943 + mutt_error (_("Server %s does not support this operation!"),
5944 + nntp_data->nserv->conn->account.host);
5948 + snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
5949 + nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
5954 + cc.child = safe_malloc (sizeof (unsigned int) * 25);
5955 + if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
5960 + /* dont try to read the xover cache. check_children() already
5961 + * made sure that we dont have the article, so we need to visit
5962 + * the server. Reading the cache at this point is also bad
5963 + * because it would duplicate messages */
5964 + if (option (OPTNEWSCACHE))
5967 + unset_option (OPTNEWSCACHE);
5969 + for (i = 0; i < cc.num; i++)
5971 + if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
5973 + if (ctx->msgcount &&
5974 + ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
5975 + ctx->hdrs[ctx->msgcount - 1]->read = 0;
5978 + set_option (OPTNEWSCACHE);
5982 diff -udprP mutt-1.5.13.orig/nntp.h mutt-1.5.13/nntp.h
5983 --- mutt-1.5.13.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
5984 +++ mutt-1.5.13/nntp.h 2006-08-15 13:04:56.000000000 +0300
5987 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
5988 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
5989 + * Copyright (C) 2000-2004 Vsevolod Volkov <vvv@mutt.org.ua>
5991 + * This program is free software; you can redistribute it and/or modify
5992 + * it under the terms of the GNU General Public License as published by
5993 + * the Free Software Foundation; either version 2 of the License, or
5994 + * (at your option) any later version.
5996 + * This program is distributed in the hope that it will be useful,
5997 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5998 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5999 + * GNU General Public License for more details.
6001 + * You should have received a copy of the GNU General Public License
6002 + * along with this program; if not, write to the Free Software
6003 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6009 +#include "mutt_socket.h"
6010 +#include "mailbox.h"
6014 +#define NNTP_PORT 119
6015 +#define NNTP_SSL_PORT 563
6017 +/* number of entries in the hash table */
6018 +#define NNTP_CACHE_LEN 10
6035 + unsigned int hasXPAT : 1;
6036 + unsigned int hasXGTITLE : 1;
6037 + unsigned int hasXOVER : 1;
6038 + unsigned int hasLISTGROUP : 1;
6039 + unsigned int status : 3;
6045 + time_t newgroups_time;
6046 + time_t check_time;
6048 + LIST *list; /* list of newsgroups */
6049 + LIST *tail; /* last entry of list */
6055 + unsigned int index;
6061 + NEWSRC_ENTRY *entries;
6062 + unsigned int num; /* number of used entries */
6063 + unsigned int max; /* number of allocated entries */
6064 + unsigned int unread;
6065 + unsigned int firstMessage;
6066 + unsigned int lastMessage;
6067 + unsigned int lastLoaded;
6068 + unsigned int lastCached;
6069 + unsigned int subscribed : 1;
6070 + unsigned int rc : 1;
6071 + unsigned int new : 1;
6072 + unsigned int allowed : 1;
6073 + unsigned int deleted : 1;
6077 + NNTP_SERVER *nserv;
6078 + NNTP_CACHE acache[NNTP_CACHE_LEN];
6081 +/* internal functions */
6082 +int nntp_get_active (NNTP_SERVER *);
6083 +int nntp_get_cache_all (NNTP_SERVER *);
6084 +int nntp_save_cache_index (NNTP_SERVER *);
6085 +int nntp_check_newgroups (NNTP_SERVER *, int);
6086 +int nntp_save_cache_group (CONTEXT *);
6087 +int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6088 +void newsrc_gen_entries (CONTEXT *);
6089 +void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6090 +void mutt_newsgroup_stat (NNTP_DATA *);
6091 +void nntp_delete_cache (NNTP_DATA *);
6092 +void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6093 +void nntp_cache_expand (char *, const char *);
6094 +void nntp_delete_data (void *);
6096 +/* exposed interface */
6097 +NNTP_SERVER *mutt_select_newsserver (char *);
6098 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6099 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6100 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6101 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6102 +void nntp_clear_cacheindex (NNTP_SERVER *);
6103 +int mutt_newsrc_update (NNTP_SERVER *);
6104 +int nntp_open_mailbox (CONTEXT *);
6105 +int nntp_sync_mailbox (CONTEXT *);
6106 +int nntp_check_mailbox (CONTEXT *);
6107 +int nntp_close_mailbox (CONTEXT *);
6108 +void nntp_fastclose_mailbox (CONTEXT *);
6109 +int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6110 +int nntp_post (const char *);
6111 +int nntp_check_msgid (CONTEXT *, const char *);
6112 +int nntp_check_children (CONTEXT *, const char *);
6113 +void nntp_buffy (char *);
6114 +void nntp_expand_path (char *, size_t, ACCOUNT *);
6115 +void nntp_logout_all ();
6116 +const char *nntp_format_str (char *, size_t, char, const char *, const char *,
6117 + const char *, const char *, unsigned long, format_flag);
6119 +NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6121 +#endif /* _NNTP_H_ */
6122 diff -udprP mutt-1.5.13.orig/pager.c mutt-1.5.13/pager.c
6123 --- mutt-1.5.13.orig/pager.c 2006-05-18 21:44:29.000000000 +0300
6124 +++ mutt-1.5.13/pager.c 2006-08-15 13:04:56.000000000 +0300
6125 @@ -1059,6 +1059,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
6135 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6136 int flags, ansi_attr *pa, int cnt,
6137 @@ -1497,6 +1502,16 @@ static struct mapping_t PagerHelpExtra[]
6142 +static struct mapping_t PagerNewsHelpExtra[] = {
6143 + { N_("Post"), OP_POST },
6144 + { N_("Followup"), OP_FOLLOWUP },
6145 + { N_("Del"), OP_DELETE },
6146 + { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6153 /* This pager is actually not so simple as it once was. It now operates in
6154 @@ -1538,6 +1553,10 @@ mutt_pager (const char *banner, const ch
6155 int old_PagerIndexLines; /* some people want to resize it
6156 * while inside the pager... */
6159 + char *followup_to;
6162 if (!(flags & M_SHOWCOLOR))
6163 flags |= M_SHOWFLAT;
6165 @@ -1577,7 +1596,11 @@ mutt_pager (const char *banner, const ch
6166 if (IsHeader (extra))
6168 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6169 - mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6170 + mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6172 + (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6175 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6178 @@ -2418,6 +2441,15 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
6179 CHECK_IMAP_ACL(IMAP_ACL_WRITE);
6183 + if (Context->magic == M_NNTP)
6186 + mutt_error _("Can't change 'important' flag on NNTP server.");
6191 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6192 redraw = REDRAW_STATUS | REDRAW_INDEX;
6193 if (option (OPTRESOLVE))
6194 @@ -2451,6 +2483,60 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE);
6195 redraw = REDRAW_FULL;
6200 + CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6202 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6203 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6204 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6206 + ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6207 + redraw = REDRAW_FULL;
6210 + case OP_FORWARD_TO_GROUP:
6211 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6213 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6214 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6215 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6217 + if (IsMsgAttach (extra))
6218 + mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6219 + extra->idxlen, extra->bdy, SENDNEWS);
6221 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6222 + redraw = REDRAW_FULL;
6226 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6229 + if (IsMsgAttach (extra))
6230 + followup_to = extra->bdy->hdr->env->followup_to;
6232 + followup_to = extra->hdr->env->followup_to;
6234 + if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6235 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6237 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6238 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6239 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6241 + if (IsMsgAttach (extra))
6242 + mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6243 + extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6245 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6246 + extra->ctx, extra->hdr);
6247 + redraw = REDRAW_FULL;
6253 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6255 @@ -2497,7 +2583,7 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE);
6257 if (IsMsgAttach (extra))
6258 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6259 - extra->idxlen, extra->bdy);
6260 + extra->idxlen, extra->bdy, 0);
6262 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6263 redraw = REDRAW_FULL;
6264 diff -udprP mutt-1.5.13.orig/parse.c mutt-1.5.13/parse.c
6265 --- mutt-1.5.13.orig/parse.c 2006-04-28 22:48:32.000000000 +0300
6266 +++ mutt-1.5.13/parse.c 2006-08-15 13:04:56.000000000 +0300
6267 @@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
6271 -static LIST *mutt_parse_references (char *s, int in_reply_to)
6272 +LIST *mutt_parse_references (char *s, int in_reply_to)
6274 LIST *t, *lst = NULL;
6276 @@ -1052,6 +1052,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6277 e->from = rfc822_parse_adrlist (e->from, p);
6281 + else if (!mutt_strcasecmp (line+1, "ollowup-to"))
6283 + if (!e->followup_to)
6285 + mutt_remove_trailing_ws (p);
6286 + e->followup_to = safe_strdup (mutt_skip_whitespace (p));
6294 @@ -1136,6 +1147,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6300 + if (!mutt_strcasecmp (line + 1, "ewsgroups"))
6302 + FREE (&e->newsgroups);
6303 + mutt_remove_trailing_ws (p);
6304 + e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
6311 + /* field `Organization:' saves only for pager! */
6312 + if (!mutt_strcasecmp (line + 1, "rganization"))
6314 + if (!e->organization && mutt_strcasecmp (p, "unknown"))
6315 + e->organization = safe_strdup (p);
6320 if (!ascii_strcasecmp (line + 1, "eferences"))
6322 @@ -1244,6 +1276,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6323 e->x_label = safe_strdup(p);
6327 + else if (!mutt_strcasecmp (line + 1, "-comment-to"))
6329 + if (!e->x_comment_to)
6330 + e->x_comment_to = safe_strdup (p);
6333 + else if (!mutt_strcasecmp (line + 1, "ref"))
6336 + e->xref = safe_strdup (p);
6343 diff -udprP mutt-1.5.13.orig/pattern.c mutt-1.5.13/pattern.c
6344 --- mutt-1.5.13.orig/pattern.c 2006-08-11 12:32:58.000000000 +0300
6345 +++ mutt-1.5.13/pattern.c 2006-08-15 13:04:56.000000000 +0300
6346 @@ -90,6 +90,9 @@ Flags[] =
6347 { 'U', M_UNREAD, 0, NULL },
6348 { 'v', M_COLLAPSED, 0, NULL },
6349 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6351 + { 'w', M_NEWSGROUPS, 0, eat_regexp },
6353 { 'x', M_REFERENCE, 0, eat_regexp },
6354 { 'X', M_MIMEATTACH, 0, eat_range },
6355 { 'y', M_XLABEL, 0, eat_regexp },
6356 @@ -1197,6 +1200,10 @@ mutt_pattern_exec (struct pattern_t *pat
6358 case M_UNREFERENCED:
6359 return (pat->not ^ (h->thread && !h->thread->child));
6361 + case M_NEWSGROUPS:
6362 + return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6365 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6367 @@ -1264,6 +1271,7 @@ int mutt_pattern_func (int op, char *pro
6370 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6371 + if (prompt || op != M_LIMIT)
6372 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6375 diff -udprP mutt-1.5.13.orig/po/POTFILES.in mutt-1.5.13/po/POTFILES.in
6376 --- mutt-1.5.13.orig/po/POTFILES.in 2005-08-03 12:17:47.000000000 +0300
6377 +++ mutt-1.5.13/po/POTFILES.in 2006-08-15 13:04:56.000000000 +0300
6378 @@ -45,6 +45,8 @@ mutt_ssl_gnutls.c
6387 diff -udprP mutt-1.5.13.orig/postpone.c mutt-1.5.13/postpone.c
6388 --- mutt-1.5.13.orig/postpone.c 2006-04-20 19:46:35.000000000 +0300
6389 +++ mutt-1.5.13/postpone.c 2006-08-15 13:04:56.000000000 +0300
6390 @@ -126,15 +126,26 @@ int mutt_num_postponed (int force)
6392 if (LastModify < st.st_mtime)
6395 + int optnews = option (OPTNEWS);
6397 LastModify = st.st_mtime;
6399 if (access (Postponed, R_OK | F_OK) != 0)
6400 return (PostCount = 0);
6403 + unset_option (OPTNEWS);
6405 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6408 PostCount = ctx.msgcount;
6409 mx_fastclose_mailbox (&ctx);
6412 + set_option (OPTNEWS);
6417 diff -udprP mutt-1.5.13.orig/protos.h mutt-1.5.13/protos.h
6418 --- mutt-1.5.13.orig/protos.h 2006-07-12 02:32:28.000000000 +0300
6419 +++ mutt-1.5.13/protos.h 2006-08-15 13:04:56.000000000 +0300
6420 @@ -110,6 +110,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
6421 HASH *mutt_make_subj_hash (CONTEXT *);
6423 LIST *mutt_make_references(ENVELOPE *e);
6424 +LIST *mutt_parse_references (char *, int);
6426 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6427 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
6428 @@ -251,6 +252,7 @@ void mutt_unblock_signals_system (int);
6429 void mutt_update_encoding (BODY *a);
6430 void mutt_version (void);
6431 void mutt_view_attachments (HEADER *);
6432 +void mutt_write_references (LIST *, FILE *);
6433 void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen, int display);
6434 void mutt_set_virtual (CONTEXT *);
6436 diff -udprP mutt-1.5.13.orig/recvattach.c mutt-1.5.13/recvattach.c
6437 --- mutt-1.5.13.orig/recvattach.c 2006-04-18 18:25:33.000000000 +0300
6438 +++ mutt-1.5.13/recvattach.c 2006-08-15 13:04:56.000000000 +0300
6439 @@ -1087,6 +1087,15 @@ void mutt_view_attachments (HEADER *hdr)
6444 + if (Context->magic == M_NNTP)
6447 + mutt_error _("Can't delete attachment from newsserver.");
6452 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6455 @@ -1178,10 +1187,33 @@ void mutt_view_attachments (HEADER *hdr)
6456 case OP_FORWARD_MESSAGE:
6458 mutt_attach_forward (fp, hdr, idx, idxlen,
6459 - menu->tagprefix ? NULL : idx[menu->current]->content);
6460 + menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6461 menu->redraw = REDRAW_FULL;
6465 + case OP_FORWARD_TO_GROUP:
6467 + mutt_attach_forward (fp, hdr, idx, idxlen,
6468 + menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6469 + menu->redraw = REDRAW_FULL;
6475 + if (!idx[menu->current]->content->hdr->env->followup_to ||
6476 + mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6477 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6479 + mutt_attach_reply (fp, hdr, idx, idxlen,
6480 + menu->tagprefix ? NULL : idx[menu->current]->content,
6481 + SENDNEWS|SENDREPLY);
6482 + menu->redraw = REDRAW_FULL;
6488 case OP_GROUP_REPLY:
6490 diff -udprP mutt-1.5.13.orig/recvcmd.c mutt-1.5.13/recvcmd.c
6491 --- mutt-1.5.13.orig/recvcmd.c 2005-09-18 11:22:22.000000000 +0300
6492 +++ mutt-1.5.13/recvcmd.c 2006-08-15 13:04:56.000000000 +0300
6493 @@ -377,7 +377,7 @@ static BODY ** copy_problematic_attachme
6494 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6495 ATTACHPTR ** idx, short idxlen,
6498 + short nattach, int flags)
6501 short mime_fwd_all = 0;
6502 @@ -523,7 +523,7 @@ _("Can't decode all tagged attachments.
6505 /* now that we have the template, send it. */
6506 - ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6507 + ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6511 @@ -550,7 +550,7 @@ _("Can't decode all tagged attachments.
6514 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6515 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6516 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6518 HEADER *curhdr = NULL;
6520 @@ -655,23 +655,23 @@ static void attach_forward_msgs (FILE *
6522 mutt_free_header (&tmphdr);
6524 - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6525 + ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
6530 void mutt_attach_forward (FILE * fp, HEADER * hdr,
6531 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6532 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6537 if (check_all_msg (idx, idxlen, cur, 0) == 0)
6538 - attach_forward_msgs (fp, hdr, idx, idxlen, cur);
6539 + attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
6542 nattach = count_tagged (idx, idxlen);
6543 - attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
6544 + attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
6548 @@ -729,28 +729,40 @@ attach_reply_envelope_defaults (ENVELOPE
6554 + if ((flags & SENDNEWS))
6556 - if (mutt_fetch_recips (env, curenv, flags) == -1)
6558 + /* in case followup set Newsgroups: with Followup-To: if it present */
6559 + if (!env->newsgroups && curenv &&
6560 + mutt_strcasecmp (curenv->followup_to, "poster"))
6561 + env->newsgroups = safe_strdup (curenv->followup_to);
6566 - for (i = 0; i < idxlen; i++)
6569 - if (idx[i]->content->tagged
6570 - && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6571 + if (mutt_fetch_recips (env, curenv, flags) == -1)
6576 + for (i = 0; i < idxlen; i++)
6578 + if (idx[i]->content->tagged
6579 + && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6584 + if ((flags & SENDLISTREPLY) && !env->to)
6586 + mutt_error _("No mailing lists found!");
6590 + mutt_fix_reply_recipients (env);
6593 - if ((flags & SENDLISTREPLY) && !env->to)
6595 - mutt_error _("No mailing lists found!");
6599 - mutt_fix_reply_recipients (env);
6600 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
6603 @@ -811,6 +823,13 @@ void mutt_attach_reply (FILE * fp, HEADE
6604 char prefix[SHORT_STRING];
6608 + if (flags & SENDNEWS)
6609 + set_option (OPTNEWSSEND);
6611 + unset_option (OPTNEWSSEND);
6614 if (check_all_msg (idx, idxlen, cur, 0) == -1)
6616 nattach = count_tagged (idx, idxlen);
6617 diff -udprP mutt-1.5.13.orig/rfc1524.c mutt-1.5.13/rfc1524.c
6618 --- mutt-1.5.13.orig/rfc1524.c 2006-05-18 21:44:29.000000000 +0300
6619 +++ mutt-1.5.13/rfc1524.c 2006-08-15 13:04:56.000000000 +0300
6620 @@ -569,13 +569,13 @@ int rfc1524_expand_filename (char *namet
6624 -int mutt_rename_file (char *oldfile, char *newfile)
6625 +int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
6629 if (access (oldfile, F_OK) != 0)
6631 - if (access (newfile, F_OK) == 0)
6632 + if (!overwrite && access (newfile, F_OK) == 0)
6634 if ((ofp = fopen (oldfile,"r")) == NULL)
6636 @@ -590,3 +590,8 @@ int mutt_rename_file (char *oldfile, cha
6637 mutt_unlink (oldfile);
6641 +int mutt_rename_file (char *oldfile, char *newfile)
6643 + return _mutt_rename_file (oldfile, newfile, 0);
6645 diff -udprP mutt-1.5.13.orig/rfc1524.h mutt-1.5.13/rfc1524.h
6646 --- mutt-1.5.13.orig/rfc1524.h 2005-09-18 11:22:22.000000000 +0300
6647 +++ mutt-1.5.13/rfc1524.h 2006-08-15 13:04:56.000000000 +0300
6648 @@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char
6649 int rfc1524_expand_filename (char *, char *, char *, size_t);
6650 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
6651 int mutt_rename_file (char *, char *);
6652 +int _mutt_rename_file (char *, char *, int);
6654 #endif /* _RFC1524_H */
6655 diff -udprP mutt-1.5.13.orig/send.c mutt-1.5.13/send.c
6656 --- mutt-1.5.13.orig/send.c 2006-03-03 12:12:34.000000000 +0200
6657 +++ mutt-1.5.13/send.c 2006-08-15 13:04:56.000000000 +0300
6659 #include <sys/types.h>
6667 #include "remailer.h"
6669 @@ -213,17 +217,51 @@ static int edit_address (ADDRESS **a, /*
6673 -static int edit_envelope (ENVELOPE *en)
6674 +static int edit_envelope (ENVELOPE *en, int flags)
6676 char buf[HUGE_STRING];
6677 LIST *uh = UserHeader;
6679 - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6681 - if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6683 - if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6686 + if (option (OPTNEWSSEND))
6688 + if (en->newsgroups)
6689 + strfcpy (buf, en->newsgroups, sizeof (buf));
6692 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
6694 + FREE (&en->newsgroups);
6695 + en->newsgroups = safe_strdup (buf);
6697 + if (en->followup_to)
6698 + strfcpy (buf, en->followup_to, sizeof (buf));
6701 + if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
6703 + FREE (&en->followup_to);
6704 + en->followup_to = safe_strdup (buf);
6706 + if (en->x_comment_to)
6707 + strfcpy (buf, en->x_comment_to, sizeof (buf));
6710 + if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
6712 + FREE (&en->x_comment_to);
6713 + en->x_comment_to = safe_strdup (buf);
6718 + if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6720 + if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6722 + if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6728 @@ -259,6 +297,14 @@ static int edit_envelope (ENVELOPE *en)
6733 +char *nntp_get_header (const char *s)
6736 + return safe_strdup (s);
6740 static void process_user_recips (ENVELOPE *env)
6742 LIST *uh = UserHeader;
6743 @@ -271,6 +317,14 @@ static void process_user_recips (ENVELOP
6744 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
6745 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
6746 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
6748 + else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
6749 + env->newsgroups = nntp_get_header (uh->data + 11);
6750 + else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
6751 + env->followup_to = nntp_get_header (uh->data + 12);
6752 + else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
6753 + env->x_comment_to = nntp_get_header (uh->data + 13);
6758 @@ -301,6 +355,12 @@ static void process_user_header (ENVELOP
6759 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
6760 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
6761 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
6763 + ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
6764 + ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
6765 + ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
6767 + ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
6768 ascii_strncasecmp ("subject:", uh->data, 8) != 0)
6771 @@ -646,6 +706,10 @@ void mutt_add_to_reference_headers (ENVE
6776 + if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
6777 + env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
6782 @@ -702,6 +766,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
6784 if (flags & SENDREPLY)
6787 + if ((flags & SENDNEWS))
6789 + /* in case followup set Newsgroups: with Followup-To: if it present */
6790 + if (!env->newsgroups && curenv &&
6791 + mutt_strcasecmp (curenv->followup_to, "poster"))
6792 + env->newsgroups = safe_strdup (curenv->followup_to);
6799 @@ -848,7 +922,18 @@ void mutt_set_followup_to (ENVELOPE *e)
6800 * it hasn't already been set
6803 - if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
6804 + if (!option (OPTFOLLOWUPTO))
6807 + if (option (OPTNEWSSEND))
6809 + if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
6810 + e->followup_to = safe_strdup (e->newsgroups);
6815 + if (!e->mail_followup_to)
6817 if (mutt_is_list_cc (0, e->to, e->cc))
6819 @@ -1081,6 +1166,13 @@ ci_send_message (int flags, /* send mod
6824 + if (flags & SENDNEWS)
6825 + set_option (OPTNEWSSEND);
6827 + unset_option (OPTNEWSSEND);
6830 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
6831 mutt_num_postponed (1))
6833 @@ -1111,6 +1203,22 @@ ci_send_message (int flags, /* send mod
6835 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
6839 + * If postponed message is a news article, it have
6840 + * a "Newsgroups:" header line, then set appropriate flag.
6842 + if (msg->env->newsgroups)
6844 + flags |= SENDNEWS;
6845 + set_option (OPTNEWSSEND);
6849 + flags &= ~SENDNEWS;
6850 + unset_option (OPTNEWSSEND);
6855 if (flags & (SENDPOSTPONED|SENDRESEND))
6856 @@ -1215,11 +1323,16 @@ ci_send_message (int flags, /* send mod
6857 /* Expand aliases and remove duplicates/crossrefs */
6858 mutt_fix_reply_recipients (msg->env);
6861 + if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
6862 + msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
6865 if (! (flags & SENDMAILX) &&
6866 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
6867 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
6869 - if (edit_envelope (msg->env) == -1)
6870 + if (edit_envelope (msg->env, flags) == -1)
6874 @@ -1470,6 +1583,11 @@ main_loop:
6879 + if (flags & SENDNEWS)
6880 + mutt_message _("Article not posted.");
6883 mutt_message _("Mail not sent.");
6886 @@ -1502,6 +1620,9 @@ main_loop:
6891 + if (!(flags & SENDNEWS))
6893 if (!msg->env->to && !msg->env->cc && !msg->env->bcc)
6895 if (! (flags & SENDBATCH))
6896 @@ -1534,6 +1655,19 @@ main_loop:
6897 mutt_error _("No subject specified.");
6901 + if ((flags & SENDNEWS) && !msg->env->subject)
6903 + mutt_error _("No subject specified.");
6907 + if ((flags & SENDNEWS) && !msg->env->newsgroups)
6909 + mutt_error _("No newsgroup specified.");
6914 if (msg->content->next)
6915 msg->content = mutt_make_multipart (msg->content);
6916 @@ -1739,7 +1873,12 @@ full_fcc:
6919 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
6920 - mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
6921 + mutt_message (i != 0 ? _("Sending in background.") :
6923 + (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
6928 if (WithCrypto && (msg->security & ENCRYPT))
6930 diff -udprP mutt-1.5.13.orig/sendlib.c mutt-1.5.13/sendlib.c
6931 --- mutt-1.5.13.orig/sendlib.c 2006-07-18 21:16:24.000000000 +0300
6932 +++ mutt-1.5.13/sendlib.c 2006-08-15 13:04:56.000000000 +0300
6934 #include <sys/wait.h>
6941 #ifdef HAVE_SYSEXITS_H
6942 #include <sysexits.h>
6943 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
6944 @@ -1496,7 +1500,7 @@ void mutt_write_address_list (ADDRESS *a
6945 /* need to write the list in reverse because they are stored in reverse order
6946 * when parsed to speed up threading
6948 -static void write_references (LIST *r, FILE *f)
6949 +void mutt_write_references (LIST *r, FILE *f)
6952 int refcnt = 0, refmax = 0;
6953 @@ -1541,6 +1545,9 @@ int mutt_write_rfc822_header (FILE *fp,
6954 LIST *tmp = env->userhdrs;
6955 int has_agent = 0; /* user defined user-agent header field exists */
6958 + if (!option (OPTNEWSSEND))
6960 if (mode == 0 && !privacy)
6961 fputs (mutt_make_date (buffer, sizeof(buffer)), fp);
6963 @@ -1560,6 +1567,9 @@ int mutt_write_rfc822_header (FILE *fp,
6964 mutt_write_address_list (env->to, fp, 4, 0);
6968 + if (!option (OPTNEWSSEND))
6970 fputs ("To: \n", fp);
6973 @@ -1568,6 +1578,9 @@ int mutt_write_rfc822_header (FILE *fp,
6974 mutt_write_address_list (env->cc, fp, 4, 0);
6978 + if (!option (OPTNEWSSEND))
6980 fputs ("Cc: \n", fp);
6983 @@ -1579,8 +1592,28 @@ int mutt_write_rfc822_header (FILE *fp,
6988 + if (!option (OPTNEWSSEND))
6990 fputs ("Bcc: \n", fp);
6993 + if (env->newsgroups)
6994 + fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
6995 + else if (mode == 1 && option (OPTNEWSSEND))
6996 + fputs ("Newsgroups: \n", fp);
6998 + if (env->followup_to)
6999 + fprintf (fp, "Followup-To: %s\n", env->followup_to);
7000 + else if (mode == 1 && option (OPTNEWSSEND))
7001 + fputs ("Followup-To: \n", fp);
7003 + if (env->x_comment_to)
7004 + fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
7005 + else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
7006 + fputs ("X-Comment-To: \n", fp);
7010 fprintf (fp, "Subject: %s\n", env->subject);
7012 @@ -1599,6 +1632,9 @@ int mutt_write_rfc822_header (FILE *fp,
7013 fputs ("Reply-To: \n", fp);
7015 if (env->mail_followup_to)
7017 + if (!option (OPTNEWSSEND))
7020 fputs ("Mail-Followup-To: ", fp);
7021 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
7022 @@ -1609,7 +1645,7 @@ int mutt_write_rfc822_header (FILE *fp,
7023 if (env->references)
7025 fputs ("References:", fp);
7026 - write_references (env->references, fp);
7027 + mutt_write_references (env->references, fp);
7031 @@ -1621,7 +1657,7 @@ int mutt_write_rfc822_header (FILE *fp,
7032 if (env->in_reply_to)
7034 fputs ("In-Reply-To:", fp);
7035 - write_references (env->in_reply_to, fp);
7036 + mutt_write_references (env->in_reply_to, fp);
7040 @@ -1921,11 +1957,30 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7041 const char *msg, /* file containing message */
7042 int eightbit) /* message contains 8bit chars */
7044 - char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
7045 + char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
7047 size_t argslen = 0, argsmax = 0;
7051 + if (option (OPTNEWSSEND))
7053 + char cmd[LONG_STRING];
7055 + mutt_FormatString (cmd, sizeof (cmd), NONULL (Inews), nntp_format_str, 0, 0);
7058 + i = nntp_post (msg);
7063 + s = safe_strdup (cmd);
7067 + s = safe_strdup (Sendmail);
7071 while ((ps = strtok (ps, " ")))
7072 @@ -1949,6 +2004,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7077 + if (!option (OPTNEWSSEND))
7080 if (eightbit && option (OPTUSE8BITMIME))
7081 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7083 @@ -1980,6 +2039,9 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7084 args = add_args (args, &argslen, &argsmax, to);
7085 args = add_args (args, &argslen, &argsmax, cc);
7086 args = add_args (args, &argslen, &argsmax, bcc);
7091 if (argslen == argsmax)
7092 safe_realloc (&args, sizeof (char *) * (++argsmax));
7093 @@ -2112,6 +2174,9 @@ void mutt_prepare_envelope (ENVELOPE *en
7094 rfc2047_encode_adrlist (env->reply_to, "Reply-To");
7098 + if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
7101 rfc2047_encode_string (&env->subject);
7103 @@ -2211,6 +2276,10 @@ int mutt_bounce_message (FILE *fp, HEADE
7105 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
7108 + unset_option (OPTNEWSSEND);
7111 ret = _mutt_bounce_message (fp, h, to, resent_from, from);
7113 rfc822_free_address (&from);
7114 diff -udprP mutt-1.5.13.orig/sort.c mutt-1.5.13/sort.c
7115 --- mutt-1.5.13.orig/sort.c 2005-09-18 11:22:22.000000000 +0300
7116 +++ mutt-1.5.13/sort.c 2006-08-15 13:04:56.000000000 +0300
7117 @@ -149,6 +149,15 @@ int compare_order (const void *a, const
7118 HEADER **ha = (HEADER **) a;
7119 HEADER **hb = (HEADER **) b;
7122 + if ((*ha)->article_num && (*hb)->article_num)
7124 + int result = (*ha)->article_num - (*hb)->article_num;
7125 + AUXSORT(result,a,b);
7126 + return (SORTCODE (result));
7130 /* no need to auxsort because you will never have equality here */
7131 return (SORTCODE ((*ha)->index - (*hb)->index));
7133 diff -udprP mutt-1.5.13.orig/url.c mutt-1.5.13/url.c
7134 --- mutt-1.5.13.orig/url.c 2005-09-18 11:22:22.000000000 +0300
7135 +++ mutt-1.5.13/url.c 2006-08-15 13:04:56.000000000 +0300
7136 @@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] =
7137 { "imaps", U_IMAPS },
7140 + { "nntp", U_NNTP },
7141 + { "nntps", U_NNTPS },
7142 { "mailto", U_MAILTO },
7145 diff -udprP mutt-1.5.13.orig/url.h mutt-1.5.13/url.h
7146 --- mutt-1.5.13.orig/url.h 2004-07-20 01:00:05.000000000 +0300
7147 +++ mutt-1.5.13/url.h 2006-08-15 13:04:56.000000000 +0300
7148 @@ -8,6 +8,8 @@ typedef enum url_scheme
7157 diff -udprP mutt-1.5.13.orig/Makefile.am mutt-1.5.13/Makefile.am
7158 --- mutt-1.5.13.orig/Makefile.am 2006-08-14 16:47:23.000000000 +0300
7159 +++ mutt-1.5.13/Makefile.am 2006-08-15 13:04:56.000000000 +0300
7160 @@ -63,6 +63,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
7161 browser.h mbyte.h remailer.h url.h \
7162 crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
7163 pgppacket.c mutt_idna.h hcache.h hcache.c bcache.c bcache.h mutt_ssl_gnutls.c \
7165 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c
7167 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
7168 @@ -73,6 +74,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7169 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7170 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7171 rfc2231.h rfc822.h sha1.h sort.h mime.types VERSION prepare \
7172 + nntp.h ChangeLog.nntp \
7173 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7174 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
7175 makedoc.c stamp-doc-rc README.SSL smime.h\
7176 diff -udprP mutt-1.5.13.orig/Makefile.in mutt-1.5.13/Makefile.in
7177 --- mutt-1.5.13.orig/Makefile.in 2006-08-14 17:09:29.000000000 +0300
7178 +++ mutt-1.5.13/Makefile.in 2006-08-15 13:04:56.000000000 +0300
7179 @@ -325,6 +325,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
7180 browser.h mbyte.h remailer.h url.h \
7181 crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
7182 pgppacket.c mutt_idna.h hcache.h hcache.c bcache.c bcache.h mutt_ssl_gnutls.c \
7184 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c
7186 EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
7187 @@ -335,6 +336,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7188 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7189 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
7190 rfc2231.h rfc822.h sha1.h sort.h mime.types VERSION prepare \
7191 + nntp.h ChangeLog.nntp \
7192 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
7193 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
7194 makedoc.c stamp-doc-rc README.SSL smime.h\
7195 @@ -550,6 +552,8 @@ distclean-compile:
7196 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@
7197 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@
7198 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@
7199 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@
7200 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@
7201 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@
7202 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
7203 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@
7204 diff -udprP mutt-1.5.13.orig/Muttrc mutt-1.5.13/Muttrc
7205 --- mutt-1.5.13.orig/Muttrc 2006-08-14 17:09:47.000000000 +0300
7206 +++ mutt-1.5.13/Muttrc 2006-08-15 13:04:56.000000000 +0300
7207 @@ -220,6 +220,28 @@ attachments -I message/external-body
7208 # editing the body of an outgoing message.
7211 +# set ask_follow_up=no
7213 +# Name: ask_follow_up
7218 +# If set, Mutt will prompt you for follow-up groups before editing
7219 +# the body of an outgoing message.
7222 +# set ask_x_comment_to=no
7224 +# Name: ask_x_comment_to
7229 +# If set, Mutt will prompt you for x-comment-to field before editing
7230 +# the body of an outgoing message.
7233 # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
7235 # Name: attach_format
7236 @@ -376,6 +398,17 @@ attachments -I message/external-body
7237 # visual terminals don't permit making the cursor invisible.
7240 +# set catchup_newsgroup=ask-yes
7242 +# Name: catchup_newsgroup
7247 +# If this variable is set, Mutt will mark all articles in newsgroup
7248 +# as read when you quit the newsgroup (catchup newsgroup).
7254 @@ -862,6 +895,19 @@ attachments -I message/external-body
7255 # of the same email for you.
7258 +# set followup_to_poster=ask-yes
7260 +# Name: followup_to_poster
7265 +# If this variable is set and the keyword "poster" is present in
7266 +# Followup-To header, follow-up to newsgroup function is not
7267 +# permitted. The message will be mailed to the submitter of the
7268 +# message via mail.
7274 @@ -959,6 +1005,28 @@ attachments -I message/external-body
7275 # "Franklin" to "Franklin, Steve".
7278 +# set group_index_format="%4C %M%N %5s %-45.45f %d"
7280 +# Name: group_index_format
7282 +# Default: "%4C %M%N %5s %-45.45f %d"
7285 +# This variable allows you to customize the newsgroup browser display to
7286 +# your personal taste. This string is similar to ``index_format'', but
7287 +# has its own set of printf()-like sequences:
7289 +# %C current newsgroup number
7290 +# %d description of newsgroup (becomes from server)
7291 +# %f newsgroup name
7292 +# %M - if newsgroup not allowed for direct post (moderated for example)
7293 +# %N N if newsgroup is new, u if unsubscribed, blank otherwise
7294 +# %n number of new articles in newsgroup
7295 +# %s number of unread articles in newsgroup
7296 +# %>X right justify the rest of the string and pad with character "X"
7297 +# %|X pad to the end of the line with character "X"
7303 @@ -1394,6 +1462,7 @@ attachments -I message/external-body
7304 # %E number of messages in current thread
7305 # %f entire From: line (address + real name)
7306 # %F author name, or recipient name if the message is from you
7307 +# %g newsgroup name (if compiled with nntp support)
7308 # %H spam attribute(s) of this message
7309 # %i message-id of the current message
7310 # %l number of lines in the message (does not work with maildir,
7311 @@ -1413,6 +1482,7 @@ attachments -I message/external-body
7312 # %T the appropriate character from the $to_chars string
7313 # %u user (login) name of the author
7314 # %v first name of the author, or the recipient if the message is from you
7315 +# %W name of organization of author (`organization:' field)
7316 # %X number of attachments
7317 # (please see the ``attachments'' section for possible speed effects)
7318 # %y `x-label:' field, if present
7319 @@ -1438,6 +1508,22 @@ attachments -I message/external-body
7320 # See also: ``$to_chars''.
7330 +# If set, specifies the program and arguments used to deliver news posted
7331 +# by Mutt. Otherwise, mutt posts article using current connection to
7332 +# news server. The following printf-style sequence is understood:
7334 +# %s newsserver name
7336 +# Example: set inews="/usr/local/bin/inews -hS"
7339 # set ispell="/usr/bin/ispell"
7342 @@ -1781,6 +1867,18 @@ attachments -I message/external-body
7343 # be attached to the newly composed message if this option is set.
7346 +# set mime_subject=yes
7348 +# Name: mime_subject
7353 +# If unset, 8-bit ``subject:'' line in article header will not be
7354 +# encoded according to RFC2047 to base64. This is useful when message
7355 +# is Usenet article, because MIME for news is nonstandard feature.
7358 # set mix_entry_format="%4n %c %-16s %a"
7360 # Name: mix_entry_format
7361 @@ -1873,6 +1971,118 @@ attachments -I message/external-body
7362 # See also ``$read_inc'' and ``$write_inc''.
7365 +# set news_cache_dir="~/.mutt"
7367 +# Name: news_cache_dir
7369 +# Default: "~/.mutt"
7372 +# This variable pointing to directory where Mutt will save cached news
7373 +# articles headers in. If unset, headers will not be saved at all
7374 +# and will be reloaded each time when you enter to newsgroup.
7377 +# set news_server=""
7379 +# Name: news_server
7384 +# This variable specifies domain name or address of NNTP server. It
7385 +# defaults to the newsserver specified in the environment variable
7386 +# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
7387 +# specify username and an alternative port for each newsserver, ie:
7389 +# [nntp[s]://][username[:password]@]newsserver[:port]
7392 +# set newsrc="~/.newsrc"
7396 +# Default: "~/.newsrc"
7399 +# The file, containing info about subscribed newsgroups - names and
7400 +# indexes of read articles. The following printf-style sequence
7403 +# %s newsserver name
7406 +# set nntp_context=1000
7408 +# Name: nntp_context
7413 +# This variable defines number of articles which will be in index when
7414 +# newsgroup entered. If active newsgroup have more articles than this
7415 +# number, oldest articles will be ignored. Also controls how many
7416 +# articles headers will be saved in cache when you quit newsgroup.
7419 +# set nntp_load_description=yes
7421 +# Name: nntp_load_description
7426 +# This variable controls whether or not descriptions for each newsgroup
7427 +# must be loaded when newsgroup is added to list (first time list
7428 +# loading or new newsgroup adding).
7438 +# Your login name on the NNTP server. If unset and NNTP server requires
7439 +# authentification, Mutt will prompt you for your account name when you
7440 +# connect to newsserver.
7450 +# Your password for NNTP account.
7460 +# The time in seconds until any operations on newsgroup except post new
7461 +# article will cause recheck for new news. If set to 0, Mutt will
7462 +# recheck newsgroup on each operation in index (stepping, read article,
7466 +# set nntp_reconnect=ask-yes
7468 +# Name: nntp_reconnect
7473 +# Controls whether or not Mutt will try to reconnect to newsserver when
7477 # set pager="builtin"
7480 @@ -3076,6 +3286,19 @@ attachments -I message/external-body
7481 # string after the inclusion of a message which is being replied to.
7484 +# set post_moderated=ask-yes
7486 +# Name: post_moderated
7491 +# If set to yes, Mutt will post article to newsgroup that have
7492 +# not permissions to posting (e.g. moderated). Note: if newsserver
7493 +# does not support posting to that newsgroup or totally read-only, that
7494 +# posting will not have an effect.
7497 # set postpone=ask-yes
7500 @@ -3588,6 +3811,41 @@ attachments -I message/external-body
7501 # shell from /etc/passwd is used.
7504 +# set save_unsubscribed=no
7506 +# Name: save_unsubscribed
7511 +# When set, info about unsubscribed newsgroups will be saved into
7512 +# ``newsrc'' file and into cache.
7515 +# set show_new_news=yes
7517 +# Name: show_new_news
7522 +# If set, newsserver will be asked for new newsgroups on entering
7523 +# the browser. Otherwise, it will be done only once for a newsserver.
7524 +# Also controls whether or not number of new articles of subscribed
7525 +# newsgroups will be then checked.
7528 +# set show_only_unread=no
7530 +# Name: show_only_unread
7535 +# If set, only subscribed newsgroups that contain unread articles
7536 +# will be displayed in browser.
7539 # set sig_dashes=yes
7542 @@ -4236,3 +4494,14 @@ attachments -I message/external-body
7543 # messages to be sent. Exim users may wish to unset this.
7546 +# set x_comment_to=no
7548 +# Name: x_comment_to
7553 +# If set, Mutt will add ``X-Comment-To:'' field (that contains full
7554 +# name of original article author) to article that followuped to newsgroup.
7557 diff -udprP mutt-1.5.13.orig/configure mutt-1.5.13/configure
7558 --- mutt-1.5.13.orig/configure 2006-08-14 17:09:30.000000000 +0300
7559 +++ mutt-1.5.13/configure 2006-08-15 13:04:56.000000000 +0300
7560 @@ -859,6 +859,7 @@ Optional Features:
7561 Force use of an external dotlock program
7562 --enable-pop Enable POP3 support
7563 --enable-imap Enable IMAP support
7564 + --enable-nntp Enable NNTP support
7565 --enable-debug Enable debugging support
7566 --enable-flock Use flock() to lock files
7567 --disable-fcntl Do NOT use fcntl() to lock files
7568 @@ -11740,6 +11741,20 @@ fi
7572 +# Check whether --enable-nntp or --disable-nntp was given.
7573 +if test "${enable_nntp+set}" = set; then
7574 + enableval="$enable_nntp"
7575 + if test x$enableval = xyes ; then
7576 + cat >>confdefs.h <<\_ACEOF
7580 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
7588 for ac_func in strftime