- merged from DEVEL
[packages/mutt.git] / mutt-vvv.nntp.patch
CommitLineData
95768aa9 1WARNING: Run the following script before configure:
2
3aclocal -I m4
4autoheader
5automake --foreign
6autoconf
7
8--
9Vsevolod Volkov <vvv@mutt.org.ua>
10
11
12diff -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
15@@ -0,0 +1,332 @@
16+* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
17+- update to 1.5.13
18+
19+* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
20+- update to 1.5.12
21+- fixed reading empty .newsrc
22+
23+* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
24+- update to 1.5.11
25+
26+* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
27+- update to 1.5.10
28+
29+* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
30+- update to 1.5.9
31+
32+* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
33+- update to 1.5.8
34+
35+* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
36+- update to 1.5.7
37+- function mutt_update_list_file() moved to newsrc.c and changed algorithm
38+
39+* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
40+- fixed error in nntp_logout_all()
41+
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()
46+
47+* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
48+- update to 1.5.6
49+
50+* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
51+- fixed compose menu
52+
53+* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
54+- update to 1.5.5.1
55+
56+* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
57+- update to 1.5.5
58+- added space after newsgroup name in .newsrc file
59+
60+* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
61+- nntp patch: fixed SIGSEGV when posting article
62+
63+* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
64+- update to 1.5.4
65+
66+* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
67+- update to 1.5.3
68+- replace safe_free calls by the FREE macro
69+
70+* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
71+- update to 1.5.2
72+- nntp authentication can be passed after any command
73+
74+* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
75+- update to 1.5.1
76+
77+* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
78+- update to 1.3.99
79+
80+* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
81+- update to 1.3.28
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
89+
90+* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
91+- update to 1.3.27
92+
93+* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
94+- update to 1.3.26
95+
96+* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
97+- update to 1.3.25
98+- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
99+- added default content disposition
100+
101+* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
102+- update to 1.3.24
103+
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
107+
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
114+
115+* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
116+- update to 1.3.23
117+- fixed typo in buffy.c
118+- added substitution of %s parameter in $inews variable
119+
120+* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
121+- update to 1.3.22.1
122+- update to 1.3.22
123+
124+* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
125+- update to 1.3.21
126+
127+* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
128+- update to 1.3.20
129+- removed 'server-hook', use 'account-hook' instead
130+- fixed error opening NNTP server without newsgroup using -f option
131+
132+* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
133+- update to 1.3.19
134+
135+* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
136+- update to 1.3.18
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
145+
146+* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
147+- update to 1.3.17
148+- support for 'LIST NEWSGROUPS' command to read descriptions
149+
150+* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
151+- update to 1.3.16
152+
153+* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
154+- update to 1.3.15
155+
156+* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
157+- update to 1.3.14
158+- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
159+
160+* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
161+- update to 1.3.13
162+
163+* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
164+- Fixed problem if last article in group is deleted
165+
166+* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
167+- Fixed checking of XGTITLE command on some servers
168+
169+* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
170+- Added \r in AUTHINFO commands
171+
172+* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
173+- update to 1.3.12
174+
175+* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
176+- update to 1.3.11
177+- fixed error opening newsgroup from mutt started with -g or -G
178+
179+* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
180+- update to 1.3.10
181+- hotkey 'G' (get-message) replaced with '^G'
182+
183+* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
184+- update to 1.3.9
185+- changed delay displaying error messages from 1 to 2 seconds
186+- fixed error compiling with nntp and without imap
187+
188+* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
189+- fixed catchup in index
190+- fixed nntp_open_mailbox()
191+
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
199+
200+* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
201+- update to 1.3.8
202+- new option show_only_unread
203+- add newsgroup completion
204+
205+* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
206+- update to 1.3.7
207+
208+* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
209+- update to 1.3.6
210+
211+* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
212+- update to 1.3.5
213+- authentication code update
214+- fix for changing to newsgroup from mailbox with read messages
215+- socket code optimization
216+
217+* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
218+- update to 1.3.4
219+
220+* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
221+- don't substitute current newsgroup with deleted new messages
222+
223+* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
224+- update to 1.3.3
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
228+
229+* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
230+- update to 1.3.2
231+
232+* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
233+- update to 1.3.1
234+
235+* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
236+- update to 1.3
237+
238+* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
239+- update to 1.2
240+
241+* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
242+- update to 1.1.14
243+
244+* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
245+- update to 1.1.12
246+
247+* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
248+- add substitution of newsgroup with new messages by default
249+
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
254+- add -G option
255+
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
260+- add -g option
261+
262+* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
263+- remove 'X-FTN-Origin' header processing
264+
265+* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
266+- update to 1.1.11
267+- update to 1.1.10
268+
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
273+
274+* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
275+- fix server-hook
276+
277+* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
278+- fix error 'bounce' function after 'post'
279+- add 'forward to newsgroup' function
280+
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
285+
286+* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
287+- update to 1.1.9
288+- remove deleted newsgroups from list
289+
290+* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
291+- update .newsrc in browser
292+
293+* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
294+- reload .newsrc if externally modified
295+- fix active cache update
296+
297+* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
298+- update to 1.1.8
299+
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
304+
305+* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
306+- load list of newsgroups from cache faster
307+
308+* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
309+- update to 1.1.7
310+
311+* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
312+- fix unread messages in browser
313+- fix newsrc_gen_entries()
314+
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()
321+
322+* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
323+- update to 1.1.5
324+
325+* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
326+- fix updating new messages in cache
327+
328+* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
329+- change default cache filenames
330+- fix updating new messages in cache
331+
332+* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
333+- fix segmentation fault in news groups browser
334+
335+* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
336+- update to 1.1.4
337+
338+* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
339+- update to 1.1.3
340+
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
345+
346+* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
347+- update to 1.1.2
348diff -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"
449diff -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
452@@ -0,0 +1 @@
453+vvv.nntp
454diff -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
458 user = PopUser;
459 #endif
460
461+#ifdef USE_NNTP
462+ if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
463+ user = NntpUser;
464+#endif
465+
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
470 }
471 #endif
472
473+#ifdef USE_NNTP
474+ if (account->type == M_ACCT_TYPE_NNTP)
475+ {
476+ if (account->flags & M_ACCT_SSL)
477+ url->scheme = U_NNTPS;
478+ else
479+ url->scheme = U_NNTP;
480+ }
481+#endif
482+
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));
489 #endif
490+#ifdef USE_NNTP
491+ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
492+ strfcpy (account->user, NntpUser, sizeof (account->user));
493+#endif
494 /* prompt (defaults to unix username), copy into account->user */
495 else
496 {
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));
500 #endif
501+#ifdef USE_NNTP
502+ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
503+ strfcpy (account->pass, NntpPass, sizeof (account->pass));
504+#endif
505 else
506 {
507 snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
508diff -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
512 {
513 M_ACCT_TYPE_NONE = 0,
514 M_ACCT_TYPE_IMAP,
515+ M_ACCT_TYPE_NNTP,
516 M_ACCT_TYPE_POP
517 };
518
519diff -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
523
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);
529
530 #endif /* _ATTACH_H_ */
531diff -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
534@@ -32,6 +32,9 @@
535 #ifdef USE_IMAP
536 #include "imap.h"
537 #endif
538+#ifdef USE_NNTP
539+#include "nntp.h"
540+#endif
541
542 #include <stdlib.h>
543 #include <dirent.h>
544@@ -49,6 +52,19 @@ static struct mapping_t FolderHelp[] = {
545 { NULL }
546 };
547
548+#ifdef USE_NNTP
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 },
557+ { NULL }
558+};
559+#endif
560+
561 typedef struct folder_t
562 {
563 struct folder_file *ff;
564@@ -114,9 +130,17 @@ static void browser_sort (struct browser
565 case SORT_ORDER:
566 return;
567 case SORT_DATE:
568+#ifdef USE_NNTP
569+ if (option (OPTNEWS))
570+ return;
571+#endif
572 f = browser_compare_date;
573 break;
574 case SORT_SIZE:
575+#ifdef USE_NNTP
576+ if (option (OPTNEWS))
577+ return;
578+#endif
579 f = browser_compare_size;
580 break;
581 case SORT_SUBJECT:
582@@ -306,8 +330,106 @@ folder_format_str (char *dest, size_t de
583 return (src);
584 }
585
586+#ifdef USE_NNTP
587+static const char *
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)
591+{
592+ char fn[SHORT_STRING], tmp[SHORT_STRING];
593+ FOLDER *folder = (FOLDER *) data;
594+
595+ switch (op)
596+ {
597+ case 'C':
598+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
599+ snprintf (dest, destlen, tmp, folder->num + 1);
600+ break;
601+
602+ case 'f':
603+ strncpy (fn, folder->ff->name, sizeof(fn) - 1);
604+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
605+ snprintf (dest, destlen, tmp, fn);
606+ break;
607+
608+ case 'N':
609+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
610+ if (folder->ff->nd->subscribed)
611+ snprintf (dest, destlen, tmp, ' ');
612+ else
613+ snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
614+ break;
615+
616+ case 'M':
617+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
618+ if (folder->ff->nd->deleted)
619+ snprintf (dest, destlen, tmp, 'D');
620+ else
621+ snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
622+ break;
623+
624+ case 's':
625+ if (flags & M_FORMAT_OPTIONAL)
626+ {
627+ if (folder->ff->nd->unread != 0)
628+ mutt_FormatString (dest, destlen, ifstring, newsgroup_format_str,
629+ data, flags);
630+ else
631+ mutt_FormatString (dest, destlen, elsestring, newsgroup_format_str,
632+ data, flags);
633+ }
634+ else if (Context && Context->data == folder->ff->nd)
635+ {
636+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
637+ snprintf (dest, destlen, tmp, Context->unread);
638+ }
639+ else
640+ {
641+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
642+ snprintf (dest, destlen, tmp, folder->ff->nd->unread);
643+ }
644+ break;
645+
646+ case 'n':
647+ if (Context && Context->data == folder->ff->nd)
648+ {
649+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
650+ snprintf (dest, destlen, tmp, Context->new);
651+ }
652+ else if (option (OPTMARKOLD) &&
653+ folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
654+ folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
655+ {
656+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
657+ snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
658+ }
659+ else
660+ {
661+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
662+ snprintf (dest, destlen, tmp, folder->ff->nd->unread);
663+ }
664+ break;
665+
666+ case 'd':
667+ if (folder->ff->nd->desc != NULL)
668+ {
669+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
670+ snprintf (dest, destlen, tmp, folder->ff->nd->desc);
671+ }
672+ else
673+ {
674+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
675+ snprintf (dest, destlen, tmp, "");
676+ }
677+ break;
678+ }
679+ return (src);
680+}
681+#endif /* USE_NNTP */
682+
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)
687 {
688 if (state->entrylen == state->entrymax)
689 {
690@@ -336,6 +458,10 @@ static void add_folder (MUTTMENU *m, str
691 #ifdef USE_IMAP
692 (state->entry)[state->entrylen].imap = 0;
693 #endif
694+#ifdef USE_NNTP
695+ if (option (OPTNEWS))
696+ (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
697+#endif
698 (state->entrylen)++;
699 }
700
701@@ -351,9 +477,35 @@ static void init_state (struct browser_s
702 menu->data = state->entry;
703 }
704
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)
708 {
709+#ifdef USE_NNTP
710+ if (option (OPTNEWS))
711+ {
712+ LIST *tmp;
713+ NNTP_DATA *data;
714+ NNTP_SERVER *news = CurrentNewsSrv;
715+
716+/* mutt_buffy_check (0); */
717+ init_state (state, menu);
718+
719+ for (tmp = news->list; tmp; tmp = tmp->next)
720+ {
721+ if (!(data = (NNTP_DATA *)tmp->data))
722+ continue;
723+ if (prefix && *prefix && strncmp (prefix, data->group,
724+ strlen (prefix)) != 0)
725+ continue;
726+ if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
727+ continue;
728+ add_folder (menu, state, data->group, NULL, data, data->new);
729+ }
730+ }
731+ else
732+#endif /* USE_NNTP */
733+ {
734 struct stat s;
735 DIR *dp;
736 struct dirent *de;
737@@ -414,17 +566,40 @@ static int examine_directory (MUTTMENU *
738 tmp = Incoming;
739 while (tmp && mutt_strcmp (buffer, tmp->path))
740 tmp = tmp->next;
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);
743+ }
744+ closedir (dp);
745 }
746- closedir (dp);
747 browser_sort (state);
748 return 0;
749 }
750
751+/* get list of mailboxes/subscribed newsgroups */
752 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
753 {
754 struct stat s;
755 char buffer[LONG_STRING];
756+
757+#ifdef USE_NNTP
758+ if (option (OPTNEWS))
759+ {
760+ LIST *tmp;
761+ NNTP_DATA *data;
762+ NNTP_SERVER *news = CurrentNewsSrv;
763+
764+/* mutt_buffy_check (0); */
765+ init_state (state, menu);
766+
767+ for (tmp = news->list; tmp; tmp = tmp->next)
768+ {
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);
772+ }
773+ }
774+ else
775+#endif
776+ {
777 BUFFY *tmp = Incoming;
778
779 if (!Incoming)
780@@ -438,14 +613,21 @@ static int examine_mailboxes (MUTTMENU *
781 #ifdef USE_IMAP
782 if (mx_is_imap (tmp->path))
783 {
784- add_folder (menu, state, tmp->path, NULL, tmp->new);
785+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
786 continue;
787 }
788 #endif
789 #ifdef USE_POP
790 if (mx_is_pop (tmp->path))
791 {
792- add_folder (menu, state, tmp->path, NULL, tmp->new);
793+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
794+ continue;
795+ }
796+#endif
797+#ifdef USE_NNTP
798+ if (mx_is_nntp (tmp->path))
799+ {
800+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
801 continue;
802 }
803 #endif
804@@ -459,15 +641,20 @@ static int examine_mailboxes (MUTTMENU *
805 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
806 mutt_pretty_mailbox (buffer);
807
808- add_folder (menu, state, buffer, &s, tmp->new);
809+ add_folder (menu, state, buffer, &s, NULL, tmp->new);
810 }
811 while ((tmp = tmp->next));
812+ }
813 browser_sort (state);
814 return 0;
815 }
816
817 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
818 {
819+#ifdef USE_NNTP
820+ if (option (OPTNEWS))
821+ return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
822+#endif
823 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
824 }
825
826@@ -478,7 +665,13 @@ static void folder_entry (char *s, size_
827 folder.ff = &((struct folder_file *) menu->data)[num];
828 folder.num = num;
829
830- mutt_FormatString (s, slen, NONULL(FolderFormat), folder_format_str,
831+#ifdef USE_NNTP
832+ if (option (OPTNEWS))
833+ mutt_FormatString (s, slen, NONULL(GroupFormat), newsgroup_format_str,
834+ (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
835+ else
836+#endif
837+ mutt_FormatString (s, slen, NONULL(FolderFormat), folder_format_str,
838 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
839 }
840
841@@ -498,6 +691,17 @@ static void init_menu (struct browser_st
842
843 menu->tagged = 0;
844
845+#ifdef USE_NNTP
846+ if (option (OPTNEWS))
847+ {
848+ if (buffy)
849+ snprintf (title, titlelen, _("Subscribed newsgroups"));
850+ else
851+ snprintf (title, titlelen, _("Newsgroups on server [%s]"),
852+ CurrentNewsSrv->conn->account.host);
853+ }
854+ else
855+#endif
856 if (buffy)
857 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
858 else
859@@ -553,6 +757,31 @@ void _mutt_select_file (char *f, size_t
860 if (!folder)
861 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
862
863+#ifdef USE_NNTP
864+ if (option (OPTNEWS))
865+ {
866+ if (*f)
867+ strfcpy (prefix, f, sizeof (prefix));
868+ else
869+ {
870+ LIST *list;
871+
872+ /* default state for news reader mode is browse subscribed newsgroups */
873+ buffy = 0;
874+ for (list = CurrentNewsSrv->list; list; list = list->next)
875+ {
876+ NNTP_DATA *data = (NNTP_DATA *) list->data;
877+
878+ if (data && data->subscribed)
879+ {
880+ buffy = 1;
881+ break;
882+ }
883+ }
884+ }
885+ }
886+ else
887+#endif
888 if (*f)
889 {
890 mutt_expand_path (f, flen);
891@@ -642,6 +871,9 @@ void _mutt_select_file (char *f, size_t
892 menu->tag = file_tag;
893
894 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
895+#ifdef USE_NNTP
896+ (option (OPTNEWS)) ? FolderNewsHelp :
897+#endif
898 FolderHelp);
899
900 init_menu (&state, menu, title, sizeof (title), buffy);
901@@ -780,7 +1012,11 @@ void _mutt_select_file (char *f, size_t
902 }
903 }
904
905+#ifdef USE_NNTP
906+ if (buffy || option (OPTNEWS)) /* news have not path */
907+#else
908 if (buffy)
909+#endif
910 {
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
914 break;
915
916 #ifdef USE_IMAP
917- case OP_BROWSER_SUBSCRIBE:
918- imap_subscribe (state.entry[menu->current].name, 1);
919- break;
920-
921- case OP_BROWSER_UNSUBSCRIBE:
922- imap_subscribe (state.entry[menu->current].name, 0);
923- break;
924-
925 case OP_BROWSER_TOGGLE_LSUB:
926 if (option (OPTIMAPLSUB))
927 {
928@@ -944,6 +1172,11 @@ void _mutt_select_file (char *f, size_t
929
930 case OP_CHANGE_DIRECTORY:
931
932+#ifdef USE_NNTP
933+ if (option (OPTNEWS))
934+ break;
935+#endif
936+
937 strfcpy (buf, LastDir, sizeof (buf));
938 #ifdef USE_IMAP
939 if (!state.imap_browse)
940@@ -1200,6 +1433,190 @@ void _mutt_select_file (char *f, size_t
941 else
942 mutt_error _("Error trying to view file");
943 }
944+ break;
945+
946+#ifdef USE_NNTP
947+ case OP_CATCHUP:
948+ case OP_UNCATCHUP:
949+ if (option (OPTNEWS))
950+ {
951+ struct folder_file *f = &state.entry[menu->current];
952+ NNTP_DATA *nd;
953+
954+ if (i == OP_CATCHUP)
955+ nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
956+ else
957+ nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
958+
959+ if (nd)
960+ {
961+/* FOLDER folder;
962+ struct folder_file ff;
963+ char buffer[_POSIX_PATH_MAX + SHORT_STRING];
964+
965+ folder.ff = &ff;
966+ folder.ff->name = f->name;
967+ folder.ff->st = NULL;
968+ folder.ff->is_new = nd->new;
969+ folder.ff->nd = nd;
970+ FREE (&f->desc);
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)
976+ menu->current++;
977+ menu->redraw = REDRAW_MOTION_RESYNCH;
978+ }
979+ }
980+ break;
981+
982+ case OP_LOAD_ACTIVE:
983+ if (!option (OPTNEWS))
984+ break;
985+
986+ {
987+ LIST *tmp;
988+ NNTP_DATA *data;
989+
990+ for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
991+ {
992+ if ((data = (NNTP_DATA *)tmp->data))
993+ data->deleted = 1;
994+ }
995+ }
996+ nntp_get_active (CurrentNewsSrv);
997+
998+ destroy_state (&state);
999+ if (buffy)
1000+ examine_mailboxes (menu, &state);
1001+ else
1002+ examine_directory (menu, &state, NULL, NULL);
1003+ init_menu (&state, menu, title, sizeof (title), buffy);
1004+ break;
1005+#endif /* USE_NNTP */
1006+
1007+#if defined USE_IMAP || defined USE_NNTP
1008+ case OP_BROWSER_SUBSCRIBE:
1009+ case OP_BROWSER_UNSUBSCRIBE:
1010+#endif
1011+#ifdef USE_NNTP
1012+ case OP_SUBSCRIBE_PATTERN:
1013+ case OP_UNSUBSCRIBE_PATTERN:
1014+ if (option (OPTNEWS))
1015+ {
1016+ regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1017+ char *s = buf;
1018+ int j = menu->current;
1019+ NNTP_DATA *nd;
1020+ NNTP_SERVER *news = CurrentNewsSrv;
1021+
1022+ if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1023+ {
1024+ char tmp[STRING];
1025+ int err;
1026+
1027+ buf[0] = 0;
1028+ if (i == OP_SUBSCRIBE_PATTERN)
1029+ snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1030+ else
1031+ snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1032+ if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1033+ {
1034+ FREE (&rx);
1035+ break;
1036+ }
1037+
1038+ if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1039+ {
1040+ regerror (err, rx, buf, sizeof (buf));
1041+ regfree (rx);
1042+ FREE (&rx);
1043+ mutt_error ("%s", buf);
1044+ break;
1045+ }
1046+ menu->redraw = REDRAW_FULL;
1047+ j = 0;
1048+ }
1049+ else if (!state.entrylen)
1050+ {
1051+ mutt_error _("No newsgroups match the mask");
1052+ break;
1053+ }
1054+
1055+ for ( ; j < state.entrylen; j++)
1056+ {
1057+ struct folder_file *f = &state.entry[j];
1058+
1059+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1060+ regexec (rx, f->name, 0, NULL, 0) == 0)
1061+ {
1062+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1063+ nd = mutt_newsgroup_subscribe (news, f->name);
1064+ else
1065+ nd = mutt_newsgroup_unsubscribe (news, f->name);
1066+/* if (nd)
1067+ {
1068+ FOLDER folder;
1069+ char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1070+
1071+ folder.name = f->name;
1072+ folder.f = NULL;
1073+ folder.new = nd->new;
1074+ folder.nd = nd;
1075+ FREE (&f->desc);
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);
1080+ } */
1081+ }
1082+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1083+ {
1084+ if (menu->current + 1 < menu->max)
1085+ menu->current++;
1086+ menu->redraw = REDRAW_MOTION_RESYNCH;
1087+ break;
1088+ }
1089+ }
1090+ if (i == OP_SUBSCRIBE_PATTERN)
1091+ {
1092+ LIST *grouplist = NULL;
1093+
1094+ if (news)
1095+ grouplist = news->list;
1096+ for (; grouplist; grouplist = grouplist->next)
1097+ {
1098+ nd = (NNTP_DATA *) grouplist->data;
1099+ if (nd && nd->group && !nd->subscribed)
1100+ {
1101+ if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1102+ {
1103+ mutt_newsgroup_subscribe (news, nd->group);
1104+ add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1105+ }
1106+ }
1107+ }
1108+ init_menu (&state, menu, title, sizeof (title), buffy);
1109+ }
1110+ mutt_newsrc_update (news);
1111+ nntp_clear_cacheindex (news);
1112+ if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1113+ regfree (rx);
1114+ FREE (&rx);
1115+ }
1116+#ifdef USE_IMAP
1117+ else
1118+#endif /* USE_IMAP && USE_NNTP */
1119+#endif /* USE_NNTP */
1120+#ifdef USE_IMAP
1121+ {
1122+ if (i == OP_BROWSER_SUBSCRIBE)
1123+ imap_subscribe (state.entry[menu->current].name, 1);
1124+ else
1125+ imap_subscribe (state.entry[menu->current].name, 0);
1126+ }
1127+#endif /* USE_IMAP */
1128 }
1129 }
1130
1131diff -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
1134@@ -20,6 +20,10 @@
1135 #ifndef _BROWSER_H
1136 #define _BROWSER_H 1
1137
1138+#ifdef USE_NNTP
1139+#include "nntp.h"
1140+#endif
1141+
1142 struct folder_file
1143 {
1144 mode_t mode;
1145@@ -38,14 +42,17 @@ struct folder_file
1146 unsigned selectable : 1;
1147 unsigned inferiors : 1;
1148 #endif
1149+#ifdef USE_NNTP
1150+ NNTP_DATA *nd;
1151+#endif
1152 unsigned tagged : 1;
1153 };
1154
1155 struct browser_state
1156 {
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 */
1162 #ifdef USE_IMAP
1163 short imap_browse;
1164 char *folder;
1165diff -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)
1169 #ifdef USE_POP
1170 if (!Context || Context->magic != M_POP)
1171 #endif
1172+#ifdef USE_NNTP
1173+ if (!Context || Context->magic != M_NNTP)
1174+#endif
1175 /* check device ID and serial number instead of comparing paths */
1176 if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0)
1177 {
1178@@ -316,6 +319,11 @@ int mutt_buffy_check (int force)
1179 tmp->magic = M_POP;
1180 else
1181 #endif
1182+#ifdef USE_NNTP
1183+ if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1184+ tmp->magic = M_NNTP;
1185+ else
1186+#endif
1187 if (stat (tmp->path, &sb) != 0 || sb.st_size == 0 ||
1188 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1189 {
1190@@ -335,25 +343,21 @@ int mutt_buffy_check (int force)
1191 /* check to see if the folder is the currently selected folder
1192 * before polling */
1193 if (!Context || !Context->path ||
1194-#if defined USE_IMAP || defined USE_POP
1195- ((
1196+ (
1197+ (0
1198 #ifdef USE_IMAP
1199- tmp->magic == M_IMAP
1200+ || tmp->magic == M_IMAP
1201 #endif
1202 #ifdef USE_POP
1203-#ifdef USE_IMAP
1204- ||
1205-#endif
1206- tmp->magic == M_POP
1207-#endif
1208- ) ? mutt_strcmp (tmp->path, Context->path) :
1209+ || tmp->magic == M_POP
1210 #endif
1211- (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1212-#if defined USE_IMAP || defined USE_POP
1213- )
1214+#ifdef USE_NNTP
1215+ || tmp->magic == M_NNTP
1216 #endif
1217- )
1218-
1219+ ) ? mutt_strcmp (tmp->path, Context->path) :
1220+ (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1221+ )
1222+ )
1223 {
1224 switch (tmp->magic)
1225 {
1226diff -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
1229@@ -25,6 +25,9 @@
1230 #include "mailbox.h"
1231 #include "imap.h"
1232 #endif
1233+#ifdef USE_NNTP
1234+#include "nntp.h"
1235+#endif
1236
1237 #include <dirent.h>
1238 #include <string.h>
1239@@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen)
1240 char filepart[_POSIX_PATH_MAX];
1241 #ifdef USE_IMAP
1242 char imap_path[LONG_STRING];
1243+#endif
1244
1245 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1246
1247+#ifdef USE_NNTP
1248+ if (option (OPTNEWS))
1249+ {
1250+ LIST *l = CurrentNewsSrv->list;
1251+
1252+ strfcpy (filepart, s, sizeof (filepart));
1253+
1254+ /*
1255+ * special case to handle when there is no filepart yet.
1256+ * find the first subscribed newsgroup
1257+ */
1258+ if ((len = mutt_strlen (filepart)) == 0)
1259+ {
1260+ for (; l; l = l->next)
1261+ {
1262+ NNTP_DATA *data = (NNTP_DATA *)l->data;
1263+
1264+ if (data && data->subscribed)
1265+ {
1266+ strfcpy (filepart, data->group, sizeof (filepart));
1267+ init++;
1268+ l = l->next;
1269+ break;
1270+ }
1271+ }
1272+ }
1273+
1274+ for (; l; l = l->next)
1275+ {
1276+ NNTP_DATA *data = (NNTP_DATA *)l->data;
1277+
1278+ if (data && data->subscribed &&
1279+ mutt_strncmp (data->group, filepart, len) == 0)
1280+ {
1281+ if (init)
1282+ {
1283+ for (i = 0; filepart[i] && data->group[i]; i++)
1284+ {
1285+ if (filepart[i] != data->group[i])
1286+ {
1287+ filepart[i] = 0;
1288+ break;
1289+ }
1290+ }
1291+ filepart[i] = 0;
1292+ }
1293+ else
1294+ {
1295+ strfcpy (filepart, data->group, sizeof (filepart));
1296+ init = 1;
1297+ }
1298+ }
1299+ }
1300+
1301+ strcpy (s, filepart);
1302+
1303+ return (init ? 0 : -1);
1304+ }
1305+#endif
1306+
1307+#ifdef USE_IMAP
1308 /* we can use '/' as a delimiter, imap_complete rewrites it */
1309 if (*s == '=' || *s == '+' || *s == '!')
1310 {
1311diff -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
1314@@ -32,10 +32,15 @@
1315 #include "mailbox.h"
1316 #include "sort.h"
1317 #include "charset.h"
1318+#include "mx.h"
1319
1320 #ifdef MIXMASTER
1321 #include "remailer.h"
1322 #endif
1323+
1324+#ifdef USE_NNTP
1325+#include "nntp.h"
1326+#endif
1327
1328 #include <errno.h>
1329 #include <string.h>
1330@@ -60,18 +65,21 @@ enum
1331 HDR_REPLYTO,
1332 HDR_FCC,
1333
1334-#ifdef MIXMASTER
1335- HDR_MIX,
1336-#endif
1337
1338 HDR_CRYPT,
1339 HDR_CRYPTINFO,
1340
1341+#ifdef USE_NNTP
1342+ HDR_NEWSGROUPS,
1343+ HDR_FOLLOWUPTO,
1344+ HDR_XCOMMENTTO,
1345+#endif
1346+
1347 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1348 };
1349
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)
1355
1356 static char *Prompts[] =
1357@@ -83,6 +91,16 @@ static char *Prompts[] =
1358 "Subject: ",
1359 "Reply-To: ",
1360 "Fcc: "
1361+#ifdef USE_NNTP
1362+#ifdef MIXMASTER
1363+ ,""
1364+#endif
1365+ ,""
1366+ ,""
1367+ ,"Newsgroups: "
1368+ ,"Followup-To: "
1369+ ,"X-Comment-To: "
1370+#endif
1371 };
1372
1373 static struct mapping_t ComposeHelp[] = {
1374@@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] =
1375 { NULL }
1376 };
1377
1378+#ifdef USE_NNTP
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 },
1387+ { NULL }
1388+};
1389+#endif
1390+
1391 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1392 {
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))
1396 {
1397 if (!msg->security)
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: ");
1406 }
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: ");
1413 else
1414 return;
1415
1416@@ -252,9 +283,28 @@ static void draw_envelope_addr (int line
1417 static void draw_envelope (HEADER *msg, char *fcc)
1418 {
1419 draw_envelope_addr (HDR_FROM, msg->env->from);
1420+#ifdef USE_NNTP
1421+ if (!option (OPTNEWSSEND))
1422+ {
1423+#endif
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);
1427+#ifdef USE_NNTP
1428+ }
1429+ else
1430+ {
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))
1436+ {
1437+ mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1438+ mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1439+ }
1440+ }
1441+#endif
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;
1448 struct stat st;
1449+#ifdef USE_NNTP
1450+ int news = 0; /* is it a news article ? */
1451+
1452+ if (option (OPTNEWSSEND))
1453+ news++;
1454+#endif
1455
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;
1461 menu->data = idx;
1462+#ifdef USE_NNTP
1463+ if (news)
1464+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1465+ else
1466+#endif
1467 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1468
1469 while (loop)
1470 {
1471+#ifdef USE_NNTP
1472+ unset_option (OPTNEWS); /* for any case */
1473+#endif
1474 switch (op = mutt_menuLoop (menu))
1475 {
1476 case OP_REDRAW:
1477@@ -534,17 +598,87 @@ int mutt_compose_menu (HEADER *msg, /*
1478 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1479 break;
1480 case OP_COMPOSE_EDIT_TO:
1481+#ifdef USE_NNTP
1482+ if (news)
1483+ break;
1484+#endif
1485 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1486 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1487 break;
1488 case OP_COMPOSE_EDIT_BCC:
1489+#ifdef USE_NNTP
1490+ if (news)
1491+ break;
1492+#endif
1493 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1494 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1495 break;
1496 case OP_COMPOSE_EDIT_CC:
1497+#ifdef USE_NNTP
1498+ if (news)
1499+ break;
1500+#endif
1501 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1502 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1503 break;
1504+#ifdef USE_NNTP
1505+ case OP_COMPOSE_EDIT_NEWSGROUPS:
1506+ if (news)
1507+ {
1508+ if (msg->env->newsgroups)
1509+ strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1510+ else
1511+ buf[0] = 0;
1512+ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1513+ {
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);
1518+ clrtoeol ();
1519+ if (msg->env->newsgroups)
1520+ printw ("%-*.*s", W, W, msg->env->newsgroups);
1521+ }
1522+ }
1523+ break;
1524+
1525+ case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1526+ if (news)
1527+ {
1528+ buf[0] = 0;
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])
1532+ {
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);
1537+ clrtoeol();
1538+ if (msg->env->followup_to)
1539+ printw ("%-*.*s", W, W, msg->env->followup_to);
1540+ }
1541+ }
1542+ break;
1543+
1544+ case OP_COMPOSE_EDIT_X_COMMENT_TO:
1545+ if (news && option (OPTXCOMMENTTO))
1546+ {
1547+ buf[0] = 0;
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])
1551+ {
1552+ FREE (&msg->env->x_comment_to);
1553+ msg->env->x_comment_to = safe_strdup (buf);
1554+ move (HDR_BCC, HDR_XOFFSET);
1555+ clrtoeol();
1556+ if (msg->env->x_comment_to)
1557+ printw ("%-*.*s", W, W, msg->env->x_comment_to);
1558+ }
1559+ }
1560+ break;
1561+#endif
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, /*
1566 break;
1567
1568 case OP_COMPOSE_ATTACH_MESSAGE:
1569+#ifdef USE_NNTP
1570+ case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1571+#endif
1572 {
1573 char *prompt;
1574 HEADER *h;
1575@@ -714,7 +851,22 @@ int mutt_compose_menu (HEADER *msg, /*
1576 fname[0] = 0;
1577 prompt = _("Open mailbox to attach message from");
1578
1579+#ifdef USE_NNTP
1580+ unset_option (OPTNEWS);
1581+ if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1582+ {
1583+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1584+ break;
1585+
1586+ prompt = _("Open newsgroup to attach message from");
1587+ set_option (OPTNEWS);
1588+ }
1589+#endif
1590+
1591 if (Context)
1592+#ifdef USE_NNTP
1593+ if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1594+#endif
1595 {
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])
1600 break;
1601
1602+#ifdef USE_NNTP
1603+ if (option (OPTNEWS))
1604+ nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1605+ else
1606+#endif
1607 mutt_expand_path (fname, sizeof (fname));
1608 #ifdef USE_IMAP
1609 if (!mx_is_imap (fname))
1610@@ -730,6 +887,9 @@ int mutt_compose_menu (HEADER *msg, /*
1611 #ifdef USE_POP
1612 if (!mx_is_pop (fname))
1613 #endif
1614+#ifdef USE_NNTP
1615+ if (!mx_is_nntp (fname) && !option (OPTNEWS))
1616+#endif
1617 /* check to make sure the file exists and is readable */
1618 if (access (fname, R_OK) == -1)
1619 {
1620diff -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
1623@@ -37,6 +37,9 @@
1624 significant more memory when defined. */
1625 #undef EXACT_ADDRESS
1626
1627+/* Compiling with newsreading support with NNTP */
1628+#undef USE_NNTP
1629+
1630 /* program to use for shell commands */
1631 #undef EXECSHELL
1632
1633diff -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"
1638 fi
1639
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"
1644+ need_socket="yes"
1645+ fi
1646+])
1647+
1648 dnl -- end socket dependencies --
1649
1650 if test "$need_socket" = "yes"
1651diff -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
1654@@ -22,6 +22,7 @@
1655
1656 #include "mutt.h"
1657 #include "mutt_curses.h"
1658+#include "mx.h"
1659 #include "mutt_menu.h"
1660 #include "attach.h"
1661 #include "mailbox.h"
1662@@ -40,6 +41,10 @@
1663
1664 #include "mutt_crypt.h"
1665
1666+#ifdef USE_NNTP
1667+#include "nntp.h"
1668+#endif
1669+
1670
1671 #include <ctype.h>
1672 #include <stdlib.h>
1673@@ -415,12 +420,27 @@ struct mapping_t IndexHelp[] = {
1674 { NULL }
1675 };
1676
1677+#ifdef USE_NNTP
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 },
1687+ { NULL }
1688+};
1689+#endif
1690+
1691 /* This function handles the message index window as well as commands returned
1692 * from the pager (MENU_PAGER).
1693 */
1694 int mutt_index_menu (void)
1695 {
1696 char buf[LONG_STRING], helpstr[SHORT_STRING];
1697+ int flags;
1698 int op = OP_NULL;
1699 int done = 0; /* controls when to exit the "event" loop */
1700 int i = 0, j;
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,
1707+#ifdef USE_NNTP
1708+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1709+#endif
1710+ IndexHelp);
1711
1712 if (!attach_msg)
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 */
1716 }
1717
1718+#ifdef USE_NNTP
1719+ unset_option (OPTNEWS); /* for any case */
1720+#endif
1721 switch (op)
1722 {
1723
1724@@ -744,6 +771,120 @@ int mutt_index_menu (void)
1725 menu_current_bottom (menu);
1726 break;
1727
1728+#ifdef USE_NNTP
1729+ case OP_GET_MESSAGE:
1730+ case OP_GET_PARENT:
1731+ CHECK_MSGCOUNT;
1732+ if (Context->magic == M_NNTP)
1733+ {
1734+ HEADER *h;
1735+
1736+ if (op == OP_GET_MESSAGE)
1737+ {
1738+ buf[0] = 0;
1739+ if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1740+ || !buf[0])
1741+ break;
1742+ }
1743+ else
1744+ {
1745+ LIST *ref = CURHDR->env->references;
1746+ if (!ref)
1747+ {
1748+ mutt_error _("Article has no parent reference!");
1749+ break;
1750+ }
1751+ strfcpy (buf, ref->data, sizeof (buf));
1752+ }
1753+ if (!Context->id_hash)
1754+ Context->id_hash = mutt_make_id_hash (Context);
1755+ if ((h = hash_find (Context->id_hash, buf)))
1756+ {
1757+ if (h->virtual != -1)
1758+ {
1759+ menu->current = h->virtual;
1760+ menu->redraw = REDRAW_MOTION_RESYNCH;
1761+ }
1762+ else if (h->collapsed)
1763+ {
1764+ mutt_uncollapse_thread (Context, h);
1765+ mutt_set_virtual (Context);
1766+ menu->current = h->virtual;
1767+ menu->redraw = REDRAW_MOTION_RESYNCH;
1768+ }
1769+ else
1770+ mutt_error _("Message not visible in limited view.");
1771+ }
1772+ else
1773+ {
1774+ if (nntp_check_msgid (Context, buf) == 0)
1775+ {
1776+ h = Context->hdrs[Context->msgcount-1];
1777+ mutt_sort_headers (Context, 0);
1778+ menu->current = h->virtual;
1779+ menu->redraw = REDRAW_FULL;
1780+ }
1781+ else
1782+ mutt_error (_("Article %s not found on server"), buf);
1783+ }
1784+ }
1785+ break;
1786+
1787+ case OP_GET_CHILDREN:
1788+ case OP_RECONSTRUCT_THREAD:
1789+ CHECK_MSGCOUNT;
1790+ if (Context->magic == M_NNTP)
1791+ {
1792+ HEADER *h;
1793+ int old = CURHDR->index, i;
1794+
1795+ if (!CURHDR->env->message_id)
1796+ {
1797+ mutt_error _("No Message-Id. Unable to perform operation");
1798+ break;
1799+ }
1800+
1801+ if (!Context->id_hash)
1802+ Context->id_hash = mutt_make_id_hash (Context);
1803+ strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1804+
1805+ if (op == OP_RECONSTRUCT_THREAD)
1806+ {
1807+ LIST *ref = CURHDR->env->references;
1808+ while (ref)
1809+ {
1810+ nntp_check_msgid (Context, ref->data);
1811+ /* the last msgid in References is the root message */
1812+ if (!ref->next)
1813+ strfcpy (buf, ref->data, sizeof (buf));
1814+ ref = ref->next;
1815+ }
1816+ }
1817+ mutt_message _("Check for children of message...");
1818+ if (nntp_check_children (Context, buf) == 0)
1819+ {
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 */
1823+ if (h)
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)
1828+ {
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);
1834+ }
1835+ }
1836+ menu->redraw = REDRAW_FULL;
1837+ mutt_clear_error ();
1838+ }
1839+ break;
1840+#endif
1841+
1842 case OP_JUMP:
1843
1844 CHECK_MSGCOUNT;
1845@@ -841,11 +982,33 @@ int mutt_index_menu (void)
1846 break;
1847
1848 case OP_MAIN_LIMIT:
1849+ case OP_TOGGLE_READ:
1850
1851 CHECK_IN_MAILBOX;
1852 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1853 CURHDR->index : -1;
1854- if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1855+ if (op == OP_TOGGLE_READ)
1856+ {
1857+ char buf[LONG_STRING];
1858+
1859+ if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1860+ {
1861+ snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1862+ Context->pattern ? Context->pattern : ".*");
1863+ set_option (OPTHIDEREAD);
1864+ }
1865+ else
1866+ {
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);
1871+ }
1872+ FREE (&Context->pattern);
1873+ Context->pattern = safe_strdup (buf);
1874+ }
1875+ if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1876+ mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1877 {
1878 if (menu->oldcurrent >= 0)
1879 {
1880@@ -1052,20 +1215,43 @@ int mutt_index_menu (void)
1881 break;
1882
1883 case OP_MAIN_CHANGE_FOLDER:
1884-
1885- if (attach_msg)
1886- op = OP_MAIN_CHANGE_FOLDER_READONLY;
1887-
1888- /* fallback to the readonly case */
1889-
1890 case OP_MAIN_CHANGE_FOLDER_READONLY:
1891+#ifdef USE_NNTP
1892+ case OP_MAIN_CHANGE_GROUP:
1893+ case OP_MAIN_CHANGE_GROUP_READONLY:
1894+#endif
1895
1896- if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1897+ if (attach_msg || option (OPTREADONLY) ||
1898+#ifdef USE_NNTP
1899+ op == OP_MAIN_CHANGE_GROUP_READONLY ||
1900+#endif
1901+ op == OP_MAIN_CHANGE_FOLDER_READONLY)
1902+ flags = M_READONLY;
1903+ else
1904+ flags = 0;
1905+
1906+ if (flags)
1907 cp = _("Open mailbox in read-only mode");
1908 else
1909 cp = _("Open mailbox");
1910
1911 buf[0] = '\0';
1912+#ifdef USE_NNTP
1913+ unset_option (OPTNEWS);
1914+ if (op == OP_MAIN_CHANGE_GROUP ||
1915+ op == OP_MAIN_CHANGE_GROUP_READONLY)
1916+ {
1917+ set_option (OPTNEWS);
1918+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1919+ break;
1920+ if (flags)
1921+ cp = _("Open newsgroup in read-only mode");
1922+ else
1923+ cp = _("Open newsgroup");
1924+ nntp_buffy (buf);
1925+ }
1926+ else
1927+#endif
1928 mutt_buffy (buf, sizeof (buf));
1929
1930 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1931@@ -1084,6 +1270,14 @@ int mutt_index_menu (void)
1932 break;
1933 }
1934
1935+#ifdef USE_NNTP
1936+ if (option (OPTNEWS))
1937+ {
1938+ unset_option (OPTNEWS);
1939+ nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1940+ }
1941+ else
1942+#endif
1943 mutt_expand_path (buf, sizeof (buf));
1944 if (mx_get_magic (buf) <= 0)
1945 {
1946@@ -1121,15 +1315,18 @@ int mutt_index_menu (void)
1947 CurrentMenu = MENU_MAIN;
1948 mutt_folder_hook (buf);
1949
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)
1954 {
1955 menu->current = ci_first_message ();
1956 }
1957 else
1958 menu->current = 0;
1959
1960+#ifdef USE_NNTP
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);
1964+#endif
1965 mutt_clear_error ();
1966 mutt_buffy_check(1); /* force the buffy check after we have changed
1967 the folder */
1968@@ -1509,6 +1706,15 @@ int mutt_index_menu (void)
1969 }
1970 #endif
1971
1972+#ifdef USE_NNTP
1973+ if (Context->magic == M_NNTP)
1974+ {
1975+ mutt_flushinp ();
1976+ mutt_error _("Can't change 'important' flag on NNTP server.");
1977+ break;
1978+ }
1979+#endif
1980+
1981 if (tag)
1982 {
1983 for (j = 0; j < Context->vcount; j++)
1984@@ -1856,6 +2062,17 @@ int mutt_index_menu (void)
1985 }
1986 break;
1987
1988+#ifdef USE_NNTP
1989+ case OP_CATCHUP:
1990+ if (Context && Context->magic == M_NNTP)
1991+ {
1992+ if (mutt_newsgroup_catchup (CurrentNewsSrv,
1993+ ((NNTP_DATA *)Context->data)->group))
1994+ menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
1995+ }
1996+ break;
1997+#endif
1998+
1999 case OP_DISPLAY_ADDRESS:
2000
2001 CHECK_MSGCOUNT;
2002@@ -1890,6 +2107,15 @@ int mutt_index_menu (void)
2003 break;
2004 }
2005 #endif
2006+
2007+#ifdef USE_NNTP
2008+ if (Context->magic == M_NNTP)
2009+ {
2010+ mutt_flushinp ();
2011+ mutt_error _("Can't edit message on newsserver.");
2012+ break;
2013+ }
2014+#endif
2015
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)
2019
2020 menu->redraw = REDRAW_FULL;
2021 break;
2022+
2023+#ifdef USE_NNTP
2024+ case OP_POST:
2025+ case OP_FOLLOWUP:
2026+ case OP_FORWARD_TO_GROUP:
2027+
2028+ CHECK_ATTACH;
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)
2032+ {
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)
2036+ break;
2037+ if (op == OP_POST)
2038+ ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2039+ else
2040+ {
2041+ CHECK_MSGCOUNT;
2042+ if (op == OP_FOLLOWUP)
2043+ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2044+ tag ? NULL : CURHDR);
2045+ else
2046+ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2047+ tag ? NULL : CURHDR);
2048+ }
2049+ menu->redraw = REDRAW_FULL;
2050+ break;
2051+ }
2052+#endif
2053
2054 case OP_REPLY:
2055
2056@@ -2136,6 +2393,12 @@ int mutt_index_menu (void)
2057 CHECK_READONLY;
2058 CHECK_IMAP_ACL(IMAP_ACL_DELETE);
2059
2060+#ifdef USE_NNTP
2061+ /* Close all open NNTP connections */
2062+ if (!attach_msg)
2063+ nntp_logout_all ();
2064+#endif
2065+
2066 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2067 op == OP_UNDELETE_THREAD ? 0 : 1);
2068
2069diff -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
2073
2074 </sect2>
2075
2076+<sect2>
2077+<title>Reading news via NNTP</title>
2078+
2079+<para>
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">&dollar;newsrc</link>
2086+variable. Article headers are cached and can be loaded from file when
2087+newsgroup entered instead loading from newsserver.
2088+</para>
2089+
2090+</sect2>
2091+
2092 </sect1>
2093
2094 <sect1 id="forwarding-mail">
2095diff -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
2099 .SH SYNOPSIS
2100 .PP
2101 .B mutt
2102-[-nRyzZ]
2103-[-e \fIcmd\fP] [-F \fIfile\fP] [-m \fItype\fP] [-f \fIfile\fP]
2104+[-GnRyzZ]
2105+[-e \fIcmd\fP] [-F \fIfile\fP] [-g \fIserver\fP] [-m \fItype\fP] [-f \fIfile\fP]
2106 .PP
2107 .B mutt
2108 [-nx]
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.
2115+.IP "-G"
2116+Start Mutt with a listing of subscribed newsgroups.
2117 .IP "-h"
2118 Display help.
2119 .IP "-H \fIdraft\fP"
2120diff -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" },
2127+#ifdef USE_NNTP
2128+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2129+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2130+#endif
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" },
2139+#ifdef USE_NNTP
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 },
2146+#endif
2147+ { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2148 { "group-reply", OP_GROUP_REPLY, "g" },
2149 #ifdef USE_POP
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" },
2155+#ifdef USE_NNTP
2156+ { "post-message", OP_POST, "P" },
2157+#endif
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" },
2166+#ifdef USE_NNTP
2167+ { "catchup", OP_CATCHUP, "y" },
2168+#endif
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 },
2178
2179
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" },
2185+#ifdef USE_NNTP
2186+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2187+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2188+#endif
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" },
2196+#ifdef USE_NNTP
2197+ { "followup-message", OP_FOLLOWUP, "F" },
2198+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2199+#endif
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" },
2204 #ifdef USE_IMAP
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" },
2210+#ifdef USE_NNTP
2211+ { "post-message", OP_POST, "P" },
2212+#endif
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 },
2222
2223
2224
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" },
2229+#ifdef USE_NNTP
2230+ { "followup-message", OP_FOLLOWUP, "F" },
2231+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2232+#endif
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" },
2248+#ifdef USE_NNTP
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" },
2252+#endif
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" },
2260+#ifdef USE_NNTP
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" },
2266+#endif
2267 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2268 { "buffy-list", OP_BUFFY_LIST, "." },
2269 #ifdef USE_IMAP
2270 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2271 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2272 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2273+#endif
2274+#if defined USE_IMAP || defined USE_NNTP
2275 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2276 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2277+#endif
2278+#ifdef USE_IMAP
2279 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2280 #endif
2281 { NULL, 0, NULL }
2282diff -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;
2286 #endif
2287
2288 WHERE char *Muttrc INITVAL (NULL);
2289+#ifdef USE_NNTP
2290+WHERE char *NewsCacheDir;
2291+WHERE char *GroupFormat;
2292+WHERE char *Inews;
2293+WHERE char *NewsServer;
2294+WHERE char *NntpUser;
2295+WHERE char *NntpPass;
2296+WHERE char *NewsRc;
2297+#endif
2298 WHERE char *Outbox;
2299 WHERE char *Pager;
2300 WHERE char *PagerFmt;
2301@@ -183,6 +192,11 @@ extern unsigned char QuadOptions[];
2302
2303 WHERE unsigned short Counter INITVAL (0);
2304
2305+#ifdef USE_NNTP
2306+WHERE short NewsPollTimeout;
2307+WHERE short NntpContext;
2308+#endif
2309+
2310 WHERE short ConnectTimeout;
2311 WHERE short HistSize;
2312 WHERE short MenuContext;
2313diff -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)
2317 if (nelem == 0)
2318 nelem = 2;
2319 table->nelem = nelem;
2320+ table->curnelem = 0;
2321 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2322 return table;
2323 }
2324
2325+HASH *hash_resize (HASH *ptr, int nelem)
2326+{
2327+ HASH *table;
2328+ struct hash_elem *elem, *tmp;
2329+ int i;
2330+
2331+ table = hash_create (nelem);
2332+
2333+ for (i = 0; i < ptr->nelem; i++)
2334+ {
2335+ for (elem = ptr->table[i]; elem; )
2336+ {
2337+ tmp = elem;
2338+ elem = elem->next;
2339+ hash_insert (table, tmp->key, tmp->data, 1);
2340+ FREE (&tmp);
2341+ }
2342+ }
2343+ FREE (&ptr->table);
2344+ FREE (&ptr);
2345+
2346+ return table;
2347+}
2348+
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
2353 {
2354 ptr->next = table->table[h];
2355 table->table[h] = ptr;
2356+ table->curnelem++;
2357 }
2358 else
2359 {
2360@@ -96,6 +122,7 @@ int hash_insert (HASH * table, const cha
2361 else
2362 table->table[h] = ptr;
2363 ptr->next = tmp;
2364+ table->curnelem++;
2365 }
2366 return h;
2367 }
2368@@ -126,6 +153,7 @@ void hash_delete_hash (HASH * table, int
2369 if (destroy)
2370 destroy (ptr->data);
2371 FREE (&ptr);
2372+ table->curnelem--;
2373
2374 ptr = *last;
2375 }
2376diff -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
2380
2381 typedef struct
2382 {
2383- int nelem;
2384+ int nelem, curnelem;
2385 struct hash_elem **table;
2386 }
2387 HASH;
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 *));
2396diff -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)
2404 * %i = message-id
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)
2408 * %T = $to_chars
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,
2416
2417 break;
2418
2419+#ifdef USE_NNTP
2420+ case 'g':
2421+ mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2422+ break;
2423+#endif
2424+
2425 case 'i':
2426 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2427 break;
2428@@ -631,6 +639,13 @@ hdr_format_str (char *dest,
2429 mutt_format_s (dest, destlen, prefix, buf2);
2430 break;
2431
2432+ case 'W':
2433+ if (!optional)
2434+ mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2435+ else if (!hdr->env->organization)
2436+ optional = 0;
2437+ break;
2438+
2439 case 'Z':
2440
2441 ch = ' ';
2442diff -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;
2447
2448 if (!msg->env->in_reply_to)
2449+#ifdef USE_NNTP
2450+ if (!option (OPTNEWSSEND))
2451+#endif
2452 mutt_free_list (&msg->env->references);
2453
2454 mutt_expand_aliases_env (msg->env);
2455diff -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
2459 else
2460 Fqdn = safe_strdup(NONULL(Hostname));
2461
2462+#ifdef USE_NNTP
2463+ {
2464+ FILE *f;
2465+ char *i;
2466+
2467+ if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2468+ {
2469+ buffer[0] = '\0';
2470+ fgets (buffer, sizeof (buffer), f);
2471+ p = &buffer;
2472+ SKIPWS (p);
2473+ i = p;
2474+ while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2475+ *i = '\0';
2476+ NewsServer = safe_strdup (p);
2477+ fclose (f);
2478+ }
2479+ }
2480+ if ((p = getenv ("NNTPSERVER")))
2481+ NewsServer = safe_strdup (p);
2482+#endif
2483+
2484 if ((p = getenv ("MAIL")))
2485 Spoolfile = safe_strdup (p);
2486 else if ((p = getenv ("MAILDIR")))
2487diff -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.
2493 */
2494+#ifdef USE_NNTP
2495+ { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2496+ /*
2497+ ** .pp
2498+ ** If set, Mutt will prompt you for follow-up groups before editing
2499+ ** the body of an outgoing message.
2500+ */
2501+ { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2502+ /*
2503+ ** .pp
2504+ ** If set, Mutt will prompt you for x-comment-to field before editing
2505+ ** the body of an outgoing message.
2506+ */
2507+#endif
2508 { "attach_format", DT_STR, R_NONE, UL &AttachFormat, UL "%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] " },
2509 /*
2510 ** .pp
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.
2514 */
2515+#ifdef USE_NNTP
2516+ { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2517+ /*
2518+ ** .pp
2519+ ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2520+ ** as read when you quit the newsgroup (catchup newsgroup).
2521+ */
2522+#endif
2523 { "charset", DT_STR, R_NONE, UL &Charset, UL 0 },
2524 /*
2525 ** .pp
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.
2529 */
2530+#ifdef USE_NNTP
2531+ { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2532+ /*
2533+ ** .pp
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.
2538+ */
2539+#endif
2540 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2541 /*
2542 ** .pp
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".
2546 */
2547+#ifdef USE_NNTP
2548+ { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2549+ /*
2550+ ** .pp
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:
2554+ ** .pp
2555+ ** .ts
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"
2565+ ** .te
2566+ */
2567+#endif
2568 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2569 /*
2570 */
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[] = {
2588 ** .pp
2589 ** See also: ``$$to_chars''.
2590 */
2591+#ifdef USE_NNTP
2592+ { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2593+ /*
2594+ ** .pp
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:
2598+ ** .pp
2599+ ** .ts
2600+ ** %s newsserver name
2601+ ** .te
2602+ ** .pp
2603+ ** Example: set inews="/usr/local/bin/inews -hS"
2604+ */
2605+#endif
2606 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2607 /*
2608 ** .pp
2609@@ -1252,6 +1322,16 @@ struct option_t MuttVars[] = {
2610 ** be attached to the newly composed message if this option is set.
2611 */
2612
2613+#ifdef USE_NNTP
2614+ { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2615+ /*
2616+ ** .pp
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.
2620+ */
2621+#endif
2622+
2623 #ifdef MIXMASTER
2624 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2625 /*
2626@@ -1322,6 +1402,77 @@ struct option_t MuttVars[] = {
2627 ** See also ``$$read_inc'' and ``$$write_inc''.
2628 */
2629 #endif
2630+#ifdef USE_NNTP
2631+ { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2632+ /*
2633+ ** .pp
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.
2637+ */
2638+ { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2639+ /*
2640+ ** .pp
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:
2645+ ** .pp
2646+ ** [nntp[s]://][username[:password]@]newsserver[:port]
2647+ */
2648+ { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2649+ /*
2650+ ** .pp
2651+ ** The file, containing info about subscribed newsgroups - names and
2652+ ** indexes of read articles. The following printf-style sequence
2653+ ** is understood:
2654+ ** .pp
2655+ ** .ts
2656+ ** %s newsserver name
2657+ ** .te
2658+ */
2659+ { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2660+ /*
2661+ ** .pp
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.
2666+ */
2667+ { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2668+ /*
2669+ ** .pp
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).
2673+ */
2674+ { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2675+ /*
2676+ ** .pp
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.
2680+ */
2681+ { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2682+ /*
2683+ ** .pp
2684+ ** Your password for NNTP account.
2685+ */
2686+ { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2687+ /*
2688+ ** .pp
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,
2692+ ** etc.).
2693+ */
2694+ { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2695+ /*
2696+ ** .pp
2697+ ** Controls whether or not Mutt will try to reconnect to newsserver when
2698+ ** connection lost.
2699+ */
2700+#endif
2701 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2702 /*
2703 ** .pp
2704@@ -2132,6 +2283,16 @@ struct option_t MuttVars[] = {
2705 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2706 /*
2707 */
2708+#ifdef USE_NNTP
2709+ { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2710+ /*
2711+ ** .pp
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.
2716+ */
2717+#endif
2718 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2719 /*
2720 ** .pp
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.
2724 */
2725+#ifdef USE_NNTP
2726+ { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2727+ /*
2728+ ** .pp
2729+ ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2730+ ** ``newsrc'' file and into cache.
2731+ */
2732+ { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2733+ /*
2734+ ** .pp
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.
2739+ */
2740+ { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2741+ /*
2742+ ** .pp
2743+ ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2744+ ** will be displayed in browser.
2745+ */
2746+#endif
2747 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2748 /*
2749 ** .pp
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.
2753 */
2754+#ifdef USE_NNTP
2755+ { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2756+ /*
2757+ ** .pp
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.
2760+ */
2761+#endif
2762 /*--*/
2763 { NULL }
2764 };
2765diff -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);
2770
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);
2776diff -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 *);
2780 #ifdef USE_POP
2781 int mx_is_pop (const char *);
2782 #endif
2783+#ifdef USE_NNTP
2784+int mx_is_nntp (const char *);
2785+#endif
2786
2787 int mx_access (const char*, int);
2788 int mx_check_empty (const char *);
2789diff -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
2792@@ -56,6 +56,10 @@
2793 #include <stringprep.h>
2794 #endif
2795
2796+#ifdef USE_NNTP
2797+#include <nntp.h>
2798+#endif
2799+
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)
2813 "-USE_POP "
2814 #endif
2815
2816+#ifdef USE_NNTP
2817+ "+USE_NNTP "
2818+#else
2819+ "-USE_NNTP "
2820+#endif
2821+
2822 #ifdef USE_IMAP
2823 "+USE_IMAP "
2824 #else
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 */
2829+#ifdef USE_NNTP
2830+#define M_NEWS (1<<5) /* -g and -G */
2831+#endif
2832
2833 int main (int argc, char **argv)
2834 {
2835@@ -566,7 +581,11 @@ int main (int argc, char **argv)
2836 memset (Options, 0, sizeof (Options));
2837 memset (QuadOptions, 0, sizeof (QuadOptions));
2838
2839+#ifdef USE_NNTP
2840+ while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2841+#else
2842 while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2843+#endif
2844 switch (i)
2845 {
2846 case 'A':
2847@@ -659,6 +678,20 @@ int main (int argc, char **argv)
2848 flags |= M_SELECT;
2849 break;
2850
2851+#ifdef USE_NNTP
2852+ case 'g': /* Specify a newsserver */
2853+ {
2854+ char buf[LONG_STRING];
2855+
2856+ snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2857+ commands = mutt_add_list (commands, buf);
2858+ }
2859+
2860+ case 'G': /* List of newsgroups */
2861+ flags |= M_SELECT | M_NEWS;
2862+ break;
2863+#endif
2864+
2865 case 'z':
2866 flags |= M_IGNORE;
2867 break;
2868@@ -921,6 +954,18 @@ int main (int argc, char **argv)
2869 }
2870 else if (flags & M_SELECT)
2871 {
2872+#ifdef USE_NNTP
2873+ if (flags & M_NEWS)
2874+ {
2875+ set_option (OPTNEWS);
2876+ if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2877+ {
2878+ mutt_endwin (Errorbuf);
2879+ exit (1);
2880+ }
2881+ }
2882+ else
2883+#endif
2884 if (!Incoming) {
2885 mutt_endwin _("No incoming mailboxes defined.");
2886 exit (1);
2887@@ -936,6 +981,15 @@ int main (int argc, char **argv)
2888
2889 if (!folder[0])
2890 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2891+
2892+#ifdef USE_NNTP
2893+ if (option (OPTNEWS))
2894+ {
2895+ unset_option (OPTNEWS);
2896+ nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2897+ }
2898+ else
2899+#endif
2900 mutt_expand_path (folder, sizeof (folder));
2901
2902 mutt_str_replace (&CurrentFolder, folder);
2903diff -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
2907 M_PGP_KEY,
2908 M_XLABEL,
2909 M_MIMEATTACH,
2910+#ifdef USE_NNTP
2911+ M_NEWSGROUPS,
2912+#endif
2913
2914 /* Options for Mailcap lookup */
2915 M_EDIT,
2916@@ -295,6 +298,12 @@ enum
2917 #endif
2918 OPT_SUBJECT,
2919 OPT_VERIFYSIG, /* verify PGP signatures */
2920+#ifdef USE_NNTP
2921+ OPT_TOMODERATED,
2922+ OPT_NNTPRECONNECT,
2923+ OPT_CATCHUP,
2924+ OPT_FOLLOWUPTOPOSTER,
2925+#endif /* USE_NNTP */
2926
2927 /* THIS MUST BE THE LAST VALUE. */
2928 OPT_MAX
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)
2934
2935 /* flags to _mutt_select_file() */
2936 #define M_SEL_BUFFY (1<<0)
2937@@ -329,6 +339,8 @@ enum
2938 OPTASCIICHARS,
2939 OPTASKBCC,
2940 OPTASKCC,
2941+ OPTASKFOLLOWUP,
2942+ OPTASKXCOMMENTTO,
2943 OPTATTACHSPLIT,
2944 OPTAUTOEDIT,
2945 OPTAUTOTAG,
2946@@ -399,6 +411,9 @@ enum
2947 OPTMETOO,
2948 OPTMHPURGE,
2949 OPTMIMEFORWDECODE,
2950+#ifdef USE_NNTP
2951+ OPTMIMESUBJECT, /* encode subject line with RFC2047 */
2952+#endif
2953 OPTNARROWTREE,
2954 OPTPAGERSTOP,
2955 OPTPIPEDECODE,
2956@@ -479,6 +494,16 @@ enum
2957 OPTPGPAUTOINLINE,
2958 OPTPGPREPLYINLINE,
2959
2960+ /* news options */
2961+
2962+#ifdef USE_NNTP
2963+ OPTSHOWNEWNEWS,
2964+ OPTSHOWONLYUNREAD,
2965+ OPTSAVEUNSUB,
2966+ OPTLOADDESC,
2967+ OPTXCOMMENTTO,
2968+#endif /* USE_NNTP */
2969+
2970 /* pseudo options */
2971
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
2980 * external program.
2981@@ -509,6 +535,12 @@ enum
2982 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
2983 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
2984
2985+#ifdef USE_NNTP
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 */
2989+#endif
2990+
2991 OPTMAX
2992 };
2993
2994@@ -586,6 +618,13 @@ typedef struct envelope
2995 char *supersedes;
2996 char *date;
2997 char *x_label;
2998+ char *organization;
2999+#ifdef USE_NNTP
3000+ char *newsgroups;
3001+ char *xref;
3002+ char *followup_to;
3003+ char *x_comment_to;
3004+#endif
3005 BUFFER *spam;
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 */
3011 char *path;
3012+#ifdef USE_NNTP
3013+ int article_num;
3014+#endif
3015
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 */
3020 #endif
3021
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 */
3025 #endif
3026
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 */
3035
3036diff -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)
3040 #ifdef MIXMASTER
3041 mutt_free_list (&(*h)->chain);
3042 #endif
3043-#if defined USE_POP || defined USE_IMAP
3044+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3045 FREE (&(*h)->data);
3046 #endif
3047 FREE (h); /* __FREE_CHECKED__ */
3048@@ -671,6 +671,13 @@ void mutt_free_envelope (ENVELOPE **p)
3049 FREE (&(*p)->supersedes);
3050 FREE (&(*p)->date);
3051 FREE (&(*p)->x_label);
3052+ FREE (&(*p)->organization);
3053+#ifdef USE_NNTP
3054+ FREE (&(*p)->newsgroups);
3055+ FREE (&(*p)->xref);
3056+ FREE (&(*p)->followup_to);
3057+ FREE (&(*p)->x_comment_to);
3058+#endif
3059
3060 mutt_buffer_free (&(*p)->spam);
3061
3062@@ -1275,6 +1282,14 @@ int mutt_save_confirm (const char *s, st
3063 }
3064 }
3065
3066+#ifdef USE_NNTP
3067+ if (magic == M_NNTP)
3068+ {
3069+ mutt_error _("Can't save message to newsserver.");
3070+ return 0;
3071+ }
3072+#endif
3073+
3074 if (stat (s, st) != -1)
3075 {
3076 if (magic == -1)
3077diff -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
3080@@ -38,6 +38,10 @@
3081 #include "pop.h"
3082 #endif
3083
3084+#ifdef USE_NNTP
3085+#include "nntp.h"
3086+#endif
3087+
3088 #ifdef BUFFY_SIZE
3089 #include "buffy.h"
3090 #endif
3091@@ -352,6 +356,22 @@ int mx_is_pop (const char *p)
3092 }
3093 #endif
3094
3095+#ifdef USE_NNTP
3096+int mx_is_nntp (const char *p)
3097+{
3098+ url_scheme_t scheme;
3099+
3100+ if (!p)
3101+ return 0;
3102+
3103+ scheme = url_check_scheme (p);
3104+ if (scheme == U_NNTP || scheme == U_NNTPS)
3105+ return 1;
3106+
3107+ return 0;
3108+}
3109+#endif
3110+
3111 int mx_get_magic (const char *path)
3112 {
3113 struct stat st;
3114@@ -369,6 +389,11 @@ int mx_get_magic (const char *path)
3115 return M_POP;
3116 #endif /* USE_POP */
3117
3118+#ifdef USE_NNTP
3119+ if (mx_is_nntp (path))
3120+ return M_NNTP;
3121+#endif /* USE_NNTP */
3122+
3123 if (stat (path, &st) == -1)
3124 {
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
3127 break;
3128 #endif /* USE_POP */
3129
3130+#ifdef USE_NNTP
3131+ case M_NNTP:
3132+ rc = nntp_open_mailbox (ctx);
3133+ break;
3134+#endif /* USE_NNTP */
3135+
3136 default:
3137 rc = -1;
3138 break;
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 */
3143+#ifdef USE_NNTP
3144+ if (ctx->magic == M_NNTP)
3145+ nntp_fastclose_mailbox (ctx);
3146+#endif /* USE_NNTP */
3147 if (ctx->subj_hash)
3148 hash_destroy (&ctx->subj_hash, NULL);
3149 if (ctx->id_hash)
3150@@ -805,6 +840,12 @@ static int sync_mailbox (CONTEXT *ctx, i
3151 rc = pop_sync_mailbox (ctx, index_hint);
3152 break;
3153 #endif /* USE_POP */
3154+
3155+#ifdef USE_NNTP
3156+ case M_NNTP:
3157+ rc = nntp_sync_mailbox (ctx);
3158+ break;
3159+#endif /* USE_NNTP */
3160 }
3161
3162 #if 0
3163@@ -833,6 +874,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
3164
3165 ctx->closing = 1;
3166
3167+#ifdef USE_NNTP
3168+ if (ctx->magic == M_NNTP)
3169+ {
3170+ int ret;
3171+
3172+ ret = nntp_close_mailbox (ctx);
3173+ mx_fastclose_mailbox (ctx);
3174+ return ret;
3175+ }
3176+#endif
3177 if (ctx->readonly || ctx->dontwrite)
3178 {
3179 /* mailbox is readonly or we don't want to write */
3180@@ -1370,6 +1421,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
3181 case M_POP:
3182 return (pop_check_mailbox (ctx, index_hint));
3183 #endif /* USE_POP */
3184+
3185+#ifdef USE_NNTP
3186+ case M_NNTP:
3187+ return (nntp_check_mailbox (ctx));
3188+#endif /* USE_NNTP */
3189 }
3190 }
3191
3192@@ -1430,6 +1486,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
3193 }
3194 #endif /* USE_POP */
3195
3196+#ifdef USE_NNTP
3197+ case M_NNTP:
3198+ {
3199+ if (nntp_fetch_message (msg, ctx, msgno) != 0)
3200+ FREE (&msg);
3201+ break;
3202+ }
3203+#endif /* USE_NNTP */
3204+
3205 default:
3206 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3207 FREE (&msg);
3208@@ -1511,6 +1576,9 @@ int mx_close_message (MESSAGE **msg)
3209 #ifdef USE_POP
3210 || (*msg)->magic == M_POP
3211 #endif
3212+#ifdef USE_NNTP
3213+ || (*msg)->magic == M_NNTP
3214+#endif
3215 )
3216 {
3217 r = safe_fclose (&(*msg)->fp);
3218diff -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
3222 #ifdef USE_POP
3223 , M_POP
3224 #endif
3225+#ifdef USE_NNTP
3226+ , M_NNTP
3227+#endif
3228 };
3229
3230 WHERE short DefaultMagic INITVAL (M_MBOX);
3231diff -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
3234@@ -0,0 +1,1170 @@
3235+/*
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>
3239+ *
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.
3244+ *
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.
3249+ *
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.
3253+ */
3254+
3255+#if HAVE_CONFIG_H
3256+# include "config.h"
3257+#endif
3258+
3259+#include "mutt.h"
3260+#include "mutt_curses.h"
3261+#include "sort.h"
3262+#include "mx.h"
3263+#include "mime.h"
3264+#include "mailbox.h"
3265+#include "nntp.h"
3266+#include "rfc822.h"
3267+#include "rfc1524.h"
3268+#include "rfc2047.h"
3269+
3270+#include <unistd.h>
3271+#include <string.h>
3272+#include <ctype.h>
3273+#include <stdlib.h>
3274+#include <sys/stat.h>
3275+
3276+void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3277+{
3278+ LIST *l;
3279+
3280+ if (!s || !d)
3281+ return;
3282+
3283+ l = safe_calloc (1, sizeof (LIST));
3284+ if (s->list)
3285+ s->tail->next = l;
3286+ else
3287+ s->list = l;
3288+ s->tail = l;
3289+ l->data = (void *) d;
3290+}
3291+
3292+static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3293+{
3294+ NNTP_DATA *data;
3295+ char group[LONG_STRING];
3296+ int x = 1;
3297+ char *p = line, *b, *h;
3298+ size_t len;
3299+
3300+ while (*p)
3301+ {
3302+ if (*p++ == ',')
3303+ x++;
3304+ }
3305+
3306+ p = line;
3307+ while (*p && (*p != ':' && *p != '!')) p++;
3308+ if (!*p)
3309+ return -1;
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)
3315+ {
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);
3325+ }
3326+ else
3327+ FREE ((void **) &data->entries);
3328+
3329+ data->rc = 1;
3330+ data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3331+ data->max = x*2;
3332+
3333+ if (*p == ':')
3334+ data->subscribed = 1;
3335+ else
3336+ data->subscribed = 0;
3337+
3338+ p++;
3339+ b = p;
3340+ x = 0;
3341+ while (*b)
3342+ {
3343+ while (*p && *p != ',' && *p != '\n') p++;
3344+ if (*p)
3345+ {
3346+ *p = '\0';
3347+ p++;
3348+ }
3349+ if ((h = strchr(b, '-')))
3350+ {
3351+ *h = '\0';
3352+ h++;
3353+ data->entries[x].first = atoi(b);
3354+ data->entries[x].last = atoi(h);
3355+ }
3356+ else
3357+ {
3358+ data->entries[x].first = atoi(b);
3359+ data->entries[x].last = data->entries[x].first;
3360+ }
3361+ b = p;
3362+ if (data->entries[x].last != 0)
3363+ x++;
3364+ }
3365+ if (x && !data->lastMessage)
3366+ data->lastMessage = data->entries[x-1].last;
3367+ data->num = x;
3368+ mutt_newsgroup_stat (data);
3369+ dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3370+
3371+ return 0;
3372+}
3373+
3374+static int slurp_newsrc (NNTP_SERVER *news)
3375+{
3376+ FILE *fp;
3377+ char *buf;
3378+ struct stat sb;
3379+
3380+ news->stat = stat (news->newsrc, &sb);
3381+ news->size = sb.st_size;
3382+ news->mtime = sb.st_mtime;
3383+
3384+ if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3385+ return -1;
3386+ /* hmm, should we use dotlock? */
3387+ if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3388+ {
3389+ fclose (fp);
3390+ return -1;
3391+ }
3392+
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);
3396+ FREE (&buf);
3397+
3398+ mx_unlock_file (news->newsrc, fileno (fp), 0);
3399+ fclose (fp);
3400+ return 0;
3401+}
3402+
3403+void nntp_cache_expand (char *dst, const char *src)
3404+{
3405+ snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3406+ mutt_expand_path (dst, _POSIX_PATH_MAX);
3407+}
3408+
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)
3412+{
3413+ struct stat st;
3414+ char buf[HUGE_STRING], *cp;
3415+ char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3416+ FILE *index;
3417+ NNTP_DATA *data;
3418+ int l, m, t;
3419+
3420+ /* check is server name defined or not */
3421+ if (!news || !news->conn || !news->conn->account.host)
3422+ return -1;
3423+ unset_option (OPTNEWSCACHE);
3424+ if (!NewsCacheDir || !*NewsCacheDir)
3425+ return 0;
3426+
3427+ strfcpy (dir, NewsCacheDir, sizeof (dir));
3428+ mutt_expand_path (dir, sizeof(dir));
3429+
3430+ if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3431+ {
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+
3434+ S_IRWXO)))
3435+ {
3436+ mutt_error _("Cache directory not created!");
3437+ return -1;
3438+ }
3439+ mutt_clear_error();
3440+ }
3441+
3442+ set_option (OPTNEWSCACHE);
3443+
3444+ FREE (&news->cache);
3445+ snprintf (buf, sizeof(buf), "%s/.index", dir);
3446+ if (!(index = safe_fopen (buf, "a+")))
3447+ return 0;
3448+ rewind (index);
3449+ while (fgets (buf, sizeof(buf), index))
3450+ {
3451+ buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3452+ if (!mutt_strncmp (buf, "#: ", 3) &&
3453+ !mutt_strcasecmp (buf+3, news->conn->account.host))
3454+ break;
3455+ }
3456+ while (fgets (buf, sizeof(buf), index))
3457+ {
3458+ cp = buf;
3459+ while (*cp && *cp != ' ') cp++;
3460+ if (!*cp) continue;
3461+ cp[0] = 0;
3462+ if (!mutt_strcmp (buf, "#:"))
3463+ break;
3464+ sscanf (cp + 1, "%s %d %d", file, &l, &m);
3465+ if (!mutt_strcmp (buf, "ALL"))
3466+ {
3467+ news->cache = safe_strdup (file);
3468+ news->newgroups_time = m;
3469+ }
3470+ else if (news->newsgroups)
3471+ {
3472+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3473+ {
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);
3483+ }
3484+ data->cache = safe_strdup (file);
3485+ t = 0;
3486+ if (!data->firstMessage || data->lastMessage < m)
3487+ t = 1;
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);
3495+ }
3496+ }
3497+ fclose (index);
3498+ return 0;
3499+}
3500+
3501+const char *
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)
3505+{
3506+ char fn[SHORT_STRING], tmp[SHORT_STRING];
3507+
3508+ switch (op)
3509+ {
3510+ case 's':
3511+ strncpy (fn, NewsServer, sizeof(fn) - 1);
3512+ mutt_strlower (fn);
3513+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3514+ snprintf (dest, destlen, tmp, fn);
3515+ break;
3516+ }
3517+ return (src);
3518+}
3519+
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)
3524+{
3525+ ciss_url_t url;
3526+ char *c;
3527+ int ret = -1;
3528+
3529+ /* Defaults */
3530+ acct->flags = 0;
3531+ acct->port = NNTP_PORT;
3532+ acct->type = M_ACCT_TYPE_NNTP;
3533+
3534+ c = safe_strdup (server);
3535+ url_parse_ciss (&url, c);
3536+
3537+ if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3538+ {
3539+ if (url.scheme == U_NNTPS)
3540+ {
3541+ acct->flags |= M_ACCT_SSL;
3542+ acct->port = NNTP_SSL_PORT;
3543+ }
3544+
3545+ *group = '\0';
3546+ if (url.path)
3547+ strfcpy (group, url.path, group_len);
3548+
3549+ ret = mutt_account_fromurl (acct, &url);
3550+ }
3551+
3552+ FREE (&c);
3553+ return ret;
3554+}
3555+
3556+void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3557+{
3558+ ciss_url_t url;
3559+
3560+ url.path = safe_strdup (line);
3561+ mutt_account_tourl (acct, &url);
3562+ url_ciss_tostring (&url, line, len, 0);
3563+ FREE (&url.path);
3564+}
3565+
3566+/*
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.
3571+ *
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.
3575+ */
3576+NNTP_SERVER *mutt_select_newsserver (char *server)
3577+{
3578+ char file[_POSIX_PATH_MAX];
3579+ char *buf, *p;
3580+ LIST *list;
3581+ ACCOUNT acct;
3582+ NNTP_SERVER *serv;
3583+ CONNECTION *conn;
3584+
3585+ if (!server || !*server)
3586+ {
3587+ mutt_error _("No newsserver defined!");
3588+ return NULL;
3589+ }
3590+
3591+ buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3592+ if (url_check_scheme (server) == U_UNKNOWN)
3593+ {
3594+ strcpy (buf, "nntp://");
3595+ p = strchr (buf, '\0');
3596+ }
3597+ strcpy (p, server);
3598+
3599+ if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3600+ {
3601+ FREE (&buf);
3602+ mutt_error (_("%s is an invalid newsserver specification!"), server);
3603+ return NULL;
3604+ }
3605+ FREE (&buf);
3606+
3607+ conn = mutt_conn_find (NULL, &acct);
3608+ if (!conn)
3609+ return NULL;
3610+
3611+ mutt_FormatString (file, sizeof (file), NONULL (NewsRc), nntp_format_str, 0, 0);
3612+ mutt_expand_path (file, sizeof (file));
3613+
3614+ serv = (NNTP_SERVER *)conn->data;
3615+ if (serv)
3616+ {
3617+ struct stat sb;
3618+
3619+ /* externally modified? */
3620+ if (serv->stat != stat (file, &sb) || (!serv->stat &&
3621+ (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3622+ {
3623+ for (list = serv->list; list; list = list->next)
3624+ {
3625+ NNTP_DATA *data = (NNTP_DATA *) list->data;
3626+
3627+ if (data)
3628+ {
3629+ data->subscribed = 0;
3630+ data->rc = 0;
3631+ data->num = 0;
3632+ }
3633+ }
3634+ slurp_newsrc (serv);
3635+ nntp_clear_cacheindex (serv);
3636+ }
3637+
3638+ if (serv->status == NNTP_BYE)
3639+ serv->status = NNTP_NONE;
3640+ nntp_check_newgroups (serv, 0);
3641+ return serv;
3642+ }
3643+
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)
3654+ {
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);
3661+ FREE (&serv);
3662+ return NULL;
3663+ }
3664+ nntp_clear_cacheindex (serv);
3665+ conn->data = (void *)serv;
3666+
3667+ return serv;
3668+}
3669+
3670+/*
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
3679+ */
3680+void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3681+{
3682+ NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3683+ int x;
3684+
3685+ if (group)
3686+ data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3687+
3688+ if (!data)
3689+ {
3690+#ifdef DEBUG
3691+ if (group)
3692+ dprint (3, (debugfile, "newsgroup %s not found\n", group));
3693+#endif
3694+ return;
3695+ }
3696+
3697+ for (x = 0; x < data->num; x++)
3698+ {
3699+ if ((article >= data->entries[x].first) &&
3700+ (article <= data->entries[x].last))
3701+ {
3702+ /* we cannot use mutt_set_flag() because mx_update_context()
3703+ didn't called yet */
3704+ h->read = 1;
3705+ return;
3706+ }
3707+ }
3708+ /* If article was not cached yet, it is new! :) */
3709+ if (!data->cache || article > data->lastCached)
3710+ return;
3711+ /* Old articles are articles which aren't read but an article after them
3712+ * has been cached */
3713+ if (option (OPTMARKOLD))
3714+ h->old = 1;
3715+}
3716+
3717+void mutt_newsgroup_stat (NNTP_DATA *data)
3718+{
3719+ int i;
3720+ unsigned int first, last;
3721+
3722+ data->unread = 0;
3723+ if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3724+ return;
3725+
3726+ data->unread = data->lastMessage - data->firstMessage + 1;
3727+ for (i = 0; i < data->num; i++)
3728+ {
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;
3737+ }
3738+}
3739+
3740+static int puti (char *line, int num)
3741+{
3742+ char *p, s[32];
3743+
3744+ for (p = s; num; )
3745+ {
3746+ *p++ = '0' + num % 10;
3747+ num /= 10;
3748+ }
3749+ while (p > s)
3750+ *line++ = *--p, num++;
3751+ *line = '\0';
3752+ return num;
3753+}
3754+
3755+static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3756+{
3757+ char *line = *pline;
3758+ size_t len = *buflen - (*pline - *buf);
3759+ int x, i;
3760+
3761+ if (len < LONG_STRING * 10)
3762+ {
3763+ len += *buflen;
3764+ *buflen *= 2;
3765+ line = *buf;
3766+ safe_realloc (buf, *buflen);
3767+ line = *buf + (*pline - line);
3768+ }
3769+ strcpy (line, data->group);
3770+ len -= strlen (line) + 1;
3771+ line += strlen (line);
3772+ *line++ = data->subscribed ? ':' : '!';
3773+ *line++ = ' ';
3774+ *line = '\0';
3775+
3776+ for (x = 0; x < data->num; x++)
3777+ {
3778+ if (len < LONG_STRING)
3779+ {
3780+ len += *buflen;
3781+ *buflen *= 2;
3782+ *pline = line;
3783+ line = *buf;
3784+ safe_realloc (buf, *buflen);
3785+ line = *buf + (*pline - line);
3786+ }
3787+ if (x)
3788+ {
3789+ *line++ = ',';
3790+ len--;
3791+ }
3792+
3793+#if 0
3794+ if (data->entries[x].first == data->entries[x].last)
3795+ snprintf (line, len, "%d%n", data->entries[x].first, &i);
3796+ else
3797+ snprintf (line, len, "%d-%d%n",
3798+ data->entries[x].first, data->entries[x].last, &i);
3799+ len -= i;
3800+ line += i;
3801+#else
3802+ i = puti (line, data->entries[x].first);
3803+ line +=i; len -= i;
3804+ if (data->entries[x].first != data->entries[x].last)
3805+ {
3806+ *line++ = '-';
3807+ len--;
3808+ i = puti (line, data->entries[x].last);
3809+ line +=i; len -= i;
3810+ }
3811+#endif
3812+ }
3813+ *line++ = '\n';
3814+ *line = '\0';
3815+ *pline = line;
3816+}
3817+
3818+void newsrc_gen_entries (CONTEXT *ctx)
3819+{
3820+ NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3821+ int series, x;
3822+ unsigned int last = 0, first = 1;
3823+ int save_sort = SORT_ORDER;
3824+
3825+ if (Sort != SORT_ORDER)
3826+ {
3827+ save_sort = Sort;
3828+ Sort = SORT_ORDER;
3829+ mutt_sort_headers (ctx, 0);
3830+ }
3831+
3832+ if (!data->max)
3833+ {
3834+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3835+ data->max = 5;
3836+ }
3837+
3838+ /*
3839+ * Set up to fake initial sequence from 1 to the article before the
3840+ * first article in our list
3841+ */
3842+ data->num = 0;
3843+ series = 1;
3844+
3845+ for (x = 0; x < ctx->msgcount; x++)
3846+ {
3847+ if (series) /* search for first unread */
3848+ {
3849+ /*
3850+ * We don't actually check sequential order, since we mark
3851+ * "missing" entries as read/deleted
3852+ */
3853+ last = ctx->hdrs[x]->article_num;
3854+ if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3855+ !ctx->hdrs[x]->read)
3856+ {
3857+ if (data->num >= data->max)
3858+ {
3859+ data->max = data->max * 2;
3860+ safe_realloc (&data->entries,
3861+ data->max * sizeof (NEWSRC_ENTRY));
3862+ }
3863+ data->entries[data->num].first = first;
3864+ data->entries[data->num].last = last - 1;
3865+ data->num++;
3866+ series = 0;
3867+ }
3868+ }
3869+ else /* search for first read */
3870+ {
3871+ if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3872+ {
3873+ first = last + 1;
3874+ series = 1;
3875+ }
3876+ last = ctx->hdrs[x]->article_num;
3877+ }
3878+ }
3879+ if (series && first <= data->lastLoaded)
3880+ {
3881+ if (data->num >= data->max)
3882+ {
3883+ data->max = data->max * 2;
3884+ safe_realloc (&data->entries,
3885+ data->max * sizeof (NEWSRC_ENTRY));
3886+ }
3887+ data->entries[data->num].first = first;
3888+ data->entries[data->num].last = data->lastLoaded;
3889+ data->num++;
3890+ }
3891+
3892+ if (save_sort != Sort)
3893+ {
3894+ Sort = save_sort;
3895+ mutt_sort_headers (ctx, 0);
3896+ }
3897+}
3898+
3899+static int mutt_update_list_file (char *filename, char *section,
3900+ char *key, char *line)
3901+{
3902+ FILE *ifp;
3903+ FILE *ofp;
3904+ char buf[HUGE_STRING];
3905+ char tmpfile[_POSIX_PATH_MAX];
3906+ char *c;
3907+ int ext = 0, done = 0, r = 0;
3908+
3909+ /* if file not exist, create it */
3910+ if ((ifp = safe_fopen (filename, "a")))
3911+ fclose (ifp);
3912+ dprint (1, (debugfile, "Opening %s\n", filename));
3913+ if (!(ifp = safe_fopen (filename, "r")))
3914+ {
3915+ mutt_error (_("Unable to open %s for reading"), filename);
3916+ return -1;
3917+ }
3918+ if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3919+ {
3920+ fclose (ifp);
3921+ mutt_error (_("Unable to lock %s"), filename);
3922+ return -1;
3923+ }
3924+ snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3925+ dprint (1, (debugfile, "Opening %s\n", tmpfile));
3926+ if (!(ofp = fopen (tmpfile, "w")))
3927+ {
3928+ fclose (ifp);
3929+ mutt_error (_("Unable to open %s for writing"), tmpfile);
3930+ return -1;
3931+ }
3932+
3933+ if (section)
3934+ {
3935+ while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3936+ {
3937+ r = fputs (buf, ofp);
3938+ c = buf;
3939+ while (*c && *c != '\n') c++;
3940+ c[0] = 0; /* strip EOL */
3941+ if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3942+ done++;
3943+ }
3944+ if (r != EOF && !done)
3945+ {
3946+ snprintf (buf, sizeof(buf), "#: %s\n", section);
3947+ r = fputs (buf, ofp);
3948+ }
3949+ done = 0;
3950+ }
3951+
3952+ while (r != EOF && fgets (buf, sizeof (buf), ifp))
3953+ {
3954+ if (ext)
3955+ {
3956+ c = buf;
3957+ while (*c && (*c != '\r') && (*c != '\n')) c++;
3958+ c--;
3959+ if (*c != '\\') ext = 0;
3960+ }
3961+ else if ((section && !strncmp (buf, "#: ", 3)))
3962+ {
3963+ if (!done && line)
3964+ {
3965+ fputs (line, ofp);
3966+ fputc ('\n', ofp);
3967+ }
3968+ r = fputs (buf, ofp);
3969+ done++;
3970+ break;
3971+ }
3972+ else if (key && !strncmp (buf, key, strlen(key)) &&
3973+ (!*key || buf[strlen(key)] == ' '))
3974+ {
3975+ c = buf;
3976+ ext = 0;
3977+ while (*c && (*c != '\r') && (*c != '\n')) c++;
3978+ c--;
3979+ if (*c == '\\') ext = 1;
3980+ if (!done && line)
3981+ {
3982+ r = fputs (line, ofp);
3983+ if (*key)
3984+ r = fputc ('\n', ofp);
3985+ done++;
3986+ }
3987+ }
3988+ else
3989+ {
3990+ r = fputs (buf, ofp);
3991+ }
3992+ }
3993+
3994+ while (r != EOF && fgets (buf, sizeof (buf), ifp))
3995+ r = fputs (buf, ofp);
3996+
3997+ /* If there wasn't a line to replace, put it on the end of the file */
3998+ if (r != EOF && !done && line)
3999+ {
4000+ fputs (line, ofp);
4001+ r = fputc ('\n', ofp);
4002+ }
4003+ mx_unlock_file (filename, fileno (ifp), 0);
4004+ fclose (ofp);
4005+ fclose (ifp);
4006+ if (r == EOF)
4007+ {
4008+ unlink (tmpfile);
4009+ mutt_error (_("Can't write %s"), tmpfile);
4010+ return -1;
4011+ }
4012+ if (rename (tmpfile, filename) < 0)
4013+ {
4014+ unlink (tmpfile);
4015+ mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
4016+ return -1;
4017+ }
4018+ return 0;
4019+}
4020+
4021+int mutt_newsrc_update (NNTP_SERVER *news)
4022+{
4023+ char *buf, *line;
4024+ NNTP_DATA *data;
4025+ LIST *tmp;
4026+ int r = -1;
4027+ size_t len, llen;
4028+
4029+ if (!news)
4030+ return -1;
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)
4035+ {
4036+ data = (NNTP_DATA *) tmp->data;
4037+ if (!data || !data->rc)
4038+ continue;
4039+ nntp_create_newsrc_line (data, &buf, &line, &llen);
4040+ if (*line)
4041+ dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4042+ line += strlen (line);
4043+ }
4044+ /* newrc being fully rewritten */
4045+ if (news->newsrc &&
4046+ (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4047+ {
4048+ struct stat st;
4049+