]> git.pld-linux.org Git - packages/mutt.git/blame - mutt-vvv.nntp.patch
- noted some patch sources
[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
e1bffe0b
JB
12diff -udprP mutt-1.5.15.orig/ChangeLog.nntp mutt-1.5.15/ChangeLog.nntp
13--- mutt-1.5.15.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14+++ mutt-1.5.15/ChangeLog.nntp 2007-04-11 17:33:57.000000000 +0300
15@@ -0,0 +1,344 @@
16+* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
17+- fixed posting error if $smtp_url is set
18+- added support of print-style sequence %R (x-comment-to)
19+
20+* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
21+- update to 1.5.15
22+- nntp://... url changed to news://...
23+- added indicator of fetching descriptions progress
24+
25+* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
26+- update to 1.5.14
27+
95768aa9 28+* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
29+- update to 1.5.13
30+
31+* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
32+- update to 1.5.12
33+- fixed reading empty .newsrc
34+
35+* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
36+- update to 1.5.11
37+
38+* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
39+- update to 1.5.10
40+
41+* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
42+- update to 1.5.9
43+
44+* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
45+- update to 1.5.8
46+
47+* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
48+- update to 1.5.7
49+- function mutt_update_list_file() moved to newsrc.c and changed algorithm
50+
51+* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
52+- fixed error in nntp_logout_all()
53+
54+* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
55+- fixed debug output in mutt_newsrc_update()
56+- added optional support of LISTGROUP command
57+- fixed typo in nntp_parse_xref()
58+
59+* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
60+- update to 1.5.6
61+
62+* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
63+- fixed compose menu
64+
65+* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
66+- update to 1.5.5.1
67+
68+* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
69+- update to 1.5.5
70+- added space after newsgroup name in .newsrc file
71+
72+* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
73+- nntp patch: fixed SIGSEGV when posting article
74+
75+* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
76+- update to 1.5.4
77+
78+* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
79+- update to 1.5.3
80+- replace safe_free calls by the FREE macro
81+
82+* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
83+- update to 1.5.2
84+- nntp authentication can be passed after any command
85+
86+* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
87+- update to 1.5.1
88+
89+* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
90+- update to 1.3.99
91+
92+* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
93+- update to 1.3.28
94+- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
95+ <reconstruct-thread> functions
96+- fixed message about nntp reconnect
97+- fixed <attach-news-message> function using browser
98+- added support of Followup-To: poster
99+- added %n (new articles) in group_index_format
100+- posting articles without inews by default
101+
102+* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
103+- update to 1.3.27
104+
105+* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
106+- update to 1.3.26
107+
108+* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
109+- update to 1.3.25
110+- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
111+- added default content disposition
112+
113+* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
114+- update to 1.3.24
115+
116+* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
117+- update to 1.3.23.2
118+- fixed segfault if mutt_conn_find() returns null
119+
120+* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
121+- update to 1.3.23.1
122+- added support of LISTGROUP command
123+- added support for servers with broken overview
124+- disabled <flag-message> function on news server
125+- fixed error storing bad authentication information
126+
127+* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
128+- update to 1.3.23
129+- fixed typo in buffy.c
130+- added substitution of %s parameter in $inews variable
131+
132+* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
133+- update to 1.3.22.1
134+- update to 1.3.22
135+
136+* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
137+- update to 1.3.21
138+
139+* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
140+- update to 1.3.20
141+- removed 'server-hook', use 'account-hook' instead
142+- fixed error opening NNTP server without newsgroup using -f option
143+
144+* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
145+- update to 1.3.19
146+
147+* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
148+- update to 1.3.18
149+- fixed typo in nntp_attempt_features()
150+- changed algorithm of XGTITLE command testing
151+- disabled writing of NNTP password in debug file
152+- fixed reading and writing of long newsrc lines
153+- changed checking of last line while reading lines from server
154+- fixed possible buffer overrun in nntp_parse_newsrc_line()
155+- removed checking of XHDR command
156+- compare NNTP return codes without trailing space
157+
158+* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
159+- update to 1.3.17
160+- support for 'LIST NEWSGROUPS' command to read descriptions
161+
162+* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
163+- update to 1.3.16
164+
165+* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
166+- update to 1.3.15
167+
168+* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
169+- update to 1.3.14
170+- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
171+
172+* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
173+- update to 1.3.13
174+
175+* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
176+- Fixed problem if last article in group is deleted
177+
178+* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
179+- Fixed checking of XGTITLE command on some servers
180+
181+* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
182+- Added \r in AUTHINFO commands
183+
184+* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
185+- update to 1.3.12
186+
187+* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
188+- update to 1.3.11
189+- fixed error opening newsgroup from mutt started with -g or -G
190+
191+* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
192+- update to 1.3.10
193+- hotkey 'G' (get-message) replaced with '^G'
194+
195+* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
196+- update to 1.3.9
197+- changed delay displaying error messages from 1 to 2 seconds
198+- fixed error compiling with nntp and without imap
199+
200+* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
201+- fixed catchup in index
202+- fixed nntp_open_mailbox()
203+
204+* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
205+- functions <edit> and <delete-entry> disabled
206+- format of news mailbox names changed to url form
207+- option nntp_attempts removed
208+- option reconnect_news renamed to nntp_reconnect
209+- default value of nntp_poll changed from 30 to 60
210+- error handling improved
211+
212+* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
213+- update to 1.3.8
214+- new option show_only_unread
215+- add newsgroup completion
216+
217+* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
218+- update to 1.3.7
219+
220+* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
221+- update to 1.3.6
222+
223+* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
224+- update to 1.3.5
225+- authentication code update
226+- fix for changing to newsgroup from mailbox with read messages
227+- socket code optimization
228+
229+* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
230+- update to 1.3.4
231+
232+* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
233+- don't substitute current newsgroup with deleted new messages
234+
235+* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
236+- update to 1.3.3
237+- fix for substitution of newsgroup after reconnection
238+- fix for loading newsgroups with very long names
239+- fix for loading more than 32768 newsgroups
240+
241+* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
242+- update to 1.3.2
243+
244+* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
245+- update to 1.3.1
246+
247+* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
248+- update to 1.3
249+
250+* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
251+- update to 1.2
252+
253+* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
254+- update to 1.1.14
255+
256+* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
257+- update to 1.1.12
258+
259+* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
260+- add substitution of newsgroup with new messages by default
261+
262+* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
263+- add attach message from newsgroup
264+- add one-line help in newsreader mode
265+- disable 'change-dir' command in newsgroups browser
266+- add -G option
267+
268+* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
269+- get default newsserver name from file /etc/nntpserver
270+- use case insensitive server names
271+- add print-style sequence %s to $newsrc
272+- add -g option
273+
274+* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
275+- remove 'X-FTN-Origin' header processing
276+
277+* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
278+- update to 1.1.11
279+- update to 1.1.10
280+
281+* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
282+- fix mutt_select_newsserver()
283+- remove 'toggle-mode' function
284+- add 'change-newsgroup' function
285+
286+* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
287+- fix server-hook
288+
289+* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
290+- fix error 'bounce' function after 'post'
291+- add 'forward to newsgroup' function
292+
293+* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
294+- 'forward' function works in newsreader mode
295+- add 'post' and 'followup' functions to pager and attachment menu
296+- fix active descriptions and allowed flag reload
297+
298+* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
299+- update to 1.1.9
300+- remove deleted newsgroups from list
301+
302+* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
303+- update .newsrc in browser
304+
305+* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
306+- reload .newsrc if externally modified
307+- fix active cache update
308+
309+* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
310+- update to 1.1.8
311+
312+* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
313+- patch *.update_list_file is not required
314+- count lines when loading descriptions
315+- remove cache of unsubscribed newsgroups
316+
317+* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
318+- load list of newsgroups from cache faster
319+
320+* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
321+- update to 1.1.7
322+
323+* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
324+- fix unread messages in browser
325+- fix newsrc_gen_entries()
326+
327+* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
328+- fix mutt_newsgroup_stat()
329+- fix nntp_delete_cache()
330+- fix nntp_get_status()
331+- fix check_children()
332+- fix nntp_fetch_headers()
333+
334+* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
335+- update to 1.1.5
336+
337+* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
338+- fix updating new messages in cache
339+
340+* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
341+- change default cache filenames
342+- fix updating new messages in cache
343+
344+* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
345+- fix segmentation fault in news groups browser
346+
347+* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
348+- update to 1.1.4
349+
350+* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
351+- update to 1.1.3
352+
353+* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
354+- add X-Comment-To editing
355+- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
356+- add variables $ask_followup_to and $ask_x_comment_to
357+
358+* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
359+- update to 1.1.2
e1bffe0b
JB
360diff -udprP mutt-1.5.15.orig/OPS mutt-1.5.15/OPS
361--- mutt-1.5.15.orig/OPS 2007-04-02 00:58:55.000000000 +0300
362+++ mutt-1.5.15/OPS 2007-04-11 17:25:15.000000000 +0300
95768aa9 363@@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
364 OP_BROWSER_NEW_FILE "select a new file in this directory"
365 OP_BROWSER_VIEW_FILE "view file"
366 OP_BROWSER_TELL "display the currently selected file's name"
367-OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
e1bffe0b
JB
368-OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
369+OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
370+OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
95768aa9 371 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
372 OP_BUFFY_LIST "list mailboxes with new mail"
373+OP_CATCHUP "mark all articles in newsgroup as read"
374 OP_CHANGE_DIRECTORY "change directories"
375 OP_CHECK_NEW "check mailboxes for new mail"
e1bffe0b 376 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
95768aa9 377 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
378+OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message"
379 OP_COMPOSE_EDIT_BCC "edit the BCC list"
380 OP_COMPOSE_EDIT_CC "edit the CC list"
381 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
382@@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
383 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
384 OP_COMPOSE_EDIT_MESSAGE "edit the message"
385 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
386+OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
387 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
388+OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
389+OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
390 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
391 OP_COMPOSE_EDIT_TO "edit the TO list"
392 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
393@@ -85,8 +90,13 @@ OP_EXIT "exit this menu"
394 OP_FILTER "filter attachment through a shell command"
395 OP_FIRST_ENTRY "move to the first entry"
396 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
397+OP_FOLLOWUP "followup to newsgroup"
398+OP_FORWARD_TO_GROUP "forward to newsgroup"
399 OP_FORWARD_MESSAGE "forward a message with comments"
400 OP_GENERIC_SELECT_ENTRY "select the current entry"
401+OP_GET_CHILDREN "get all children of the current message"
402+OP_GET_MESSAGE "get message with Message-Id"
403+OP_GET_PARENT "get parent of the current message"
404 OP_GROUP_REPLY "reply to all recipients"
405 OP_HALF_DOWN "scroll down 1/2 page"
406 OP_HALF_UP "scroll up 1/2 page"
407@@ -94,11 +104,14 @@ OP_HELP "this screen"
408 OP_JUMP "jump to an index number"
409 OP_LAST_ENTRY "move to the last entry"
410 OP_LIST_REPLY "reply to specified mailing list"
411+OP_LOAD_ACTIVE "load active file from NNTP server"
412 OP_MACRO "execute a macro"
413 OP_MAIL "compose a new mail message"
414 OP_MAIN_BREAK_THREAD "break the thread in two"
415 OP_MAIN_CHANGE_FOLDER "open a different folder"
416 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
417+OP_MAIN_CHANGE_GROUP "open a different newsgroup"
418+OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
419 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
420 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
421 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
422@@ -136,6 +149,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
423 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
424 OP_PAGER_TOP "jump to the top of the message"
425 OP_PIPE "pipe message/attachment to a shell command"
426+OP_POST "post message to newsgroup"
427 OP_PREV_ENTRY "move to the previous entry"
428 OP_PREV_LINE "scroll up one line"
429 OP_PREV_PAGE "move to the previous page"
430@@ -144,6 +158,7 @@ OP_QUERY "query external program for add
431 OP_QUERY_APPEND "append new query results to current results"
432 OP_QUIT "save changes to mailbox and quit"
433 OP_RECALL_MESSAGE "recall a postponed message"
434+OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
435 OP_REDRAW "clear and redraw the screen"
436 OP_REFORMAT_WINCH "{internal}"
437 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
438@@ -158,18 +173,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
439 OP_SHELL_ESCAPE "invoke a command in a subshell"
440 OP_SORT "sort messages"
441 OP_SORT_REVERSE "sort messages in reverse order"
442+OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
443 OP_TAG "tag the current entry"
444 OP_TAG_PREFIX "apply next function to tagged messages"
445 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
446 OP_TAG_SUBTHREAD "tag the current subthread"
447 OP_TAG_THREAD "tag the current thread"
448 OP_TOGGLE_NEW "toggle a message's 'new' flag"
449+OP_TOGGLE_READ "toggle view of read messages"
450 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
451 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
452 OP_TOP_PAGE "move to the top of the page"
453+OP_UNCATCHUP "mark all articles in newsgroup as unread"
454 OP_UNDELETE "undelete the current entry"
455 OP_UNDELETE_THREAD "undelete all messages in thread"
456 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
457+OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
458 OP_VERSION "show the Mutt version number and date"
459 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
460 OP_VIEW_ATTACHMENTS "show MIME attachments"
e1bffe0b
JB
461diff -udprP mutt-1.5.15.orig/PATCHES mutt-1.5.15/PATCHES
462--- mutt-1.5.15.orig/PATCHES 2007-03-15 17:49:37.000000000 +0200
463+++ mutt-1.5.15/PATCHES 2007-04-11 17:25:15.000000000 +0300
95768aa9 464@@ -0,0 +1 @@
465+vvv.nntp
e1bffe0b
JB
466diff -udprP mutt-1.5.15.orig/account.c mutt-1.5.15/account.c
467--- mutt-1.5.15.orig/account.c 2007-04-02 00:58:55.000000000 +0300
468+++ mutt-1.5.15/account.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 469@@ -54,6 +54,11 @@ int mutt_account_match (const ACCOUNT* a
470 user = PopUser;
471 #endif
472
473+#ifdef USE_NNTP
474+ if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
475+ user = NntpUser;
476+#endif
477+
478 if (a1->flags & a2->flags & M_ACCT_USER)
479 return (!strcmp (a1->user, a2->user));
480 if (a1->flags & M_ACCT_USER)
e1bffe0b 481@@ -133,6 +138,16 @@ void mutt_account_tourl (ACCOUNT* accoun
95768aa9 482 }
483 #endif
484
485+#ifdef USE_NNTP
486+ if (account->type == M_ACCT_TYPE_NNTP)
487+ {
488+ if (account->flags & M_ACCT_SSL)
489+ url->scheme = U_NNTPS;
490+ else
491+ url->scheme = U_NNTP;
492+ }
493+#endif
494+
495 url->host = account->host;
496 if (account->flags & M_ACCT_PORT)
497 url->port = account->port;
e1bffe0b 498@@ -158,6 +173,10 @@ int mutt_account_getuser (ACCOUNT* accou
95768aa9 499 else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
500 strfcpy (account->user, PopUser, sizeof (account->user));
501 #endif
502+#ifdef USE_NNTP
503+ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
504+ strfcpy (account->user, NntpUser, sizeof (account->user));
505+#endif
506 /* prompt (defaults to unix username), copy into account->user */
507 else
508 {
e1bffe0b 509@@ -214,6 +233,10 @@ int mutt_account_getpass (ACCOUNT* accou
95768aa9 510 else if ((account->type == M_ACCT_TYPE_POP) && PopPass)
511 strfcpy (account->pass, PopPass, sizeof (account->pass));
512 #endif
513+#ifdef USE_NNTP
514+ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
515+ strfcpy (account->pass, NntpPass, sizeof (account->pass));
516+#endif
517 else
518 {
519 snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
e1bffe0b
JB
520diff -udprP mutt-1.5.15.orig/account.h mutt-1.5.15/account.h
521--- mutt-1.5.15.orig/account.h 2007-04-02 00:58:55.000000000 +0300
522+++ mutt-1.5.15/account.h 2007-04-11 17:25:15.000000000 +0300
523@@ -29,7 +29,8 @@ enum
95768aa9 524 M_ACCT_TYPE_NONE = 0,
525 M_ACCT_TYPE_IMAP,
e1bffe0b
JB
526 M_ACCT_TYPE_POP,
527- M_ACCT_TYPE_SMTP
528+ M_ACCT_TYPE_SMTP,
529+ M_ACCT_TYPE_NNTP
95768aa9 530 };
531
e1bffe0b
JB
532 /* account flags */
533diff -udprP mutt-1.5.15.orig/attach.h mutt-1.5.15/attach.h
534--- mutt-1.5.15.orig/attach.h 2007-04-02 00:58:55.000000000 +0300
535+++ mutt-1.5.15/attach.h 2007-04-11 17:25:15.000000000 +0300
95768aa9 536@@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f
537
538 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
539 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
540-void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
541+void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
542 void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
543
544 #endif /* _ATTACH_H_ */
e1bffe0b
JB
545diff -udprP mutt-1.5.15.orig/browser.c mutt-1.5.15/browser.c
546--- mutt-1.5.15.orig/browser.c 2007-04-03 07:57:21.000000000 +0300
547+++ mutt-1.5.15/browser.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 548@@ -32,6 +32,9 @@
549 #ifdef USE_IMAP
550 #include "imap.h"
551 #endif
552+#ifdef USE_NNTP
553+#include "nntp.h"
554+#endif
555
556 #include <stdlib.h>
557 #include <dirent.h>
558@@ -49,6 +52,19 @@ static struct mapping_t FolderHelp[] = {
559 { NULL }
560 };
561
562+#ifdef USE_NNTP
563+static struct mapping_t FolderNewsHelp[] = {
564+ { N_("Exit"), OP_EXIT },
565+ { N_("List"), OP_TOGGLE_MAILBOXES },
566+ { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
567+ { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
568+ { N_("Catchup"), OP_CATCHUP },
569+ { N_("Mask"), OP_ENTER_MASK },
570+ { N_("Help"), OP_HELP },
571+ { NULL }
572+};
573+#endif
574+
575 typedef struct folder_t
576 {
577 struct folder_file *ff;
578@@ -114,9 +130,17 @@ static void browser_sort (struct browser
579 case SORT_ORDER:
580 return;
581 case SORT_DATE:
582+#ifdef USE_NNTP
583+ if (option (OPTNEWS))
584+ return;
585+#endif
586 f = browser_compare_date;
587 break;
588 case SORT_SIZE:
589+#ifdef USE_NNTP
590+ if (option (OPTNEWS))
591+ return;
592+#endif
593 f = browser_compare_size;
594 break;
595 case SORT_SUBJECT:
596@@ -306,8 +330,106 @@ folder_format_str (char *dest, size_t de
597 return (src);
598 }
599
600+#ifdef USE_NNTP
601+static const char *
602+newsgroup_format_str (char *dest, size_t destlen, char op, const char *src,
603+ const char *fmt, const char *ifstring, const char *elsestring,
604+ unsigned long data, format_flag flags)
605+{
606+ char fn[SHORT_STRING], tmp[SHORT_STRING];
607+ FOLDER *folder = (FOLDER *) data;
608+
609+ switch (op)
610+ {
611+ case 'C':
612+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
613+ snprintf (dest, destlen, tmp, folder->num + 1);
614+ break;
615+
616+ case 'f':
617+ strncpy (fn, folder->ff->name, sizeof(fn) - 1);
618+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
619+ snprintf (dest, destlen, tmp, fn);
620+ break;
621+
622+ case 'N':
623+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
624+ if (folder->ff->nd->subscribed)
625+ snprintf (dest, destlen, tmp, ' ');
626+ else
627+ snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
628+ break;
629+
630+ case 'M':
631+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
632+ if (folder->ff->nd->deleted)
633+ snprintf (dest, destlen, tmp, 'D');
634+ else
635+ snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
636+ break;
637+
638+ case 's':
639+ if (flags & M_FORMAT_OPTIONAL)
640+ {
641+ if (folder->ff->nd->unread != 0)
642+ mutt_FormatString (dest, destlen, ifstring, newsgroup_format_str,
643+ data, flags);
644+ else
645+ mutt_FormatString (dest, destlen, elsestring, newsgroup_format_str,
646+ data, flags);
647+ }
648+ else if (Context && Context->data == folder->ff->nd)
649+ {
650+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
651+ snprintf (dest, destlen, tmp, Context->unread);
652+ }
653+ else
654+ {
655+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
656+ snprintf (dest, destlen, tmp, folder->ff->nd->unread);
657+ }
658+ break;
659+
660+ case 'n':
661+ if (Context && Context->data == folder->ff->nd)
662+ {
663+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
664+ snprintf (dest, destlen, tmp, Context->new);
665+ }
666+ else if (option (OPTMARKOLD) &&
667+ folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
668+ folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
669+ {
670+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
671+ snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
672+ }
673+ else
674+ {
675+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
676+ snprintf (dest, destlen, tmp, folder->ff->nd->unread);
677+ }
678+ break;
679+
680+ case 'd':
681+ if (folder->ff->nd->desc != NULL)
682+ {
683+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
684+ snprintf (dest, destlen, tmp, folder->ff->nd->desc);
685+ }
686+ else
687+ {
688+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
689+ snprintf (dest, destlen, tmp, "");
690+ }
691+ break;
692+ }
693+ return (src);
694+}
695+#endif /* USE_NNTP */
696+
697 static void add_folder (MUTTMENU *m, struct browser_state *state,
698- const char *name, const struct stat *s, int new)
699+ const char *name, const struct stat *s,
700+ void *data, int new)
701 {
702 if (state->entrylen == state->entrymax)
703 {
704@@ -336,6 +458,10 @@ static void add_folder (MUTTMENU *m, str
705 #ifdef USE_IMAP
706 (state->entry)[state->entrylen].imap = 0;
707 #endif
708+#ifdef USE_NNTP
709+ if (option (OPTNEWS))
710+ (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
711+#endif
712 (state->entrylen)++;
713 }
714
715@@ -351,9 +477,35 @@ static void init_state (struct browser_s
716 menu->data = state->entry;
717 }
718
719+/* get list of all files/newsgroups with mask */
720 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
721 char *d, const char *prefix)
722 {
723+#ifdef USE_NNTP
724+ if (option (OPTNEWS))
725+ {
726+ LIST *tmp;
727+ NNTP_DATA *data;
728+ NNTP_SERVER *news = CurrentNewsSrv;
729+
730+/* mutt_buffy_check (0); */
731+ init_state (state, menu);
732+
733+ for (tmp = news->list; tmp; tmp = tmp->next)
734+ {
735+ if (!(data = (NNTP_DATA *)tmp->data))
736+ continue;
737+ if (prefix && *prefix && strncmp (prefix, data->group,
738+ strlen (prefix)) != 0)
739+ continue;
740+ if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
741+ continue;
742+ add_folder (menu, state, data->group, NULL, data, data->new);
743+ }
744+ }
745+ else
746+#endif /* USE_NNTP */
747+ {
748 struct stat s;
749 DIR *dp;
750 struct dirent *de;
751@@ -414,17 +566,40 @@ static int examine_directory (MUTTMENU *
752 tmp = Incoming;
753 while (tmp && mutt_strcmp (buffer, tmp->path))
754 tmp = tmp->next;
755- add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
756+ add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
757+ }
758+ closedir (dp);
759 }
760- closedir (dp);
761 browser_sort (state);
762 return 0;
763 }
764
765+/* get list of mailboxes/subscribed newsgroups */
766 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
767 {
768 struct stat s;
769 char buffer[LONG_STRING];
770+
771+#ifdef USE_NNTP
772+ if (option (OPTNEWS))
773+ {
774+ LIST *tmp;
775+ NNTP_DATA *data;
776+ NNTP_SERVER *news = CurrentNewsSrv;
777+
778+/* mutt_buffy_check (0); */
779+ init_state (state, menu);
780+
781+ for (tmp = news->list; tmp; tmp = tmp->next)
782+ {
783+ if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
784+ (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
785+ add_folder (menu, state, data->group, NULL, data, data->new);
786+ }
787+ }
788+ else
789+#endif
790+ {
791 BUFFY *tmp = Incoming;
95768aa9 792 #ifdef USE_IMAP
e1bffe0b
JB
793 struct mailbox_state mbox;
794@@ -442,14 +617,21 @@ static int examine_mailboxes (MUTTMENU *
95768aa9 795 if (mx_is_imap (tmp->path))
796 {
e1bffe0b
JB
797 imap_mailbox_state (tmp->path, &mbox);
798- add_folder (menu, state, tmp->path, NULL, mbox.new);
799+ add_folder (menu, state, tmp->path, NULL, NULL, mbox.new);
95768aa9 800 continue;
801 }
802 #endif
803 #ifdef USE_POP
804 if (mx_is_pop (tmp->path))
805 {
806- add_folder (menu, state, tmp->path, NULL, tmp->new);
807+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
808+ continue;
809+ }
810+#endif
811+#ifdef USE_NNTP
812+ if (mx_is_nntp (tmp->path))
813+ {
814+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
815 continue;
816 }
817 #endif
e1bffe0b 818@@ -463,15 +645,20 @@ static int examine_mailboxes (MUTTMENU *
95768aa9 819 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
820 mutt_pretty_mailbox (buffer);
821
822- add_folder (menu, state, buffer, &s, tmp->new);
823+ add_folder (menu, state, buffer, &s, NULL, tmp->new);
824 }
825 while ((tmp = tmp->next));
826+ }
827 browser_sort (state);
828 return 0;
829 }
830
831 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
832 {
833+#ifdef USE_NNTP
834+ if (option (OPTNEWS))
835+ return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
836+#endif
837 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
838 }
839
e1bffe0b 840@@ -482,7 +669,13 @@ static void folder_entry (char *s, size_
95768aa9 841 folder.ff = &((struct folder_file *) menu->data)[num];
842 folder.num = num;
843
844- mutt_FormatString (s, slen, NONULL(FolderFormat), folder_format_str,
845+#ifdef USE_NNTP
846+ if (option (OPTNEWS))
847+ mutt_FormatString (s, slen, NONULL(GroupFormat), newsgroup_format_str,
848+ (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
849+ else
850+#endif
851+ mutt_FormatString (s, slen, NONULL(FolderFormat), folder_format_str,
852 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
853 }
854
e1bffe0b 855@@ -502,6 +695,17 @@ static void init_menu (struct browser_st
95768aa9 856
857 menu->tagged = 0;
858
859+#ifdef USE_NNTP
860+ if (option (OPTNEWS))
861+ {
862+ if (buffy)
863+ snprintf (title, titlelen, _("Subscribed newsgroups"));
864+ else
865+ snprintf (title, titlelen, _("Newsgroups on server [%s]"),
866+ CurrentNewsSrv->conn->account.host);
867+ }
868+ else
869+#endif
870 if (buffy)
871 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
872 else
e1bffe0b 873@@ -557,6 +761,31 @@ void _mutt_select_file (char *f, size_t
95768aa9 874 if (!folder)
875 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
876
877+#ifdef USE_NNTP
878+ if (option (OPTNEWS))
879+ {
880+ if (*f)
881+ strfcpy (prefix, f, sizeof (prefix));
882+ else
883+ {
884+ LIST *list;
885+
886+ /* default state for news reader mode is browse subscribed newsgroups */
887+ buffy = 0;
888+ for (list = CurrentNewsSrv->list; list; list = list->next)
889+ {
890+ NNTP_DATA *data = (NNTP_DATA *) list->data;
891+
892+ if (data && data->subscribed)
893+ {
894+ buffy = 1;
895+ break;
896+ }
897+ }
898+ }
899+ }
900+ else
901+#endif
902 if (*f)
903 {
904 mutt_expand_path (f, flen);
e1bffe0b 905@@ -646,6 +875,9 @@ void _mutt_select_file (char *f, size_t
95768aa9 906 menu->tag = file_tag;
907
908 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
909+#ifdef USE_NNTP
910+ (option (OPTNEWS)) ? FolderNewsHelp :
911+#endif
912 FolderHelp);
913
914 init_menu (&state, menu, title, sizeof (title), buffy);
e1bffe0b 915@@ -784,7 +1016,11 @@ void _mutt_select_file (char *f, size_t
95768aa9 916 }
917 }
918
919+#ifdef USE_NNTP
920+ if (buffy || option (OPTNEWS)) /* news have not path */
921+#else
922 if (buffy)
923+#endif
924 {
925 strfcpy (f, state.entry[menu->current].name, flen);
926 mutt_expand_path (f, flen);
e1bffe0b 927@@ -842,14 +1078,6 @@ void _mutt_select_file (char *f, size_t
95768aa9 928 break;
929
930 #ifdef USE_IMAP
931- case OP_BROWSER_SUBSCRIBE:
932- imap_subscribe (state.entry[menu->current].name, 1);
933- break;
934-
935- case OP_BROWSER_UNSUBSCRIBE:
936- imap_subscribe (state.entry[menu->current].name, 0);
937- break;
938-
939 case OP_BROWSER_TOGGLE_LSUB:
940 if (option (OPTIMAPLSUB))
941 {
e1bffe0b 942@@ -948,6 +1176,11 @@ void _mutt_select_file (char *f, size_t
95768aa9 943
944 case OP_CHANGE_DIRECTORY:
945
946+#ifdef USE_NNTP
947+ if (option (OPTNEWS))
948+ break;
949+#endif
950+
951 strfcpy (buf, LastDir, sizeof (buf));
952 #ifdef USE_IMAP
953 if (!state.imap_browse)
e1bffe0b 954@@ -1204,6 +1437,190 @@ void _mutt_select_file (char *f, size_t
95768aa9 955 else
956 mutt_error _("Error trying to view file");
957 }
958+ break;
959+
960+#ifdef USE_NNTP
961+ case OP_CATCHUP:
962+ case OP_UNCATCHUP:
963+ if (option (OPTNEWS))
964+ {
965+ struct folder_file *f = &state.entry[menu->current];
966+ NNTP_DATA *nd;
967+
968+ if (i == OP_CATCHUP)
969+ nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
970+ else
971+ nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
972+
973+ if (nd)
974+ {
975+/* FOLDER folder;
976+ struct folder_file ff;
977+ char buffer[_POSIX_PATH_MAX + SHORT_STRING];
978+
979+ folder.ff = &ff;
980+ folder.ff->name = f->name;
981+ folder.ff->st = NULL;
982+ folder.ff->is_new = nd->new;
983+ folder.ff->nd = nd;
984+ FREE (&f->desc);
985+ mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
986+ newsgroup_format_str, (unsigned long) &folder,
987+ M_FORMAT_ARROWCURSOR);
988+ f->desc = safe_strdup (buffer); */
989+ if (menu->current + 1 < menu->max)
990+ menu->current++;
991+ menu->redraw = REDRAW_MOTION_RESYNCH;
992+ }
993+ }
994+ break;
995+
996+ case OP_LOAD_ACTIVE:
997+ if (!option (OPTNEWS))
998+ break;
999+
1000+ {
1001+ LIST *tmp;
1002+ NNTP_DATA *data;
1003+
1004+ for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
1005+ {
1006+ if ((data = (NNTP_DATA *)tmp->data))
1007+ data->deleted = 1;
1008+ }
1009+ }
1010+ nntp_get_active (CurrentNewsSrv);
1011+
1012+ destroy_state (&state);
1013+ if (buffy)
1014+ examine_mailboxes (menu, &state);
1015+ else
1016+ examine_directory (menu, &state, NULL, NULL);
1017+ init_menu (&state, menu, title, sizeof (title), buffy);
1018+ break;
1019+#endif /* USE_NNTP */
1020+
1021+#if defined USE_IMAP || defined USE_NNTP
1022+ case OP_BROWSER_SUBSCRIBE:
1023+ case OP_BROWSER_UNSUBSCRIBE:
1024+#endif
1025+#ifdef USE_NNTP
1026+ case OP_SUBSCRIBE_PATTERN:
1027+ case OP_UNSUBSCRIBE_PATTERN:
1028+ if (option (OPTNEWS))
1029+ {
1030+ regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1031+ char *s = buf;
1032+ int j = menu->current;
1033+ NNTP_DATA *nd;
1034+ NNTP_SERVER *news = CurrentNewsSrv;
1035+
1036+ if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1037+ {
1038+ char tmp[STRING];
1039+ int err;
1040+
1041+ buf[0] = 0;
1042+ if (i == OP_SUBSCRIBE_PATTERN)
1043+ snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1044+ else
1045+ snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1046+ if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1047+ {
1048+ FREE (&rx);
1049+ break;
1050+ }
1051+
1052+ if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1053+ {
1054+ regerror (err, rx, buf, sizeof (buf));
1055+ regfree (rx);
1056+ FREE (&rx);
1057+ mutt_error ("%s", buf);
1058+ break;
1059+ }
1060+ menu->redraw = REDRAW_FULL;
1061+ j = 0;
1062+ }
1063+ else if (!state.entrylen)
1064+ {
1065+ mutt_error _("No newsgroups match the mask");
1066+ break;
1067+ }
1068+
1069+ for ( ; j < state.entrylen; j++)
1070+ {
1071+ struct folder_file *f = &state.entry[j];
1072+
1073+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1074+ regexec (rx, f->name, 0, NULL, 0) == 0)
1075+ {
1076+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1077+ nd = mutt_newsgroup_subscribe (news, f->name);
1078+ else
1079+ nd = mutt_newsgroup_unsubscribe (news, f->name);
1080+/* if (nd)
1081+ {
1082+ FOLDER folder;
1083+ char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1084+
1085+ folder.name = f->name;
1086+ folder.f = NULL;
1087+ folder.new = nd->new;
1088+ folder.nd = nd;
1089+ FREE (&f->desc);
1090+ mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
1091+ newsgroup_format_str, (unsigned long) &folder,
1092+ M_FORMAT_ARROWCURSOR);
1093+ f->desc = safe_strdup (buffer);
1094+ } */
1095+ }
1096+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1097+ {
1098+ if (menu->current + 1 < menu->max)
1099+ menu->current++;
1100+ menu->redraw = REDRAW_MOTION_RESYNCH;
1101+ break;
1102+ }
1103+ }
1104+ if (i == OP_SUBSCRIBE_PATTERN)
1105+ {
1106+ LIST *grouplist = NULL;
1107+
1108+ if (news)
1109+ grouplist = news->list;
1110+ for (; grouplist; grouplist = grouplist->next)
1111+ {
1112+ nd = (NNTP_DATA *) grouplist->data;
1113+ if (nd && nd->group && !nd->subscribed)
1114+ {
1115+ if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1116+ {
1117+ mutt_newsgroup_subscribe (news, nd->group);
1118+ add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1119+ }
1120+ }
1121+ }
1122+ init_menu (&state, menu, title, sizeof (title), buffy);
1123+ }
1124+ mutt_newsrc_update (news);
1125+ nntp_clear_cacheindex (news);
1126+ if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1127+ regfree (rx);
1128+ FREE (&rx);
1129+ }
1130+#ifdef USE_IMAP
1131+ else
1132+#endif /* USE_IMAP && USE_NNTP */
1133+#endif /* USE_NNTP */
1134+#ifdef USE_IMAP
1135+ {
1136+ if (i == OP_BROWSER_SUBSCRIBE)
1137+ imap_subscribe (state.entry[menu->current].name, 1);
1138+ else
1139+ imap_subscribe (state.entry[menu->current].name, 0);
1140+ }
1141+#endif /* USE_IMAP */
1142 }
1143 }
1144
e1bffe0b
JB
1145diff -udprP mutt-1.5.15.orig/browser.h mutt-1.5.15/browser.h
1146--- mutt-1.5.15.orig/browser.h 2007-04-03 07:57:21.000000000 +0300
1147+++ mutt-1.5.15/browser.h 2007-04-11 17:25:15.000000000 +0300
95768aa9 1148@@ -20,6 +20,10 @@
1149 #ifndef _BROWSER_H
1150 #define _BROWSER_H 1
1151
1152+#ifdef USE_NNTP
1153+#include "nntp.h"
1154+#endif
1155+
1156 struct folder_file
1157 {
1158 mode_t mode;
1159@@ -38,14 +42,17 @@ struct folder_file
1160 unsigned selectable : 1;
1161 unsigned inferiors : 1;
1162 #endif
1163+#ifdef USE_NNTP
1164+ NNTP_DATA *nd;
1165+#endif
1166 unsigned tagged : 1;
1167 };
1168
1169 struct browser_state
1170 {
1171 struct folder_file *entry;
1172- short entrylen; /* number of real entries */
1173- short entrymax; /* max entry */
1174+ unsigned int entrylen; /* number of real entries */
1175+ unsigned int entrymax; /* max entry */
1176 #ifdef USE_IMAP
1177 short imap_browse;
1178 char *folder;
e1bffe0b
JB
1179diff -udprP mutt-1.5.15.orig/buffy.c mutt-1.5.15/buffy.c
1180--- mutt-1.5.15.orig/buffy.c 2007-04-02 00:58:55.000000000 +0300
1181+++ mutt-1.5.15/buffy.c 2007-04-11 17:25:15.000000000 +0300
1182@@ -285,6 +285,9 @@ int mutt_buffy_check (int force)
95768aa9 1183 #ifdef USE_POP
1184 if (!Context || Context->magic != M_POP)
1185 #endif
1186+#ifdef USE_NNTP
1187+ if (!Context || Context->magic != M_NNTP)
1188+#endif
1189 /* check device ID and serial number instead of comparing paths */
1190 if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0)
1191 {
e1bffe0b 1192@@ -308,6 +311,11 @@ int mutt_buffy_check (int force)
95768aa9 1193 tmp->magic = M_POP;
1194 else
1195 #endif
1196+#ifdef USE_NNTP
1197+ if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1198+ tmp->magic = M_NNTP;
1199+ else
1200+#endif
1201 if (stat (tmp->path, &sb) != 0 || sb.st_size == 0 ||
1202 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1203 {
e1bffe0b 1204@@ -325,25 +333,21 @@ int mutt_buffy_check (int force)
95768aa9 1205 /* check to see if the folder is the currently selected folder
1206 * before polling */
1207 if (!Context || !Context->path ||
1208-#if defined USE_IMAP || defined USE_POP
1209- ((
1210+ (
1211+ (0
1212 #ifdef USE_IMAP
1213- tmp->magic == M_IMAP
1214+ || tmp->magic == M_IMAP
1215 #endif
1216 #ifdef USE_POP
1217-#ifdef USE_IMAP
1218- ||
1219-#endif
1220- tmp->magic == M_POP
1221-#endif
1222- ) ? mutt_strcmp (tmp->path, Context->path) :
1223+ || tmp->magic == M_POP
1224 #endif
1225- (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1226-#if defined USE_IMAP || defined USE_POP
1227- )
1228+#ifdef USE_NNTP
1229+ || tmp->magic == M_NNTP
1230 #endif
1231- )
1232-
1233+ ) ? mutt_strcmp (tmp->path, Context->path) :
1234+ (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1235+ )
1236+ )
1237 {
1238 switch (tmp->magic)
1239 {
e1bffe0b
JB
1240diff -udprP mutt-1.5.15.orig/complete.c mutt-1.5.15/complete.c
1241--- mutt-1.5.15.orig/complete.c 2007-04-02 00:58:55.000000000 +0300
1242+++ mutt-1.5.15/complete.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 1243@@ -25,6 +25,9 @@
1244 #include "mailbox.h"
1245 #include "imap.h"
1246 #endif
1247+#ifdef USE_NNTP
1248+#include "nntp.h"
1249+#endif
1250
1251 #include <dirent.h>
1252 #include <string.h>
1253@@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen)
1254 char filepart[_POSIX_PATH_MAX];
1255 #ifdef USE_IMAP
1256 char imap_path[LONG_STRING];
1257+#endif
1258
1259 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1260
1261+#ifdef USE_NNTP
1262+ if (option (OPTNEWS))
1263+ {
1264+ LIST *l = CurrentNewsSrv->list;
1265+
1266+ strfcpy (filepart, s, sizeof (filepart));
1267+
1268+ /*
1269+ * special case to handle when there is no filepart yet.
1270+ * find the first subscribed newsgroup
1271+ */
1272+ if ((len = mutt_strlen (filepart)) == 0)
1273+ {
1274+ for (; l; l = l->next)
1275+ {
1276+ NNTP_DATA *data = (NNTP_DATA *)l->data;
1277+
1278+ if (data && data->subscribed)
1279+ {
1280+ strfcpy (filepart, data->group, sizeof (filepart));
1281+ init++;
1282+ l = l->next;
1283+ break;
1284+ }
1285+ }
1286+ }
1287+
1288+ for (; l; l = l->next)
1289+ {
1290+ NNTP_DATA *data = (NNTP_DATA *)l->data;
1291+
1292+ if (data && data->subscribed &&
1293+ mutt_strncmp (data->group, filepart, len) == 0)
1294+ {
1295+ if (init)
1296+ {
1297+ for (i = 0; filepart[i] && data->group[i]; i++)
1298+ {
1299+ if (filepart[i] != data->group[i])
1300+ {
1301+ filepart[i] = 0;
1302+ break;
1303+ }
1304+ }
1305+ filepart[i] = 0;
1306+ }
1307+ else
1308+ {
1309+ strfcpy (filepart, data->group, sizeof (filepart));
1310+ init = 1;
1311+ }
1312+ }
1313+ }
1314+
1315+ strcpy (s, filepart);
1316+
1317+ return (init ? 0 : -1);
1318+ }
1319+#endif
1320+
1321+#ifdef USE_IMAP
1322 /* we can use '/' as a delimiter, imap_complete rewrites it */
1323 if (*s == '=' || *s == '+' || *s == '!')
1324 {
e1bffe0b
JB
1325diff -udprP mutt-1.5.15.orig/compose.c mutt-1.5.15/compose.c
1326--- mutt-1.5.15.orig/compose.c 2007-04-02 00:58:55.000000000 +0300
1327+++ mutt-1.5.15/compose.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 1328@@ -32,10 +32,15 @@
1329 #include "mailbox.h"
1330 #include "sort.h"
1331 #include "charset.h"
1332+#include "mx.h"
1333
1334 #ifdef MIXMASTER
1335 #include "remailer.h"
1336 #endif
1337+
1338+#ifdef USE_NNTP
1339+#include "nntp.h"
1340+#endif
1341
1342 #include <errno.h>
1343 #include <string.h>
d6a4f209 1344@@ -67,11 +72,17 @@ enum
95768aa9 1345 HDR_CRYPT,
1346 HDR_CRYPTINFO,
1347
1348+#ifdef USE_NNTP
1349+ HDR_NEWSGROUPS,
1350+ HDR_FOLLOWUPTO,
1351+ HDR_XCOMMENTTO,
1352+#endif
1353+
1354 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1355 };
1356
1357-#define HDR_XOFFSET 10
1358-#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1359+#define HDR_XOFFSET 14
1360+#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1361 #define W (COLS - HDR_XOFFSET)
1362
1363 static char *Prompts[] =
1364@@ -83,6 +91,16 @@ static char *Prompts[] =
1365 "Subject: ",
1366 "Reply-To: ",
1367 "Fcc: "
1368+#ifdef USE_NNTP
1369+#ifdef MIXMASTER
1370+ ,""
1371+#endif
1372+ ,""
1373+ ,""
1374+ ,"Newsgroups: "
1375+ ,"Followup-To: "
1376+ ,"X-Comment-To: "
1377+#endif
1378 };
1379
1380 static struct mapping_t ComposeHelp[] = {
1381@@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] =
1382 { NULL }
1383 };
1384
1385+#ifdef USE_NNTP
1386+static struct mapping_t ComposeNewsHelp[] = {
1387+ { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1388+ { N_("Abort"), OP_EXIT },
1389+ { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1390+ { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1391+ { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1392+ { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1393+ { N_("Help"), OP_HELP },
1394+ { NULL }
1395+};
1396+#endif
1397+
1398 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1399 {
1400 mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
1401@@ -115,16 +146,16 @@ static void redraw_crypt_lines (HEADER *
1402 if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
1403 {
1404 if (!msg->security)
1405- mvaddstr (HDR_CRYPT, 0, "Security: ");
1406+ mvaddstr (HDR_CRYPT, 0, " Security: ");
1407 else if (msg->security & APPLICATION_SMIME)
1408- mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1409+ mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1410 else if (msg->security & APPLICATION_PGP)
1411- mvaddstr (HDR_CRYPT, 0, " PGP: ");
1412+ mvaddstr (HDR_CRYPT, 0, " PGP: ");
1413 }
1414 else if ((WithCrypto & APPLICATION_SMIME))
1415- mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1416+ mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1417 else if ((WithCrypto & APPLICATION_PGP))
1418- mvaddstr (HDR_CRYPT, 0, " PGP: ");
1419+ mvaddstr (HDR_CRYPT, 0, " PGP: ");
1420 else
1421 return;
1422
1423@@ -252,9 +283,28 @@ static void draw_envelope_addr (int line
1424 static void draw_envelope (HEADER *msg, char *fcc)
1425 {
1426 draw_envelope_addr (HDR_FROM, msg->env->from);
1427+#ifdef USE_NNTP
1428+ if (!option (OPTNEWSSEND))
1429+ {
1430+#endif
1431 draw_envelope_addr (HDR_TO, msg->env->to);
1432 draw_envelope_addr (HDR_CC, msg->env->cc);
1433 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1434+#ifdef USE_NNTP
1435+ }
1436+ else
1437+ {
1438+ mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1439+ mutt_paddstr (W, NONULL (msg->env->newsgroups));
1440+ mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1441+ mutt_paddstr (W, NONULL (msg->env->followup_to));
1442+ if (option (OPTXCOMMENTTO))
1443+ {
1444+ mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1445+ mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1446+ }
1447+ }
1448+#endif
1449 mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1450 mutt_paddstr (W, NONULL (msg->env->subject));
1451 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1452@@ -507,6 +557,12 @@ int mutt_compose_menu (HEADER *msg, /*
1453 /* Sort, SortAux could be changed in mutt_index_menu() */
1454 int oldSort, oldSortAux;
1455 struct stat st;
1456+#ifdef USE_NNTP
1457+ int news = 0; /* is it a news article ? */
1458+
1459+ if (option (OPTNEWSSEND))
1460+ news++;
1461+#endif
1462
1463 mutt_attach_init (msg->content);
1464 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
1465@@ -518,10 +574,18 @@ int mutt_compose_menu (HEADER *msg, /*
1466 menu->make_entry = snd_entry;
1467 menu->tag = mutt_tag_attach;
1468 menu->data = idx;
1469+#ifdef USE_NNTP
1470+ if (news)
1471+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1472+ else
1473+#endif
1474 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1475
1476 while (loop)
1477 {
1478+#ifdef USE_NNTP
1479+ unset_option (OPTNEWS); /* for any case */
1480+#endif
1481 switch (op = mutt_menuLoop (menu))
1482 {
1483 case OP_REDRAW:
1484@@ -534,17 +598,87 @@ int mutt_compose_menu (HEADER *msg, /*
1485 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1486 break;
1487 case OP_COMPOSE_EDIT_TO:
1488+#ifdef USE_NNTP
1489+ if (news)
1490+ break;
1491+#endif
1492 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1493 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1494 break;
1495 case OP_COMPOSE_EDIT_BCC:
1496+#ifdef USE_NNTP
1497+ if (news)
1498+ break;
1499+#endif
1500 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1501 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1502 break;
1503 case OP_COMPOSE_EDIT_CC:
1504+#ifdef USE_NNTP
1505+ if (news)
1506+ break;
1507+#endif
1508 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1509 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1510 break;
1511+#ifdef USE_NNTP
1512+ case OP_COMPOSE_EDIT_NEWSGROUPS:
1513+ if (news)
1514+ {
1515+ if (msg->env->newsgroups)
1516+ strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1517+ else
1518+ buf[0] = 0;
1519+ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1520+ {
1521+ FREE (&msg->env->newsgroups);
1522+ mutt_remove_trailing_ws (buf);
1523+ msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1524+ move (HDR_TO, HDR_XOFFSET);
1525+ clrtoeol ();
1526+ if (msg->env->newsgroups)
1527+ printw ("%-*.*s", W, W, msg->env->newsgroups);
1528+ }
1529+ }
1530+ break;
1531+
1532+ case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1533+ if (news)
1534+ {
1535+ buf[0] = 0;
1536+ if (msg->env->followup_to)
1537+ strfcpy (buf, msg->env->followup_to, sizeof (buf));
1538+ if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1539+ {
1540+ FREE (&msg->env->followup_to);
1541+ mutt_remove_trailing_ws (buf);
1542+ msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1543+ move (HDR_CC, HDR_XOFFSET);
1544+ clrtoeol();
1545+ if (msg->env->followup_to)
1546+ printw ("%-*.*s", W, W, msg->env->followup_to);
1547+ }
1548+ }
1549+ break;
1550+
1551+ case OP_COMPOSE_EDIT_X_COMMENT_TO:
1552+ if (news && option (OPTXCOMMENTTO))
1553+ {
1554+ buf[0] = 0;
1555+ if (msg->env->x_comment_to)
1556+ strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1557+ if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1558+ {
1559+ FREE (&msg->env->x_comment_to);
1560+ msg->env->x_comment_to = safe_strdup (buf);
1561+ move (HDR_BCC, HDR_XOFFSET);
1562+ clrtoeol();
1563+ if (msg->env->x_comment_to)
1564+ printw ("%-*.*s", W, W, msg->env->x_comment_to);
1565+ }
1566+ }
1567+ break;
1568+#endif
1569 case OP_COMPOSE_EDIT_SUBJECT:
1570 if (msg->env->subject)
1571 strfcpy (buf, msg->env->subject, sizeof (buf));
1572@@ -707,6 +841,9 @@ int mutt_compose_menu (HEADER *msg, /*
1573 break;
1574
1575 case OP_COMPOSE_ATTACH_MESSAGE:
1576+#ifdef USE_NNTP
1577+ case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1578+#endif
1579 {
1580 char *prompt;
1581 HEADER *h;
1582@@ -714,7 +851,22 @@ int mutt_compose_menu (HEADER *msg, /*
1583 fname[0] = 0;
1584 prompt = _("Open mailbox to attach message from");
1585
1586+#ifdef USE_NNTP
1587+ unset_option (OPTNEWS);
1588+ if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1589+ {
1590+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1591+ break;
1592+
1593+ prompt = _("Open newsgroup to attach message from");
1594+ set_option (OPTNEWS);
1595+ }
1596+#endif
1597+
1598 if (Context)
1599+#ifdef USE_NNTP
1600+ if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1601+#endif
1602 {
1603 strfcpy (fname, NONULL (Context->path), sizeof (fname));
1604 mutt_pretty_mailbox (fname);
1605@@ -723,6 +875,11 @@ int mutt_compose_menu (HEADER *msg, /*
1606 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1607 break;
1608
1609+#ifdef USE_NNTP
1610+ if (option (OPTNEWS))
1611+ nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1612+ else
1613+#endif
1614 mutt_expand_path (fname, sizeof (fname));
1615 #ifdef USE_IMAP
1616 if (!mx_is_imap (fname))
1617@@ -730,6 +887,9 @@ int mutt_compose_menu (HEADER *msg, /*
1618 #ifdef USE_POP
1619 if (!mx_is_pop (fname))
1620 #endif
1621+#ifdef USE_NNTP
1622+ if (!mx_is_nntp (fname) && !option (OPTNEWS))
1623+#endif
1624 /* check to make sure the file exists and is readable */
1625 if (access (fname, R_OK) == -1)
1626 {
e1bffe0b
JB
1627diff -udprP mutt-1.5.15.orig/config.h.in mutt-1.5.15/config.h.in
1628--- mutt-1.5.15.orig/config.h.in 2007-04-06 10:18:47.000000000 +0300
1629+++ mutt-1.5.15/config.h.in 2007-04-11 17:25:15.000000000 +0300
1630@@ -34,6 +34,9 @@
95768aa9 1631 significant more memory when defined. */
1632 #undef EXACT_ADDRESS
1633
1634+/* Compiling with newsreading support with NNTP */
1635+#undef USE_NNTP
1636+
1637 /* program to use for shell commands */
1638 #undef EXECSHELL
1639
e1bffe0b
JB
1640diff -udprP mutt-1.5.15.orig/configure.ac mutt-1.5.15/configure.ac
1641--- mutt-1.5.15.orig/configure.ac 2007-04-06 10:11:53.000000000 +0300
1642+++ mutt-1.5.15/configure.ac 2007-04-11 17:25:15.000000000 +0300
1643@@ -584,6 +584,14 @@ if test x"$need_imap" = xyes -o x"$need_
95768aa9 1644 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1645 fi
1646
1647+AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1648+[ if test x$enableval = xyes ; then
1649+ AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1650+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1651+ need_socket="yes"
1652+ fi
1653+])
1654+
1655 dnl -- end socket dependencies --
1656
1657 if test "$need_socket" = "yes"
e1bffe0b
JB
1658diff -udprP mutt-1.5.15.orig/curs_main.c mutt-1.5.15/curs_main.c
1659--- mutt-1.5.15.orig/curs_main.c 2007-04-03 20:41:14.000000000 +0300
1660+++ mutt-1.5.15/curs_main.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 1661@@ -22,6 +22,7 @@
1662
1663 #include "mutt.h"
1664 #include "mutt_curses.h"
1665+#include "mx.h"
1666 #include "mutt_menu.h"
1667 #include "attach.h"
1668 #include "mailbox.h"
1669@@ -40,6 +41,10 @@
1670
1671 #include "mutt_crypt.h"
1672
1673+#ifdef USE_NNTP
1674+#include "nntp.h"
1675+#endif
1676+
1677
1678 #include <ctype.h>
1679 #include <stdlib.h>
1680@@ -415,12 +420,27 @@ struct mapping_t IndexHelp[] = {
1681 { NULL }
1682 };
1683
1684+#ifdef USE_NNTP
1685+struct mapping_t IndexNewsHelp[] = {
1686+ { N_("Quit"), OP_QUIT },
1687+ { N_("Del"), OP_DELETE },
1688+ { N_("Undel"), OP_UNDELETE },
1689+ { N_("Save"), OP_SAVE },
1690+ { N_("Post"), OP_POST },
1691+ { N_("Followup"), OP_FOLLOWUP },
1692+ { N_("Catchup"), OP_CATCHUP },
1693+ { N_("Help"), OP_HELP },
1694+ { NULL }
1695+};
1696+#endif
1697+
1698 /* This function handles the message index window as well as commands returned
1699 * from the pager (MENU_PAGER).
1700 */
1701 int mutt_index_menu (void)
1702 {
e1bffe0b 1703 char buf[LONG_STRING], helpstr[LONG_STRING];
95768aa9 1704+ int flags;
1705 int op = OP_NULL;
1706 int done = 0; /* controls when to exit the "event" loop */
1707 int i = 0, j;
1708@@ -442,7 +462,11 @@ int mutt_index_menu (void)
1709 menu->make_entry = index_make_entry;
1710 menu->color = index_color;
1711 menu->current = ci_first_message ();
1712- menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1713+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1714+#ifdef USE_NNTP
1715+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1716+#endif
1717+ IndexHelp);
1718
1719 if (!attach_msg)
1720 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
1721@@ -694,6 +718,9 @@ int mutt_index_menu (void)
1722 mutt_curs_set (1); /* fallback from the pager */
1723 }
1724
1725+#ifdef USE_NNTP
1726+ unset_option (OPTNEWS); /* for any case */
1727+#endif
1728 switch (op)
1729 {
1730
1731@@ -744,6 +771,120 @@ int mutt_index_menu (void)
1732 menu_current_bottom (menu);
1733 break;
1734
1735+#ifdef USE_NNTP
1736+ case OP_GET_MESSAGE:
1737+ case OP_GET_PARENT:
1738+ CHECK_MSGCOUNT;
1739+ if (Context->magic == M_NNTP)
1740+ {
1741+ HEADER *h;
1742+
1743+ if (op == OP_GET_MESSAGE)
1744+ {
1745+ buf[0] = 0;
1746+ if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1747+ || !buf[0])
1748+ break;
1749+ }
1750+ else
1751+ {
1752+ LIST *ref = CURHDR->env->references;
1753+ if (!ref)
1754+ {
1755+ mutt_error _("Article has no parent reference!");
1756+ break;
1757+ }
1758+ strfcpy (buf, ref->data, sizeof (buf));
1759+ }
1760+ if (!Context->id_hash)
1761+ Context->id_hash = mutt_make_id_hash (Context);
1762+ if ((h = hash_find (Context->id_hash, buf)))
1763+ {
1764+ if (h->virtual != -1)
1765+ {
1766+ menu->current = h->virtual;
1767+ menu->redraw = REDRAW_MOTION_RESYNCH;
1768+ }
1769+ else if (h->collapsed)
1770+ {
1771+ mutt_uncollapse_thread (Context, h);
1772+ mutt_set_virtual (Context);
1773+ menu->current = h->virtual;
1774+ menu->redraw = REDRAW_MOTION_RESYNCH;
1775+ }
1776+ else
1777+ mutt_error _("Message not visible in limited view.");
1778+ }
1779+ else
1780+ {
1781+ if (nntp_check_msgid (Context, buf) == 0)
1782+ {
1783+ h = Context->hdrs[Context->msgcount-1];
1784+ mutt_sort_headers (Context, 0);
1785+ menu->current = h->virtual;
1786+ menu->redraw = REDRAW_FULL;
1787+ }
1788+ else
1789+ mutt_error (_("Article %s not found on server"), buf);
1790+ }
1791+ }
1792+ break;
1793+
1794+ case OP_GET_CHILDREN:
1795+ case OP_RECONSTRUCT_THREAD:
1796+ CHECK_MSGCOUNT;
1797+ if (Context->magic == M_NNTP)
1798+ {
1799+ HEADER *h;
1800+ int old = CURHDR->index, i;
1801+
1802+ if (!CURHDR->env->message_id)
1803+ {
1804+ mutt_error _("No Message-Id. Unable to perform operation");
1805+ break;
1806+ }
1807+
1808+ if (!Context->id_hash)
1809+ Context->id_hash = mutt_make_id_hash (Context);
1810+ strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1811+
1812+ if (op == OP_RECONSTRUCT_THREAD)
1813+ {
1814+ LIST *ref = CURHDR->env->references;
1815+ while (ref)
1816+ {
1817+ nntp_check_msgid (Context, ref->data);
1818+ /* the last msgid in References is the root message */
1819+ if (!ref->next)
1820+ strfcpy (buf, ref->data, sizeof (buf));
1821+ ref = ref->next;
1822+ }
1823+ }
1824+ mutt_message _("Check for children of message...");
1825+ if (nntp_check_children (Context, buf) == 0)
1826+ {
1827+ mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1828+ h = hash_find (Context->id_hash, buf);
1829+ /* if the root message was retrieved, move to it */
1830+ if (h)
1831+ menu->current = h->virtual;
1832+ else /* try to restore old position */
1833+ for (i = 0; i < Context->msgcount; i++)
1834+ if (Context->hdrs[i]->index == old)
1835+ {
1836+ menu->current = Context->hdrs[i]->virtual;
1837+ /* As an added courtesy, recenter the menu
1838+ * with the current entry at the middle of the screen */
1839+ menu_check_recenter (menu);
1840+ menu_current_middle (menu);
1841+ }
1842+ }
1843+ menu->redraw = REDRAW_FULL;
1844+ mutt_clear_error ();
1845+ }
1846+ break;
1847+#endif
1848+
1849 case OP_JUMP:
1850
1851 CHECK_MSGCOUNT;
1852@@ -841,11 +982,33 @@ int mutt_index_menu (void)
1853 break;
1854
1855 case OP_MAIN_LIMIT:
1856+ case OP_TOGGLE_READ:
1857
1858 CHECK_IN_MAILBOX;
1859 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1860 CURHDR->index : -1;
1861- if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1862+ if (op == OP_TOGGLE_READ)
1863+ {
1864+ char buf[LONG_STRING];
1865+
1866+ if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1867+ {
1868+ snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1869+ Context->pattern ? Context->pattern : ".*");
1870+ set_option (OPTHIDEREAD);
1871+ }
1872+ else
1873+ {
1874+ strfcpy (buf, Context->pattern + 8, sizeof(buf));
1875+ if (!*buf || strncmp (buf, ".*", 2) == 0)
1876+ snprintf (buf, sizeof(buf), "~A");
1877+ unset_option (OPTHIDEREAD);
1878+ }
1879+ FREE (&Context->pattern);
1880+ Context->pattern = safe_strdup (buf);
1881+ }
1882+ if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1883+ mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1884 {
1885 if (menu->oldcurrent >= 0)
1886 {
1887@@ -1052,20 +1215,43 @@ int mutt_index_menu (void)
1888 break;
1889
1890 case OP_MAIN_CHANGE_FOLDER:
1891-
1892- if (attach_msg)
1893- op = OP_MAIN_CHANGE_FOLDER_READONLY;
1894-
1895- /* fallback to the readonly case */
1896-
1897 case OP_MAIN_CHANGE_FOLDER_READONLY:
1898+#ifdef USE_NNTP
1899+ case OP_MAIN_CHANGE_GROUP:
1900+ case OP_MAIN_CHANGE_GROUP_READONLY:
1901+#endif
1902
1903- if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1904+ if (attach_msg || option (OPTREADONLY) ||
1905+#ifdef USE_NNTP
1906+ op == OP_MAIN_CHANGE_GROUP_READONLY ||
1907+#endif
1908+ op == OP_MAIN_CHANGE_FOLDER_READONLY)
1909+ flags = M_READONLY;
1910+ else
1911+ flags = 0;
1912+
1913+ if (flags)
1914 cp = _("Open mailbox in read-only mode");
1915 else
1916 cp = _("Open mailbox");
1917
1918 buf[0] = '\0';
1919+#ifdef USE_NNTP
1920+ unset_option (OPTNEWS);
1921+ if (op == OP_MAIN_CHANGE_GROUP ||
1922+ op == OP_MAIN_CHANGE_GROUP_READONLY)
1923+ {
1924+ set_option (OPTNEWS);
1925+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1926+ break;
1927+ if (flags)
1928+ cp = _("Open newsgroup in read-only mode");
1929+ else
1930+ cp = _("Open newsgroup");
1931+ nntp_buffy (buf);
1932+ }
1933+ else
1934+#endif
1935 mutt_buffy (buf, sizeof (buf));
1936
1937 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
1938@@ -1084,6 +1270,14 @@ int mutt_index_menu (void)
1939 break;
1940 }
1941
1942+#ifdef USE_NNTP
1943+ if (option (OPTNEWS))
1944+ {
1945+ unset_option (OPTNEWS);
1946+ nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1947+ }
1948+ else
1949+#endif
1950 mutt_expand_path (buf, sizeof (buf));
1951 if (mx_get_magic (buf) <= 0)
1952 {
1953@@ -1121,15 +1315,18 @@ int mutt_index_menu (void)
1954 CurrentMenu = MENU_MAIN;
1955 mutt_folder_hook (buf);
1956
1957- if ((Context = mx_open_mailbox (buf,
1958- (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1959- M_READONLY : 0, NULL)) != NULL)
1960+ if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1961 {
1962 menu->current = ci_first_message ();
1963 }
1964 else
1965 menu->current = 0;
1966
1967+#ifdef USE_NNTP
1968+ /* mutt_buffy_check() must be done with mail-reader mode! */
1969+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1970+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1971+#endif
1972 mutt_clear_error ();
1973 mutt_buffy_check(1); /* force the buffy check after we have changed
1974 the folder */
e1bffe0b
JB
1975@@ -1500,6 +1697,15 @@ int mutt_index_menu (void)
1976 CHECK_READONLY;
1977 CHECK_ACL(M_ACL_WRITE, _("flag message"));
95768aa9 1978
1979+#ifdef USE_NNTP
1980+ if (Context->magic == M_NNTP)
1981+ {
1982+ mutt_flushinp ();
1983+ mutt_error _("Can't change 'important' flag on NNTP server.");
1984+ break;
1985+ }
1986+#endif
1987+
1988 if (tag)
1989 {
1990 for (j = 0; j < Context->vcount; j++)
e1bffe0b 1991@@ -1847,6 +2053,17 @@ int mutt_index_menu (void)
95768aa9 1992 }
1993 break;
1994
1995+#ifdef USE_NNTP
1996+ case OP_CATCHUP:
1997+ if (Context && Context->magic == M_NNTP)
1998+ {
1999+ if (mutt_newsgroup_catchup (CurrentNewsSrv,
2000+ ((NNTP_DATA *)Context->data)->group))
2001+ menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2002+ }
2003+ break;
2004+#endif
2005+
2006 case OP_DISPLAY_ADDRESS:
2007
2008 CHECK_MSGCOUNT;
e1bffe0b
JB
2009@@ -1974,6 +2191,15 @@ int mutt_index_menu (void)
2010 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
95768aa9 2011 }
2012 #endif
2013+
2014+#ifdef USE_NNTP
2015+ if (Context->magic == M_NNTP)
2016+ {
2017+ mutt_flushinp ();
2018+ mutt_error _("Can't edit message on newsserver.");
2019+ break;
2020+ }
2021+#endif
2022
e1bffe0b
JB
2023 MAYBE_REDRAW (menu->redraw);
2024 break;
2025@@ -2045,6 +2271,37 @@ int mutt_index_menu (void)
95768aa9 2026
2027 menu->redraw = REDRAW_FULL;
2028 break;
2029+
2030+#ifdef USE_NNTP
2031+ case OP_POST:
2032+ case OP_FOLLOWUP:
2033+ case OP_FORWARD_TO_GROUP:
2034+
2035+ CHECK_ATTACH;
2036+ if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2037+ mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2038+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2039+ {
2040+ if (Context && Context->magic == M_NNTP &&
2041+ !((NNTP_DATA *)Context->data)->allowed &&
2042+ query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2043+ break;
2044+ if (op == OP_POST)
2045+ ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2046+ else
2047+ {
2048+ CHECK_MSGCOUNT;
2049+ if (op == OP_FOLLOWUP)
2050+ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2051+ tag ? NULL : CURHDR);
2052+ else
2053+ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2054+ tag ? NULL : CURHDR);
2055+ }
2056+ menu->redraw = REDRAW_FULL;
2057+ break;
2058+ }
2059+#endif
2060
2061 case OP_REPLY:
2062
e1bffe0b 2063@@ -2118,6 +2375,12 @@ int mutt_index_menu (void)
95768aa9 2064 CHECK_READONLY;
e1bffe0b 2065 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
95768aa9 2066
2067+#ifdef USE_NNTP
2068+ /* Close all open NNTP connections */
2069+ if (!attach_msg)
2070+ nntp_logout_all ();
2071+#endif
2072+
2073 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2074 op == OP_UNDELETE_THREAD ? 0 : 1);
2075
e1bffe0b
JB
2076diff -udprP mutt-1.5.15.orig/doc/manual.xml.head mutt-1.5.15/doc/manual.xml.head
2077--- mutt-1.5.15.orig/doc/manual.xml.head 2007-04-04 08:37:13.000000000 +0300
2078+++ mutt-1.5.15/doc/manual.xml.head 2007-04-11 17:25:15.000000000 +0300
2079@@ -1295,6 +1295,22 @@ fo-table</literal> for details.
95768aa9 2080
2081 </sect2>
2082
2083+<sect2>
2084+<title>Reading news via NNTP</title>
2085+
2086+<para>
2087+If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2088+read news from newsserver via NNTP. You can open a newsgroup with
2089+function ``change-newsgroup'' (default: ``i''). Default newsserver
2090+can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2091+variable. Like other news readers, info about subscribed newsgroups
2092+is saved in file by <link linkend="newsrc">&dollar;newsrc</link>
2093+variable. Article headers are cached and can be loaded from file when
2094+newsgroup entered instead loading from newsserver.
2095+</para>
2096+
2097+</sect2>
2098+
2099 </sect1>
2100
2101 <sect1 id="forwarding-mail">
e1bffe0b
JB
2102diff -udprP mutt-1.5.15.orig/doc/mutt.man mutt-1.5.15/doc/mutt.man
2103--- mutt-1.5.15.orig/doc/mutt.man 2007-04-04 08:37:13.000000000 +0300
2104+++ mutt-1.5.15/doc/mutt.man 2007-04-11 17:25:15.000000000 +0300
95768aa9 2105@@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2106 .SH SYNOPSIS
2107 .PP
2108 .B mutt
2109-[-nRyzZ]
2110-[-e \fIcmd\fP] [-F \fIfile\fP] [-m \fItype\fP] [-f \fIfile\fP]
2111+[-GnRyzZ]
2112+[-e \fIcmd\fP] [-F \fIfile\fP] [-g \fIserver\fP] [-m \fItype\fP] [-f \fIfile\fP]
2113 .PP
2114 .B mutt
2115 [-nx]
e1bffe0b 2116@@ -83,6 +83,10 @@ files.
95768aa9 2117 Specify which mailbox to load.
2118 .IP "-F \fImuttrc\fP"
2119 Specify an initialization file to read instead of ~/.muttrc
2120+.IP "-g \fIserver\fP"
2121+Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2122+.IP "-G"
2123+Start Mutt with a listing of subscribed newsgroups.
2124 .IP "-h"
2125 Display help.
2126 .IP "-H \fIdraft\fP"
e1bffe0b
JB
2127diff -udprP mutt-1.5.15.orig/functions.h mutt-1.5.15/functions.h
2128--- mutt-1.5.15.orig/functions.h 2007-04-02 00:58:55.000000000 +0300
2129+++ mutt-1.5.15/functions.h 2007-04-11 17:25:15.000000000 +0300
2130@@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in
95768aa9 2131 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2132 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2133 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2134+#ifdef USE_NNTP
a1403320 2135+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "I" },
95768aa9 2136+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2137+#endif
2138 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2139 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
2140 { "copy-message", OP_COPY_MESSAGE, "C" },
a1403320 2141@@ -101,6 +105,14 @@ struct binding_t OpMain[] = { /* map: in
95768aa9 2142 { "edit-type", OP_EDIT_TYPE, "\005" },
2143 { "forward-message", OP_FORWARD_MESSAGE, "f" },
a1403320 2144 { "flag-message", OP_FLAG_MESSAGE, "F" },
95768aa9 2145+#ifdef USE_NNTP
2146+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
a1403320 2147+ { "followup-message", OP_FOLLOWUP, "\033f" },
95768aa9 2148+ { "get-children", OP_GET_CHILDREN, NULL },
2149+ { "get-message", OP_GET_MESSAGE, "\007" },
2150+ { "get-parent", OP_GET_PARENT, "\033G" },
2151+ { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2152+#endif
95768aa9 2153 { "group-reply", OP_GROUP_REPLY, "g" },
2154 #ifdef USE_POP
2155 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
e1bffe0b 2156@@ -126,6 +138,9 @@ struct binding_t OpMain[] = { /* map: in
95768aa9 2157 { "sort-mailbox", OP_SORT, "o" },
2158 { "sort-reverse", OP_SORT_REVERSE, "O" },
2159 { "print-message", OP_PRINT, "p" },
2160+#ifdef USE_NNTP
a1403320 2161+ { "post-message", OP_POST, "\033m" },
95768aa9 2162+#endif
2163 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2164 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2165 { "recall-message", OP_RECALL_MESSAGE, "R" },
e1bffe0b 2166@@ -145,6 +160,10 @@ struct binding_t OpMain[] = { /* map: in
95768aa9 2167 { "show-version", OP_VERSION, "V" },
2168 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2169 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2170+ { "toggle-read", OP_TOGGLE_READ, "X" },
2171+#ifdef USE_NNTP
2172+ { "catchup", OP_CATCHUP, "y" },
2173+#endif
2174 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2175 { "buffy-list", OP_BUFFY_LIST, "." },
2176 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
e1bffe0b 2177@@ -176,6 +195,10 @@ struct binding_t OpPager[] = { /* map: p
95768aa9 2178 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2179 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2180 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2181+#ifdef USE_NNTP
2182+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2183+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2184+#endif
2185 { "copy-message", OP_COPY_MESSAGE, "C" },
2186 { "decode-copy", OP_DECODE_COPY, "\033C" },
2187 { "delete-message", OP_DELETE, "d" },
a1403320 2188@@ -183,6 +206,10 @@ struct binding_t OpPager[] = { /* map: p
95768aa9 2189 { "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" },
2190 { "edit", OP_EDIT_MESSAGE, "e" },
2191 { "edit-type", OP_EDIT_TYPE, "\005" },
2192+#ifdef USE_NNTP
a1403320 2193+ { "followup-message", OP_FOLLOWUP, "\033f" },
95768aa9 2194+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2195+#endif
2196 { "forward-message", OP_FORWARD_MESSAGE, "f" },
a1403320 2197 { "flag-message", OP_FLAG_MESSAGE, "F" },
95768aa9 2198 { "group-reply", OP_GROUP_REPLY, "g" },
e1bffe0b 2199@@ -203,6 +230,9 @@ struct binding_t OpPager[] = { /* map: p
95768aa9 2200 { "next-thread", OP_MAIN_NEXT_THREAD, "\016" },
2201 { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" },
2202 { "print-message", OP_PRINT, "p" },
2203+#ifdef USE_NNTP
a1403320 2204+ { "post-message", OP_POST, "\033m" },
95768aa9 2205+#endif
2206 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2207 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2208 { "quit", OP_QUIT, "Q" },
e1bffe0b 2209@@ -270,6 +300,10 @@ struct binding_t OpAttach[] = { /* map:
95768aa9 2210 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2211 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2212 { "edit-type", OP_EDIT_TYPE, "\005" },
2213+#ifdef USE_NNTP
2214+ { "followup-message", OP_FOLLOWUP, "F" },
2215+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2216+#endif
2217 { "print-entry", OP_PRINT, "p" },
2218 { "save-entry", OP_SAVE, "s" },
2219 { "pipe-entry", OP_PIPE, "|" },
e1bffe0b
JB
2220@@ -295,6 +329,7 @@ struct binding_t OpAttach[] = { /* map:
2221 struct binding_t OpCompose[] = { /* map: compose */
95768aa9 2222 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2223 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2224+ { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2225 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2226 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2227 { "copy-file", OP_SAVE, "C" },
e1bffe0b 2228@@ -314,6 +349,11 @@ struct binding_t OpCompose[] = { /* map:
95768aa9 2229 { "print-entry", OP_PRINT, "l" },
2230 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2231 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2232+#ifdef USE_NNTP
2233+ { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2234+ { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2235+ { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2236+#endif
2237 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2238 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2239 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
e1bffe0b 2240@@ -365,14 +405,25 @@ struct binding_t OpBrowser[] = { /* map:
95768aa9 2241 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2242 { "check-new", OP_CHECK_NEW, NULL },
2243 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2244+#ifdef USE_NNTP
2245+ { "reload-active", OP_LOAD_ACTIVE, "g" },
2246+ { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2247+ { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2248+ { "catchup", OP_CATCHUP, "y" },
2249+ { "uncatchup", OP_UNCATCHUP, "Y" },
2250+#endif
2251 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2252 { "buffy-list", OP_BUFFY_LIST, "." },
2253 #ifdef USE_IMAP
2254 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2255 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2256 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2257+#endif
2258+#if defined USE_IMAP || defined USE_NNTP
2259 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2260 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2261+#endif
2262+#ifdef USE_IMAP
2263 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2264 #endif
2265 { NULL, 0, NULL }
e1bffe0b
JB
2266diff -udprP mutt-1.5.15.orig/globals.h mutt-1.5.15/globals.h
2267--- mutt-1.5.15.orig/globals.h 2007-04-05 19:04:56.000000000 +0300
2268+++ mutt-1.5.15/globals.h 2007-04-11 17:25:15.000000000 +0300
2269@@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
95768aa9 2270 #endif
2271
2272 WHERE char *Muttrc INITVAL (NULL);
2273+#ifdef USE_NNTP
2274+WHERE char *NewsCacheDir;
2275+WHERE char *GroupFormat;
2276+WHERE char *Inews;
2277+WHERE char *NewsServer;
2278+WHERE char *NntpUser;
2279+WHERE char *NntpPass;
2280+WHERE char *NewsRc;
2281+#endif
2282 WHERE char *Outbox;
2283 WHERE char *Pager;
2284 WHERE char *PagerFmt;
e1bffe0b 2285@@ -189,6 +198,11 @@ extern unsigned char QuadOptions[];
95768aa9 2286
2287 WHERE unsigned short Counter INITVAL (0);
2288
2289+#ifdef USE_NNTP
2290+WHERE short NewsPollTimeout;
2291+WHERE short NntpContext;
2292+#endif
2293+
2294 WHERE short ConnectTimeout;
2295 WHERE short HistSize;
2296 WHERE short MenuContext;
e1bffe0b
JB
2297diff -udprP mutt-1.5.15.orig/hash.c mutt-1.5.15/hash.c
2298--- mutt-1.5.15.orig/hash.c 2007-04-02 00:58:56.000000000 +0300
2299+++ mutt-1.5.15/hash.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 2300@@ -51,10 +51,35 @@ HASH *hash_create (int nelem)
2301 if (nelem == 0)
2302 nelem = 2;
2303 table->nelem = nelem;
2304+ table->curnelem = 0;
2305 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2306 return table;
2307 }
2308
2309+HASH *hash_resize (HASH *ptr, int nelem)
2310+{
2311+ HASH *table;
2312+ struct hash_elem *elem, *tmp;
2313+ int i;
2314+
2315+ table = hash_create (nelem);
2316+
2317+ for (i = 0; i < ptr->nelem; i++)
2318+ {
2319+ for (elem = ptr->table[i]; elem; )
2320+ {
2321+ tmp = elem;
2322+ elem = elem->next;
2323+ hash_insert (table, tmp->key, tmp->data, 1);
2324+ FREE (&tmp);
2325+ }
2326+ }
2327+ FREE (&ptr->table);
2328+ FREE (&ptr);
2329+
2330+ return table;
2331+}
2332+
2333 /* table hash table to update
2334 * key key to hash on
2335 * data data to associate with `key'
2336@@ -74,6 +99,7 @@ int hash_insert (HASH * table, const cha
2337 {
2338 ptr->next = table->table[h];
2339 table->table[h] = ptr;
2340+ table->curnelem++;
2341 }
2342 else
2343 {
2344@@ -96,6 +122,7 @@ int hash_insert (HASH * table, const cha
2345 else
2346 table->table[h] = ptr;
2347 ptr->next = tmp;
2348+ table->curnelem++;
2349 }
2350 return h;
2351 }
2352@@ -126,6 +153,7 @@ void hash_delete_hash (HASH * table, int
2353 if (destroy)
2354 destroy (ptr->data);
2355 FREE (&ptr);
2356+ table->curnelem--;
2357
2358 ptr = *last;
2359 }
e1bffe0b
JB
2360diff -udprP mutt-1.5.15.orig/hash.h mutt-1.5.15/hash.h
2361--- mutt-1.5.15.orig/hash.h 2007-04-02 00:58:56.000000000 +0300
2362+++ mutt-1.5.15/hash.h 2007-04-11 17:25:15.000000000 +0300
95768aa9 2363@@ -28,7 +28,7 @@ struct hash_elem
2364
2365 typedef struct
2366 {
2367- int nelem;
2368+ int nelem, curnelem;
2369 struct hash_elem **table;
2370 }
2371 HASH;
2372@@ -40,6 +40,7 @@ HASH;
2373 HASH *hash_create (int nelem);
2374 int hash_string (const unsigned char *s, int n);
2375 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2376+HASH *hash_resize (HASH * table, int nelem);
2377 void *hash_find_hash (const HASH * table, int hash, const char *key);
2378 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2379 void (*destroy) (void *));
e1bffe0b
JB
2380diff -udprP mutt-1.5.15.orig/hdrline.c mutt-1.5.15/hdrline.c
2381--- mutt-1.5.15.orig/hdrline.c 2007-04-03 20:52:56.000000000 +0300
2382+++ mutt-1.5.15/hdrline.c 2007-04-11 17:29:25.000000000 +0300
2383@@ -209,6 +209,7 @@ int mutt_user_is_recipient (HEADER *h)
95768aa9 2384 * %E = number of messages in current thread
2385 * %f = entire from line
2386 * %F = like %n, unless from self
2387+ * %g = newsgroup name (if compiled with nntp support)
2388 * %i = message-id
2389 * %l = number of lines in the message
2390 * %L = like %F, except `lists' are displayed first
e1bffe0b
JB
2391@@ -216,12 +217,14 @@ int mutt_user_is_recipient (HEADER *h)
2392 * %n = name of author
2393 * %N = score
2394 * %O = like %L, except using address instead of name
2395+ * %R = `x-comment-to:' field (if present and compiled with nntp support)
2396 * %s = subject
2397 * %S = short message status (e.g., N/O/D/!/r/-)
2398 * %t = `to:' field (recipients)
95768aa9 2399 * %T = $to_chars
2400 * %u = user (login) name of author
2401 * %v = first name of author, unless from self
2402+ * %W = where user is (organization)
2403 * %X = number of MIME attachments
2404 * %y = `x-label:' field (if present)
2405 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
e1bffe0b 2406@@ -459,6 +462,12 @@ hdr_format_str (char *dest,
95768aa9 2407
2408 break;
2409
2410+#ifdef USE_NNTP
2411+ case 'g':
2412+ mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2413+ break;
2414+#endif
2415+
2416 case 'i':
2417 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2418 break;
e1bffe0b
JB
2419@@ -546,6 +555,15 @@ hdr_format_str (char *dest,
2420 }
2421 break;
2422
2423+#ifdef USE_NNTP
2424+ case 'R':
2425+ if (!optional)
2426+ mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2427+ else if (!hdr->env->x_comment_to)
2428+ optional = 0;
2429+ break;
2430+#endif
2431+
2432 case 's':
2433
2434 if (flags & M_FORMAT_TREE && !hdr->collapsed)
2435@@ -635,6 +653,13 @@ hdr_format_str (char *dest,
95768aa9 2436 mutt_format_s (dest, destlen, prefix, buf2);
2437 break;
2438
2439+ case 'W':
2440+ if (!optional)
2441+ mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2442+ else if (!hdr->env->organization)
2443+ optional = 0;
2444+ break;
2445+
2446 case 'Z':
2447
2448 ch = ' ';
e1bffe0b
JB
2449diff -udprP mutt-1.5.15.orig/headers.c mutt-1.5.15/headers.c
2450--- mutt-1.5.15.orig/headers.c 2007-04-02 00:58:56.000000000 +0300
2451+++ mutt-1.5.15/headers.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 2452@@ -118,6 +118,9 @@ void mutt_edit_headers (const char *edit
2453 msg->env = n; n = NULL;
2454
2455 if (!msg->env->in_reply_to)
2456+#ifdef USE_NNTP
2457+ if (!option (OPTNEWSSEND))
2458+#endif
2459 mutt_free_list (&msg->env->references);
2460
2461 mutt_expand_aliases_env (msg->env);
e1bffe0b
JB
2462diff -udprP mutt-1.5.15.orig/init.c mutt-1.5.15/init.c
2463--- mutt-1.5.15.orig/init.c 2007-04-02 00:58:56.000000000 +0300
2464+++ mutt-1.5.15/init.c 2007-04-11 17:25:15.000000000 +0300
2465@@ -2859,6 +2859,28 @@ void mutt_init (int skip_sys_rc, LIST *c
95768aa9 2466 else
2467 Fqdn = safe_strdup(NONULL(Hostname));
2468
2469+#ifdef USE_NNTP
2470+ {
2471+ FILE *f;
2472+ char *i;
2473+
2474+ if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2475+ {
2476+ buffer[0] = '\0';
2477+ fgets (buffer, sizeof (buffer), f);
2478+ p = &buffer;
2479+ SKIPWS (p);
2480+ i = p;
2481+ while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2482+ *i = '\0';
2483+ NewsServer = safe_strdup (p);
2484+ fclose (f);
2485+ }
2486+ }
2487+ if ((p = getenv ("NNTPSERVER")))
2488+ NewsServer = safe_strdup (p);
2489+#endif
2490+
2491 if ((p = getenv ("MAIL")))
2492 Spoolfile = safe_strdup (p);
2493 else if ((p = getenv ("MAILDIR")))
e1bffe0b
JB
2494diff -udprP mutt-1.5.15.orig/init.h mutt-1.5.15/init.h
2495--- mutt-1.5.15.orig/init.h 2007-04-05 19:03:55.000000000 +0300
2496+++ mutt-1.5.15/init.h 2007-04-11 17:29:25.000000000 +0300
2497@@ -169,6 +169,20 @@ struct option_t MuttVars[] = {
95768aa9 2498 ** If set, Mutt will prompt you for carbon-copy (Cc) recipients before
2499 ** editing the body of an outgoing message.
2500 */
2501+#ifdef USE_NNTP
2502+ { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2503+ /*
2504+ ** .pp
2505+ ** If set, Mutt will prompt you for follow-up groups before editing
2506+ ** the body of an outgoing message.
2507+ */
2508+ { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2509+ /*
2510+ ** .pp
2511+ ** If set, Mutt will prompt you for x-comment-to field before editing
2512+ ** the body of an outgoing message.
2513+ */
2514+#endif
e1bffe0b 2515 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
95768aa9 2516 /*
2517 ** .pp
e1bffe0b
JB
2518@@ -308,6 +322,14 @@ struct option_t MuttVars[] = {
2519 ** When this variable is set, mutt will use file size attribute instead of
2520 ** access time when checking for new mail.
95768aa9 2521 */
2522+#ifdef USE_NNTP
2523+ { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2524+ /*
2525+ ** .pp
2526+ ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2527+ ** as read when you quit the newsgroup (catchup newsgroup).
2528+ */
2529+#endif
2530 { "charset", DT_STR, R_NONE, UL &Charset, UL 0 },
2531 /*
2532 ** .pp
e1bffe0b 2533@@ -635,6 +657,16 @@ struct option_t MuttVars[] = {
95768aa9 2534 ** sent to both the list and your address, resulting in two copies
2535 ** of the same email for you.
2536 */
2537+#ifdef USE_NNTP
2538+ { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2539+ /*
2540+ ** .pp
2541+ ** If this variable is \fIset\fP and the keyword "poster" is present in
2542+ ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2543+ ** permitted. The message will be mailed to the submitter of the
2544+ ** message via mail.
2545+ */
2546+#endif
2547 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2548 /*
2549 ** .pp
e1bffe0b 2550@@ -706,6 +738,27 @@ struct option_t MuttVars[] = {
95768aa9 2551 ** a regular expression that will match the whole name so mutt will expand
2552 ** "Franklin" to "Franklin, Steve".
2553 */
2554+#ifdef USE_NNTP
2555+ { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2556+ /*
2557+ ** .pp
2558+ ** This variable allows you to customize the newsgroup browser display to
2559+ ** your personal taste. This string is similar to ``$index_format'', but
2560+ ** has its own set of printf()-like sequences:
2561+ ** .pp
2562+ ** .ts
2563+ ** %C current newsgroup number
2564+ ** %d description of newsgroup (becomes from server)
2565+ ** %f newsgroup name
2566+ ** %M - if newsgroup not allowed for direct post (moderated for example)
2567+ ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2568+ ** %n number of new articles in newsgroup
2569+ ** %s number of unread articles in newsgroup
2570+ ** %>X right justify the rest of the string and pad with character "X"
2571+ ** %|X pad to the end of the line with character "X"
2572+ ** .te
2573+ */
2574+#endif
2575 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2576 /*
2577 */
e1bffe0b 2578@@ -996,6 +1049,7 @@ struct option_t MuttVars[] = {
95768aa9 2579 ** .dt %E .dd number of messages in current thread
2580 ** .dt %f .dd entire From: line (address + real name)
2581 ** .dt %F .dd author name, or recipient name if the message is from you
2582+ ** .dt %g .dd newsgroup name (if compiled with nntp support)
2583 ** .dt %H .dd spam attribute(s) of this message
2584 ** .dt %i .dd message-id of the current message
2585 ** .dt %l .dd number of lines in the message (does not work with maildir,
e1bffe0b
JB
2586@@ -1009,12 +1063,14 @@ struct option_t MuttVars[] = {
2587 ** .dt %n .dd author's real name (or address if missing)
2588 ** .dt %O .dd (_O_riginal save folder) Where mutt would formerly have
2589 ** stashed the message: list name or recipient name if no list
2590+ ** .dt %R .dd `x-comment-to:' field (if present and compiled with nntp support)
2591 ** .dt %s .dd subject of the message
2592 ** .dt %S .dd status of the message (N/D/d/!/r/\(as)
2593 ** .dt %t .dd `to:' field (recipients)
95768aa9 2594 ** .dt %T .dd the appropriate character from the $$to_chars string
2595 ** .dt %u .dd user (login) name of the author
2596 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2597+ ** .dt %W .dd name of organization of author (`organization:' field)
2598 ** .dt %X .dd number of attachments
2599 ** (please see the ``$attachments'' section for possible speed effects)
2600 ** .dt %y .dd `x-label:' field, if present
e1bffe0b 2601@@ -1039,6 +1095,21 @@ struct option_t MuttVars[] = {
95768aa9 2602 ** .pp
2603 ** See also: ``$$to_chars''.
2604 */
2605+#ifdef USE_NNTP
2606+ { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2607+ /*
2608+ ** .pp
2609+ ** If set, specifies the program and arguments used to deliver news posted
2610+ ** by Mutt. Otherwise, mutt posts article using current connection to
2611+ ** news server. The following printf-style sequence is understood:
2612+ ** .pp
2613+ ** .ts
2614+ ** %s newsserver name
2615+ ** .te
2616+ ** .pp
2617+ ** Example: set inews="/usr/local/bin/inews -hS"
2618+ */
2619+#endif
2620 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2621 /*
2622 ** .pp
e1bffe0b 2623@@ -1253,6 +1324,16 @@ struct option_t MuttVars[] = {
95768aa9 2624 ** be attached to the newly composed message if this option is set.
2625 */
2626
2627+#ifdef USE_NNTP
2628+ { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2629+ /*
2630+ ** .pp
2631+ ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2632+ ** encoded according to RFC2047 to base64. This is useful when message
2633+ ** is Usenet article, because MIME for news is nonstandard feature.
2634+ */
2635+#endif
2636+
2637 #ifdef MIXMASTER
2638 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2639 /*
e1bffe0b 2640@@ -1323,6 +1404,77 @@ struct option_t MuttVars[] = {
95768aa9 2641 ** See also ``$$read_inc'' and ``$$write_inc''.
2642 */
2643 #endif
2644+#ifdef USE_NNTP
2645+ { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2646+ /*
2647+ ** .pp
2648+ ** This variable pointing to directory where Mutt will save cached news
2649+ ** articles headers in. If \fIunset\fP, headers will not be saved at all
2650+ ** and will be reloaded each time when you enter to newsgroup.
2651+ */
2652+ { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2653+ /*
2654+ ** .pp
2655+ ** This variable specifies domain name or address of NNTP server. It
2656+ ** defaults to the newsserver specified in the environment variable
2657+ ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2658+ ** specify username and an alternative port for each newsserver, ie:
2659+ ** .pp
e1bffe0b 2660+ ** [news[s]://][username[:password]@]newsserver[:port]
95768aa9 2661+ */
2662+ { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2663+ /*
2664+ ** .pp
2665+ ** The file, containing info about subscribed newsgroups - names and
2666+ ** indexes of read articles. The following printf-style sequence
2667+ ** is understood:
2668+ ** .pp
2669+ ** .ts
2670+ ** %s newsserver name
2671+ ** .te
2672+ */
2673+ { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2674+ /*
2675+ ** .pp
2676+ ** This variable defines number of articles which will be in index when
2677+ ** newsgroup entered. If active newsgroup have more articles than this
2678+ ** number, oldest articles will be ignored. Also controls how many
2679+ ** articles headers will be saved in cache when you quit newsgroup.
2680+ */
2681+ { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2682+ /*
2683+ ** .pp
2684+ ** This variable controls whether or not descriptions for each newsgroup
2685+ ** must be loaded when newsgroup is added to list (first time list
2686+ ** loading or new newsgroup adding).
2687+ */
2688+ { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2689+ /*
2690+ ** .pp
2691+ ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2692+ ** authentification, Mutt will prompt you for your account name when you
2693+ ** connect to newsserver.
2694+ */
2695+ { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2696+ /*
2697+ ** .pp
2698+ ** Your password for NNTP account.
2699+ */
2700+ { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2701+ /*
2702+ ** .pp
2703+ ** The time in seconds until any operations on newsgroup except post new
2704+ ** article will cause recheck for new news. If set to 0, Mutt will
2705+ ** recheck newsgroup on each operation in index (stepping, read article,
2706+ ** etc.).
2707+ */
2708+ { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2709+ /*
2710+ ** .pp
2711+ ** Controls whether or not Mutt will try to reconnect to newsserver when
2712+ ** connection lost.
2713+ */
2714+#endif
2715 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2716 /*
2717 ** .pp
e1bffe0b 2718@@ -2133,6 +2285,16 @@ struct option_t MuttVars[] = {
95768aa9 2719 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2720 /*
2721 */
2722+#ifdef USE_NNTP
2723+ { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2724+ /*
2725+ ** .pp
2726+ ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2727+ ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2728+ ** does not support posting to that newsgroup or totally read-only, that
2729+ ** posting will not have an effect.
2730+ */
2731+#endif
2732 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2733 /*
2734 ** .pp
e1bffe0b 2735@@ -2489,6 +2651,28 @@ struct option_t MuttVars[] = {
95768aa9 2736 ** Command to use when spawning a subshell. By default, the user's login
2737 ** shell from /etc/passwd is used.
2738 */
2739+#ifdef USE_NNTP
2740+ { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2741+ /*
2742+ ** .pp
2743+ ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2744+ ** ``newsrc'' file and into cache.
2745+ */
2746+ { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2747+ /*
2748+ ** .pp
2749+ ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2750+ ** the browser. Otherwise, it will be done only once for a newsserver.
2751+ ** Also controls whether or not number of new articles of subscribed
2752+ ** newsgroups will be then checked.
2753+ */
2754+ { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2755+ /*
2756+ ** .pp
2757+ ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2758+ ** will be displayed in browser.
2759+ */
2760+#endif
2761 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2762 /*
2763 ** .pp
e1bffe0b
JB
2764@@ -2987,6 +3171,14 @@ struct option_t MuttVars[] = {
2765 ** option does nothing: mutt will never write out the BCC header
2766 ** in this case.
95768aa9 2767 */
2768+#ifdef USE_NNTP
2769+ { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2770+ /*
2771+ ** .pp
2772+ ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2773+ ** name of original article author) to article that followuped to newsgroup.
2774+ */
2775+#endif
2776 /*--*/
2777 { NULL }
2778 };
e1bffe0b
JB
2779diff -udprP mutt-1.5.15.orig/mailbox.h mutt-1.5.15/mailbox.h
2780--- mutt-1.5.15.orig/mailbox.h 2007-04-02 00:58:56.000000000 +0300
2781+++ mutt-1.5.15/mailbox.h 2007-04-11 17:25:15.000000000 +0300
95768aa9 2782@@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2783 #ifdef USE_POP
2784 int mx_is_pop (const char *);
2785 #endif
2786+#ifdef USE_NNTP
2787+int mx_is_nntp (const char *);
2788+#endif
2789
2790 int mx_access (const char*, int);
2791 int mx_check_empty (const char *);
e1bffe0b
JB
2792diff -udprP mutt-1.5.15.orig/main.c mutt-1.5.15/main.c
2793--- mutt-1.5.15.orig/main.c 2007-04-04 08:37:13.000000000 +0300
2794+++ mutt-1.5.15/main.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 2795@@ -56,6 +56,10 @@
2796 #include <stringprep.h>
2797 #endif
2798
2799+#ifdef USE_NNTP
e1bffe0b 2800+#include "nntp.h"
95768aa9 2801+#endif
2802+
2803 static const char *ReachingUs = N_("\
2804 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2805 To report a bug, please visit http://bugs.mutt.org/.\n");
2806@@ -127,6 +131,8 @@ options:\n\
2807 " -e <command>\tspecify a command to be executed after initialization\n\
2808 -f <file>\tspecify which mailbox to read\n\
2809 -F <file>\tspecify an alternate muttrc file\n\
2810+ -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2811+ -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2812 -H <file>\tspecify a draft file to read header and body from\n\
2813 -i <file>\tspecify a file which Mutt should include in the body\n\
2814 -m <type>\tspecify a default mailbox type\n\
e1bffe0b 2815@@ -253,6 +259,12 @@ static void show_version (void)
95768aa9 2816 "-USE_POP "
2817 #endif
2818
2819+#ifdef USE_NNTP
2820+ "+USE_NNTP "
2821+#else
2822+ "-USE_NNTP "
2823+#endif
2824+
2825 #ifdef USE_IMAP
2826 "+USE_IMAP "
2827 #else
e1bffe0b 2828@@ -521,6 +533,9 @@ static void start_curses (void)
95768aa9 2829 #define M_NOSYSRC (1<<2) /* -n */
2830 #define M_RO (1<<3) /* -R */
2831 #define M_SELECT (1<<4) /* -y */
2832+#ifdef USE_NNTP
2833+#define M_NEWS (1<<5) /* -g and -G */
2834+#endif
2835
2836 int main (int argc, char **argv)
2837 {
e1bffe0b
JB
2838@@ -577,7 +592,11 @@ int main (int argc, char **argv)
2839 break;
2840 }
2841
95768aa9 2842+#ifdef USE_NNTP
2843+ while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2844+#else
2845 while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2846+#endif
2847 switch (i)
2848 {
2849 case 'A':
e1bffe0b 2850@@ -670,6 +689,20 @@ int main (int argc, char **argv)
95768aa9 2851 flags |= M_SELECT;
2852 break;
2853
2854+#ifdef USE_NNTP
2855+ case 'g': /* Specify a newsserver */
2856+ {
2857+ char buf[LONG_STRING];
2858+
2859+ snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2860+ commands = mutt_add_list (commands, buf);
2861+ }
2862+
2863+ case 'G': /* List of newsgroups */
2864+ flags |= M_SELECT | M_NEWS;
2865+ break;
2866+#endif
2867+
2868 case 'z':
2869 flags |= M_IGNORE;
2870 break;
e1bffe0b 2871@@ -943,6 +976,18 @@ int main (int argc, char **argv)
95768aa9 2872 }
2873 else if (flags & M_SELECT)
2874 {
2875+#ifdef USE_NNTP
2876+ if (flags & M_NEWS)
2877+ {
2878+ set_option (OPTNEWS);
2879+ if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2880+ {
2881+ mutt_endwin (Errorbuf);
2882+ exit (1);
2883+ }
2884+ }
2885+ else
2886+#endif
2887 if (!Incoming) {
2888 mutt_endwin _("No incoming mailboxes defined.");
2889 exit (1);
e1bffe0b 2890@@ -958,6 +1003,15 @@ int main (int argc, char **argv)
95768aa9 2891
2892 if (!folder[0])
2893 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2894+
2895+#ifdef USE_NNTP
2896+ if (option (OPTNEWS))
2897+ {
2898+ unset_option (OPTNEWS);
2899+ nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2900+ }
2901+ else
2902+#endif
2903 mutt_expand_path (folder, sizeof (folder));
2904
2905 mutt_str_replace (&CurrentFolder, folder);
e1bffe0b
JB
2906diff -udprP mutt-1.5.15.orig/mutt.h mutt-1.5.15/mutt.h
2907--- mutt-1.5.15.orig/mutt.h 2007-04-02 21:04:35.000000000 +0300
2908+++ mutt-1.5.15/mutt.h 2007-04-11 17:25:15.000000000 +0300
2909@@ -243,6 +243,9 @@ enum
95768aa9 2910 M_PGP_KEY,
2911 M_XLABEL,
2912 M_MIMEATTACH,
2913+#ifdef USE_NNTP
2914+ M_NEWSGROUPS,
2915+#endif
2916
2917 /* Options for Mailcap lookup */
2918 M_EDIT,
e1bffe0b 2919@@ -298,6 +301,12 @@ enum
95768aa9 2920 #endif
2921 OPT_SUBJECT,
2922 OPT_VERIFYSIG, /* verify PGP signatures */
2923+#ifdef USE_NNTP
2924+ OPT_TOMODERATED,
2925+ OPT_NNTPRECONNECT,
2926+ OPT_CATCHUP,
2927+ OPT_FOLLOWUPTOPOSTER,
2928+#endif /* USE_NNTP */
2929
2930 /* THIS MUST BE THE LAST VALUE. */
2931 OPT_MAX
e1bffe0b 2932@@ -313,6 +322,7 @@ enum
95768aa9 2933 #define SENDMAILX (1<<6)
2934 #define SENDKEY (1<<7)
2935 #define SENDRESEND (1<<8)
2936+#define SENDNEWS (1<<9)
2937
2938 /* flags to _mutt_select_file() */
2939 #define M_SEL_BUFFY (1<<0)
e1bffe0b 2940@@ -332,6 +342,8 @@ enum
95768aa9 2941 OPTASCIICHARS,
2942 OPTASKBCC,
2943 OPTASKCC,
2944+ OPTASKFOLLOWUP,
2945+ OPTASKXCOMMENTTO,
2946 OPTATTACHSPLIT,
2947 OPTAUTOEDIT,
2948 OPTAUTOTAG,
e1bffe0b 2949@@ -404,6 +416,9 @@ enum
95768aa9 2950 OPTMETOO,
2951 OPTMHPURGE,
2952 OPTMIMEFORWDECODE,
2953+#ifdef USE_NNTP
2954+ OPTMIMESUBJECT, /* encode subject line with RFC2047 */
2955+#endif
2956 OPTNARROWTREE,
2957 OPTPAGERSTOP,
2958 OPTPIPEDECODE,
e1bffe0b 2959@@ -485,6 +500,16 @@ enum
95768aa9 2960 OPTPGPAUTOINLINE,
2961 OPTPGPREPLYINLINE,
2962
2963+ /* news options */
2964+
2965+#ifdef USE_NNTP
2966+ OPTSHOWNEWNEWS,
2967+ OPTSHOWONLYUNREAD,
2968+ OPTSAVEUNSUB,
2969+ OPTLOADDESC,
2970+ OPTXCOMMENTTO,
2971+#endif /* USE_NNTP */
2972+
2973 /* pseudo options */
2974
2975 OPTAUXSORT, /* (pseudo) using auxillary sort function */
e1bffe0b 2976@@ -505,6 +530,7 @@ enum
95768aa9 2977 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
2978 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
2979 OPTATTACHMSG, /* (pseudo) used by attach-message */
2980+ OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
2981 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
2982 * functions while we are executing an
2983 * external program.
e1bffe0b 2984@@ -515,6 +541,12 @@ enum
95768aa9 2985 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
2986 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
2987
2988+#ifdef USE_NNTP
2989+ OPTNEWS, /* (pseudo) used to change reader mode */
2990+ OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
2991+ OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
2992+#endif
2993+
2994 OPTMAX
2995 };
2996
e1bffe0b 2997@@ -592,6 +624,13 @@ typedef struct envelope
95768aa9 2998 char *supersedes;
2999 char *date;
3000 char *x_label;
3001+ char *organization;
3002+#ifdef USE_NNTP
3003+ char *newsgroups;
3004+ char *xref;
3005+ char *followup_to;
3006+ char *x_comment_to;
3007+#endif
3008 BUFFER *spam;
3009 LIST *references; /* message references (in reverse order) */
3010 LIST *in_reply_to; /* in-reply-to header content */
e1bffe0b 3011@@ -758,6 +797,9 @@ typedef struct header
95768aa9 3012 ENVELOPE *env; /* envelope information */
3013 BODY *content; /* list of MIME parts */
3014 char *path;
3015+#ifdef USE_NNTP
3016+ int article_num;
3017+#endif
3018
3019 char *tree; /* character string to print thread tree */
3020 struct thread *thread;
e1bffe0b 3021@@ -773,7 +815,7 @@ typedef struct header
95768aa9 3022 int refno; /* message number on server */
3023 #endif
3024
3025-#if defined USE_POP || defined USE_IMAP
3026+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3027 void *data; /* driver-specific data */
3028 #endif
3029
e1bffe0b
JB
3030diff -udprP mutt-1.5.15.orig/muttlib.c mutt-1.5.15/muttlib.c
3031--- mutt-1.5.15.orig/muttlib.c 2007-04-03 20:52:56.000000000 +0300
3032+++ mutt-1.5.15/muttlib.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 3033@@ -286,7 +286,7 @@ void mutt_free_header (HEADER **h)
3034 #ifdef MIXMASTER
3035 mutt_free_list (&(*h)->chain);
3036 #endif
3037-#if defined USE_POP || defined USE_IMAP
3038+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3039 FREE (&(*h)->data);
3040 #endif
3041 FREE (h); /* __FREE_CHECKED__ */
e1bffe0b 3042@@ -674,6 +674,13 @@ void mutt_free_envelope (ENVELOPE **p)
95768aa9 3043 FREE (&(*p)->supersedes);
3044 FREE (&(*p)->date);
3045 FREE (&(*p)->x_label);
3046+ FREE (&(*p)->organization);
3047+#ifdef USE_NNTP
3048+ FREE (&(*p)->newsgroups);
3049+ FREE (&(*p)->xref);
3050+ FREE (&(*p)->followup_to);
3051+ FREE (&(*p)->x_comment_to);
3052+#endif
3053
3054 mutt_buffer_free (&(*p)->spam);
3055
e1bffe0b 3056@@ -1392,6 +1399,14 @@ int mutt_save_confirm (const char *s, st
95768aa9 3057 }
3058 }
3059
3060+#ifdef USE_NNTP
3061+ if (magic == M_NNTP)
3062+ {
3063+ mutt_error _("Can't save message to newsserver.");
3064+ return 0;
3065+ }
3066+#endif
3067+
3068 if (stat (s, st) != -1)
3069 {
3070 if (magic == -1)
e1bffe0b
JB
3071diff -udprP mutt-1.5.15.orig/mx.c mutt-1.5.15/mx.c
3072--- mutt-1.5.15.orig/mx.c 2007-04-03 20:41:14.000000000 +0300
3073+++ mutt-1.5.15/mx.c 2007-04-11 17:25:15.000000000 +0300
3074@@ -348,6 +348,22 @@ int mx_is_pop (const char *p)
95768aa9 3075 }
3076 #endif
3077
3078+#ifdef USE_NNTP
3079+int mx_is_nntp (const char *p)
3080+{
3081+ url_scheme_t scheme;
3082+
3083+ if (!p)
3084+ return 0;
3085+
3086+ scheme = url_check_scheme (p);
3087+ if (scheme == U_NNTP || scheme == U_NNTPS)
3088+ return 1;
3089+
3090+ return 0;
3091+}
3092+#endif
3093+
3094 int mx_get_magic (const char *path)
3095 {
3096 struct stat st;
e1bffe0b 3097@@ -365,6 +381,11 @@ int mx_get_magic (const char *path)
95768aa9 3098 return M_POP;
3099 #endif /* USE_POP */
3100
3101+#ifdef USE_NNTP
3102+ if (mx_is_nntp (path))
3103+ return M_NNTP;
3104+#endif /* USE_NNTP */
3105+
3106 if (stat (path, &st) == -1)
3107 {
3108 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
e1bffe0b 3109@@ -704,6 +725,12 @@ CONTEXT *mx_open_mailbox (const char *pa
95768aa9 3110 break;
3111 #endif /* USE_POP */
3112
3113+#ifdef USE_NNTP
3114+ case M_NNTP:
3115+ rc = nntp_open_mailbox (ctx);
3116+ break;
3117+#endif /* USE_NNTP */
3118+
3119 default:
3120 rc = -1;
3121 break;
e1bffe0b 3122@@ -796,6 +823,12 @@ static int sync_mailbox (CONTEXT *ctx, i
95768aa9 3123 rc = pop_sync_mailbox (ctx, index_hint);
3124 break;
3125 #endif /* USE_POP */
3126+
3127+#ifdef USE_NNTP
3128+ case M_NNTP:
3129+ rc = nntp_sync_mailbox (ctx);
3130+ break;
3131+#endif /* USE_NNTP */
3132 }
3133
3134 #if 0
e1bffe0b 3135@@ -822,6 +855,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
95768aa9 3136
3137 ctx->closing = 1;
3138
3139+#ifdef USE_NNTP
3140+ if (ctx->magic == M_NNTP)
3141+ {
3142+ int ret;
3143+
3144+ ret = nntp_close_mailbox (ctx);
3145+ mx_fastclose_mailbox (ctx);
3146+ return ret;
3147+ }
3148+#endif
3149 if (ctx->readonly || ctx->dontwrite)
3150 {
3151 /* mailbox is readonly or we don't want to write */
e1bffe0b 3152@@ -1359,6 +1402,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
95768aa9 3153 case M_POP:
3154 return (pop_check_mailbox (ctx, index_hint));
3155 #endif /* USE_POP */
3156+
3157+#ifdef USE_NNTP
3158+ case M_NNTP:
3159+ return (nntp_check_mailbox (ctx));
3160+#endif /* USE_NNTP */
3161 }
3162 }
3163
e1bffe0b 3164@@ -1419,6 +1467,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
95768aa9 3165 }
3166 #endif /* USE_POP */
3167
3168+#ifdef USE_NNTP
3169+ case M_NNTP:
3170+ {
3171+ if (nntp_fetch_message (msg, ctx, msgno) != 0)
3172+ FREE (&msg);
3173+ break;
3174+ }
3175+#endif /* USE_NNTP */
3176+
3177 default:
3178 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3179 FREE (&msg);
e1bffe0b 3180@@ -1500,6 +1557,9 @@ int mx_close_message (MESSAGE **msg)
95768aa9 3181 #ifdef USE_POP
3182 || (*msg)->magic == M_POP
3183 #endif
3184+#ifdef USE_NNTP
3185+ || (*msg)->magic == M_NNTP
3186+#endif
3187 )
3188 {
3189 r = safe_fclose (&(*msg)->fp);
e1bffe0b
JB
3190diff -udprP mutt-1.5.15.orig/mx.h mutt-1.5.15/mx.h
3191--- mutt-1.5.15.orig/mx.h 2007-04-02 00:58:56.000000000 +0300
3192+++ mutt-1.5.15/mx.h 2007-04-11 17:25:15.000000000 +0300
95768aa9 3193@@ -40,6 +40,9 @@ enum
3194 #ifdef USE_POP
3195 , M_POP
3196 #endif
3197+#ifdef USE_NNTP
3198+ , M_NNTP
3199+#endif
3200 };
3201
3202 WHERE short DefaultMagic INITVAL (M_MBOX);
e1bffe0b
JB
3203diff -udprP mutt-1.5.15.orig/newsrc.c mutt-1.5.15/newsrc.c
3204--- mutt-1.5.15.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3205+++ mutt-1.5.15/newsrc.c 2007-04-11 18:13:00.000000000 +0300
95768aa9 3206@@ -0,0 +1,1170 @@
3207+/*
3208+ * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3209+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
e1bffe0b 3210+ * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
95768aa9 3211+ *
3212+ * This program is free software; you can redistribute it and/or modify
3213+ * it under the terms of the GNU General Public License as published by
3214+ * the Free Software Foundation; either version 2 of the License, or
3215+ * (at your option) any later version.
3216+ *
3217+ * This program is distributed in the hope that it will be useful,
3218+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3219+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3220+ * GNU General Public License for more details.
3221+ *
3222+ * You should have received a copy of the GNU General Public License
3223+ * along with this program; if not, write to the Free Software
3224+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3225+ */
3226+
3227+#if HAVE_CONFIG_H
3228+# include "config.h"
3229+#endif
3230+
3231+#include "mutt.h"
3232+#include "mutt_curses.h"
3233+#include "sort.h"
3234+#include "mx.h"
3235+#include "mime.h"
3236+#include "mailbox.h"
3237+#include "nntp.h"
3238+#include "rfc822.h"
3239+#include "rfc1524.h"
3240+#include "rfc2047.h"
3241+
3242+#include <unistd.h>
3243+#include <string.h>
3244+#include <ctype.h>
3245+#include <stdlib.h>
3246+#include <sys/stat.h>
3247+
3248+void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3249+{
3250+ LIST *l;
3251+
3252+ if (!s || !d)
3253+ return;
3254+
3255+ l = safe_calloc (1, sizeof (LIST));
3256+ if (s->list)
3257+ s->tail->next = l;
3258+ else
3259+ s->list = l;
3260+ s->tail = l;
3261+ l->data = (void *) d;
3262+}
3263+
3264+static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3265+{
3266+ NNTP_DATA *data;
3267+ char group[LONG_STRING];
3268+ int x = 1;
3269+ char *p = line, *b, *h;
3270+ size_t len;
3271+
3272+ while (*p)
3273+ {
3274+ if (*p++ == ',')
3275+ x++;
3276+ }
3277+
3278+ p = line;
3279+ while (*p && (*p != ':' && *p != '!')) p++;
3280+ if (!*p)
3281+ return -1;
3282+ len = p + 1 - line;
3283+ if (len > sizeof (group))
3284+ len = sizeof (group);
3285+ strfcpy (group, line, len);
3286+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3287+ {
3288+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3289+ data->group = (char *) data + sizeof (NNTP_DATA);
3290+ strcpy (data->group, group);
3291+ data->nserv = news;
3292+ data->deleted = 1;
3293+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3294+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3295+ hash_insert (news->newsgroups, data->group, data, 0);
3296+ nntp_add_to_list (news, data);
3297+ }
3298+ else
3299+ FREE ((void **) &data->entries);
3300+
3301+ data->rc = 1;
3302+ data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3303+ data->max = x*2;
3304+
3305+ if (*p == ':')
3306+ data->subscribed = 1;
3307+ else
3308+ data->subscribed = 0;
3309+
3310+ p++;
3311+ b = p;
3312+ x = 0;
3313+ while (*b)
3314+ {
3315+ while (*p && *p != ',' && *p != '\n') p++;
3316+ if (*p)
3317+ {
3318+ *p = '\0';
3319+ p++;
3320+ }
3321+ if ((h = strchr(b, '-')))
3322+ {
3323+ *h = '\0';
3324+ h++;
3325+ data->entries[x].first = atoi(b);
3326+ data->entries[x].last = atoi(h);
3327+ }
3328+ else
3329+ {
3330+ data->entries[x].first = atoi(b);
3331+ data->entries[x].last = data->entries[x].first;
3332+ }
3333+ b = p;
3334+ if (data->entries[x].last != 0)
3335+ x++;
3336+ }
3337+ if (x && !data->lastMessage)
3338+ data->lastMessage = data->entries[x-1].last;
3339+ data->num = x;
3340+ mutt_newsgroup_stat (data);
3341+ dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3342+
3343+ return 0;
3344+}
3345+
3346+static int slurp_newsrc (NNTP_SERVER *news)
3347+{
3348+ FILE *fp;
3349+ char *buf;
3350+ struct stat sb;
3351+
3352+ news->stat = stat (news->newsrc, &sb);
3353+ news->size = sb.st_size;
3354+ news->mtime = sb.st_mtime;
3355+
3356+ if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3357+ return -1;
3358+ /* hmm, should we use dotlock? */
3359+ if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3360+ {
3361+ fclose (fp);
3362+ return -1;
3363+ }
3364+
3365+ buf = safe_malloc (sb.st_size + 1);
3366+ while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3367+ nntp_parse_newsrc_line (news, buf);
3368+ FREE (&buf);
3369+
3370+ mx_unlock_file (news->newsrc, fileno (fp), 0);
3371+ fclose (fp);
3372+ return 0;
3373+}
3374+
3375+void nntp_cache_expand (char *dst, const char *src)
3376+{
3377+ snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3378+ mutt_expand_path (dst, _POSIX_PATH_MAX);
3379+}
3380+
3381+/* Loads $news_cache_dir/.index into memory, loads newsserver data
3382+ * and newsgroup cache names */
3383+static int nntp_parse_cacheindex (NNTP_SERVER *news)
3384+{
3385+ struct stat st;
3386+ char buf[HUGE_STRING], *cp;
3387+ char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3388+ FILE *index;
3389+ NNTP_DATA *data;
3390+ int l, m, t;
3391+
3392+ /* check is server name defined or not */
3393+ if (!news || !news->conn || !news->conn->account.host)
3394+ return -1;
3395+ unset_option (OPTNEWSCACHE);
3396+ if (!NewsCacheDir || !*NewsCacheDir)
3397+ return 0;
3398+
3399+ strfcpy (dir, NewsCacheDir, sizeof (dir));
3400+ mutt_expand_path (dir, sizeof(dir));
3401+
3402+ if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3403+ {
3404+ snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3405+ if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3406+ S_IRWXO)))
3407+ {
3408+ mutt_error _("Cache directory not created!");
3409+ return -1;
3410+ }
3411+ mutt_clear_error();
3412+ }
3413+
3414+ set_option (OPTNEWSCACHE);
3415+
3416+ FREE (&news->cache);
3417+ snprintf (buf, sizeof(buf), "%s/.index", dir);
3418+ if (!(index = safe_fopen (buf, "a+")))
3419+ return 0;
3420+ rewind (index);
3421+ while (fgets (buf, sizeof(buf), index))
3422+ {
3423+ buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3424+ if (!mutt_strncmp (buf, "#: ", 3) &&
3425+ !mutt_strcasecmp (buf+3, news->conn->account.host))
3426+ break;
3427+ }
3428+ while (fgets (buf, sizeof(buf), index))
3429+ {
3430+ cp = buf;
3431+ while (*cp && *cp != ' ') cp++;
3432+ if (!*cp) continue;
3433+ cp[0] = 0;
3434+ if (!mutt_strcmp (buf, "#:"))
3435+ break;
3436+ sscanf (cp + 1, "%s %d %d", file, &l, &m);
3437+ if (!mutt_strcmp (buf, "ALL"))
3438+ {
3439+ news->cache = safe_strdup (file);
3440+ news->newgroups_time = m;
3441+ }
3442+ else if (news->newsgroups)
3443+ {
3444+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3445+ {
3446+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3447+ data->group = (char *) data + sizeof (NNTP_DATA);
3448+ strcpy(data->group, buf);
3449+ data->nserv = news;
3450+ data->deleted = 1;
3451+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3452+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3453+ hash_insert (news->newsgroups, data->group, data, 0);
3454+ nntp_add_to_list (news, data);
3455+ }
3456+ data->cache = safe_strdup (file);
3457+ t = 0;
3458+ if (!data->firstMessage || data->lastMessage < m)
3459+ t = 1;
3460+ if (!data->firstMessage)
3461+ data->firstMessage = l;
3462+ if (data->lastMessage < m)
3463+ data->lastMessage = m;
3464+ data->lastCached = m;
3465+ if (t || !data->unread)
3466+ mutt_newsgroup_stat (data);
3467+ }
3468+ }
3469+ fclose (index);
3470+ return 0;
3471+}
3472+
3473+const char *
3474+nntp_format_str (char *dest, size_t destlen, char op, const char *src,
3475+ const char *fmt, const char *ifstring, const char *elsestring,
3476+ unsigned long data, format_flag flags)
3477+{
3478+ char fn[SHORT_STRING], tmp[SHORT_STRING];
3479+
3480+ switch (op)
3481+ {
3482+ case 's':
3483+ strncpy (fn, NewsServer, sizeof(fn) - 1);
3484+ mutt_strlower (fn);
3485+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3486+ snprintf (dest, destlen, tmp, fn);
3487+ break;
3488+ }
3489+ return (src);
3490+}
3491+
3492+/* nntp_parse_url: given an NNPT URL, return host, port,
3493+ * username, password and newsgroup will recognise. */
3494+int nntp_parse_url (const char *server, ACCOUNT *acct,
3495+ char *group, size_t group_len)
3496+{
3497+ ciss_url_t url;
3498+ char *c;
3499+ int ret = -1;
3500+
3501+ /* Defaults */
3502+ acct->flags = 0;
3503+ acct->port = NNTP_PORT;
3504+ acct->type = M_ACCT_TYPE_NNTP;
3505+
3506+ c = safe_strdup (server);
3507+ url_parse_ciss (&url, c);
3508+
3509+ if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3510+ {
3511+ if (url.scheme == U_NNTPS)
3512+ {
3513+ acct->flags |= M_ACCT_SSL;
3514+ acct->port = NNTP_SSL_PORT;
3515+ }
3516+
3517+ *group = '\0';
3518+ if (url.path)
3519+ strfcpy (group, url.path, group_len);
3520+
3521+ ret = mutt_account_fromurl (acct, &url);
3522+ }
3523+
3524+ FREE (&c);
3525+ return ret;
3526+}
3527+
3528+void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3529+{
3530+ ciss_url_t url;
3531+
3532+ url.path = safe_strdup (line);
3533+ mutt_account_tourl (acct, &url);
3534+ url_ciss_tostring (&url, line, len, 0);
3535+ FREE (&url.path);
3536+}
3537+
3538+/*
3539+ * Automatically loads a newsrc into memory, if necessary.
3540+ * Checks the size/mtime of a newsrc file, if it doesn't match, load
3541+ * again. Hmm, if a system has broken mtimes, this might mean the file
3542+ * is reloaded every time, which we'd have to fix.
3543+ *
3544+ * a newsrc file is a line per newsgroup, with the newsgroup, then a
3545+ * ':' denoting subscribed or '!' denoting unsubscribed, then a
3546+ * comma separated list of article numbers and ranges.
3547+ */
3548+NNTP_SERVER *mutt_select_newsserver (char *server)
3549+{
3550+ char file[_POSIX_PATH_MAX];
3551+ char *buf, *p;
3552+ LIST *list;
3553+ ACCOUNT acct;
3554+ NNTP_SERVER *serv;
3555+ CONNECTION *conn;
3556+
3557+ if (!server || !*server)
3558+ {
3559+ mutt_error _("No newsserver defined!");
3560+ return NULL;
3561+ }
3562+
3563+ buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3564+ if (url_check_scheme (server) == U_UNKNOWN)
3565+ {
e1bffe0b 3566+ strcpy (buf, "news://");
95768aa9 3567+ p = strchr (buf, '\0');
3568+ }
3569+ strcpy (p, server);
3570+
3571+ if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3572+ {
3573+ FREE (&buf);
3574+ mutt_error (_("%s is an invalid newsserver specification!"), server);
3575+ return NULL;
3576+ }
3577+ FREE (&buf);
3578+
3579+ conn = mutt_conn_find (NULL, &acct);
3580+ if (!conn)
3581+ return NULL;
3582+
3583+ mutt_FormatString (file, sizeof (file), NONULL (NewsRc), nntp_format_str, 0, 0);
3584+ mutt_expand_path (file, sizeof (file));
3585+
3586+ serv = (NNTP_SERVER *)conn->data;
3587+ if (serv)
3588+ {
3589+ struct stat sb;
3590+
3591+ /* externally modified? */
3592+ if (serv->stat != stat (file, &sb) || (!serv->stat &&
3593+ (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3594+ {
3595+ for (list = serv->list; list; list = list->next)
3596+ {
3597+ NNTP_DATA *data = (NNTP_DATA *) list->data;
3598+
3599+ if (data)
3600+ {
3601+ data->subscribed = 0;
3602+ data->rc = 0;
3603+ data->num = 0;
3604+ }
3605+ }
3606+ slurp_newsrc (serv);
3607+ nntp_clear_cacheindex (serv);
3608+ }
3609+
3610+ if (serv->status == NNTP_BYE)
3611+ serv->status = NNTP_NONE;
3612+ nntp_check_newgroups (serv, 0);
3613+ return serv;
3614+ }
3615+
3616+ /* New newsserver */
3617+ serv = safe_calloc (1, sizeof (NNTP_SERVER));
3618+ serv->conn = conn;
3619+ serv->newsrc = safe_strdup (file);
3620+ serv->newsgroups = hash_create (1009);
3621+ slurp_newsrc (serv); /* load .newsrc */
3622+ nntp_parse_cacheindex (serv); /* load .index */
3623+ if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3624+ nntp_check_newgroups (serv, 1);
3625+ else if (nntp_get_active (serv) < 0)
3626+ {
3627+ hash_destroy (&serv->newsgroups, nntp_delete_data);
3628+ for (list = serv->list; list; list = list->next)
3629+ list->data = NULL;
3630+ mutt_free_list (&serv->list);
3631+ FREE (&serv->newsrc);
3632+ FREE (&serv->cache);
3633+ FREE (&serv);
3634+ return NULL;
3635+ }
3636+ nntp_clear_cacheindex (serv);
3637+ conn->data = (void *)serv;
3638+
3639+ return serv;
3640+}
3641+
3642+/*
3643+ * full status flags are not supported by nntp, but we can fake some
3644+ * of them. This is how:
3645+ * Read = a read message number is in the .newsrc
3646+ * New = a message is new since we last read this newsgroup
3647+ * Old = anything else
3648+ * So, Read is marked as such in the newsrc, old is anything that is
3649+ * "skipped" in the newsrc, and new is anything not in the newsrc nor
3650+ * in the cache. By skipped, I mean before the last unread message
3651+ */
3652+void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3653+{
3654+ NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3655+ int x;
3656+
3657+ if (group)
3658+ data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3659+
3660+ if (!data)
3661+ {
3662+#ifdef DEBUG
3663+ if (group)
3664+ dprint (3, (debugfile, "newsgroup %s not found\n", group));
3665+#endif
3666+ return;
3667+ }
3668+
3669+ for (x = 0; x < data->num; x++)
3670+ {
3671+ if ((article >= data->entries[x].first) &&
3672+ (article <= data->entries[x].last))
3673+ {
3674+ /* we cannot use mutt_set_flag() because mx_update_context()
3675+ didn't called yet */
3676+ h->read = 1;
3677+ return;
3678+ }
3679+ }
3680+ /* If article was not cached yet, it is new! :) */
3681+ if (!data->cache || article > data->lastCached)
3682+ return;
3683+ /* Old articles are articles which aren't read but an article after them
3684+ * has been cached */
3685+ if (option (OPTMARKOLD))
3686+ h->old = 1;
3687+}
3688+
3689+void mutt_newsgroup_stat (NNTP_DATA *data)
3690+{
3691+ int i;
3692+ unsigned int first, last;
3693+
3694+ data->unread = 0;
3695+ if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3696+ return;
3697+
3698+ data->unread = data->lastMessage - data->firstMessage + 1;
3699+ for (i = 0; i < data->num; i++)
3700+ {
3701+ first = data->entries[i].first;
3702+ if (first < data->firstMessage)
3703+ first = data->firstMessage;
3704+ last = data->entries[i].last;
3705+ if (last > data->lastMessage)
3706+ last = data->lastMessage;
3707+ if (first <= last)
3708+ data->unread -= last - first + 1;
3709+ }
3710+}
3711+
3712+static int puti (char *line, int num)
3713+{
3714+ char *p, s[32];
3715+
3716+ for (p = s; num; )
3717+ {
3718+ *p++ = '0' + num % 10;
3719+ num /= 10;
3720+ }
3721+ while (p > s)
3722+ *line++ = *--p, num++;
3723+ *line = '\0';
3724+ return num;
3725+}
3726+
3727+static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3728+{
3729+ char *line = *pline;
3730+ size_t len = *buflen - (*pline - *buf);
3731+ int x, i;
3732+
3733+ if (len < LONG_STRING * 10)
3734+ {
3735+ len += *buflen;
3736+ *buflen *= 2;
3737+ line = *buf;
3738+ safe_realloc (buf, *buflen);
3739+ line = *buf + (*pline - line);
3740+ }
3741+ strcpy (line, data->group);
3742+ len -= strlen (line) + 1;
3743+ line += strlen (line);
3744+ *line++ = data->subscribed ? ':' : '!';
3745+ *line++ = ' ';
3746+ *line = '\0';
3747+
3748+ for (x = 0; x < data->num; x++)
3749+ {
3750+ if (len < LONG_STRING)
3751+ {
3752+ len += *buflen;
3753+ *buflen *= 2;
3754+ *pline = line;
3755+ line = *buf;
3756+ safe_realloc (buf, *buflen);
3757+ line = *buf + (*pline - line);
3758+ }
3759+ if (x)
3760+ {
3761+ *line++ = ',';
3762+ len--;
3763+ }
3764+
3765+#if 0
3766+ if (data->entries[x].first == data->entries[x].last)
3767+ snprintf (line, len, "%d%n", data->entries[x].first, &i);
3768+ else
3769+ snprintf (line, len, "%d-%d%n",
3770+ data->entries[x].first, data->entries[x].last, &i);
3771+ len -= i;
3772+ line += i;
3773+#else
3774+ i = puti (line, data->entries[x].first);
3775+ line +=i; len -= i;
3776+ if (data->entries[x].first != data->entries[x].last)
3777+ {
3778+ *line++ = '-';
3779+ len--;
3780+ i = puti (line, data->entries[x].last);
3781+ line +=i; len -= i;
3782+ }
3783+#endif
3784+ }
3785+ *line++ = '\n';
3786+ *line = '\0';
3787+ *pline = line;
3788+}
3789+
3790+void newsrc_gen_entries (CONTEXT *ctx)
3791+{
3792+ NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3793+ int series, x;
3794+ unsigned int last = 0, first = 1;
3795+ int save_sort = SORT_ORDER;
3796+
3797+ if (Sort != SORT_ORDER)
3798+ {
3799+ save_sort = Sort;
3800+ Sort = SORT_ORDER;
3801+ mutt_sort_headers (ctx, 0);
3802+ }
3803+
3804+ if (!data->max)
3805+ {
3806+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3807+ data->max = 5;
3808+ }
3809+
3810+ /*
3811+ * Set up to fake initial sequence from 1 to the article before the
3812+ * first article in our list
3813+ */
3814+ data->num = 0;
3815+ series = 1;
3816+
3817+ for (x = 0; x < ctx->msgcount; x++)
3818+ {
3819+ if (series) /* search for first unread */
3820+ {
3821+ /*
3822+ * We don't actually check sequential order, since we mark
3823+ * "missing" entries as read/deleted
3824+ */
3825+ last = ctx->hdrs[x]->article_num;
3826+ if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3827+ !ctx->hdrs[x]->read)
3828+ {
3829+ if (data->num >= data->max)
3830+ {
3831+ data->max = data->max * 2;
3832+ safe_realloc (&data->entries,
3833+ data->max * sizeof (NEWSRC_ENTRY));
3834+ }
3835+ data->entries[data->num].first = first;
3836+ data->entries[data->num].last = last - 1;
3837+ data->num++;
3838+ series = 0;
3839+ }
3840+ }
3841+ else /* search for first read */
3842+ {
3843+ if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3844+ {
3845+ first = last + 1;
3846+ series = 1;
3847+ }
3848+ last = ctx->hdrs[x]->article_num;
3849+ }
3850+ }
3851+ if (series && first <= data->lastLoaded)
3852+ {
3853+ if (data->num >= data->max)
3854+ {
3855+ data->max = data->max * 2;
3856+ safe_realloc (&data->entries,
3857+ data->max * sizeof (NEWSRC_ENTRY));
3858+ }
3859+ data->entries[data->num].first = first;
3860+ data->entries[data->num].last = data->lastLoaded;
3861+ data->num++;
3862+ }
3863+
3864+ if (save_sort != Sort)
3865+ {
3866+ Sort = save_sort;
3867+ mutt_sort_headers (ctx, 0);
3868+ }
3869+}
3870+
3871+static int mutt_update_list_file (char *filename, char *section,
3872+ char *key, char *line)
3873+{
3874+ FILE *ifp;
3875+ FILE *ofp;
3876+ char buf[HUGE_STRING];
3877+ char tmpfile[_POSIX_PATH_MAX];
3878+ char *c;
3879+ int ext = 0, done = 0, r = 0;
3880+
3881+ /* if file not exist, create it */
3882+ if ((ifp = safe_fopen (filename, "a")))
3883+ fclose (ifp);
3884+ dprint (1, (debugfile, "Opening %s\n", filename));
3885+ if (!(ifp = safe_fopen (filename, "r")))
3886+ {
3887+ mutt_error (_("Unable to open %s for reading"), filename);
3888+ return -1;
3889+ }
3890+ if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3891+ {
3892+ fclose (ifp);
3893+ mutt_error (_("Unable to lock %s"), filename);
3894+ return -1;
3895+ }
3896+ snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3897+ dprint (1, (debugfile, "Opening %s\n", tmpfile));
3898+ if (!(ofp = fopen (tmpfile, "w")))
3899+ {
3900+ fclose (ifp);
3901+ mutt_error (_("Unable to open %s for writing"), tmpfile);
3902+ return -1;
3903+ }
3904+
3905+ if (section)
3906+ {
3907+ while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3908+ {
3909+ r = fputs (buf, ofp);
3910+ c = buf;
3911+ while (*c && *c != '\n') c++;
3912+ c[0] = 0; /* strip EOL */
3913+ if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3914+ done++;
3915+ }
3916+ if (r != EOF && !done)
3917+ {
3918+ snprintf (buf, sizeof(buf), "#: %s\n", section);
3919+ r = fputs (buf, ofp);
3920+ }
3921+ done = 0;
3922+ }
3923+
3924+ while (r != EOF && fgets (buf, sizeof (buf), ifp))
3925+ {
3926+ if (ext)
3927+ {
3928+ c = buf;
3929+ while (*c && (*c != '\r') && (*c != '\n')) c++;
3930+ c--;
3931+ if (*c != '\\') ext = 0;
3932+ }
3933+ else if ((section && !strncmp (buf, "#: ", 3)))
3934+ {
3935+ if (!done && line)
3936+ {
3937+ fputs (line, ofp);
3938+ fputc ('\n', ofp);
3939+ }
3940+ r = fputs (buf, ofp);
3941+ done++;
3942+ break;
3943+ }
3944+ else if (key && !strncmp (buf, key, strlen(key)) &&
3945+ (!*key || buf[strlen(key)] == ' '))
3946+ {
3947+ c = buf;
3948+ ext = 0;
3949+ while (*c && (*c != '\r') && (*c != '\n')) c++;
3950+ c--;
3951+ if (*c == '\\') ext = 1;
3952+ if (!done && line)
3953+ {
3954+ r = fputs (line, ofp);
3955+ if (*key)
3956+ r = fputc ('\n', ofp);
3957+ done++;
3958+ }
3959+ }
3960+ else
3961+ {
3962+ r = fputs (buf, ofp);
3963+ }
3964+ }
3965+
3966+ while (r != EOF && fgets (buf, sizeof (buf), ifp))
3967+ r = fputs (buf, ofp);
3968+
3969+ /* If there wasn't a line to replace, put it on the end of the file */
3970+ if (r != EOF && !done && line)
3971+ {
3972+ fputs (line, ofp);
3973+ r = fputc ('\n', ofp);
3974+ }
3975+ mx_unlock_file (filename, fileno (ifp), 0);
3976+ fclose (ofp);
3977+ fclose (ifp);
3978+ if (r == EOF)
3979+ {
3980+ unlink (tmpfile);
3981+ mutt_error (_("Can't write %s"), tmpfile);
3982+ return -1;
3983+ }
3984+ if (rename (tmpfile, filename) < 0)
3985+ {
3986+ unlink (tmpfile);
3987+ mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
3988+ return -1;
3989+ }
3990+ return 0;
3991+}
3992+
3993+int mutt_newsrc_update (NNTP_SERVER *news)
3994+{
3995+ char *buf, *line;
3996+ NNTP_DATA *data;
3997+ LIST *tmp;
3998+ int r = -1;
3999+ size_t len, llen;
4000+
4001+ if (!news)
4002+ return -1;
4003+ llen = len = 10 * LONG_STRING;
4004+ line = buf = safe_calloc (1, len);
4005+ /* we will generate full newsrc here */
4006+ for (tmp = news->list; tmp; tmp = tmp->next)
4007+ {
4008+ data = (NNTP_DATA *) tmp->data;
4009+ if (!data || !data->rc)
4010+ continue;
4011+ nntp_create_newsrc_line (data, &buf, &line, &llen);
4012+ if (*line)
4013+ dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4014+ line += strlen (line);
4015+ }
4016+ /* newrc being fully rewritten */
4017+ if (news->newsrc &&
4018+ (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4019+ {
4020+ struct stat st;
4021+
4022+ stat (news->newsrc, &st);
4023+ news->size = st.st_size;
4024+ news->mtime = st.st_mtime;
4025+ }
4026+ FREE (&buf);
4027+ return r;
4028+}
4029+
4030+static FILE *mutt_mkname (char *s)
4031+{
4032+ char buf[_POSIX_PATH_MAX], *pc;
4033+ int fd;
4034+ FILE *fp;
4035+
4036+ nntp_cache_expand (buf, s);
4037+ if ((fp = safe_fopen (buf, "w")))
4038+ return fp;
4039+
4040+ nntp_cache_expand (buf, "cache-XXXXXX");
4041+ pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4042+ if ((fd = mkstemp (buf)) == -1)
4043+ return NULL;
4044+ strcpy (s, pc); /* generated name */
4045+ return fdopen (fd, "w");
4046+}
4047+
4048+/* Updates info into .index file: ALL or about selected newsgroup */
4049+static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4050+{
4051+ char buf[LONG_STRING], *key = "ALL";
4052+ char file[_POSIX_PATH_MAX];
4053+
4054+ if (!serv || !serv->conn || !serv->conn->account.host)
4055+ return -1;
4056+
4057+ if (data && data->group)
4058+ {
4059+ key = data->group;
4060+ snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4061+ data->firstMessage, data->lastLoaded);
4062+ }
4063+ else
4064+ {
4065+ strfcpy (file, serv->cache, sizeof (file));
4066+ snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4067+ }
4068+ nntp_cache_expand (file, ".index");
4069+ return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4070+}
4071+
4072+/* Remove cache files of unsubscribed newsgroups */
4073+void nntp_clear_cacheindex (NNTP_SERVER *news)
4074+{
4075+ NNTP_DATA *data;
4076+ LIST *tmp;
4077+
4078+ if (option (OPTSAVEUNSUB) || !news)
4079+ return;
4080+
4081+ for (tmp = news->list; tmp; tmp = tmp->next)
4082+ {
4083+ data = (NNTP_DATA *) tmp->data;
4084+ if (!data || data->subscribed || !data->cache)
4085+ continue;
4086+ nntp_delete_cache (data);
4087+ dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4088+ }
4089+ return;
4090+}
4091+
4092+int nntp_save_cache_index (NNTP_SERVER *news)
4093+{
4094+ char buf[HUGE_STRING];
4095+ char file[_POSIX_PATH_MAX];
4096+ NNTP_DATA *d;
4097+ FILE *f;
4098+ LIST *l;
4099+
4100+ if (!news || !news->newsgroups)
4101+ return -1;
4102+ if (!option (OPTNEWSCACHE))
4103+ return 0;
4104+
4105+ if (news->cache)
4106+ {
4107+ nntp_cache_expand (file, news->cache);
4108+ unlink (file);
4109+ f = safe_fopen (file, "w");
4110+ }
4111+ else
4112+ {
4113+ strfcpy (buf, news->conn->account.host, sizeof(buf));
4114+ f = mutt_mkname (buf);
4115+ news->cache = safe_strdup (buf);
4116+ nntp_cache_expand (file, buf);
4117+ }
4118+ if (!f)
4119+ return -1;
4120+
4121+ for (l = news->list; l; l = l->next)
4122+ {
4123+ if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4124+ {
4125+ if (d->desc)
4126+ snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4127+ d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4128+ d->desc);
4129+ else
4130+ snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4131+ d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4132+ if (fputs (buf, f) == EOF)
4133+ {
4134+ fclose (f);
4135+ unlink (file);
4136+ return -1;
4137+ }
4138+ }
4139+ }
4140+ fclose (f);
4141+
4142+ if (nntp_update_cacheindex (news, NULL))
4143+ {
4144+ unlink (file);
4145+ return -1;
4146+ }
4147+ return 0;
4148+}
4149+
4150+int nntp_save_cache_group (CONTEXT *ctx)
4151+{
4152+ char buf[HUGE_STRING], addr[STRING];
4153+ char file[_POSIX_PATH_MAX];
4154+ FILE *f;
4155+ HEADER *h;
4156+ struct tm *tm;
4157+ int i = 0, save = SORT_ORDER;
4158+ int prev = 0;
4159+
4160+ if (!option (OPTNEWSCACHE))
4161+ return 0;
4162+ if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4163+ return -1;
4164+
4165+ if (((NNTP_DATA *)ctx->data)->cache)
4166+ {
4167+ nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4168+ unlink (file);
4169+ f = safe_fopen (file, "w");
4170+ }
4171+ else
4172+ {
4173+ snprintf (buf, sizeof(buf), "%s-%s",
4174+ ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4175+ ((NNTP_DATA *)ctx->data)->group);
4176+ f = mutt_mkname (buf);
4177+ ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4178+ nntp_cache_expand (file, buf);
4179+ }
4180+ if (!f)
4181+ return -1;
4182+
4183+ if (Sort != SORT_ORDER)
4184+ {
4185+ save = Sort;
4186+ Sort = SORT_ORDER;
4187+ mutt_sort_headers (ctx, 0);
4188+ }
4189+
4190+ /* Save only $nntp_context messages... */
4191+ ((NNTP_DATA *)ctx->data)->lastCached = 0;
4192+ if (NntpContext && ctx->msgcount > NntpContext)
4193+ i = ctx->msgcount - NntpContext;
4194+ for (; i < ctx->msgcount; i++)
4195+ {
4196+ if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4197+ {
4198+ h = ctx->hdrs[i];
4199+ addr[0] = 0;
4200+ rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4201+ tm = gmtime (&h->date_sent);
4202+ snprintf (buf, sizeof(buf),
4203+ "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4204+ h->article_num, h->env->subject, addr, tm->tm_mday,
4205+ Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4206+ tm->tm_sec, h->env->message_id);
4207+ fputs (buf, f);
4208+ if (h->env->references)
4209+ mutt_write_references (h->env->references, f);
e1bffe0b
JB
4210+ snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length,
4211+ (int) h->lines, NONULL(h->env->xref));
95768aa9 4212+ if (fputs (buf, f) == EOF)
4213+ {
4214+ fclose (f);
4215+ unlink (file);
4216+ return -1;
4217+ }
4218+ }
4219+ prev = ctx->hdrs[i]->article_num;
4220+ }
4221+
4222+ if (save != Sort)
4223+ {
4224+ Sort = save;
4225+ mutt_sort_headers (ctx, 0);
4226+ }
4227+ fclose (f);
4228+
4229+ if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4230+ (NNTP_DATA *)ctx->data))
4231+ {
4232+ unlink (file);
4233+ return -1;
4234+ }
4235+ ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4236+ return 0;
4237+}
4238+
4239+void nntp_delete_cache (NNTP_DATA *data)
4240+{
4241+ char buf[_POSIX_PATH_MAX];
4242+
4243+ if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4244+ return;
4245+
4246+ nntp_cache_expand (buf, data->cache);
4247+ unlink (buf);
4248+ FREE (&data->cache);
4249+ data->lastCached = 0;
4250+ nntp_cache_expand (buf, ".index");
4251+ mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4252+}
4253+
4254+NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4255+{
4256+ NNTP_DATA *data;
4257+
4258+ if (!news || !news->newsgroups || !group || !*group)
4259+ return NULL;
4260+ if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4261+ {
4262+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4263+ data->group = (char *) data + sizeof (NNTP_DATA);
4264+ strcpy (data->group, group);
4265+ data->nserv = news;
4266+ data->deleted = 1;
4267+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4268+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
4269+ hash_insert (news->newsgroups, data->group, data, 0);
4270+ nntp_add_to_list (news, data);
4271+ }
4272+ if (!data->subscribed)
4273+ {
4274+ data->subscribed = 1;
4275+ data->rc = 1;
4276+ }
4277+ return data;
4278+}
4279+
4280+NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4281+{
4282+ NNTP_DATA *data;
4283+
4284+ if (!news || !news->newsgroups || !group || !*group ||
4285+ !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4286+ return NULL;
4287+ if (data->subscribed)
4288+ {
4289+ data->subscribed = 0;
4290+ if (!option (OPTSAVEUNSUB))
4291+ data->rc = 0;
4292+ }
4293+ return data;
4294+}
4295+
4296+NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4297+{
4298+ NNTP_DATA *data;
4299+
4300+ if (!news || !news->newsgroups || !group || !*group ||
4301+ !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4302+ return NULL;
4303+ if (!data->max)
4304+ {
4305+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4306+ data->max = 5;
4307+ }
4308+ data->num = 1;
4309+ data->entries[0].first = 1;
4310+ data->unread = 0;
4311+ data->entries[0].last = data->lastMessage;
4312+ if (Context && Context->data == data)
4313+ {
4314+ int x;
4315+
4316+ for (x = 0; x < Context->msgcount; x++)
4317+ mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4318+ }
4319+ return data;
4320+}
4321+
4322+NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4323+{
4324+ NNTP_DATA *data;
4325+
4326+ if (!news || !news->newsgroups || !group || !*group ||
4327+ !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4328+ return NULL;
4329+ if (!data->max)
4330+ {
4331+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4332+ data->max = 5;
4333+ }
4334+ data->num = 1;
4335+ data->entries[0].first = 1;
4336+ data->entries[0].last = data->firstMessage - 1;
4337+ if (Context && Context->data == data)
4338+ {
4339+ int x;
4340+
4341+ data->unread = Context->msgcount;
4342+ for (x = 0; x < Context->msgcount; x++)
4343+ mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4344+ }
4345+ else
4346+ data->unread = data->lastMessage - data->entries[0].last;
4347+ return data;
4348+}
4349+
4350+/* this routine gives the first newsgroup with new messages */
4351+void nntp_buffy (char *s)
4352+{
4353+ LIST *list;
4354+
4355+ for (list = CurrentNewsSrv->list; list; list = list->next)
4356+ {
4357+ NNTP_DATA *data = (NNTP_DATA *) list->data;
4358+
4359+ if (data && data->subscribed && data->unread)
4360+ {
4361+ if (Context && Context->magic == M_NNTP &&
4362+ !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4363+ {
4364+ unsigned int i, unread = 0;
4365+
4366+ for (i = 0; i < Context->msgcount; i++)
4367+ if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4368+ unread++;
4369+ if (!unread)
4370+ continue;
4371+ }
4372+ strcpy (s, data->group);
4373+ break;
4374+ }
4375+ }
4376+}
e1bffe0b
JB
4377diff -udprP mutt-1.5.15.orig/nntp.c mutt-1.5.15/nntp.c
4378--- mutt-1.5.15.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4379+++ mutt-1.5.15/nntp.c 2007-04-11 17:48:16.000000000 +0300
4380@@ -0,0 +1,1588 @@
95768aa9 4381+/*
4382+ * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4383+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
e1bffe0b 4384+ * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
95768aa9 4385+ *
4386+ * This program is free software; you can redistribute it and/or modify
4387+ * it under the terms of the GNU General Public License as published by
4388+ * the Free Software Foundation; either version 2 of the License, or
4389+ * (at your option) any later version.
4390+ *
4391+ * This program is distributed in the hope that it will be useful,
4392+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4393+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4394+ * GNU General Public License for more details.
4395+ *
4396+ * You should have received a copy of the GNU General Public License
4397+ * along with this program; if not, write to the Free Software
4398+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4399+ */
4400+
4401+#if HAVE_CONFIG_H
4402+# include "config.h"
4403+#endif
4404+
4405+#include "mutt.h"
4406+#include "mutt_curses.h"
4407+#include "sort.h"
4408+#include "mx.h"
4409+#include "mime.h"
4410+#include "rfc1524.h"
4411+#include "rfc2047.h"
4412+#include "mailbox.h"
4413+#include "nntp.h"
4414+
4415+#ifdef HAVE_PGP
4416+#include "pgp.h"
4417+#endif
4418+
4419+#ifdef HAVE_SMIME
4420+#include "smime.h"
4421+#endif
4422+
4423+#include <unistd.h>
4424+#include <string.h>
4425+#include <ctype.h>
4426+#include <stdlib.h>
4427+
4428+static unsigned int _checked = 0;
4429+
4430+#ifdef DEBUG
4431+static void nntp_error (const char *where, const char *msg)
4432+{
4433+ dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4434+}
4435+#endif /* DEBUG */
4436+
4437+static int nntp_auth (NNTP_SERVER *serv)
4438+{
4439+ CONNECTION *conn = serv->conn;
4440+ char buf[STRING];
4441+ unsigned char flags = conn->account.flags;
4442+
4443+ if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4444+ mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4445+ {
4446+ conn->account.flags = flags;
4447+ return -2;
4448+ }
4449+
4450+ mutt_message _("Logging in...");
4451+
4452+ snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4453+ mutt_socket_write (conn, buf);
4454+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4455+ {
4456+ conn->account.flags = flags;
4457+ return -1;
4458+ }
4459+
4460+#ifdef DEBUG
4461+ /* don't print the password unless we're at the ungodly debugging level */
4462+ if (debuglevel < M_SOCK_LOG_FULL)
4463+ dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4464+#endif
4465+ snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4466+ mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4467+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4468+ {
4469+ conn->account.flags = flags;
4470+ return -1;
4471+ }
4472+
4473+ if (mutt_strncmp ("281", buf, 3))
4474+ {
4475+ conn->account.flags = flags;
4476+ mutt_error _("Login failed.");
4477+ sleep (2);
4478+ return -3;
4479+ }
4480+
4481+ return 0;
4482+}
4483+
4484+static int nntp_connect_error (NNTP_SERVER *serv)
4485+{
4486+ serv->status = NNTP_NONE;
4487+ mutt_socket_close (serv->conn);
4488+ mutt_error _("Server closed connection!");
4489+ sleep (2);
4490+ return -1;
4491+}
4492+
4493+static int nntp_connect_and_auth (NNTP_SERVER *serv)
4494+{
4495+ CONNECTION *conn = serv->conn;
4496+ char buf[STRING];
4497+ int rc;
4498+
4499+ serv->status = NNTP_NONE;
4500+
4501+ if (mutt_socket_open (conn) < 0)
4502+ return -1;
4503+
4504+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4505+ return nntp_connect_error (serv);
4506+
4507+ if (!mutt_strncmp ("200", buf, 3))
4508+ mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4509+ else if (!mutt_strncmp ("201", buf, 3))
4510+ mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4511+ else
4512+ {
4513+ mutt_socket_close (conn);
4514+ mutt_remove_trailing_ws (buf);
4515+ mutt_error ("%s", buf);
4516+ sleep (2);
4517+ return -1;
4518+ }
4519+
4520+ sleep (1);
4521+
4522+ /* Tell INN to switch to mode reader if it isn't so. Ignore all
4523+ returned codes and messages. */
4524+ mutt_socket_write (conn, "MODE READER\r\n");
4525+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4526+ return nntp_connect_error (serv);
4527+
4528+ mutt_socket_write (conn, "STAT\r\n");
4529+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4530+ return nntp_connect_error (serv);
4531+
4532+ if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
4533+ {
4534+ serv->status = NNTP_OK;
4535+ return 0;
4536+ }
4537+
4538+ rc = nntp_auth (serv);
4539+ if (rc == -1)
4540+ return nntp_connect_error (serv);
4541+ if (rc == -2)
4542+ {
4543+ mutt_socket_close (conn);
4544+ serv->status = NNTP_BYE;
4545+ return -1;
4546+ }
4547+ if (rc < 0)
4548+ {
4549+ mutt_socket_close (conn);
4550+ mutt_error _("Login failed.");
4551+ sleep (2);
4552+ return -1;
4553+ }
4554+ serv->status = NNTP_OK;
4555+ return 0;
4556+}
4557+
4558+static int nntp_attempt_features (NNTP_SERVER *serv)
4559+{
4560+ char buf[LONG_STRING];
4561+ CONNECTION *conn = serv->conn;
4562+
4563+ mutt_socket_write (conn, "XOVER\r\n");
4564+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4565+ return nntp_connect_error (serv);
4566+ if (mutt_strncmp ("500", buf, 3))
4567+ serv->hasXOVER = 1;
4568+
4569+ mutt_socket_write (conn, "XPAT\r\n");
4570+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4571+ return nntp_connect_error (serv);
4572+ if (mutt_strncmp ("500", buf, 3))
4573+ serv->hasXPAT = 1;
4574+
4575+ mutt_socket_write (conn, "LISTGROUP\r\n");
4576+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4577+ return nntp_connect_error (serv);
4578+ if (mutt_strncmp ("500", buf, 3))
4579+ serv->hasLISTGROUP = 1;
4580+
4581+ mutt_socket_write (conn, "XGTITLE +\r\n");
4582+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4583+ return nntp_connect_error (serv);
4584+ if (mutt_strncmp ("500", buf, 3))
4585+ serv->hasXGTITLE = 1;
4586+
4587+ if (!mutt_strncmp ("282", buf, 3))
4588+ {
4589+ do
4590+ {
4591+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4592+ return nntp_connect_error (serv);
4593+ } while (!(buf[0] == '.' && buf[1] == '\0'));
4594+ }
4595+
4596+ return 0;
4597+}
4598+
4599+static int nntp_open_connection (NNTP_SERVER *serv)
4600+{
4601+ if (serv->status == NNTP_OK)
4602+ return 0;
4603+ if (serv->status == NNTP_BYE)
4604+ return -1;
4605+ if (nntp_connect_and_auth (serv) < 0)
4606+ return -1;
4607+ if (nntp_attempt_features (serv) < 0)
4608+ return -1;
4609+ return 0;
4610+}
4611+
4612+static int nntp_reconnect (NNTP_SERVER *serv)
4613+{
4614+ char buf[SHORT_STRING];
4615+
4616+ mutt_socket_close (serv->conn);
4617+
4618+ FOREVER
4619+ {
4620+ if (nntp_connect_and_auth (serv) == 0)
4621+ return 0;
4622+
4623+ snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
4624+ serv->conn->account.host);
4625+ if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
4626+ {
4627+ serv->status = NNTP_BYE;
4628+ return -1;
4629+ }
4630+ }
4631+}
4632+
4633+/* Send data from line[LONG_STRING] and receive answer to same line */
4634+static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
4635+{
4636+ char buf[LONG_STRING];
4637+ int done = TRUE;
4638+
4639+ if (data->nserv->status == NNTP_BYE)
4640+ return -1;
4641+
4642+ do
4643+ {
4644+ if (*line)
4645+ {
4646+ mutt_socket_write (data->nserv->conn, line);
4647+ }
4648+ else if (data->group)
4649+ {
4650+ snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4651+ mutt_socket_write (data->nserv->conn, buf);
4652+ }
4653+
4654+ done = TRUE;
4655+ if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4656+ {
4657+ if (nntp_reconnect (data->nserv) < 0)
4658+ return -1;
4659+
4660+ if (data->group)
4661+ {
4662+ snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
4663+ mutt_socket_write (data->nserv->conn, buf);
4664+ if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
4665+ return -1;
4666+ }
4667+ if (*line)
4668+ done = FALSE;
4669+ }
4670+ else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
4671+ return -1;
4672+ } while (!done);
4673+
4674+ strfcpy (line, buf, linelen);
4675+ return 0;
4676+}
4677+
4678+/*
4679+ * This function calls funct(*line, *data) for each received line,
4680+ * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
4681+ * Returned codes:
4682+ * 0 - successful,
4683+ * 1 - correct but not performed (may be, have to be continued),
4684+ * -1 - conection lost,
4685+ * -2 - invalid command or execution error,
4686+ * -3 - error in funct(*line, *data).
4687+ */
4688+static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
4689+ int (*funct) (char *, void *), void *data, int tagged)
4690+{
4691+ char buf[LONG_STRING];
4692+ char *inbuf, *p;
4693+ int done = FALSE;
4694+ int chunk, line;
4695+ size_t lenbuf = 0;
4696+ int ret;
4697+
4698+ do
4699+ {
4700+ strfcpy (buf, query, sizeof (buf));
4701+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
4702+ return -1;
4703+ if (buf[0] == '5')
4704+ return -2;
4705+ if (buf[0] != '2')
4706+ return 1;
4707+
4708+ ret = 0;
4709+ line = 0;
4710+ inbuf = safe_malloc (sizeof (buf));
4711+
4712+ FOREVER
4713+ {
4714+ chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
4715+ M_SOCK_LOG_HDR);
4716+ if (chunk < 0)
4717+ break;
4718+
4719+ p = buf;
4720+ if (!lenbuf && buf[0] == '.')
4721+ {
4722+ if (buf[1] == '\0')
4723+ {
4724+ done = TRUE;
4725+ break;
4726+ }
4727+ if (buf[1] == '.')
4728+ p++;
4729+ }
4730+
4731+ strfcpy (inbuf + lenbuf, p, sizeof (buf));
4732+
4733+ if (chunk >= sizeof (buf))
4734+ {
4735+ lenbuf += strlen (p);
4736+ }
4737+ else
4738+ {
4739+ line++;
4740+ if (msg && ReadInc && (line % ReadInc == 0)) {
4741+ if (tagged)
4742+ mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
4743+ else
4744+ mutt_message ("%s %d", msg, line);
4745+ }
4746+
4747+ if (ret == 0 && funct (inbuf, data) < 0)
4748+ ret = -3;
4749+ lenbuf = 0;
4750+ }
4751+
4752+ safe_realloc (&inbuf, lenbuf + sizeof (buf));
4753+ }
4754+ FREE (&inbuf);
4755+ funct (NULL, data);
4756+ }
4757+ while (!done);
4758+ return ret;
4759+}
4760+
4761+static int nntp_read_tempfile (char *line, void *file)
4762+{
4763+ FILE *f = (FILE *)file;
4764+
4765+ if (!line)
4766+ rewind (f);
4767+ else
4768+ {
4769+ fputs (line, f);
4770+ if (fputc ('\n', f) == EOF)
4771+ return -1;
4772+ }
4773+ return 0;
4774+}
4775+
4776+static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
4777+{
4778+ register char *p, *b;
4779+ register char *colon = NULL;
4780+
4781+ b = p = xref;
4782+ while (*p)
4783+ {
4784+ /* skip to next word */
4785+ b = p;
4786+ while (*b && ((*b == ' ') || (*b == '\t'))) b++;
4787+ p = b;
4788+ colon = NULL;
4789+ /* skip to end of word */
4790+ while (*p && (*p != ' ') && (*p != '\t'))
4791+ {
4792+ if (*p == ':')
4793+ colon = p;
4794+ p++;
4795+ }
4796+ if (*p)
4797+ {
4798+ *p = '\0';
4799+ p++;
4800+ }
4801+ if (colon)
4802+ {
4803+ *colon = '\0';
4804+ colon++;
4805+ nntp_get_status (ctx, h, b, atoi(colon));
4806+ if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
4807+ h->article_num = atoi(colon);
4808+ }
4809+ }
4810+}
4811+
4812+/*
4813+ * returns:
4814+ * 0 on success
4815+ * 1 if article not found
4816+ * -1 if read or write error on tempfile or socket
4817+ */
4818+static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
4819+{
4820+ NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
4821+ FILE *f;
4822+ char buf[LONG_STRING];
4823+ char tempfile[_POSIX_PATH_MAX];
4824+ int ret;
4825+ HEADER *h = ctx->hdrs[ctx->msgcount];
4826+
4827+ mutt_mktemp (tempfile);
4828+ if (!(f = safe_fopen (tempfile, "w+")))
4829+ return -1;
4830+
4831+ if (!msgid)
4832+ snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
4833+ else
4834+ snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
4835+
4836+ ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
4837+ if (ret)
4838+ {
4839+#ifdef DEBUG
4840+ if (ret != -1)
4841+ dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
4842+#endif
4843+ fclose (f);
4844+ unlink (tempfile);
4845+ return (ret == -1 ? -1 : 1);
4846+ }
4847+
4848+ h->article_num = article_num;
4849+ h->env = mutt_read_rfc822_header (f, h, 0, 0);
4850+ fclose (f);
4851+ unlink (tempfile);
4852+
4853+ if (h->env->xref != NULL)
4854+ nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
4855+ else if (h->article_num == 0 && msgid)
4856+ {
4857+ snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
4858+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
4859+ h->article_num = atoi (buf + 4);
4860+ }
4861+
4862+ return 0;
4863+}
4864+
4865+static int parse_description (char *line, void *n)
4866+{
4867+#define news ((NNTP_SERVER *) n)
4868+ register char *d = line;
4869+ NNTP_DATA *data;
4870+
4871+ if (!line)
4872+ return 0;
4873+ while (*d && *d != '\t' && *d != ' ') d++;
4874+ *d = 0;
4875+ d++;
4876+ while (*d && (*d == '\t' || *d == ' ')) d++;
4877+ dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
4878+ if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
4879+ mutt_strcmp (d, data->desc))
4880+ {
4881+ FREE (&data->desc);
4882+ data->desc = safe_strdup (d);
4883+ }
4884+ return 0;
4885+#undef news
4886+}
4887+
4888+static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
4889+{
4890+ char buf[STRING];
4891+
4892+ if (!option (OPTLOADDESC) || !data || !data->nserv)
4893+ return;
4894+
4895+ /* Get newsgroup description, if we can */
4896+ if (data->nserv->hasXGTITLE)
4897+ snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
4898+ else
4899+ snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
4900+ if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
4901+ {
4902+#ifdef DEBUG
4903+ nntp_error ("nntp_get_desc()", buf);
4904+#endif
4905+ }
4906+}
4907+
4908+/*
4909+ * XOVER returns a tab separated list of:
4910+ * id|subject|from|date|Msgid|references|bytes|lines|xref
4911+ *
4912+ * This has to duplicate some of the functionality of
4913+ * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
4914+ * a limited number of headers which are "parsed" by placement in the list)
4915+ */
4916+static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
4917+{
4918+ NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
4919+ char *p, *b;
4920+ int x, done = 0;
4921+
4922+ hdr->env = mutt_new_envelope();
4923+ hdr->env->newsgroups = safe_strdup (nntp_data->group);
4924+ hdr->content = mutt_new_body();
4925+ hdr->content->type = TYPETEXT;
4926+ hdr->content->subtype = safe_strdup ("plain");
4927+ hdr->content->encoding = ENC7BIT;
4928+ hdr->content->disposition = DISPINLINE;
4929+ hdr->content->length = -1;
4930+ b = p = buf;
4931+
4932+ for (x = 0; !done && x < 9; x++)
4933+ {
4934+ /* if from file, need to skip newline character */
4935+ while (*p && *p != '\n' && *p != '\t') p++;
4936+ if (!*p) done++;
4937+ *p = '\0';
4938+ p++;
4939+ switch (x)
4940+ {
4941+ case 0:
4942+
4943+ hdr->article_num = atoi (b);
4944+ nntp_get_status (ctx, hdr, NULL, hdr->article_num);
4945+ break;
4946+ case 1:
4947+ hdr->env->subject = safe_strdup (b);
4948+ /* Now we need to do the things which would normally be done in
4949+ * mutt_read_rfc822_header() */
4950+ if (hdr->env->subject)
4951+ {
4952+ regmatch_t pmatch[1];
4953+
4954+ rfc2047_decode (&hdr->env->subject);
4955+
4956+ if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
4957+ hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
4958+ else
4959+ hdr->env->real_subj = hdr->env->subject;
4960+ }
4961+ break;
4962+ case 2:
4963+ rfc822_free_address (&hdr->env->from);
4964+ hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
4965+ rfc2047_decode_adrlist (hdr->env->from);
4966+ break;
4967+ case 3:
4968+ hdr->date_sent = mutt_parse_date (b, hdr);
4969+ hdr->received = hdr->date_sent;
4970+ break;
4971+ case 4:
4972+ FREE (&hdr->env->message_id);
4973+ hdr->env->message_id = safe_strdup (b);
4974+ break;
4975+ case 5:
4976+ mutt_free_list (&hdr->env->references);
4977+ hdr->env->references = mutt_parse_references (b, 0);
4978+ break;
4979+ case 6:
4980+ hdr->content->length = atoi (b);
4981+ break;
4982+ case 7:
4983+ hdr->lines = atoi (b);
4984+ break;
4985+ case 8:
4986+ if (!hdr->read)
4987+ FREE (&hdr->env->xref);
4988+ b = b + 6; /* skips the "Xref: " */
4989+ hdr->env->xref = safe_strdup (b);
4990+ nntp_parse_xref (ctx, nntp_data->group, b, hdr);
4991+ }
4992+ if (!*p)
4993+ return -1;
4994+ b = p;
4995+ }
4996+ return 0;
4997+}
4998+
4999+typedef struct
5000+{
5001+ CONTEXT *ctx;
5002+ unsigned int base;
5003+ unsigned int first;
5004+ unsigned int last;
5005+ unsigned short *messages;
5006+ char* msg;
5007+} FETCH_CONTEXT;
5008+
5009+#define fc ((FETCH_CONTEXT *) c)
5010+static int nntp_fetch_numbers (char *line, void *c)
5011+{
5012+ unsigned int num;
5013+
5014+ if (!line)
5015+ return 0;
5016+ num = atoi (line);
5017+ if (num < fc->base || num > fc->last)
5018+ return 0;
5019+ fc->messages[num - fc->base] = 1;
5020+ return 0;
5021+}
5022+
5023+static int add_xover_line (char *line, void *c)
5024+{
5025+ unsigned int num, total;
5026+ CONTEXT *ctx = fc->ctx;
5027+ NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5028+
5029+ if (!line)
5030+ return 0;
5031+
5032+ if (ctx->msgcount >= ctx->hdrmax)
5033+ mx_alloc_memory (ctx);
5034+ ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5035+ ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5036+
5037+ nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5038+ num = ctx->hdrs[ctx->msgcount]->article_num;
5039+
5040+ if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5041+ {
5042+ ctx->msgcount++;
5043+ if (num > data->lastLoaded)
5044+ data->lastLoaded = num;
5045+ num = num - fc->first + 1;
5046+ total = fc->last - fc->first + 1;
5047+ if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5048+ mutt_message ("%s %d/%d", fc->msg, num, total);
5049+ }
5050+ else
5051+ mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5052+
5053+ return 0;
5054+}
5055+#undef fc
5056+
5057+static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5058+ unsigned int last)
5059+{
5060+ char buf[HUGE_STRING];
5061+ char *msg = _("Fetching message headers...");
5062+ NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5063+ int ret;
5064+ int num;
5065+ int oldmsgcount;
5066+ unsigned int current;
5067+ FILE *f;
5068+ FETCH_CONTEXT fc;
5069+
5070+ /* if empty group or nothing to do */
5071+ if (!last || first > last)
5072+ return 0;
5073+
5074+ /* fetch list of articles */
5075+ fc.ctx = ctx;
5076+ fc.base = first;
5077+ fc.last = last;
5078+ fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5079+ if (nntp_data->nserv->hasLISTGROUP)
5080+ {
5081+ mutt_message _("Fetching list of articles...");
5082+ snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5083+ if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5084+ {
5085+ mutt_error (_("LISTGROUP command failed: %s"), buf);
5086+#ifdef DEBUG
5087+ nntp_error ("nntp_fetch_headers()", buf);
5088+#endif
5089+ FREE (&fc.messages);
5090+ return -1;
5091+ }
5092+ }
5093+ else
5094+ {
5095+ for (num = 0; num < last - first + 1; num++)
5096+ fc.messages[num] = 1;
5097+ }
5098+
5099+ /* CACHE: must be loaded xover cache here */
5100+ num = nntp_data->lastCached - first + 1;
5101+ if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5102+ {
5103+ nntp_cache_expand (buf, nntp_data->cache);
5104+ mutt_message _("Fetching headers from cache...");
5105+ if ((f = safe_fopen (buf, "r")))
5106+ {
5107+ int r = 0;
5108+
5109+ /* counting number of lines */
5110+ while (fgets (buf, sizeof (buf), f) != NULL)
5111+ r++;
5112+ rewind (f);
5113+ while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5114+ r--;
5115+ oldmsgcount = ctx->msgcount;
5116+ fc.first = first;
5117+ fc.last = first + num - 1;
5118+ fc.msg = NULL;
5119+ while (fgets (buf, sizeof (buf), f) != NULL)
5120+ add_xover_line (buf, &fc);
5121+ fclose (f);
5122+ nntp_data->lastLoaded = fc.last;
5123+ first = fc.last + 1;
5124+ if (ctx->msgcount > oldmsgcount)
5125+ mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5126+ }
5127+ else
5128+ nntp_delete_cache (nntp_data);
5129+ }
5130+ num = last - first + 1;
5131+ if (num <= 0)
5132+ {
5133+ FREE (&fc.messages);
5134+ return 0;
5135+ }
5136+
5137+ /*
5138+ * Without XOVER, we have to fetch each article header and parse
5139+ * it. With XOVER, we ask for all of them
5140+ */
5141+ mutt_message (msg);
5142+ if (nntp_data->nserv->hasXOVER)
5143+ {
5144+ oldmsgcount = ctx->msgcount;
5145+ fc.first = first;
5146+ fc.last = last;
5147+ fc.msg = msg;
5148+ snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5149+ ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5150+ if (ctx->msgcount > oldmsgcount)
5151+ mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5152+ if (ret != 0)
5153+ {
5154+ mutt_error (_("XOVER command failed: %s"), buf);
5155+#ifdef DEBUG
5156+ nntp_error ("nntp_fetch_headers()", buf);
5157+#endif
5158+ FREE (&fc.messages);
5159+ return -1;
5160+ }
5161+ /* fetched OK */
5162+ }
5163+ else
5164+ for (current = first; current <= last; current++)
5165+ {
5166+ HEADER *h;
5167+
5168+ ret = current - first + 1;
5169+ mutt_message ("%s %d/%d", msg, ret, num);
5170+
5171+ if (!fc.messages[current - fc.base])
5172+ continue;
5173+
5174+ if (ctx->msgcount >= ctx->hdrmax)
5175+ mx_alloc_memory (ctx);
5176+ h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5177+ h->index = ctx->msgcount;
5178+
5179+ ret = nntp_read_header (ctx, NULL, current);
5180+ if (ret == 0) /* Got article. Fetch next header */
5181+ {
5182+ nntp_get_status (ctx, h, NULL, h->article_num);
5183+ ctx->msgcount++;
5184+ mx_update_context (ctx, 1);
5185+ }
5186+ else
5187+ mutt_free_header (&h); /* skip it */
5188+ if (ret == -1)
5189+ {
5190+ FREE (&fc.messages);
5191+ return -1;
5192+ }
5193+
5194+ if (current > nntp_data->lastLoaded)
5195+ nntp_data->lastLoaded = current;
5196+ }
5197+ FREE (&fc.messages);
5198+ nntp_data->lastLoaded = last;
5199+ mutt_clear_error ();
5200+ return 0;
5201+}
5202+
5203+/*
5204+ * currently, nntp "mailbox" is "newsgroup"
5205+ */
5206+int nntp_open_mailbox (CONTEXT *ctx)
5207+{
5208+ NNTP_DATA *nntp_data;
5209+ NNTP_SERVER *serv;
5210+ char buf[HUGE_STRING];
5211+ char server[LONG_STRING];
5212+ int count = 0;
5213+ unsigned int first;
5214+ ACCOUNT acct;
5215+
5216+ if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5217+ {
5218+ mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5219+ mutt_sleep (2);
5220+ return -1;
5221+ }
5222+
5223+ server[0] = '\0';
5224+ nntp_expand_path (server, sizeof (server), &acct);
5225+ if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5226+ return -1;
5227+
5228+ CurrentNewsSrv = serv;
5229+
5230+ /* create NNTP-specific state struct if nof found in list */
5231+ if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5232+ {
5233+ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5234+ nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5235+ strcpy (nntp_data->group, buf);
5236+ hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5237+ nntp_add_to_list (serv, nntp_data);
5238+ }
5239+ ctx->data = nntp_data;
e1bffe0b 5240+ ctx->mx_close = nntp_fastclose_mailbox;
95768aa9 5241+ nntp_data->nserv = serv;
5242+
5243+ mutt_message (_("Selecting %s..."), nntp_data->group);
5244+
5245+ if (!nntp_data->desc)
5246+ {
5247+ nntp_get_desc (nntp_data, nntp_data->group, NULL);
5248+ if (nntp_data->desc)
5249+ nntp_save_cache_index (serv);
5250+ }
5251+
5252+ buf[0] = 0;
5253+ if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5254+ {
5255+#ifdef DEBUG
5256+ nntp_error ("nntp_open_mailbox()", buf);
5257+#endif
5258+ return -1;
5259+ }
5260+
5261+ if (mutt_strncmp ("211", buf, 3))
5262+ {
5263+ LIST *l = serv->list;
5264+
5265+ /* GROUP command failed */
5266+ if (!mutt_strncmp ("411", buf, 3))
5267+ {
5268+ mutt_error (_("Newsgroup %s not found on server %s"),
5269+ nntp_data->group, serv->conn->account.host);
5270+
5271+ /* CACHE: delete cache and line from .index */
5272+ nntp_delete_cache (nntp_data);
5273+ hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5274+ while (l && l->data != (void *) nntp_data) l = l->next;
5275+ if (l)
5276+ l->data = NULL;
5277+
5278+ sleep (2);
5279+ }
5280+
5281+ return -1;
5282+ }
5283+
5284+ sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5285+ &nntp_data->lastMessage, buf);
5286+
5287+ nntp_data->deleted = 0;
5288+
5289+ time (&serv->check_time);
5290+
5291+ /*
5292+ * Check for max adding context. If it is greater than $nntp_context,
5293+ * strip off extra articles
5294+ */
5295+ first = nntp_data->firstMessage;
5296+ if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5297+ first = nntp_data->lastMessage - NntpContext + 1;
5298+ if (first)
5299+ nntp_data->lastLoaded = first - 1;
5300+ return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5301+}
5302+
5303+int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5304+{
5305+ char buf[LONG_STRING];
5306+ char path[_POSIX_PATH_MAX];
5307+ NNTP_CACHE *cache;
5308+ char *m = _("Fetching message...");
5309+ int ret;
5310+
5311+ /* see if we already have the message in our cache */
5312+ cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5313+
5314+ /* if everything is fine, assign msg->fp and return */
5315+ if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5316+ (msg->fp = fopen (cache->path, "r")))
5317+ return 0;
5318+
5319+ /* clear the previous entry */
5320+ unlink (cache->path);
5321+ free (cache->path);
5322+
5323+ mutt_message (m);
5324+
5325+ cache->index = ctx->hdrs[msgno]->index;
5326+ mutt_mktemp (path);
5327+ cache->path = safe_strdup (path);
5328+ if (!(msg->fp = safe_fopen (path, "w+")))
5329+ {
5330+ FREE (&cache->path);
5331+ return -1;
5332+ }
5333+
5334+ if (ctx->hdrs[msgno]->article_num == 0)
5335+ snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5336+ ctx->hdrs[msgno]->env->message_id);
5337+ else
5338+ snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5339+ ctx->hdrs[msgno]->article_num);
5340+
5341+ ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5342+ msg->fp, ctx->tagged);
5343+ if (ret == 1)
5344+ {
5345+ mutt_error (_("Article %d not found on server"),
5346+ ctx->hdrs[msgno]->article_num);
5347+ dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5348+ }
5349+
5350+ if (ret)
5351+ {
5352+ fclose (msg->fp);
5353+ unlink (path);
5354+ FREE (&cache->path);
5355+ return -1;
5356+ }
5357+
5358+ mutt_free_envelope (&ctx->hdrs[msgno]->env);
5359+ ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5360+ /* fix content length */
5361+ fseek(msg->fp, 0, SEEK_END);
5362+ ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5363+ ctx->hdrs[msgno]->content->offset;
5364+
5365+ /* this is called in mutt before the open which fetches the message,
5366+ * which is probably wrong, but we just call it again here to handle
5367+ * the problem instead of fixing it.
5368+ */
5369+ mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5370+
5371+ /* These would normally be updated in mx_update_context(), but the
5372+ * full headers aren't parsed with XOVER, so the information wasn't
5373+ * available then.
5374+ */
5375+#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5376+ ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5377+#endif /* HAVE_PGP || HAVE_SMIME */
5378+
5379+ mutt_clear_error();
5380+ rewind (msg->fp);
5381+
5382+ return 0;
5383+}
5384+
5385+/* Post article */
5386+int nntp_post (const char *msg) {
5387+ char buf[LONG_STRING];
5388+ size_t len;
5389+ FILE *f;
5390+ NNTP_DATA *nntp_data;
5391+
5392+ if (Context && Context->magic == M_NNTP)
5393+ nntp_data = (NNTP_DATA *)Context->data;
5394+ else
5395+ {
5396+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5397+ !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5398+ {
5399+ mutt_error (_("Can't post article. No connection to news server."));
5400+ return -1;
5401+ }
5402+ nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5403+ }
5404+
5405+ if (!(f = safe_fopen (msg, "r")))
5406+ {
5407+ mutt_error (_("Can't post article. Unable to open %s"), msg);
5408+ return -1;
5409+ }
5410+
5411+ strfcpy (buf, "POST\r\n", sizeof (buf));
5412+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5413+ {
5414+ mutt_error (_("Can't post article. Connection to %s lost."),
5415+ nntp_data->nserv->conn->account.host);
5416+ return -1;
5417+ }
5418+ if (buf[0] != '3')
5419+ {
5420+ mutt_error (_("Can't post article: %s"), buf);
5421+ return -1;
5422+ }
5423+
5424+ buf[0] = '.';
5425+ buf[1] = '\0';
5426+ while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5427+ {
5428+ len = strlen (buf);
5429+ if (buf[len - 1] == '\n')
5430+ {
5431+ buf[len - 1] = '\r';
5432+ buf[len] = '\n';
5433+ len++;
5434+ buf[len] = '\0';
5435+ }
5436+ if (buf[1] == '.')
5437+ mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5438+ else
5439+ mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5440+ }
5441+ fclose (f);
5442+
5443+ if (buf[strlen (buf) - 1] != '\n')
5444+ mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5445+ mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5446+ if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5447+ {
5448+ mutt_error (_("Can't post article. Connection to %s lost."),
5449+ nntp_data->nserv->conn->account.host);
5450+ return -1;
5451+ }
5452+ if (buf[0] != '2')
5453+ {
5454+ mutt_error (_("Can't post article: %s"), buf);
5455+ return -1;
5456+ }
5457+
5458+ return 0;
5459+}
5460+
5461+/* nntp_logout_all: close all open connections. */
5462+void nntp_logout_all (void)
5463+{
5464+ char buf[LONG_STRING];
5465+ CONNECTION* conn;
5466+
5467+ conn = mutt_socket_head ();
5468+
5469+ while (conn)
5470+ {
5471+ CONNECTION *next = conn->next;
5472+
5473+ if (conn->account.type == M_ACCT_TYPE_NNTP)
5474+ {
5475+ mutt_message (_("Closing connection to %s..."), conn->account.host);
5476+ mutt_socket_write (conn, "QUIT\r\n");
5477+ mutt_socket_readln (buf, sizeof (buf), conn);
5478+ mutt_clear_error ();
5479+ mutt_socket_close (conn);
5480+ mutt_socket_free (conn);
5481+ }
5482+
5483+ conn = next;
5484+ }
5485+}
5486+
5487+static void nntp_free_acache (NNTP_DATA *data)
5488+{
5489+ int i;
5490+
5491+ for (i = 0; i < NNTP_CACHE_LEN; i++)
5492+ {
5493+ if (data->acache[i].path)
5494+ {
5495+ unlink (data->acache[i].path);
5496+ FREE (&data->acache[i].path);
5497+ }
5498+ }
5499+}
5500+
5501+void nntp_delete_data (void *p)
5502+{
5503+ NNTP_DATA *data = (NNTP_DATA *)p;
5504+
5505+ if (!p)
5506+ return;
5507+ FREE (&data->entries);
5508+ FREE (&data->desc);
5509+ FREE (&data->cache);
5510+ nntp_free_acache (data);
5511+ FREE (p);
5512+}
5513+
5514+int nntp_sync_mailbox (CONTEXT *ctx)
5515+{
5516+ NNTP_DATA *data = ctx->data;
5517+
5518+ /* CACHE: update cache and .index files */
5519+ if ((option (OPTSAVEUNSUB) || data->subscribed))
5520+ nntp_save_cache_group (ctx);
5521+ nntp_free_acache (data);
5522+
5523+ data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
5524+ return 0;
5525+}
5526+
e1bffe0b 5527+int nntp_fastclose_mailbox (CONTEXT *ctx)
95768aa9 5528+{
5529+ NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
5530+
5531+ if (!data)
e1bffe0b 5532+ return 0;
95768aa9 5533+ nntp_free_acache (data);
5534+ if (!data->nserv || !data->nserv->newsgroups || !data->group)
e1bffe0b 5535+ return 0;
95768aa9 5536+ nntp_save_cache_index (data->nserv);
5537+ if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
5538+ || tmp != data)
5539+ nntp_delete_data (data);
e1bffe0b 5540+ return 0;
95768aa9 5541+}
5542+
5543+/* commit changes and terminate connection */
5544+int nntp_close_mailbox (CONTEXT *ctx)
5545+{
5546+ if (!ctx)
5547+ return -1;
5548+ mutt_message _("Quitting newsgroup...");
5549+ if (ctx->data)
5550+ {
5551+ NNTP_DATA *data = (NNTP_DATA *) ctx->data;
5552+ int ret;
5553+
5554+ if (data->nserv && data->nserv->conn && ctx->unread)
5555+ {
5556+ ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
5557+ if (ret == M_YES)
5558+ mutt_newsgroup_catchup (data->nserv, data->group);
5559+ else if (ret < 0)
5560+ return -1;
5561+ }
5562+ }
5563+ nntp_sync_mailbox (ctx);
5564+ if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
5565+ {
5566+ NNTP_SERVER *news;
5567+
5568+ news = ((NNTP_DATA *)ctx->data)->nserv;
5569+ newsrc_gen_entries (ctx);
5570+ ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
5571+ mutt_newsrc_update (news);
5572+ }
5573+ mutt_clear_error();
5574+ return 0;
5575+}
5576+
5577+/* use the GROUP command to poll for new mail */
5578+static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
5579+{
5580+ char buf[LONG_STRING];
5581+ int count = 0;
5582+
5583+ if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
5584+ return 0;
5585+
5586+ buf[0] = 0;
5587+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5588+ {
5589+#ifdef DEBUG
5590+ nntp_error ("nntp_check_mailbox()", buf);
5591+#endif
5592+ return -1;
5593+ }
5594+ if (mutt_strncmp ("211", buf, 3))
5595+ {
5596+ buf[0] = 0;
5597+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5598+ {
5599+#ifdef DEBUG
5600+ nntp_error ("nntp_check_mailbox()", buf);
5601+#endif
5602+ return -1;
5603+ }
5604+ }
5605+ if (!mutt_strncmp ("211", buf, 3))
5606+ {
5607+ int first;
5608+ int last;
5609+
5610+ sscanf (buf + 4, "%d %d %d", &count, &first, &last);
5611+ nntp_data->firstMessage = first;
5612+ nntp_data->lastMessage = last;
5613+ if (ctx && last > nntp_data->lastLoaded)
5614+ {
5615+ nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
5616+ time (&nntp_data->nserv->check_time);
5617+ return 1;
5618+ }
5619+ if (!last || (!nntp_data->rc && !nntp_data->lastCached))
5620+ nntp_data->unread = count;
5621+ else
5622+ mutt_newsgroup_stat (nntp_data);
5623+ /* active was renumbered? */
5624+ if (last < nntp_data->lastLoaded)
5625+ {
5626+ if (!nntp_data->max)
5627+ {
5628+ nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
5629+ nntp_data->max = 5;
5630+ }
5631+ nntp_data->lastCached = 0;
5632+ nntp_data->num = 1;
5633+ nntp_data->entries[0].first = 1;
5634+ nntp_data->entries[0].last = 0;
5635+ }
5636+ }
5637+
5638+ time (&nntp_data->nserv->check_time);
5639+ return 0;
5640+}
5641+
5642+int nntp_check_mailbox (CONTEXT *ctx)
5643+{
5644+ return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
5645+}
5646+
5647+static int add_group (char *buf, void *serv)
5648+{
5649+#define s ((NNTP_SERVER *) serv)
5650+ char group[LONG_STRING], mod, desc[HUGE_STRING];
5651+ int first, last;
5652+ NNTP_DATA *nntp_data;
5653+ static int n = 0;
5654+
5655+ _checked = n; /* _checked have N, where N = number of groups */
5656+ if (!buf) /* at EOF must be zerouth */
5657+ n = 0;
5658+
5659+ if (!s || !buf)
5660+ return 0;
5661+
5662+ *desc = 0;
5663+ sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
5664+ if (!group)
5665+ return 0;
5666+ if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
5667+ {
5668+ n++;
5669+ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
5670+ nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5671+ strcpy (nntp_data->group, group);
5672+ nntp_data->nserv = s;
5673+ if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
5674+ s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2);
5675+ hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
5676+ nntp_add_to_list (s, nntp_data);
5677+ }
5678+ nntp_data->deleted = 0;
5679+ nntp_data->firstMessage = first;
5680+ nntp_data->lastMessage = last;
5681+ if (mod == 'y')
5682+ nntp_data->allowed = 1;
5683+ else
5684+ nntp_data->allowed = 0;
5685+ if (nntp_data->desc)
5686+ FREE (&nntp_data->desc);
5687+ if (*desc)
5688+ nntp_data->desc = safe_strdup (desc);
5689+ if (nntp_data->rc || nntp_data->lastCached)
5690+ mutt_newsgroup_stat (nntp_data);
5691+ else if (nntp_data->lastMessage &&
5692+ nntp_data->firstMessage <= nntp_data->lastMessage)
5693+ nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
5694+ else
5695+ nntp_data->unread = 0;
5696+
5697+ return 0;
5698+#undef s
5699+}
5700+
5701+int nntp_check_newgroups (NNTP_SERVER *serv, int force)
5702+{
5703+ char buf[LONG_STRING];
e1bffe0b 5704+ char msg[SHORT_STRING];
95768aa9 5705+ NNTP_DATA nntp_data;
5706+ LIST *l;
5707+ LIST emp;
5708+ time_t now;
5709+ struct tm *t;
e1bffe0b
JB
5710+ unsigned int count = 0;
5711+ unsigned int total = 0;
95768aa9 5712+
5713+ if (!serv || !serv->newgroups_time)
5714+ return -1;
5715+
5716+ if (nntp_open_connection (serv) < 0)
5717+ return -1;
5718+
5719+ /* check subscribed groups for new news */
5720+ if (option (OPTSHOWNEWNEWS))
5721+ {
5722+ mutt_message _("Checking for new messages...");
5723+ for (l = serv->list; l; l = l->next)
5724+ {
5725+ serv->check_time = 0; /* really check! */
5726+ if (l->data && ((NNTP_DATA *) l->data)->subscribed)
5727+ _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
5728+ }
5729+ }
5730+ else if (!force)
5731+ return 0;
5732+
5733+ mutt_message _("Checking for new newsgroups...");
5734+ now = serv->newgroups_time;
5735+ time (&serv->newgroups_time);
5736+ t = gmtime (&now);
5737+ snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
5738+ (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
5739+ t->tm_sec);
5740+ nntp_data.nserv = serv;
5741+ if (Context && Context->magic == M_NNTP)
5742+ nntp_data.group = ((NNTP_DATA *)Context->data)->group;
5743+ else
5744+ nntp_data.group = NULL;
5745+ l = serv->tail;
5746+ if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
5747+ add_group, serv, 0) != 0)
5748+ {
5749+#ifdef DEBUG
5750+ nntp_error ("nntp_check_newgroups()", buf);
5751+#endif
5752+ return -1;
5753+ }
5754+
e1bffe0b
JB
5755+ strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5756+ mutt_message (msg);
95768aa9 5757+ if (l)
5758+ emp.next = l->next;
5759+ else
5760+ emp.next = serv->list;
5761+ l = &emp;
5762+ while (l->next)
5763+ {
5764+ l = l->next;
5765+ ((NNTP_DATA *) l->data)->new = 1;
e1bffe0b
JB
5766+ total++;
5767+ }
5768+ l = &emp;
5769+ while (l->next)
5770+ {
5771+ l = l->next;
95768aa9 5772+ nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
e1bffe0b
JB
5773+ count++;
5774+ if (ReadInc && (count % ReadInc == 0))
5775+ mutt_message ("%s %d/%d", msg, count, total);
95768aa9 5776+ }
5777+ if (emp.next)
5778+ nntp_save_cache_index (serv);
5779+ mutt_clear_error ();
5780+ return _checked;
5781+}
5782+
5783+/* Load list of all newsgroups from cache ALL */
5784+int nntp_get_cache_all (NNTP_SERVER *serv)
5785+{
5786+ char buf[HUGE_STRING];
5787+ FILE *f;
5788+
5789+ nntp_cache_expand (buf, serv->cache);
5790+ if ((f = safe_fopen (buf, "r")))
5791+ {
5792+ int i = 0;
5793+
5794+ while (fgets (buf, sizeof(buf), f) != NULL)
5795+ {
5796+ if (ReadInc && (i % ReadInc == 0))
5797+ mutt_message (_("Loading list from cache... %d"), i);
5798+ add_group (buf, serv);
5799+ i++;
5800+ }
5801+ add_group (NULL, NULL);
5802+ fclose (f);
5803+ mutt_clear_error ();
5804+ return 0;
5805+ }
5806+ else
5807+ {
5808+ FREE (&serv->cache);
5809+ return -1;
5810+ }
5811+}
5812+
5813+/* Load list of all newsgroups from active */
5814+int nntp_get_active (NNTP_SERVER *serv)
5815+{
5816+ char msg[SHORT_STRING];
5817+ NNTP_DATA nntp_data;
5818+ LIST *tmp;
5819+
5820+ if (nntp_open_connection (serv) < 0)
5821+ return -1;
5822+
5823+ snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
5824+ serv->conn->account.host);
5825+ mutt_message (msg);
5826+ time (&serv->newgroups_time);
5827+ nntp_data.nserv = serv;
5828+ nntp_data.group = NULL;
5829+
5830+ if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
5831+ {
5832+#ifdef DEBUG
5833+ nntp_error ("nntp_get_active()", "LIST\r\n");
5834+#endif
5835+ return -1;
5836+ }
5837+
5838+ strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
5839+ mutt_message (msg);
5840+ nntp_get_desc (&nntp_data, "*", msg);
5841+
5842+ for (tmp = serv->list; tmp; tmp = tmp->next)
5843+ {
5844+ NNTP_DATA *data = (NNTP_DATA *)tmp->data;
5845+
5846+ if (data && data->deleted && !data->rc)
5847+ {
5848+ nntp_delete_cache (data);
5849+ hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
5850+ tmp->data = NULL;
5851+ }
5852+ }
5853+ nntp_save_cache_index (serv);
5854+
5855+ mutt_clear_error ();
5856+ return _checked;
5857+}
5858+
5859+/*
5860+ * returns -1 if error ocurred while retrieving header,
5861+ * number of articles which ones exist in context on success.
5862+ */
5863+int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
5864+{
5865+ int ret;
5866+
5867+ /* if msgid is already in context, don't reload them */
5868+ if (hash_find (ctx->id_hash, msgid))
5869+ return 1;
5870+ if (ctx->msgcount == ctx->hdrmax)
5871+ mx_alloc_memory (ctx);
5872+ ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5873+ ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5874+
5875+ mutt_message (_("Fetching %s from server..."), msgid);
5876+ ret = nntp_read_header (ctx, msgid, 0);
5877+ /* since nntp_read_header() may set read flag, we must reset it */
5878+ ctx->hdrs[ctx->msgcount]->read = 0;
5879+ if (ret != 0)
5880+ mutt_free_header (&ctx->hdrs[ctx->msgcount]);
5881+ else
5882+ {
5883+ ctx->msgcount++;
5884+ mx_update_context (ctx, 1);
5885+ ctx->changed = 1;
5886+ }
5887+ return ret;
5888+}
5889+
5890+typedef struct
5891+{
5892+ CONTEXT *ctx;
5893+ unsigned int num;
5894+ unsigned int max;
5895+ unsigned int *child;
5896+} CHILD_CONTEXT;
5897+
5898+static int check_children (char *s, void *c)
5899+{
5900+#define cc ((CHILD_CONTEXT *) c)
5901+ unsigned int i, n;
5902+
5903+ if (!s || (n = atoi (s)) == 0)
5904+ return 0;
5905+ for (i = 0; i < cc->ctx->msgcount; i++)
5906+ if (cc->ctx->hdrs[i]->article_num == n)
5907+ return 0;
5908+ if (cc->num >= cc->max)
5909+ safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
5910+ cc->child[cc->num++] = n;
5911+
5912+ return 0;
5913+#undef cc
5914+}
5915+
5916+int nntp_check_children (CONTEXT *ctx, const char *msgid)
5917+{
5918+ NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
5919+ char buf[STRING];
5920+ int i, ret = 0, tmp = 0;
5921+ CHILD_CONTEXT cc;
5922+
5923+ if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
5924+ !nntp_data->nserv->conn->account.host)
5925+ return -1;
5926+ if (nntp_data->firstMessage > nntp_data->lastLoaded)
5927+ return 0;
5928+ if (!nntp_data->nserv->hasXPAT)
5929+ {
5930+ mutt_error (_("Server %s does not support this operation!"),
5931+ nntp_data->nserv->conn->account.host);
5932+ return -1;
5933+ }
5934+
5935+ snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
5936+ nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
5937+
5938+ cc.ctx = ctx;
5939+ cc.num = 0;
5940+ cc.max = 25;
5941+ cc.child = safe_malloc (sizeof (unsigned int) * 25);
5942+ if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
5943+ {
5944+ FREE (&cc.child);
5945+ return -1;
5946+ }
5947+ /* dont try to read the xover cache. check_children() already
5948+ * made sure that we dont have the article, so we need to visit
5949+ * the server. Reading the cache at this point is also bad
5950+ * because it would duplicate messages */
5951+ if (option (OPTNEWSCACHE))
5952+ {
5953+ tmp++;
5954+ unset_option (OPTNEWSCACHE);
5955+ }
5956+ for (i = 0; i < cc.num; i++)
5957+ {
5958+ if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
5959+ break;
5960+ if (ctx->msgcount &&
5961+ ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
5962+ ctx->hdrs[ctx->msgcount - 1]->read = 0;
5963+ }
5964+ if (tmp)
5965+ set_option (OPTNEWSCACHE);
5966+ FREE (&cc.child);
5967+ return ret;
5968+}
e1bffe0b
JB
5969diff -udprP mutt-1.5.15.orig/nntp.h mutt-1.5.15/nntp.h
5970--- mutt-1.5.15.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
5971+++ mutt-1.5.15/nntp.h 2007-04-11 17:46:58.000000000 +0300
95768aa9 5972@@ -0,0 +1,136 @@
5973+/*
5974+ * Copyright (C) 1998 Brandon Long <blong@fiction.net>
5975+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
e1bffe0b 5976+ * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
95768aa9 5977+ *
5978+ * This program is free software; you can redistribute it and/or modify
5979+ * it under the terms of the GNU General Public License as published by
5980+ * the Free Software Foundation; either version 2 of the License, or
5981+ * (at your option) any later version.
5982+ *
5983+ * This program is distributed in the hope that it will be useful,
5984+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
5985+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5986+ * GNU General Public License for more details.
5987+ *
5988+ * You should have received a copy of the GNU General Public License
5989+ * along with this program; if not, write to the Free Software
5990+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5991+ */
5992+
5993+#ifndef _NNTP_H_
5994+#define _NNTP_H_ 1
5995+
5996+#include "mutt_socket.h"
5997+#include "mailbox.h"
5998+
5999+#include <time.h>
6000+
6001+#define NNTP_PORT 119
6002+#define NNTP_SSL_PORT 563
6003+
6004+/* number of entries in the hash table */
6005+#define NNTP_CACHE_LEN 10
6006+
6007+enum
6008+{
6009+ NNTP_NONE = 0,
6010+ NNTP_OK,
6011+ NNTP_BYE
6012+};
6013+
6014+typedef struct
6015+{
6016+ int first;
6017+ int last;
6018+} NEWSRC_ENTRY;
6019+
6020+typedef struct
6021+{
6022+ unsigned int hasXPAT : 1;
6023+ unsigned int hasXGTITLE : 1;
6024+ unsigned int hasXOVER : 1;
6025+ unsigned int hasLISTGROUP : 1;
6026+ unsigned int status : 3;
6027+ char *newsrc;
6028+ char *cache;
6029+ int stat;
6030+ off_t size;
6031+ time_t mtime;
6032+ time_t newgroups_time;
6033+ time_t check_time;
6034+ HASH *newsgroups;
6035+ LIST *list; /* list of newsgroups */
6036+ LIST *tail; /* last entry of list */
6037+ CONNECTION *conn;
6038+} NNTP_SERVER;
6039+
6040+typedef struct
6041+{
6042+ unsigned int index;
6043+ char *path;
6044+} NNTP_CACHE;
6045+
6046+typedef struct
6047+{
6048+ NEWSRC_ENTRY *entries;
6049+ unsigned int num; /* number of used entries */
6050+ unsigned int max; /* number of allocated entries */
6051+ unsigned int unread;
6052+ unsigned int firstMessage;
6053+ unsigned int lastMessage;
6054+ unsigned int lastLoaded;
6055+ unsigned int lastCached;
6056+ unsigned int subscribed : 1;
6057+ unsigned int rc : 1;
6058+ unsigned int new : 1;
6059+ unsigned int allowed : 1;
6060+ unsigned int deleted : 1;
6061+ char *group;
6062+ char *desc;
6063+ char *cache;
6064+ NNTP_SERVER *nserv;
6065+ NNTP_CACHE acache[NNTP_CACHE_LEN];
6066+} NNTP_DATA;
6067+
6068+/* internal functions */
6069+int nntp_get_active (NNTP_SERVER *);
6070+int nntp_get_cache_all (NNTP_SERVER *);
6071+int nntp_save_cache_index (NNTP_SERVER *);
6072+int nntp_check_newgroups (NNTP_SERVER *, int);
6073+int nntp_save_cache_group (CONTEXT *);
6074+int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6075+void newsrc_gen_entries (CONTEXT *);
6076+void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6077+void mutt_newsgroup_stat (NNTP_DATA *);
6078+void nntp_delete_cache (NNTP_DATA *);
6079+void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6080+void nntp_cache_expand (char *, const char *);
6081+void nntp_delete_data (void *);
6082+
6083+/* exposed interface */
6084+NNTP_SERVER *mutt_select_newsserver (char *);
6085+NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6086+NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6087+NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6088+NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6089+void nntp_clear_cacheindex (NNTP_SERVER *);
6090+int mutt_newsrc_update (NNTP_SERVER *);
6091+int nntp_open_mailbox (CONTEXT *);
6092+int nntp_sync_mailbox (CONTEXT *);
6093+int nntp_check_mailbox (CONTEXT *);
6094+int nntp_close_mailbox (CONTEXT *);
e1bffe0b 6095+int nntp_fastclose_mailbox (CONTEXT *);
95768aa9 6096+int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6097+int nntp_post (const char *);
6098+int nntp_check_msgid (CONTEXT *, const char *);
6099+int nntp_check_children (CONTEXT *, const char *);
6100+void nntp_buffy (char *);
6101+void nntp_expand_path (char *, size_t, ACCOUNT *);
6102+void nntp_logout_all ();
6103+const char *nntp_format_str (char *, size_t, char, const char *, const char *,
6104+ const char *, const char *, unsigned long, format_flag);
6105+
6106+NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6107+
6108+#endif /* _NNTP_H_ */
e1bffe0b
JB
6109diff -udprP mutt-1.5.15.orig/pager.c mutt-1.5.15/pager.c
6110--- mutt-1.5.15.orig/pager.c 2007-04-02 00:58:56.000000000 +0300
6111+++ mutt-1.5.15/pager.c 2007-04-11 17:25:15.000000000 +0300
6112@@ -1055,6 +1055,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
95768aa9 6113 return b_read;
6114 }
6115
6116+#ifdef USE_NNTP
6117+#include "mx.h"
6118+#include "nntp.h"
6119+#endif
6120+
6121
6122 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6123 int flags, ansi_attr *pa, int cnt,
e1bffe0b 6124@@ -1490,6 +1495,16 @@ static struct mapping_t PagerHelpExtra[]
95768aa9 6125 { NULL, 0 }
6126 };
6127
6128+#ifdef USE_NNTP
6129+static struct mapping_t PagerNewsHelpExtra[] = {
6130+ { N_("Post"), OP_POST },
6131+ { N_("Followup"), OP_FOLLOWUP },
6132+ { N_("Del"), OP_DELETE },
6133+ { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6134+ { NULL, 0 }
6135+};
6136+#endif
6137+
6138
6139
6140 /* This pager is actually not so simple as it once was. It now operates in
e1bffe0b 6141@@ -1531,6 +1546,10 @@ mutt_pager (const char *banner, const ch
95768aa9 6142 int old_PagerIndexLines; /* some people want to resize it
6143 * while inside the pager... */
6144
6145+#ifdef USE_NNTP
6146+ char *followup_to;
6147+#endif
6148+
6149 if (!(flags & M_SHOWCOLOR))
6150 flags |= M_SHOWFLAT;
6151
e1bffe0b 6152@@ -1570,7 +1589,11 @@ mutt_pager (const char *banner, const ch
95768aa9 6153 if (IsHeader (extra))
6154 {
6155 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6156- mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6157+ mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6158+#ifdef USE_NNTP
6159+ (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6160+#endif
6161+ PagerHelpExtra);
6162 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6163 }
6164 if (!InHelp)
e1bffe0b
JB
6165@@ -2393,6 +2416,15 @@ search_next:
6166 CHECK_READONLY;
6167 CHECK_ACL(M_ACL_WRITE, "flag message");
95768aa9 6168
6169+#ifdef USE_NNTP
6170+ if (Context->magic == M_NNTP)
6171+ {
6172+ mutt_flushinp ();
6173+ mutt_error _("Can't change 'important' flag on NNTP server.");
6174+ break;
6175+ }
6176+#endif
6177+
6178 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6179 redraw = REDRAW_STATUS | REDRAW_INDEX;
6180 if (option (OPTRESOLVE))
e1bffe0b 6181@@ -2426,6 +2458,60 @@ search_next:
95768aa9 6182 redraw = REDRAW_FULL;
6183 break;
6184
6185+#ifdef USE_NNTP
6186+ case OP_POST:
6187+ CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6188+ CHECK_ATTACH;
6189+ if (extra->ctx && extra->ctx->magic == M_NNTP &&
6190+ !((NNTP_DATA *)extra->ctx->data)->allowed &&
6191+ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6192+ break;
6193+ ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6194+ redraw = REDRAW_FULL;
6195+ break;
6196+
6197+ case OP_FORWARD_TO_GROUP:
6198+ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6199+ CHECK_ATTACH;
6200+ if (extra->ctx && extra->ctx->magic == M_NNTP &&
6201+ !((NNTP_DATA *)extra->ctx->data)->allowed &&
6202+ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6203+ break;
6204+ if (IsMsgAttach (extra))
6205+ mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6206+ extra->idxlen, extra->bdy, SENDNEWS);
6207+ else
6208+ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6209+ redraw = REDRAW_FULL;
6210+ break;
6211+
6212+ case OP_FOLLOWUP:
6213+ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6214+ CHECK_ATTACH;
6215+
6216+ if (IsMsgAttach (extra))
6217+ followup_to = extra->bdy->hdr->env->followup_to;
6218+ else
6219+ followup_to = extra->hdr->env->followup_to;
6220+
6221+ if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6222+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6223+ {
6224+ if (extra->ctx && extra->ctx->magic == M_NNTP &&
6225+ !((NNTP_DATA *)extra->ctx->data)->allowed &&
6226+ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6227+ break;
6228+ if (IsMsgAttach (extra))
6229+ mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6230+ extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6231+ else
6232+ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6233+ extra->ctx, extra->hdr);
6234+ redraw = REDRAW_FULL;
6235+ break;
6236+ }
6237+#endif
6238+
6239 case OP_REPLY:
6240 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6241 CHECK_ATTACH;
e1bffe0b 6242@@ -2472,7 +2558,7 @@ search_next:
95768aa9 6243 CHECK_ATTACH;
6244 if (IsMsgAttach (extra))
6245 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6246- extra->idxlen, extra->bdy);
6247+ extra->idxlen, extra->bdy, 0);
6248 else
6249 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6250 redraw = REDRAW_FULL;
e1bffe0b
JB
6251diff -udprP mutt-1.5.15.orig/parse.c mutt-1.5.15/parse.c
6252--- mutt-1.5.15.orig/parse.c 2007-04-02 00:58:56.000000000 +0300
6253+++ mutt-1.5.15/parse.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 6254@@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
6255 /* not reached */
6256 }
6257
6258-static LIST *mutt_parse_references (char *s, int in_reply_to)
6259+LIST *mutt_parse_references (char *s, int in_reply_to)
6260 {
6261 LIST *t, *lst = NULL;
6262 int m, n = 0;
e1bffe0b 6263@@ -1068,6 +1068,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
95768aa9 6264 e->from = rfc822_parse_adrlist (e->from, p);
6265 matched = 1;
6266 }
6267+#ifdef USE_NNTP
6268+ else if (!mutt_strcasecmp (line+1, "ollowup-to"))
6269+ {
6270+ if (!e->followup_to)
6271+ {
6272+ mutt_remove_trailing_ws (p);
6273+ e->followup_to = safe_strdup (mutt_skip_whitespace (p));
6274+ }
6275+ matched = 1;
6276+ }
6277+#endif
6278 break;
6279
6280 case 'i':
e1bffe0b 6281@@ -1152,6 +1163,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
95768aa9 6282 }
6283 break;
6284
6285+#ifdef USE_NNTP
6286+ case 'n':
6287+ if (!mutt_strcasecmp (line + 1, "ewsgroups"))
6288+ {
6289+ FREE (&e->newsgroups);
6290+ mutt_remove_trailing_ws (p);
6291+ e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
6292+ matched = 1;
6293+ }
6294+ break;
6295+#endif
6296+
6297+ case 'o':
6298+ /* field `Organization:' saves only for pager! */
6299+ if (!mutt_strcasecmp (line + 1, "rganization"))
6300+ {
6301+ if (!e->organization && mutt_strcasecmp (p, "unknown"))
6302+ e->organization = safe_strdup (p);
6303+ }
6304+ break;
6305+
6306 case 'r':
6307 if (!ascii_strcasecmp (line + 1, "eferences"))
6308 {
e1bffe0b 6309@@ -1260,6 +1292,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
95768aa9 6310 e->x_label = safe_strdup(p);
6311 matched = 1;
6312 }
6313+#ifdef USE_NNTP
6314+ else if (!mutt_strcasecmp (line + 1, "-comment-to"))
6315+ {
6316+ if (!e->x_comment_to)
6317+ e->x_comment_to = safe_strdup (p);
6318+ matched = 1;
6319+ }
6320+ else if (!mutt_strcasecmp (line + 1, "ref"))
6321+ {
6322+ if (!e->xref)
6323+ e->xref = safe_strdup (p);
6324+ matched = 1;
6325+ }
6326+#endif
6327
6328 default:
6329 break;
e1bffe0b
JB
6330diff -udprP mutt-1.5.15.orig/pattern.c mutt-1.5.15/pattern.c
6331--- mutt-1.5.15.orig/pattern.c 2007-04-02 00:58:56.000000000 +0300
6332+++ mutt-1.5.15/pattern.c 2007-04-11 17:25:15.000000000 +0300
6333@@ -91,6 +91,9 @@ Flags[] =
95768aa9 6334 { 'U', M_UNREAD, 0, NULL },
6335 { 'v', M_COLLAPSED, 0, NULL },
6336 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6337+#ifdef USE_NNTP
6338+ { 'w', M_NEWSGROUPS, 0, eat_regexp },
6339+#endif
6340 { 'x', M_REFERENCE, 0, eat_regexp },
6341 { 'X', M_MIMEATTACH, 0, eat_range },
6342 { 'y', M_XLABEL, 0, eat_regexp },
e1bffe0b 6343@@ -1208,6 +1211,10 @@ mutt_pattern_exec (struct pattern_t *pat
95768aa9 6344 }
6345 case M_UNREFERENCED:
6346 return (pat->not ^ (h->thread && !h->thread->child));
6347+#ifdef USE_NNTP
6348+ case M_NEWSGROUPS:
6349+ return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6350+#endif
6351 }
6352 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6353 return (-1);
e1bffe0b
JB
6354@@ -1276,6 +1283,7 @@ int mutt_pattern_func (int op, char *pro
6355 progress_t progress;
95768aa9 6356
6357 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6358+ if (prompt || op != M_LIMIT)
6359 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6360 return (-1);
6361
e1bffe0b
JB
6362diff -udprP mutt-1.5.15.orig/po/POTFILES.in mutt-1.5.15/po/POTFILES.in
6363--- mutt-1.5.15.orig/po/POTFILES.in 2007-04-02 00:58:57.000000000 +0300
6364+++ mutt-1.5.15/po/POTFILES.in 2007-04-11 17:25:15.000000000 +0300
6365@@ -47,6 +47,8 @@ mutt_ssl_gnutls.c
95768aa9 6366 mutt_tunnel.c
6367 muttlib.c
6368 mx.c
6369+newsrc.c
6370+nntp.c
6371 pager.c
6372 parse.c
6373 pattern.c
e1bffe0b
JB
6374diff -udprP mutt-1.5.15.orig/postpone.c mutt-1.5.15/postpone.c
6375--- mutt-1.5.15.orig/postpone.c 2007-04-02 00:58:57.000000000 +0300
6376+++ mutt-1.5.15/postpone.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 6377@@ -126,15 +126,26 @@ int mutt_num_postponed (int force)
6378
6379 if (LastModify < st.st_mtime)
6380 {
6381+#ifdef USE_NNTP
6382+ int optnews = option (OPTNEWS);
6383+#endif
6384 LastModify = st.st_mtime;
6385
6386 if (access (Postponed, R_OK | F_OK) != 0)
6387 return (PostCount = 0);
6388+#ifdef USE_NNTP
6389+ if (optnews)
6390+ unset_option (OPTNEWS);
6391+#endif
6392 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6393 PostCount = 0;
6394 else
6395 PostCount = ctx.msgcount;
6396 mx_fastclose_mailbox (&ctx);
6397+#ifdef USE_NNTP
6398+ if (optnews)
6399+ set_option (OPTNEWS);
6400+#endif
6401 }
6402
6403 return (PostCount);
e1bffe0b
JB
6404diff -udprP mutt-1.5.15.orig/protos.h mutt-1.5.15/protos.h
6405--- mutt-1.5.15.orig/protos.h 2007-04-02 00:58:57.000000000 +0300
6406+++ mutt-1.5.15/protos.h 2007-04-11 17:25:15.000000000 +0300
6407@@ -104,6 +104,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
95768aa9 6408 HASH *mutt_make_subj_hash (CONTEXT *);
6409
6410 LIST *mutt_make_references(ENVELOPE *e);
6411+LIST *mutt_parse_references (char *, int);
6412
6413 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6414 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
e1bffe0b 6415@@ -246,6 +247,7 @@ void mutt_unblock_signals_system (int);
95768aa9 6416 void mutt_update_encoding (BODY *a);
6417 void mutt_version (void);
6418 void mutt_view_attachments (HEADER *);
6419+void mutt_write_references (LIST *, FILE *);
6420 void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen, int display);
6421 void mutt_set_virtual (CONTEXT *);
6422
e1bffe0b
JB
6423diff -udprP mutt-1.5.15.orig/recvattach.c mutt-1.5.15/recvattach.c
6424--- mutt-1.5.15.orig/recvattach.c 2007-04-02 00:58:57.000000000 +0300
6425+++ mutt-1.5.15/recvattach.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 6426@@ -1087,6 +1087,15 @@ void mutt_view_attachments (HEADER *hdr)
6427 }
6428 #endif
6429
6430+#ifdef USE_NNTP
6431+ if (Context->magic == M_NNTP)
6432+ {
6433+ mutt_flushinp ();
6434+ mutt_error _("Can't delete attachment from newsserver.");
6435+ break;
6436+ }
6437+#endif
6438+
6439 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6440 {
6441 mutt_message _(
6442@@ -1178,10 +1187,33 @@ void mutt_view_attachments (HEADER *hdr)
6443 case OP_FORWARD_MESSAGE:
6444 CHECK_ATTACH;
6445 mutt_attach_forward (fp, hdr, idx, idxlen,
6446- menu->tagprefix ? NULL : idx[menu->current]->content);
6447+ menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6448 menu->redraw = REDRAW_FULL;
6449 break;
6450
6451+#ifdef USE_NNTP
6452+ case OP_FORWARD_TO_GROUP:
6453+ CHECK_ATTACH;
6454+ mutt_attach_forward (fp, hdr, idx, idxlen,
6455+ menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6456+ menu->redraw = REDRAW_FULL;
6457+ break;
6458+
6459+ case OP_FOLLOWUP:
6460+ CHECK_ATTACH;
6461+
6462+ if (!idx[menu->current]->content->hdr->env->followup_to ||
6463+ mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6464+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6465+ {
6466+ mutt_attach_reply (fp, hdr, idx, idxlen,
6467+ menu->tagprefix ? NULL : idx[menu->current]->content,
6468+ SENDNEWS|SENDREPLY);
6469+ menu->redraw = REDRAW_FULL;
6470+ break;
6471+ }
6472+#endif
6473+
6474 case OP_REPLY:
6475 case OP_GROUP_REPLY:
6476 case OP_LIST_REPLY:
e1bffe0b
JB
6477diff -udprP mutt-1.5.15.orig/recvcmd.c mutt-1.5.15/recvcmd.c
6478--- mutt-1.5.15.orig/recvcmd.c 2007-04-02 00:58:57.000000000 +0300
6479+++ mutt-1.5.15/recvcmd.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 6480@@ -377,7 +377,7 @@ static BODY ** copy_problematic_attachme
6481 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6482 ATTACHPTR ** idx, short idxlen,
6483 BODY * cur,
6484- short nattach)
6485+ short nattach, int flags)
6486 {
6487 short i;
6488 short mime_fwd_all = 0;
6489@@ -523,7 +523,7 @@ _("Can't decode all tagged attachments.
6490 tmpfp = NULL;
6491
6492 /* now that we have the template, send it. */
6493- ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6494+ ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6495 return;
6496
6497 bail:
6498@@ -550,7 +550,7 @@ _("Can't decode all tagged attachments.
6499 */
6500
6501 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6502- ATTACHPTR ** idx, short idxlen, BODY * cur)
6503+ ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6504 {
6505 HEADER *curhdr = NULL;
6506 HEADER *tmphdr;
6507@@ -655,23 +655,23 @@ static void attach_forward_msgs (FILE *
6508 else
6509 mutt_free_header (&tmphdr);
6510
6511- ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6512+ ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
6513 NULL, curhdr);
6514
6515 }
6516
6517 void mutt_attach_forward (FILE * fp, HEADER * hdr,
6518- ATTACHPTR ** idx, short idxlen, BODY * cur)
6519+ ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6520 {
6521 short nattach;
6522
6523
6524 if (check_all_msg (idx, idxlen, cur, 0) == 0)
6525- attach_forward_msgs (fp, hdr, idx, idxlen, cur);
6526+ attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
6527 else
6528 {
6529 nattach = count_tagged (idx, idxlen);
6530- attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
6531+ attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
6532 }
6533 }
6534
6535@@ -729,28 +729,40 @@ attach_reply_envelope_defaults (ENVELOPE
6536 return -1;
6537 }
6538
6539- if (parent)
6540+#ifdef USE_NNTP
6541+ if ((flags & SENDNEWS))
6542 {
6543- if (mutt_fetch_recips (env, curenv, flags) == -1)
6544- return -1;
6545+ /* in case followup set Newsgroups: with Followup-To: if it present */
6546+ if (!env->newsgroups && curenv &&
6547+ mutt_strcasecmp (curenv->followup_to, "poster"))
6548+ env->newsgroups = safe_strdup (curenv->followup_to);
6549 }
6550 else
6551+#endif
6552 {
6553- for (i = 0; i < idxlen; i++)
6554+ if (parent)
6555 {
6556- if (idx[i]->content->tagged
6557- && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6558+ if (mutt_fetch_recips (env, curenv, flags) == -1)
6559 return -1;
6560 }
6561+ else
6562+ {
6563+ for (i = 0; i < idxlen; i++)
6564+ {
6565+ if (idx[i]->content->tagged
6566+ && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
6567+ return -1;
6568+ }
6569+ }
6570+
6571+ if ((flags & SENDLISTREPLY) && !env->to)
6572+ {
6573+ mutt_error _("No mailing lists found!");
6574+ return (-1);
6575+ }
6576+
6577+ mutt_fix_reply_recipients (env);
6578 }
6579-
6580- if ((flags & SENDLISTREPLY) && !env->to)
6581- {
6582- mutt_error _("No mailing lists found!");
6583- return (-1);
6584- }
6585-
6586- mutt_fix_reply_recipients (env);
6587 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
6588
6589 if (parent)
6590@@ -811,6 +823,13 @@ void mutt_attach_reply (FILE * fp, HEADE
6591 char prefix[SHORT_STRING];
6592 int rc;
6593
6594+#ifdef USE_NNTP
6595+ if (flags & SENDNEWS)
6596+ set_option (OPTNEWSSEND);
6597+ else
6598+ unset_option (OPTNEWSSEND);
6599+#endif
6600+
6601 if (check_all_msg (idx, idxlen, cur, 0) == -1)
6602 {
6603 nattach = count_tagged (idx, idxlen);
e1bffe0b
JB
6604diff -udprP mutt-1.5.15.orig/rfc1524.c mutt-1.5.15/rfc1524.c
6605--- mutt-1.5.15.orig/rfc1524.c 2007-04-02 00:58:58.000000000 +0300
6606+++ mutt-1.5.15/rfc1524.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 6607@@ -569,13 +569,13 @@ int rfc1524_expand_filename (char *namet
6608 * safe_fopen().
6609 */
6610
6611-int mutt_rename_file (char *oldfile, char *newfile)
6612+int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
6613 {
6614 FILE *ofp, *nfp;
6615
6616 if (access (oldfile, F_OK) != 0)
6617 return 1;
6618- if (access (newfile, F_OK) == 0)
6619+ if (!overwrite && access (newfile, F_OK) == 0)
6620 return 2;
6621 if ((ofp = fopen (oldfile,"r")) == NULL)
6622 return 3;
6623@@ -590,3 +590,8 @@ int mutt_rename_file (char *oldfile, cha
6624 mutt_unlink (oldfile);
6625 return 0;
6626 }
6627+
6628+int mutt_rename_file (char *oldfile, char *newfile)
6629+{
6630+ return _mutt_rename_file (oldfile, newfile, 0);
6631+}
e1bffe0b
JB
6632diff -udprP mutt-1.5.15.orig/rfc1524.h mutt-1.5.15/rfc1524.h
6633--- mutt-1.5.15.orig/rfc1524.h 2007-04-02 00:58:58.000000000 +0300
6634+++ mutt-1.5.15/rfc1524.h 2007-04-11 17:25:15.000000000 +0300
95768aa9 6635@@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char
6636 int rfc1524_expand_filename (char *, char *, char *, size_t);
6637 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
6638 int mutt_rename_file (char *, char *);
6639+int _mutt_rename_file (char *, char *, int);
6640
6641 #endif /* _RFC1524_H */
e1bffe0b
JB
6642diff -udprP mutt-1.5.15.orig/send.c mutt-1.5.15/send.c
6643--- mutt-1.5.15.orig/send.c 2007-04-02 00:58:58.000000000 +0300
6644+++ mutt-1.5.15/send.c 2007-04-11 16:07:11.000000000 +0300
6645@@ -45,6 +45,10 @@
95768aa9 6646 #include <sys/types.h>
6647 #include <utime.h>
6648
6649+#ifdef USE_NNTP
6650+#include "nntp.h"
6651+#endif
6652+
6653 #ifdef MIXMASTER
6654 #include "remailer.h"
6655 #endif
e1bffe0b 6656@@ -214,17 +218,51 @@ static int edit_address (ADDRESS **a, /*
95768aa9 6657 return 0;
6658 }
6659
6660-static int edit_envelope (ENVELOPE *en)
6661+static int edit_envelope (ENVELOPE *en, int flags)
6662 {
6663 char buf[HUGE_STRING];
6664 LIST *uh = UserHeader;
6665
6666- if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6667- return (-1);
6668- if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6669- return (-1);
6670- if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6671- return (-1);
6672+#ifdef USE_NNTP
6673+ if (option (OPTNEWSSEND))
6674+ {
6675+ if (en->newsgroups)
6676+ strfcpy (buf, en->newsgroups, sizeof (buf));
6677+ else
6678+ buf[0] = 0;
6679+ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
6680+ return (-1);
6681+ FREE (&en->newsgroups);
6682+ en->newsgroups = safe_strdup (buf);
6683+
6684+ if (en->followup_to)
6685+ strfcpy (buf, en->followup_to, sizeof (buf));
6686+ else
6687+ buf[0] = 0;
6688+ if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
6689+ return (-1);
6690+ FREE (&en->followup_to);
6691+ en->followup_to = safe_strdup (buf);
6692+
6693+ if (en->x_comment_to)
6694+ strfcpy (buf, en->x_comment_to, sizeof (buf));
6695+ else
6696+ buf[0] = 0;
6697+ if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
6698+ return (-1);
6699+ FREE (&en->x_comment_to);
6700+ en->x_comment_to = safe_strdup (buf);
6701+ }
6702+ else
6703+#endif
6704+ {
6705+ if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
6706+ return (-1);
6707+ if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
6708+ return (-1);
6709+ if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
6710+ return (-1);
6711+ }
6712
6713 if (en->subject)
6714 {
e1bffe0b 6715@@ -260,6 +298,14 @@ static int edit_envelope (ENVELOPE *en)
95768aa9 6716 return 0;
6717 }
6718
6719+#ifdef USE_NNTP
6720+char *nntp_get_header (const char *s)
6721+{
6722+ SKIPWS (s);
6723+ return safe_strdup (s);
6724+}
6725+#endif
6726+
6727 static void process_user_recips (ENVELOPE *env)
6728 {
6729 LIST *uh = UserHeader;
e1bffe0b 6730@@ -272,6 +318,14 @@ static void process_user_recips (ENVELOP
95768aa9 6731 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
6732 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
6733 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
6734+#ifdef USE_NNTP
6735+ else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
6736+ env->newsgroups = nntp_get_header (uh->data + 11);
6737+ else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
6738+ env->followup_to = nntp_get_header (uh->data + 12);
6739+ else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
6740+ env->x_comment_to = nntp_get_header (uh->data + 13);
6741+#endif
6742 }
6743 }
6744
e1bffe0b 6745@@ -302,6 +356,12 @@ static void process_user_header (ENVELOP
95768aa9 6746 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
6747 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
6748 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
6749+#ifdef USE_NNTP
6750+ ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
6751+ ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
6752+ ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
6753+#endif
6754+ ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
6755 ascii_strncasecmp ("subject:", uh->data, 8) != 0)
6756 {
6757 if (last)
e1bffe0b 6758@@ -645,6 +705,10 @@ void mutt_add_to_reference_headers (ENVE
95768aa9 6759 if (pp) *pp = p;
6760 if (qq) *qq = q;
6761
6762+#ifdef USE_NNTP
6763+ if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
6764+ env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
6765+#endif
6766 }
6767
6768 static void
e1bffe0b 6769@@ -701,6 +765,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
95768aa9 6770
6771 if (flags & SENDREPLY)
6772 {
6773+#ifdef USE_NNTP
6774+ if ((flags & SENDNEWS))
6775+ {
6776+ /* in case followup set Newsgroups: with Followup-To: if it present */
6777+ if (!env->newsgroups && curenv &&
6778+ mutt_strcasecmp (curenv->followup_to, "poster"))
6779+ env->newsgroups = safe_strdup (curenv->followup_to);
6780+ }
6781+ else
6782+#endif
6783 if (tag)
6784 {
6785 HEADER *h;
e1bffe0b 6786@@ -847,7 +921,18 @@ void mutt_set_followup_to (ENVELOPE *e)
95768aa9 6787 * it hasn't already been set
6788 */
6789
6790- if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
6791+ if (!option (OPTFOLLOWUPTO))
6792+ return;
6793+#ifdef USE_NNTP
6794+ if (option (OPTNEWSSEND))
6795+ {
6796+ if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
6797+ e->followup_to = safe_strdup (e->newsgroups);
6798+ return;
6799+ }
6800+#endif
6801+
6802+ if (!e->mail_followup_to)
6803 {
6804 if (mutt_is_list_cc (0, e->to, e->cc))
6805 {
e1bffe0b
JB
6806@@ -1008,6 +1093,9 @@ static int send_message (HEADER *msg)
6807 #endif
6808
6809 #if USE_SMTP
6810+#ifdef USE_NNTP
6811+ if (!option (OPTNEWSSEND))
6812+#endif /* USE_NNTP */
6813 if (SmtpUrl)
6814 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
6815 msg->env->bcc, tempfile,
6816@@ -1100,6 +1188,13 @@ ci_send_message (int flags, /* send mod
95768aa9 6817
6818 int rv = -1;
6819
6820+#ifdef USE_NNTP
6821+ if (flags & SENDNEWS)
6822+ set_option (OPTNEWSSEND);
6823+ else
6824+ unset_option (OPTNEWSSEND);
6825+#endif
6826+
6827 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
6828 mutt_num_postponed (1))
6829 {
e1bffe0b 6830@@ -1130,6 +1225,22 @@ ci_send_message (int flags, /* send mod
95768aa9 6831 {
6832 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
6833 goto cleanup;
6834+#ifdef USE_NNTP
6835+ /*
6836+ * If postponed message is a news article, it have
6837+ * a "Newsgroups:" header line, then set appropriate flag.
6838+ */
6839+ if (msg->env->newsgroups)
6840+ {
6841+ flags |= SENDNEWS;
6842+ set_option (OPTNEWSSEND);
6843+ }
6844+ else
6845+ {
6846+ flags &= ~SENDNEWS;
6847+ unset_option (OPTNEWSSEND);
6848+ }
6849+#endif
6850 }
6851
6852 if (flags & (SENDPOSTPONED|SENDRESEND))
e1bffe0b
JB
6853@@ -1237,11 +1348,16 @@ ci_send_message (int flags, /* send mod
6854 if (flags & SENDREPLY)
6855 mutt_fix_reply_recipients (msg->env);
95768aa9 6856
6857+#ifdef USE_NNTP
6858+ if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
6859+ msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
6860+#endif
6861+
6862 if (! (flags & SENDMAILX) &&
6863 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
6864 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
6865 {
6866- if (edit_envelope (msg->env) == -1)
6867+ if (edit_envelope (msg->env, flags) == -1)
6868 goto cleanup;
6869 }
6870
e1bffe0b 6871@@ -1495,6 +1611,11 @@ main_loop:
95768aa9 6872 if (i == -1)
6873 {
6874 /* abort */
6875+#ifdef USE_NNTP
6876+ if (flags & SENDNEWS)
6877+ mutt_message _("Article not posted.");
6878+ else
6879+#endif
6880 mutt_message _("Mail not sent.");
6881 goto cleanup;
6882 }
e1bffe0b 6883@@ -1527,6 +1648,9 @@ main_loop:
95768aa9 6884 }
6885 }
6886
6887+#ifdef USE_NNTP
6888+ if (!(flags & SENDNEWS))
6889+#endif
6890 if (!msg->env->to && !msg->env->cc && !msg->env->bcc)
6891 {
6892 if (! (flags & SENDBATCH))
e1bffe0b 6893@@ -1559,6 +1683,19 @@ main_loop:
95768aa9 6894 mutt_error _("No subject specified.");
6895 goto main_loop;
6896 }
6897+#ifdef USE_NNTP
6898+ if ((flags & SENDNEWS) && !msg->env->subject)
6899+ {
6900+ mutt_error _("No subject specified.");
6901+ goto main_loop;
6902+ }
6903+
6904+ if ((flags & SENDNEWS) && !msg->env->newsgroups)
6905+ {
6906+ mutt_error _("No newsgroup specified.");
6907+ goto main_loop;
6908+ }
6909+#endif
6910
6911 if (msg->content->next)
6912 msg->content = mutt_make_multipart (msg->content);
e1bffe0b 6913@@ -1764,7 +1901,12 @@ full_fcc:
95768aa9 6914 }
6915 }
6916 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
6917- mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
6918+ mutt_message (i != 0 ? _("Sending in background.") :
6919+#ifdef USE_NNTP
6920+ (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
6921+#else
6922+ _("Mail sent."));
6923+#endif
6924
6925 if (WithCrypto && (msg->security & ENCRYPT))
6926 FREE (&pgpkeylist);
e1bffe0b
JB
6927diff -udprP mutt-1.5.15.orig/sendlib.c mutt-1.5.15/sendlib.c
6928--- mutt-1.5.15.orig/sendlib.c 2007-04-03 20:52:56.000000000 +0300
6929+++ mutt-1.5.15/sendlib.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 6930@@ -45,6 +45,10 @@
6931 #include <sys/wait.h>
6932 #include <fcntl.h>
6933
6934+#ifdef USE_NNTP
e1bffe0b 6935+#include "nntp.h"
95768aa9 6936+#endif
6937+
6938 #ifdef HAVE_SYSEXITS_H
6939 #include <sysexits.h>
6940 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
e1bffe0b 6941@@ -1525,7 +1529,7 @@ void mutt_write_address_list (ADDRESS *a
95768aa9 6942 /* need to write the list in reverse because they are stored in reverse order
6943 * when parsed to speed up threading
6944 */
6945-static void write_references (LIST *r, FILE *f)
6946+void mutt_write_references (LIST *r, FILE *f)
6947 {
6948 LIST **ref = NULL;
6949 int refcnt = 0, refmax = 0;
e1bffe0b 6950@@ -1742,6 +1746,9 @@ int mutt_write_rfc822_header (FILE *fp,
95768aa9 6951 LIST *tmp = env->userhdrs;
6952 int has_agent = 0; /* user defined user-agent header field exists */
6953
6954+#ifdef USE_NNTP
6955+ if (!option (OPTNEWSSEND))
6956+#endif
6957 if (mode == 0 && !privacy)
6958 fputs (mutt_make_date (buffer, sizeof(buffer)), fp);
6959
e1bffe0b 6960@@ -1768,6 +1775,9 @@ int mutt_write_rfc822_header (FILE *fp,
95768aa9 6961 mutt_write_address_list (env->to, fp, 4, 0);
6962 }
6963 else if (mode > 0)
6964+#ifdef USE_NNTP
6965+ if (!option (OPTNEWSSEND))
6966+#endif
6967 fputs ("To: \n", fp);
6968
6969 if (env->cc)
e1bffe0b 6970@@ -1776,6 +1786,9 @@ int mutt_write_rfc822_header (FILE *fp,
95768aa9 6971 mutt_write_address_list (env->cc, fp, 4, 0);
6972 }
6973 else if (mode > 0)
6974+#ifdef USE_NNTP
6975+ if (!option (OPTNEWSSEND))
6976+#endif
6977 fputs ("Cc: \n", fp);
6978
6979 if (env->bcc)
e1bffe0b 6980@@ -1787,8 +1800,28 @@ int mutt_write_rfc822_header (FILE *fp,
95768aa9 6981 }
6982 }
6983 else if (mode > 0)
6984+#ifdef USE_NNTP
6985+ if (!option (OPTNEWSSEND))
6986+#endif
6987 fputs ("Bcc: \n", fp);
6988
6989+#ifdef USE_NNTP
6990+ if (env->newsgroups)
6991+ fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
6992+ else if (mode == 1 && option (OPTNEWSSEND))
6993+ fputs ("Newsgroups: \n", fp);
6994+
6995+ if (env->followup_to)
6996+ fprintf (fp, "Followup-To: %s\n", env->followup_to);
6997+ else if (mode == 1 && option (OPTNEWSSEND))
6998+ fputs ("Followup-To: \n", fp);
6999+
7000+ if (env->x_comment_to)
7001+ fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
7002+ else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
7003+ fputs ("X-Comment-To: \n", fp);
7004+#endif
7005+
7006 if (env->subject)
e1bffe0b 7007 mutt_write_one_header (fp, "Subject", env->subject, NULL, 0);
95768aa9 7008 else if (mode == 1)
e1bffe0b 7009@@ -1807,6 +1840,9 @@ int mutt_write_rfc822_header (FILE *fp,
95768aa9 7010 fputs ("Reply-To: \n", fp);
7011
7012 if (env->mail_followup_to)
7013+#ifdef USE_NNTP
7014+ if (!option (OPTNEWSSEND))
7015+#endif
7016 {
7017 fputs ("Mail-Followup-To: ", fp);
7018 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
e1bffe0b 7019@@ -1817,7 +1853,7 @@ int mutt_write_rfc822_header (FILE *fp,
95768aa9 7020 if (env->references)
7021 {
7022 fputs ("References:", fp);
7023- write_references (env->references, fp);
7024+ mutt_write_references (env->references, fp);
7025 fputc('\n', fp);
7026 }
7027
e1bffe0b 7028@@ -1829,7 +1865,7 @@ int mutt_write_rfc822_header (FILE *fp,
95768aa9 7029 if (env->in_reply_to)
7030 {
7031 fputs ("In-Reply-To:", fp);
7032- write_references (env->in_reply_to, fp);
7033+ mutt_write_references (env->in_reply_to, fp);
7034 fputc ('\n', fp);
7035 }
7036
e1bffe0b 7037@@ -2145,11 +2181,30 @@ mutt_invoke_sendmail (ADDRESS *from, /*
95768aa9 7038 const char *msg, /* file containing message */
7039 int eightbit) /* message contains 8bit chars */
7040 {
7041- char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
7042+ char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
7043 char **args = NULL;
7044 size_t argslen = 0, argsmax = 0;
7045 int i;
7046
7047+#ifdef USE_NNTP
7048+ if (option (OPTNEWSSEND))
7049+ {
7050+ char cmd[LONG_STRING];
7051+
7052+ mutt_FormatString (cmd, sizeof (cmd), NONULL (Inews), nntp_format_str, 0, 0);
7053+ if (!*cmd)
7054+ {
7055+ i = nntp_post (msg);
7056+ unlink (msg);
7057+ return i;
7058+ }
7059+
7060+ s = safe_strdup (cmd);
7061+ }
7062+ else
7063+#endif
7064+ s = safe_strdup (Sendmail);
7065+
7066 ps = s;
7067 i = 0;
7068 while ((ps = strtok (ps, " ")))
e1bffe0b 7069@@ -2173,6 +2228,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
95768aa9 7070 i++;
7071 }
7072
7073+#ifdef USE_NNTP
7074+ if (!option (OPTNEWSSEND))
7075+ {
7076+#endif
7077 if (eightbit && option (OPTUSE8BITMIME))
7078 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7079
e1bffe0b 7080@@ -2204,6 +2263,9 @@ mutt_invoke_sendmail (ADDRESS *from, /*
95768aa9 7081 args = add_args (args, &argslen, &argsmax, to);
7082 args = add_args (args, &argslen, &argsmax, cc);
7083 args = add_args (args, &argslen, &argsmax, bcc);
7084+#ifdef USE_NNTP
7085+ }
7086+#endif
7087
7088 if (argslen == argsmax)
7089 safe_realloc (&args, sizeof (char *) * (++argsmax));
e1bffe0b 7090@@ -2336,6 +2398,9 @@ void mutt_prepare_envelope (ENVELOPE *en
95768aa9 7091 rfc2047_encode_adrlist (env->reply_to, "Reply-To");
7092
7093 if (env->subject)
7094+#ifdef USE_NNTP
7095+ if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
7096+#endif
7097 {
7098 rfc2047_encode_string (&env->subject);
7099 }
e1bffe0b 7100@@ -2441,6 +2506,10 @@ int mutt_bounce_message (FILE *fp, HEADE
95768aa9 7101 }
7102 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
7103
7104+#ifdef USE_NNTP
7105+ unset_option (OPTNEWSSEND);
7106+#endif
7107+
7108 ret = _mutt_bounce_message (fp, h, to, resent_from, from);
7109
7110 rfc822_free_address (&from);
e1bffe0b
JB
7111diff -udprP mutt-1.5.15.orig/sort.c mutt-1.5.15/sort.c
7112--- mutt-1.5.15.orig/sort.c 2007-04-02 00:58:58.000000000 +0300
7113+++ mutt-1.5.15/sort.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 7114@@ -149,6 +149,15 @@ int compare_order (const void *a, const
7115 HEADER **ha = (HEADER **) a;
7116 HEADER **hb = (HEADER **) b;
7117
7118+#ifdef USE_NNTP
7119+ if ((*ha)->article_num && (*hb)->article_num)
7120+ {
7121+ int result = (*ha)->article_num - (*hb)->article_num;
7122+ AUXSORT(result,a,b);
7123+ return (SORTCODE (result));
7124+ }
7125+ else
7126+#endif
7127 /* no need to auxsort because you will never have equality here */
7128 return (SORTCODE ((*ha)->index - (*hb)->index));
7129 }
e1bffe0b
JB
7130diff -udprP mutt-1.5.15.orig/url.c mutt-1.5.15/url.c
7131--- mutt-1.5.15.orig/url.c 2007-04-02 00:58:58.000000000 +0300
7132+++ mutt-1.5.15/url.c 2007-04-11 17:25:15.000000000 +0300
95768aa9 7133@@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] =
7134 { "imaps", U_IMAPS },
e1bffe0b
JB
7135 { "pop", U_POP },
7136 { "pops", U_POPS },
7137+ { "news", U_NNTP },
7138+ { "newss", U_NNTPS },
95768aa9 7139 { "mailto", U_MAILTO },
e1bffe0b
JB
7140 { "smtp", U_SMTP },
7141 { "smtps", U_SMTPS },
7142diff -udprP mutt-1.5.15.orig/url.h mutt-1.5.15/url.h
7143--- mutt-1.5.15.orig/url.h 2007-04-02 00:58:58.000000000 +0300
7144+++ mutt-1.5.15/url.h 2007-04-11 17:25:15.000000000 +0300
95768aa9 7145@@ -8,6 +8,8 @@ typedef enum url_scheme
7146 U_POPS,
7147 U_IMAP,
7148 U_IMAPS,
7149+ U_NNTP,
7150+ U_NNTPS,
e1bffe0b
JB
7151 U_SMTP,
7152 U_SMTPS,
95768aa9 7153 U_MAILTO,
e1bffe0b
JB
7154diff -udprP mutt-1.5.15.orig/Makefile.am mutt-1.5.15/Makefile.am
7155--- mutt-1.5.15.orig/Makefile.am 2007-04-06 23:04:45.000000000 +0300
7156+++ mutt-1.5.15/Makefile.am 2007-04-11 17:25:15.000000000 +0300
7157@@ -62,6 +62,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
7158 smtp.c browser.h mbyte.h remailer.h url.h \
95768aa9 7159 crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
7160 pgppacket.c mutt_idna.h hcache.h hcache.c bcache.c bcache.h mutt_ssl_gnutls.c \
7161+ nntp.c newsrc.c \
e1bffe0b
JB
7162 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c \
7163 utf8.c wcwidth.c
95768aa9 7164
95768aa9 7165@@ -73,6 +74,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
7166 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7167 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
e1bffe0b 7168 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
95768aa9 7169+ nntp.h ChangeLog.nntp \
7170 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
e1bffe0b
JB
7171 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
7172 makedoc.c makedoc-defs.h stamp-doc-rc README.SSL smime.h \
7173diff -udprP mutt-1.5.15.orig/Makefile.in mutt-1.5.15/Makefile.in
7174--- mutt-1.5.15.orig/Makefile.in 2007-04-06 23:05:40.000000000 +0300
7175+++ mutt-1.5.15/Makefile.in 2007-04-11 17:25:15.000000000 +0300
7176@@ -330,6 +330,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
7177 smtp.c browser.h mbyte.h remailer.h url.h \
95768aa9 7178 crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
7179 pgppacket.c mutt_idna.h hcache.h hcache.c bcache.c bcache.h mutt_ssl_gnutls.c \
7180+ nntp.c newsrc.c \
e1bffe0b
JB
7181 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c \
7182 utf8.c wcwidth.c
95768aa9 7183
e1bffe0b 7184@@ -341,6 +342,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
95768aa9 7185 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
7186 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
e1bffe0b 7187 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
95768aa9 7188+ nntp.h ChangeLog.nntp \
7189 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
e1bffe0b
JB
7190 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
7191 makedoc.c makedoc-defs.h stamp-doc-rc README.SSL smime.h \
7192@@ -554,6 +556,8 @@ distclean-compile:
95768aa9 7193 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@
7194 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@
7195 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@
7196+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@
7197+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@
7198 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@
7199 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
7200 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@
e1bffe0b
JB
7201diff -udprP mutt-1.5.15.orig/Muttrc mutt-1.5.15/Muttrc
7202--- mutt-1.5.15.orig/Muttrc 2007-04-06 23:34:36.000000000 +0300
7203+++ mutt-1.5.15/Muttrc 2007-04-11 18:20:29.000000000 +0300
7204@@ -263,6 +263,28 @@ attachments -I message/external-body
7205 # if included.
95768aa9 7206 #
7207 #
7208+# set ask_follow_up=no
7209+#
7210+# Name: ask_follow_up
7211+# Type: boolean
7212+# Default: no
7213+#
7214+#
7215+# If set, Mutt will prompt you for follow-up groups before editing
7216+# the body of an outgoing message.
7217+#
7218+#
7219+# set ask_x_comment_to=no
7220+#
7221+# Name: ask_x_comment_to
7222+# Type: boolean
7223+# Default: no
7224+#
7225+#
7226+# If set, Mutt will prompt you for x-comment-to field before editing
7227+# the body of an outgoing message.
7228+#
7229+#
7230 # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
7231 #
7232 # Name: attach_format
e1bffe0b
JB
7233@@ -430,6 +452,17 @@ attachments -I message/external-body
7234 # access time when checking for new mail.
95768aa9 7235 #
7236 #
7237+# set catchup_newsgroup=ask-yes
7238+#
7239+# Name: catchup_newsgroup
7240+# Type: quadoption
7241+# Default: ask-yes
7242+#
7243+#
7244+# If this variable is set, Mutt will mark all articles in newsgroup
7245+# as read when you quit the newsgroup (catchup newsgroup).
7246+#
7247+#
7248 # set charset=""
7249 #
7250 # Name: charset
e1bffe0b 7251@@ -927,6 +960,19 @@ attachments -I message/external-body
95768aa9 7252 # of the same email for you.
7253 #
7254 #
7255+# set followup_to_poster=ask-yes
7256+#
7257+# Name: followup_to_poster
7258+# Type: quadoption
7259+# Default: ask-yes
7260+#
7261+#
7262+# If this variable is set and the keyword "poster" is present in
7263+# Followup-To header, follow-up to newsgroup function is not
7264+# permitted. The message will be mailed to the submitter of the
7265+# message via mail.
7266+#
7267+#
7268 # set force_name=no
7269 #
7270 # Name: force_name
e1bffe0b 7271@@ -1024,6 +1070,28 @@ attachments -I message/external-body
95768aa9 7272 # "Franklin" to "Franklin, Steve".
7273 #
7274 #
7275+# set group_index_format="%4C %M%N %5s %-45.45f %d"
7276+#
7277+# Name: group_index_format
7278+# Type: string
7279+# Default: "%4C %M%N %5s %-45.45f %d"
7280+#
7281+#
7282+# This variable allows you to customize the newsgroup browser display to
7283+# your personal taste. This string is similar to ``index_format'', but
7284+# has its own set of printf()-like sequences:
7285+#
7286+# %C current newsgroup number
7287+# %d description of newsgroup (becomes from server)
7288+# %f newsgroup name
7289+# %M - if newsgroup not allowed for direct post (moderated for example)
7290+# %N N if newsgroup is new, u if unsubscribed, blank otherwise
7291+# %n number of new articles in newsgroup
7292+# %s number of unread articles in newsgroup
7293+# %>X right justify the rest of the string and pad with character "X"
7294+# %|X pad to the end of the line with character "X"
7295+#
7296+#
7297 # set hdrs=yes
7298 #
7299 # Name: hdrs
e1bffe0b 7300@@ -1469,6 +1537,7 @@ attachments -I message/external-body
95768aa9 7301 # %E number of messages in current thread
7302 # %f entire From: line (address + real name)
7303 # %F author name, or recipient name if the message is from you
7304+# %g newsgroup name (if compiled with nntp support)
7305 # %H spam attribute(s) of this message
7306 # %i message-id of the current message
7307 # %l number of lines in the message (does not work with maildir,
e1bffe0b
JB
7308@@ -1482,12 +1551,14 @@ attachments -I message/external-body
7309 # %n author's real name (or address if missing)
7310 # %O (_O_riginal save folder) Where mutt would formerly have
7311 # stashed the message: list name or recipient name if no list
7312+# %R `x-comment-to:' field (if present and compiled with nntp support)
7313 # %s subject of the message
7314 # %S status of the message (N/D/d/!/r/*)
7315 # %t `to:' field (recipients)
95768aa9 7316 # %T the appropriate character from the $to_chars string
7317 # %u user (login) name of the author
7318 # %v first name of the author, or the recipient if the message is from you
7319+# %W name of organization of author (`organization:' field)
7320 # %X number of attachments
7321 # (please see the ``attachments'' section for possible speed effects)
7322 # %y `x-label:' field, if present
e1bffe0b 7323@@ -1513,6 +1584,22 @@ attachments -I message/external-body
95768aa9 7324 # See also: ``$to_chars''.
7325 #
7326 #
7327+# set inews=""
7328+#
7329+# Name: inews
7330+# Type: path
7331+# Default: ""
7332+#
7333+#
7334+# If set, specifies the program and arguments used to deliver news posted
7335+# by Mutt. Otherwise, mutt posts article using current connection to
7336+# news server. The following printf-style sequence is understood:
7337+#
7338+# %s newsserver name
7339+#
7340+# Example: set inews="/usr/local/bin/inews -hS"
7341+#
7342+#
e1bffe0b 7343 # set ispell="ispell"
95768aa9 7344 #
7345 # Name: ispell
e1bffe0b 7346@@ -1856,6 +1943,18 @@ attachments -I message/external-body
95768aa9 7347 # be attached to the newly composed message if this option is set.
7348 #
7349 #
7350+# set mime_subject=yes
7351+#
7352+# Name: mime_subject
7353+# Type: boolean
7354+# Default: yes
7355+#
7356+#
7357+# If unset, 8-bit ``subject:'' line in article header will not be
7358+# encoded according to RFC2047 to base64. This is useful when message
7359+# is Usenet article, because MIME for news is nonstandard feature.
7360+#
7361+#
7362 # set mix_entry_format="%4n %c %-16s %a"
7363 #
7364 # Name: mix_entry_format
e1bffe0b 7365@@ -1948,6 +2047,118 @@ attachments -I message/external-body
95768aa9 7366 # See also ``$read_inc'' and ``$write_inc''.
7367 #
7368 #
7369+# set news_cache_dir="~/.mutt"
7370+#
7371+# Name: news_cache_dir
7372+# Type: path
7373+# Default: "~/.mutt"
7374+#
7375+#
7376+# This variable pointing to directory where Mutt will save cached news
7377+# articles headers in. If unset, headers will not be saved at all
7378+# and will be reloaded each time when you enter to newsgroup.
7379+#
7380+#
7381+# set news_server=""
7382+#
7383+# Name: news_server
7384+# Type: string
7385+# Default: ""
7386+#
7387+#
7388+# This variable specifies domain name or address of NNTP server. It
7389+# defaults to the newsserver specified in the environment variable
7390+# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
7391+# specify username and an alternative port for each newsserver, ie:
7392+#
e1bffe0b 7393+# [news[s]://][username[:password]@]newsserver[:port]
95768aa9 7394+#
7395+#
7396+# set newsrc="~/.newsrc"
7397+#
7398+# Name: newsrc
7399+# Type: path
7400+# Default: "~/.newsrc"
7401+#
7402+#
7403+# The file, containing info about subscribed newsgroups - names and
7404+# indexes of read articles. The following printf-style sequence
7405+# is understood:
7406+#
7407+# %s newsserver name
7408+#
7409+#
7410+# set nntp_context=1000
7411+#
7412+# Name: nntp_context
7413+# Type: number
7414+# Default: 1000
7415+#
7416+#
7417+# This variable defines number of articles which will be in index when
7418+# newsgroup entered. If active newsgroup have more articles than this
7419+# number, oldest articles will be ignored. Also controls how many
7420+# articles headers will be saved in cache when you quit newsgroup.
7421+#
7422+#
7423+# set nntp_load_description=yes
7424+#
7425+# Name: nntp_load_description
7426+# Type: boolean
7427+# Default: yes
7428+#
7429+#
7430+# This variable controls whether or not descriptions for each newsgroup
7431+# must be loaded when newsgroup is added to list (first time list
7432+# loading or new newsgroup adding).
7433+#
7434+#
7435+# set nntp_user=""
7436+#
7437+# Name: nntp_user
7438+# Type: string
7439+# Default: ""
7440+#
7441+#
7442+# Your login name on the NNTP server. If unset and NNTP server requires
7443+# authentification, Mutt will prompt you for your account name when you
7444+# connect to newsserver.
7445+#
7446+#
7447+# set nntp_pass=""
7448+#
7449+# Name: nntp_pass
7450+# Type: string
7451+# Default: ""
7452+#
7453+#
7454+# Your password for NNTP account.
7455+#
7456+#
7457+# set nntp_poll=60
7458+#
7459+# Name: nntp_poll
7460+# Type: number
7461+# Default: 60
7462+#
7463+#
7464+# The time in seconds until any operations on newsgroup except post new
7465+# article will cause recheck for new news. If set to 0, Mutt will
7466+# recheck newsgroup on each operation in index (stepping, read article,
7467+# etc.).
7468+#
7469+#
7470+# set nntp_reconnect=ask-yes
7471+#
7472+# Name: nntp_reconnect
7473+# Type: quadoption
7474+# Default: ask-yes
7475+#
7476+#
7477+# Controls whether or not Mutt will try to reconnect to newsserver when
7478+# connection lost.
7479+#
7480+#
7481 # set pager="builtin"
7482 #
7483 # Name: pager
e1bffe0b 7484@@ -3151,6 +3362,19 @@ attachments -I message/external-body
95768aa9 7485 # string after the inclusion of a message which is being replied to.
7486 #
7487 #
7488+# set post_moderated=ask-yes
7489+#
7490+# Name: post_moderated
7491+# Type: quadoption
7492+# Default: ask-yes
7493+#
7494+#
7495+# If set to yes, Mutt will post article to newsgroup that have
7496+# not permissions to posting (e.g. moderated). Note: if newsserver
7497+# does not support posting to that newsgroup or totally read-only, that
7498+# posting will not have an effect.
7499+#
7500+#
7501 # set postpone=ask-yes
7502 #
7503 # Name: postpone
e1bffe0b 7504@@ -3676,6 +3900,41 @@ attachments -I message/external-body
95768aa9 7505 # shell from /etc/passwd is used.
7506 #
7507 #
7508+# set save_unsubscribed=no
7509+#
7510+# Name: save_unsubscribed
7511+# Type: boolean
7512+# Default: no
7513+#
7514+#
7515+# When set, info about unsubscribed newsgroups will be saved into
7516+# ``newsrc'' file and into cache.
7517+#
7518+#
7519+# set show_new_news=yes
7520+#
7521+# Name: show_new_news
7522+# Type: boolean
7523+# Default: yes
7524+#
7525+#
7526+# If set, newsserver will be asked for new newsgroups on entering
7527+# the browser. Otherwise, it will be done only once for a newsserver.
7528+# Also controls whether or not number of new articles of subscribed
7529+# newsgroups will be then checked.
7530+#
7531+#
7532+# set show_only_unread=no
7533+#
7534+# Name: show_only_unread
7535+# Type: boolean
7536+# Default: no
7537+#
7538+#
7539+# If set, only subscribed newsgroups that contain unread articles
7540+# will be displayed in browser.
7541+#
7542+#
7543 # set sig_dashes=yes
7544 #
7545 # Name: sig_dashes
e1bffe0b
JB
7546@@ -4374,3 +4633,14 @@ attachments -I message/external-body
7547 # in this case.
95768aa9 7548 #
7549 #
7550+# set x_comment_to=no
7551+#
7552+# Name: x_comment_to
7553+# Type: boolean
7554+# Default: no
7555+#
7556+#
7557+# If set, Mutt will add ``X-Comment-To:'' field (that contains full
7558+# name of original article author) to article that followuped to newsgroup.
7559+#
7560+#
e1bffe0b
JB
7561diff -udprP mutt-1.5.15.orig/configure mutt-1.5.15/configure
7562--- mutt-1.5.15.orig/configure 2007-04-06 10:17:16.000000000 +0300
7563+++ mutt-1.5.15/configure 2007-04-11 17:25:15.000000000 +0300
7564@@ -1341,6 +1341,7 @@ Optional Features:
95768aa9 7565 Force use of an external dotlock program
7566 --enable-pop Enable POP3 support
7567 --enable-imap Enable IMAP support
7568+ --enable-nntp Enable NNTP support
e1bffe0b 7569 --enable-smtp include internal SMTP relay support
95768aa9 7570 --enable-debug Enable debugging support
7571 --enable-flock Use flock() to lock files
e1bffe0b 7572@@ -13918,6 +13919,20 @@ fi
95768aa9 7573 fi
7574 done
7575
7576+# Check whether --enable-nntp or --disable-nntp was given.
7577+if test "${enable_nntp+set}" = set; then
7578+ enableval="$enable_nntp"
7579+ if test x$enableval = xyes ; then
7580+ cat >>confdefs.h <<\_ACEOF
7581+#define USE_NNTP 1
7582+_ACEOF
7583+
7584+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
7585+ need_socket="yes"
7586+ fi
7587+
7588+fi;
7589+
7590
7591
7592 for ac_func in strftime
This page took 1.104099 seconds and 4 git commands to generate.