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