- updated to 1.11.1, enable sidebar support
[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
4adf126f
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
4adf126f
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"
4adf126f 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"
4adf126f 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)"
4adf126f 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"
4adf126f
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
4adf126f
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
4adf126f
JB
537 else if (option (OPTNOCURSES))
538 return -1;
bebcbf73 539 /* prompt (defaults to unix username), copy into account->user */
4adf126f 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
4adf126f
JB
548 else if (option (OPTNOCURSES))
549 return -1;
bebcbf73 550 else
4adf126f
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 */
4adf126f
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_ */
4adf126f
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>
4adf126f
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;
4adf126f 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:
4adf126f 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 {
4adf126f 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
4adf126f 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;
4adf126f 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;
4adf126f 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
4adf126f 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
4adf126f 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 }
4adf126f 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
4adf126f 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);
4adf126f 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);
4adf126f 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);
4adf126f 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);
4adf126f 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)
4adf126f 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
4adf126f
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
4adf126f
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
4adf126f 1206+ || Context->magic == M_NNTP
ce1255c1 1207+#endif
4adf126f 1208 || stat (Context->path, &contex_sb) != 0)
ce1255c1 1209 {
4adf126f
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
4adf126f
JB
1216+ if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1217+ tmp->magic = M_NNTP;
1218+ else
ce1255c1 1219+#endif
4adf126f
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 ||
4adf126f
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
4adf126f
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)
4adf126f
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 {
4adf126f
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>
4adf126f 1341@@ -67,11 +72,17 @@ enum
ce1255c1
JB
1342 HDR_CRYPT,
1343 HDR_CRYPTINFO,
1344
1345+#ifdef USE_NNTP
1346+ HDR_NEWSGROUPS,
1347+ HDR_FOLLOWUPTO,
1348+ HDR_XCOMMENTTO,
1349+#endif
1350+
1351 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1352 };
1353
1354-#define HDR_XOFFSET 10
1355-#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1356+#define HDR_XOFFSET 14
1357+#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
4adf126f 1358 #define W (COLS - HDR_XOFFSET - SidebarWidth)
ce1255c1
JB
1359
1360 static char *Prompts[] =
4adf126f 1361@@ -83,6 +94,16 @@ static char *Prompts[] =
ce1255c1
JB
1362 "Subject: ",
1363 "Reply-To: ",
1364 "Fcc: "
1365+#ifdef USE_NNTP
1366+#ifdef MIXMASTER
1367+ ,""
1368+#endif
1369+ ,""
1370+ ,""
1371+ ,"Newsgroups: "
1372+ ,"Followup-To: "
1373+ ,"X-Comment-To: "
1374+#endif
1375 };
1376
1377 static struct mapping_t ComposeHelp[] = {
4adf126f
JB
1378@@ -97,6 +118,19 @@ static struct mapping_t ComposeHelp[] =
1379 { NULL, 0 }
ce1255c1
JB
1380 };
1381
1382+#ifdef USE_NNTP
1383+static struct mapping_t ComposeNewsHelp[] = {
1384+ { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1385+ { N_("Abort"), OP_EXIT },
1386+ { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1387+ { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1388+ { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1389+ { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1390+ { N_("Help"), OP_HELP },
1391+ { NULL }
1392+};
1393+#endif
1394+
1395 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1396 {
1397 mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt,
4adf126f
JB
1398@@ -112,7 +146,7 @@ static void redraw_crypt_lines (HEADER *
1399 {
1400 int off = 0;
1401
1402- mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
1403+ mvprintw (HDR_CRYPT, SidebarWidth, TITLE_FMT, "Security: ");
1404
1405 if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
1406 {
1407@@ -148,12 +182,15 @@ static void redraw_crypt_lines (HEADER *
1408 clrtoeol ();
1409
1410 if ((WithCrypto & APPLICATION_PGP)
1411- && msg->security & APPLICATION_PGP && msg->security & SIGN)
1412- printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>"));
1413+ && msg->security & APPLICATION_PGP && msg->security & SIGN) {
1414+ printw (TITLE_FMT, _(" sign as: "));
1415+ printw ("%s", PgpSignAs ? PgpSignAs : _("<default>"));
1416+ }
1417
1418 if ((WithCrypto & APPLICATION_SMIME)
1419 && msg->security & APPLICATION_SMIME && msg->security & SIGN) {
1420- printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
1421+ printw (TITLE_FMT, _(" sign as: "));
1422+ printw ("%s", SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
ce1255c1 1423 }
ce1255c1 1424
4adf126f
JB
1425 if ((WithCrypto & APPLICATION_SMIME)
1426@@ -175,7 +212,7 @@ static void redraw_mix_line (LIST *chain
1427 int c;
1428 char *t;
1429
1430- mvaddstr (HDR_MIX, SidebarWidth, " Mix: ");
1431+ mvprintw (HDR_MIX, SidebarWidth, TITLE_FMT, "Mix: ");
1432
1433 if (!chain)
1434 {
1435@@ -249,9 +286,28 @@ static void draw_envelope_addr (int line
ce1255c1
JB
1436 static void draw_envelope (HEADER *msg, char *fcc)
1437 {
1438 draw_envelope_addr (HDR_FROM, msg->env->from);
1439+#ifdef USE_NNTP
1440+ if (!option (OPTNEWSSEND))
1441+ {
1442+#endif
1443 draw_envelope_addr (HDR_TO, msg->env->to);
1444 draw_envelope_addr (HDR_CC, msg->env->cc);
1445 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1446+#ifdef USE_NNTP
1447+ }
1448+ else
1449+ {
4adf126f 1450+ mvprintw (HDR_TO, SidebarWidth, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
ce1255c1 1451+ mutt_paddstr (W, NONULL (msg->env->newsgroups));
4adf126f 1452+ mvprintw (HDR_CC, SidebarWidth, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
ce1255c1
JB
1453+ mutt_paddstr (W, NONULL (msg->env->followup_to));
1454+ if (option (OPTXCOMMENTTO))
1455+ {
4adf126f 1456+ mvprintw (HDR_BCC, SidebarWidth, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
ce1255c1
JB
1457+ mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1458+ }
1459+ }
1460+#endif
4adf126f 1461 mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
ce1255c1
JB
1462 mutt_paddstr (W, NONULL (msg->env->subject));
1463 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
4adf126f 1464@@ -504,6 +560,12 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1465 /* Sort, SortAux could be changed in mutt_index_menu() */
1466 int oldSort, oldSortAux;
1467 struct stat st;
1468+#ifdef USE_NNTP
1469+ int news = 0; /* is it a news article ? */
1470+
1471+ if (option (OPTNEWSSEND))
1472+ news++;
1473+#endif
1474
1475 mutt_attach_init (msg->content);
1476 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
4adf126f 1477@@ -514,10 +576,18 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1478 menu->make_entry = snd_entry;
1479 menu->tag = mutt_tag_attach;
1480 menu->data = idx;
1481+#ifdef USE_NNTP
1482+ if (news)
1483+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1484+ else
1485+#endif
1486 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1487
1488 while (loop)
1489 {
1490+#ifdef USE_NNTP
1491+ unset_option (OPTNEWS); /* for any case */
1492+#endif
1493 switch (op = mutt_menuLoop (menu))
1494 {
1495 case OP_REDRAW:
4adf126f 1496@@ -530,17 +600,87 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1497 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1498 break;
1499 case OP_COMPOSE_EDIT_TO:
1500+#ifdef USE_NNTP
1501+ if (news)
1502+ break;
1503+#endif
1504 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1505 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1506 break;
1507 case OP_COMPOSE_EDIT_BCC:
1508+#ifdef USE_NNTP
1509+ if (news)
1510+ break;
1511+#endif
1512 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1513 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1514 break;
1515 case OP_COMPOSE_EDIT_CC:
1516+#ifdef USE_NNTP
1517+ if (news)
1518+ break;
1519+#endif
1520 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1521 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1522 break;
1523+#ifdef USE_NNTP
1524+ case OP_COMPOSE_EDIT_NEWSGROUPS:
1525+ if (news)
1526+ {
1527+ if (msg->env->newsgroups)
1528+ strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1529+ else
1530+ buf[0] = 0;
1531+ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1532+ {
1533+ FREE (&msg->env->newsgroups);
1534+ mutt_remove_trailing_ws (buf);
1535+ msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1536+ move (HDR_TO, HDR_XOFFSET);
1537+ clrtoeol ();
1538+ if (msg->env->newsgroups)
1539+ printw ("%-*.*s", W, W, msg->env->newsgroups);
1540+ }
1541+ }
1542+ break;
1543+
1544+ case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1545+ if (news)
1546+ {
1547+ buf[0] = 0;
1548+ if (msg->env->followup_to)
1549+ strfcpy (buf, msg->env->followup_to, sizeof (buf));
1550+ if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1551+ {
1552+ FREE (&msg->env->followup_to);
1553+ mutt_remove_trailing_ws (buf);
1554+ msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1555+ move (HDR_CC, HDR_XOFFSET);
1556+ clrtoeol();
1557+ if (msg->env->followup_to)
1558+ printw ("%-*.*s", W, W, msg->env->followup_to);
1559+ }
1560+ }
1561+ break;
1562+
1563+ case OP_COMPOSE_EDIT_X_COMMENT_TO:
1564+ if (news && option (OPTXCOMMENTTO))
1565+ {
1566+ buf[0] = 0;
1567+ if (msg->env->x_comment_to)
1568+ strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1569+ if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1570+ {
1571+ FREE (&msg->env->x_comment_to);
1572+ msg->env->x_comment_to = safe_strdup (buf);
1573+ move (HDR_BCC, HDR_XOFFSET);
1574+ clrtoeol();
1575+ if (msg->env->x_comment_to)
1576+ printw ("%-*.*s", W, W, msg->env->x_comment_to);
1577+ }
1578+ }
1579+ break;
1580+#endif
1581 case OP_COMPOSE_EDIT_SUBJECT:
1582 if (msg->env->subject)
1583 strfcpy (buf, msg->env->subject, sizeof (buf));
4adf126f 1584@@ -703,6 +843,9 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1585 break;
1586
1587 case OP_COMPOSE_ATTACH_MESSAGE:
1588+#ifdef USE_NNTP
1589+ case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1590+#endif
1591 {
1592 char *prompt;
1593 HEADER *h;
4adf126f 1594@@ -710,7 +853,22 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1595 fname[0] = 0;
1596 prompt = _("Open mailbox to attach message from");
1597
1598+#ifdef USE_NNTP
1599+ unset_option (OPTNEWS);
1600+ if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1601+ {
1602+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1603+ break;
1604+
1605+ prompt = _("Open newsgroup to attach message from");
1606+ set_option (OPTNEWS);
1607+ }
1608+#endif
1609+
1610 if (Context)
1611+#ifdef USE_NNTP
1612+ if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1613+#endif
1614 {
1615 strfcpy (fname, NONULL (Context->path), sizeof (fname));
bebcbf73 1616 mutt_pretty_mailbox (fname, sizeof (fname));
4adf126f 1617@@ -719,6 +877,11 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1618 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1619 break;
1620
1621+#ifdef USE_NNTP
1622+ if (option (OPTNEWS))
1623+ nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1624+ else
1625+#endif
1626 mutt_expand_path (fname, sizeof (fname));
1627 #ifdef USE_IMAP
1628 if (!mx_is_imap (fname))
4adf126f 1629@@ -726,6 +889,9 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1630 #ifdef USE_POP
1631 if (!mx_is_pop (fname))
1632 #endif
1633+#ifdef USE_NNTP
1634+ if (!mx_is_nntp (fname) && !option (OPTNEWS))
1635+#endif
1636 /* check to make sure the file exists and is readable */
1637 if (access (fname, R_OK) == -1)
1638 {
4adf126f
JB
1639diff -udprP mutt-1.5.21.orig/config.h.in mutt-1.5.21/config.h.in
1640--- mutt-1.5.21.orig/config.h.in 2010-08-25 19:32:03.000000000 +0300
1641+++ mutt-1.5.21/config.h.in 2010-09-16 13:14:39.000000000 +0300
1642@@ -37,6 +37,9 @@
ce1255c1
JB
1643 significant more memory when defined. */
1644 #undef EXACT_ADDRESS
1645
1646+/* Compiling with newsreading support with NNTP */
1647+#undef USE_NNTP
1648+
1649 /* program to use for shell commands */
1650 #undef EXECSHELL
1651
4adf126f
JB
1652diff -udprP mutt-1.5.21.orig/configure.ac mutt-1.5.21/configure.ac
1653--- mutt-1.5.21.orig/configure.ac 2010-08-24 19:34:21.000000000 +0300
1654+++ mutt-1.5.21/configure.ac 2010-09-16 13:14:39.000000000 +0300
1655@@ -602,6 +602,14 @@ if test x"$need_imap" = xyes -o x"$need_
ce1255c1
JB
1656 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1657 fi
1658
1659+AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1660+[ if test x$enableval = xyes ; then
1661+ AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1662+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1663+ need_socket="yes"
1664+ fi
1665+])
1666+
1667 dnl -- end socket dependencies --
1668
1669 if test "$need_socket" = "yes"
4adf126f
JB
1670diff -udprP mutt-1.5.21.orig/curs_main.c mutt-1.5.21/curs_main.c
1671--- mutt-1.5.21.orig/curs_main.c 2010-09-13 20:19:55.000000000 +0300
1672+++ mutt-1.5.21/curs_main.c 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
1673@@ -22,6 +22,7 @@
1674
1675 #include "mutt.h"
1676 #include "mutt_curses.h"
1677+#include "mx.h"
1678 #include "mutt_menu.h"
ce1255c1 1679 #include "mailbox.h"
bebcbf73
AG
1680 #include "mapping.h"
1681@@ -38,6 +39,10 @@
ce1255c1
JB
1682
1683 #include "mutt_crypt.h"
1684
1685+#ifdef USE_NNTP
1686+#include "nntp.h"
1687+#endif
1688+
1689
1690 #include <ctype.h>
1691 #include <stdlib.h>
bebcbf73 1692@@ -413,12 +418,27 @@ static struct mapping_t IndexHelp[] = {
4adf126f 1693 { NULL, 0 }
ce1255c1
JB
1694 };
1695
1696+#ifdef USE_NNTP
1697+struct mapping_t IndexNewsHelp[] = {
1698+ { N_("Quit"), OP_QUIT },
1699+ { N_("Del"), OP_DELETE },
1700+ { N_("Undel"), OP_UNDELETE },
1701+ { N_("Save"), OP_SAVE },
1702+ { N_("Post"), OP_POST },
1703+ { N_("Followup"), OP_FOLLOWUP },
1704+ { N_("Catchup"), OP_CATCHUP },
1705+ { N_("Help"), OP_HELP },
1706+ { NULL }
1707+};
1708+#endif
1709+
1710 /* This function handles the message index window as well as commands returned
1711 * from the pager (MENU_PAGER).
1712 */
1713 int mutt_index_menu (void)
1714 {
1715 char buf[LONG_STRING], helpstr[LONG_STRING];
1716+ int flags;
1717 int op = OP_NULL;
1718 int done = 0; /* controls when to exit the "event" loop */
1719 int i = 0, j;
bebcbf73 1720@@ -439,7 +459,11 @@ int mutt_index_menu (void)
ce1255c1
JB
1721 menu->make_entry = index_make_entry;
1722 menu->color = index_color;
1723 menu->current = ci_first_message ();
1724- menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1725+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1726+#ifdef USE_NNTP
1727+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1728+#endif
1729+ IndexHelp);
4adf126f
JB
1730
1731 if (!attach_msg)
ce1255c1 1732 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
4adf126f
JB
1733@@ -682,6 +706,9 @@ int mutt_index_menu (void)
1734 mutt_curs_set (1); /* fallback from the pager */
1735 }
ce1255c1
JB
1736
1737+#ifdef USE_NNTP
1738+ unset_option (OPTNEWS); /* for any case */
1739+#endif
1740 switch (op)
1741 {
1742
4adf126f 1743@@ -732,6 +759,120 @@ int mutt_index_menu (void)
ce1255c1
JB
1744 menu_current_bottom (menu);
1745 break;
1746
1747+#ifdef USE_NNTP
1748+ case OP_GET_MESSAGE:
1749+ case OP_GET_PARENT:
1750+ CHECK_MSGCOUNT;
1751+ if (Context->magic == M_NNTP)
1752+ {
1753+ HEADER *h;
1754+
1755+ if (op == OP_GET_MESSAGE)
1756+ {
1757+ buf[0] = 0;
1758+ if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1759+ || !buf[0])
1760+ break;
1761+ }
1762+ else
1763+ {
1764+ LIST *ref = CURHDR->env->references;
1765+ if (!ref)
1766+ {
1767+ mutt_error _("Article has no parent reference!");
1768+ break;
1769+ }
1770+ strfcpy (buf, ref->data, sizeof (buf));
1771+ }
1772+ if (!Context->id_hash)
1773+ Context->id_hash = mutt_make_id_hash (Context);
1774+ if ((h = hash_find (Context->id_hash, buf)))
1775+ {
1776+ if (h->virtual != -1)
1777+ {
1778+ menu->current = h->virtual;
1779+ menu->redraw = REDRAW_MOTION_RESYNCH;
1780+ }
1781+ else if (h->collapsed)
1782+ {
1783+ mutt_uncollapse_thread (Context, h);
1784+ mutt_set_virtual (Context);
1785+ menu->current = h->virtual;
1786+ menu->redraw = REDRAW_MOTION_RESYNCH;
1787+ }
1788+ else
1789+ mutt_error _("Message not visible in limited view.");
1790+ }
1791+ else
1792+ {
1793+ if (nntp_check_msgid (Context, buf) == 0)
1794+ {
1795+ h = Context->hdrs[Context->msgcount-1];
1796+ mutt_sort_headers (Context, 0);
1797+ menu->current = h->virtual;
1798+ menu->redraw = REDRAW_FULL;
1799+ }
1800+ else
1801+ mutt_error (_("Article %s not found on server"), buf);
1802+ }
1803+ }
1804+ break;
1805+
1806+ case OP_GET_CHILDREN:
1807+ case OP_RECONSTRUCT_THREAD:
1808+ CHECK_MSGCOUNT;
1809+ if (Context->magic == M_NNTP)
1810+ {
1811+ HEADER *h;
1812+ int old = CURHDR->index, i;
1813+
1814+ if (!CURHDR->env->message_id)
1815+ {
1816+ mutt_error _("No Message-Id. Unable to perform operation");
1817+ break;
1818+ }
1819+
1820+ if (!Context->id_hash)
1821+ Context->id_hash = mutt_make_id_hash (Context);
1822+ strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1823+
1824+ if (op == OP_RECONSTRUCT_THREAD)
1825+ {
1826+ LIST *ref = CURHDR->env->references;
1827+ while (ref)
1828+ {
1829+ nntp_check_msgid (Context, ref->data);
1830+ /* the last msgid in References is the root message */
1831+ if (!ref->next)
1832+ strfcpy (buf, ref->data, sizeof (buf));
1833+ ref = ref->next;
1834+ }
1835+ }
1836+ mutt_message _("Check for children of message...");
1837+ if (nntp_check_children (Context, buf) == 0)
1838+ {
1839+ mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1840+ h = hash_find (Context->id_hash, buf);
1841+ /* if the root message was retrieved, move to it */
1842+ if (h)
1843+ menu->current = h->virtual;
1844+ else /* try to restore old position */
1845+ for (i = 0; i < Context->msgcount; i++)
1846+ if (Context->hdrs[i]->index == old)
1847+ {
1848+ menu->current = Context->hdrs[i]->virtual;
1849+ /* As an added courtesy, recenter the menu
1850+ * with the current entry at the middle of the screen */
1851+ menu_check_recenter (menu);
1852+ menu_current_middle (menu);
1853+ }
1854+ }
1855+ menu->redraw = REDRAW_FULL;
1856+ mutt_clear_error ();
1857+ }
1858+ break;
1859+#endif
1860+
1861 case OP_JUMP:
1862
1863 CHECK_MSGCOUNT;
4adf126f 1864@@ -828,11 +969,33 @@ int mutt_index_menu (void)
ce1255c1
JB
1865 break;
1866
1867 case OP_MAIN_LIMIT:
1868+ case OP_TOGGLE_READ:
1869
1870 CHECK_IN_MAILBOX;
1871 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1872 CURHDR->index : -1;
1873- if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1874+ if (op == OP_TOGGLE_READ)
1875+ {
1876+ char buf[LONG_STRING];
1877+
1878+ if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1879+ {
1880+ snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1881+ Context->pattern ? Context->pattern : ".*");
1882+ set_option (OPTHIDEREAD);
1883+ }
1884+ else
1885+ {
1886+ strfcpy (buf, Context->pattern + 8, sizeof(buf));
1887+ if (!*buf || strncmp (buf, ".*", 2) == 0)
1888+ snprintf (buf, sizeof(buf), "~A");
1889+ unset_option (OPTHIDEREAD);
1890+ }
1891+ FREE (&Context->pattern);
1892+ Context->pattern = safe_strdup (buf);
1893+ }
1894+ if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1895+ mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1896 {
1897 if (menu->oldcurrent >= 0)
1898 {
4adf126f 1899@@ -1071,15 +1234,22 @@ int mutt_index_menu (void)
ce1255c1
JB
1900
1901 case OP_MAIN_CHANGE_FOLDER:
1902 case OP_MAIN_NEXT_UNREAD_MAILBOX:
4adf126f 1903-
ce1255c1
JB
1904- if (attach_msg)
1905- op = OP_MAIN_CHANGE_FOLDER_READONLY;
1906-
1907- /* fallback to the readonly case */
1908-
1909 case OP_MAIN_CHANGE_FOLDER_READONLY:
1910+#ifdef USE_NNTP
1911+ case OP_MAIN_CHANGE_GROUP:
1912+ case OP_MAIN_CHANGE_GROUP_READONLY:
1913+ unset_option (OPTNEWS);
1914+#endif
1915+ if (attach_msg || option (OPTREADONLY) ||
1916+#ifdef USE_NNTP
1917+ op == OP_MAIN_CHANGE_GROUP_READONLY ||
1918+#endif
1919+ op == OP_MAIN_CHANGE_FOLDER_READONLY)
1920+ flags = M_READONLY;
1921+ else
1922+ flags = 0;
1923
1924- if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1925+ if (flags)
1926 cp = _("Open mailbox in read-only mode");
1927 else
1928 cp = _("Open mailbox");
4adf126f 1929@@ -1098,6 +1268,21 @@ int mutt_index_menu (void)
ce1255c1
JB
1930 }
1931 else
1932 {
1933+#ifdef USE_NNTP
1934+ if (op == OP_MAIN_CHANGE_GROUP ||
1935+ op == OP_MAIN_CHANGE_GROUP_READONLY)
1936+ {
1937+ set_option (OPTNEWS);
1938+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1939+ break;
1940+ if (flags)
1941+ cp = _("Open newsgroup in read-only mode");
1942+ else
1943+ cp = _("Open newsgroup");
1944+ nntp_buffy (buf);
1945+ }
1946+ else
1947+#endif
1948 mutt_buffy (buf, sizeof (buf));
1949
1950 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
4adf126f 1951@@ -1117,6 +1302,14 @@ int mutt_index_menu (void)
ce1255c1
JB
1952 }
1953 }
1954
1955+#ifdef USE_NNTP
1956+ if (option (OPTNEWS))
1957+ {
1958+ unset_option (OPTNEWS);
1959+ nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1960+ }
1961+ else
1962+#endif
1963 mutt_expand_path (buf, sizeof (buf));
1964 if (mx_get_magic (buf) <= 0)
1965 {
4adf126f 1966@@ -1158,15 +1351,18 @@ int mutt_index_menu (void)
ce1255c1
JB
1967 CurrentMenu = MENU_MAIN;
1968 mutt_folder_hook (buf);
1969
4adf126f 1970- if ((Context = mx_open_mailbox (buf,
ce1255c1
JB
1971- (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1972- M_READONLY : 0, NULL)) != NULL)
1973+ if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1974 {
1975 menu->current = ci_first_message ();
1976 }
1977 else
1978 menu->current = 0;
1979
1980+#ifdef USE_NNTP
1981+ /* mutt_buffy_check() must be done with mail-reader mode! */
1982+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1983+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1984+#endif
1985 mutt_clear_error ();
1986 mutt_buffy_check(1); /* force the buffy check after we have changed
1987 the folder */
4adf126f 1988@@ -1539,6 +1735,15 @@ int mutt_index_menu (void)
ce1255c1
JB
1989 CHECK_READONLY;
1990 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1991
1992+#ifdef USE_NNTP
1993+ if (Context->magic == M_NNTP)
1994+ {
1995+ mutt_flushinp ();
1996+ mutt_error _("Can't change 'important' flag on NNTP server.");
1997+ break;
1998+ }
1999+#endif
2000+
2001 if (tag)
2002 {
2003 for (j = 0; j < Context->vcount; j++)
4adf126f 2004@@ -1886,6 +2091,17 @@ int mutt_index_menu (void)
ce1255c1
JB
2005 }
2006 break;
2007
2008+#ifdef USE_NNTP
2009+ case OP_CATCHUP:
2010+ if (Context && Context->magic == M_NNTP)
2011+ {
2012+ if (mutt_newsgroup_catchup (CurrentNewsSrv,
2013+ ((NNTP_DATA *)Context->data)->group))
2014+ menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2015+ }
2016+ break;
2017+#endif
2018+
2019 case OP_DISPLAY_ADDRESS:
2020
2021 CHECK_MSGCOUNT;
4adf126f 2022@@ -2013,6 +2229,15 @@ int mutt_index_menu (void)
ce1255c1
JB
2023 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2024 }
2025 #endif
2026+
2027+#ifdef USE_NNTP
2028+ if (Context->magic == M_NNTP)
2029+ {
2030+ mutt_flushinp ();
2031+ mutt_error _("Can't edit message on newsserver.");
2032+ break;
2033+ }
2034+#endif
2035
2036 MAYBE_REDRAW (menu->redraw);
2037 break;
4adf126f 2038@@ -2090,6 +2315,41 @@ int mutt_index_menu (void)
ce1255c1
JB
2039 menu->redraw = REDRAW_FULL;
2040 break;
4adf126f 2041
ce1255c1 2042+#ifdef USE_NNTP
ce1255c1
JB
2043+ case OP_FOLLOWUP:
2044+ case OP_FORWARD_TO_GROUP:
2045+
bebcbf73
AG
2046+ CHECK_MSGCOUNT;
2047+ CHECK_VISIBLE;
2048+
2049+ case OP_POST:
2050+
ce1255c1
JB
2051+ CHECK_ATTACH;
2052+ if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2053+ mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2054+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2055+ {
2056+ if (Context && Context->magic == M_NNTP &&
2057+ !((NNTP_DATA *)Context->data)->allowed &&
2058+ query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2059+ break;
2060+ if (op == OP_POST)
2061+ ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2062+ else
2063+ {
2064+ CHECK_MSGCOUNT;
2065+ if (op == OP_FOLLOWUP)
2066+ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2067+ tag ? NULL : CURHDR);
2068+ else
2069+ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2070+ tag ? NULL : CURHDR);
2071+ }
2072+ menu->redraw = REDRAW_FULL;
2073+ break;
2074+ }
2075+#endif
4adf126f 2076+
ce1255c1
JB
2077 case OP_REPLY:
2078
4adf126f
JB
2079 CHECK_ATTACH;
2080@@ -2165,6 +2425,12 @@ int mutt_index_menu (void)
ce1255c1
JB
2081 CHECK_READONLY;
2082 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2083
2084+#ifdef USE_NNTP
2085+ /* Close all open NNTP connections */
2086+ if (!attach_msg)
2087+ nntp_logout_all ();
2088+#endif
2089+
2090 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2091 op == OP_UNDELETE_THREAD ? 0 : 1);
2092
4adf126f
JB
2093diff -udprP mutt-1.5.21.orig/doc/manual.xml.head mutt-1.5.21/doc/manual.xml.head
2094--- mutt-1.5.21.orig/doc/manual.xml.head 2010-08-24 19:34:21.000000000 +0300
2095+++ mutt-1.5.21/doc/manual.xml.head 2010-09-16 13:14:39.000000000 +0300
2096@@ -1611,6 +1611,22 @@ fo-table</literal> for details.
ce1255c1
JB
2097
2098 </sect2>
2099
2100+<sect2>
2101+<title>Reading news via NNTP</title>
2102+
2103+<para>
2104+If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2105+read news from newsserver via NNTP. You can open a newsgroup with
2106+function ``change-newsgroup'' (default: ``i''). Default newsserver
2107+can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2108+variable. Like other news readers, info about subscribed newsgroups
2109+is saved in file by <link linkend="newsrc">&dollar;newsrc</link>
2110+variable. Article headers are cached and can be loaded from file when
2111+newsgroup entered instead loading from newsserver.
2112+</para>
2113+
2114+</sect2>
2115+
2116 </sect1>
2117
2118 <sect1 id="forwarding-mail">
4adf126f
JB
2119diff -udprP mutt-1.5.21.orig/doc/mutt.man mutt-1.5.21/doc/mutt.man
2120--- mutt-1.5.21.orig/doc/mutt.man 2010-08-24 19:34:21.000000000 +0300
2121+++ mutt-1.5.21/doc/mutt.man 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
2122@@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2123 .SH SYNOPSIS
2124 .PP
2125 .B mutt
4adf126f
JB
2126-[\-nRyzZ]
2127-[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2128+[\-GnRyzZ]
2129+[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-g \fIserver\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
ce1255c1
JB
2130 .PP
2131 .B mutt
4adf126f 2132 [\-nx]
bebcbf73 2133@@ -101,6 +101,10 @@ files.
ce1255c1
JB
2134 Specify which mailbox to load.
2135 .IP "-F \fImuttrc\fP"
2136 Specify an initialization file to read instead of ~/.muttrc
2137+.IP "-g \fIserver\fP"
2138+Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2139+.IP "-G"
2140+Start Mutt with a listing of subscribed newsgroups.
2141 .IP "-h"
2142 Display help.
2143 .IP "-H \fIdraft\fP"
4adf126f
JB
2144diff -udprP mutt-1.5.21.orig/functions.h mutt-1.5.21/functions.h
2145--- mutt-1.5.21.orig/functions.h 2010-08-24 19:34:21.000000000 +0300
2146+++ mutt-1.5.21/functions.h 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
2147@@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in
2148 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2149 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2150 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2151+#ifdef USE_NNTP
4adf126f 2152+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "I" },
ce1255c1
JB
2153+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2154+#endif
2155 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2156 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2157 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
bebcbf73
AG
2158@@ -101,7 +105,15 @@ struct binding_t OpMain[] = { /* map: in
2159 { "edit", OP_EDIT_MESSAGE, "e" },
ce1255c1
JB
2160 { "edit-type", OP_EDIT_TYPE, "\005" },
2161 { "forward-message", OP_FORWARD_MESSAGE, "f" },
4adf126f 2162 { "flag-message", OP_FLAG_MESSAGE, "F" },
ce1255c1
JB
2163+#ifdef USE_NNTP
2164+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
4adf126f 2165+ { "followup-message", OP_FOLLOWUP, "\033f" },
ce1255c1
JB
2166+ { "get-children", OP_GET_CHILDREN, NULL },
2167+ { "get-message", OP_GET_MESSAGE, "\007" },
2168+ { "get-parent", OP_GET_PARENT, "\033G" },
2169+ { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2170+#endif
ce1255c1
JB
2171 { "group-reply", OP_GROUP_REPLY, "g" },
2172 #ifdef USE_POP
2173 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
4adf126f 2174@@ -128,6 +140,9 @@ struct binding_t OpMain[] = { /* map: in
ce1255c1
JB
2175 { "sort-mailbox", OP_SORT, "o" },
2176 { "sort-reverse", OP_SORT_REVERSE, "O" },
2177 { "print-message", OP_PRINT, "p" },
2178+#ifdef USE_NNTP
4adf126f 2179+ { "post-message", OP_POST, "\033m" },
ce1255c1
JB
2180+#endif
2181 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2182 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2183 { "recall-message", OP_RECALL_MESSAGE, "R" },
4adf126f 2184@@ -147,6 +162,10 @@ struct binding_t OpMain[] = { /* map: in
ce1255c1
JB
2185 { "show-version", OP_VERSION, "V" },
2186 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2187 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2188+ { "toggle-read", OP_TOGGLE_READ, "X" },
2189+#ifdef USE_NNTP
2190+ { "catchup", OP_CATCHUP, "y" },
2191+#endif
2192 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2193 { "buffy-list", OP_BUFFY_LIST, "." },
2194 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
4adf126f 2195@@ -178,6 +197,10 @@ struct binding_t OpPager[] = { /* map: p
ce1255c1
JB
2196 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2197 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2198 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2199+#ifdef USE_NNTP
bebcbf73 2200+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
ce1255c1
JB
2201+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2202+#endif
2203 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2204 { "copy-message", OP_COPY_MESSAGE, "C" },
2205 { "decode-copy", OP_DECODE_COPY, "\033C" },
4adf126f
JB
2206@@ -188,8 +211,12 @@ struct binding_t OpPager[] = { /* map: p
2207 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
ce1255c1
JB
2208 { "edit", OP_EDIT_MESSAGE, "e" },
2209 { "edit-type", OP_EDIT_TYPE, "\005" },
2210+#ifdef USE_NNTP
4adf126f 2211+ { "followup-message", OP_FOLLOWUP, "\033f" },
ce1255c1
JB
2212+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2213+#endif
2214 { "forward-message", OP_FORWARD_MESSAGE, "f" },
4adf126f 2215 { "flag-message", OP_FLAG_MESSAGE, "F" },
ce1255c1 2216 { "group-reply", OP_GROUP_REPLY, "g" },
bebcbf73
AG
2217 #ifdef USE_IMAP
2218 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
4adf126f
JB
2219@@ -211,6 +238,9 @@ struct binding_t OpPager[] = { /* map: p
2220 { "sort-mailbox", OP_SORT, "o" },
2221 { "sort-reverse", OP_SORT_REVERSE, "O" },
ce1255c1
JB
2222 { "print-message", OP_PRINT, "p" },
2223+#ifdef USE_NNTP
4adf126f 2224+ { "post-message", OP_POST, "\033m" },
ce1255c1
JB
2225+#endif
2226 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2227 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2228 { "quit", OP_QUIT, "Q" },
4adf126f 2229@@ -279,6 +309,10 @@ struct binding_t OpAttach[] = { /* map:
ce1255c1
JB
2230 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2231 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2232 { "edit-type", OP_EDIT_TYPE, "\005" },
2233+#ifdef USE_NNTP
4adf126f 2234+ { "followup-message", OP_FOLLOWUP, "\033f" },
ce1255c1
JB
2235+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2236+#endif
2237 { "print-entry", OP_PRINT, "p" },
2238 { "save-entry", OP_SAVE, "s" },
2239 { "pipe-entry", OP_PIPE, "|" },
4adf126f 2240@@ -304,6 +338,7 @@ struct binding_t OpAttach[] = { /* map:
ce1255c1
JB
2241 struct binding_t OpCompose[] = { /* map: compose */
2242 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2243 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2244+ { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2245 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2246 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2247 { "copy-file", OP_SAVE, "C" },
4adf126f 2248@@ -323,6 +358,11 @@ struct binding_t OpCompose[] = { /* map:
ce1255c1
JB
2249 { "print-entry", OP_PRINT, "l" },
2250 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2251 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2252+#ifdef USE_NNTP
2253+ { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2254+ { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2255+ { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2256+#endif
2257 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2258 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2259 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
4adf126f 2260@@ -374,14 +414,25 @@ struct binding_t OpBrowser[] = { /* map:
ce1255c1
JB
2261 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2262 { "check-new", OP_CHECK_NEW, NULL },
2263 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2264+#ifdef USE_NNTP
2265+ { "reload-active", OP_LOAD_ACTIVE, "g" },
2266+ { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2267+ { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2268+ { "catchup", OP_CATCHUP, "y" },
2269+ { "uncatchup", OP_UNCATCHUP, "Y" },
2270+#endif
2271 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2272 { "buffy-list", OP_BUFFY_LIST, "." },
2273 #ifdef USE_IMAP
2274 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2275 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2276 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2277+#endif
2278+#if defined USE_IMAP || defined USE_NNTP
2279 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2280 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2281+#endif
2282+#ifdef USE_IMAP
2283 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2284 #endif
2285 { NULL, 0, NULL }
4adf126f
JB
2286diff -udprP mutt-1.5.21.orig/globals.h mutt-1.5.21/globals.h
2287--- mutt-1.5.21.orig/globals.h 2009-08-25 22:08:52.000000000 +0300
2288+++ mutt-1.5.21/globals.h 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
2289@@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
2290 #endif
2291
2292 WHERE char *Muttrc INITVAL (NULL);
2293+#ifdef USE_NNTP
2294+WHERE char *NewsCacheDir;
2295+WHERE char *GroupFormat;
2296+WHERE char *Inews;
2297+WHERE char *NewsServer;
2298+WHERE char *NntpUser;
2299+WHERE char *NntpPass;
2300+WHERE char *NewsRc;
2301+#endif
2302 WHERE char *Outbox;
2303 WHERE char *Pager;
2304 WHERE char *PagerFmt;
4adf126f 2305@@ -188,6 +197,11 @@ extern unsigned char QuadOptions[];
ce1255c1
JB
2306
2307 WHERE unsigned short Counter INITVAL (0);
2308
2309+#ifdef USE_NNTP
2310+WHERE short NewsPollTimeout;
2311+WHERE short NntpContext;
2312+#endif
2313+
2314 WHERE short ConnectTimeout;
2315 WHERE short HistSize;
2316 WHERE short MenuContext;
4adf126f
JB
2317diff -udprP mutt-1.5.21.orig/hash.c mutt-1.5.21/hash.c
2318--- mutt-1.5.21.orig/hash.c 2009-03-19 21:41:18.000000000 +0200
2319+++ mutt-1.5.21/hash.c 2010-09-16 13:14:39.000000000 +0300
2320@@ -57,6 +57,7 @@ HASH *hash_create (int nelem, int lower)
ce1255c1
JB
2321 if (nelem == 0)
2322 nelem = 2;
2323 table->nelem = nelem;
2324+ table->curnelem = 0;
2325 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
4adf126f
JB
2326 if (lower)
2327 {
2328@@ -71,6 +72,29 @@ HASH *hash_create (int nelem, int lower)
ce1255c1
JB
2329 return table;
2330 }
2331
4adf126f 2332+HASH *hash_resize (HASH *ptr, int nelem, int lower)
ce1255c1
JB
2333+{
2334+ HASH *table;
2335+ struct hash_elem *elem, *tmp;
2336+ int i;
2337+
4adf126f 2338+ table = hash_create (nelem, lower);
ce1255c1
JB
2339+
2340+ for (i = 0; i < ptr->nelem; i++)
2341+ {
2342+ for (elem = ptr->table[i]; elem; )
2343+ {
2344+ tmp = elem;
2345+ elem = elem->next;
2346+ hash_insert (table, tmp->key, tmp->data, 1);
2347+ FREE (&tmp);
2348+ }
2349+ }
2350+ FREE (&ptr->table);
2351+ FREE (&ptr);
ce1255c1
JB
2352+ return table;
2353+}
2354+
2355 /* table hash table to update
2356 * key key to hash on
2357 * data data to associate with `key'
4adf126f 2358@@ -90,6 +114,7 @@ int hash_insert (HASH * table, const cha
ce1255c1
JB
2359 {
2360 ptr->next = table->table[h];
2361 table->table[h] = ptr;
2362+ table->curnelem++;
2363 }
2364 else
2365 {
4adf126f 2366@@ -112,6 +137,7 @@ int hash_insert (HASH * table, const cha
ce1255c1
JB
2367 else
2368 table->table[h] = ptr;
2369 ptr->next = tmp;
2370+ table->curnelem++;
2371 }
2372 return h;
2373 }
4adf126f 2374@@ -142,6 +168,7 @@ void hash_delete_hash (HASH * table, int
ce1255c1
JB
2375 if (destroy)
2376 destroy (ptr->data);
2377 FREE (&ptr);
2378+ table->curnelem--;
2379
2380 ptr = *last;
2381 }
4adf126f
JB
2382diff -udprP mutt-1.5.21.orig/hash.h mutt-1.5.21/hash.h
2383--- mutt-1.5.21.orig/hash.h 2009-03-19 21:41:18.000000000 +0200
2384+++ mutt-1.5.21/hash.h 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
2385@@ -28,7 +28,7 @@ struct hash_elem
2386
2387 typedef struct
2388 {
2389- int nelem;
2390+ int nelem, curnelem;
2391 struct hash_elem **table;
4adf126f
JB
2392 unsigned int (*hash_string)(const unsigned char *, unsigned int);
2393 int (*cmp_string)(const char *, const char *);
2394@@ -41,6 +41,7 @@ HASH;
2395
2396 HASH *hash_create (int nelem, int lower);
ce1255c1 2397 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
4adf126f 2398+HASH *hash_resize (HASH * table, int nelem, int lower);
ce1255c1
JB
2399 void *hash_find_hash (const HASH * table, int hash, const char *key);
2400 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2401 void (*destroy) (void *));
4adf126f
JB
2402diff -udprP mutt-1.5.21.orig/hdrline.c mutt-1.5.21/hdrline.c
2403--- mutt-1.5.21.orig/hdrline.c 2009-04-11 02:45:19.000000000 +0300
2404+++ mutt-1.5.21/hdrline.c 2010-09-16 13:14:39.000000000 +0300
2405@@ -211,6 +211,7 @@ int mutt_user_is_recipient (HEADER *h)
ce1255c1
JB
2406 * %E = number of messages in current thread
2407 * %f = entire from line
2408 * %F = like %n, unless from self
2409+ * %g = newsgroup name (if compiled with nntp support)
2410 * %i = message-id
2411 * %l = number of lines in the message
2412 * %L = like %F, except `lists' are displayed first
4adf126f 2413@@ -219,12 +220,14 @@ int mutt_user_is_recipient (HEADER *h)
ce1255c1
JB
2414 * %N = score
2415 * %O = like %L, except using address instead of name
2416 * %P = progress indicator for builtin pager
2417+ * %R = `x-comment-to:' field (if present and compiled with nntp support)
2418 * %s = subject
2419 * %S = short message status (e.g., N/O/D/!/r/-)
2420 * %t = `to:' field (recipients)
2421 * %T = $to_chars
2422 * %u = user (login) name of author
2423 * %v = first name of author, unless from self
2424+ * %W = where user is (organization)
2425 * %X = number of MIME attachments
2426 * %y = `x-label:' field (if present)
2427 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
4adf126f 2428@@ -457,6 +460,12 @@ hdr_format_str (char *dest,
ce1255c1
JB
2429
2430 break;
2431
2432+#ifdef USE_NNTP
2433+ case 'g':
2434+ mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2435+ break;
2436+#endif
2437+
2438 case 'i':
2439 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2440 break;
4adf126f 2441@@ -548,6 +557,15 @@ hdr_format_str (char *dest,
ce1255c1
JB
2442 strfcpy(dest, NONULL(hfi->pager_progress), destlen);
2443 break;
2444
2445+#ifdef USE_NNTP
2446+ case 'R':
2447+ if (!optional)
2448+ mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2449+ else if (!hdr->env->x_comment_to)
2450+ optional = 0;
2451+ break;
2452+#endif
2453+
2454 case 's':
2455
2456 if (flags & M_FORMAT_TREE && !hdr->collapsed)
4adf126f 2457@@ -637,6 +655,13 @@ hdr_format_str (char *dest,
ce1255c1
JB
2458 mutt_format_s (dest, destlen, prefix, buf2);
2459 break;
2460
2461+ case 'W':
2462+ if (!optional)
2463+ mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2464+ else if (!hdr->env->organization)
2465+ optional = 0;
2466+ break;
2467+
2468 case 'Z':
2469
2470 ch = ' ';
4adf126f
JB
2471diff -udprP mutt-1.5.21.orig/headers.c mutt-1.5.21/headers.c
2472--- mutt-1.5.21.orig/headers.c 2009-08-25 22:08:52.000000000 +0300
2473+++ mutt-1.5.21/headers.c 2010-09-16 13:14:39.000000000 +0300
2474@@ -114,6 +114,9 @@ void mutt_edit_headers (const char *edit
2475 $edit_headers set, we remove References: as they're likely invalid;
2476 we can simply compare strings as we don't generate References for
2477 multiple Message-Ids in IRT anyways */
ce1255c1
JB
2478+#ifdef USE_NNTP
2479+ if (!option (OPTNEWSSEND))
2480+#endif
4adf126f
JB
2481 if (!n->in_reply_to || (msg->env->in_reply_to &&
2482 mutt_strcmp (n->in_reply_to->data,
2483 msg->env->in_reply_to->data) != 0))
2484diff -udprP mutt-1.5.21.orig/init.c mutt-1.5.21/init.c
2485--- mutt-1.5.21.orig/init.c 2010-08-25 19:31:40.000000000 +0300
2486+++ mutt-1.5.21/init.c 2010-09-16 13:14:39.000000000 +0300
2487@@ -2966,6 +2966,28 @@ void mutt_init (int skip_sys_rc, LIST *c
ce1255c1
JB
2488 else
2489 Fqdn = safe_strdup(NONULL(Hostname));
2490
2491+#ifdef USE_NNTP
2492+ {
2493+ FILE *f;
2494+ char *i;
2495+
2496+ if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2497+ {
2498+ buffer[0] = '\0';
2499+ fgets (buffer, sizeof (buffer), f);
2500+ p = &buffer;
2501+ SKIPWS (p);
2502+ i = p;
2503+ while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2504+ *i = '\0';
2505+ NewsServer = safe_strdup (p);
2506+ fclose (f);
2507+ }
2508+ }
2509+ if ((p = getenv ("NNTPSERVER")))
2510+ NewsServer = safe_strdup (p);
2511+#endif
2512+
2513 if ((p = getenv ("MAIL")))
2514 Spoolfile = safe_strdup (p);
2515 else if ((p = getenv ("MAILDIR")))
4adf126f
JB
2516diff -udprP mutt-1.5.21.orig/init.h mutt-1.5.21/init.h
2517--- mutt-1.5.21.orig/init.h 2010-09-15 18:39:31.000000000 +0300
2518+++ mutt-1.5.21/init.h 2010-09-16 13:14:39.000000000 +0300
bebcbf73
AG
2519@@ -176,6 +176,20 @@ struct option_t MuttVars[] = {
2520 ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before
ce1255c1 2521 ** editing the body of an outgoing message.
bebcbf73 2522 */
ce1255c1
JB
2523+#ifdef USE_NNTP
2524+ { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2525+ /*
2526+ ** .pp
2527+ ** If set, Mutt will prompt you for follow-up groups before editing
2528+ ** the body of an outgoing message.
bebcbf73 2529+ */
ce1255c1
JB
2530+ { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2531+ /*
2532+ ** .pp
2533+ ** If set, Mutt will prompt you for x-comment-to field before editing
2534+ ** the body of an outgoing message.
bebcbf73 2535+ */
ce1255c1
JB
2536+#endif
2537 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2538 /*
2539 ** .pp
4adf126f
JB
2540@@ -322,6 +336,14 @@ struct option_t MuttVars[] = {
2541 ** follow these menus. The option is \fIunset\fP by default because many
2542 ** visual terminals don't permit making the cursor invisible.
ce1255c1
JB
2543 */
2544+#ifdef USE_NNTP
2545+ { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2546+ /*
2547+ ** .pp
2548+ ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2549+ ** as read when you quit the newsgroup (catchup newsgroup).
2550+ */
2551+#endif
4adf126f
JB
2552 #if defined(USE_SSL)
2553 { "certificate_file", DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" },
ce1255c1 2554 /*
4adf126f 2555@@ -798,6 +820,16 @@ struct option_t MuttVars[] = {
ce1255c1
JB
2556 ** sent to both the list and your address, resulting in two copies
2557 ** of the same email for you.
2558 */
2559+#ifdef USE_NNTP
2560+ { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2561+ /*
2562+ ** .pp
2563+ ** If this variable is \fIset\fP and the keyword "poster" is present in
2564+ ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2565+ ** permitted. The message will be mailed to the submitter of the
2566+ ** message via mail.
2567+ */
2568+#endif
2569 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2570 /*
2571 ** .pp
4adf126f 2572@@ -880,6 +912,27 @@ struct option_t MuttVars[] = {
ce1255c1 2573 ** a regular expression that will match the whole name so mutt will expand
bebcbf73 2574 ** ``Franklin'' to ``Franklin, Steve''.
ce1255c1
JB
2575 */
2576+#ifdef USE_NNTP
2577+ { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2578+ /*
2579+ ** .pp
2580+ ** This variable allows you to customize the newsgroup browser display to
2581+ ** your personal taste. This string is similar to ``$index_format'', but
2582+ ** has its own set of printf()-like sequences:
2583+ ** .pp
2584+ ** .ts
2585+ ** %C current newsgroup number
2586+ ** %d description of newsgroup (becomes from server)
2587+ ** %f newsgroup name
2588+ ** %M - if newsgroup not allowed for direct post (moderated for example)
2589+ ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2590+ ** %n number of new articles in newsgroup
2591+ ** %s number of unread articles in newsgroup
2592+ ** %>X right justify the rest of the string and pad with character "X"
2593+ ** %|X pad to the end of the line with character "X"
2594+ ** .te
2595+ */
2596+#endif
2597 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2598 /*
2599 */
4adf126f 2600@@ -1256,6 +1309,7 @@ struct option_t MuttVars[] = {
ce1255c1 2601 ** .dt %E .dd number of messages in current thread
bebcbf73 2602 ** .dt %f .dd sender (address + real name), either From: or Return-Path:
ce1255c1
JB
2603 ** .dt %F .dd author name, or recipient name if the message is from you
2604+ ** .dt %g .dd newsgroup name (if compiled with nntp support)
2605 ** .dt %H .dd spam attribute(s) of this message
2606 ** .dt %i .dd message-id of the current message
2607 ** .dt %l .dd number of lines in the message (does not work with maildir,
4adf126f 2608@@ -1271,12 +1325,14 @@ struct option_t MuttVars[] = {
bebcbf73
AG
2609 ** stashed the message: list name or recipient name
2610 ** if not sent to a list
4adf126f
JB
2611 ** .dt %P .dd progress indicator for the built-in pager (how much of the file has been displayed)
2612+ ** .dt %R .dd ``x-comment-to:'' field (if present and compiled with nntp support)
ce1255c1 2613 ** .dt %s .dd subject of the message
bebcbf73
AG
2614 ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as)
2615 ** .dt %t .dd ``To:'' field (recipients)
ce1255c1
JB
2616 ** .dt %T .dd the appropriate character from the $$to_chars string
2617 ** .dt %u .dd user (login) name of the author
2618 ** .dt %v .dd first name of the author, or the recipient if the message is from you
4adf126f 2619+ ** .dt %W .dd name of organization of author (``organization:'' field)
ce1255c1
JB
2620 ** .dt %X .dd number of attachments
2621 ** (please see the ``$attachments'' section for possible speed effects)
bebcbf73 2622 ** .dt %y .dd ``X-Label:'' field, if present
4adf126f 2623@@ -1311,6 +1367,21 @@ struct option_t MuttVars[] = {
bebcbf73
AG
2624 ** Note that these expandos are supported in
2625 ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too.
ce1255c1
JB
2626 */
2627+#ifdef USE_NNTP
2628+ { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2629+ /*
2630+ ** .pp
2631+ ** If set, specifies the program and arguments used to deliver news posted
2632+ ** by Mutt. Otherwise, mutt posts article using current connection to
2633+ ** news server. The following printf-style sequence is understood:
2634+ ** .pp
2635+ ** .ts
2636+ ** %s newsserver name
2637+ ** .te
2638+ ** .pp
2639+ ** Example: set inews="/usr/local/bin/inews -hS"
2640+ */
2641+#endif
2642 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2643 /*
2644 ** .pp
4adf126f 2645@@ -1545,6 +1616,15 @@ struct option_t MuttVars[] = {
bebcbf73
AG
2646 ** menu, attachments which cannot be decoded in a reasonable manner will
2647 ** be attached to the newly composed message if this option is \fIset\fP.
ce1255c1 2648 */
ce1255c1
JB
2649+#ifdef USE_NNTP
2650+ { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2651+ /*
2652+ ** .pp
2653+ ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2654+ ** encoded according to RFC2047 to base64. This is useful when message
2655+ ** is Usenet article, because MIME for news is nonstandard feature.
2656+ */
2657+#endif
ce1255c1
JB
2658 #ifdef MIXMASTER
2659 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2660 /*
4adf126f 2661@@ -1592,6 +1672,77 @@ struct option_t MuttVars[] = {
bebcbf73 2662 ** See also $$read_inc, $$write_inc and $$net_inc.
ce1255c1 2663 */
bebcbf73 2664 #endif
ce1255c1
JB
2665+#ifdef USE_NNTP
2666+ { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2667+ /*
2668+ ** .pp
2669+ ** This variable pointing to directory where Mutt will save cached news
2670+ ** articles headers in. If \fIunset\fP, headers will not be saved at all
2671+ ** and will be reloaded each time when you enter to newsgroup.
2672+ */
2673+ { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2674+ /*
2675+ ** .pp
2676+ ** This variable specifies domain name or address of NNTP server. It
2677+ ** defaults to the newsserver specified in the environment variable
2678+ ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2679+ ** specify username and an alternative port for each newsserver, ie:
2680+ ** .pp
2681+ ** [news[s]://][username[:password]@]newsserver[:port]
2682+ */
2683+ { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2684+ /*
2685+ ** .pp
2686+ ** The file, containing info about subscribed newsgroups - names and
2687+ ** indexes of read articles. The following printf-style sequence
2688+ ** is understood:
2689+ ** .pp
2690+ ** .ts
2691+ ** %s newsserver name
2692+ ** .te
2693+ */
2694+ { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2695+ /*
2696+ ** .pp
2697+ ** This variable defines number of articles which will be in index when
2698+ ** newsgroup entered. If active newsgroup have more articles than this
2699+ ** number, oldest articles will be ignored. Also controls how many
2700+ ** articles headers will be saved in cache when you quit newsgroup.
2701+ */
2702+ { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2703+ /*
2704+ ** .pp
2705+ ** This variable controls whether or not descriptions for each newsgroup
2706+ ** must be loaded when newsgroup is added to list (first time list
2707+ ** loading or new newsgroup adding).
2708+ */
2709+ { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2710+ /*
2711+ ** .pp
2712+ ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2713+ ** authentification, Mutt will prompt you for your account name when you
2714+ ** connect to newsserver.
2715+ */
2716+ { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2717+ /*
2718+ ** .pp
2719+ ** Your password for NNTP account.
2720+ */
2721+ { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2722+ /*
2723+ ** .pp
2724+ ** The time in seconds until any operations on newsgroup except post new
2725+ ** article will cause recheck for new news. If set to 0, Mutt will
2726+ ** recheck newsgroup on each operation in index (stepping, read article,
2727+ ** etc.).
2728+ */
2729+ { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2730+ /*
2731+ ** .pp
2732+ ** Controls whether or not Mutt will try to reconnect to newsserver when
2733+ ** connection lost.
2734+ */
2735+#endif
2736 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2737 /*
2738 ** .pp
4adf126f 2739@@ -2091,6 +2242,16 @@ struct option_t MuttVars[] = {
ce1255c1
JB
2740 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2741 /*
2742 */
2743+#ifdef USE_NNTP
2744+ { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2745+ /*
2746+ ** .pp
2747+ ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2748+ ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2749+ ** does not support posting to that newsgroup or totally read-only, that
2750+ ** posting will not have an effect.
2751+ */
2752+#endif
2753 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2754 /*
2755 ** .pp
4adf126f 2756@@ -2494,6 +2655,28 @@ struct option_t MuttVars[] = {
ce1255c1 2757 ** Command to use when spawning a subshell. By default, the user's login
bebcbf73 2758 ** shell from \fC/etc/passwd\fP is used.
ce1255c1
JB
2759 */
2760+#ifdef USE_NNTP
2761+ { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2762+ /*
2763+ ** .pp
2764+ ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2765+ ** ``newsrc'' file and into cache.
2766+ */
2767+ { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2768+ /*
2769+ ** .pp
2770+ ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2771+ ** the browser. Otherwise, it will be done only once for a newsserver.
2772+ ** Also controls whether or not number of new articles of subscribed
2773+ ** newsgroups will be then checked.
2774+ */
2775+ { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2776+ /*
2777+ ** .pp
2778+ ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2779+ ** will be displayed in browser.
2780+ */
2781+#endif
2782 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2783 /*
2784 ** .pp
4adf126f
JB
2785@@ -3364,6 +3547,14 @@ struct option_t MuttVars[] = {
2786 ** Also see the $$read_inc, $$net_inc and $$time_inc variables and the
2787 ** ``$tuning'' section of the manual for performance considerations.
ce1255c1
JB
2788 */
2789+#ifdef USE_NNTP
2790+ { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2791+ /*
2792+ ** .pp
2793+ ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2794+ ** name of original article author) to article that followuped to newsgroup.
2795+ */
2796+#endif
2797 /*--*/
4adf126f 2798 { NULL, 0, 0, 0, 0 }
ce1255c1 2799 };
4adf126f
JB
2800diff -udprP mutt-1.5.21.orig/mailbox.h mutt-1.5.21/mailbox.h
2801--- mutt-1.5.21.orig/mailbox.h 2009-04-30 20:33:48.000000000 +0300
2802+++ mutt-1.5.21/mailbox.h 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
2803@@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2804 #ifdef USE_POP
2805 int mx_is_pop (const char *);
2806 #endif
2807+#ifdef USE_NNTP
2808+int mx_is_nntp (const char *);
2809+#endif
2810
2811 int mx_access (const char*, int);
2812 int mx_check_empty (const char *);
4adf126f
JB
2813diff -udprP mutt-1.5.21.orig/main.c mutt-1.5.21/main.c
2814--- mutt-1.5.21.orig/main.c 2010-09-13 20:19:55.000000000 +0300
2815+++ mutt-1.5.21/main.c 2010-09-16 13:14:39.000000000 +0300
bebcbf73 2816@@ -60,6 +60,10 @@
ce1255c1
JB
2817 #include <stringprep.h>
2818 #endif
2819
2820+#ifdef USE_NNTP
2821+#include "nntp.h"
2822+#endif
2823+
2824 static const char *ReachingUs = N_("\
2825 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2826 To report a bug, please visit http://bugs.mutt.org/.\n");
4adf126f 2827@@ -134,6 +138,8 @@ options:\n\
ce1255c1
JB
2828 " -e <command>\tspecify a command to be executed after initialization\n\
2829 -f <file>\tspecify which mailbox to read\n\
2830 -F <file>\tspecify an alternate muttrc file\n\
2831+ -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2832+ -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2833 -H <file>\tspecify a draft file to read header and body from\n\
2834 -i <file>\tspecify a file which Mutt should include in the body\n\
2835 -m <type>\tspecify a default mailbox type\n\
4adf126f 2836@@ -254,6 +260,12 @@ static void show_version (void)
ce1255c1
JB
2837 "-USE_POP "
2838 #endif
2839
2840+#ifdef USE_NNTP
2841+ "+USE_NNTP "
2842+#else
2843+ "-USE_NNTP "
2844+#endif
2845+
2846 #ifdef USE_IMAP
2847 "+USE_IMAP "
2848 #else
4adf126f 2849@@ -522,6 +534,9 @@ init_extended_keys();
ce1255c1
JB
2850 #define M_NOSYSRC (1<<2) /* -n */
2851 #define M_RO (1<<3) /* -R */
2852 #define M_SELECT (1<<4) /* -y */
2853+#ifdef USE_NNTP
2854+#define M_NEWS (1<<5) /* -g and -G */
2855+#endif
2856
2857 int main (int argc, char **argv)
2858 {
bebcbf73
AG
2859@@ -594,7 +609,11 @@ int main (int argc, char **argv)
2860 argv[nargc++] = argv[optind];
ce1255c1
JB
2861 }
2862
2863+#ifdef USE_NNTP
bebcbf73 2864+ if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
ce1255c1 2865+#else
bebcbf73 2866 if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
ce1255c1 2867+#endif
bebcbf73
AG
2868 switch (i)
2869 {
ce1255c1 2870 case 'A':
4adf126f 2871@@ -691,6 +710,20 @@ int main (int argc, char **argv)
ce1255c1
JB
2872 flags |= M_SELECT;
2873 break;
2874
2875+#ifdef USE_NNTP
2876+ case 'g': /* Specify a newsserver */
2877+ {
2878+ char buf[LONG_STRING];
2879+
2880+ snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2881+ commands = mutt_add_list (commands, buf);
2882+ }
2883+
2884+ case 'G': /* List of newsgroups */
2885+ flags |= M_SELECT | M_NEWS;
2886+ break;
2887+#endif
2888+
2889 case 'z':
2890 flags |= M_IGNORE;
2891 break;
4adf126f 2892@@ -978,6 +1011,18 @@ int main (int argc, char **argv)
ce1255c1
JB
2893 }
2894 else if (flags & M_SELECT)
2895 {
2896+#ifdef USE_NNTP
2897+ if (flags & M_NEWS)
2898+ {
2899+ set_option (OPTNEWS);
2900+ if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2901+ {
2902+ mutt_endwin (Errorbuf);
2903+ exit (1);
2904+ }
2905+ }
2906+ else
2907+#endif
2908 if (!Incoming) {
2909 mutt_endwin _("No incoming mailboxes defined.");
2910 exit (1);
4adf126f 2911@@ -993,6 +1038,15 @@ int main (int argc, char **argv)
ce1255c1
JB
2912
2913 if (!folder[0])
2914 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2915+
2916+#ifdef USE_NNTP
2917+ if (option (OPTNEWS))
2918+ {
2919+ unset_option (OPTNEWS);
2920+ nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2921+ }
2922+ else
2923+#endif
2924 mutt_expand_path (folder, sizeof (folder));
2925
2926 mutt_str_replace (&CurrentFolder, folder);
4adf126f
JB
2927diff -udprP mutt-1.5.21.orig/mutt.h mutt-1.5.21/mutt.h
2928--- mutt-1.5.21.orig/mutt.h 2010-09-13 20:19:55.000000000 +0300
2929+++ mutt-1.5.21/mutt.h 2010-09-16 13:14:39.000000000 +0300
2930@@ -229,6 +229,9 @@ enum
ce1255c1
JB
2931 M_PGP_KEY,
2932 M_XLABEL,
2933 M_MIMEATTACH,
2934+#ifdef USE_NNTP
2935+ M_NEWSGROUPS,
2936+#endif
2937
2938 /* Options for Mailcap lookup */
2939 M_EDIT,
4adf126f 2940@@ -285,6 +288,12 @@ enum
ce1255c1
JB
2941 #endif
2942 OPT_SUBJECT,
2943 OPT_VERIFYSIG, /* verify PGP signatures */
2944+#ifdef USE_NNTP
2945+ OPT_TOMODERATED,
2946+ OPT_NNTPRECONNECT,
2947+ OPT_CATCHUP,
2948+ OPT_FOLLOWUPTOPOSTER,
2949+#endif /* USE_NNTP */
2950
2951 /* THIS MUST BE THE LAST VALUE. */
2952 OPT_MAX
4adf126f 2953@@ -300,6 +309,7 @@ enum
ce1255c1
JB
2954 #define SENDMAILX (1<<6)
2955 #define SENDKEY (1<<7)
2956 #define SENDRESEND (1<<8)
2957+#define SENDNEWS (1<<9)
2958
2959 /* flags to _mutt_select_file() */
2960 #define M_SEL_BUFFY (1<<0)
4adf126f 2961@@ -319,6 +329,8 @@ enum
ce1255c1
JB
2962 OPTASCIICHARS,
2963 OPTASKBCC,
2964 OPTASKCC,
2965+ OPTASKFOLLOWUP,
2966+ OPTASKXCOMMENTTO,
2967 OPTATTACHSPLIT,
2968 OPTAUTOEDIT,
2969 OPTAUTOTAG,
4adf126f 2970@@ -397,6 +409,9 @@ enum
ce1255c1
JB
2971 OPTMETOO,
2972 OPTMHPURGE,
2973 OPTMIMEFORWDECODE,
2974+#ifdef USE_NNTP
2975+ OPTMIMESUBJECT, /* encode subject line with RFC2047 */
2976+#endif
2977 OPTNARROWTREE,
2978 OPTPAGERSTOP,
2979 OPTPIPEDECODE,
4adf126f 2980@@ -478,6 +493,16 @@ enum
ce1255c1
JB
2981 OPTPGPAUTOINLINE,
2982 OPTPGPREPLYINLINE,
2983
2984+ /* news options */
2985+
2986+#ifdef USE_NNTP
2987+ OPTSHOWNEWNEWS,
2988+ OPTSHOWONLYUNREAD,
2989+ OPTSAVEUNSUB,
2990+ OPTLOADDESC,
2991+ OPTXCOMMENTTO,
2992+#endif /* USE_NNTP */
2993+
2994 /* pseudo options */
2995
2996 OPTAUXSORT, /* (pseudo) using auxillary sort function */
4adf126f 2997@@ -498,6 +523,7 @@ enum
ce1255c1
JB
2998 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
2999 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3000 OPTATTACHMSG, /* (pseudo) used by attach-message */
3001+ OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3002 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3003 * functions while we are executing an
3004 * external program.
4adf126f 3005@@ -508,6 +534,12 @@ enum
ce1255c1
JB
3006 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3007 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
3008
3009+#ifdef USE_NNTP
3010+ OPTNEWS, /* (pseudo) used to change reader mode */
3011+ OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3012+ OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
3013+#endif
3014+
3015 OPTMAX
3016 };
3017
4adf126f 3018@@ -587,6 +619,13 @@ typedef struct envelope
ce1255c1
JB
3019 char *supersedes;
3020 char *date;
3021 char *x_label;
3022+ char *organization;
3023+#ifdef USE_NNTP
3024+ char *newsgroups;
3025+ char *xref;
3026+ char *followup_to;
3027+ char *x_comment_to;
3028+#endif
3029 BUFFER *spam;
3030 LIST *references; /* message references (in reverse order) */
3031 LIST *in_reply_to; /* in-reply-to header content */
4adf126f 3032@@ -756,6 +795,9 @@ typedef struct header
ce1255c1
JB
3033 ENVELOPE *env; /* envelope information */
3034 BODY *content; /* list of MIME parts */
3035 char *path;
3036+#ifdef USE_NNTP
3037+ int article_num;
3038+#endif
3039
3040 char *tree; /* character string to print thread tree */
4adf126f
JB
3041 THREAD *thread;
3042@@ -771,7 +813,7 @@ typedef struct header
ce1255c1
JB
3043 int refno; /* message number on server */
3044 #endif
3045
3046-#if defined USE_POP || defined USE_IMAP
3047+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3048 void *data; /* driver-specific data */
3049 #endif
3050
4adf126f
JB
3051diff -udprP mutt-1.5.21.orig/muttlib.c mutt-1.5.21/muttlib.c
3052--- mutt-1.5.21.orig/muttlib.c 2010-08-25 19:31:40.000000000 +0300
3053+++ mutt-1.5.21/muttlib.c 2010-09-16 13:14:39.000000000 +0300
3054@@ -337,7 +337,7 @@ void mutt_free_header (HEADER **h)
ce1255c1
JB
3055 #ifdef MIXMASTER
3056 mutt_free_list (&(*h)->chain);
3057 #endif
3058-#if defined USE_POP || defined USE_IMAP
3059+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3060 FREE (&(*h)->data);
3061 #endif
3062 FREE (h); /* __FREE_CHECKED__ */
4adf126f 3063@@ -722,6 +722,13 @@ void mutt_free_envelope (ENVELOPE **p)
ce1255c1
JB
3064 FREE (&(*p)->supersedes);
3065 FREE (&(*p)->date);
3066 FREE (&(*p)->x_label);
3067+ FREE (&(*p)->organization);
3068+#ifdef USE_NNTP
3069+ FREE (&(*p)->newsgroups);
3070+ FREE (&(*p)->xref);
3071+ FREE (&(*p)->followup_to);
3072+ FREE (&(*p)->x_comment_to);
3073+#endif
3074
3075 mutt_buffer_free (&(*p)->spam);
3076
4adf126f 3077@@ -1525,6 +1532,14 @@ int mutt_save_confirm (const char *s, st
ce1255c1
JB
3078 }
3079 }
3080
3081+#ifdef USE_NNTP
3082+ if (magic == M_NNTP)
3083+ {
3084+ mutt_error _("Can't save message to newsserver.");
3085+ return 0;
3086+ }
3087+#endif
3088+
3089 if (stat (s, st) != -1)
3090 {
3091 if (magic == -1)
4adf126f
JB
3092diff -udprP mutt-1.5.21.orig/mx.c mutt-1.5.21/mx.c
3093--- mutt-1.5.21.orig/mx.c 2010-09-13 20:19:55.000000000 +0300
3094+++ mutt-1.5.21/mx.c 2010-09-16 13:14:39.000000000 +0300
bebcbf73 3095@@ -343,6 +343,22 @@ int mx_is_pop (const char *p)
ce1255c1
JB
3096 }
3097 #endif
3098
3099+#ifdef USE_NNTP
3100+int mx_is_nntp (const char *p)
3101+{
3102+ url_scheme_t scheme;
3103+
3104+ if (!p)
3105+ return 0;
3106+
3107+ scheme = url_check_scheme (p);
3108+ if (scheme == U_NNTP || scheme == U_NNTPS)
3109+ return 1;
3110+
3111+ return 0;
3112+}
3113+#endif
3114+
3115 int mx_get_magic (const char *path)
3116 {
3117 struct stat st;
bebcbf73 3118@@ -360,6 +376,11 @@ int mx_get_magic (const char *path)
ce1255c1
JB
3119 return M_POP;
3120 #endif /* USE_POP */
3121
3122+#ifdef USE_NNTP
3123+ if (mx_is_nntp (path))
3124+ return M_NNTP;
3125+#endif /* USE_NNTP */
3126+
3127 if (stat (path, &st) == -1)
3128 {
3129 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
4adf126f 3130@@ -668,6 +689,12 @@ CONTEXT *mx_open_mailbox (const char *pa
ce1255c1
JB
3131 break;
3132 #endif /* USE_POP */
3133
3134+#ifdef USE_NNTP
3135+ case M_NNTP:
3136+ rc = nntp_open_mailbox (ctx);
3137+ break;
3138+#endif /* USE_NNTP */
3139+
3140 default:
3141 rc = -1;
3142 break;
4adf126f 3143@@ -764,6 +791,12 @@ static int sync_mailbox (CONTEXT *ctx, i
ce1255c1
JB
3144 rc = pop_sync_mailbox (ctx, index_hint);
3145 break;
3146 #endif /* USE_POP */
3147+
3148+#ifdef USE_NNTP
3149+ case M_NNTP:
3150+ rc = nntp_sync_mailbox (ctx);
3151+ break;
3152+#endif /* USE_NNTP */
3153 }
3154
3155 #if 0
4adf126f 3156@@ -790,6 +823,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
ce1255c1
JB
3157
3158 ctx->closing = 1;
3159
3160+#ifdef USE_NNTP
3161+ if (ctx->magic == M_NNTP)
3162+ {
3163+ int ret;
3164+
3165+ ret = nntp_close_mailbox (ctx);
3166+ mx_fastclose_mailbox (ctx);
3167+ return ret;
3168+ }
3169+#endif
3170 if (ctx->readonly || ctx->dontwrite)
3171 {
3172 /* mailbox is readonly or we don't want to write */
4adf126f 3173@@ -1341,6 +1384,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
ce1255c1
JB
3174 case M_POP:
3175 return (pop_check_mailbox (ctx, index_hint));
3176 #endif /* USE_POP */
3177+
3178+#ifdef USE_NNTP
3179+ case M_NNTP:
3180+ return (nntp_check_mailbox (ctx));
3181+#endif /* USE_NNTP */
3182 }
3183 }
3184
4adf126f 3185@@ -1401,6 +1449,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
ce1255c1
JB
3186 }
3187 #endif /* USE_POP */
3188
3189+#ifdef USE_NNTP
3190+ case M_NNTP:
3191+ {
3192+ if (nntp_fetch_message (msg, ctx, msgno) != 0)
3193+ FREE (&msg);
3194+ break;
3195+ }
3196+#endif /* USE_NNTP */
3197+
3198 default:
3199 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3200 FREE (&msg);
4adf126f
JB
3201@@ -1476,6 +1533,9 @@ int mx_close_message (MESSAGE **msg)
3202 int r = 0;
3203
3204 if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR
ce1255c1
JB
3205+#ifdef USE_NNTP
3206+ || (*msg)->magic == M_NNTP
3207+#endif
4adf126f 3208 || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP)
ce1255c1
JB
3209 {
3210 r = safe_fclose (&(*msg)->fp);
4adf126f
JB
3211diff -udprP mutt-1.5.21.orig/mx.h mutt-1.5.21/mx.h
3212--- mutt-1.5.21.orig/mx.h 2009-08-25 22:08:52.000000000 +0300
3213+++ mutt-1.5.21/mx.h 2010-09-16 13:14:39.000000000 +0300
3214@@ -34,6 +34,9 @@ enum
3215 M_MMDF,
3216 M_MH,
3217 M_MAILDIR,
3218+#ifdef USE_NNTP
3219+ M_NNTP,
3220+#endif
3221 M_IMAP,
3222 M_POP
ce1255c1 3223 };
4adf126f
JB
3224diff -udprP mutt-1.5.21.orig/newsrc.c mutt-1.5.21/newsrc.c
3225--- mutt-1.5.21.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3226+++ mutt-1.5.21/newsrc.c 2010-09-16 13:14:39.000000000 +0300
ce1255c1
JB
3227@@ -0,0 +1,1170 @@
3228+/*
3229+ * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3230+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
bebcbf73 3231+ * Copyright (C) 2000-2009 Vsevolod Volkov <vvv@mutt.org.ua>
ce1255c1
JB
3232+ *
3233+ * This program is free software; you can redistribute it and/or modify
3234+ * it under the terms of the GNU General Public License as published by
3235+ * the Free Software Foundation; either version 2 of the License, or
3236+ * (at your option) any later version.
3237+ *
3238+ * This program is distributed in the hope that it will be useful,
3239+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3240+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3241+ * GNU General Public License for more details.
3242+ *
3243+ * You should have received a copy of the GNU General Public License
3244+ * along with this program; if not, write to the Free Software
3245+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3246+ */
3247+
3248+#if HAVE_CONFIG_H
3249+# include "config.h"
3250+#endif
3251+
3252+#include "mutt.h"
3253+#include "mutt_curses.h"
3254+#include "sort.h"
3255+#include "mx.h"
3256+#include "mime.h"
3257+#include "mailbox.h"
3258+#include "nntp.h"
3259+#include "rfc822.h"
3260+#include "rfc1524.h"
3261+#include "rfc2047.h"
3262+
3263+#include <unistd.h>
3264+#include <string.h>
3265+#include <ctype.h>
3266+#include <stdlib.h>
3267+#include <sys/stat.h>
3268+
3269+void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3270+{
3271+ LIST *l;
3272+
3273+ if (!s || !d)
3274+ return;
3275+
3276+ l = safe_calloc (1, sizeof (LIST));
3277+ if (s->list)
3278+ s->tail->next = l;
3279+ else
3280+ s->list = l;
3281+ s->tail = l;
3282+ l->data = (void *) d;
3283+}
3284+
3285+static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3286+{
3287+ NNTP_DATA *data;
3288+ char group[LONG_STRING];
3289+ int x = 1;
3290+ char *p = line, *b, *h;
3291+ size_t len;
3292+
3293+ while (*p)
3294+ {
3295+ if (*p++ == ',')
3296+ x++;
3297+ }
3298+
3299+ p = line;
3300+ while (*p && (*p != ':' && *p != '!')) p++;
3301+ if (!*p)
3302+ return -1;
3303+ len = p + 1 - line;
3304+ if (len > sizeof (group))
3305+ len = sizeof (group);
3306+ strfcpy (group, line, len);
3307+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3308+ {
3309+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3310+ data->group = (char *) data + sizeof (NNTP_DATA);
3311+ strcpy (data->group, group);
3312+ data->nserv = news;
3313+ data->deleted = 1;
3314+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4adf126f 3315+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
ce1255c1
JB
3316+ hash_insert (news->newsgroups, data->group, data, 0);
3317+ nntp_add_to_list (news, data);
3318+ }
3319+ else
3320+ FREE ((void **) &data->entries);
3321+
3322+ data->rc = 1;
3323+ data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3324+ data->max = x*2;
3325+
3326+ if (*p == ':')
3327+ data->subscribed = 1;
3328+ else
3329+ data->subscribed = 0;
3330+
3331+ p++;
3332+ b = p;
3333+ x = 0;
3334+ while (*b)
3335+ {
3336+ while (*p && *p != ',' && *p != '\n') p++;
3337+ if (*p)
3338+ {
3339+ *p = '\0';
3340+ p++;
3341+ }
3342+ if ((h = strchr(b, '-')))
3343+ {
3344+ *h = '\0';
3345+ h++;
3346+ data->entries[x].first = atoi(b);
3347+ data->entries[x].last = atoi(h);
3348+ }
3349+ else
3350+ {
3351+ data->entries[x].first = atoi(b);
3352+ data->entries[x].last = data->entries[x].first;
3353+ }
3354+ b = p;
3355+ if (data->entries[x].last != 0)
3356+ x++;
3357+ }
3358+ if (x && !data->lastMessage)
3359+ data->lastMessage = data->entries[x-1].last;
3360+ data->num = x;
3361+ mutt_newsgroup_stat (data);
3362+ dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3363+
3364+ return 0;
3365+}
3366+
3367+static int slurp_newsrc (NNTP_SERVER *news)
3368+{
3369+ FILE *fp;
3370+ char *buf;
3371+ struct stat sb;
3372+
3373+ news->stat = stat (news->newsrc, &sb);
3374+ news->size = sb.st_size;
3375+ news->mtime = sb.st_mtime;
3376+
3377+ if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3378+ return -1;
3379+ /* hmm, should we use dotlock? */
3380+ if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3381+ {
3382+ fclose (fp);
3383+ return -1;
3384+ }
3385+
3386+ buf = safe_malloc (sb.st_size + 1);
3387+ while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3388+ nntp_parse_newsrc_line (news, buf);
3389+ FREE (&buf);
3390+
3391+ mx_unlock_file (news->newsrc, fileno (fp), 0);
3392+ fclose (fp);
3393+ return 0;
3394+}
3395+
3396+void nntp_cache_expand (char *dst, const char *src)
3397+{
3398+ snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3399+ mutt_expand_path (dst, _POSIX_PATH_MAX);
3400+}
3401+
3402+/* Loads $news_cache_dir/.index into memory, loads newsserver data
3403+ * and newsgroup cache names */
3404+static int nntp_parse_cacheindex (NNTP_SERVER *news)
3405+{
3406+ struct stat st;
3407+ char buf[HUGE_STRING], *cp;
3408+ char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3409+ FILE *index;
3410+ NNTP_DATA *data;
3411+ int l, m, t;
3412+
3413+ /* check is server name defined or not */
3414+ if (!news || !news->conn || !news->conn->account.host)
3415+ return -1;
3416+ unset_option (OPTNEWSCACHE);
3417+ if (!NewsCacheDir || !*NewsCacheDir)
3418+ return 0;
3419+
3420+ strfcpy (dir, NewsCacheDir, sizeof (dir));
3421+ mutt_expand_path (dir, sizeof(dir));
3422+
3423+ if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3424+ {
3425+ snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3426+ if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3427+ S_IRWXO)))
3428+ {
3429+ mutt_error _("Cache directory not created!");
3430+ return -1;
3431+ }
3432+ mutt_clear_error();
3433+ }
3434+
3435+ set_option (OPTNEWSCACHE);
3436+
3437+ FREE (&news->cache);
3438+ snprintf (buf, sizeof(buf), "%s/.index", dir);
3439+ if (!(index = safe_fopen (buf, "a+")))
3440+ return 0;
3441+ rewind (index);
3442+ while (fgets (buf, sizeof(buf), index))
3443+ {
3444+ buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3445+ if (!mutt_strncmp (buf, "#: ", 3) &&
3446+ !mutt_strcasecmp (buf+3, news->conn->account.host))
3447+ break;
3448+ }
3449+ while (fgets (buf, sizeof(buf), index))
3450+ {
3451+ cp = buf;
3452+ while (*cp && *cp != ' ') cp++;
3453+ if (!*cp) continue;
3454+ cp[0] = 0;
3455+ if (!mutt_strcmp (buf, "#:"))
3456+ break;
3457+ sscanf (cp + 1, "%s %d %d", file, &l, &m);
3458+ if (!mutt_strcmp (buf, "ALL"))
3459+ {
3460+ news->cache = safe_strdup (file);
3461+ news->newgroups_time = m;
3462+ }
3463+ else if (news->newsgroups)
3464+ {
3465+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3466+ {
3467+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3468+ data->group = (char *) data + sizeof (NNTP_DATA);
3469+ strcpy(data->group, buf);
3470+ data->nserv = news;
3471+ data->deleted = 1;
3472+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4adf126f 3473+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0);
ce1255c1
JB
3474+ hash_insert (news->newsgroups, data->group, data, 0);
3475+ nntp_add_to_list (news, data);
3476+ }
3477+ data->cache = safe_strdup (file);
3478+ t = 0;
3479+ if (!data->firstMessage || data->lastMessage < m)
3480+ t = 1;
3481+ if (!data->firstMessage)
3482+ data->firstMessage = l;
3483+ if (data->lastMessage < m)
3484+ data->lastMessage = m;
3485+ data->lastCached = m;
3486+ if (t || !data->unread)
3487+ mutt_newsgroup_stat (data);
3488+ }
3489+ }
3490+ fclose (index);
3491+ return 0;
3492+}
3493+
3494+const char *
bebcbf73 3495+nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
ce1255c1
JB
3496+ const char *fmt, const char *ifstring, const char *elsestring,
3497+ unsigned long data, format_flag flags)
3498+{
3499+ char fn[SHORT_STRING], tmp[SHORT_STRING];
3500+
3501+ switch (op)
3502+ {
3503+ case 's':
3504+ strncpy (fn, NewsServer, sizeof(fn) - 1);
3505+ mutt_strlower (fn);
3506+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3507+ snprintf (dest, destlen, tmp, fn);
3508+ break;
3509+ }
3510+ return (src);
3511+}
3512+
3513+/* nntp_parse_url: given an NNPT URL, return host, port,
3514+ * username, password and newsgroup will recognise. */
3515+int nntp_parse_url (const char *server, ACCOUNT *acct,
3516+ char *group, size_t group_len)
3517+{
3518+ ciss_url_t url;
3519+ char *c;
3520+ int ret = -1;
3521+
3522+ /* Defaults */
3523+ acct->flags = 0;
3524+ acct->port = NNTP_PORT;
3525+ acct->type = M_ACCT_TYPE_NNTP;
3526+
3527+ c = safe_strdup (server);
3528+ url_parse_ciss (&url, c);
3529+
3530+ if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3531+ {
3532+ if (url.scheme == U_NNTPS)
3533+ {
3534+ acct->flags |= M_ACCT_SSL;
3535+ acct->port = NNTP_SSL_PORT;
3536+ }
3537+
3538+ *group = '\0';
3539+ if (url.path)
3540+ strfcpy (group, url.path, group_len);
3541+
3542+ ret = mutt_account_fromurl (acct, &url);
3543+ }
3544+
3545+ FREE (&c);
3546+ return ret;
3547+}
3548+
3549+void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3550+{
3551+ ciss_url_t url;
3552+
3553+ url.path = safe_strdup (line);
3554+ mutt_account_tourl (acct, &url);
3555+ url_ciss_tostring (&url, line, len, 0);
3556+ FREE (&url.path);
3557+}
3558+
3559+/*
3560+ * Automatically loads a newsrc into memory, if necessary.
3561+ * Checks the size/mtime of a newsrc file, if it doesn't match, load
3562+ * again. Hmm, if a system has broken mtimes, this might mean the file
3563+ * is reloaded every time, which we'd have to fix.
3564+ *
3565+ * a newsrc file is a line per newsgroup, with the newsgroup, then a
3566+ * ':' denoting subscribed or '!' denoting unsubscribed, then a
3567+ * comma separated list of article numbers and ranges.
3568+ */
3569+NNTP_SERVER *mutt_select_newsserver (char *server)
3570+{
3571+ char file[_POSIX_PATH_MAX];
3572+ char *buf, *p;
3573+ LIST *list;
3574+ ACCOUNT acct;
3575+ NNTP_SERVER *serv;
3576+ CONNECTION *conn;
3577+
3578+ if (!server || !*server)
3579+ {
3580+ mutt_error _("No newsserver defined!");
3581+ return NULL;
3582+ }
3583+
3584+ buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3585+ if (url_check_scheme (server) == U_UNKNOWN)
3586+ {
3587+ strcpy (buf, "news://");
3588+ p = strchr (buf, '\0');
3589+ }
3590+ strcpy (p, server);
3591+
3592+ if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3593+ {
3594+ FREE (&buf);
3595+ mutt_error (_("%s is an invalid newsserver specification!"), server);
3596+ return NULL;
3597+ }
3598+ FREE (&buf);
3599+
3600+ conn = mutt_conn_find (NULL, &acct);
3601+ if (!conn)
3602+ return NULL;
3603+
3604+ mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), nntp_format_str, 0, 0);
3605+ mutt_expand_path (file, sizeof (file));
3606+
3607+ serv = (NNTP_SERVER *)conn->data;
3608+ if (serv)
3609+ {
3610+ struct stat sb;
3611+
3612+ /* externally modified? */
3613+ if (serv->stat != stat (file, &sb) || (!serv->stat &&
3614+ (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3615+ {
3616+ for (list = serv->list; list; list = list->next)
3617+ {
3618+ NNTP_DATA *data = (NNTP_DATA *) list->data;
3619+
3620+ if (data)
3621+ {
3622+ data->subscribed = 0;
3623+ data->rc = 0;
3624+ data->num = 0;
3625+ }
3626+ }
3627+ slurp_newsrc (serv);
3628+ nntp_clear_cacheindex (serv);
3629+ }
3630+
3631+ if (serv->status == NNTP_BYE)
3632+ serv->status = NNTP_NONE;
3633+ nntp_check_newgroups (serv, 0);
3634+ return serv;
3635+ }
3636+
3637+ /* New newsserver */
3638+ serv = safe_calloc (1, sizeof (NNTP_SERVER));
3639+ serv->conn = conn;
3640+ serv->newsrc = safe_strdup (file);
4adf126f 3641+ serv->newsgroups = hash_create (1009, 0);
ce1255c1
JB
3642+ slurp_newsrc (serv); /* load .newsrc */
3643+ nntp_parse_cacheindex (serv); /* load .index */
3644+ if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3645+ nntp_check_newgroups (serv, 1);
3646+ else if (nntp_get_active (serv) < 0)
3647+ {
3648+ hash_destroy (&serv->newsgroups, nntp_delete_data);
3649+ for (list = serv->list; list; list = list->next)
3650+ list->data = NULL;
3651+ mutt_free_list (&serv->list);
3652+ FREE (&serv->newsrc);
3653+ FREE (&serv->cache);
3654+ FREE (&serv);
3655+ return NULL;
3656+ }
3657+ nntp_clear_cacheindex (serv);
3658+ conn->data = (void *)serv;
3659+
3660+ return serv;
3661+}
3662+
3663+/*
3664+ * full status flags are not supported by nntp, but we can fake some
3665+ * of them. This is how:
3666+ * Read = a read message number is in the .newsrc
3667+ * New = a message is new since we last read this newsgroup
3668+ * Old = anything else
3669+ * So, Read is marked as such in the newsrc, old is anything that is
3670+ * "skipped" in the newsrc, and new is anything not in the newsrc nor
3671+ * in the cache. By skipped, I mean before the last unread message
3672+ */
3673+void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3674+{
3675+ NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3676+ int x;
3677+
3678+ if (group)
3679+ data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3680+
3681+ if (!data)
3682+ {
3683+#ifdef DEBUG
3684+ if (group)
3685+ dprint (3, (debugfile, "newsgroup %s not found\n", group));
3686+#endif
3687+ return;
3688+ }
3689+
3690+ for (x = 0; x < data->num; x++)
3691+ {
3692+ if ((article >= data->entries[x].first) &&
3693+ (article <= data->entries[x].last))
3694+ {
3695+ /* we cannot use mutt_set_flag() because mx_update_context()
3696+ didn't called yet */
3697+ h->read = 1;
3698+ return;
3699+ }
3700+ }
3701+ /* If article was not cached yet, it is new! :) */
3702+ if (!data->cache || article > data->lastCached)
3703+ return;
3704+ /* Old articles are articles which aren't read but an article after them
3705+ * has been cached */
3706+ if (option (OPTMARKOLD))
3707+ h->old = 1;
3708+}
3709+
3710+void mutt_newsgroup_stat (NNTP_DATA *data)
3711+{
3712+ int i;
3713+ unsigned int first, last;
3714+
3715+ data->unread = 0;
3716+ if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3717+ return;
3718+
3719+ data->unread = data->lastMessage - data->firstMessage + 1;
3720+ for (i = 0; i < data->num; i++)
3721+ {
3722+ first = data->entries[i].first;
3723+ if (first < data->firstMessage)
3724+ first = data->firstMessage;
3725+ last = data->entries[i].last;
3726+ if (last > data->lastMessage)
3727+ last = data->lastMessage;
3728+ if (first <= last)
3729+ data->unread -= last - first + 1;
3730+ }
3731+}
3732+
3733+static int puti (char *line, int num)
3734+{
3735+ char *p, s[32];
3736+
3737+ for (p = s; num; )
3738+ {
3739+ *p++ = '0' + num % 10;
3740+ num /= 10;
3741+ }
3742+ while (p > s)
3743+ *line++ = *--p, num++;
3744+ *line = '\0';
3745+ return num;
3746+}
3747+
3748+static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3749+{
3750+ char *line = *pline;
3751+ size_t len = *buflen - (*pline - *buf);
3752+ int x, i;
3753+
3754+ if (len < LONG_STRING * 10)
3755+ {
3756+ len += *buflen;
3757+ *buflen *= 2;
3758+ line = *buf;
3759+ safe_realloc (buf, *buflen);
3760+ line = *buf + (*pline - line);
3761+ }
3762+ strcpy (line, data->group);
3763+ len -= strlen (line) + 1;
3764+ line += strlen (line);
3765+ *line++ = data->subscribed ? ':' : '!';
3766+ *line++ = ' ';
3767+ *line = '\0';
3768+
3769+ for (x = 0; x < data->num; x++)
3770+ {
3771+ if (len < LONG_STRING)
3772+ {
3773+ len += *buflen;
3774+ *buflen *= 2;
3775+ *pline = line;
3776+ line = *buf;
3777+ safe_realloc (buf, *buflen);
3778+ line = *buf + (*pline - line);
3779+ }
3780+ if (x)
3781+ {
3782+ *line++ = ',';
3783+ len--;
3784+ }
3785+
3786+#if 0
3787+ if (data->entries[x].first == data->entries[x].last)
3788+ snprintf (line, len, "%d%n", data->entries[x].first, &i);
3789+ else
3790+ snprintf (line, len, "%d-%d%n",
3791+ data->entries[x].first, data->entries[x].last, &i);
3792+ len -= i;
3793+ line += i;
3794+#else
3795+ i = puti (line, data->entries[x].first);
3796+ line +=i; len -= i;
3797+ if (data->entries[x].first != data->entries[x].last)
3798+ {
3799+ *line++ = '-';
3800+ len--;
3801+ i = puti (line, data->entries[x].last);
3802+ line +=i; len -= i;
3803+ }
3804+#endif
3805+ }
3806+ *line++ = '\n';
3807+ *line = '\0';
3808+ *pline = line;
3809+}
3810+
3811+void newsrc_gen_entries (CONTEXT *ctx)
3812+{
3813+ NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3814+ int series, x;
3815+ unsigned int last = 0, first = 1;
3816+ int save_sort = SORT_ORDER;
3817+
3818+ if (Sort != SORT_ORDER)
3819+ {
3820+ save_sort = Sort;
3821+ Sort = SORT_ORDER;
3822+ mutt_sort_headers (ctx, 0);
3823+ }
3824+
3825+ if (!data->max)
3826+ {
3827+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3828+ data->max = 5;
3829+ }
3830+
3831+ /*
3832+ * Set up to fake initial sequence from 1 to the article before the
3833+ * first article in our list
3834+ */
3835+ data->num = 0;
3836+ series = 1;
3837+
3838+ for (x = 0; x < ctx->msgcount; x++)
3839+ {
3840+ if (series) /* search for first unread */
3841+ {
3842+ /*
3843+ * We don't actually check sequential order, since we mark
3844+ * "missing" entries as read/deleted
3845+ */
3846+ last = ctx->hdrs[x]->article_num;
3847+ if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3848+ !ctx->hdrs[x]->read)
3849+ {
3850+ if (data->num >= data->max)
3851+ {
3852+ data->max = data->max * 2;
3853+ safe_realloc (&data->entries,
3854+ data->max * sizeof (NEWSRC_ENTRY));
3855+ }
3856+ data->entries[data->num].first = first;
3857+ data->entries[data->num].last = last - 1;
3858+ data->num++;
3859+ series = 0;
3860+ }
3861+ }
3862+ else /* search for first read */
3863+ {
3864+ if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3865+ {
3866+ first = last + 1;
3867+ series = 1;
3868+ }
3869+ last = ctx->hdrs[x]->article_num;
3870+ }
3871+ }
3872+ if (series && first <= data->lastLoaded)
3873+ {
3874+ if (data->num >= data->max)
3875+ {
3876+ data->max = data->max * 2;
3877+ safe_realloc (&data->entries,