- properly handle db/gdbm/qdbm/tokyocabinet selection; don't "BR'em all"
[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
bebcbf73
AG
12diff -udprP mutt-1.5.19.orig/ChangeLog.nntp mutt-1.5.19/ChangeLog.nntp
13--- mutt-1.5.19.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14+++ mutt-1.5.19/ChangeLog.nntp 2009-01-06 22:27:38.000000000 +0200
15@@ -0,0 +1,363 @@
16+* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua>
17+- update to 1.5.19
18+
19+* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua>
20+- update to 1.5.18
21+- fixed SIGSEGV when followup or forward to newsgroup
22+
23+* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua>
24+- update to 1.5.17
25+
26+* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua>
27+- fixed arguments of nntp_format_str()
28+
ce1255c1
JB
29+* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua>
30+- fixed error selecting news group
31+
32+* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua>
33+- update to 1.5.16
34+
e1bffe0b
JB
35+* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
36+- fixed posting error if $smtp_url is set
37+- added support of print-style sequence %R (x-comment-to)
38+
39+* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
40+- update to 1.5.15
41+- nntp://... url changed to news://...
42+- added indicator of fetching descriptions progress
43+
44+* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
45+- update to 1.5.14
46+
95768aa9 47+* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
48+- update to 1.5.13
49+
50+* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
51+- update to 1.5.12
52+- fixed reading empty .newsrc
53+
54+* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
55+- update to 1.5.11
56+
57+* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
58+- update to 1.5.10
59+
60+* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
61+- update to 1.5.9
62+
63+* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
64+- update to 1.5.8
65+
66+* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
67+- update to 1.5.7
68+- function mutt_update_list_file() moved to newsrc.c and changed algorithm
69+
70+* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
71+- fixed error in nntp_logout_all()
72+
73+* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
74+- fixed debug output in mutt_newsrc_update()
75+- added optional support of LISTGROUP command
76+- fixed typo in nntp_parse_xref()
77+
78+* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
79+- update to 1.5.6
80+
81+* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
82+- fixed compose menu
83+
84+* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
85+- update to 1.5.5.1
86+
87+* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
88+- update to 1.5.5
89+- added space after newsgroup name in .newsrc file
90+
91+* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
92+- nntp patch: fixed SIGSEGV when posting article
93+
94+* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
95+- update to 1.5.4
96+
97+* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
98+- update to 1.5.3
99+- replace safe_free calls by the FREE macro
100+
101+* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
102+- update to 1.5.2
103+- nntp authentication can be passed after any command
104+
105+* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
106+- update to 1.5.1
107+
108+* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
109+- update to 1.3.99
110+
111+* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
112+- update to 1.3.28
113+- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
114+ <reconstruct-thread> functions
115+- fixed message about nntp reconnect
116+- fixed <attach-news-message> function using browser
117+- added support of Followup-To: poster
118+- added %n (new articles) in group_index_format
119+- posting articles without inews by default
120+
121+* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
122+- update to 1.3.27
123+
124+* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
125+- update to 1.3.26
126+
127+* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
128+- update to 1.3.25
129+- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
130+- added default content disposition
131+
132+* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
133+- update to 1.3.24
134+
135+* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
136+- update to 1.3.23.2
137+- fixed segfault if mutt_conn_find() returns null
138+
139+* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
140+- update to 1.3.23.1
141+- added support of LISTGROUP command
142+- added support for servers with broken overview
143+- disabled <flag-message> function on news server
144+- fixed error storing bad authentication information
145+
146+* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
147+- update to 1.3.23
148+- fixed typo in buffy.c
149+- added substitution of %s parameter in $inews variable
150+
151+* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
152+- update to 1.3.22.1
153+- update to 1.3.22
154+
155+* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
156+- update to 1.3.21
157+
158+* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
159+- update to 1.3.20
160+- removed 'server-hook', use 'account-hook' instead
161+- fixed error opening NNTP server without newsgroup using -f option
162+
163+* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
164+- update to 1.3.19
165+
166+* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
167+- update to 1.3.18
168+- fixed typo in nntp_attempt_features()
169+- changed algorithm of XGTITLE command testing
170+- disabled writing of NNTP password in debug file
171+- fixed reading and writing of long newsrc lines
172+- changed checking of last line while reading lines from server
173+- fixed possible buffer overrun in nntp_parse_newsrc_line()
174+- removed checking of XHDR command
175+- compare NNTP return codes without trailing space
176+
177+* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
178+- update to 1.3.17
179+- support for 'LIST NEWSGROUPS' command to read descriptions
180+
181+* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
182+- update to 1.3.16
183+
184+* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
185+- update to 1.3.15
186+
187+* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
188+- update to 1.3.14
189+- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
190+
191+* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
192+- update to 1.3.13
193+
194+* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
195+- Fixed problem if last article in group is deleted
196+
197+* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
198+- Fixed checking of XGTITLE command on some servers
199+
200+* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
201+- Added \r in AUTHINFO commands
202+
203+* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
204+- update to 1.3.12
205+
206+* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
207+- update to 1.3.11
208+- fixed error opening newsgroup from mutt started with -g or -G
209+
210+* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
211+- update to 1.3.10
212+- hotkey 'G' (get-message) replaced with '^G'
213+
214+* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
215+- update to 1.3.9
216+- changed delay displaying error messages from 1 to 2 seconds
217+- fixed error compiling with nntp and without imap
218+
219+* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
220+- fixed catchup in index
221+- fixed nntp_open_mailbox()
222+
223+* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
224+- functions <edit> and <delete-entry> disabled
225+- format of news mailbox names changed to url form
226+- option nntp_attempts removed
227+- option reconnect_news renamed to nntp_reconnect
228+- default value of nntp_poll changed from 30 to 60
229+- error handling improved
230+
231+* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
232+- update to 1.3.8
233+- new option show_only_unread
234+- add newsgroup completion
235+
236+* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
237+- update to 1.3.7
238+
239+* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
240+- update to 1.3.6
241+
242+* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
243+- update to 1.3.5
244+- authentication code update
245+- fix for changing to newsgroup from mailbox with read messages
246+- socket code optimization
247+
248+* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
249+- update to 1.3.4
250+
251+* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
252+- don't substitute current newsgroup with deleted new messages
253+
254+* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
255+- update to 1.3.3
256+- fix for substitution of newsgroup after reconnection
257+- fix for loading newsgroups with very long names
258+- fix for loading more than 32768 newsgroups
259+
260+* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
261+- update to 1.3.2
262+
263+* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
264+- update to 1.3.1
265+
266+* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
267+- update to 1.3
268+
269+* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
270+- update to 1.2
271+
272+* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
273+- update to 1.1.14
274+
275+* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
276+- update to 1.1.12
277+
278+* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
279+- add substitution of newsgroup with new messages by default
280+
281+* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
282+- add attach message from newsgroup
283+- add one-line help in newsreader mode
284+- disable 'change-dir' command in newsgroups browser
285+- add -G option
286+
287+* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
288+- get default newsserver name from file /etc/nntpserver
289+- use case insensitive server names
290+- add print-style sequence %s to $newsrc
291+- add -g option
292+
293+* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
294+- remove 'X-FTN-Origin' header processing
295+
296+* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
297+- update to 1.1.11
298+- update to 1.1.10
299+
300+* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
301+- fix mutt_select_newsserver()
302+- remove 'toggle-mode' function
303+- add 'change-newsgroup' function
304+
305+* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
306+- fix server-hook
307+
308+* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
309+- fix error 'bounce' function after 'post'
310+- add 'forward to newsgroup' function
311+
312+* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
313+- 'forward' function works in newsreader mode
314+- add 'post' and 'followup' functions to pager and attachment menu
315+- fix active descriptions and allowed flag reload
316+
317+* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
318+- update to 1.1.9
319+- remove deleted newsgroups from list
320+
321+* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
322+- update .newsrc in browser
323+
324+* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
325+- reload .newsrc if externally modified
326+- fix active cache update
327+
328+* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
329+- update to 1.1.8
330+
331+* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
332+- patch *.update_list_file is not required
333+- count lines when loading descriptions
334+- remove cache of unsubscribed newsgroups
335+
336+* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
337+- load list of newsgroups from cache faster
338+
339+* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
340+- update to 1.1.7
341+
342+* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
343+- fix unread messages in browser
344+- fix newsrc_gen_entries()
345+
346+* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
347+- fix mutt_newsgroup_stat()
348+- fix nntp_delete_cache()
349+- fix nntp_get_status()
350+- fix check_children()
351+- fix nntp_fetch_headers()
352+
353+* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
354+- update to 1.1.5
355+
356+* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
357+- fix updating new messages in cache
358+
359+* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
360+- change default cache filenames
361+- fix updating new messages in cache
362+
363+* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
364+- fix segmentation fault in news groups browser
365+
366+* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
367+- update to 1.1.4
368+
369+* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
370+- update to 1.1.3
371+
372+* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
373+- add X-Comment-To editing
374+- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
375+- add variables $ask_followup_to and $ask_x_comment_to
376+
377+* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
378+- update to 1.1.2
bebcbf73
AG
379diff -udprP mutt-1.5.19.orig/OPS mutt-1.5.19/OPS
380--- mutt-1.5.19.orig/OPS 2008-03-19 22:07:57.000000000 +0200
381+++ mutt-1.5.19/OPS 2009-01-06 22:27:38.000000000 +0200
382@@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
383 OP_BROWSER_NEW_FILE "select a new file in this directory"
384 OP_BROWSER_VIEW_FILE "view file"
385 OP_BROWSER_TELL "display the currently selected file's name"
386-OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
387-OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
388+OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
389+OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
390 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
391 OP_BUFFY_LIST "list mailboxes with new mail"
392+OP_CATCHUP "mark all articles in newsgroup as read"
393 OP_CHANGE_DIRECTORY "change directories"
394 OP_CHECK_NEW "check mailboxes for new mail"
395 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
396 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
397+OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message"
398 OP_COMPOSE_EDIT_BCC "edit the BCC list"
399 OP_COMPOSE_EDIT_CC "edit the CC list"
400 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
401@@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
402 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
403 OP_COMPOSE_EDIT_MESSAGE "edit the message"
404 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
405+OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
406 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
407+OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
408+OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
409 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
410 OP_COMPOSE_EDIT_TO "edit the TO list"
411 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
412@@ -85,8 +90,13 @@ OP_EXIT "exit this menu"
413 OP_FILTER "filter attachment through a shell command"
414 OP_FIRST_ENTRY "move to the first entry"
415 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
416+OP_FOLLOWUP "followup to newsgroup"
417+OP_FORWARD_TO_GROUP "forward to newsgroup"
418 OP_FORWARD_MESSAGE "forward a message with comments"
419 OP_GENERIC_SELECT_ENTRY "select the current entry"
420+OP_GET_CHILDREN "get all children of the current message"
421+OP_GET_MESSAGE "get message with Message-Id"
422+OP_GET_PARENT "get parent of the current message"
423 OP_GROUP_REPLY "reply to all recipients"
424 OP_HALF_DOWN "scroll down 1/2 page"
425 OP_HALF_UP "scroll up 1/2 page"
426@@ -94,11 +104,14 @@ OP_HELP "this screen"
427 OP_JUMP "jump to an index number"
428 OP_LAST_ENTRY "move to the last entry"
429 OP_LIST_REPLY "reply to specified mailing list"
430+OP_LOAD_ACTIVE "load active file from NNTP server"
431 OP_MACRO "execute a macro"
432 OP_MAIL "compose a new mail message"
433 OP_MAIN_BREAK_THREAD "break the thread in two"
434 OP_MAIN_CHANGE_FOLDER "open a different folder"
435 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
436+OP_MAIN_CHANGE_GROUP "open a different newsgroup"
437+OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
438 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
439 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
440 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
441@@ -137,6 +150,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
442 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
443 OP_PAGER_TOP "jump to the top of the message"
444 OP_PIPE "pipe message/attachment to a shell command"
445+OP_POST "post message to newsgroup"
446 OP_PREV_ENTRY "move to the previous entry"
447 OP_PREV_LINE "scroll up one line"
448 OP_PREV_PAGE "move to the previous page"
449@@ -145,6 +159,7 @@ OP_QUERY "query external program for add
450 OP_QUERY_APPEND "append new query results to current results"
451 OP_QUIT "save changes to mailbox and quit"
452 OP_RECALL_MESSAGE "recall a postponed message"
453+OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
454 OP_REDRAW "clear and redraw the screen"
455 OP_REFORMAT_WINCH "{internal}"
456 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
457@@ -159,18 +174,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
458 OP_SHELL_ESCAPE "invoke a command in a subshell"
459 OP_SORT "sort messages"
460 OP_SORT_REVERSE "sort messages in reverse order"
461+OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
462 OP_TAG "tag the current entry"
463 OP_TAG_PREFIX "apply next function to tagged messages"
464 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
465 OP_TAG_SUBTHREAD "tag the current subthread"
466 OP_TAG_THREAD "tag the current thread"
467 OP_TOGGLE_NEW "toggle a message's 'new' flag"
468+OP_TOGGLE_READ "toggle view of read messages"
469 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
470 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
471 OP_TOP_PAGE "move to the top of the page"
472+OP_UNCATCHUP "mark all articles in newsgroup as unread"
473 OP_UNDELETE "undelete the current entry"
474 OP_UNDELETE_THREAD "undelete all messages in thread"
475 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
476+OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
477 OP_VERSION "show the Mutt version number and date"
478 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
479 OP_VIEW_ATTACHMENTS "show MIME attachments"
480diff -udprP mutt-1.5.19.orig/PATCHES mutt-1.5.19/PATCHES
481--- mutt-1.5.19.orig/PATCHES 2008-03-19 22:07:06.000000000 +0200
482+++ mutt-1.5.19/PATCHES 2009-01-06 22:27:38.000000000 +0200
483@@ -0,0 +1 @@
484+vvv.nntp
485diff -udprP mutt-1.5.19.orig/account.c mutt-1.5.19/account.c
486--- mutt-1.5.19.orig/account.c 2008-10-30 02:30:17.000000000 +0200
487+++ mutt-1.5.19/account.c 2009-01-06 22:27:38.000000000 +0200
488@@ -51,6 +51,11 @@ int mutt_account_match (const ACCOUNT* a
489 user = PopUser;
490 #endif
491
492+#ifdef USE_NNTP
493+ if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
494+ user = NntpUser;
495+#endif
496+
497 if (a1->flags & a2->flags & M_ACCT_USER)
498 return (!strcmp (a1->user, a2->user));
499 if (a1->flags & M_ACCT_USER)
500@@ -130,6 +135,16 @@ void mutt_account_tourl (ACCOUNT* accoun
501 }
502 #endif
95768aa9 503
bebcbf73
AG
504+#ifdef USE_NNTP
505+ if (account->type == M_ACCT_TYPE_NNTP)
506+ {
507+ if (account->flags & M_ACCT_SSL)
508+ url->scheme = U_NNTPS;
509+ else
510+ url->scheme = U_NNTP;
511+ }
512+#endif
513+
514 url->host = account->host;
515 if (account->flags & M_ACCT_PORT)
516 url->port = account->port;
517@@ -155,6 +170,10 @@ int mutt_account_getuser (ACCOUNT* accou
518 else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
519 strfcpy (account->user, PopUser, sizeof (account->user));
520 #endif
521+#ifdef USE_NNTP
522+ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
523+ strfcpy (account->user, NntpUser, sizeof (account->user));
524+#endif
525 /* prompt (defaults to unix username), copy into account->user */
526 else
527 {
528@@ -215,6 +234,10 @@ int mutt_account_getpass (ACCOUNT* accou
529 else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass)
530 strfcpy (account->pass, SmtpPass, sizeof (account->pass));
531 #endif
532+#ifdef USE_NNTP
533+ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
534+ strfcpy (account->pass, NntpPass, sizeof (account->pass));
535+#endif
536 else
537 {
538 snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
539diff -udprP mutt-1.5.19.orig/account.h mutt-1.5.19/account.h
540--- mutt-1.5.19.orig/account.h 2008-03-19 22:07:06.000000000 +0200
541+++ mutt-1.5.19/account.h 2009-01-06 22:27:38.000000000 +0200
542@@ -29,7 +29,8 @@ enum
543 M_ACCT_TYPE_NONE = 0,
544 M_ACCT_TYPE_IMAP,
545 M_ACCT_TYPE_POP,
546- M_ACCT_TYPE_SMTP
547+ M_ACCT_TYPE_SMTP,
548+ M_ACCT_TYPE_NNTP
549 };
ce1255c1
JB
550
551 /* account flags */
bebcbf73
AG
552diff -udprP mutt-1.5.19.orig/attach.h mutt-1.5.19/attach.h
553--- mutt-1.5.19.orig/attach.h 2008-03-19 22:07:06.000000000 +0200
554+++ mutt-1.5.19/attach.h 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
555@@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f
556
557 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
558 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
559-void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
560+void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
561 void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
562
563 #endif /* _ATTACH_H_ */
bebcbf73
AG
564diff -udprP mutt-1.5.19.orig/browser.c mutt-1.5.19/browser.c
565--- mutt-1.5.19.orig/browser.c 2009-01-06 01:36:28.000000000 +0200
566+++ mutt-1.5.19/browser.c 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
567@@ -32,6 +32,9 @@
568 #ifdef USE_IMAP
569 #include "imap.h"
570 #endif
571+#ifdef USE_NNTP
572+#include "nntp.h"
573+#endif
574
575 #include <stdlib.h>
576 #include <dirent.h>
577@@ -49,6 +52,19 @@ static struct mapping_t FolderHelp[] = {
578 { NULL }
579 };
580
581+#ifdef USE_NNTP
582+static struct mapping_t FolderNewsHelp[] = {
583+ { N_("Exit"), OP_EXIT },
584+ { N_("List"), OP_TOGGLE_MAILBOXES },
585+ { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
586+ { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
587+ { N_("Catchup"), OP_CATCHUP },
588+ { N_("Mask"), OP_ENTER_MASK },
589+ { N_("Help"), OP_HELP },
590+ { NULL }
591+};
592+#endif
593+
594 typedef struct folder_t
595 {
596 struct folder_file *ff;
597@@ -114,9 +130,17 @@ static void browser_sort (struct browser
598 case SORT_ORDER:
599 return;
600 case SORT_DATE:
601+#ifdef USE_NNTP
602+ if (option (OPTNEWS))
603+ return;
604+#endif
605 f = browser_compare_date;
606 break;
607 case SORT_SIZE:
608+#ifdef USE_NNTP
609+ if (option (OPTNEWS))
610+ return;
611+#endif
612 f = browser_compare_size;
613 break;
614 case SORT_SUBJECT:
615@@ -307,8 +331,106 @@ folder_format_str (char *dest, size_t de
616 return (src);
617 }
618
619+#ifdef USE_NNTP
620+static const char *
621+newsgroup_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
622+ const char *fmt, const char *ifstring, const char *elsestring,
623+ unsigned long data, format_flag flags)
624+{
625+ char fn[SHORT_STRING], tmp[SHORT_STRING];
626+ FOLDER *folder = (FOLDER *) data;
627+
628+ switch (op)
629+ {
630+ case 'C':
631+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
632+ snprintf (dest, destlen, tmp, folder->num + 1);
633+ break;
634+
635+ case 'f':
636+ strncpy (fn, folder->ff->name, sizeof(fn) - 1);
637+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
638+ snprintf (dest, destlen, tmp, fn);
639+ break;
640+
641+ case 'N':
642+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
643+ if (folder->ff->nd->subscribed)
644+ snprintf (dest, destlen, tmp, ' ');
645+ else
646+ snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
647+ break;
648+
649+ case 'M':
650+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
651+ if (folder->ff->nd->deleted)
652+ snprintf (dest, destlen, tmp, 'D');
653+ else
654+ snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
655+ break;
656+
657+ case 's':
658+ if (flags & M_FORMAT_OPTIONAL)
659+ {
660+ if (folder->ff->nd->unread != 0)
661+ mutt_FormatString (dest, destlen, col, ifstring, newsgroup_format_str,
662+ data, flags);
663+ else
664+ mutt_FormatString (dest, destlen, col, elsestring, newsgroup_format_str,
665+ data, flags);
666+ }
667+ else if (Context && Context->data == folder->ff->nd)
668+ {
669+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
670+ snprintf (dest, destlen, tmp, Context->unread);
671+ }
672+ else
673+ {
674+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
675+ snprintf (dest, destlen, tmp, folder->ff->nd->unread);
676+ }
677+ break;
678+
679+ case 'n':
680+ if (Context && Context->data == folder->ff->nd)
681+ {
682+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
683+ snprintf (dest, destlen, tmp, Context->new);
684+ }
685+ else if (option (OPTMARKOLD) &&
686+ folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
687+ folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
688+ {
689+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
690+ snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
691+ }
692+ else
693+ {
694+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
695+ snprintf (dest, destlen, tmp, folder->ff->nd->unread);
696+ }
697+ break;
698+
699+ case 'd':
700+ if (folder->ff->nd->desc != NULL)
701+ {
702+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
703+ snprintf (dest, destlen, tmp, folder->ff->nd->desc);
704+ }
705+ else
706+ {
707+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
708+ snprintf (dest, destlen, tmp, "");
709+ }
710+ break;
711+ }
712+ return (src);
713+}
714+#endif /* USE_NNTP */
715+
716 static void add_folder (MUTTMENU *m, struct browser_state *state,
717- const char *name, const struct stat *s, int new)
718+ const char *name, const struct stat *s,
719+ void *data, int new)
720 {
721 if (state->entrylen == state->entrymax)
722 {
723@@ -337,6 +459,10 @@ static void add_folder (MUTTMENU *m, str
724 #ifdef USE_IMAP
725 (state->entry)[state->entrylen].imap = 0;
726 #endif
727+#ifdef USE_NNTP
728+ if (option (OPTNEWS))
729+ (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
730+#endif
731 (state->entrylen)++;
732 }
733
734@@ -352,9 +478,35 @@ static void init_state (struct browser_s
735 menu->data = state->entry;
736 }
737
738+/* get list of all files/newsgroups with mask */
739 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
740 char *d, const char *prefix)
741 {
742+#ifdef USE_NNTP
743+ if (option (OPTNEWS))
744+ {
745+ LIST *tmp;
746+ NNTP_DATA *data;
747+ NNTP_SERVER *news = CurrentNewsSrv;
748+
749+/* mutt_buffy_check (0); */
750+ init_state (state, menu);
751+
752+ for (tmp = news->list; tmp; tmp = tmp->next)
753+ {
754+ if (!(data = (NNTP_DATA *)tmp->data))
755+ continue;
756+ if (prefix && *prefix && strncmp (prefix, data->group,
757+ strlen (prefix)) != 0)
758+ continue;
759+ if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
760+ continue;
761+ add_folder (menu, state, data->group, NULL, data, data->new);
762+ }
763+ }
764+ else
765+#endif /* USE_NNTP */
766+ {
767 struct stat s;
768 DIR *dp;
769 struct dirent *de;
770@@ -415,17 +567,40 @@ static int examine_directory (MUTTMENU *
771 tmp = Incoming;
772 while (tmp && mutt_strcmp (buffer, tmp->path))
773 tmp = tmp->next;
774- add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
775+ add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
776+ }
777+ closedir (dp);
778 }
779- closedir (dp);
780 browser_sort (state);
781 return 0;
782 }
783
784+/* get list of mailboxes/subscribed newsgroups */
785 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
786 {
787 struct stat s;
788 char buffer[LONG_STRING];
789+
790+#ifdef USE_NNTP
791+ if (option (OPTNEWS))
792+ {
793+ LIST *tmp;
794+ NNTP_DATA *data;
795+ NNTP_SERVER *news = CurrentNewsSrv;
796+
797+/* mutt_buffy_check (0); */
798+ init_state (state, menu);
799+
800+ for (tmp = news->list; tmp; tmp = tmp->next)
801+ {
802+ if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
803+ (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
804+ add_folder (menu, state, data->group, NULL, data, data->new);
805+ }
806+ }
807+ else
808+#endif
809+ {
810 BUFFY *tmp = Incoming;
811 #ifdef USE_IMAP
812 struct mailbox_state mbox;
813@@ -443,14 +618,21 @@ static int examine_mailboxes (MUTTMENU *
814 if (mx_is_imap (tmp->path))
815 {
816 imap_mailbox_state (tmp->path, &mbox);
817- add_folder (menu, state, tmp->path, NULL, mbox.new);
818+ add_folder (menu, state, tmp->path, NULL, NULL, mbox.new);
819 continue;
820 }
821 #endif
822 #ifdef USE_POP
823 if (mx_is_pop (tmp->path))
824 {
825- add_folder (menu, state, tmp->path, NULL, tmp->new);
826+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
827+ continue;
828+ }
829+#endif
830+#ifdef USE_NNTP
831+ if (mx_is_nntp (tmp->path))
832+ {
833+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
834 continue;
835 }
836 #endif
837@@ -464,15 +646,20 @@ static int examine_mailboxes (MUTTMENU *
838 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
bebcbf73 839 mutt_pretty_mailbox (buffer, sizeof (buffer));
ce1255c1
JB
840
841- add_folder (menu, state, buffer, &s, tmp->new);
842+ add_folder (menu, state, buffer, &s, NULL, tmp->new);
843 }
844 while ((tmp = tmp->next));
845+ }
846 browser_sort (state);
847 return 0;
848 }
849
850 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
851 {
852+#ifdef USE_NNTP
853+ if (option (OPTNEWS))
854+ return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
855+#endif
856 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
857 }
858
859@@ -483,6 +670,12 @@ static void folder_entry (char *s, size_
860 folder.ff = &((struct folder_file *) menu->data)[num];
861 folder.num = num;
862
863+#ifdef USE_NNTP
864+ if (option (OPTNEWS))
865+ mutt_FormatString (s, slen, 0, NONULL(GroupFormat), newsgroup_format_str,
866+ (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
867+ else
868+#endif
869 mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str,
870 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
871 }
872@@ -503,6 +696,17 @@ static void init_menu (struct browser_st
873
874 menu->tagged = 0;
875
876+#ifdef USE_NNTP
877+ if (option (OPTNEWS))
878+ {
879+ if (buffy)
880+ snprintf (title, titlelen, _("Subscribed newsgroups"));
881+ else
882+ snprintf (title, titlelen, _("Newsgroups on server [%s]"),
883+ CurrentNewsSrv->conn->account.host);
884+ }
885+ else
886+#endif
887 if (buffy)
888 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
889 else
890@@ -558,6 +762,31 @@ void _mutt_select_file (char *f, size_t
891 if (!folder)
892 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
893
894+#ifdef USE_NNTP
895+ if (option (OPTNEWS))
896+ {
897+ if (*f)
898+ strfcpy (prefix, f, sizeof (prefix));
899+ else
900+ {
901+ LIST *list;
902+
903+ /* default state for news reader mode is browse subscribed newsgroups */
904+ buffy = 0;
905+ for (list = CurrentNewsSrv->list; list; list = list->next)
906+ {
907+ NNTP_DATA *data = (NNTP_DATA *) list->data;
908+
909+ if (data && data->subscribed)
910+ {
911+ buffy = 1;
912+ break;
913+ }
914+ }
915+ }
916+ }
917+ else
918+#endif
919 if (*f)
920 {
921 mutt_expand_path (f, flen);
bebcbf73 922@@ -654,6 +883,9 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
923 menu->tag = file_tag;
924
925 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
926+#ifdef USE_NNTP
927+ (option (OPTNEWS)) ? FolderNewsHelp :
928+#endif
929 FolderHelp);
930
931 init_menu (&state, menu, title, sizeof (title), buffy);
bebcbf73 932@@ -792,7 +1024,11 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
933 }
934 }
935
936+#ifdef USE_NNTP
937+ if (buffy || option (OPTNEWS)) /* news have not path */
938+#else
939 if (buffy)
940+#endif
941 {
942 strfcpy (f, state.entry[menu->current].name, flen);
943 mutt_expand_path (f, flen);
bebcbf73 944@@ -850,14 +1086,6 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
945 break;
946
947 #ifdef USE_IMAP
948- case OP_BROWSER_SUBSCRIBE:
949- imap_subscribe (state.entry[menu->current].name, 1);
950- break;
951-
952- case OP_BROWSER_UNSUBSCRIBE:
953- imap_subscribe (state.entry[menu->current].name, 0);
954- break;
955-
956 case OP_BROWSER_TOGGLE_LSUB:
957 if (option (OPTIMAPLSUB))
bebcbf73
AG
958 unset_option (OPTIMAPLSUB);
959@@ -958,6 +1186,11 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
960
961 case OP_CHANGE_DIRECTORY:
962
963+#ifdef USE_NNTP
964+ if (option (OPTNEWS))
965+ break;
966+#endif
967+
968 strfcpy (buf, LastDir, sizeof (buf));
969 #ifdef USE_IMAP
970 if (!state.imap_browse)
bebcbf73 971@@ -1224,6 +1457,190 @@ void _mutt_select_file (char *f, size_t
ce1255c1
JB
972 else
973 mutt_error _("Error trying to view file");
974 }
975+ break;
976+
977+#ifdef USE_NNTP
978+ case OP_CATCHUP:
979+ case OP_UNCATCHUP:
980+ if (option (OPTNEWS))
981+ {
982+ struct folder_file *f = &state.entry[menu->current];
983+ NNTP_DATA *nd;
984+
985+ if (i == OP_CATCHUP)
986+ nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
987+ else
988+ nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
989+
990+ if (nd)
991+ {
992+/* FOLDER folder;
993+ struct folder_file ff;
994+ char buffer[_POSIX_PATH_MAX + SHORT_STRING];
995+
996+ folder.ff = &ff;
997+ folder.ff->name = f->name;
998+ folder.ff->st = NULL;
999+ folder.ff->is_new = nd->new;
1000+ folder.ff->nd = nd;
1001+ FREE (&f->desc);
1002+ mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1003+ newsgroup_format_str, (unsigned long) &folder,
1004+ M_FORMAT_ARROWCURSOR);
1005+ f->desc = safe_strdup (buffer); */
1006+ if (menu->current + 1 < menu->max)
1007+ menu->current++;
1008+ menu->redraw = REDRAW_MOTION_RESYNCH;
1009+ }
1010+ }
1011+ break;
1012+
1013+ case OP_LOAD_ACTIVE:
1014+ if (!option (OPTNEWS))
1015+ break;
1016+
1017+ {
1018+ LIST *tmp;
1019+ NNTP_DATA *data;
1020+
1021+ for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
1022+ {
1023+ if ((data = (NNTP_DATA *)tmp->data))
1024+ data->deleted = 1;
1025+ }
1026+ }
1027+ nntp_get_active (CurrentNewsSrv);
1028+
1029+ destroy_state (&state);
1030+ if (buffy)
1031+ examine_mailboxes (menu, &state);
1032+ else
1033+ examine_directory (menu, &state, NULL, NULL);
1034+ init_menu (&state, menu, title, sizeof (title), buffy);
1035+ break;
1036+#endif /* USE_NNTP */
1037+
1038+#if defined USE_IMAP || defined USE_NNTP
1039+ case OP_BROWSER_SUBSCRIBE:
1040+ case OP_BROWSER_UNSUBSCRIBE:
1041+#endif
1042+#ifdef USE_NNTP
1043+ case OP_SUBSCRIBE_PATTERN:
1044+ case OP_UNSUBSCRIBE_PATTERN:
1045+ if (option (OPTNEWS))
1046+ {
1047+ regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1048+ char *s = buf;
1049+ int j = menu->current;
1050+ NNTP_DATA *nd;
1051+ NNTP_SERVER *news = CurrentNewsSrv;
1052+
1053+ if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1054+ {
1055+ char tmp[STRING];
1056+ int err;
1057+
1058+ buf[0] = 0;
1059+ if (i == OP_SUBSCRIBE_PATTERN)
1060+ snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1061+ else
1062+ snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1063+ if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1064+ {
1065+ FREE (&rx);
1066+ break;
1067+ }
1068+
1069+ if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1070+ {
1071+ regerror (err, rx, buf, sizeof (buf));
1072+ regfree (rx);
1073+ FREE (&rx);
1074+ mutt_error ("%s", buf);
1075+ break;
1076+ }
1077+ menu->redraw = REDRAW_FULL;
1078+ j = 0;
1079+ }
1080+ else if (!state.entrylen)
1081+ {
1082+ mutt_error _("No newsgroups match the mask");
1083+ break;
1084+ }
1085+
1086+ for ( ; j < state.entrylen; j++)
1087+ {
1088+ struct folder_file *f = &state.entry[j];
1089+
1090+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1091+ regexec (rx, f->name, 0, NULL, 0) == 0)
1092+ {
1093+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1094+ nd = mutt_newsgroup_subscribe (news, f->name);
1095+ else
1096+ nd = mutt_newsgroup_unsubscribe (news, f->name);
1097+/* if (nd)
1098+ {
1099+ FOLDER folder;
1100+ char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1101+
1102+ folder.name = f->name;
1103+ folder.f = NULL;
1104+ folder.new = nd->new;
1105+ folder.nd = nd;
1106+ FREE (&f->desc);
1107+ mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1108+ newsgroup_format_str, (unsigned long) &folder,
1109+ M_FORMAT_ARROWCURSOR);
1110+ f->desc = safe_strdup (buffer);
1111+ } */
1112+ }
1113+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1114+ {
1115+ if (menu->current + 1 < menu->max)
1116+ menu->current++;
1117+ menu->redraw = REDRAW_MOTION_RESYNCH;
1118+ break;
1119+ }
1120+ }
1121+ if (i == OP_SUBSCRIBE_PATTERN)
1122+ {
1123+ LIST *grouplist = NULL;
1124+
1125+ if (news)
1126+ grouplist = news->list;
1127+ for (; grouplist; grouplist = grouplist->next)
1128+ {
1129+ nd = (NNTP_DATA *) grouplist->data;
1130+ if (nd && nd->group && !nd->subscribed)
1131+ {
1132+ if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1133+ {
1134+ mutt_newsgroup_subscribe (news, nd->group);
1135+ add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1136+ }
1137+ }
1138+ }
1139+ init_menu (&state, menu, title, sizeof (title), buffy);
1140+ }
1141+ mutt_newsrc_update (news);
1142+ nntp_clear_cacheindex (news);
1143+ if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1144+ regfree (rx);
1145+ FREE (&rx);
1146+ }
1147+#ifdef USE_IMAP
1148+ else
1149+#endif /* USE_IMAP && USE_NNTP */
1150+#endif /* USE_NNTP */
1151+#ifdef USE_IMAP
1152+ {
1153+ if (i == OP_BROWSER_SUBSCRIBE)
1154+ imap_subscribe (state.entry[menu->current].name, 1);
1155+ else
1156+ imap_subscribe (state.entry[menu->current].name, 0);
1157+ }
1158+#endif /* USE_IMAP */
1159 }
1160 }
1161
bebcbf73
AG
1162diff -udprP mutt-1.5.19.orig/browser.h mutt-1.5.19/browser.h
1163--- mutt-1.5.19.orig/browser.h 2009-01-05 21:20:53.000000000 +0200
1164+++ mutt-1.5.19/browser.h 2009-01-06 22:27:38.000000000 +0200
1165@@ -19,6 +19,10 @@
ce1255c1
JB
1166 #ifndef _BROWSER_H
1167 #define _BROWSER_H 1
1168
1169+#ifdef USE_NNTP
1170+#include "nntp.h"
1171+#endif
1172+
1173 struct folder_file
1174 {
1175 mode_t mode;
bebcbf73 1176@@ -37,6 +41,9 @@ struct folder_file
ce1255c1
JB
1177 unsigned selectable : 1;
1178 unsigned inferiors : 1;
1179 #endif
1180+#ifdef USE_NNTP
1181+ NNTP_DATA *nd;
1182+#endif
1183 unsigned tagged : 1;
1184 };
1185
bebcbf73
AG
1186diff -udprP mutt-1.5.19.orig/buffy.c mutt-1.5.19/buffy.c
1187--- mutt-1.5.19.orig/buffy.c 2008-08-30 02:39:48.000000000 +0300
1188+++ mutt-1.5.19/buffy.c 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
1189@@ -285,6 +285,9 @@ int mutt_buffy_check (int force)
1190 #ifdef USE_POP
1191 if (!Context || Context->magic != M_POP)
1192 #endif
1193+#ifdef USE_NNTP
1194+ if (!Context || Context->magic != M_NNTP)
1195+#endif
1196 /* check device ID and serial number instead of comparing paths */
1197 if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0)
1198 {
1199@@ -308,6 +311,11 @@ int mutt_buffy_check (int force)
1200 tmp->magic = M_POP;
1201 else
1202 #endif
1203+#ifdef USE_NNTP
1204+ if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1205+ tmp->magic = M_NNTP;
1206+ else
1207+#endif
bebcbf73 1208 if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
ce1255c1
JB
1209 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1210 {
1211@@ -325,25 +333,21 @@ int mutt_buffy_check (int force)
1212 /* check to see if the folder is the currently selected folder
1213 * before polling */
1214 if (!Context || !Context->path ||
1215-#if defined USE_IMAP || defined USE_POP
1216- ((
1217+ (
1218+ (0
1219 #ifdef USE_IMAP
1220- tmp->magic == M_IMAP
1221+ || tmp->magic == M_IMAP
1222 #endif
1223 #ifdef USE_POP
1224-#ifdef USE_IMAP
1225- ||
1226-#endif
1227- tmp->magic == M_POP
1228-#endif
1229- ) ? mutt_strcmp (tmp->path, Context->path) :
1230+ || tmp->magic == M_POP
1231 #endif
1232- (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1233-#if defined USE_IMAP || defined USE_POP
1234- )
1235+#ifdef USE_NNTP
1236+ || tmp->magic == M_NNTP
1237 #endif
1238- )
1239-
1240+ ) ? mutt_strcmp (tmp->path, Context->path) :
1241+ (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1242+ )
1243+ )
1244 {
1245 switch (tmp->magic)
1246 {
bebcbf73
AG
1247diff -udprP mutt-1.5.19.orig/complete.c mutt-1.5.19/complete.c
1248--- mutt-1.5.19.orig/complete.c 2009-01-05 21:20:53.000000000 +0200
1249+++ mutt-1.5.19/complete.c 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
1250@@ -25,6 +25,9 @@
1251 #include "mailbox.h"
1252 #include "imap.h"
1253 #endif
1254+#ifdef USE_NNTP
1255+#include "nntp.h"
1256+#endif
1257
1258 #include <dirent.h>
1259 #include <string.h>
1260@@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen)
1261 char filepart[_POSIX_PATH_MAX];
1262 #ifdef USE_IMAP
1263 char imap_path[LONG_STRING];
1264+#endif
1265
1266 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1267
1268+#ifdef USE_NNTP
1269+ if (option (OPTNEWS))
1270+ {
1271+ LIST *l = CurrentNewsSrv->list;
1272+
1273+ strfcpy (filepart, s, sizeof (filepart));
1274+
1275+ /*
1276+ * special case to handle when there is no filepart yet.
1277+ * find the first subscribed newsgroup
1278+ */
1279+ if ((len = mutt_strlen (filepart)) == 0)
1280+ {
1281+ for (; l; l = l->next)
1282+ {
1283+ NNTP_DATA *data = (NNTP_DATA *)l->data;
1284+
1285+ if (data && data->subscribed)
1286+ {
1287+ strfcpy (filepart, data->group, sizeof (filepart));
1288+ init++;
1289+ l = l->next;
1290+ break;
1291+ }
1292+ }
1293+ }
1294+
1295+ for (; l; l = l->next)
1296+ {
1297+ NNTP_DATA *data = (NNTP_DATA *)l->data;
1298+
1299+ if (data && data->subscribed &&
1300+ mutt_strncmp (data->group, filepart, len) == 0)
1301+ {
1302+ if (init)
1303+ {
1304+ for (i = 0; filepart[i] && data->group[i]; i++)
1305+ {
1306+ if (filepart[i] != data->group[i])
1307+ {
1308+ filepart[i] = 0;
1309+ break;
1310+ }
1311+ }
1312+ filepart[i] = 0;
1313+ }
1314+ else
1315+ {
1316+ strfcpy (filepart, data->group, sizeof (filepart));
1317+ init = 1;
1318+ }
1319+ }
1320+ }
1321+
1322+ strcpy (s, filepart);
1323+
1324+ return (init ? 0 : -1);
1325+ }
1326+#endif
1327+
1328+#ifdef USE_IMAP
1329 /* we can use '/' as a delimiter, imap_complete rewrites it */
1330 if (*s == '=' || *s == '+' || *s == '!')
1331 {
bebcbf73
AG
1332diff -udprP mutt-1.5.19.orig/compose.c mutt-1.5.19/compose.c
1333--- mutt-1.5.19.orig/compose.c 2009-01-05 21:20:53.000000000 +0200
1334+++ mutt-1.5.19/compose.c 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
1335@@ -32,10 +32,15 @@
1336 #include "mailbox.h"
1337 #include "sort.h"
1338 #include "charset.h"
1339+#include "mx.h"
1340
1341 #ifdef MIXMASTER
1342 #include "remailer.h"
1343 #endif
1344+
1345+#ifdef USE_NNTP
1346+#include "nntp.h"
1347+#endif
1348
1349 #include <errno.h>
1350 #include <string.h>
73dfce7f 1351@@ -67,11 +69,17 @@ enum
ce1255c1
JB
1352 HDR_CRYPT,
1353 HDR_CRYPTINFO,
1354
1355+#ifdef USE_NNTP
1356+ HDR_NEWSGROUPS,
1357+ HDR_FOLLOWUPTO,
1358+ HDR_XCOMMENTTO,
1359+#endif
1360+
1361 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1362 };
1363
1364-#define HDR_XOFFSET 10
1365-#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1366+#define HDR_XOFFSET 14
1367+#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1368 #define W (COLS - HDR_XOFFSET)
1369
1370 static char *Prompts[] =
1371@@ -83,6 +91,16 @@ static char *Prompts[] =
1372 "Subject: ",
1373 "Reply-To: ",
1374 "Fcc: "
1375+#ifdef USE_NNTP
1376+#ifdef MIXMASTER
1377+ ,""
1378+#endif
1379+ ,""
1380+ ,""
1381+ ,"Newsgroups: "
1382+ ,"Followup-To: "
1383+ ,"X-Comment-To: "
1384+#endif
1385 };
1386
1387 static struct mapping_t ComposeHelp[] = {
1388@@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] =
1389 { NULL }
1390 };
1391
1392+#ifdef USE_NNTP
1393+static struct mapping_t ComposeNewsHelp[] = {
1394+ { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1395+ { N_("Abort"), OP_EXIT },
1396+ { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1397+ { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1398+ { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1399+ { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1400+ { N_("Help"), OP_HELP },
1401+ { NULL }
1402+};
1403+#endif
1404+
1405 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1406 {
1407 mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt,
1408@@ -115,16 +146,16 @@ static void redraw_crypt_lines (HEADER *
1409 if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
1410 {
1411 if (!msg->security)
1412- mvaddstr (HDR_CRYPT, 0, "Security: ");
1413+ mvaddstr (HDR_CRYPT, 0, " Security: ");
1414 else if (msg->security & APPLICATION_SMIME)
1415- mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1416+ mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1417 else if (msg->security & APPLICATION_PGP)
1418- mvaddstr (HDR_CRYPT, 0, " PGP: ");
1419+ mvaddstr (HDR_CRYPT, 0, " PGP: ");
1420 }
1421 else if ((WithCrypto & APPLICATION_SMIME))
1422- mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1423+ mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1424 else if ((WithCrypto & APPLICATION_PGP))
1425- mvaddstr (HDR_CRYPT, 0, " PGP: ");
1426+ mvaddstr (HDR_CRYPT, 0, " PGP: ");
1427 else
1428 return;
1429
1430@@ -252,9 +283,28 @@ static void draw_envelope_addr (int line
1431 static void draw_envelope (HEADER *msg, char *fcc)
1432 {
1433 draw_envelope_addr (HDR_FROM, msg->env->from);
1434+#ifdef USE_NNTP
1435+ if (!option (OPTNEWSSEND))
1436+ {
1437+#endif
1438 draw_envelope_addr (HDR_TO, msg->env->to);
1439 draw_envelope_addr (HDR_CC, msg->env->cc);
1440 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1441+#ifdef USE_NNTP
1442+ }
1443+ else
1444+ {
1445+ mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1446+ mutt_paddstr (W, NONULL (msg->env->newsgroups));
1447+ mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1448+ mutt_paddstr (W, NONULL (msg->env->followup_to));
1449+ if (option (OPTXCOMMENTTO))
1450+ {
1451+ mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1452+ mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1453+ }
1454+ }
1455+#endif
1456 mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1457 mutt_paddstr (W, NONULL (msg->env->subject));
1458 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1459@@ -507,6 +557,12 @@ int mutt_compose_menu (HEADER *msg, /*
1460 /* Sort, SortAux could be changed in mutt_index_menu() */
1461 int oldSort, oldSortAux;
1462 struct stat st;
1463+#ifdef USE_NNTP
1464+ int news = 0; /* is it a news article ? */
1465+
1466+ if (option (OPTNEWSSEND))
1467+ news++;
1468+#endif
1469
1470 mutt_attach_init (msg->content);
1471 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
bebcbf73 1472@@ -517,10 +573,18 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1473 menu->make_entry = snd_entry;
1474 menu->tag = mutt_tag_attach;
1475 menu->data = idx;
1476+#ifdef USE_NNTP
1477+ if (news)
1478+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1479+ else
1480+#endif
1481 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1482
1483 while (loop)
1484 {
1485+#ifdef USE_NNTP
1486+ unset_option (OPTNEWS); /* for any case */
1487+#endif
1488 switch (op = mutt_menuLoop (menu))
1489 {
1490 case OP_REDRAW:
bebcbf73 1491@@ -533,17 +597,87 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1492 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1493 break;
1494 case OP_COMPOSE_EDIT_TO:
1495+#ifdef USE_NNTP
1496+ if (news)
1497+ break;
1498+#endif
1499 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1500 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1501 break;
1502 case OP_COMPOSE_EDIT_BCC:
1503+#ifdef USE_NNTP
1504+ if (news)
1505+ break;
1506+#endif
1507 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1508 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1509 break;
1510 case OP_COMPOSE_EDIT_CC:
1511+#ifdef USE_NNTP
1512+ if (news)
1513+ break;
1514+#endif
1515 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1516 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1517 break;
1518+#ifdef USE_NNTP
1519+ case OP_COMPOSE_EDIT_NEWSGROUPS:
1520+ if (news)
1521+ {
1522+ if (msg->env->newsgroups)
1523+ strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1524+ else
1525+ buf[0] = 0;
1526+ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1527+ {
1528+ FREE (&msg->env->newsgroups);
1529+ mutt_remove_trailing_ws (buf);
1530+ msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1531+ move (HDR_TO, HDR_XOFFSET);
1532+ clrtoeol ();
1533+ if (msg->env->newsgroups)
1534+ printw ("%-*.*s", W, W, msg->env->newsgroups);
1535+ }
1536+ }
1537+ break;
1538+
1539+ case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1540+ if (news)
1541+ {
1542+ buf[0] = 0;
1543+ if (msg->env->followup_to)
1544+ strfcpy (buf, msg->env->followup_to, sizeof (buf));
1545+ if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1546+ {
1547+ FREE (&msg->env->followup_to);
1548+ mutt_remove_trailing_ws (buf);
1549+ msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1550+ move (HDR_CC, HDR_XOFFSET);
1551+ clrtoeol();
1552+ if (msg->env->followup_to)
1553+ printw ("%-*.*s", W, W, msg->env->followup_to);
1554+ }
1555+ }
1556+ break;
1557+
1558+ case OP_COMPOSE_EDIT_X_COMMENT_TO:
1559+ if (news && option (OPTXCOMMENTTO))
1560+ {
1561+ buf[0] = 0;
1562+ if (msg->env->x_comment_to)
1563+ strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1564+ if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1565+ {
1566+ FREE (&msg->env->x_comment_to);
1567+ msg->env->x_comment_to = safe_strdup (buf);
1568+ move (HDR_BCC, HDR_XOFFSET);
1569+ clrtoeol();
1570+ if (msg->env->x_comment_to)
1571+ printw ("%-*.*s", W, W, msg->env->x_comment_to);
1572+ }
1573+ }
1574+ break;
1575+#endif
1576 case OP_COMPOSE_EDIT_SUBJECT:
1577 if (msg->env->subject)
1578 strfcpy (buf, msg->env->subject, sizeof (buf));
bebcbf73 1579@@ -706,6 +840,9 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1580 break;
1581
1582 case OP_COMPOSE_ATTACH_MESSAGE:
1583+#ifdef USE_NNTP
1584+ case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1585+#endif
1586 {
1587 char *prompt;
1588 HEADER *h;
bebcbf73 1589@@ -713,7 +850,22 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1590 fname[0] = 0;
1591 prompt = _("Open mailbox to attach message from");
1592
1593+#ifdef USE_NNTP
1594+ unset_option (OPTNEWS);
1595+ if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1596+ {
1597+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1598+ break;
1599+
1600+ prompt = _("Open newsgroup to attach message from");
1601+ set_option (OPTNEWS);
1602+ }
1603+#endif
1604+
1605 if (Context)
1606+#ifdef USE_NNTP
1607+ if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
1608+#endif
1609 {
1610 strfcpy (fname, NONULL (Context->path), sizeof (fname));
bebcbf73
AG
1611 mutt_pretty_mailbox (fname, sizeof (fname));
1612@@ -722,6 +874,11 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1613 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
1614 break;
1615
1616+#ifdef USE_NNTP
1617+ if (option (OPTNEWS))
1618+ nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1619+ else
1620+#endif
1621 mutt_expand_path (fname, sizeof (fname));
1622 #ifdef USE_IMAP
1623 if (!mx_is_imap (fname))
bebcbf73 1624@@ -729,6 +886,9 @@ int mutt_compose_menu (HEADER *msg, /*
ce1255c1
JB
1625 #ifdef USE_POP
1626 if (!mx_is_pop (fname))
1627 #endif
1628+#ifdef USE_NNTP
1629+ if (!mx_is_nntp (fname) && !option (OPTNEWS))
1630+#endif
1631 /* check to make sure the file exists and is readable */
1632 if (access (fname, R_OK) == -1)
1633 {
bebcbf73
AG
1634diff -udprP mutt-1.5.19.orig/config.h.in mutt-1.5.19/config.h.in
1635--- mutt-1.5.19.orig/config.h.in 2008-11-18 01:54:00.000000000 +0200
1636+++ mutt-1.5.19/config.h.in 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
1637@@ -34,6 +34,9 @@
1638 significant more memory when defined. */
1639 #undef EXACT_ADDRESS
1640
1641+/* Compiling with newsreading support with NNTP */
1642+#undef USE_NNTP
1643+
1644 /* program to use for shell commands */
1645 #undef EXECSHELL
1646
bebcbf73
AG
1647diff -udprP mutt-1.5.19.orig/configure.ac mutt-1.5.19/configure.ac
1648--- mutt-1.5.19.orig/configure.ac 2008-11-17 22:15:26.000000000 +0200
1649+++ mutt-1.5.19/configure.ac 2009-01-06 22:27:38.000000000 +0200
1650@@ -598,6 +598,14 @@ if test x"$need_imap" = xyes -o x"$need_
ce1255c1
JB
1651 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1652 fi
1653
1654+AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
1655+[ if test x$enableval = xyes ; then
1656+ AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1657+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1658+ need_socket="yes"
1659+ fi
1660+])
1661+
1662 dnl -- end socket dependencies --
1663
1664 if test "$need_socket" = "yes"
bebcbf73
AG
1665diff -udprP mutt-1.5.19.orig/curs_main.c mutt-1.5.19/curs_main.c
1666--- mutt-1.5.19.orig/curs_main.c 2009-01-05 21:20:53.000000000 +0200
1667+++ mutt-1.5.19/curs_main.c 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
1668@@ -22,6 +22,7 @@
1669
1670 #include "mutt.h"
1671 #include "mutt_curses.h"
1672+#include "mx.h"
1673 #include "mutt_menu.h"
ce1255c1 1674 #include "mailbox.h"
bebcbf73
AG
1675 #include "mapping.h"
1676@@ -38,6 +39,10 @@
ce1255c1
JB
1677
1678 #include "mutt_crypt.h"
1679
1680+#ifdef USE_NNTP
1681+#include "nntp.h"
1682+#endif
1683+
1684
1685 #include <ctype.h>
1686 #include <stdlib.h>
bebcbf73 1687@@ -413,12 +418,27 @@ static struct mapping_t IndexHelp[] = {
ce1255c1
JB
1688 { NULL }
1689 };
1690
1691+#ifdef USE_NNTP
1692+struct mapping_t IndexNewsHelp[] = {
1693+ { N_("Quit"), OP_QUIT },
1694+ { N_("Del"), OP_DELETE },
1695+ { N_("Undel"), OP_UNDELETE },
1696+ { N_("Save"), OP_SAVE },
1697+ { N_("Post"), OP_POST },
1698+ { N_("Followup"), OP_FOLLOWUP },
1699+ { N_("Catchup"), OP_CATCHUP },
1700+ { N_("Help"), OP_HELP },
1701+ { NULL }
1702+};
1703+#endif
1704+
1705 /* This function handles the message index window as well as commands returned
1706 * from the pager (MENU_PAGER).
1707 */
1708 int mutt_index_menu (void)
1709 {
1710 char buf[LONG_STRING], helpstr[LONG_STRING];
1711+ int flags;
1712 int op = OP_NULL;
1713 int done = 0; /* controls when to exit the "event" loop */
1714 int i = 0, j;
bebcbf73 1715@@ -439,7 +459,11 @@ int mutt_index_menu (void)
ce1255c1
JB
1716 menu->make_entry = index_make_entry;
1717 menu->color = index_color;
1718 menu->current = ci_first_message ();
1719- menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1720+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1721+#ifdef USE_NNTP
1722+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
1723+#endif
1724+ IndexHelp);
1725
1726 if (!attach_msg)
1727 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
bebcbf73
AG
1728@@ -690,6 +714,9 @@ int mutt_index_menu (void)
1729 imap_disallow_reopen (Context);
1730 #endif
ce1255c1
JB
1731
1732+#ifdef USE_NNTP
1733+ unset_option (OPTNEWS); /* for any case */
1734+#endif
1735 switch (op)
1736 {
1737
bebcbf73 1738@@ -740,6 +767,120 @@ int mutt_index_menu (void)
ce1255c1
JB
1739 menu_current_bottom (menu);
1740 break;
1741
1742+#ifdef USE_NNTP
1743+ case OP_GET_MESSAGE:
1744+ case OP_GET_PARENT:
1745+ CHECK_MSGCOUNT;
1746+ if (Context->magic == M_NNTP)
1747+ {
1748+ HEADER *h;
1749+
1750+ if (op == OP_GET_MESSAGE)
1751+ {
1752+ buf[0] = 0;
1753+ if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
1754+ || !buf[0])
1755+ break;
1756+ }
1757+ else
1758+ {
1759+ LIST *ref = CURHDR->env->references;
1760+ if (!ref)
1761+ {
1762+ mutt_error _("Article has no parent reference!");
1763+ break;
1764+ }
1765+ strfcpy (buf, ref->data, sizeof (buf));
1766+ }
1767+ if (!Context->id_hash)
1768+ Context->id_hash = mutt_make_id_hash (Context);
1769+ if ((h = hash_find (Context->id_hash, buf)))
1770+ {
1771+ if (h->virtual != -1)
1772+ {
1773+ menu->current = h->virtual;
1774+ menu->redraw = REDRAW_MOTION_RESYNCH;
1775+ }
1776+ else if (h->collapsed)
1777+ {
1778+ mutt_uncollapse_thread (Context, h);
1779+ mutt_set_virtual (Context);
1780+ menu->current = h->virtual;
1781+ menu->redraw = REDRAW_MOTION_RESYNCH;
1782+ }
1783+ else
1784+ mutt_error _("Message not visible in limited view.");
1785+ }
1786+ else
1787+ {
1788+ if (nntp_check_msgid (Context, buf) == 0)
1789+ {
1790+ h = Context->hdrs[Context->msgcount-1];
1791+ mutt_sort_headers (Context, 0);
1792+ menu->current = h->virtual;
1793+ menu->redraw = REDRAW_FULL;
1794+ }
1795+ else
1796+ mutt_error (_("Article %s not found on server"), buf);
1797+ }
1798+ }
1799+ break;
1800+
1801+ case OP_GET_CHILDREN:
1802+ case OP_RECONSTRUCT_THREAD:
1803+ CHECK_MSGCOUNT;
1804+ if (Context->magic == M_NNTP)
1805+ {
1806+ HEADER *h;
1807+ int old = CURHDR->index, i;
1808+
1809+ if (!CURHDR->env->message_id)
1810+ {
1811+ mutt_error _("No Message-Id. Unable to perform operation");
1812+ break;
1813+ }
1814+
1815+ if (!Context->id_hash)
1816+ Context->id_hash = mutt_make_id_hash (Context);
1817+ strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1818+
1819+ if (op == OP_RECONSTRUCT_THREAD)
1820+ {
1821+ LIST *ref = CURHDR->env->references;
1822+ while (ref)
1823+ {
1824+ nntp_check_msgid (Context, ref->data);
1825+ /* the last msgid in References is the root message */
1826+ if (!ref->next)
1827+ strfcpy (buf, ref->data, sizeof (buf));
1828+ ref = ref->next;
1829+ }
1830+ }
1831+ mutt_message _("Check for children of message...");
1832+ if (nntp_check_children (Context, buf) == 0)
1833+ {
1834+ mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1835+ h = hash_find (Context->id_hash, buf);
1836+ /* if the root message was retrieved, move to it */
1837+ if (h)
1838+ menu->current = h->virtual;
1839+ else /* try to restore old position */
1840+ for (i = 0; i < Context->msgcount; i++)
1841+ if (Context->hdrs[i]->index == old)
1842+ {
1843+ menu->current = Context->hdrs[i]->virtual;
1844+ /* As an added courtesy, recenter the menu
1845+ * with the current entry at the middle of the screen */
1846+ menu_check_recenter (menu);
1847+ menu_current_middle (menu);
1848+ }
1849+ }
1850+ menu->redraw = REDRAW_FULL;
1851+ mutt_clear_error ();
1852+ }
1853+ break;
1854+#endif
1855+
1856 case OP_JUMP:
1857
1858 CHECK_MSGCOUNT;
bebcbf73 1859@@ -837,11 +978,33 @@ int mutt_index_menu (void)
ce1255c1
JB
1860 break;
1861
1862 case OP_MAIN_LIMIT:
1863+ case OP_TOGGLE_READ:
1864
1865 CHECK_IN_MAILBOX;
1866 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
1867 CURHDR->index : -1;
1868- if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1869+ if (op == OP_TOGGLE_READ)
1870+ {
1871+ char buf[LONG_STRING];
1872+
1873+ if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
1874+ {
1875+ snprintf (buf, sizeof (buf), "!~R!~D~s%s",
1876+ Context->pattern ? Context->pattern : ".*");
1877+ set_option (OPTHIDEREAD);
1878+ }
1879+ else
1880+ {
1881+ strfcpy (buf, Context->pattern + 8, sizeof(buf));
1882+ if (!*buf || strncmp (buf, ".*", 2) == 0)
1883+ snprintf (buf, sizeof(buf), "~A");
1884+ unset_option (OPTHIDEREAD);
1885+ }
1886+ FREE (&Context->pattern);
1887+ Context->pattern = safe_strdup (buf);
1888+ }
1889+ if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
1890+ mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
1891 {
1892 if (menu->oldcurrent >= 0)
1893 {
bebcbf73 1894@@ -1050,15 +1213,22 @@ int mutt_index_menu (void)
ce1255c1
JB
1895
1896 case OP_MAIN_CHANGE_FOLDER:
1897 case OP_MAIN_NEXT_UNREAD_MAILBOX:
1898-
1899- if (attach_msg)
1900- op = OP_MAIN_CHANGE_FOLDER_READONLY;
1901-
1902- /* fallback to the readonly case */
1903-
1904 case OP_MAIN_CHANGE_FOLDER_READONLY:
1905+#ifdef USE_NNTP
1906+ case OP_MAIN_CHANGE_GROUP:
1907+ case OP_MAIN_CHANGE_GROUP_READONLY:
1908+ unset_option (OPTNEWS);
1909+#endif
1910+ if (attach_msg || option (OPTREADONLY) ||
1911+#ifdef USE_NNTP
1912+ op == OP_MAIN_CHANGE_GROUP_READONLY ||
1913+#endif
1914+ op == OP_MAIN_CHANGE_FOLDER_READONLY)
1915+ flags = M_READONLY;
1916+ else
1917+ flags = 0;
1918
1919- if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
1920+ if (flags)
1921 cp = _("Open mailbox in read-only mode");
1922 else
1923 cp = _("Open mailbox");
bebcbf73 1924@@ -1077,6 +1247,21 @@ int mutt_index_menu (void)
ce1255c1
JB
1925 }
1926 else
1927 {
1928+#ifdef USE_NNTP
1929+ if (op == OP_MAIN_CHANGE_GROUP ||
1930+ op == OP_MAIN_CHANGE_GROUP_READONLY)
1931+ {
1932+ set_option (OPTNEWS);
1933+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
1934+ break;
1935+ if (flags)
1936+ cp = _("Open newsgroup in read-only mode");
1937+ else
1938+ cp = _("Open newsgroup");
1939+ nntp_buffy (buf);
1940+ }
1941+ else
1942+#endif
1943 mutt_buffy (buf, sizeof (buf));
1944
1945 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
bebcbf73 1946@@ -1096,6 +1281,14 @@ int mutt_index_menu (void)
ce1255c1
JB
1947 }
1948 }
1949
1950+#ifdef USE_NNTP
1951+ if (option (OPTNEWS))
1952+ {
1953+ unset_option (OPTNEWS);
1954+ nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
1955+ }
1956+ else
1957+#endif
1958 mutt_expand_path (buf, sizeof (buf));
1959 if (mx_get_magic (buf) <= 0)
1960 {
bebcbf73 1961@@ -1133,15 +1326,18 @@ int mutt_index_menu (void)
ce1255c1
JB
1962 CurrentMenu = MENU_MAIN;
1963 mutt_folder_hook (buf);
1964
1965- if ((Context = mx_open_mailbox (buf,
1966- (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
1967- M_READONLY : 0, NULL)) != NULL)
1968+ if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
1969 {
1970 menu->current = ci_first_message ();
1971 }
1972 else
1973 menu->current = 0;
1974
1975+#ifdef USE_NNTP
1976+ /* mutt_buffy_check() must be done with mail-reader mode! */
1977+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1978+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
1979+#endif
1980 mutt_clear_error ();
1981 mutt_buffy_check(1); /* force the buffy check after we have changed
1982 the folder */
bebcbf73 1983@@ -1512,6 +1708,15 @@ int mutt_index_menu (void)
ce1255c1
JB
1984 CHECK_READONLY;
1985 CHECK_ACL(M_ACL_WRITE, _("flag message"));
1986
1987+#ifdef USE_NNTP
1988+ if (Context->magic == M_NNTP)
1989+ {
1990+ mutt_flushinp ();
1991+ mutt_error _("Can't change 'important' flag on NNTP server.");
1992+ break;
1993+ }
1994+#endif
1995+
1996 if (tag)
1997 {
1998 for (j = 0; j < Context->vcount; j++)
bebcbf73 1999@@ -1859,6 +2064,17 @@ int mutt_index_menu (void)
ce1255c1
JB
2000 }
2001 break;
2002
2003+#ifdef USE_NNTP
2004+ case OP_CATCHUP:
2005+ if (Context && Context->magic == M_NNTP)
2006+ {
2007+ if (mutt_newsgroup_catchup (CurrentNewsSrv,
2008+ ((NNTP_DATA *)Context->data)->group))
2009+ menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2010+ }
2011+ break;
2012+#endif
2013+
2014 case OP_DISPLAY_ADDRESS:
2015
2016 CHECK_MSGCOUNT;
bebcbf73 2017@@ -1986,6 +2202,15 @@ int mutt_index_menu (void)
ce1255c1
JB
2018 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2019 }
2020 #endif
2021+
2022+#ifdef USE_NNTP
2023+ if (Context->magic == M_NNTP)
2024+ {
2025+ mutt_flushinp ();
2026+ mutt_error _("Can't edit message on newsserver.");
2027+ break;
2028+ }
2029+#endif
2030
2031 MAYBE_REDRAW (menu->redraw);
2032 break;
bebcbf73 2033@@ -2057,6 +2282,41 @@ int mutt_index_menu (void)
ce1255c1
JB
2034
2035 menu->redraw = REDRAW_FULL;
2036 break;
2037+
2038+#ifdef USE_NNTP
ce1255c1
JB
2039+ case OP_FOLLOWUP:
2040+ case OP_FORWARD_TO_GROUP:
2041+
bebcbf73
AG
2042+ CHECK_MSGCOUNT;
2043+ CHECK_VISIBLE;
2044+
2045+ case OP_POST:
2046+
ce1255c1
JB
2047+ CHECK_ATTACH;
2048+ if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2049+ mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2050+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2051+ {
2052+ if (Context && Context->magic == M_NNTP &&
2053+ !((NNTP_DATA *)Context->data)->allowed &&
2054+ query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2055+ break;
2056+ if (op == OP_POST)
2057+ ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2058+ else
2059+ {
2060+ CHECK_MSGCOUNT;
2061+ if (op == OP_FOLLOWUP)
2062+ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2063+ tag ? NULL : CURHDR);
2064+ else
2065+ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2066+ tag ? NULL : CURHDR);
2067+ }
2068+ menu->redraw = REDRAW_FULL;
2069+ break;
2070+ }
2071+#endif
2072
2073 case OP_REPLY:
2074
bebcbf73 2075@@ -2133,6 +2393,12 @@ int mutt_index_menu (void)
ce1255c1
JB
2076 CHECK_READONLY;
2077 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2078
2079+#ifdef USE_NNTP
2080+ /* Close all open NNTP connections */
2081+ if (!attach_msg)
2082+ nntp_logout_all ();
2083+#endif
2084+
2085 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2086 op == OP_UNDELETE_THREAD ? 0 : 1);
2087
bebcbf73
AG
2088diff -udprP mutt-1.5.19.orig/doc/manual.xml.head mutt-1.5.19/doc/manual.xml.head
2089--- mutt-1.5.19.orig/doc/manual.xml.head 2009-01-05 21:20:53.000000000 +0200
2090+++ mutt-1.5.19/doc/manual.xml.head 2009-01-06 22:27:38.000000000 +0200
2091@@ -1388,6 +1388,22 @@ fo-table</literal> for details.
ce1255c1
JB
2092
2093 </sect2>
2094
2095+<sect2>
2096+<title>Reading news via NNTP</title>
2097+
2098+<para>
2099+If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2100+read news from newsserver via NNTP. You can open a newsgroup with
2101+function ``change-newsgroup'' (default: ``i''). Default newsserver
2102+can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2103+variable. Like other news readers, info about subscribed newsgroups
2104+is saved in file by <link linkend="newsrc">&dollar;newsrc</link>
2105+variable. Article headers are cached and can be loaded from file when
2106+newsgroup entered instead loading from newsserver.
2107+</para>
2108+
2109+</sect2>
2110+
2111 </sect1>
2112
2113 <sect1 id="forwarding-mail">
bebcbf73
AG
2114diff -udprP mutt-1.5.19.orig/doc/mutt.man mutt-1.5.19/doc/mutt.man
2115--- mutt-1.5.19.orig/doc/mutt.man 2009-01-05 22:18:18.000000000 +0200
2116+++ mutt-1.5.19/doc/mutt.man 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
2117@@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2118 .SH SYNOPSIS
2119 .PP
2120 .B mutt
2121-[-nRyzZ]
2122-[-e \fIcmd\fP] [-F \fIfile\fP] [-m \fItype\fP] [-f \fIfile\fP]
2123+[-GnRyzZ]
2124+[-e \fIcmd\fP] [-F \fIfile\fP] [-g \fIserver\fP] [-m \fItype\fP] [-f \fIfile\fP]
2125 .PP
2126 .B mutt
2127 [-nx]
bebcbf73 2128@@ -101,6 +101,10 @@ files.
ce1255c1
JB
2129 Specify which mailbox to load.
2130 .IP "-F \fImuttrc\fP"
2131 Specify an initialization file to read instead of ~/.muttrc
2132+.IP "-g \fIserver\fP"
2133+Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2134+.IP "-G"
2135+Start Mutt with a listing of subscribed newsgroups.
2136 .IP "-h"
2137 Display help.
2138 .IP "-H \fIdraft\fP"
bebcbf73
AG
2139diff -udprP mutt-1.5.19.orig/functions.h mutt-1.5.19/functions.h
2140--- mutt-1.5.19.orig/functions.h 2009-01-05 21:20:53.000000000 +0200
2141+++ mutt-1.5.19/functions.h 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
2142@@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in
2143 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2144 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2145 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2146+#ifdef USE_NNTP
bebcbf73 2147+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
ce1255c1
JB
2148+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2149+#endif
2150 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2151 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2152 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
bebcbf73
AG
2153@@ -101,7 +105,15 @@ struct binding_t OpMain[] = { /* map: in
2154 { "edit", OP_EDIT_MESSAGE, "e" },
ce1255c1
JB
2155 { "edit-type", OP_EDIT_TYPE, "\005" },
2156 { "forward-message", OP_FORWARD_MESSAGE, "f" },
bebcbf73 2157- { "flag-message", OP_FLAG_MESSAGE, "F" },
ce1255c1
JB
2158+#ifdef USE_NNTP
2159+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
bebcbf73 2160+ { "followup-message", OP_FOLLOWUP, "F" },
ce1255c1
JB
2161+ { "get-children", OP_GET_CHILDREN, NULL },
2162+ { "get-message", OP_GET_MESSAGE, "\007" },
2163+ { "get-parent", OP_GET_PARENT, "\033G" },
2164+ { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2165+#endif
bebcbf73 2166+ { "flag-message", OP_FLAG_MESSAGE, "\033f" },
ce1255c1
JB
2167 { "group-reply", OP_GROUP_REPLY, "g" },
2168 #ifdef USE_POP
2169 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2170@@ -127,6 +139,9 @@ struct binding_t OpMain[] = { /* map: in
2171 { "sort-mailbox", OP_SORT, "o" },
2172 { "sort-reverse", OP_SORT_REVERSE, "O" },
2173 { "print-message", OP_PRINT, "p" },
2174+#ifdef USE_NNTP
bebcbf73 2175+ { "post-message", OP_POST, "P" },
ce1255c1
JB
2176+#endif
2177 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2178 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2179 { "recall-message", OP_RECALL_MESSAGE, "R" },
2180@@ -146,6 +161,10 @@ struct binding_t OpMain[] = { /* map: in
2181 { "show-version", OP_VERSION, "V" },
2182 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2183 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2184+ { "toggle-read", OP_TOGGLE_READ, "X" },
2185+#ifdef USE_NNTP
2186+ { "catchup", OP_CATCHUP, "y" },
2187+#endif
2188 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2189 { "buffy-list", OP_BUFFY_LIST, "." },
2190 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
bebcbf73
AG
2191@@ -157,7 +176,7 @@ struct binding_t OpMain[] = { /* map: in
2192 { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" },
2193 { "next-unread", OP_MAIN_NEXT_UNREAD, NULL },
2194 { "previous-unread", OP_MAIN_PREV_UNREAD, NULL },
2195- { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2196+ { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2197
2198
2199 { "extract-keys", OP_EXTRACT_KEYS, "\013" },
ce1255c1
JB
2200@@ -177,6 +196,10 @@ struct binding_t OpPager[] = { /* map: p
2201 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2202 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2203 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2204+#ifdef USE_NNTP
bebcbf73 2205+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
ce1255c1
JB
2206+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2207+#endif
2208 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2209 { "copy-message", OP_COPY_MESSAGE, "C" },
2210 { "decode-copy", OP_DECODE_COPY, "\033C" },
bebcbf73 2211@@ -185,8 +208,12 @@ struct binding_t OpPager[] = { /* map: p
ce1255c1
JB
2212 { "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" },
2213 { "edit", OP_EDIT_MESSAGE, "e" },
2214 { "edit-type", OP_EDIT_TYPE, "\005" },
2215+#ifdef USE_NNTP
bebcbf73 2216+ { "followup-message", OP_FOLLOWUP, "F" },
ce1255c1
JB
2217+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2218+#endif
2219 { "forward-message", OP_FORWARD_MESSAGE, "f" },
bebcbf73
AG
2220- { "flag-message", OP_FLAG_MESSAGE, "F" },
2221+ { "flag-message", OP_FLAG_MESSAGE, "\033f" },
ce1255c1 2222 { "group-reply", OP_GROUP_REPLY, "g" },
bebcbf73
AG
2223 #ifdef USE_IMAP
2224 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
ce1255c1
JB
2225@@ -205,6 +232,9 @@ struct binding_t OpPager[] = { /* map: p
2226 { "next-thread", OP_MAIN_NEXT_THREAD, "\016" },
2227 { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" },
2228 { "print-message", OP_PRINT, "p" },
2229+#ifdef USE_NNTP
bebcbf73 2230+ { "post-message", OP_POST, "P" },
ce1255c1
JB
2231+#endif
2232 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2233 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2234 { "quit", OP_QUIT, "Q" },
bebcbf73
AG
2235@@ -252,7 +282,7 @@ struct binding_t OpPager[] = { /* map: p
2236 { "half-down", OP_HALF_DOWN, NULL },
2237 { "previous-line", OP_PREV_LINE, NULL },
2238 { "bottom", OP_PAGER_BOTTOM, NULL },
2239- { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2240+ { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2241
2242
2243
2244@@ -273,6 +303,10 @@ struct binding_t OpAttach[] = { /* map:
ce1255c1
JB
2245 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2246 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2247 { "edit-type", OP_EDIT_TYPE, "\005" },
2248+#ifdef USE_NNTP
bebcbf73 2249+ { "followup-message", OP_FOLLOWUP, "F" },
ce1255c1
JB
2250+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2251+#endif
2252 { "print-entry", OP_PRINT, "p" },
2253 { "save-entry", OP_SAVE, "s" },
2254 { "pipe-entry", OP_PIPE, "|" },
bebcbf73 2255@@ -298,6 +332,7 @@ struct binding_t OpAttach[] = { /* map:
ce1255c1
JB
2256 struct binding_t OpCompose[] = { /* map: compose */
2257 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2258 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2259+ { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2260 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2261 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2262 { "copy-file", OP_SAVE, "C" },
bebcbf73 2263@@ -317,6 +352,11 @@ struct binding_t OpCompose[] = { /* map:
ce1255c1
JB
2264 { "print-entry", OP_PRINT, "l" },
2265 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2266 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2267+#ifdef USE_NNTP
2268+ { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2269+ { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2270+ { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2271+#endif
2272 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2273 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2274 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
bebcbf73 2275@@ -368,14 +408,25 @@ struct binding_t OpBrowser[] = { /* map:
ce1255c1
JB
2276 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2277 { "check-new", OP_CHECK_NEW, NULL },
2278 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2279+#ifdef USE_NNTP
2280+ { "reload-active", OP_LOAD_ACTIVE, "g" },
2281+ { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2282+ { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2283+ { "catchup", OP_CATCHUP, "y" },
2284+ { "uncatchup", OP_UNCATCHUP, "Y" },
2285+#endif
2286 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2287 { "buffy-list", OP_BUFFY_LIST, "." },
2288 #ifdef USE_IMAP
2289 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2290 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2291 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2292+#endif
2293+#if defined USE_IMAP || defined USE_NNTP
2294 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2295 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2296+#endif
2297+#ifdef USE_IMAP
2298 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2299 #endif
2300 { NULL, 0, NULL }
bebcbf73
AG
2301diff -udprP mutt-1.5.19.orig/globals.h mutt-1.5.19/globals.h
2302--- mutt-1.5.19.orig/globals.h 2009-01-04 01:27:10.000000000 +0200
2303+++ mutt-1.5.19/globals.h 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
2304@@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
2305 #endif
2306
2307 WHERE char *Muttrc INITVAL (NULL);
2308+#ifdef USE_NNTP
2309+WHERE char *NewsCacheDir;
2310+WHERE char *GroupFormat;
2311+WHERE char *Inews;
2312+WHERE char *NewsServer;
2313+WHERE char *NntpUser;
2314+WHERE char *NntpPass;
2315+WHERE char *NewsRc;
2316+#endif
2317 WHERE char *Outbox;
2318 WHERE char *Pager;
2319 WHERE char *PagerFmt;
bebcbf73 2320@@ -187,6 +196,11 @@ extern unsigned char QuadOptions[];
ce1255c1
JB
2321
2322 WHERE unsigned short Counter INITVAL (0);
2323
2324+#ifdef USE_NNTP
2325+WHERE short NewsPollTimeout;
2326+WHERE short NntpContext;
2327+#endif
2328+
2329 WHERE short ConnectTimeout;
2330 WHERE short HistSize;
2331 WHERE short MenuContext;
bebcbf73
AG
2332diff -udprP mutt-1.5.19.orig/hash.c mutt-1.5.19/hash.c
2333--- mutt-1.5.19.orig/hash.c 2009-01-04 01:27:10.000000000 +0200
2334+++ mutt-1.5.19/hash.c 2009-01-06 22:27:38.000000000 +0200
2335@@ -45,10 +45,35 @@ HASH *hash_create (int nelem)
ce1255c1
JB
2336 if (nelem == 0)
2337 nelem = 2;
2338 table->nelem = nelem;
2339+ table->curnelem = 0;
2340 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2341 return table;
2342 }
2343
2344+HASH *hash_resize (HASH *ptr, int nelem)
2345+{
2346+ HASH *table;
2347+ struct hash_elem *elem, *tmp;
2348+ int i;
2349+
2350+ table = hash_create (nelem);
2351+
2352+ for (i = 0; i < ptr->nelem; i++)
2353+ {
2354+ for (elem = ptr->table[i]; elem; )
2355+ {
2356+ tmp = elem;
2357+ elem = elem->next;
2358+ hash_insert (table, tmp->key, tmp->data, 1);
2359+ FREE (&tmp);
2360+ }
2361+ }
2362+ FREE (&ptr->table);
2363+ FREE (&ptr);
2364+
2365+ return table;
2366+}
2367+
2368 /* table hash table to update
2369 * key key to hash on
2370 * data data to associate with `key'
bebcbf73 2371@@ -68,6 +93,7 @@ int hash_insert (HASH * table, const cha
ce1255c1
JB
2372 {
2373 ptr->next = table->table[h];
2374 table->table[h] = ptr;
2375+ table->curnelem++;
2376 }
2377 else
2378 {
bebcbf73 2379@@ -90,6 +116,7 @@ int hash_insert (HASH * table, const cha
ce1255c1
JB
2380 else
2381 table->table[h] = ptr;
2382 ptr->next = tmp;
2383+ table->curnelem++;
2384 }
2385 return h;
2386 }
bebcbf73 2387@@ -120,6 +147,7 @@ void hash_delete_hash (HASH * table, int
ce1255c1
JB
2388 if (destroy)
2389 destroy (ptr->data);
2390 FREE (&ptr);
2391+ table->curnelem--;
2392
2393 ptr = *last;
2394 }
bebcbf73
AG
2395diff -udprP mutt-1.5.19.orig/hash.h mutt-1.5.19/hash.h
2396--- mutt-1.5.19.orig/hash.h 2009-01-04 01:27:10.000000000 +0200
2397+++ mutt-1.5.19/hash.h 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
2398@@ -28,7 +28,7 @@ struct hash_elem
2399
2400 typedef struct
2401 {
2402- int nelem;
2403+ int nelem, curnelem;
2404 struct hash_elem **table;
2405 }
2406 HASH;
2407@@ -40,6 +40,7 @@ HASH;
2408 HASH *hash_create (int nelem);
bebcbf73 2409 unsigned int hash_string (const unsigned char *s, unsigned int n);
ce1255c1
JB
2410 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2411+HASH *hash_resize (HASH * table, int nelem);
2412 void *hash_find_hash (const HASH * table, int hash, const char *key);
2413 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2414 void (*destroy) (void *));
bebcbf73
AG
2415diff -udprP mutt-1.5.19.orig/hdrline.c mutt-1.5.19/hdrline.c
2416--- mutt-1.5.19.orig/hdrline.c 2009-01-05 21:20:53.000000000 +0200
2417+++ mutt-1.5.19/hdrline.c 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
2418@@ -209,6 +209,7 @@ int mutt_user_is_recipient (HEADER *h)
2419 * %E = number of messages in current thread
2420 * %f = entire from line
2421 * %F = like %n, unless from self
2422+ * %g = newsgroup name (if compiled with nntp support)
2423 * %i = message-id
2424 * %l = number of lines in the message
2425 * %L = like %F, except `lists' are displayed first
2426@@ -217,12 +218,14 @@ int mutt_user_is_recipient (HEADER *h)
2427 * %N = score
2428 * %O = like %L, except using address instead of name
2429 * %P = progress indicator for builtin pager
2430+ * %R = `x-comment-to:' field (if present and compiled with nntp support)
2431 * %s = subject
2432 * %S = short message status (e.g., N/O/D/!/r/-)
2433 * %t = `to:' field (recipients)
2434 * %T = $to_chars
2435 * %u = user (login) name of author
2436 * %v = first name of author, unless from self
2437+ * %W = where user is (organization)
2438 * %X = number of MIME attachments
2439 * %y = `x-label:' field (if present)
2440 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2441@@ -455,6 +458,12 @@ hdr_format_str (char *dest,
2442
2443 break;
2444
2445+#ifdef USE_NNTP
2446+ case 'g':
2447+ mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2448+ break;
2449+#endif
2450+
2451 case 'i':
2452 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2453 break;
2454@@ -546,6 +555,15 @@ hdr_format_str (char *dest,
2455 strfcpy(dest, NONULL(hfi->pager_progress), destlen);
2456 break;
2457
2458+#ifdef USE_NNTP
2459+ case 'R':
2460+ if (!optional)
2461+ mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2462+ else if (!hdr->env->x_comment_to)
2463+ optional = 0;
2464+ break;
2465+#endif
2466+
2467 case 's':
2468
2469 if (flags & M_FORMAT_TREE && !hdr->collapsed)
2470@@ -635,6 +653,13 @@ hdr_format_str (char *dest,
2471 mutt_format_s (dest, destlen, prefix, buf2);
2472 break;
2473
2474+ case 'W':
2475+ if (!optional)
2476+ mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2477+ else if (!hdr->env->organization)
2478+ optional = 0;
2479+ break;
2480+
2481 case 'Z':
2482
2483 ch = ' ';
bebcbf73
AG
2484diff -udprP mutt-1.5.19.orig/headers.c mutt-1.5.19/headers.c
2485--- mutt-1.5.19.orig/headers.c 2008-08-15 21:30:12.000000000 +0300
2486+++ mutt-1.5.19/headers.c 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
2487@@ -118,6 +118,9 @@ void mutt_edit_headers (const char *edit
2488 msg->env = n; n = NULL;
2489
2490 if (!msg->env->in_reply_to)
2491+#ifdef USE_NNTP
2492+ if (!option (OPTNEWSSEND))
2493+#endif
2494 mutt_free_list (&msg->env->references);
2495
2496 mutt_expand_aliases_env (msg->env);
bebcbf73
AG
2497diff -udprP mutt-1.5.19.orig/init.c mutt-1.5.19/init.c
2498--- mutt-1.5.19.orig/init.c 2009-01-05 21:20:53.000000000 +0200
2499+++ mutt-1.5.19/init.c 2009-01-06 22:27:38.000000000 +0200
2500@@ -2965,6 +2965,28 @@ void mutt_init (int skip_sys_rc, LIST *c
ce1255c1
JB
2501 else
2502 Fqdn = safe_strdup(NONULL(Hostname));
2503
2504+#ifdef USE_NNTP
2505+ {
2506+ FILE *f;
2507+ char *i;
2508+
2509+ if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2510+ {
2511+ buffer[0] = '\0';
2512+ fgets (buffer, sizeof (buffer), f);
2513+ p = &buffer;
2514+ SKIPWS (p);
2515+ i = p;
2516+ while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2517+ *i = '\0';
2518+ NewsServer = safe_strdup (p);
2519+ fclose (f);
2520+ }
2521+ }
2522+ if ((p = getenv ("NNTPSERVER")))
2523+ NewsServer = safe_strdup (p);
2524+#endif
2525+
2526 if ((p = getenv ("MAIL")))
2527 Spoolfile = safe_strdup (p);
2528 else if ((p = getenv ("MAILDIR")))
bebcbf73
AG
2529diff -udprP mutt-1.5.19.orig/init.h mutt-1.5.19/init.h
2530--- mutt-1.5.19.orig/init.h 2009-01-05 21:20:53.000000000 +0200
2531+++ mutt-1.5.19/init.h 2009-01-06 22:27:38.000000000 +0200
2532@@ -176,6 +176,20 @@ struct option_t MuttVars[] = {
2533 ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before
ce1255c1 2534 ** editing the body of an outgoing message.
bebcbf73 2535 */
ce1255c1
JB
2536+#ifdef USE_NNTP
2537+ { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2538+ /*
2539+ ** .pp
2540+ ** If set, Mutt will prompt you for follow-up groups before editing
2541+ ** the body of an outgoing message.
bebcbf73 2542+ */
ce1255c1
JB
2543+ { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2544+ /*
2545+ ** .pp
2546+ ** If set, Mutt will prompt you for x-comment-to field before editing
2547+ ** the body of an outgoing message.
bebcbf73 2548+ */
ce1255c1
JB
2549+#endif
2550 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2551 /*
2552 ** .pp
bebcbf73
AG
2553@@ -329,6 +343,14 @@ struct option_t MuttVars[] = {
2554 ** mailbox by performing a fast mailbox scan when it is defined.
2555 ** Afterwards the new mail status is tracked by file size changes.
ce1255c1
JB
2556 */
2557+#ifdef USE_NNTP
2558+ { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
2559+ /*
2560+ ** .pp
2561+ ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2562+ ** as read when you quit the newsgroup (catchup newsgroup).
2563+ */
2564+#endif
2565 { "charset", DT_STR, R_NONE, UL &Charset, UL 0 },
2566 /*
2567 ** .pp
bebcbf73 2568@@ -690,6 +712,16 @@ struct option_t MuttVars[] = {
ce1255c1
JB
2569 ** sent to both the list and your address, resulting in two copies
2570 ** of the same email for you.
2571 */
2572+#ifdef USE_NNTP
2573+ { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
2574+ /*
2575+ ** .pp
2576+ ** If this variable is \fIset\fP and the keyword "poster" is present in
2577+ ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2578+ ** permitted. The message will be mailed to the submitter of the
2579+ ** message via mail.
2580+ */
2581+#endif
2582 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2583 /*
2584 ** .pp
bebcbf73 2585@@ -760,6 +792,27 @@ struct option_t MuttVars[] = {
ce1255c1 2586 ** a regular expression that will match the whole name so mutt will expand
bebcbf73 2587 ** ``Franklin'' to ``Franklin, Steve''.
ce1255c1
JB
2588 */
2589+#ifdef USE_NNTP
2590+ { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2591+ /*
2592+ ** .pp
2593+ ** This variable allows you to customize the newsgroup browser display to
2594+ ** your personal taste. This string is similar to ``$index_format'', but
2595+ ** has its own set of printf()-like sequences:
2596+ ** .pp
2597+ ** .ts
2598+ ** %C current newsgroup number
2599+ ** %d description of newsgroup (becomes from server)
2600+ ** %f newsgroup name
2601+ ** %M - if newsgroup not allowed for direct post (moderated for example)
2602+ ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
2603+ ** %n number of new articles in newsgroup
2604+ ** %s number of unread articles in newsgroup
2605+ ** %>X right justify the rest of the string and pad with character "X"
2606+ ** %|X pad to the end of the line with character "X"
2607+ ** .te
2608+ */
2609+#endif
2610 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2611 /*
2612 */
bebcbf73 2613@@ -1090,6 +1143,7 @@ struct option_t MuttVars[] = {
ce1255c1 2614 ** .dt %E .dd number of messages in current thread
bebcbf73 2615 ** .dt %f .dd sender (address + real name), either From: or Return-Path:
ce1255c1
JB
2616 ** .dt %F .dd author name, or recipient name if the message is from you
2617+ ** .dt %g .dd newsgroup name (if compiled with nntp support)
2618 ** .dt %H .dd spam attribute(s) of this message
2619 ** .dt %i .dd message-id of the current message
2620 ** .dt %l .dd number of lines in the message (does not work with maildir,
bebcbf73
AG
2621@@ -1105,12 +1159,14 @@ struct option_t MuttVars[] = {
2622 ** stashed the message: list name or recipient name
2623 ** if not sent to a list
ce1255c1
JB
2624 ** .dt %P .dd progress indicator for the builtin pager (how much of the file has been displayed)
2625+ ** .dt %R .dd `x-comment-to:' field (if present and compiled with nntp support)
2626 ** .dt %s .dd subject of the message
bebcbf73
AG
2627 ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as)
2628 ** .dt %t .dd ``To:'' field (recipients)
ce1255c1
JB
2629 ** .dt %T .dd the appropriate character from the $$to_chars string
2630 ** .dt %u .dd user (login) name of the author
2631 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2632+ ** .dt %W .dd name of organization of author (`organization:' field)
2633 ** .dt %X .dd number of attachments
2634 ** (please see the ``$attachments'' section for possible speed effects)
bebcbf73
AG
2635 ** .dt %y .dd ``X-Label:'' field, if present
2636@@ -1145,6 +1201,21 @@ struct option_t MuttVars[] = {
2637 ** Note that these expandos are supported in
2638 ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too.
ce1255c1
JB
2639 */
2640+#ifdef USE_NNTP
2641+ { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2642+ /*
2643+ ** .pp
2644+ ** If set, specifies the program and arguments used to deliver news posted
2645+ ** by Mutt. Otherwise, mutt posts article using current connection to
2646+ ** news server. The following printf-style sequence is understood:
2647+ ** .pp
2648+ ** .ts
2649+ ** %s newsserver name
2650+ ** .te
2651+ ** .pp
2652+ ** Example: set inews="/usr/local/bin/inews -hS"
2653+ */
2654+#endif
2655 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2656 /*
2657 ** .pp
bebcbf73
AG
2658@@ -1368,6 +1439,15 @@ struct option_t MuttVars[] = {
2659 ** menu, attachments which cannot be decoded in a reasonable manner will
2660 ** be attached to the newly composed message if this option is \fIset\fP.
ce1255c1 2661 */
ce1255c1
JB
2662+#ifdef USE_NNTP
2663+ { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2664+ /*
2665+ ** .pp
2666+ ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2667+ ** encoded according to RFC2047 to base64. This is useful when message
2668+ ** is Usenet article, because MIME for news is nonstandard feature.
2669+ */
2670+#endif
ce1255c1
JB
2671 #ifdef MIXMASTER
2672 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2673 /*
bebcbf73
AG
2674@@ -1448,6 +1528,77 @@ struct option_t MuttVars[] = {
2675 ** See also $$read_inc, $$write_inc and $$net_inc.
ce1255c1 2676 */
bebcbf73 2677 #endif
ce1255c1
JB
2678+#ifdef USE_NNTP
2679+ { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2680+ /*
2681+ ** .pp
2682+ ** This variable pointing to directory where Mutt will save cached news
2683+ ** articles headers in. If \fIunset\fP, headers will not be saved at all
2684+ ** and will be reloaded each time when you enter to newsgroup.
2685+ */
2686+ { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2687+ /*
2688+ ** .pp
2689+ ** This variable specifies domain name or address of NNTP server. It
2690+ ** defaults to the newsserver specified in the environment variable
2691+ ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2692+ ** specify username and an alternative port for each newsserver, ie:
2693+ ** .pp
2694+ ** [news[s]://][username[:password]@]newsserver[:port]
2695+ */
2696+ { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2697+ /*
2698+ ** .pp
2699+ ** The file, containing info about subscribed newsgroups - names and
2700+ ** indexes of read articles. The following printf-style sequence
2701+ ** is understood:
2702+ ** .pp
2703+ ** .ts
2704+ ** %s newsserver name
2705+ ** .te
2706+ */
2707+ { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2708+ /*
2709+ ** .pp
2710+ ** This variable defines number of articles which will be in index when
2711+ ** newsgroup entered. If active newsgroup have more articles than this
2712+ ** number, oldest articles will be ignored. Also controls how many
2713+ ** articles headers will be saved in cache when you quit newsgroup.
2714+ */
2715+ { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2716+ /*
2717+ ** .pp
2718+ ** This variable controls whether or not descriptions for each newsgroup
2719+ ** must be loaded when newsgroup is added to list (first time list
2720+ ** loading or new newsgroup adding).
2721+ */
2722+ { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2723+ /*
2724+ ** .pp
2725+ ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2726+ ** authentification, Mutt will prompt you for your account name when you
2727+ ** connect to newsserver.
2728+ */
2729+ { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2730+ /*
2731+ ** .pp
2732+ ** Your password for NNTP account.
2733+ */
2734+ { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2735+ /*
2736+ ** .pp
2737+ ** The time in seconds until any operations on newsgroup except post new
2738+ ** article will cause recheck for new news. If set to 0, Mutt will
2739+ ** recheck newsgroup on each operation in index (stepping, read article,
2740+ ** etc.).
2741+ */
2742+ { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
2743+ /*
2744+ ** .pp
2745+ ** Controls whether or not Mutt will try to reconnect to newsserver when
2746+ ** connection lost.
2747+ */
2748+#endif
2749 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2750 /*
2751 ** .pp
bebcbf73 2752@@ -2331,6 +2482,16 @@ struct option_t MuttVars[] = {
ce1255c1
JB
2753 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2754 /*
2755 */
2756+#ifdef USE_NNTP
2757+ { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
2758+ /*
2759+ ** .pp
2760+ ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2761+ ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
2762+ ** does not support posting to that newsgroup or totally read-only, that
2763+ ** posting will not have an effect.
2764+ */
2765+#endif
2766 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
2767 /*
2768 ** .pp
bebcbf73 2769@@ -2725,6 +2886,28 @@ struct option_t MuttVars[] = {
ce1255c1 2770 ** Command to use when spawning a subshell. By default, the user's login
bebcbf73 2771 ** shell from \fC/etc/passwd\fP is used.
ce1255c1
JB
2772 */
2773+#ifdef USE_NNTP
2774+ { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2775+ /*
2776+ ** .pp
2777+ ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2778+ ** ``newsrc'' file and into cache.
2779+ */
2780+ { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2781+ /*
2782+ ** .pp
2783+ ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
2784+ ** the browser. Otherwise, it will be done only once for a newsserver.
2785+ ** Also controls whether or not number of new articles of subscribed
2786+ ** newsgroups will be then checked.
2787+ */
2788+ { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2789+ /*
2790+ ** .pp
2791+ ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2792+ ** will be displayed in browser.
2793+ */
2794+#endif
2795 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
2796 /*
2797 ** .pp
bebcbf73
AG
2798@@ -3275,6 +3458,14 @@ struct option_t MuttVars[] = {
2799 ** option does nothing: mutt will never write out the ``Bcc:'' header
ce1255c1
JB
2800 ** in this case.
2801 */
2802+#ifdef USE_NNTP
2803+ { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2804+ /*
2805+ ** .pp
2806+ ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2807+ ** name of original article author) to article that followuped to newsgroup.
2808+ */
2809+#endif
2810 /*--*/
2811 { NULL }
2812 };
bebcbf73
AG
2813diff -udprP mutt-1.5.19.orig/keymap.c mutt-1.5.19/keymap.c
2814--- mutt-1.5.19.orig/keymap.c 2008-11-26 20:48:48.000000000 +0200
2815+++ mutt-1.5.19/keymap.c 2009-01-06 22:27:38.000000000 +0200
2816@@ -654,7 +654,6 @@ void km_init (void)
2817 km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE);
2818
2819 km_bindkey ("x", MENU_PAGER, OP_EXIT);
2820- km_bindkey ("i", MENU_PAGER, OP_EXIT);
2821 km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE);
2822 km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE);
2823 km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE);
2824diff -udprP mutt-1.5.19.orig/mailbox.h mutt-1.5.19/mailbox.h
2825--- mutt-1.5.19.orig/mailbox.h 2008-03-19 22:07:06.000000000 +0200
2826+++ mutt-1.5.19/mailbox.h 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
2827@@ -74,6 +74,9 @@ int mx_is_imap (const char *);
2828 #ifdef USE_POP
2829 int mx_is_pop (const char *);
2830 #endif
2831+#ifdef USE_NNTP
2832+int mx_is_nntp (const char *);
2833+#endif
2834
2835 int mx_access (const char*, int);
2836 int mx_check_empty (const char *);
bebcbf73
AG
2837diff -udprP mutt-1.5.19.orig/main.c mutt-1.5.19/main.c
2838--- mutt-1.5.19.orig/main.c 2009-01-04 01:27:10.000000000 +0200
2839+++ mutt-1.5.19/main.c 2009-01-06 22:27:38.000000000 +0200
2840@@ -60,6 +60,10 @@
ce1255c1
JB
2841 #include <stringprep.h>
2842 #endif
2843
2844+#ifdef USE_NNTP
2845+#include "nntp.h"
2846+#endif
2847+
2848 static const char *ReachingUs = N_("\
2849 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2850 To report a bug, please visit http://bugs.mutt.org/.\n");
bebcbf73 2851@@ -133,6 +137,8 @@ options:\n\
ce1255c1
JB
2852 " -e <command>\tspecify a command to be executed after initialization\n\
2853 -f <file>\tspecify which mailbox to read\n\
2854 -F <file>\tspecify an alternate muttrc file\n\
2855+ -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
2856+ -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2857 -H <file>\tspecify a draft file to read header and body from\n\
2858 -i <file>\tspecify a file which Mutt should include in the body\n\
2859 -m <type>\tspecify a default mailbox type\n\
bebcbf73 2860@@ -255,6 +261,12 @@ static void show_version (void)
ce1255c1
JB
2861 "-USE_POP "
2862 #endif
2863
2864+#ifdef USE_NNTP
2865+ "+USE_NNTP "
2866+#else
2867+ "-USE_NNTP "
2868+#endif
2869+
2870 #ifdef USE_IMAP
2871 "+USE_IMAP "
2872 #else
bebcbf73 2873@@ -522,6 +534,9 @@ static void start_curses (void)
ce1255c1
JB
2874 #define M_NOSYSRC (1<<2) /* -n */
2875 #define M_RO (1<<3) /* -R */
2876 #define M_SELECT (1<<4) /* -y */
2877+#ifdef USE_NNTP
2878+#define M_NEWS (1<<5) /* -g and -G */
2879+#endif
2880
2881 int main (int argc, char **argv)
2882 {
bebcbf73
AG
2883@@ -594,7 +609,11 @@ int main (int argc, char **argv)
2884 argv[nargc++] = argv[optind];
ce1255c1
JB
2885 }
2886
2887+#ifdef USE_NNTP
bebcbf73 2888+ if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
ce1255c1 2889+#else
bebcbf73 2890 if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
ce1255c1 2891+#endif
bebcbf73
AG
2892 switch (i)
2893 {
ce1255c1 2894 case 'A':
bebcbf73 2895@@ -687,6 +706,20 @@ int main (int argc, char **argv)
ce1255c1
JB
2896 flags |= M_SELECT;
2897 break;
2898
2899+#ifdef USE_NNTP
2900+ case 'g': /* Specify a newsserver */
2901+ {
2902+ char buf[LONG_STRING];
2903+
2904+ snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
2905+ commands = mutt_add_list (commands, buf);
2906+ }
2907+
2908+ case 'G': /* List of newsgroups */
2909+ flags |= M_SELECT | M_NEWS;
2910+ break;
2911+#endif
2912+
2913 case 'z':
2914 flags |= M_IGNORE;
2915 break;
bebcbf73 2916@@ -974,6 +1007,18 @@ int main (int argc, char **argv)
ce1255c1
JB
2917 }
2918 else if (flags & M_SELECT)
2919 {
2920+#ifdef USE_NNTP
2921+ if (flags & M_NEWS)
2922+ {
2923+ set_option (OPTNEWS);
2924+ if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2925+ {
2926+ mutt_endwin (Errorbuf);
2927+ exit (1);
2928+ }
2929+ }
2930+ else
2931+#endif
2932 if (!Incoming) {
2933 mutt_endwin _("No incoming mailboxes defined.");
2934 exit (1);
bebcbf73 2935@@ -989,6 +1034,15 @@ int main (int argc, char **argv)
ce1255c1
JB
2936
2937 if (!folder[0])
2938 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
2939+
2940+#ifdef USE_NNTP
2941+ if (option (OPTNEWS))
2942+ {
2943+ unset_option (OPTNEWS);
2944+ nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
2945+ }
2946+ else
2947+#endif
2948 mutt_expand_path (folder, sizeof (folder));
2949
2950 mutt_str_replace (&CurrentFolder, folder);
bebcbf73
AG
2951diff -udprP mutt-1.5.19.orig/mutt.h mutt-1.5.19/mutt.h
2952--- mutt-1.5.19.orig/mutt.h 2008-09-26 01:00:03.000000000 +0300
2953+++ mutt-1.5.19/mutt.h 2009-01-06 22:27:38.000000000 +0200
2954@@ -223,6 +223,9 @@ enum
ce1255c1
JB
2955 M_PGP_KEY,
2956 M_XLABEL,
2957 M_MIMEATTACH,
2958+#ifdef USE_NNTP
2959+ M_NEWSGROUPS,
2960+#endif
2961
2962 /* Options for Mailcap lookup */
2963 M_EDIT,
bebcbf73 2964@@ -278,6 +281,12 @@ enum
ce1255c1
JB
2965 #endif
2966 OPT_SUBJECT,
2967 OPT_VERIFYSIG, /* verify PGP signatures */
2968+#ifdef USE_NNTP
2969+ OPT_TOMODERATED,
2970+ OPT_NNTPRECONNECT,
2971+ OPT_CATCHUP,
2972+ OPT_FOLLOWUPTOPOSTER,
2973+#endif /* USE_NNTP */
2974
2975 /* THIS MUST BE THE LAST VALUE. */
2976 OPT_MAX
bebcbf73 2977@@ -293,6 +302,7 @@ enum
ce1255c1
JB
2978 #define SENDMAILX (1<<6)
2979 #define SENDKEY (1<<7)
2980 #define SENDRESEND (1<<8)
2981+#define SENDNEWS (1<<9)
2982
2983 /* flags to _mutt_select_file() */
2984 #define M_SEL_BUFFY (1<<0)
bebcbf73 2985@@ -312,6 +322,8 @@ enum
ce1255c1
JB
2986 OPTASCIICHARS,
2987 OPTASKBCC,
2988 OPTASKCC,
2989+ OPTASKFOLLOWUP,
2990+ OPTASKXCOMMENTTO,
2991 OPTATTACHSPLIT,
2992 OPTAUTOEDIT,
2993 OPTAUTOTAG,
bebcbf73 2994@@ -387,6 +399,9 @@ enum
ce1255c1
JB
2995 OPTMETOO,
2996 OPTMHPURGE,
2997 OPTMIMEFORWDECODE,
2998+#ifdef USE_NNTP
2999+ OPTMIMESUBJECT, /* encode subject line with RFC2047 */
3000+#endif
3001 OPTNARROWTREE,
3002 OPTPAGERSTOP,
3003 OPTPIPEDECODE,
bebcbf73 3004@@ -468,6 +483,16 @@ enum
ce1255c1
JB
3005 OPTPGPAUTOINLINE,
3006 OPTPGPREPLYINLINE,
3007
3008+ /* news options */
3009+
3010+#ifdef USE_NNTP
3011+ OPTSHOWNEWNEWS,
3012+ OPTSHOWONLYUNREAD,
3013+ OPTSAVEUNSUB,
3014+ OPTLOADDESC,
3015+ OPTXCOMMENTTO,
3016+#endif /* USE_NNTP */
3017+
3018 /* pseudo options */
3019
3020 OPTAUXSORT, /* (pseudo) using auxillary sort function */
bebcbf73 3021@@ -488,6 +513,7 @@ enum
ce1255c1
JB
3022 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
3023 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3024 OPTATTACHMSG, /* (pseudo) used by attach-message */
3025+ OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3026 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3027 * functions while we are executing an
3028 * external program.
bebcbf73 3029@@ -498,6 +524,12 @@ enum
ce1255c1
JB
3030 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3031 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
3032
3033+#ifdef USE_NNTP
3034+ OPTNEWS, /* (pseudo) used to change reader mode */
3035+ OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3036+ OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
3037+#endif
3038+
3039 OPTMAX
3040 };
3041
bebcbf73 3042@@ -575,6 +607,13 @@ typedef struct envelope
ce1255c1
JB
3043 char *supersedes;
3044 char *date;
3045 char *x_label;
3046+ char *organization;
3047+#ifdef USE_NNTP
3048+ char *newsgroups;
3049+ char *xref;
3050+ char *followup_to;
3051+ char *x_comment_to;
3052+#endif
3053 BUFFER *spam;
3054 LIST *references; /* message references (in reverse order) */
3055 LIST *in_reply_to; /* in-reply-to header content */
bebcbf73 3056@@ -741,6 +780,9 @@ typedef struct header
ce1255c1
JB
3057 ENVELOPE *env; /* envelope information */
3058 BODY *content; /* list of MIME parts */
3059 char *path;
3060+#ifdef USE_NNTP
3061+ int article_num;
3062+#endif
3063
3064 char *tree; /* character string to print thread tree */
3065 struct thread *thread;
bebcbf73 3066@@ -756,7 +798,7 @@ typedef struct header
ce1255c1
JB
3067 int refno; /* message number on server */
3068 #endif
3069
3070-#if defined USE_POP || defined USE_IMAP
3071+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3072 void *data; /* driver-specific data */
3073 #endif
3074
bebcbf73
AG
3075diff -udprP mutt-1.5.19.orig/muttlib.c mutt-1.5.19/muttlib.c
3076--- mutt-1.5.19.orig/muttlib.c 2009-01-05 21:20:53.000000000 +0200
3077+++ mutt-1.5.19/muttlib.c 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
3078@@ -286,7 +286,7 @@ void mutt_free_header (HEADER **h)
3079 #ifdef MIXMASTER
3080 mutt_free_list (&(*h)->chain);
3081 #endif
3082-#if defined USE_POP || defined USE_IMAP
3083+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3084 FREE (&(*h)->data);
3085 #endif
3086 FREE (h); /* __FREE_CHECKED__ */
3087@@ -674,6 +674,13 @@ void mutt_free_envelope (ENVELOPE **p)
3088 FREE (&(*p)->supersedes);
3089 FREE (&(*p)->date);
3090 FREE (&(*p)->x_label);
3091+ FREE (&(*p)->organization);
3092+#ifdef USE_NNTP
3093+ FREE (&(*p)->newsgroups);
3094+ FREE (&(*p)->xref);
3095+ FREE (&(*p)->followup_to);
3096+ FREE (&(*p)->x_comment_to);
3097+#endif
3098
3099 mutt_buffer_free (&(*p)->spam);
3100
bebcbf73 3101@@ -1455,6 +1462,14 @@ int mutt_save_confirm (const char *s, st
ce1255c1
JB
3102 }
3103 }
3104
3105+#ifdef USE_NNTP
3106+ if (magic == M_NNTP)
3107+ {
3108+ mutt_error _("Can't save message to newsserver.");
3109+ return 0;
3110+ }
3111+#endif
3112+
3113 if (stat (s, st) != -1)
3114 {
3115 if (magic == -1)
bebcbf73
AG
3116diff -udprP mutt-1.5.19.orig/mx.c mutt-1.5.19/mx.c
3117--- mutt-1.5.19.orig/mx.c 2009-01-05 21:20:53.000000000 +0200
3118+++ mutt-1.5.19/mx.c 2009-01-06 22:27:38.000000000 +0200
3119@@ -343,6 +343,22 @@ int mx_is_pop (const char *p)
ce1255c1
JB
3120 }
3121 #endif
3122
3123+#ifdef USE_NNTP
3124+int mx_is_nntp (const char *p)
3125+{
3126+ url_scheme_t scheme;
3127+
3128+ if (!p)
3129+ return 0;
3130+
3131+ scheme = url_check_scheme (p);
3132+ if (scheme == U_NNTP || scheme == U_NNTPS)
3133+ return 1;
3134+
3135+ return 0;
3136+}
3137+#endif
3138+
3139 int mx_get_magic (const char *path)
3140 {
3141 struct stat st;
bebcbf73 3142@@ -360,6 +376,11 @@ int mx_get_magic (const char *path)
ce1255c1
JB
3143 return M_POP;
3144 #endif /* USE_POP */
3145
3146+#ifdef USE_NNTP
3147+ if (mx_is_nntp (path))
3148+ return M_NNTP;
3149+#endif /* USE_NNTP */
3150+
3151 if (stat (path, &st) == -1)
3152 {
3153 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
bebcbf73 3154@@ -699,6 +720,12 @@ CONTEXT *mx_open_mailbox (const char *pa
ce1255c1
JB
3155 break;
3156 #endif /* USE_POP */
3157
3158+#ifdef USE_NNTP
3159+ case M_NNTP:
3160+ rc = nntp_open_mailbox (ctx);
3161+ break;
3162+#endif /* USE_NNTP */
3163+
3164 default:
3165 rc = -1;
3166 break;
bebcbf73 3167@@ -791,6 +818,12 @@ static int sync_mailbox (CONTEXT *ctx, i
ce1255c1
JB
3168 rc = pop_sync_mailbox (ctx, index_hint);
3169 break;
3170 #endif /* USE_POP */
3171+
3172+#ifdef USE_NNTP
3173+ case M_NNTP:
3174+ rc = nntp_sync_mailbox (ctx);
3175+ break;
3176+#endif /* USE_NNTP */
3177 }
3178
3179 #if 0
bebcbf73 3180@@ -817,6 +850,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
ce1255c1
JB
3181
3182 ctx->closing = 1;
3183
3184+#ifdef USE_NNTP
3185+ if (ctx->magic == M_NNTP)
3186+ {
3187+ int ret;
3188+
3189+ ret = nntp_close_mailbox (ctx);
3190+ mx_fastclose_mailbox (ctx);
3191+ return ret;
3192+ }
3193+#endif
3194 if (ctx->readonly || ctx->dontwrite)
3195 {
3196 /* mailbox is readonly or we don't want to write */
bebcbf73 3197@@ -1354,6 +1397,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
ce1255c1
JB
3198 case M_POP:
3199 return (pop_check_mailbox (ctx, index_hint));
3200 #endif /* USE_POP */
3201+
3202+#ifdef USE_NNTP
3203+ case M_NNTP:
3204+ return (nntp_check_mailbox (ctx));
3205+#endif /* USE_NNTP */
3206 }
3207 }
3208
bebcbf73 3209@@ -1414,6 +1462,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
ce1255c1
JB
3210 }
3211 #endif /* USE_POP */
3212
3213+#ifdef USE_NNTP
3214+ case M_NNTP:
3215+ {
3216+ if (nntp_fetch_message (msg, ctx, msgno) != 0)
3217+ FREE (&msg);
3218+ break;
3219+ }
3220+#endif /* USE_NNTP */
3221+
3222 default:
3223 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3224 FREE (&msg);
bebcbf73 3225@@ -1495,6 +1552,9 @@ int mx_close_message (MESSAGE **msg)
ce1255c1
JB
3226 #ifdef USE_POP
3227 || (*msg)->magic == M_POP
3228 #endif
3229+#ifdef USE_NNTP
3230+ || (*msg)->magic == M_NNTP
3231+#endif
3232 )
3233 {
3234 r = safe_fclose (&(*msg)->fp);
bebcbf73
AG
3235diff -udprP mutt-1.5.19.orig/mx.h mutt-1.5.19/mx.h
3236--- mutt-1.5.19.orig/mx.h 2008-03-19 22:07:06.000000000 +0200
3237+++ mutt-1.5.19/mx.h 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
3238@@ -40,6 +40,9 @@ enum
3239 #ifdef USE_POP
3240 , M_POP
3241 #endif
3242+#ifdef USE_NNTP
3243+ , M_NNTP
3244+#endif
3245 };
3246
3247 WHERE short DefaultMagic INITVAL (M_MBOX);
bebcbf73
AG
3248diff -udprP mutt-1.5.19.orig/newsrc.c mutt-1.5.19/newsrc.c
3249--- mutt-1.5.19.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3250+++ mutt-1.5.19/newsrc.c 2009-01-06 22:27:38.000000000 +0200
ce1255c1
JB
3251@@ -0,0 +1,1170 @@
3252+/*
3253+ * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3254+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
bebcbf73 3255+ * Copyright (C) 2000-2009 Vsevolod Volkov <vvv@mutt.org.ua>
ce1255c1
JB
3256+ *
3257+ * This program is free software; you can redistribute it and/or modify
3258+ * it under the terms of the GNU General Public License as published by
3259+ * the Free Software Foundation; either version 2 of the License, or
3260+ * (at your option) any later version.
3261+ *
3262+ * This program is distributed in the hope that it will be useful,
3263+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3264+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3265+ * GNU General Public License for more details.
3266+ *
3267+ * You should have received a copy of the GNU General Public License
3268+ * along with this program; if not, write to the Free Software
3269+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3270+ */
3271+
3272+#if HAVE_CONFIG_H
3273+# include "config.h"
3274+#endif
3275+
3276+#include "mutt.h"
3277+#include "mutt_curses.h"
3278+#include "sort.h"
3279+#include "mx.h"
3280+#include "mime.h"
3281+#include "mailbox.h"
3282+#include "nntp.h"
3283+#include "rfc822.h"
3284+#include "rfc1524.h"
3285+#include "rfc2047.h"
3286+
3287+#include <unistd.h>
3288+#include <string.h>
3289+#include <ctype.h>
3290+#include <stdlib.h>
3291+#include <sys/stat.h>
3292+
3293+void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3294+{
3295+ LIST *l;
3296+
3297+ if (!s || !d)
3298+ return;
3299+
3300+ l = safe_calloc (1, sizeof (LIST));
3301+ if (s->list)
3302+ s->tail->next = l;
3303+ else
3304+ s->list = l;
3305+ s->tail = l;
3306+ l->data = (void *) d;
3307+}
3308+
3309+static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3310+{
3311+ NNTP_DATA *data;
3312+ char group[LONG_STRING];
3313+ int x = 1;
3314+ char *p = line, *b, *h;
3315+ size_t len;
3316+
3317+ while (*p)
3318+ {
3319+ if (*p++ == ',')
3320+ x++;
3321+ }
3322+
3323+ p = line;
3324+ while (*p && (*p != ':' && *p != '!')) p++;
3325+ if (!*p)
3326+ return -1;
3327+ len = p + 1 - line;
3328+ if (len > sizeof (group))
3329+ len = sizeof (group);
3330+ strfcpy (group, line, len);
3331+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3332+ {
3333+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3334+ data->group = (char *) data + sizeof (NNTP_DATA);
3335+ strcpy (data->group, group);
3336+ data->nserv = news;
3337+ data->deleted = 1;
3338+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3339+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3340+ hash_insert (news->newsgroups, data->group, data, 0);
3341+ nntp_add_to_list (news, data);
3342+ }
3343+ else
3344+ FREE ((void **) &data->entries);
3345+
3346+ data->rc = 1;
3347+ data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3348+ data->max = x*2;
3349+
3350+ if (*p == ':')
3351+ data->subscribed = 1;
3352+ else
3353+ data->subscribed = 0;
3354+
3355+ p++;
3356+ b = p;
3357+ x = 0;
3358+ while (*b)
3359+ {
3360+ while (*p && *p != ',' && *p != '\n') p++;
3361+ if (*p)
3362+ {
3363+ *p = '\0';
3364+ p++;
3365+ }
3366+ if ((h = strchr(b, '-')))
3367+ {
3368+ *h = '\0';
3369+ h++;
3370+ data->entries[x].first = atoi(b);
3371+ data->entries[x].last = atoi(h);
3372+ }
3373+ else
3374+ {
3375+ data->entries[x].first = atoi(b);
3376+ data->entries[x].last = data->entries[x].first;
3377+ }
3378+ b = p;
3379+ if (data->entries[x].last != 0)
3380+ x++;
3381+ }
3382+ if (x && !data->lastMessage)
3383+ data->lastMessage = data->entries[x-1].last;
3384+ data->num = x;
3385+ mutt_newsgroup_stat (data);
3386+ dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3387+
3388+ return 0;
3389+}
3390+
3391+static int slurp_newsrc (NNTP_SERVER *news)
3392+{
3393+ FILE *fp;
3394+ char *buf;
3395+ struct stat sb;
3396+
3397+ news->stat = stat (news->newsrc, &sb);
3398+ news->size = sb.st_size;
3399+ news->mtime = sb.st_mtime;
3400+
3401+ if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3402+ return -1;
3403+ /* hmm, should we use dotlock? */
3404+ if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3405+ {
3406+ fclose (fp);
3407+ return -1;
3408+ }
3409+
3410+ buf = safe_malloc (sb.st_size + 1);
3411+ while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3412+ nntp_parse_newsrc_line (news, buf);
3413+ FREE (&buf);
3414+
3415+ mx_unlock_file (news->newsrc, fileno (fp), 0);
3416+ fclose (fp);
3417+ return 0;
3418+}
3419+
3420+void nntp_cache_expand (char *dst, const char *src)
3421+{
3422+ snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3423+ mutt_expand_path (dst, _POSIX_PATH_MAX);
3424+}
3425+
3426+/* Loads $news_cache_dir/.index into memory, loads newsserver data
3427+ * and newsgroup cache names */
3428+static int nntp_parse_cacheindex (NNTP_SERVER *news)
3429+{
3430+ struct stat st;
3431+ char buf[HUGE_STRING], *cp;
3432+ char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3433+ FILE *index;
3434+ NNTP_DATA *data;
3435+ int l, m, t;
3436+
3437+ /* check is server name defined or not */
3438+ if (!news || !news->conn || !news->conn->account.host)
3439+ return -1;
3440+ unset_option (OPTNEWSCACHE);
3441+ if (!NewsCacheDir || !*NewsCacheDir)
3442+ return 0;
3443+
3444+ strfcpy (dir, NewsCacheDir, sizeof (dir));
3445+ mutt_expand_path (dir, sizeof(dir));
3446+
3447+ if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3448+ {
3449+ snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3450+ if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3451+ S_IRWXO)))
3452+ {
3453+ mutt_error _("Cache directory not created!");
3454+ return -1;
3455+ }
3456+ mutt_clear_error();
3457+ }
3458+
3459+ set_option (OPTNEWSCACHE);
3460+
3461+ FREE (&news->cache);
3462+ snprintf (buf, sizeof(buf), "%s/.index", dir);
3463+ if (!(index = safe_fopen (buf, "a+")))
3464+ return 0;
3465+ rewind (index);
3466+ while (fgets (buf, sizeof(buf), index))
3467+ {
3468+ buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3469+ if (!mutt_strncmp (buf, "#: ", 3) &&
3470+ !mutt_strcasecmp (buf+3, news->conn->account.host))
3471+ break;
3472+ }
3473+ while (fgets (buf, sizeof(buf), index))
3474+ {
3475+ cp = buf;
3476+ while (*cp && *cp != ' ') cp++;
3477+ if (!*cp) continue;
3478+ cp[0] = 0;
3479+ if (!mutt_strcmp (buf, "#:"))
3480+ break;
3481+ sscanf (cp + 1, "%s %d %d", file, &l, &m);
3482+ if (!mutt_strcmp (buf, "ALL"))
3483+ {
3484+ news->cache = safe_strdup (file);
3485+ news->newgroups_time = m;
3486+ }
3487+ else if (news->newsgroups)
3488+ {
3489+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3490+ {
3491+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3492+ data->group = (char *) data + sizeof (NNTP_DATA);
3493+ strcpy(data->group, buf);
3494+ data->nserv = news;
3495+ data->deleted = 1;
3496+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3497+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3498+ hash_insert (news->newsgroups, data->group, data, 0);
3499+ nntp_add_to_list (news, data);
3500+ }
3501+ data->cache = safe_strdup (file);
3502+ t = 0;
3503+ if (!data->firstMessage || data->lastMessage < m)
3504+ t = 1;
3505+ if (!data->firstMessage)
3506+ data->firstMessage = l;
3507+ if (data->lastMessage < m)
3508+ data->lastMessage = m;
3509+ data->lastCached = m;
3510+ if (t || !data->unread)
3511+ mutt_newsgroup_stat (data);
3512+ }
3513+ }
3514+ fclose (index);
3515+ return 0;
3516+}
3517+
3518+const char *
bebcbf73 3519+nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
ce1255c1
JB
3520+ const char *fmt, const char *ifstring, const char *elsestring,
3521+ unsigned long data, format_flag flags)
3522+{
3523+ char fn[SHORT_STRING], tmp[SHORT_STRING];
3524+
3525+ switch (op)
3526+ {
3527+ case 's':
3528+ strncpy (fn, NewsServer, sizeof(fn) - 1);
3529+ mutt_strlower (fn);
3530+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3531+ snprintf (dest, destlen, tmp, fn);
3532+ break;
3533+ }
3534+ return (src);
3535+}
3536+
3537+/* nntp_parse_url: given an NNPT URL, return host, port,
3538+ * username, password and newsgroup will recognise. */
3539+int nntp_parse_url (const char *server, ACCOUNT *acct,
3540+ char *group, size_t group_len)
3541+{
3542+ ciss_url_t url;
3543+ char *c;
3544+ int ret = -1;
3545+
3546+ /* Defaults */
3547+ acct->flags = 0;
3548+ acct->port = NNTP_PORT;
3549+ acct->type = M_ACCT_TYPE_NNTP;
3550+
3551+ c = safe_strdup (server);
3552+ url_parse_ciss (&url, c);
3553+
3554+ if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3555+ {
3556+ if (url.scheme == U_NNTPS)
3557+ {
3558+ acct->flags |= M_ACCT_SSL;
3559+ acct->port = NNTP_SSL_PORT;
3560+ }
3561+
3562+ *group = '\0';
3563+ if (url.path)
3564+ strfcpy (group, url.path, group_len);
3565+
3566+ ret = mutt_account_fromurl (acct, &url);
3567+ }
3568+
3569+ FREE (&c);
3570+ return ret;
3571+}
3572+
3573+void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3574+{
3575+ ciss_url_t url;
3576+
3577+ url.path = safe_strdup (line);
3578+ mutt_account_tourl (acct, &url);
3579+ url_ciss_tostring (&url, line, len, 0);
3580+ FREE (&url.path);
3581+}
3582+
3583+/*
3584+ * Automatically loads a newsrc into memory, if necessary.
3585+ * Checks the size/mtime of a newsrc file, if it doesn't match, load
3586+ * again. Hmm, if a system has broken mtimes, this might mean the file
3587+ * is reloaded every time, which we'd have to fix.
3588+ *
3589+ * a newsrc file is a line per newsgroup, with the newsgroup, then a
3590+ * ':' denoting subscribed or '!' denoting unsubscribed, then a
3591+ * comma separated list of article numbers and ranges.
3592+ */
3593+NNTP_SERVER *mutt_select_newsserver (char *server)
3594+{
3595+ char file[_POSIX_PATH_MAX];
3596+ char *buf, *p;
3597+ LIST *list;
3598+ ACCOUNT acct;
3599+ NNTP_SERVER *serv;
3600+ CONNECTION *conn;
3601+
3602+ if (!server || !*server)
3603+ {
3604+ mutt_error _("No newsserver defined!");
3605+ return NULL;
3606+ }
3607+
3608+ buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
3609+ if (url_check_scheme (server) == U_UNKNOWN)
3610+ {
3611+ strcpy (buf, "news://");
3612+ p = strchr (buf, '\0');
3613+ }
3614+ strcpy (p, server);
3615+
3616+ if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
3617+ {
3618+ FREE (&buf);
3619+ mutt_error (_("%s is an invalid newsserver specification!"), server);
3620+ return NULL;
3621+ }
3622+ FREE (&buf);
3623+
3624+ conn = mutt_conn_find (NULL, &acct);
3625+ if (!conn)
3626+ return NULL;
3627+
3628+ mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), nntp_format_str, 0, 0);
3629+ mutt_expand_path (file, sizeof (file));
3630+
3631+ serv = (NNTP_SERVER *)conn->data;
3632+ if (serv)
3633+ {
3634+ struct stat sb;
3635+
3636+ /* externally modified? */
3637+ if (serv->stat != stat (file, &sb) || (!serv->stat &&
3638+ (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
3639+ {
3640+ for (list = serv->list; list; list = list->next)
3641+ {
3642+ NNTP_DATA *data = (NNTP_DATA *) list->data;
3643+
3644+ if (data)
3645+ {
3646+ data->subscribed = 0;
3647+ data->rc = 0;
3648+ data->num = 0;
3649+ }
3650+ }
3651+ slurp_newsrc (serv);
3652+ nntp_clear_cacheindex (serv);
3653+ }
3654+
3655+ if (serv->status == NNTP_BYE)
3656+ serv->status = NNTP_NONE;
3657+ nntp_check_newgroups (serv, 0);
3658+ return serv;
3659+ }
3660+
3661+ /* New newsserver */
3662+ serv = safe_calloc (1, sizeof (NNTP_SERVER));
3663+ serv->conn = conn;
3664+ serv->newsrc = safe_strdup (file);
3665+ serv->newsgroups = hash_create (1009);
3666+ slurp_newsrc (serv); /* load .newsrc */
3667+ nntp_parse_cacheindex (serv); /* load .index */
3668+ if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
3669+ nntp_check_newgroups (serv, 1);
3670+ else if (nntp_get_active (serv) < 0)
3671+ {
3672+ hash_destroy (&serv->newsgroups, nntp_delete_data);
3673+ for (list = serv->list; list; list = list->next)
3674+ list->data = NULL;
3675+ mutt_free_list (&serv->list);
3676+ FREE (&serv->newsrc);
3677+ FREE (&serv->cache);
3678+ FREE (&serv);
3679+ return NULL;
3680+ }
3681+ nntp_clear_cacheindex (serv);
3682+ conn->data = (void *)serv;
3683+
3684+ return serv;
3685+}
3686+
3687+/*
3688+ * full status flags are not supported by nntp, but we can fake some
3689+ * of them. This is how:
3690+ * Read = a read message number is in the .newsrc
3691+ * New = a message is new since we last read this newsgroup
3692+ * Old = anything else
3693+ * So, Read is marked as such in the newsrc, old is anything that is
3694+ * "skipped" in the newsrc, and new is anything not in the newsrc nor
3695+ * in the cache. By skipped, I mean before the last unread message
3696+ */
3697+void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
3698+{
3699+ NNTP_DATA *data = (NNTP_DATA *) ctx->data;
3700+ int x;
3701+
3702+ if (group)
3703+ data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
3704+
3705+ if (!data)
3706+ {
3707+#ifdef DEBUG
3708+ if (group)
3709+ dprint (3, (debugfile, "newsgroup %s not found\n", group));
3710+#endif
3711+ return;
3712+ }
3713+
3714+ for (x = 0; x < data->num; x++)
3715+ {
3716+ if ((article >= data->entries[x].first) &&
3717+ (article <= data->entries[x].last))
3718+ {
3719+ /* we cannot use mutt_set_flag() because mx_update_context()
3720+ didn't called yet */
3721+ h->read = 1;
3722+ return;
3723+ }
3724+ }
3725+ /* If article was not cached yet, it is new! :) */
3726+ if (!data->cache || article > data->lastCached)
3727+ return;
3728+ /* Old articles are articles which aren't read but an article after them
3729+ * has been cached */
3730+ if (option (OPTMARKOLD))
3731+ h->old = 1;
3732+}
3733+
3734+void mutt_newsgroup_stat (NNTP_DATA *data)
3735+{
3736+ int i;
3737+ unsigned int first, last;
3738+
3739+ data->unread = 0;
3740+ if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
3741+ return;
3742+
3743+ data->unread = data->lastMessage - data->firstMessage + 1;
3744+ for (i = 0; i < data->num; i++)
3745+ {
3746+ first = data->entries[i].first;
3747+ if (first < data->firstMessage)
3748+ first = data->firstMessage;
3749+ last = data->entries[i].last;
3750+ if (last > data->lastMessage)
3751+ last = data->lastMessage;
3752+ if (first <= last)
3753+ data->unread -= last - first + 1;
3754+ }
3755+}
3756+
3757+static int puti (char *line, int num)
3758+{
3759+ char *p, s[32];
3760+
3761+ for (p = s; num; )
3762+ {
3763+ *p++ = '0' + num % 10;
3764+ num /= 10;
3765+ }
3766+ while (p > s)
3767+ *line++ = *--p, num++;
3768+ *line = '\0';
3769+ return num;
3770+}
3771+
3772+static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
3773+{
3774+ char *line = *pline;
3775+ size_t len = *buflen - (*pline - *buf);
3776+ int x, i;
3777+
3778+ if (len < LONG_STRING * 10)
3779+ {
3780+ len += *buflen;
3781+ *buflen *= 2;
3782+ line = *buf;
3783+ safe_realloc (buf, *buflen);
3784+ line = *buf + (*pline - line);
3785+ }
3786+ strcpy (line, data->group);
3787+ len -= strlen (line) + 1;
3788+ line += strlen (line);
3789+ *line++ = data->subscribed ? ':' : '!';
3790+ *line++ = ' ';
3791+ *line = '\0';
3792+
3793+ for (x = 0; x < data->num; x++)
3794+ {
3795+ if (len < LONG_STRING)
3796+ {
3797+ len += *buflen;
3798+ *buflen *= 2;
3799+ *pline = line;
3800+ line = *buf;
3801+ safe_realloc (buf, *buflen);
3802+ line = *buf + (*pline - line);
3803+ }
3804+ if (x)
3805+ {
3806+ *line++ = ',';
3807+ len--;
3808+ }
3809+
3810+#if 0
3811+ if (data->entries[x].first == data->entries[x].last)
3812+ snprintf (line, len, "%d%n", data->entries[x].first, &i);
3813+ else
3814+ snprintf (line, len, "%d-%d%n",
3815+ data->entries[x].first, data->entries[x].last, &i);
3816+ len -= i;
3817+ line += i;
3818+#else
3819+ i = puti (line, data->entries[x].first);
3820+ line +=i; len -= i;
3821+ if (data->entries[x].first != data->entries[x].last)
3822+ {
3823+ *line++ = '-';
3824+ len--;
3825+ i = puti (line, data->entries[x].last);
3826+ line +=i; len -= i;
3827+ }
3828+#endif
3829+ }
3830+ *line++ = '\n';
3831+ *line = '\0';
3832+ *pline = line;
3833+}
3834+
3835+void newsrc_gen_entries (CONTEXT *ctx)
3836+{
3837+ NNTP_DATA *data = (NNTP_DATA *)ctx->data;
3838+ int series, x;
3839+ unsigned int last = 0, first = 1;
3840+ int save_sort = SORT_ORDER;
3841+
3842+ if (Sort != SORT_ORDER)
3843+ {
3844+ save_sort = Sort;
3845+ Sort = SORT_ORDER;
3846+ mutt_sort_headers (ctx, 0);
3847+ }
3848+
3849+ if (!data->max)
3850+ {
3851+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
3852+ data->max = 5;
3853+ }
3854+
3855+ /*
3856+ * Set up to fake initial sequence from 1 to the article before the
3857+ * first article in our list
3858+ */
3859+ data->num = 0;
3860+ series = 1;
3861+
3862+ for (x = 0; x < ctx->msgcount; x++)
3863+ {
3864+ if (series) /* search for first unread */
3865+ {
3866+ /*
3867+ * We don't actually check sequential order, since we mark
3868+ * "missing" entries as read/deleted
3869+ */
3870+ last = ctx->hdrs[x]->article_num;
3871+ if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
3872+ !ctx->hdrs[x]->read)
3873+ {
3874+ if (data->num >= data->max)
3875+ {
3876+ data->max = data->max * 2;
3877+ safe_realloc (&data->entries,
3878+ data->max * sizeof (NEWSRC_ENTRY));
3879+ }
3880+ data->entries[data->num].first = first;
3881+ data->entries[data->num].last = last - 1;
3882+ data->num++;
3883+ series = 0;
3884+ }
3885+ }
3886+ else /* search for first read */
3887+ {
3888+ if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
3889+ {
3890+ first = last + 1;
3891+ series = 1;
3892+ }
3893+ last = ctx->hdrs[x]->article_num;
3894+ }
3895+ }
3896+ if (series && first <= data->lastLoaded)
3897+ {
3898+ if (data->num >= data->max)
3899+ {
3900+ data->max = data->max * 2;
3901+ safe_realloc (&data->entries,
3902+ data->max * sizeof (NEWSRC_ENTRY));
3903+ }
3904+ data->entries[data->num].first = first;
3905+ data->entries[data->num].last = data->lastLoaded;
3906+ data->num++;
3907+ }
3908+
3909+ if (save_sort != Sort)
3910+ {
3911+ Sort = save_sort;
3912+ mutt_sort_headers (ctx, 0);
3913+ }
3914+}
3915+
3916+static int mutt_update_list_file (char *filename, char *section,
3917+ char *key, char *line)
3918+{
3919+ FILE *ifp;
3920+ FILE *ofp;
3921+ char buf[HUGE_STRING];
3922+ char tmpfile[_POSIX_PATH_MAX];
3923+ char *c;
3924+ int ext = 0, done = 0, r = 0;
3925+
3926+ /* if file not exist, create it */
3927+ if ((ifp = safe_fopen (filename, "a")))
3928+ fclose (ifp);
3929+ dprint (1, (debugfile, "Opening %s\n", filename));
3930+ if (!(ifp = safe_fopen (filename, "r")))
3931+ {
3932+ mutt_error (_("Unable to open %s for reading"), filename);
3933+ return -1;
3934+ }
3935+ if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
3936+ {
3937+ fclose (ifp);
3938+ mutt_error (_("Unable to lock %s"), filename);
3939+ return -1;
3940+ }
3941+ snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
3942+ dprint (1, (debugfile, "Opening %s\n", tmpfile));
3943+ if (!(ofp = fopen (tmpfile, "w")))
3944+ {
3945+ fclose (ifp);
3946+ mutt_error (_("Unable to open %s for writing"), tmpfile);
3947+ return -1;
3948+ }
3949+
3950+ if (section)
3951+ {
3952+ while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
3953+ {
3954+ r = fputs (buf, ofp);
3955+ c = buf;
3956+ while (*c && *c != '\n') c++;
3957+ c[0] = 0; /* strip EOL */
3958+ if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
3959+ done++;
3960+ }
3961+ if (r != EOF && !done)
3962+ {
3963+ snprintf (buf, sizeof(buf), "#: %s\n", section);
3964+ r = fputs (buf, ofp);
3965+ }
3966+ done = 0;
3967+ }
3968+
3969+ while (r != EOF && fgets (buf, sizeof (buf), ifp))
3970+ {
3971+ if (ext)
3972+ {
3973+ c = buf;
3974+ while (*c && (*c != '\r') && (*c != '\n')) c++;
3975+ c--;
3976+ if (*c != '\\') ext = 0;
3977+ }
3978+ else if ((section && !strncmp (buf, "#: ", 3)))
3979+ {
3980+ if (!done && line)
3981+ {
3982+ fputs (line, ofp);
3983+ fputc ('\n', ofp);
3984+ }
3985+ r = fputs (buf, ofp);
3986+ done++;
3987+ break;
3988+ }
3989+ else if (key && !strncmp (buf, key, strlen(key)) &&
3990+ (!*key || buf[strlen(key)] == ' '))
3991+ {
3992+ c = buf;
3993</