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++)