1 WARNING: Run the following script before configure:
9 Vsevolod Volkov <vvv@mutt.org.ua>
12 diff -udprP mutt-1.5.16.orig/ChangeLog.nntp mutt-1.5.16/ChangeLog.nntp
13 --- mutt-1.5.16.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14 +++ mutt-1.5.16/ChangeLog.nntp 2007-06-15 17:14:18.000000000 +0300
16 +* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua>
17 +- fixed error selecting news group
19 +* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua>
22 +* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
23 +- fixed posting error if $smtp_url is set
24 +- added support of print-style sequence %R (x-comment-to)
26 +* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
28 +- nntp://... url changed to news://...
29 +- added indicator of fetching descriptions progress
31 +* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
34 +* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
37 +* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
39 +- fixed reading empty .newsrc
41 +* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
44 +* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
47 +* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
50 +* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
53 +* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
55 +- function mutt_update_list_file() moved to newsrc.c and changed algorithm
57 +* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
58 +- fixed error in nntp_logout_all()
60 +* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
61 +- fixed debug output in mutt_newsrc_update()
62 +- added optional support of LISTGROUP command
63 +- fixed typo in nntp_parse_xref()
65 +* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
68 +* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
71 +* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
74 +* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
76 +- added space after newsgroup name in .newsrc file
78 +* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
79 +- nntp patch: fixed SIGSEGV when posting article
81 +* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
84 +* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
86 +- replace safe_free calls by the FREE macro
88 +* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
90 +- nntp authentication can be passed after any command
92 +* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
95 +* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
98 +* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
100 +- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
101 + <reconstruct-thread> functions
102 +- fixed message about nntp reconnect
103 +- fixed <attach-news-message> function using browser
104 +- added support of Followup-To: poster
105 +- added %n (new articles) in group_index_format
106 +- posting articles without inews by default
108 +* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
111 +* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
114 +* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
116 +- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
117 +- added default content disposition
119 +* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
122 +* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
123 +- update to 1.3.23.2
124 +- fixed segfault if mutt_conn_find() returns null
126 +* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
127 +- update to 1.3.23.1
128 +- added support of LISTGROUP command
129 +- added support for servers with broken overview
130 +- disabled <flag-message> function on news server
131 +- fixed error storing bad authentication information
133 +* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
135 +- fixed typo in buffy.c
136 +- added substitution of %s parameter in $inews variable
138 +* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
139 +- update to 1.3.22.1
142 +* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
145 +* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
147 +- removed 'server-hook', use 'account-hook' instead
148 +- fixed error opening NNTP server without newsgroup using -f option
150 +* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
153 +* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
155 +- fixed typo in nntp_attempt_features()
156 +- changed algorithm of XGTITLE command testing
157 +- disabled writing of NNTP password in debug file
158 +- fixed reading and writing of long newsrc lines
159 +- changed checking of last line while reading lines from server
160 +- fixed possible buffer overrun in nntp_parse_newsrc_line()
161 +- removed checking of XHDR command
162 +- compare NNTP return codes without trailing space
164 +* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
166 +- support for 'LIST NEWSGROUPS' command to read descriptions
168 +* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
171 +* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
174 +* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
176 +- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
178 +* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
181 +* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
182 +- Fixed problem if last article in group is deleted
184 +* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
185 +- Fixed checking of XGTITLE command on some servers
187 +* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
188 +- Added \r in AUTHINFO commands
190 +* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
193 +* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
195 +- fixed error opening newsgroup from mutt started with -g or -G
197 +* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
199 +- hotkey 'G' (get-message) replaced with '^G'
201 +* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
203 +- changed delay displaying error messages from 1 to 2 seconds
204 +- fixed error compiling with nntp and without imap
206 +* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
207 +- fixed catchup in index
208 +- fixed nntp_open_mailbox()
210 +* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
211 +- functions <edit> and <delete-entry> disabled
212 +- format of news mailbox names changed to url form
213 +- option nntp_attempts removed
214 +- option reconnect_news renamed to nntp_reconnect
215 +- default value of nntp_poll changed from 30 to 60
216 +- error handling improved
218 +* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
220 +- new option show_only_unread
221 +- add newsgroup completion
223 +* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
226 +* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
229 +* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
231 +- authentication code update
232 +- fix for changing to newsgroup from mailbox with read messages
233 +- socket code optimization
235 +* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
238 +* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
239 +- don't substitute current newsgroup with deleted new messages
241 +* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
243 +- fix for substitution of newsgroup after reconnection
244 +- fix for loading newsgroups with very long names
245 +- fix for loading more than 32768 newsgroups
247 +* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
250 +* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
253 +* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
256 +* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
259 +* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
262 +* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
265 +* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
266 +- add substitution of newsgroup with new messages by default
268 +* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
269 +- add attach message from newsgroup
270 +- add one-line help in newsreader mode
271 +- disable 'change-dir' command in newsgroups browser
274 +* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
275 +- get default newsserver name from file /etc/nntpserver
276 +- use case insensitive server names
277 +- add print-style sequence %s to $newsrc
280 +* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
281 +- remove 'X-FTN-Origin' header processing
283 +* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
287 +* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
288 +- fix mutt_select_newsserver()
289 +- remove 'toggle-mode' function
290 +- add 'change-newsgroup' function
292 +* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
295 +* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
296 +- fix error 'bounce' function after 'post'
297 +- add 'forward to newsgroup' function
299 +* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
300 +- 'forward' function works in newsreader mode
301 +- add 'post' and 'followup' functions to pager and attachment menu
302 +- fix active descriptions and allowed flag reload
304 +* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
306 +- remove deleted newsgroups from list
308 +* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
309 +- update .newsrc in browser
311 +* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
312 +- reload .newsrc if externally modified
313 +- fix active cache update
315 +* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
318 +* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
319 +- patch *.update_list_file is not required
320 +- count lines when loading descriptions
321 +- remove cache of unsubscribed newsgroups
323 +* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
324 +- load list of newsgroups from cache faster
326 +* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
329 +* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
330 +- fix unread messages in browser
331 +- fix newsrc_gen_entries()
333 +* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
334 +- fix mutt_newsgroup_stat()
335 +- fix nntp_delete_cache()
336 +- fix nntp_get_status()
337 +- fix check_children()
338 +- fix nntp_fetch_headers()
340 +* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
343 +* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
344 +- fix updating new messages in cache
346 +* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
347 +- change default cache filenames
348 +- fix updating new messages in cache
350 +* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
351 +- fix segmentation fault in news groups browser
353 +* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
356 +* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
359 +* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
360 +- add X-Comment-To editing
361 +- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
362 +- add variables $ask_followup_to and $ask_x_comment_to
364 +* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
366 diff -udprP mutt-1.5.16.orig/Makefile.am mutt-1.5.16/Makefile.am
367 --- mutt-1.5.16.orig/Makefile.am 2007-06-04 07:20:01.000000000 +0300
368 +++ mutt-1.5.16/Makefile.am 2007-06-15 17:12:26.000000000 +0300
369 @@ -62,6 +62,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
370 smtp.c browser.h mbyte.h remailer.h url.h \
371 crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
372 pgppacket.c mutt_idna.h hcache.h hcache.c bcache.c bcache.h mutt_ssl_gnutls.c \
374 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c \
377 @@ -73,6 +74,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
378 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
379 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
380 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
381 + nntp.h ChangeLog.nntp \
382 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
383 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
384 makedoc.c makedoc-defs.h stamp-doc-rc README.SSL smime.h \
385 diff -udprP mutt-1.5.16.orig/Makefile.in mutt-1.5.16/Makefile.in
386 --- mutt-1.5.16.orig/Makefile.in 2007-06-10 05:43:26.000000000 +0300
387 +++ mutt-1.5.16/Makefile.in 2007-06-15 17:12:26.000000000 +0300
388 @@ -331,6 +331,7 @@ EXTRA_mutt_SOURCES = account.c md5c.c mu
389 smtp.c browser.h mbyte.h remailer.h url.h \
390 crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
391 pgppacket.c mutt_idna.h hcache.h hcache.c bcache.c bcache.h mutt_ssl_gnutls.c \
393 crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c \
396 @@ -342,6 +343,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
397 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
398 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
399 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
400 + nntp.h ChangeLog.nntp \
401 _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
402 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
403 makedoc.c makedoc-defs.h stamp-doc-rc README.SSL smime.h \
404 @@ -557,6 +559,8 @@ distclean-compile:
405 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@
406 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@
407 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@
408 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@
409 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@
410 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@
411 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
412 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@
413 diff -udprP mutt-1.5.16.orig/Muttrc mutt-1.5.16/Muttrc
414 --- mutt-1.5.16.orig/Muttrc 2007-06-10 06:29:25.000000000 +0300
415 +++ mutt-1.5.16/Muttrc 2007-06-15 17:12:26.000000000 +0300
416 @@ -266,6 +266,28 @@ attachments -I message/external-body
420 +# set ask_follow_up=no
422 +# Name: ask_follow_up
427 +# If set, Mutt will prompt you for follow-up groups before editing
428 +# the body of an outgoing message.
431 +# set ask_x_comment_to=no
433 +# Name: ask_x_comment_to
438 +# If set, Mutt will prompt you for x-comment-to field before editing
439 +# the body of an outgoing message.
442 # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "
444 # Name: attach_format
445 @@ -433,6 +455,17 @@ attachments -I message/external-body
446 # access time when checking for new mail.
449 +# set catchup_newsgroup=ask-yes
451 +# Name: catchup_newsgroup
456 +# If this variable is set, Mutt will mark all articles in newsgroup
457 +# as read when you quit the newsgroup (catchup newsgroup).
463 @@ -930,6 +963,19 @@ attachments -I message/external-body
464 # of the same email for you.
467 +# set followup_to_poster=ask-yes
469 +# Name: followup_to_poster
474 +# If this variable is set and the keyword "poster" is present in
475 +# Followup-To header, follow-up to newsgroup function is not
476 +# permitted. The message will be mailed to the submitter of the
483 @@ -1027,6 +1073,28 @@ attachments -I message/external-body
484 # "Franklin" to "Franklin, Steve".
487 +# set group_index_format="%4C %M%N %5s %-45.45f %d"
489 +# Name: group_index_format
491 +# Default: "%4C %M%N %5s %-45.45f %d"
494 +# This variable allows you to customize the newsgroup browser display to
495 +# your personal taste. This string is similar to ``index_format'', but
496 +# has its own set of printf()-like sequences:
498 +# %C current newsgroup number
499 +# %d description of newsgroup (becomes from server)
501 +# %M - if newsgroup not allowed for direct post (moderated for example)
502 +# %N N if newsgroup is new, u if unsubscribed, blank otherwise
503 +# %n number of new articles in newsgroup
504 +# %s number of unread articles in newsgroup
505 +# %>X right justify the rest of the string and pad with character "X"
506 +# %|X pad to the end of the line with character "X"
512 @@ -1472,6 +1540,7 @@ attachments -I message/external-body
513 # %E number of messages in current thread
514 # %f entire From: line (address + real name)
515 # %F author name, or recipient name if the message is from you
516 +# %g newsgroup name (if compiled with nntp support)
517 # %H spam attribute(s) of this message
518 # %i message-id of the current message
519 # %l number of lines in the message (does not work with maildir,
520 @@ -1486,12 +1555,14 @@ attachments -I message/external-body
521 # %O (_O_riginal save folder) Where mutt would formerly have
522 # stashed the message: list name or recipient name if no list
523 # %P progress indicator for the builtin pager (how much of the file has been displayed)
524 +# %R `x-comment-to:' field (if present and compiled with nntp support)
525 # %s subject of the message
526 # %S status of the message (N/D/d/!/r/*)
527 # %t `to:' field (recipients)
528 # %T the appropriate character from the $to_chars string
529 # %u user (login) name of the author
530 # %v first name of the author, or the recipient if the message is from you
531 +# %W name of organization of author (`organization:' field)
532 # %X number of attachments
533 # (please see the ``attachments'' section for possible speed effects)
534 # %y `x-label:' field, if present
535 @@ -1517,6 +1588,22 @@ attachments -I message/external-body
536 # See also: ``$to_chars''.
546 +# If set, specifies the program and arguments used to deliver news posted
547 +# by Mutt. Otherwise, mutt posts article using current connection to
548 +# news server. The following printf-style sequence is understood:
550 +# %s newsserver name
552 +# Example: set inews="/usr/local/bin/inews -hS"
555 # set ispell="ispell"
558 @@ -1860,6 +1947,18 @@ attachments -I message/external-body
559 # be attached to the newly composed message if this option is set.
562 +# set mime_subject=yes
564 +# Name: mime_subject
569 +# If unset, 8-bit ``subject:'' line in article header will not be
570 +# encoded according to RFC2047 to base64. This is useful when message
571 +# is Usenet article, because MIME for news is nonstandard feature.
574 # set mix_entry_format="%4n %c %-16s %a"
576 # Name: mix_entry_format
577 @@ -1964,6 +2063,118 @@ attachments -I message/external-body
578 # See also ``$read_inc'' and ``$write_inc''.
581 +# set news_cache_dir="~/.mutt"
583 +# Name: news_cache_dir
585 +# Default: "~/.mutt"
588 +# This variable pointing to directory where Mutt will save cached news
589 +# articles headers in. If unset, headers will not be saved at all
590 +# and will be reloaded each time when you enter to newsgroup.
593 +# set news_server=""
600 +# This variable specifies domain name or address of NNTP server. It
601 +# defaults to the newsserver specified in the environment variable
602 +# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
603 +# specify username and an alternative port for each newsserver, ie:
605 +# [news[s]://][username[:password]@]newsserver[:port]
608 +# set newsrc="~/.newsrc"
612 +# Default: "~/.newsrc"
615 +# The file, containing info about subscribed newsgroups - names and
616 +# indexes of read articles. The following printf-style sequence
619 +# %s newsserver name
622 +# set nntp_context=1000
624 +# Name: nntp_context
629 +# This variable defines number of articles which will be in index when
630 +# newsgroup entered. If active newsgroup have more articles than this
631 +# number, oldest articles will be ignored. Also controls how many
632 +# articles headers will be saved in cache when you quit newsgroup.
635 +# set nntp_load_description=yes
637 +# Name: nntp_load_description
642 +# This variable controls whether or not descriptions for each newsgroup
643 +# must be loaded when newsgroup is added to list (first time list
644 +# loading or new newsgroup adding).
654 +# Your login name on the NNTP server. If unset and NNTP server requires
655 +# authentification, Mutt will prompt you for your account name when you
656 +# connect to newsserver.
666 +# Your password for NNTP account.
676 +# The time in seconds until any operations on newsgroup except post new
677 +# article will cause recheck for new news. If set to 0, Mutt will
678 +# recheck newsgroup on each operation in index (stepping, read article,
682 +# set nntp_reconnect=ask-yes
684 +# Name: nntp_reconnect
689 +# Controls whether or not Mutt will try to reconnect to newsserver when
693 # set pager="builtin"
696 @@ -3167,6 +3378,19 @@ attachments -I message/external-body
697 # string after the inclusion of a message which is being replied to.
700 +# set post_moderated=ask-yes
702 +# Name: post_moderated
707 +# If set to yes, Mutt will post article to newsgroup that have
708 +# not permissions to posting (e.g. moderated). Note: if newsserver
709 +# does not support posting to that newsgroup or totally read-only, that
710 +# posting will not have an effect.
713 # set postpone=ask-yes
716 @@ -3692,6 +3916,41 @@ attachments -I message/external-body
717 # shell from /etc/passwd is used.
720 +# set save_unsubscribed=no
722 +# Name: save_unsubscribed
727 +# When set, info about unsubscribed newsgroups will be saved into
728 +# ``newsrc'' file and into cache.
731 +# set show_new_news=yes
733 +# Name: show_new_news
738 +# If set, newsserver will be asked for new newsgroups on entering
739 +# the browser. Otherwise, it will be done only once for a newsserver.
740 +# Also controls whether or not number of new articles of subscribed
741 +# newsgroups will be then checked.
744 +# set show_only_unread=no
746 +# Name: show_only_unread
751 +# If set, only subscribed newsgroups that contain unread articles
752 +# will be displayed in browser.
758 @@ -4405,3 +4664,14 @@ attachments -I message/external-body
762 +# set x_comment_to=no
764 +# Name: x_comment_to
769 +# If set, Mutt will add ``X-Comment-To:'' field (that contains full
770 +# name of original article author) to article that followuped to newsgroup.
773 diff -udprP mutt-1.5.16.orig/OPS mutt-1.5.16/OPS
774 --- mutt-1.5.16.orig/OPS 2007-05-14 20:09:59.000000000 +0300
775 +++ mutt-1.5.16/OPS 2007-06-15 17:12:26.000000000 +0300
776 @@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
777 OP_BROWSER_NEW_FILE "select a new file in this directory"
778 OP_BROWSER_VIEW_FILE "view file"
779 OP_BROWSER_TELL "display the currently selected file's name"
780 -OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
781 -OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
782 +OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
783 +OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
784 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
785 OP_BUFFY_LIST "list mailboxes with new mail"
786 +OP_CATCHUP "mark all articles in newsgroup as read"
787 OP_CHANGE_DIRECTORY "change directories"
788 OP_CHECK_NEW "check mailboxes for new mail"
789 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
790 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
791 +OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message"
792 OP_COMPOSE_EDIT_BCC "edit the BCC list"
793 OP_COMPOSE_EDIT_CC "edit the CC list"
794 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
795 @@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
796 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
797 OP_COMPOSE_EDIT_MESSAGE "edit the message"
798 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
799 +OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
800 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
801 +OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
802 +OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
803 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
804 OP_COMPOSE_EDIT_TO "edit the TO list"
805 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
806 @@ -85,8 +90,13 @@ OP_EXIT "exit this menu"
807 OP_FILTER "filter attachment through a shell command"
808 OP_FIRST_ENTRY "move to the first entry"
809 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
810 +OP_FOLLOWUP "followup to newsgroup"
811 +OP_FORWARD_TO_GROUP "forward to newsgroup"
812 OP_FORWARD_MESSAGE "forward a message with comments"
813 OP_GENERIC_SELECT_ENTRY "select the current entry"
814 +OP_GET_CHILDREN "get all children of the current message"
815 +OP_GET_MESSAGE "get message with Message-Id"
816 +OP_GET_PARENT "get parent of the current message"
817 OP_GROUP_REPLY "reply to all recipients"
818 OP_HALF_DOWN "scroll down 1/2 page"
819 OP_HALF_UP "scroll up 1/2 page"
820 @@ -94,11 +104,14 @@ OP_HELP "this screen"
821 OP_JUMP "jump to an index number"
822 OP_LAST_ENTRY "move to the last entry"
823 OP_LIST_REPLY "reply to specified mailing list"
824 +OP_LOAD_ACTIVE "load active file from NNTP server"
825 OP_MACRO "execute a macro"
826 OP_MAIL "compose a new mail message"
827 OP_MAIN_BREAK_THREAD "break the thread in two"
828 OP_MAIN_CHANGE_FOLDER "open a different folder"
829 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
830 +OP_MAIN_CHANGE_GROUP "open a different newsgroup"
831 +OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
832 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
833 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
834 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
835 @@ -137,6 +150,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
836 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
837 OP_PAGER_TOP "jump to the top of the message"
838 OP_PIPE "pipe message/attachment to a shell command"
839 +OP_POST "post message to newsgroup"
840 OP_PREV_ENTRY "move to the previous entry"
841 OP_PREV_LINE "scroll up one line"
842 OP_PREV_PAGE "move to the previous page"
843 @@ -145,6 +159,7 @@ OP_QUERY "query external program for add
844 OP_QUERY_APPEND "append new query results to current results"
845 OP_QUIT "save changes to mailbox and quit"
846 OP_RECALL_MESSAGE "recall a postponed message"
847 +OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
848 OP_REDRAW "clear and redraw the screen"
849 OP_REFORMAT_WINCH "{internal}"
850 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
851 @@ -159,18 +174,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
852 OP_SHELL_ESCAPE "invoke a command in a subshell"
853 OP_SORT "sort messages"
854 OP_SORT_REVERSE "sort messages in reverse order"
855 +OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
856 OP_TAG "tag the current entry"
857 OP_TAG_PREFIX "apply next function to tagged messages"
858 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
859 OP_TAG_SUBTHREAD "tag the current subthread"
860 OP_TAG_THREAD "tag the current thread"
861 OP_TOGGLE_NEW "toggle a message's 'new' flag"
862 +OP_TOGGLE_READ "toggle view of read messages"
863 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
864 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
865 OP_TOP_PAGE "move to the top of the page"
866 +OP_UNCATCHUP "mark all articles in newsgroup as unread"
867 OP_UNDELETE "undelete the current entry"
868 OP_UNDELETE_THREAD "undelete all messages in thread"
869 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
870 +OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
871 OP_VERSION "show the Mutt version number and date"
872 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
873 OP_VIEW_ATTACHMENTS "show MIME attachments"
874 diff -udprP mutt-1.5.16.orig/PATCHES mutt-1.5.16/PATCHES
875 --- mutt-1.5.16.orig/PATCHES 2007-04-30 05:07:48.000000000 +0300
876 +++ mutt-1.5.16/PATCHES 2007-06-15 17:12:26.000000000 +0300
879 diff -udprP mutt-1.5.16.orig/account.c mutt-1.5.16/account.c
880 --- mutt-1.5.16.orig/account.c 2007-04-11 23:28:23.000000000 +0300
881 +++ mutt-1.5.16/account.c 2007-06-15 17:12:26.000000000 +0300
882 @@ -54,6 +54,11 @@ int mutt_account_match (const ACCOUNT* a
887 + if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
891 if (a1->flags & a2->flags & M_ACCT_USER)
892 return (!strcmp (a1->user, a2->user));
893 if (a1->flags & M_ACCT_USER)
894 @@ -133,6 +138,16 @@ void mutt_account_tourl (ACCOUNT* accoun
899 + if (account->type == M_ACCT_TYPE_NNTP)
901 + if (account->flags & M_ACCT_SSL)
902 + url->scheme = U_NNTPS;
904 + url->scheme = U_NNTP;
908 url->host = account->host;
909 if (account->flags & M_ACCT_PORT)
910 url->port = account->port;
911 @@ -158,6 +173,10 @@ int mutt_account_getuser (ACCOUNT* accou
912 else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
913 strfcpy (account->user, PopUser, sizeof (account->user));
916 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
917 + strfcpy (account->user, NntpUser, sizeof (account->user));
919 /* prompt (defaults to unix username), copy into account->user */
922 @@ -218,6 +237,10 @@ int mutt_account_getpass (ACCOUNT* accou
923 else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass)
924 strfcpy (account->pass, SmtpPass, sizeof (account->pass));
927 + else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
928 + strfcpy (account->pass, NntpPass, sizeof (account->pass));
932 snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
933 diff -udprP mutt-1.5.16.orig/account.h mutt-1.5.16/account.h
934 --- mutt-1.5.16.orig/account.h 2007-04-02 00:58:55.000000000 +0300
935 +++ mutt-1.5.16/account.h 2007-06-15 17:12:26.000000000 +0300
936 @@ -29,7 +29,8 @@ enum
937 M_ACCT_TYPE_NONE = 0,
946 diff -udprP mutt-1.5.16.orig/attach.h mutt-1.5.16/attach.h
947 --- mutt-1.5.16.orig/attach.h 2007-04-02 00:58:55.000000000 +0300
948 +++ mutt-1.5.16/attach.h 2007-06-15 17:12:26.000000000 +0300
949 @@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f
951 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
952 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
953 -void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
954 +void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
955 void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int);
957 #endif /* _ATTACH_H_ */
958 diff -udprP mutt-1.5.16.orig/browser.c mutt-1.5.16/browser.c
959 --- mutt-1.5.16.orig/browser.c 2007-04-16 02:56:26.000000000 +0300
960 +++ mutt-1.5.16/browser.c 2007-06-15 17:12:38.000000000 +0300
971 @@ -49,6 +52,19 @@ static struct mapping_t FolderHelp[] = {
976 +static struct mapping_t FolderNewsHelp[] = {
977 + { N_("Exit"), OP_EXIT },
978 + { N_("List"), OP_TOGGLE_MAILBOXES },
979 + { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
980 + { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
981 + { N_("Catchup"), OP_CATCHUP },
982 + { N_("Mask"), OP_ENTER_MASK },
983 + { N_("Help"), OP_HELP },
988 typedef struct folder_t
990 struct folder_file *ff;
991 @@ -114,9 +130,17 @@ static void browser_sort (struct browser
996 + if (option (OPTNEWS))
999 f = browser_compare_date;
1003 + if (option (OPTNEWS))
1006 f = browser_compare_size;
1009 @@ -307,8 +331,106 @@ folder_format_str (char *dest, size_t de
1014 +static const char *
1015 +newsgroup_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
1016 + const char *fmt, const char *ifstring, const char *elsestring,
1017 + unsigned long data, format_flag flags)
1019 + char fn[SHORT_STRING], tmp[SHORT_STRING];
1020 + FOLDER *folder = (FOLDER *) data;
1025 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
1026 + snprintf (dest, destlen, tmp, folder->num + 1);
1030 + strncpy (fn, folder->ff->name, sizeof(fn) - 1);
1031 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
1032 + snprintf (dest, destlen, tmp, fn);
1036 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
1037 + if (folder->ff->nd->subscribed)
1038 + snprintf (dest, destlen, tmp, ' ');
1040 + snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
1044 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
1045 + if (folder->ff->nd->deleted)
1046 + snprintf (dest, destlen, tmp, 'D');
1048 + snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
1052 + if (flags & M_FORMAT_OPTIONAL)
1054 + if (folder->ff->nd->unread != 0)
1055 + mutt_FormatString (dest, destlen, col, ifstring, newsgroup_format_str,
1058 + mutt_FormatString (dest, destlen, col, elsestring, newsgroup_format_str,
1061 + else if (Context && Context->data == folder->ff->nd)
1063 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
1064 + snprintf (dest, destlen, tmp, Context->unread);
1068 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
1069 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
1074 + if (Context && Context->data == folder->ff->nd)
1076 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
1077 + snprintf (dest, destlen, tmp, Context->new);
1079 + else if (option (OPTMARKOLD) &&
1080 + folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
1081 + folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
1083 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
1084 + snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
1088 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
1089 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
1094 + if (folder->ff->nd->desc != NULL)
1096 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
1097 + snprintf (dest, destlen, tmp, folder->ff->nd->desc);
1101 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
1102 + snprintf (dest, destlen, tmp, "");
1108 +#endif /* USE_NNTP */
1110 static void add_folder (MUTTMENU *m, struct browser_state *state,
1111 - const char *name, const struct stat *s, int new)
1112 + const char *name, const struct stat *s,
1113 + void *data, int new)
1115 if (state->entrylen == state->entrymax)
1117 @@ -337,6 +459,10 @@ static void add_folder (MUTTMENU *m, str
1119 (state->entry)[state->entrylen].imap = 0;
1122 + if (option (OPTNEWS))
1123 + (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
1125 (state->entrylen)++;
1128 @@ -352,9 +478,35 @@ static void init_state (struct browser_s
1129 menu->data = state->entry;
1132 +/* get list of all files/newsgroups with mask */
1133 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
1134 char *d, const char *prefix)
1137 + if (option (OPTNEWS))
1141 + NNTP_SERVER *news = CurrentNewsSrv;
1143 +/* mutt_buffy_check (0); */
1144 + init_state (state, menu);
1146 + for (tmp = news->list; tmp; tmp = tmp->next)
1148 + if (!(data = (NNTP_DATA *)tmp->data))
1150 + if (prefix && *prefix && strncmp (prefix, data->group,
1151 + strlen (prefix)) != 0)
1153 + if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
1155 + add_folder (menu, state, data->group, NULL, data, data->new);
1159 +#endif /* USE_NNTP */
1164 @@ -415,17 +567,40 @@ static int examine_directory (MUTTMENU *
1166 while (tmp && mutt_strcmp (buffer, tmp->path))
1168 - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
1169 + add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
1174 browser_sort (state);
1178 +/* get list of mailboxes/subscribed newsgroups */
1179 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
1182 char buffer[LONG_STRING];
1185 + if (option (OPTNEWS))
1189 + NNTP_SERVER *news = CurrentNewsSrv;
1191 +/* mutt_buffy_check (0); */
1192 + init_state (state, menu);
1194 + for (tmp = news->list; tmp; tmp = tmp->next)
1196 + if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
1197 + (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
1198 + add_folder (menu, state, data->group, NULL, data, data->new);
1204 BUFFY *tmp = Incoming;
1206 struct mailbox_state mbox;
1207 @@ -443,14 +618,21 @@ static int examine_mailboxes (MUTTMENU *
1208 if (mx_is_imap (tmp->path))
1210 imap_mailbox_state (tmp->path, &mbox);
1211 - add_folder (menu, state, tmp->path, NULL, mbox.new);
1212 + add_folder (menu, state, tmp->path, NULL, NULL, mbox.new);
1217 if (mx_is_pop (tmp->path))
1219 - add_folder (menu, state, tmp->path, NULL, tmp->new);
1220 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
1225 + if (mx_is_nntp (tmp->path))
1227 + add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
1231 @@ -464,15 +646,20 @@ static int examine_mailboxes (MUTTMENU *
1232 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
1233 mutt_pretty_mailbox (buffer);
1235 - add_folder (menu, state, buffer, &s, tmp->new);
1236 + add_folder (menu, state, buffer, &s, NULL, tmp->new);
1238 while ((tmp = tmp->next));
1240 browser_sort (state);
1244 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
1247 + if (option (OPTNEWS))
1248 + return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
1250 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
1253 @@ -483,6 +670,12 @@ static void folder_entry (char *s, size_
1254 folder.ff = &((struct folder_file *) menu->data)[num];
1258 + if (option (OPTNEWS))
1259 + mutt_FormatString (s, slen, 0, NONULL(GroupFormat), newsgroup_format_str,
1260 + (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
1263 mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str,
1264 (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
1266 @@ -503,6 +696,17 @@ static void init_menu (struct browser_st
1271 + if (option (OPTNEWS))
1274 + snprintf (title, titlelen, _("Subscribed newsgroups"));
1276 + snprintf (title, titlelen, _("Newsgroups on server [%s]"),
1277 + CurrentNewsSrv->conn->account.host);
1282 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
1284 @@ -558,6 +762,31 @@ void _mutt_select_file (char *f, size_t
1286 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
1289 + if (option (OPTNEWS))
1292 + strfcpy (prefix, f, sizeof (prefix));
1297 + /* default state for news reader mode is browse subscribed newsgroups */
1299 + for (list = CurrentNewsSrv->list; list; list = list->next)
1301 + NNTP_DATA *data = (NNTP_DATA *) list->data;
1303 + if (data && data->subscribed)
1315 mutt_expand_path (f, flen);
1316 @@ -655,6 +884,9 @@ void _mutt_select_file (char *f, size_t
1317 menu->tag = file_tag;
1319 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
1321 + (option (OPTNEWS)) ? FolderNewsHelp :
1325 init_menu (&state, menu, title, sizeof (title), buffy);
1326 @@ -793,7 +1025,11 @@ void _mutt_select_file (char *f, size_t
1331 + if (buffy || option (OPTNEWS)) /* news have not path */
1336 strfcpy (f, state.entry[menu->current].name, flen);
1337 mutt_expand_path (f, flen);
1338 @@ -851,14 +1087,6 @@ void _mutt_select_file (char *f, size_t
1342 - case OP_BROWSER_SUBSCRIBE:
1343 - imap_subscribe (state.entry[menu->current].name, 1);
1346 - case OP_BROWSER_UNSUBSCRIBE:
1347 - imap_subscribe (state.entry[menu->current].name, 0);
1350 case OP_BROWSER_TOGGLE_LSUB:
1351 if (option (OPTIMAPLSUB))
1353 @@ -957,6 +1185,11 @@ void _mutt_select_file (char *f, size_t
1355 case OP_CHANGE_DIRECTORY:
1358 + if (option (OPTNEWS))
1362 strfcpy (buf, LastDir, sizeof (buf));
1364 if (!state.imap_browse)
1365 @@ -1213,6 +1446,190 @@ void _mutt_select_file (char *f, size_t
1367 mutt_error _("Error trying to view file");
1373 + case OP_UNCATCHUP:
1374 + if (option (OPTNEWS))
1376 + struct folder_file *f = &state.entry[menu->current];
1379 + if (i == OP_CATCHUP)
1380 + nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
1382 + nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
1387 + struct folder_file ff;
1388 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1391 + folder.ff->name = f->name;
1392 + folder.ff->st = NULL;
1393 + folder.ff->is_new = nd->new;
1394 + folder.ff->nd = nd;
1396 + mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1397 + newsgroup_format_str, (unsigned long) &folder,
1398 + M_FORMAT_ARROWCURSOR);
1399 + f->desc = safe_strdup (buffer); */
1400 + if (menu->current + 1 < menu->max)
1402 + menu->redraw = REDRAW_MOTION_RESYNCH;
1407 + case OP_LOAD_ACTIVE:
1408 + if (!option (OPTNEWS))
1415 + for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
1417 + if ((data = (NNTP_DATA *)tmp->data))
1418 + data->deleted = 1;
1421 + nntp_get_active (CurrentNewsSrv);
1423 + destroy_state (&state);
1425 + examine_mailboxes (menu, &state);
1427 + examine_directory (menu, &state, NULL, NULL);
1428 + init_menu (&state, menu, title, sizeof (title), buffy);
1430 +#endif /* USE_NNTP */
1432 +#if defined USE_IMAP || defined USE_NNTP
1433 + case OP_BROWSER_SUBSCRIBE:
1434 + case OP_BROWSER_UNSUBSCRIBE:
1437 + case OP_SUBSCRIBE_PATTERN:
1438 + case OP_UNSUBSCRIBE_PATTERN:
1439 + if (option (OPTNEWS))
1441 + regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1443 + int j = menu->current;
1445 + NNTP_SERVER *news = CurrentNewsSrv;
1447 + if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1453 + if (i == OP_SUBSCRIBE_PATTERN)
1454 + snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1456 + snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1457 + if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1463 + if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
1465 + regerror (err, rx, buf, sizeof (buf));
1468 + mutt_error ("%s", buf);
1471 + menu->redraw = REDRAW_FULL;
1474 + else if (!state.entrylen)
1476 + mutt_error _("No newsgroups match the mask");
1480 + for ( ; j < state.entrylen; j++)
1482 + struct folder_file *f = &state.entry[j];
1484 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1485 + regexec (rx, f->name, 0, NULL, 0) == 0)
1487 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1488 + nd = mutt_newsgroup_subscribe (news, f->name);
1490 + nd = mutt_newsgroup_unsubscribe (news, f->name);
1494 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1496 + folder.name = f->name;
1498 + folder.new = nd->new;
1501 + mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat),
1502 + newsgroup_format_str, (unsigned long) &folder,
1503 + M_FORMAT_ARROWCURSOR);
1504 + f->desc = safe_strdup (buffer);
1507 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1509 + if (menu->current + 1 < menu->max)
1511 + menu->redraw = REDRAW_MOTION_RESYNCH;
1515 + if (i == OP_SUBSCRIBE_PATTERN)
1517 + LIST *grouplist = NULL;
1520 + grouplist = news->list;
1521 + for (; grouplist; grouplist = grouplist->next)
1523 + nd = (NNTP_DATA *) grouplist->data;
1524 + if (nd && nd->group && !nd->subscribed)
1526 + if (regexec (rx, nd->group, 0, NULL, 0) == 0)
1528 + mutt_newsgroup_subscribe (news, nd->group);
1529 + add_folder (menu, &state, nd->group, NULL, nd, nd->new);
1533 + init_menu (&state, menu, title, sizeof (title), buffy);
1535 + mutt_newsrc_update (news);
1536 + nntp_clear_cacheindex (news);
1537 + if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1543 +#endif /* USE_IMAP && USE_NNTP */
1544 +#endif /* USE_NNTP */
1547 + if (i == OP_BROWSER_SUBSCRIBE)
1548 + imap_subscribe (state.entry[menu->current].name, 1);
1550 + imap_subscribe (state.entry[menu->current].name, 0);
1552 +#endif /* USE_IMAP */
1556 diff -udprP mutt-1.5.16.orig/browser.h mutt-1.5.16/browser.h
1557 --- mutt-1.5.16.orig/browser.h 2007-04-03 07:57:21.000000000 +0300
1558 +++ mutt-1.5.16/browser.h 2007-06-15 17:12:26.000000000 +0300
1561 #define _BROWSER_H 1
1570 @@ -38,14 +42,17 @@ struct folder_file
1571 unsigned selectable : 1;
1572 unsigned inferiors : 1;
1577 unsigned tagged : 1;
1580 struct browser_state
1582 struct folder_file *entry;
1583 - short entrylen; /* number of real entries */
1584 - short entrymax; /* max entry */
1585 + unsigned int entrylen; /* number of real entries */
1586 + unsigned int entrymax; /* max entry */
1590 diff -udprP mutt-1.5.16.orig/buffy.c mutt-1.5.16/buffy.c
1591 --- mutt-1.5.16.orig/buffy.c 2007-04-02 00:58:55.000000000 +0300
1592 +++ mutt-1.5.16/buffy.c 2007-06-15 17:12:26.000000000 +0300
1593 @@ -285,6 +285,9 @@ int mutt_buffy_check (int force)
1595 if (!Context || Context->magic != M_POP)
1598 + if (!Context || Context->magic != M_NNTP)
1600 /* check device ID and serial number instead of comparing paths */
1601 if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0)
1603 @@ -308,6 +311,11 @@ int mutt_buffy_check (int force)
1608 + if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path))
1609 + tmp->magic = M_NNTP;
1612 if (stat (tmp->path, &sb) != 0 || sb.st_size == 0 ||
1613 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1615 @@ -325,25 +333,21 @@ int mutt_buffy_check (int force)
1616 /* check to see if the folder is the currently selected folder
1618 if (!Context || !Context->path ||
1619 -#if defined USE_IMAP || defined USE_POP
1624 - tmp->magic == M_IMAP
1625 + || tmp->magic == M_IMAP
1631 - tmp->magic == M_POP
1633 - ) ? mutt_strcmp (tmp->path, Context->path) :
1634 + || tmp->magic == M_POP
1636 - (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1637 -#if defined USE_IMAP || defined USE_POP
1640 + || tmp->magic == M_NNTP
1644 + ) ? mutt_strcmp (tmp->path, Context->path) :
1645 + (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
1651 diff -udprP mutt-1.5.16.orig/complete.c mutt-1.5.16/complete.c
1652 --- mutt-1.5.16.orig/complete.c 2007-04-08 00:39:04.000000000 +0300
1653 +++ mutt-1.5.16/complete.c 2007-06-15 17:12:26.000000000 +0300
1655 #include "mailbox.h"
1664 @@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen)
1665 char filepart[_POSIX_PATH_MAX];
1667 char imap_path[LONG_STRING];
1670 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1673 + if (option (OPTNEWS))
1675 + LIST *l = CurrentNewsSrv->list;
1677 + strfcpy (filepart, s, sizeof (filepart));
1680 + * special case to handle when there is no filepart yet.
1681 + * find the first subscribed newsgroup
1683 + if ((len = mutt_strlen (filepart)) == 0)
1685 + for (; l; l = l->next)
1687 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1689 + if (data && data->subscribed)
1691 + strfcpy (filepart, data->group, sizeof (filepart));
1699 + for (; l; l = l->next)
1701 + NNTP_DATA *data = (NNTP_DATA *)l->data;
1703 + if (data && data->subscribed &&
1704 + mutt_strncmp (data->group, filepart, len) == 0)
1708 + for (i = 0; filepart[i] && data->group[i]; i++)
1710 + if (filepart[i] != data->group[i])
1720 + strfcpy (filepart, data->group, sizeof (filepart));
1726 + strcpy (s, filepart);
1728 + return (init ? 0 : -1);
1733 /* we can use '/' as a delimiter, imap_complete rewrites it */
1734 if (*s == '=' || *s == '+' || *s == '!')
1736 diff -udprP mutt-1.5.16.orig/compose.c mutt-1.5.16/compose.c
1737 --- mutt-1.5.16.orig/compose.c 2007-04-16 02:56:26.000000000 +0300
1738 +++ mutt-1.5.16/compose.c 2007-06-15 17:12:26.000000000 +0300
1740 #include "mailbox.h"
1742 #include "charset.h"
1746 #include "remailer.h"
1755 @@ -60,18 +65,21 @@ enum
1772 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1775 -#define HDR_XOFFSET 10
1776 -#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
1777 +#define HDR_XOFFSET 14
1778 +#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
1779 #define W (COLS - HDR_XOFFSET)
1781 static char *Prompts[] =
1782 @@ -83,6 +91,16 @@ static char *Prompts[] =
1798 static struct mapping_t ComposeHelp[] = {
1799 @@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] =
1804 +static struct mapping_t ComposeNewsHelp[] = {
1805 + { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1806 + { N_("Abort"), OP_EXIT },
1807 + { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS },
1808 + { "Subj", OP_COMPOSE_EDIT_SUBJECT },
1809 + { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1810 + { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1811 + { N_("Help"), OP_HELP },
1816 static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
1818 mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt,
1819 @@ -115,16 +146,16 @@ static void redraw_crypt_lines (HEADER *
1820 if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
1823 - mvaddstr (HDR_CRYPT, 0, "Security: ");
1824 + mvaddstr (HDR_CRYPT, 0, " Security: ");
1825 else if (msg->security & APPLICATION_SMIME)
1826 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1827 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1828 else if (msg->security & APPLICATION_PGP)
1829 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1830 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1832 else if ((WithCrypto & APPLICATION_SMIME))
1833 - mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1834 + mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
1835 else if ((WithCrypto & APPLICATION_PGP))
1836 - mvaddstr (HDR_CRYPT, 0, " PGP: ");
1837 + mvaddstr (HDR_CRYPT, 0, " PGP: ");
1841 @@ -252,9 +283,28 @@ static void draw_envelope_addr (int line
1842 static void draw_envelope (HEADER *msg, char *fcc)
1844 draw_envelope_addr (HDR_FROM, msg->env->from);
1846 + if (!option (OPTNEWSSEND))
1849 draw_envelope_addr (HDR_TO, msg->env->to);
1850 draw_envelope_addr (HDR_CC, msg->env->cc);
1851 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1856 + mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
1857 + mutt_paddstr (W, NONULL (msg->env->newsgroups));
1858 + mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
1859 + mutt_paddstr (W, NONULL (msg->env->followup_to));
1860 + if (option (OPTXCOMMENTTO))
1862 + mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
1863 + mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1867 mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
1868 mutt_paddstr (W, NONULL (msg->env->subject));
1869 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
1870 @@ -507,6 +557,12 @@ int mutt_compose_menu (HEADER *msg, /*
1871 /* Sort, SortAux could be changed in mutt_index_menu() */
1872 int oldSort, oldSortAux;
1875 + int news = 0; /* is it a news article ? */
1877 + if (option (OPTNEWSSEND))
1881 mutt_attach_init (msg->content);
1882 idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
1883 @@ -518,10 +574,18 @@ int mutt_compose_menu (HEADER *msg, /*
1884 menu->make_entry = snd_entry;
1885 menu->tag = mutt_tag_attach;
1889 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1892 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1897 + unset_option (OPTNEWS); /* for any case */
1899 switch (op = mutt_menuLoop (menu))
1902 @@ -534,17 +598,87 @@ int mutt_compose_menu (HEADER *msg, /*
1903 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1905 case OP_COMPOSE_EDIT_TO:
1910 menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
1911 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1913 case OP_COMPOSE_EDIT_BCC:
1918 menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
1919 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1921 case OP_COMPOSE_EDIT_CC:
1926 menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
1927 mutt_message_hook (NULL, msg, M_SEND2HOOK);
1930 + case OP_COMPOSE_EDIT_NEWSGROUPS:
1933 + if (msg->env->newsgroups)
1934 + strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1937 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
1939 + FREE (&msg->env->newsgroups);
1940 + mutt_remove_trailing_ws (buf);
1941 + msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
1942 + move (HDR_TO, HDR_XOFFSET);
1944 + if (msg->env->newsgroups)
1945 + printw ("%-*.*s", W, W, msg->env->newsgroups);
1950 + case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1954 + if (msg->env->followup_to)
1955 + strfcpy (buf, msg->env->followup_to, sizeof (buf));
1956 + if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1958 + FREE (&msg->env->followup_to);
1959 + mutt_remove_trailing_ws (buf);
1960 + msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
1961 + move (HDR_CC, HDR_XOFFSET);
1963 + if (msg->env->followup_to)
1964 + printw ("%-*.*s", W, W, msg->env->followup_to);
1969 + case OP_COMPOSE_EDIT_X_COMMENT_TO:
1970 + if (news && option (OPTXCOMMENTTO))
1973 + if (msg->env->x_comment_to)
1974 + strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1975 + if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
1977 + FREE (&msg->env->x_comment_to);
1978 + msg->env->x_comment_to = safe_strdup (buf);
1979 + move (HDR_BCC, HDR_XOFFSET);
1981 + if (msg->env->x_comment_to)
1982 + printw ("%-*.*s", W, W, msg->env->x_comment_to);
1987 case OP_COMPOSE_EDIT_SUBJECT:
1988 if (msg->env->subject)
1989 strfcpy (buf, msg->env->subject, sizeof (buf));
1990 @@ -707,6 +841,9 @@ int mutt_compose_menu (HEADER *msg, /*
1993 case OP_COMPOSE_ATTACH_MESSAGE:
1995 + case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
2000 @@ -714,7 +851,22 @@ int mutt_compose_menu (HEADER *msg, /*
2002 prompt = _("Open mailbox to attach message from");
2005 + unset_option (OPTNEWS);
2006 + if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
2008 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2011 + prompt = _("Open newsgroup to attach message from");
2012 + set_option (OPTNEWS);
2018 + if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
2021 strfcpy (fname, NONULL (Context->path), sizeof (fname));
2022 mutt_pretty_mailbox (fname);
2023 @@ -723,6 +875,11 @@ int mutt_compose_menu (HEADER *msg, /*
2024 if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
2028 + if (option (OPTNEWS))
2029 + nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
2032 mutt_expand_path (fname, sizeof (fname));
2034 if (!mx_is_imap (fname))
2035 @@ -730,6 +887,9 @@ int mutt_compose_menu (HEADER *msg, /*
2037 if (!mx_is_pop (fname))
2040 + if (!mx_is_nntp (fname) && !option (OPTNEWS))
2042 /* check to make sure the file exists and is readable */
2043 if (access (fname, R_OK) == -1)
2045 diff -udprP mutt-1.5.16.orig/config.h.in mutt-1.5.16/config.h.in
2046 --- mutt-1.5.16.orig/config.h.in 2007-06-10 05:44:57.000000000 +0300
2047 +++ mutt-1.5.16/config.h.in 2007-06-15 17:12:26.000000000 +0300
2049 significant more memory when defined. */
2050 #undef EXACT_ADDRESS
2052 +/* Compiling with newsreading support with NNTP */
2055 /* program to use for shell commands */
2058 diff -udprP mutt-1.5.16.orig/configure mutt-1.5.16/configure
2059 --- mutt-1.5.16.orig/configure 2007-06-10 05:43:29.000000000 +0300
2060 +++ mutt-1.5.16/configure 2007-06-15 17:12:26.000000000 +0300
2061 @@ -1342,6 +1342,7 @@ Optional Features:
2062 Force use of an external dotlock program
2063 --enable-pop Enable POP3 support
2064 --enable-imap Enable IMAP support
2065 + --enable-nntp Enable NNTP support
2066 --enable-smtp include internal SMTP relay support
2067 --enable-debug Enable debugging support
2068 --enable-flock Use flock() to lock files
2069 @@ -13919,6 +13920,20 @@ fi
2073 +# Check whether --enable-nntp or --disable-nntp was given.
2074 +if test "${enable_nntp+set}" = set; then
2075 + enableval="$enable_nntp"
2076 + if test x$enableval = xyes ; then
2077 + cat >>confdefs.h <<\_ACEOF
2081 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
2089 for ac_func in strftime
2090 diff -udprP mutt-1.5.16.orig/configure.ac mutt-1.5.16/configure.ac
2091 --- mutt-1.5.16.orig/configure.ac 2007-06-04 07:20:01.000000000 +0300
2092 +++ mutt-1.5.16/configure.ac 2007-06-15 17:12:26.000000000 +0300
2093 @@ -584,6 +584,14 @@ if test x"$need_imap" = xyes -o x"$need_
2094 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
2097 +AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support],
2098 +[ if test x$enableval = xyes ; then
2099 + AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
2100 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
2105 dnl -- end socket dependencies --
2107 if test "$need_socket" = "yes"
2108 diff -udprP mutt-1.5.16.orig/curs_main.c mutt-1.5.16/curs_main.c
2109 --- mutt-1.5.16.orig/curs_main.c 2007-05-20 10:30:00.000000000 +0300
2110 +++ mutt-1.5.16/curs_main.c 2007-06-15 17:12:41.000000000 +0300
2114 #include "mutt_curses.h"
2116 #include "mutt_menu.h"
2118 #include "mailbox.h"
2121 #include "mutt_crypt.h"
2130 @@ -415,12 +420,27 @@ struct mapping_t IndexHelp[] = {
2135 +struct mapping_t IndexNewsHelp[] = {
2136 + { N_("Quit"), OP_QUIT },
2137 + { N_("Del"), OP_DELETE },
2138 + { N_("Undel"), OP_UNDELETE },
2139 + { N_("Save"), OP_SAVE },
2140 + { N_("Post"), OP_POST },
2141 + { N_("Followup"), OP_FOLLOWUP },
2142 + { N_("Catchup"), OP_CATCHUP },
2143 + { N_("Help"), OP_HELP },
2148 /* This function handles the message index window as well as commands returned
2149 * from the pager (MENU_PAGER).
2151 int mutt_index_menu (void)
2153 char buf[LONG_STRING], helpstr[LONG_STRING];
2156 int done = 0; /* controls when to exit the "event" loop */
2158 @@ -442,7 +462,11 @@ int mutt_index_menu (void)
2159 menu->make_entry = index_make_entry;
2160 menu->color = index_color;
2161 menu->current = ci_first_message ();
2162 - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
2163 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
2165 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
2170 mutt_buffy_check(1); /* force the buffy check after we enter the folder */
2171 @@ -694,6 +718,9 @@ int mutt_index_menu (void)
2172 mutt_curs_set (1); /* fallback from the pager */
2176 + unset_option (OPTNEWS); /* for any case */
2181 @@ -744,6 +771,120 @@ int mutt_index_menu (void)
2182 menu_current_bottom (menu);
2186 + case OP_GET_MESSAGE:
2187 + case OP_GET_PARENT:
2189 + if (Context->magic == M_NNTP)
2193 + if (op == OP_GET_MESSAGE)
2196 + if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
2202 + LIST *ref = CURHDR->env->references;
2205 + mutt_error _("Article has no parent reference!");
2208 + strfcpy (buf, ref->data, sizeof (buf));
2210 + if (!Context->id_hash)
2211 + Context->id_hash = mutt_make_id_hash (Context);
2212 + if ((h = hash_find (Context->id_hash, buf)))
2214 + if (h->virtual != -1)
2216 + menu->current = h->virtual;
2217 + menu->redraw = REDRAW_MOTION_RESYNCH;
2219 + else if (h->collapsed)
2221 + mutt_uncollapse_thread (Context, h);
2222 + mutt_set_virtual (Context);
2223 + menu->current = h->virtual;
2224 + menu->redraw = REDRAW_MOTION_RESYNCH;
2227 + mutt_error _("Message not visible in limited view.");
2231 + if (nntp_check_msgid (Context, buf) == 0)
2233 + h = Context->hdrs[Context->msgcount-1];
2234 + mutt_sort_headers (Context, 0);
2235 + menu->current = h->virtual;
2236 + menu->redraw = REDRAW_FULL;
2239 + mutt_error (_("Article %s not found on server"), buf);
2244 + case OP_GET_CHILDREN:
2245 + case OP_RECONSTRUCT_THREAD:
2247 + if (Context->magic == M_NNTP)
2250 + int old = CURHDR->index, i;
2252 + if (!CURHDR->env->message_id)
2254 + mutt_error _("No Message-Id. Unable to perform operation");
2258 + if (!Context->id_hash)
2259 + Context->id_hash = mutt_make_id_hash (Context);
2260 + strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
2262 + if (op == OP_RECONSTRUCT_THREAD)
2264 + LIST *ref = CURHDR->env->references;
2267 + nntp_check_msgid (Context, ref->data);
2268 + /* the last msgid in References is the root message */
2270 + strfcpy (buf, ref->data, sizeof (buf));
2274 + mutt_message _("Check for children of message...");
2275 + if (nntp_check_children (Context, buf) == 0)
2277 + mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
2278 + h = hash_find (Context->id_hash, buf);
2279 + /* if the root message was retrieved, move to it */
2281 + menu->current = h->virtual;
2282 + else /* try to restore old position */
2283 + for (i = 0; i < Context->msgcount; i++)
2284 + if (Context->hdrs[i]->index == old)
2286 + menu->current = Context->hdrs[i]->virtual;
2287 + /* As an added courtesy, recenter the menu
2288 + * with the current entry at the middle of the screen */
2289 + menu_check_recenter (menu);
2290 + menu_current_middle (menu);
2293 + menu->redraw = REDRAW_FULL;
2294 + mutt_clear_error ();
2302 @@ -841,11 +982,33 @@ int mutt_index_menu (void)
2306 + case OP_TOGGLE_READ:
2309 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
2311 - if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
2312 + if (op == OP_TOGGLE_READ)
2314 + char buf[LONG_STRING];
2316 + if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
2318 + snprintf (buf, sizeof (buf), "!~R!~D~s%s",
2319 + Context->pattern ? Context->pattern : ".*");
2320 + set_option (OPTHIDEREAD);
2324 + strfcpy (buf, Context->pattern + 8, sizeof(buf));
2325 + if (!*buf || strncmp (buf, ".*", 2) == 0)
2326 + snprintf (buf, sizeof(buf), "~A");
2327 + unset_option (OPTHIDEREAD);
2329 + FREE (&Context->pattern);
2330 + Context->pattern = safe_strdup (buf);
2332 + if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
2333 + mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
2335 if (menu->oldcurrent >= 0)
2337 @@ -1053,15 +1216,22 @@ int mutt_index_menu (void)
2339 case OP_MAIN_CHANGE_FOLDER:
2340 case OP_MAIN_NEXT_UNREAD_MAILBOX:
2343 - op = OP_MAIN_CHANGE_FOLDER_READONLY;
2345 - /* fallback to the readonly case */
2347 case OP_MAIN_CHANGE_FOLDER_READONLY:
2349 + case OP_MAIN_CHANGE_GROUP:
2350 + case OP_MAIN_CHANGE_GROUP_READONLY:
2351 + unset_option (OPTNEWS);
2353 + if (attach_msg || option (OPTREADONLY) ||
2355 + op == OP_MAIN_CHANGE_GROUP_READONLY ||
2357 + op == OP_MAIN_CHANGE_FOLDER_READONLY)
2358 + flags = M_READONLY;
2362 - if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
2364 cp = _("Open mailbox in read-only mode");
2366 cp = _("Open mailbox");
2367 @@ -1080,6 +1250,21 @@ int mutt_index_menu (void)
2372 + if (op == OP_MAIN_CHANGE_GROUP ||
2373 + op == OP_MAIN_CHANGE_GROUP_READONLY)
2375 + set_option (OPTNEWS);
2376 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
2379 + cp = _("Open newsgroup in read-only mode");
2381 + cp = _("Open newsgroup");
2386 mutt_buffy (buf, sizeof (buf));
2388 if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
2389 @@ -1099,6 +1284,14 @@ int mutt_index_menu (void)
2394 + if (option (OPTNEWS))
2396 + unset_option (OPTNEWS);
2397 + nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
2401 mutt_expand_path (buf, sizeof (buf));
2402 if (mx_get_magic (buf) <= 0)
2404 @@ -1136,15 +1329,18 @@ int mutt_index_menu (void)
2405 CurrentMenu = MENU_MAIN;
2406 mutt_folder_hook (buf);
2408 - if ((Context = mx_open_mailbox (buf,
2409 - (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
2410 - M_READONLY : 0, NULL)) != NULL)
2411 + if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
2413 menu->current = ci_first_message ();
2419 + /* mutt_buffy_check() must be done with mail-reader mode! */
2420 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
2421 + (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
2423 mutt_clear_error ();
2424 mutt_buffy_check(1); /* force the buffy check after we have changed
2426 @@ -1515,6 +1711,15 @@ int mutt_index_menu (void)
2428 CHECK_ACL(M_ACL_WRITE, _("flag message"));
2431 + if (Context->magic == M_NNTP)
2434 + mutt_error _("Can't change 'important' flag on NNTP server.");
2441 for (j = 0; j < Context->vcount; j++)
2442 @@ -1862,6 +2067,17 @@ int mutt_index_menu (void)
2448 + if (Context && Context->magic == M_NNTP)
2450 + if (mutt_newsgroup_catchup (CurrentNewsSrv,
2451 + ((NNTP_DATA *)Context->data)->group))
2452 + menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2457 case OP_DISPLAY_ADDRESS:
2460 @@ -1989,6 +2205,15 @@ int mutt_index_menu (void)
2461 menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
2466 + if (Context->magic == M_NNTP)
2469 + mutt_error _("Can't edit message on newsserver.");
2474 MAYBE_REDRAW (menu->redraw);
2476 @@ -2060,6 +2285,37 @@ int mutt_index_menu (void)
2478 menu->redraw = REDRAW_FULL;
2484 + case OP_FORWARD_TO_GROUP:
2487 + if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2488 + mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2489 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
2491 + if (Context && Context->magic == M_NNTP &&
2492 + !((NNTP_DATA *)Context->data)->allowed &&
2493 + query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
2495 + if (op == OP_POST)
2496 + ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2500 + if (op == OP_FOLLOWUP)
2501 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
2502 + tag ? NULL : CURHDR);
2504 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
2505 + tag ? NULL : CURHDR);
2507 + menu->redraw = REDRAW_FULL;
2514 @@ -2136,6 +2392,12 @@ int mutt_index_menu (void)
2516 CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
2519 + /* Close all open NNTP connections */
2521 + nntp_logout_all ();
2524 rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
2525 op == OP_UNDELETE_THREAD ? 0 : 1);
2527 diff -udprP mutt-1.5.16.orig/doc/manual.xml.head mutt-1.5.16/doc/manual.xml.head
2528 --- mutt-1.5.16.orig/doc/manual.xml.head 2007-04-04 08:37:13.000000000 +0300
2529 +++ mutt-1.5.16/doc/manual.xml.head 2007-06-15 17:12:26.000000000 +0300
2530 @@ -1295,6 +1295,22 @@ fo-table</literal> for details.
2535 +<title>Reading news via NNTP</title>
2538 +If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2539 +read news from newsserver via NNTP. You can open a newsgroup with
2540 +function ``change-newsgroup'' (default: ``i''). Default newsserver
2541 +can be obtained from <emphasis>NNTPSERVER</emphasis> environment
2542 +variable. Like other news readers, info about subscribed newsgroups
2543 +is saved in file by <link linkend="newsrc">$newsrc</link>
2544 +variable. Article headers are cached and can be loaded from file when
2545 +newsgroup entered instead loading from newsserver.
2552 <sect1 id="forwarding-mail">
2553 diff -udprP mutt-1.5.16.orig/doc/mutt.man mutt-1.5.16/doc/mutt.man
2554 --- mutt-1.5.16.orig/doc/mutt.man 2007-04-04 08:37:13.000000000 +0300
2555 +++ mutt-1.5.16/doc/mutt.man 2007-06-15 17:12:26.000000000 +0300
2556 @@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2561 -[-e \fIcmd\fP] [-F \fIfile\fP] [-m \fItype\fP] [-f \fIfile\fP]
2563 +[-e \fIcmd\fP] [-F \fIfile\fP] [-g \fIserver\fP] [-m \fItype\fP] [-f \fIfile\fP]
2567 @@ -83,6 +83,10 @@ files.
2568 Specify which mailbox to load.
2569 .IP "-F \fImuttrc\fP"
2570 Specify an initialization file to read instead of ~/.muttrc
2571 +.IP "-g \fIserver\fP"
2572 +Start Mutt with a listing of subscribed newsgroups at specified newsserver.
2574 +Start Mutt with a listing of subscribed newsgroups.
2577 .IP "-H \fIdraft\fP"
2578 diff -udprP mutt-1.5.16.orig/functions.h mutt-1.5.16/functions.h
2579 --- mutt-1.5.16.orig/functions.h 2007-05-14 20:10:00.000000000 +0300
2580 +++ mutt-1.5.16/functions.h 2007-06-15 17:12:26.000000000 +0300
2581 @@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in
2582 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2583 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2584 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2586 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2587 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2589 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2590 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2591 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
2592 @@ -101,7 +105,15 @@ struct binding_t OpMain[] = { /* map: in
2593 { "edit", OP_EDIT_MESSAGE, "e" },
2594 { "edit-type", OP_EDIT_TYPE, "\005" },
2595 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2596 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2598 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2599 + { "followup-message", OP_FOLLOWUP, "F" },
2600 + { "get-children", OP_GET_CHILDREN, NULL },
2601 + { "get-message", OP_GET_MESSAGE, "\007" },
2602 + { "get-parent", OP_GET_PARENT, "\033G" },
2603 + { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2605 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2606 { "group-reply", OP_GROUP_REPLY, "g" },
2608 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2609 @@ -127,6 +139,9 @@ struct binding_t OpMain[] = { /* map: in
2610 { "sort-mailbox", OP_SORT, "o" },
2611 { "sort-reverse", OP_SORT_REVERSE, "O" },
2612 { "print-message", OP_PRINT, "p" },
2614 + { "post-message", OP_POST, "P" },
2616 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2617 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2618 { "recall-message", OP_RECALL_MESSAGE, "R" },
2619 @@ -146,6 +161,10 @@ struct binding_t OpMain[] = { /* map: in
2620 { "show-version", OP_VERSION, "V" },
2621 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2622 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2623 + { "toggle-read", OP_TOGGLE_READ, "X" },
2625 + { "catchup", OP_CATCHUP, "y" },
2627 { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S },
2628 { "buffy-list", OP_BUFFY_LIST, "." },
2629 { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" },
2630 @@ -157,7 +176,7 @@ struct binding_t OpMain[] = { /* map: in
2631 { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" },
2632 { "next-unread", OP_MAIN_NEXT_UNREAD, NULL },
2633 { "previous-unread", OP_MAIN_PREV_UNREAD, NULL },
2634 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2635 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2638 { "extract-keys", OP_EXTRACT_KEYS, "\013" },
2639 @@ -177,6 +196,10 @@ struct binding_t OpPager[] = { /* map: p
2640 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2641 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2642 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2644 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2645 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2647 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2648 { "copy-message", OP_COPY_MESSAGE, "C" },
2649 { "decode-copy", OP_DECODE_COPY, "\033C" },
2650 @@ -185,8 +208,12 @@ struct binding_t OpPager[] = { /* map: p
2651 { "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" },
2652 { "edit", OP_EDIT_MESSAGE, "e" },
2653 { "edit-type", OP_EDIT_TYPE, "\005" },
2655 + { "followup-message", OP_FOLLOWUP, "F" },
2656 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2658 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2659 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2660 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2661 { "group-reply", OP_GROUP_REPLY, "g" },
2663 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
2664 @@ -205,6 +232,9 @@ struct binding_t OpPager[] = { /* map: p
2665 { "next-thread", OP_MAIN_NEXT_THREAD, "\016" },
2666 { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" },
2667 { "print-message", OP_PRINT, "p" },
2669 + { "post-message", OP_POST, "P" },
2671 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2672 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2673 { "quit", OP_QUIT, "Q" },
2674 @@ -252,7 +282,7 @@ struct binding_t OpPager[] = { /* map: p
2675 { "half-down", OP_HALF_DOWN, NULL },
2676 { "previous-line", OP_PREV_LINE, NULL },
2677 { "bottom", OP_PAGER_BOTTOM, NULL },
2678 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2679 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2683 @@ -272,6 +302,10 @@ struct binding_t OpAttach[] = { /* map:
2684 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2685 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2686 { "edit-type", OP_EDIT_TYPE, "\005" },
2688 + { "followup-message", OP_FOLLOWUP, "F" },
2689 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2691 { "print-entry", OP_PRINT, "p" },
2692 { "save-entry", OP_SAVE, "s" },
2693 { "pipe-entry", OP_PIPE, "|" },
2694 @@ -297,6 +331,7 @@ struct binding_t OpAttach[] = { /* map:
2695 struct binding_t OpCompose[] = { /* map: compose */
2696 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2697 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2698 + { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2699 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2700 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2701 { "copy-file", OP_SAVE, "C" },
2702 @@ -316,6 +351,11 @@ struct binding_t OpCompose[] = { /* map:
2703 { "print-entry", OP_PRINT, "l" },
2704 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2705 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2707 + { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2708 + { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2709 + { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2711 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2712 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2713 { "rename-file", OP_COMPOSE_RENAME_FILE, "R" },
2714 @@ -367,14 +407,25 @@ struct binding_t OpBrowser[] = { /* map:
2715 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2716 { "check-new", OP_CHECK_NEW, NULL },
2717 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2719 + { "reload-active", OP_LOAD_ACTIVE, "g" },
2720 + { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2721 + { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2722 + { "catchup", OP_CATCHUP, "y" },
2723 + { "uncatchup", OP_UNCATCHUP, "Y" },
2725 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2726 { "buffy-list", OP_BUFFY_LIST, "." },
2728 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2729 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2730 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2732 +#if defined USE_IMAP || defined USE_NNTP
2733 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2734 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2737 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2740 diff -udprP mutt-1.5.16.orig/globals.h mutt-1.5.16/globals.h
2741 --- mutt-1.5.16.orig/globals.h 2007-06-10 05:29:21.000000000 +0300
2742 +++ mutt-1.5.16/globals.h 2007-06-15 17:12:26.000000000 +0300
2743 @@ -95,6 +95,15 @@ WHERE char *MixEntryFormat;
2746 WHERE char *Muttrc INITVAL (NULL);
2748 +WHERE char *NewsCacheDir;
2749 +WHERE char *GroupFormat;
2751 +WHERE char *NewsServer;
2752 +WHERE char *NntpUser;
2753 +WHERE char *NntpPass;
2754 +WHERE char *NewsRc;
2758 WHERE char *PagerFmt;
2759 @@ -190,6 +199,11 @@ extern unsigned char QuadOptions[];
2761 WHERE unsigned short Counter INITVAL (0);
2764 +WHERE short NewsPollTimeout;
2765 +WHERE short NntpContext;
2768 WHERE short ConnectTimeout;
2769 WHERE short HistSize;
2770 WHERE short MenuContext;
2771 diff -udprP mutt-1.5.16.orig/hash.c mutt-1.5.16/hash.c
2772 --- mutt-1.5.16.orig/hash.c 2007-04-02 00:58:56.000000000 +0300
2773 +++ mutt-1.5.16/hash.c 2007-06-15 17:12:26.000000000 +0300
2774 @@ -51,10 +51,35 @@ HASH *hash_create (int nelem)
2777 table->nelem = nelem;
2778 + table->curnelem = 0;
2779 table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
2783 +HASH *hash_resize (HASH *ptr, int nelem)
2786 + struct hash_elem *elem, *tmp;
2789 + table = hash_create (nelem);
2791 + for (i = 0; i < ptr->nelem; i++)
2793 + for (elem = ptr->table[i]; elem; )
2796 + elem = elem->next;
2797 + hash_insert (table, tmp->key, tmp->data, 1);
2801 + FREE (&ptr->table);
2807 /* table hash table to update
2808 * key key to hash on
2809 * data data to associate with `key'
2810 @@ -74,6 +99,7 @@ int hash_insert (HASH * table, const cha
2812 ptr->next = table->table[h];
2813 table->table[h] = ptr;
2814 + table->curnelem++;
2818 @@ -96,6 +122,7 @@ int hash_insert (HASH * table, const cha
2820 table->table[h] = ptr;
2822 + table->curnelem++;
2826 @@ -126,6 +153,7 @@ void hash_delete_hash (HASH * table, int
2828 destroy (ptr->data);
2830 + table->curnelem--;
2834 diff -udprP mutt-1.5.16.orig/hash.h mutt-1.5.16/hash.h
2835 --- mutt-1.5.16.orig/hash.h 2007-04-02 00:58:56.000000000 +0300
2836 +++ mutt-1.5.16/hash.h 2007-06-15 17:12:26.000000000 +0300
2837 @@ -28,7 +28,7 @@ struct hash_elem
2842 + int nelem, curnelem;
2843 struct hash_elem **table;
2846 @@ -40,6 +40,7 @@ HASH;
2847 HASH *hash_create (int nelem);
2848 int hash_string (const unsigned char *s, int n);
2849 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
2850 +HASH *hash_resize (HASH * table, int nelem);
2851 void *hash_find_hash (const HASH * table, int hash, const char *key);
2852 void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
2853 void (*destroy) (void *));
2854 diff -udprP mutt-1.5.16.orig/hdrline.c mutt-1.5.16/hdrline.c
2855 --- mutt-1.5.16.orig/hdrline.c 2007-04-16 02:56:26.000000000 +0300
2856 +++ mutt-1.5.16/hdrline.c 2007-06-15 17:12:26.000000000 +0300
2857 @@ -209,6 +209,7 @@ int mutt_user_is_recipient (HEADER *h)
2858 * %E = number of messages in current thread
2859 * %f = entire from line
2860 * %F = like %n, unless from self
2861 + * %g = newsgroup name (if compiled with nntp support)
2863 * %l = number of lines in the message
2864 * %L = like %F, except `lists' are displayed first
2865 @@ -217,12 +218,14 @@ int mutt_user_is_recipient (HEADER *h)
2867 * %O = like %L, except using address instead of name
2868 * %P = progress indicator for builtin pager
2869 + * %R = `x-comment-to:' field (if present and compiled with nntp support)
2871 * %S = short message status (e.g., N/O/D/!/r/-)
2872 * %t = `to:' field (recipients)
2874 * %u = user (login) name of author
2875 * %v = first name of author, unless from self
2876 + * %W = where user is (organization)
2877 * %X = number of MIME attachments
2878 * %y = `x-label:' field (if present)
2879 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2880 @@ -455,6 +458,12 @@ hdr_format_str (char *dest,
2886 + mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2891 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2893 @@ -546,6 +555,15 @@ hdr_format_str (char *dest,
2894 strfcpy(dest, NONULL(hfi->pager_progress), destlen);
2900 + mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2901 + else if (!hdr->env->x_comment_to)
2908 if (flags & M_FORMAT_TREE && !hdr->collapsed)
2909 @@ -635,6 +653,13 @@ hdr_format_str (char *dest,
2910 mutt_format_s (dest, destlen, prefix, buf2);
2915 + mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2916 + else if (!hdr->env->organization)
2923 diff -udprP mutt-1.5.16.orig/headers.c mutt-1.5.16/headers.c
2924 --- mutt-1.5.16.orig/headers.c 2007-04-10 07:33:44.000000000 +0300
2925 +++ mutt-1.5.16/headers.c 2007-06-15 17:12:26.000000000 +0300
2926 @@ -118,6 +118,9 @@ void mutt_edit_headers (const char *edit
2927 msg->env = n; n = NULL;
2929 if (!msg->env->in_reply_to)
2931 + if (!option (OPTNEWSSEND))
2933 mutt_free_list (&msg->env->references);
2935 mutt_expand_aliases_env (msg->env);
2936 diff -udprP mutt-1.5.16.orig/init.c mutt-1.5.16/init.c
2937 --- mutt-1.5.16.orig/init.c 2007-04-02 00:58:56.000000000 +0300
2938 +++ mutt-1.5.16/init.c 2007-06-15 17:12:26.000000000 +0300
2939 @@ -2859,6 +2859,28 @@ void mutt_init (int skip_sys_rc, LIST *c
2941 Fqdn = safe_strdup(NONULL(Hostname));
2948 + if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2951 + fgets (buffer, sizeof (buffer), f);
2955 + while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2957 + NewsServer = safe_strdup (p);
2961 + if ((p = getenv ("NNTPSERVER")))
2962 + NewsServer = safe_strdup (p);
2965 if ((p = getenv ("MAIL")))
2966 Spoolfile = safe_strdup (p);
2967 else if ((p = getenv ("MAILDIR")))
2968 diff -udprP mutt-1.5.16.orig/init.h mutt-1.5.16/init.h
2969 --- mutt-1.5.16.orig/init.h 2007-06-10 05:29:21.000000000 +0300
2970 +++ mutt-1.5.16/init.h 2007-06-15 17:12:26.000000000 +0300
2971 @@ -169,6 +169,20 @@ struct option_t MuttVars[] = {
2972 ** If set, Mutt will prompt you for carbon-copy (Cc) recipients before
2973 ** editing the body of an outgoing message.
2976 + { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2979 + ** If set, Mutt will prompt you for follow-up groups before editing
2980 + ** the body of an outgoing message.
2982 + { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2985 + ** If set, Mutt will prompt you for x-comment-to field before editing
2986 + ** the body of an outgoing message.
2989 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2992 @@ -308,6 +322,14 @@ struct option_t MuttVars[] = {
2993 ** When this variable is set, mutt will use file size attribute instead of
2994 ** access time when checking for new mail.
2997 + { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
3000 + ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
3001 + ** as read when you quit the newsgroup (catchup newsgroup).
3004 { "charset", DT_STR, R_NONE, UL &Charset, UL 0 },
3007 @@ -635,6 +657,16 @@ struct option_t MuttVars[] = {
3008 ** sent to both the list and your address, resulting in two copies
3009 ** of the same email for you.
3012 + { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
3015 + ** If this variable is \fIset\fP and the keyword "poster" is present in
3016 + ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
3017 + ** permitted. The message will be mailed to the submitter of the
3018 + ** message via mail.
3021 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
3024 @@ -706,6 +738,27 @@ struct option_t MuttVars[] = {
3025 ** a regular expression that will match the whole name so mutt will expand
3026 ** "Franklin" to "Franklin, Steve".
3029 + { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
3032 + ** This variable allows you to customize the newsgroup browser display to
3033 + ** your personal taste. This string is similar to ``$index_format'', but
3034 + ** has its own set of printf()-like sequences:
3037 + ** %C current newsgroup number
3038 + ** %d description of newsgroup (becomes from server)
3039 + ** %f newsgroup name
3040 + ** %M - if newsgroup not allowed for direct post (moderated for example)
3041 + ** %N N if newsgroup is new, u if unsubscribed, blank otherwise
3042 + ** %n number of new articles in newsgroup
3043 + ** %s number of unread articles in newsgroup
3044 + ** %>X right justify the rest of the string and pad with character "X"
3045 + ** %|X pad to the end of the line with character "X"
3049 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
3052 @@ -996,6 +1049,7 @@ struct option_t MuttVars[] = {
3053 ** .dt %E .dd number of messages in current thread
3054 ** .dt %f .dd entire From: line (address + real name)
3055 ** .dt %F .dd author name, or recipient name if the message is from you
3056 + ** .dt %g .dd newsgroup name (if compiled with nntp support)
3057 ** .dt %H .dd spam attribute(s) of this message
3058 ** .dt %i .dd message-id of the current message
3059 ** .dt %l .dd number of lines in the message (does not work with maildir,
3060 @@ -1010,12 +1064,14 @@ struct option_t MuttVars[] = {
3061 ** .dt %O .dd (_O_riginal save folder) Where mutt would formerly have
3062 ** stashed the message: list name or recipient name if no list
3063 ** .dt %P .dd progress indicator for the builtin pager (how much of the file has been displayed)
3064 + ** .dt %R .dd `x-comment-to:' field (if present and compiled with nntp support)
3065 ** .dt %s .dd subject of the message
3066 ** .dt %S .dd status of the message (N/D/d/!/r/\(as)
3067 ** .dt %t .dd `to:' field (recipients)
3068 ** .dt %T .dd the appropriate character from the $$to_chars string
3069 ** .dt %u .dd user (login) name of the author
3070 ** .dt %v .dd first name of the author, or the recipient if the message is from you
3071 + ** .dt %W .dd name of organization of author (`organization:' field)
3072 ** .dt %X .dd number of attachments
3073 ** (please see the ``$attachments'' section for possible speed effects)
3074 ** .dt %y .dd `x-label:' field, if present
3075 @@ -1040,6 +1096,21 @@ struct option_t MuttVars[] = {
3077 ** See also: ``$$to_chars''.
3080 + { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
3083 + ** If set, specifies the program and arguments used to deliver news posted
3084 + ** by Mutt. Otherwise, mutt posts article using current connection to
3085 + ** news server. The following printf-style sequence is understood:
3088 + ** %s newsserver name
3091 + ** Example: set inews="/usr/local/bin/inews -hS"
3094 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
3097 @@ -1254,6 +1325,16 @@ struct option_t MuttVars[] = {
3098 ** be attached to the newly composed message if this option is set.
3102 + { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
3105 + ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
3106 + ** encoded according to RFC2047 to base64. This is useful when message
3107 + ** is Usenet article, because MIME for news is nonstandard feature.
3112 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
3114 @@ -1331,6 +1412,77 @@ struct option_t MuttVars[] = {
3115 ** See also ``$$read_inc'' and ``$$write_inc''.
3119 + { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
3122 + ** This variable pointing to directory where Mutt will save cached news
3123 + ** articles headers in. If \fIunset\fP, headers will not be saved at all
3124 + ** and will be reloaded each time when you enter to newsgroup.
3126 + { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
3129 + ** This variable specifies domain name or address of NNTP server. It
3130 + ** defaults to the newsserver specified in the environment variable
3131 + ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
3132 + ** specify username and an alternative port for each newsserver, ie:
3134 + ** [news[s]://][username[:password]@]newsserver[:port]
3136 + { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
3139 + ** The file, containing info about subscribed newsgroups - names and
3140 + ** indexes of read articles. The following printf-style sequence
3144 + ** %s newsserver name
3147 + { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
3150 + ** This variable defines number of articles which will be in index when
3151 + ** newsgroup entered. If active newsgroup have more articles than this
3152 + ** number, oldest articles will be ignored. Also controls how many
3153 + ** articles headers will be saved in cache when you quit newsgroup.
3155 + { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
3158 + ** This variable controls whether or not descriptions for each newsgroup
3159 + ** must be loaded when newsgroup is added to list (first time list
3160 + ** loading or new newsgroup adding).
3162 + { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
3165 + ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
3166 + ** authentification, Mutt will prompt you for your account name when you
3167 + ** connect to newsserver.
3169 + { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
3172 + ** Your password for NNTP account.
3174 + { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
3177 + ** The time in seconds until any operations on newsgroup except post new
3178 + ** article will cause recheck for new news. If set to 0, Mutt will
3179 + ** recheck newsgroup on each operation in index (stepping, read article,
3182 + { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
3185 + ** Controls whether or not Mutt will try to reconnect to newsserver when
3186 + ** connection lost.
3189 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
3192 @@ -2141,6 +2293,16 @@ struct option_t MuttVars[] = {
3193 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
3197 + { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
3200 + ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
3201 + ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver
3202 + ** does not support posting to that newsgroup or totally read-only, that
3203 + ** posting will not have an effect.
3206 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
3209 @@ -2497,6 +2659,28 @@ struct option_t MuttVars[] = {
3210 ** Command to use when spawning a subshell. By default, the user's login
3211 ** shell from /etc/passwd is used.
3214 + { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
3217 + ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
3218 + ** ``newsrc'' file and into cache.
3220 + { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
3223 + ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
3224 + ** the browser. Otherwise, it will be done only once for a newsserver.
3225 + ** Also controls whether or not number of new articles of subscribed
3226 + ** newsgroups will be then checked.
3228 + { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
3231 + ** If \fIset\fP, only subscribed newsgroups that contain unread articles
3232 + ** will be displayed in browser.
3235 { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
3238 @@ -3005,6 +3189,14 @@ struct option_t MuttVars[] = {
3239 ** option does nothing: mutt will never write out the BCC header
3243 + { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
3246 + ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
3247 + ** name of original article author) to article that followuped to newsgroup.
3253 diff -udprP mutt-1.5.16.orig/keymap.c mutt-1.5.16/keymap.c
3254 --- mutt-1.5.16.orig/keymap.c 2007-04-02 00:58:56.000000000 +0300
3255 +++ mutt-1.5.16/keymap.c 2007-06-15 17:12:26.000000000 +0300
3256 @@ -629,7 +629,6 @@ void km_init (void)
3257 km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE);
3259 km_bindkey ("x", MENU_PAGER, OP_EXIT);
3260 - km_bindkey ("i", MENU_PAGER, OP_EXIT);
3261 km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE);
3262 km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE);
3263 km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE);
3264 diff -udprP mutt-1.5.16.orig/mailbox.h mutt-1.5.16/mailbox.h
3265 --- mutt-1.5.16.orig/mailbox.h 2007-04-02 00:58:56.000000000 +0300
3266 +++ mutt-1.5.16/mailbox.h 2007-06-15 17:12:26.000000000 +0300
3267 @@ -74,6 +74,9 @@ int mx_is_imap (const char *);
3269 int mx_is_pop (const char *);
3272 +int mx_is_nntp (const char *);
3275 int mx_access (const char*, int);
3276 int mx_check_empty (const char *);
3277 diff -udprP mutt-1.5.16.orig/main.c mutt-1.5.16/main.c
3278 --- mutt-1.5.16.orig/main.c 2007-04-10 23:53:08.000000000 +0300
3279 +++ mutt-1.5.16/main.c 2007-06-15 17:12:26.000000000 +0300
3281 #include <stringprep.h>
3288 static const char *ReachingUs = N_("\
3289 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
3290 To report a bug, please visit http://bugs.mutt.org/.\n");
3291 @@ -127,6 +131,8 @@ options:\n\
3292 " -e <command>\tspecify a command to be executed after initialization\n\
3293 -f <file>\tspecify which mailbox to read\n\
3294 -F <file>\tspecify an alternate muttrc file\n\
3295 + -g <server>\tspecify a newsserver (if compiled with NNTP)\n\
3296 + -G\t\tselect a newsgroup (if compiled with NNTP)\n\
3297 -H <file>\tspecify a draft file to read header and body from\n\
3298 -i <file>\tspecify a file which Mutt should include in the body\n\
3299 -m <type>\tspecify a default mailbox type\n\
3300 @@ -253,6 +259,12 @@ static void show_version (void)
3313 @@ -521,6 +533,9 @@ static void start_curses (void)
3314 #define M_NOSYSRC (1<<2) /* -n */
3315 #define M_RO (1<<3) /* -R */
3316 #define M_SELECT (1<<4) /* -y */
3318 +#define M_NEWS (1<<5) /* -g and -G */
3321 int main (int argc, char **argv)
3323 @@ -577,7 +592,11 @@ int main (int argc, char **argv)
3328 + while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
3330 while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
3335 @@ -670,6 +689,20 @@ int main (int argc, char **argv)
3340 + case 'g': /* Specify a newsserver */
3342 + char buf[LONG_STRING];
3344 + snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
3345 + commands = mutt_add_list (commands, buf);
3348 + case 'G': /* List of newsgroups */
3349 + flags |= M_SELECT | M_NEWS;
3356 @@ -947,6 +980,18 @@ int main (int argc, char **argv)
3358 else if (flags & M_SELECT)
3361 + if (flags & M_NEWS)
3363 + set_option (OPTNEWS);
3364 + if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
3366 + mutt_endwin (Errorbuf);
3373 mutt_endwin _("No incoming mailboxes defined.");
3375 @@ -962,6 +1007,15 @@ int main (int argc, char **argv)
3378 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
3381 + if (option (OPTNEWS))
3383 + unset_option (OPTNEWS);
3384 + nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
3388 mutt_expand_path (folder, sizeof (folder));
3390 mutt_str_replace (&CurrentFolder, folder);
3391 diff -udprP mutt-1.5.16.orig/mutt.h mutt-1.5.16/mutt.h
3392 --- mutt-1.5.16.orig/mutt.h 2007-04-11 06:14:01.000000000 +0300
3393 +++ mutt-1.5.16/mutt.h 2007-06-15 17:12:26.000000000 +0300
3394 @@ -243,6 +243,9 @@ enum
3402 /* Options for Mailcap lookup */
3404 @@ -298,6 +301,12 @@ enum
3407 OPT_VERIFYSIG, /* verify PGP signatures */
3410 + OPT_NNTPRECONNECT,
3412 + OPT_FOLLOWUPTOPOSTER,
3413 +#endif /* USE_NNTP */
3415 /* THIS MUST BE THE LAST VALUE. */
3417 @@ -313,6 +322,7 @@ enum
3418 #define SENDMAILX (1<<6)
3419 #define SENDKEY (1<<7)
3420 #define SENDRESEND (1<<8)
3421 +#define SENDNEWS (1<<9)
3423 /* flags to _mutt_select_file() */
3424 #define M_SEL_BUFFY (1<<0)
3425 @@ -332,6 +342,8 @@ enum
3434 @@ -407,6 +419,9 @@ enum
3439 + OPTMIMESUBJECT, /* encode subject line with RFC2047 */
3444 @@ -488,6 +503,16 @@ enum
3448 + /* news options */
3452 + OPTSHOWONLYUNREAD,
3456 +#endif /* USE_NNTP */
3458 /* pseudo options */
3460 OPTAUXSORT, /* (pseudo) using auxillary sort function */
3461 @@ -508,6 +533,7 @@ enum
3462 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
3463 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3464 OPTATTACHMSG, /* (pseudo) used by attach-message */
3465 + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3466 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3467 * functions while we are executing an
3469 @@ -518,6 +544,12 @@ enum
3470 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3471 OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
3474 + OPTNEWS, /* (pseudo) used to change reader mode */
3475 + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3476 + OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */
3482 @@ -595,6 +627,13 @@ typedef struct envelope
3486 + char *organization;
3490 + char *followup_to;
3491 + char *x_comment_to;
3494 LIST *references; /* message references (in reverse order) */
3495 LIST *in_reply_to; /* in-reply-to header content */
3496 @@ -761,6 +800,9 @@ typedef struct header
3497 ENVELOPE *env; /* envelope information */
3498 BODY *content; /* list of MIME parts */
3504 char *tree; /* character string to print thread tree */
3505 struct thread *thread;
3506 @@ -776,7 +818,7 @@ typedef struct header
3507 int refno; /* message number on server */
3510 -#if defined USE_POP || defined USE_IMAP
3511 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3512 void *data; /* driver-specific data */
3515 diff -udprP mutt-1.5.16.orig/muttlib.c mutt-1.5.16/muttlib.c
3516 --- mutt-1.5.16.orig/muttlib.c 2007-05-14 20:10:00.000000000 +0300
3517 +++ mutt-1.5.16/muttlib.c 2007-06-15 17:12:26.000000000 +0300
3518 @@ -286,7 +286,7 @@ void mutt_free_header (HEADER **h)
3520 mutt_free_list (&(*h)->chain);
3522 -#if defined USE_POP || defined USE_IMAP
3523 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3526 FREE (h); /* __FREE_CHECKED__ */
3527 @@ -674,6 +674,13 @@ void mutt_free_envelope (ENVELOPE **p)
3528 FREE (&(*p)->supersedes);
3530 FREE (&(*p)->x_label);
3531 + FREE (&(*p)->organization);
3533 + FREE (&(*p)->newsgroups);
3534 + FREE (&(*p)->xref);
3535 + FREE (&(*p)->followup_to);
3536 + FREE (&(*p)->x_comment_to);
3539 mutt_buffer_free (&(*p)->spam);
3541 @@ -1394,6 +1401,14 @@ int mutt_save_confirm (const char *s, st
3546 + if (magic == M_NNTP)
3548 + mutt_error _("Can't save message to newsserver.");
3553 if (stat (s, st) != -1)
3556 diff -udprP mutt-1.5.16.orig/mx.c mutt-1.5.16/mx.c
3557 --- mutt-1.5.16.orig/mx.c 2007-04-03 20:41:14.000000000 +0300
3558 +++ mutt-1.5.16/mx.c 2007-06-15 17:12:26.000000000 +0300
3559 @@ -348,6 +348,22 @@ int mx_is_pop (const char *p)
3564 +int mx_is_nntp (const char *p)
3566 + url_scheme_t scheme;
3571 + scheme = url_check_scheme (p);
3572 + if (scheme == U_NNTP || scheme == U_NNTPS)
3579 int mx_get_magic (const char *path)
3582 @@ -365,6 +381,11 @@ int mx_get_magic (const char *path)
3584 #endif /* USE_POP */
3587 + if (mx_is_nntp (path))
3589 +#endif /* USE_NNTP */
3591 if (stat (path, &st) == -1)
3593 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
3594 @@ -704,6 +725,12 @@ CONTEXT *mx_open_mailbox (const char *pa
3596 #endif /* USE_POP */
3600 + rc = nntp_open_mailbox (ctx);
3602 +#endif /* USE_NNTP */
3607 @@ -796,6 +823,12 @@ static int sync_mailbox (CONTEXT *ctx, i
3608 rc = pop_sync_mailbox (ctx, index_hint);
3610 #endif /* USE_POP */
3614 + rc = nntp_sync_mailbox (ctx);
3616 +#endif /* USE_NNTP */
3620 @@ -822,6 +855,16 @@ int mx_close_mailbox (CONTEXT *ctx, int
3625 + if (ctx->magic == M_NNTP)
3629 + ret = nntp_close_mailbox (ctx);
3630 + mx_fastclose_mailbox (ctx);
3634 if (ctx->readonly || ctx->dontwrite)
3636 /* mailbox is readonly or we don't want to write */
3637 @@ -1359,6 +1402,11 @@ int mx_check_mailbox (CONTEXT *ctx, int
3639 return (pop_check_mailbox (ctx, index_hint));
3640 #endif /* USE_POP */
3644 + return (nntp_check_mailbox (ctx));
3645 +#endif /* USE_NNTP */
3649 @@ -1419,6 +1467,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx,
3651 #endif /* USE_POP */
3656 + if (nntp_fetch_message (msg, ctx, msgno) != 0)
3660 +#endif /* USE_NNTP */
3663 dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
3665 @@ -1500,6 +1557,9 @@ int mx_close_message (MESSAGE **msg)
3667 || (*msg)->magic == M_POP
3670 + || (*msg)->magic == M_NNTP
3674 r = safe_fclose (&(*msg)->fp);
3675 diff -udprP mutt-1.5.16.orig/mx.h mutt-1.5.16/mx.h
3676 --- mutt-1.5.16.orig/mx.h 2007-04-02 00:58:56.000000000 +0300
3677 +++ mutt-1.5.16/mx.h 2007-06-15 17:12:26.000000000 +0300
3678 @@ -40,6 +40,9 @@ enum
3687 WHERE short DefaultMagic INITVAL (M_MBOX);
3688 diff -udprP mutt-1.5.16.orig/newsrc.c mutt-1.5.16/newsrc.c
3689 --- mutt-1.5.16.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3690 +++ mutt-1.5.16/newsrc.c 2007-06-15 17:12:26.000000000 +0300
3693 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3694 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
3695 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
3697 + * This program is free software; you can redistribute it and/or modify
3698 + * it under the terms of the GNU General Public License as published by
3699 + * the Free Software Foundation; either version 2 of the License, or
3700 + * (at your option) any later version.
3702 + * This program is distributed in the hope that it will be useful,
3703 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3704 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3705 + * GNU General Public License for more details.
3707 + * You should have received a copy of the GNU General Public License
3708 + * along with this program; if not, write to the Free Software
3709 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3713 +# include "config.h"
3717 +#include "mutt_curses.h"
3721 +#include "mailbox.h"
3723 +#include "rfc822.h"
3724 +#include "rfc1524.h"
3725 +#include "rfc2047.h"
3727 +#include <unistd.h>
3728 +#include <string.h>
3730 +#include <stdlib.h>
3731 +#include <sys/stat.h>
3733 +void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
3740 + l = safe_calloc (1, sizeof (LIST));
3742 + s->tail->next = l;
3746 + l->data = (void *) d;
3749 +static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
3752 + char group[LONG_STRING];
3754 + char *p = line, *b, *h;
3764 + while (*p && (*p != ':' && *p != '!')) p++;
3767 + len = p + 1 - line;
3768 + if (len > sizeof (group))
3769 + len = sizeof (group);
3770 + strfcpy (group, line, len);
3771 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
3773 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3774 + data->group = (char *) data + sizeof (NNTP_DATA);
3775 + strcpy (data->group, group);
3776 + data->nserv = news;
3777 + data->deleted = 1;
3778 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3779 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3780 + hash_insert (news->newsgroups, data->group, data, 0);
3781 + nntp_add_to_list (news, data);
3784 + FREE ((void **) &data->entries);
3787 + data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
3791 + data->subscribed = 1;
3793 + data->subscribed = 0;
3800 + while (*p && *p != ',' && *p != '\n') p++;
3806 + if ((h = strchr(b, '-')))
3810 + data->entries[x].first = atoi(b);
3811 + data->entries[x].last = atoi(h);
3815 + data->entries[x].first = atoi(b);
3816 + data->entries[x].last = data->entries[x].first;
3819 + if (data->entries[x].last != 0)
3822 + if (x && !data->lastMessage)
3823 + data->lastMessage = data->entries[x-1].last;
3825 + mutt_newsgroup_stat (data);
3826 + dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
3831 +static int slurp_newsrc (NNTP_SERVER *news)
3837 + news->stat = stat (news->newsrc, &sb);
3838 + news->size = sb.st_size;
3839 + news->mtime = sb.st_mtime;
3841 + if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
3843 + /* hmm, should we use dotlock? */
3844 + if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
3850 + buf = safe_malloc (sb.st_size + 1);
3851 + while (sb.st_size && fgets (buf, sb.st_size + 1, fp))
3852 + nntp_parse_newsrc_line (news, buf);
3855 + mx_unlock_file (news->newsrc, fileno (fp), 0);
3860 +void nntp_cache_expand (char *dst, const char *src)
3862 + snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src);
3863 + mutt_expand_path (dst, _POSIX_PATH_MAX);
3866 +/* Loads $news_cache_dir/.index into memory, loads newsserver data
3867 + * and newsgroup cache names */
3868 +static int nntp_parse_cacheindex (NNTP_SERVER *news)
3871 + char buf[HUGE_STRING], *cp;
3872 + char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
3877 + /* check is server name defined or not */
3878 + if (!news || !news->conn || !news->conn->account.host)
3880 + unset_option (OPTNEWSCACHE);
3881 + if (!NewsCacheDir || !*NewsCacheDir)
3884 + strfcpy (dir, NewsCacheDir, sizeof (dir));
3885 + mutt_expand_path (dir, sizeof(dir));
3887 + if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
3889 + snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
3890 + if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
3893 + mutt_error _("Cache directory not created!");
3896 + mutt_clear_error();
3899 + set_option (OPTNEWSCACHE);
3901 + FREE (&news->cache);
3902 + snprintf (buf, sizeof(buf), "%s/.index", dir);
3903 + if (!(index = safe_fopen (buf, "a+")))
3906 + while (fgets (buf, sizeof(buf), index))
3908 + buf[strlen(buf) - 1] = 0; /* strip ending '\n' */
3909 + if (!mutt_strncmp (buf, "#: ", 3) &&
3910 + !mutt_strcasecmp (buf+3, news->conn->account.host))
3913 + while (fgets (buf, sizeof(buf), index))
3916 + while (*cp && *cp != ' ') cp++;
3917 + if (!*cp) continue;
3919 + if (!mutt_strcmp (buf, "#:"))
3921 + sscanf (cp + 1, "%s %d %d", file, &l, &m);
3922 + if (!mutt_strcmp (buf, "ALL"))
3924 + news->cache = safe_strdup (file);
3925 + news->newgroups_time = m;
3927 + else if (news->newsgroups)
3929 + if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
3931 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
3932 + data->group = (char *) data + sizeof (NNTP_DATA);
3933 + strcpy(data->group, buf);
3934 + data->nserv = news;
3935 + data->deleted = 1;
3936 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
3937 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
3938 + hash_insert (news->newsgroups, data->group, data, 0);
3939 + nntp_add_to_list (news, data);
3941 + data->cache = safe_strdup (file);
3943 + if (!data->firstMessage || data->lastMessage < m)
3945 + if (!data->firstMessage)
3946 + data->firstMessage = l;
3947 + if (data->lastMessage < m)
3948 + data->lastMessage = m;
3949 + data->lastCached = m;
3950 + if (t || !data->unread)
3951 + mutt_newsgroup_stat (data);
3959 +nntp_format_str (char *dest, size_t destlen, char op, const char *src,
3960 + const char *fmt, const char *ifstring, const char *elsestring,
3961 + unsigned long data, format_flag flags)
3963 + char fn[SHORT_STRING], tmp[SHORT_STRING];
3968 + strncpy (fn, NewsServer, sizeof(fn) - 1);
3969 + mutt_strlower (fn);
3970 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
3971 + snprintf (dest, destlen, tmp, fn);
3977 +/* nntp_parse_url: given an NNPT URL, return host, port,
3978 + * username, password and newsgroup will recognise. */
3979 +int nntp_parse_url (const char *server, ACCOUNT *acct,
3980 + char *group, size_t group_len)
3988 + acct->port = NNTP_PORT;
3989 + acct->type = M_ACCT_TYPE_NNTP;
3991 + c = safe_strdup (server);
3992 + url_parse_ciss (&url, c);
3994 + if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
3996 + if (url.scheme == U_NNTPS)
3998 + acct->flags |= M_ACCT_SSL;
3999 + acct->port = NNTP_SSL_PORT;
4004 + strfcpy (group, url.path, group_len);
4006 + ret = mutt_account_fromurl (acct, &url);
4013 +void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
4017 + url.path = safe_strdup (line);
4018 + mutt_account_tourl (acct, &url);
4019 + url_ciss_tostring (&url, line, len, 0);
4024 + * Automatically loads a newsrc into memory, if necessary.
4025 + * Checks the size/mtime of a newsrc file, if it doesn't match, load
4026 + * again. Hmm, if a system has broken mtimes, this might mean the file
4027 + * is reloaded every time, which we'd have to fix.
4029 + * a newsrc file is a line per newsgroup, with the newsgroup, then a
4030 + * ':' denoting subscribed or '!' denoting unsubscribed, then a
4031 + * comma separated list of article numbers and ranges.
4033 +NNTP_SERVER *mutt_select_newsserver (char *server)
4035 + char file[_POSIX_PATH_MAX];
4039 + NNTP_SERVER *serv;
4042 + if (!server || !*server)
4044 + mutt_error _("No newsserver defined!");
4048 + buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
4049 + if (url_check_scheme (server) == U_UNKNOWN)
4051 + strcpy (buf, "news://");
4052 + p = strchr (buf, '\0');
4054 + strcpy (p, server);
4056 + if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
4059 + mutt_error (_("%s is an invalid newsserver specification!"), server);
4064 + conn = mutt_conn_find (NULL, &acct);
4068 + mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), nntp_format_str, 0, 0);
4069 + mutt_expand_path (file, sizeof (file));
4071 + serv = (NNTP_SERVER *)conn->data;
4076 + /* externally modified? */
4077 + if (serv->stat != stat (file, &sb) || (!serv->stat &&
4078 + (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
4080 + for (list = serv->list; list; list = list->next)
4082 + NNTP_DATA *data = (NNTP_DATA *) list->data;
4086 + data->subscribed = 0;
4091 + slurp_newsrc (serv);
4092 + nntp_clear_cacheindex (serv);
4095 + if (serv->status == NNTP_BYE)
4096 + serv->status = NNTP_NONE;
4097 + nntp_check_newgroups (serv, 0);
4101 + /* New newsserver */
4102 + serv = safe_calloc (1, sizeof (NNTP_SERVER));
4103 + serv->conn = conn;
4104 + serv->newsrc = safe_strdup (file);
4105 + serv->newsgroups = hash_create (1009);
4106 + slurp_newsrc (serv); /* load .newsrc */
4107 + nntp_parse_cacheindex (serv); /* load .index */
4108 + if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
4109 + nntp_check_newgroups (serv, 1);
4110 + else if (nntp_get_active (serv) < 0)
4112 + hash_destroy (&serv->newsgroups, nntp_delete_data);
4113 + for (list = serv->list; list; list = list->next)
4114 + list->data = NULL;
4115 + mutt_free_list (&serv->list);
4116 + FREE (&serv->newsrc);
4117 + FREE (&serv->cache);
4121 + nntp_clear_cacheindex (serv);
4122 + conn->data = (void *)serv;
4128 + * full status flags are not supported by nntp, but we can fake some
4129 + * of them. This is how:
4130 + * Read = a read message number is in the .newsrc
4131 + * New = a message is new since we last read this newsgroup
4132 + * Old = anything else
4133 + * So, Read is marked as such in the newsrc, old is anything that is
4134 + * "skipped" in the newsrc, and new is anything not in the newsrc nor
4135 + * in the cache. By skipped, I mean before the last unread message
4137 +void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
4139 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
4143 + data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
4149 + dprint (3, (debugfile, "newsgroup %s not found\n", group));
4154 + for (x = 0; x < data->num; x++)
4156 + if ((article >= data->entries[x].first) &&
4157 + (article <= data->entries[x].last))
4159 + /* we cannot use mutt_set_flag() because mx_update_context()
4160 + didn't called yet */
4165 + /* If article was not cached yet, it is new! :) */
4166 + if (!data->cache || article > data->lastCached)
4168 + /* Old articles are articles which aren't read but an article after them
4169 + * has been cached */
4170 + if (option (OPTMARKOLD))
4174 +void mutt_newsgroup_stat (NNTP_DATA *data)
4177 + unsigned int first, last;
4180 + if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
4183 + data->unread = data->lastMessage - data->firstMessage + 1;
4184 + for (i = 0; i < data->num; i++)
4186 + first = data->entries[i].first;
4187 + if (first < data->firstMessage)
4188 + first = data->firstMessage;
4189 + last = data->entries[i].last;
4190 + if (last > data->lastMessage)
4191 + last = data->lastMessage;
4192 + if (first <= last)
4193 + data->unread -= last - first + 1;
4197 +static int puti (char *line, int num)
4201 + for (p = s; num; )
4203 + *p++ = '0' + num % 10;
4207 + *line++ = *--p, num++;
4212 +static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
4214 + char *line = *pline;
4215 + size_t len = *buflen - (*pline - *buf);
4218 + if (len < LONG_STRING * 10)
4223 + safe_realloc (buf, *buflen);
4224 + line = *buf + (*pline - line);
4226 + strcpy (line, data->group);
4227 + len -= strlen (line) + 1;
4228 + line += strlen (line);
4229 + *line++ = data->subscribed ? ':' : '!';
4233 + for (x = 0; x < data->num; x++)
4235 + if (len < LONG_STRING)
4241 + safe_realloc (buf, *buflen);
4242 + line = *buf + (*pline - line);
4251 + if (data->entries[x].first == data->entries[x].last)
4252 + snprintf (line, len, "%d%n", data->entries[x].first, &i);
4254 + snprintf (line, len, "%d-%d%n",
4255 + data->entries[x].first, data->entries[x].last, &i);
4259 + i = puti (line, data->entries[x].first);
4260 + line +=i; len -= i;
4261 + if (data->entries[x].first != data->entries[x].last)
4265 + i = puti (line, data->entries[x].last);
4266 + line +=i; len -= i;
4275 +void newsrc_gen_entries (CONTEXT *ctx)
4277 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
4279 + unsigned int last = 0, first = 1;
4280 + int save_sort = SORT_ORDER;
4282 + if (Sort != SORT_ORDER)
4285 + Sort = SORT_ORDER;
4286 + mutt_sort_headers (ctx, 0);
4291 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4296 + * Set up to fake initial sequence from 1 to the article before the
4297 + * first article in our list
4302 + for (x = 0; x < ctx->msgcount; x++)
4304 + if (series) /* search for first unread */
4307 + * We don't actually check sequential order, since we mark
4308 + * "missing" entries as read/deleted
4310 + last = ctx->hdrs[x]->article_num;
4311 + if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
4312 + !ctx->hdrs[x]->read)
4314 + if (data->num >= data->max)
4316 + data->max = data->max * 2;
4317 + safe_realloc (&data->entries,
4318 + data->max * sizeof (NEWSRC_ENTRY));
4320 + data->entries[data->num].first = first;
4321 + data->entries[data->num].last = last - 1;
4326 + else /* search for first read */
4328 + if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
4333 + last = ctx->hdrs[x]->article_num;
4336 + if (series && first <= data->lastLoaded)
4338 + if (data->num >= data->max)
4340 + data->max = data->max * 2;
4341 + safe_realloc (&data->entries,
4342 + data->max * sizeof (NEWSRC_ENTRY));
4344 + data->entries[data->num].first = first;
4345 + data->entries[data->num].last = data->lastLoaded;
4349 + if (save_sort != Sort)
4352 + mutt_sort_headers (ctx, 0);
4356 +static int mutt_update_list_file (char *filename, char *section,
4357 + char *key, char *line)
4361 + char buf[HUGE_STRING];
4362 + char tmpfile[_POSIX_PATH_MAX];
4364 + int ext = 0, done = 0, r = 0;
4366 + /* if file not exist, create it */
4367 + if ((ifp = safe_fopen (filename, "a")))
4369 + dprint (1, (debugfile, "Opening %s\n", filename));
4370 + if (!(ifp = safe_fopen (filename, "r")))
4372 + mutt_error (_("Unable to open %s for reading"), filename);
4375 + if (mx_lock_file (filename, fileno (ifp), 0, 0, 1))
4378 + mutt_error (_("Unable to lock %s"), filename);
4381 + snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename);
4382 + dprint (1, (debugfile, "Opening %s\n", tmpfile));
4383 + if (!(ofp = fopen (tmpfile, "w")))
4386 + mutt_error (_("Unable to open %s for writing"), tmpfile);
4392 + while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
4394 + r = fputs (buf, ofp);
4396 + while (*c && *c != '\n') c++;
4397 + c[0] = 0; /* strip EOL */
4398 + if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
4401 + if (r != EOF && !done)
4403 + snprintf (buf, sizeof(buf), "#: %s\n", section);
4404 + r = fputs (buf, ofp);
4409 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
4414 + while (*c && (*c != '\r') && (*c != '\n')) c++;
4416 + if (*c != '\\') ext = 0;
4418 + else if ((section && !strncmp (buf, "#: ", 3)))
4420 + if (!done && line)
4422 + fputs (line, ofp);
4423 + fputc ('\n', ofp);
4425 + r = fputs (buf, ofp);
4429 + else if (key && !strncmp (buf, key, strlen(key)) &&
4430 + (!*key || buf[strlen(key)] == ' '))
4434 + while (*c && (*c != '\r') && (*c != '\n')) c++;
4436 + if (*c == '\\') ext = 1;
4437 + if (!done && line)
4439 + r = fputs (line, ofp);
4441 + r = fputc ('\n', ofp);
4447 + r = fputs (buf, ofp);
4451 + while (r != EOF && fgets (buf, sizeof (buf), ifp))
4452 + r = fputs (buf, ofp);
4454 + /* If there wasn't a line to replace, put it on the end of the file */
4455 + if (r != EOF && !done && line)
4457 + fputs (line, ofp);
4458 + r = fputc ('\n', ofp);
4460 + mx_unlock_file (filename, fileno (ifp), 0);
4466 + mutt_error (_("Can't write %s"), tmpfile);
4469 + if (rename (tmpfile, filename) < 0)
4472 + mutt_error (_("Can't rename %s to %s"), tmpfile, filename);
4478 +int mutt_newsrc_update (NNTP_SERVER *news)
4488 + llen = len = 10 * LONG_STRING;
4489 + line = buf = safe_calloc (1, len);
4490 + /* we will generate full newsrc here */
4491 + for (tmp = news->list; tmp; tmp = tmp->next)
4493 + data = (NNTP_DATA *) tmp->data;
4494 + if (!data || !data->rc)
4496 + nntp_create_newsrc_line (data, &buf, &line, &llen);
4498 + dprint (2, (debugfile, "Added to newsrc: %s\n", line));
4499 + line += strlen (line);
4501 + /* newrc being fully rewritten */
4502 + if (news->newsrc &&
4503 + (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
4507 + stat (news->newsrc, &st);
4508 + news->size = st.st_size;
4509 + news->mtime = st.st_mtime;
4515 +static FILE *mutt_mkname (char *s)
4517 + char buf[_POSIX_PATH_MAX], *pc;
4521 + nntp_cache_expand (buf, s);
4522 + if ((fp = safe_fopen (buf, "w")))
4525 + nntp_cache_expand (buf, "cache-XXXXXX");
4526 + pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
4527 + if ((fd = mkstemp (buf)) == -1)
4529 + strcpy (s, pc); /* generated name */
4530 + return fdopen (fd, "w");
4533 +/* Updates info into .index file: ALL or about selected newsgroup */
4534 +static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
4536 + char buf[LONG_STRING], *key = "ALL";
4537 + char file[_POSIX_PATH_MAX];
4539 + if (!serv || !serv->conn || !serv->conn->account.host)
4542 + if (data && data->group)
4544 + key = data->group;
4545 + snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
4546 + data->firstMessage, data->lastLoaded);
4550 + strfcpy (file, serv->cache, sizeof (file));
4551 + snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
4553 + nntp_cache_expand (file, ".index");
4554 + return mutt_update_list_file (file, serv->conn->account.host, key, buf);
4557 +/* Remove cache files of unsubscribed newsgroups */
4558 +void nntp_clear_cacheindex (NNTP_SERVER *news)
4563 + if (option (OPTSAVEUNSUB) || !news)
4566 + for (tmp = news->list; tmp; tmp = tmp->next)
4568 + data = (NNTP_DATA *) tmp->data;
4569 + if (!data || data->subscribed || !data->cache)
4571 + nntp_delete_cache (data);
4572 + dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
4577 +int nntp_save_cache_index (NNTP_SERVER *news)
4579 + char buf[HUGE_STRING];
4580 + char file[_POSIX_PATH_MAX];
4585 + if (!news || !news->newsgroups)
4587 + if (!option (OPTNEWSCACHE))
4592 + nntp_cache_expand (file, news->cache);
4594 + f = safe_fopen (file, "w");
4598 + strfcpy (buf, news->conn->account.host, sizeof(buf));
4599 + f = mutt_mkname (buf);
4600 + news->cache = safe_strdup (buf);
4601 + nntp_cache_expand (file, buf);
4606 + for (l = news->list; l; l = l->next)
4608 + if ((d = (NNTP_DATA *)l->data) && !d->deleted)
4611 + snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
4612 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
4615 + snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
4616 + d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
4617 + if (fputs (buf, f) == EOF)
4627 + if (nntp_update_cacheindex (news, NULL))
4635 +int nntp_save_cache_group (CONTEXT *ctx)
4637 + char buf[HUGE_STRING], addr[STRING];
4638 + char file[_POSIX_PATH_MAX];
4642 + int i = 0, save = SORT_ORDER;
4645 + if (!option (OPTNEWSCACHE))
4647 + if (!ctx || !ctx->data || ctx->magic != M_NNTP)
4650 + if (((NNTP_DATA *)ctx->data)->cache)
4652 + nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
4654 + f = safe_fopen (file, "w");
4658 + snprintf (buf, sizeof(buf), "%s-%s",
4659 + ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
4660 + ((NNTP_DATA *)ctx->data)->group);
4661 + f = mutt_mkname (buf);
4662 + ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
4663 + nntp_cache_expand (file, buf);
4668 + if (Sort != SORT_ORDER)
4671 + Sort = SORT_ORDER;
4672 + mutt_sort_headers (ctx, 0);
4675 + /* Save only $nntp_context messages... */
4676 + ((NNTP_DATA *)ctx->data)->lastCached = 0;
4677 + if (NntpContext && ctx->msgcount > NntpContext)
4678 + i = ctx->msgcount - NntpContext;
4679 + for (; i < ctx->msgcount; i++)
4681 + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
4685 + rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
4686 + tm = gmtime (&h->date_sent);
4687 + snprintf (buf, sizeof(buf),
4688 + "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
4689 + h->article_num, h->env->subject, addr, tm->tm_mday,
4690 + Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
4691 + tm->tm_sec, h->env->message_id);
4693 + if (h->env->references)
4694 + mutt_write_references (h->env->references, f);
4695 + snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length,
4696 + (int) h->lines, NONULL(h->env->xref));
4697 + if (fputs (buf, f) == EOF)
4704 + prev = ctx->hdrs[i]->article_num;
4710 + mutt_sort_headers (ctx, 0);
4714 + if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
4715 + (NNTP_DATA *)ctx->data))
4720 + ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
4724 +void nntp_delete_cache (NNTP_DATA *data)
4726 + char buf[_POSIX_PATH_MAX];
4728 + if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv)
4731 + nntp_cache_expand (buf, data->cache);
4733 + FREE (&data->cache);
4734 + data->lastCached = 0;
4735 + nntp_cache_expand (buf, ".index");
4736 + mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
4739 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
4743 + if (!news || !news->newsgroups || !group || !*group)
4745 + if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4747 + data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
4748 + data->group = (char *) data + sizeof (NNTP_DATA);
4749 + strcpy (data->group, group);
4750 + data->nserv = news;
4751 + data->deleted = 1;
4752 + if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
4753 + news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
4754 + hash_insert (news->newsgroups, data->group, data, 0);
4755 + nntp_add_to_list (news, data);
4757 + if (!data->subscribed)
4759 + data->subscribed = 1;
4765 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
4769 + if (!news || !news->newsgroups || !group || !*group ||
4770 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4772 + if (data->subscribed)
4774 + data->subscribed = 0;
4775 + if (!option (OPTSAVEUNSUB))
4781 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
4785 + if (!news || !news->newsgroups || !group || !*group ||
4786 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4790 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4794 + data->entries[0].first = 1;
4796 + data->entries[0].last = data->lastMessage;
4797 + if (Context && Context->data == data)
4801 + for (x = 0; x < Context->msgcount; x++)
4802 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 1);
4807 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
4811 + if (!news || !news->newsgroups || !group || !*group ||
4812 + !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
4816 + data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
4820 + data->entries[0].first = 1;
4821 + data->entries[0].last = data->firstMessage - 1;
4822 + if (Context && Context->data == data)
4826 + data->unread = Context->msgcount;
4827 + for (x = 0; x < Context->msgcount; x++)
4828 + mutt_set_flag (Context, Context->hdrs[x], M_READ, 0);
4831 + data->unread = data->lastMessage - data->entries[0].last;
4835 +/* this routine gives the first newsgroup with new messages */
4836 +void nntp_buffy (char *s)
4840 + for (list = CurrentNewsSrv->list; list; list = list->next)
4842 + NNTP_DATA *data = (NNTP_DATA *) list->data;
4844 + if (data && data->subscribed && data->unread)
4846 + if (Context && Context->magic == M_NNTP &&
4847 + !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
4849 + unsigned int i, unread = 0;
4851 + for (i = 0; i < Context->msgcount; i++)
4852 + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4857 + strcpy (s, data->group);
4862 diff -udprP mutt-1.5.16.orig/nntp.c mutt-1.5.16/nntp.c
4863 --- mutt-1.5.16.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4864 +++ mutt-1.5.16/nntp.c 2007-06-15 17:12:26.000000000 +0300
4867 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4868 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4869 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
4871 + * This program is free software; you can redistribute it and/or modify
4872 + * it under the terms of the GNU General Public License as published by
4873 + * the Free Software Foundation; either version 2 of the License, or
4874 + * (at your option) any later version.
4876 + * This program is distributed in the hope that it will be useful,
4877 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4878 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4879 + * GNU General Public License for more details.
4881 + * You should have received a copy of the GNU General Public License
4882 + * along with this program; if not, write to the Free Software
4883 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4887 +# include "config.h"
4891 +#include "mutt_curses.h"
4895 +#include "rfc1524.h"
4896 +#include "rfc2047.h"
4897 +#include "mailbox.h"
4908 +#include <unistd.h>
4909 +#include <string.h>
4911 +#include <stdlib.h>
4913 +static unsigned int _checked = 0;
4916 +static void nntp_error (const char *where, const char *msg)
4918 + dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
4922 +static int nntp_auth (NNTP_SERVER *serv)
4924 + CONNECTION *conn = serv->conn;
4926 + unsigned char flags = conn->account.flags;
4928 + if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4929 + mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4931 + conn->account.flags = flags;
4935 + mutt_message _("Logging in...");
4937 + snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4938 + mutt_socket_write (conn, buf);
4939 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4941 + conn->account.flags = flags;
4946 + /* don't print the password unless we're at the ungodly debugging level */
4947 + if (debuglevel < M_SOCK_LOG_FULL)
4948 + dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
4950 + snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
4951 + mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL);
4952 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4954 + conn->account.flags = flags;
4958 + if (mutt_strncmp ("281", buf, 3))
4960 + conn->account.flags = flags;
4961 + mutt_error _("Login failed.");
4969 +static int nntp_connect_error (NNTP_SERVER *serv)
4971 + serv->status = NNTP_NONE;
4972 + mutt_socket_close (serv->conn);
4973 + mutt_error _("Server closed connection!");
4978 +static int nntp_connect_and_auth (NNTP_SERVER *serv)
4980 + CONNECTION *conn = serv->conn;
4984 + serv->status = NNTP_NONE;
4986 + if (mutt_socket_open (conn) < 0)
4989 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4990 + return nntp_connect_error (serv);
4992 + if (!mutt_strncmp ("200", buf, 3))
4993 + mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
4994 + else if (!mutt_strncmp ("201", buf, 3))
4995 + mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
4998 + mutt_socket_close (conn);
4999 + mutt_remove_trailing_ws (buf);
5000 + mutt_error ("%s", buf);
5007 + /* Tell INN to switch to mode reader if it isn't so. Ignore all
5008 + returned codes and messages. */
5009 + mutt_socket_write (conn, "MODE READER\r\n");
5010 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
5011 + return nntp_connect_error (serv);
5013 + mutt_socket_write (conn, "STAT\r\n");
5014 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
5015 + return nntp_connect_error (serv);
5017 + if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
5019 + serv->status = NNTP_OK;
5023 + rc = nntp_auth (serv);
5025 + return nntp_connect_error (serv);
5028 + mutt_socket_close (conn);
5029 + serv->status = NNTP_BYE;
5034 + mutt_socket_close (conn);
5035 + mutt_error _("Login failed.");
5039 + serv->status = NNTP_OK;
5043 +static int nntp_attempt_features (NNTP_SERVER *serv)
5045 + char buf[LONG_STRING];
5046 + CONNECTION *conn = serv->conn;
5048 + mutt_socket_write (conn, "XOVER\r\n");
5049 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
5050 + return nntp_connect_error (serv);
5051 + if (mutt_strncmp ("500", buf, 3))
5052 + serv->hasXOVER = 1;
5054 + mutt_socket_write (conn, "XPAT\r\n");
5055 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
5056 + return nntp_connect_error (serv);
5057 + if (mutt_strncmp ("500", buf, 3))
5058 + serv->hasXPAT = 1;
5060 + mutt_socket_write (conn, "LISTGROUP\r\n");
5061 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
5062 + return nntp_connect_error (serv);
5063 + if (mutt_strncmp ("500", buf, 3))
5064 + serv->hasLISTGROUP = 1;
5066 + mutt_socket_write (conn, "XGTITLE +\r\n");
5067 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
5068 + return nntp_connect_error (serv);
5069 + if (mutt_strncmp ("500", buf, 3))
5070 + serv->hasXGTITLE = 1;
5072 + if (!mutt_strncmp ("282", buf, 3))
5076 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
5077 + return nntp_connect_error (serv);
5078 + } while (!(buf[0] == '.' && buf[1] == '\0'));
5084 +static int nntp_open_connection (NNTP_SERVER *serv)
5086 + if (serv->status == NNTP_OK)
5088 + if (serv->status == NNTP_BYE)
5090 + if (nntp_connect_and_auth (serv) < 0)
5092 + if (nntp_attempt_features (serv) < 0)
5097 +static int nntp_reconnect (NNTP_SERVER *serv)
5099 + char buf[SHORT_STRING];
5101 + mutt_socket_close (serv->conn);
5105 + if (nntp_connect_and_auth (serv) == 0)
5108 + snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
5109 + serv->conn->account.host);
5110 + if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
5112 + serv->status = NNTP_BYE;
5118 +/* Send data from line[LONG_STRING] and receive answer to same line */
5119 +static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
5121 + char buf[LONG_STRING];
5124 + if (data->nserv->status == NNTP_BYE)
5131 + mutt_socket_write (data->nserv->conn, line);
5133 + else if (data->group)
5135 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
5136 + mutt_socket_write (data->nserv->conn, buf);
5140 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
5142 + if (nntp_reconnect (data->nserv) < 0)
5147 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
5148 + mutt_socket_write (data->nserv->conn, buf);
5149 + if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
5155 + else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
5159 + strfcpy (line, buf, linelen);
5164 + * This function calls funct(*line, *data) for each received line,
5165 + * funct(NULL, *data) if rewind(*data) needs, exits when fail or done.
5168 + * 1 - correct but not performed (may be, have to be continued),
5169 + * -1 - conection lost,
5170 + * -2 - invalid command or execution error,
5171 + * -3 - error in funct(*line, *data).
5173 +static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
5174 + int (*funct) (char *, void *), void *data, int tagged)
5176 + char buf[LONG_STRING];
5180 + size_t lenbuf = 0;
5185 + strfcpy (buf, query, sizeof (buf));
5186 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5188 + if (buf[0] == '5')
5190 + if (buf[0] != '2')
5195 + inbuf = safe_malloc (sizeof (buf));
5199 + chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
5205 + if (!lenbuf && buf[0] == '.')
5207 + if (buf[1] == '\0')
5212 + if (buf[1] == '.')
5216 + strfcpy (inbuf + lenbuf, p, sizeof (buf));
5218 + if (chunk >= sizeof (buf))
5220 + lenbuf += strlen (p);
5225 + if (msg && ReadInc && (line % ReadInc == 0)) {
5227 + mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
5229 + mutt_message ("%s %d", msg, line);
5232 + if (ret == 0 && funct (inbuf, data) < 0)
5237 + safe_realloc (&inbuf, lenbuf + sizeof (buf));
5240 + funct (NULL, data);
5246 +static int nntp_read_tempfile (char *line, void *file)
5248 + FILE *f = (FILE *)file;
5255 + if (fputc ('\n', f) == EOF)
5261 +static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
5263 + register char *p, *b;
5264 + register char *colon = NULL;
5269 + /* skip to next word */
5271 + while (*b && ((*b == ' ') || (*b == '\t'))) b++;
5274 + /* skip to end of word */
5275 + while (*p && (*p != ' ') && (*p != '\t'))
5290 + nntp_get_status (ctx, h, b, atoi(colon));
5291 + if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
5292 + h->article_num = atoi(colon);
5300 + * 1 if article not found
5301 + * -1 if read or write error on tempfile or socket
5303 +static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
5305 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5307 + char buf[LONG_STRING];
5308 + char tempfile[_POSIX_PATH_MAX];
5310 + HEADER *h = ctx->hdrs[ctx->msgcount];
5312 + mutt_mktemp (tempfile);
5313 + if (!(f = safe_fopen (tempfile, "w+")))
5317 + snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num);
5319 + snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
5321 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
5326 + dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
5329 + unlink (tempfile);
5330 + return (ret == -1 ? -1 : 1);
5333 + h->article_num = article_num;
5334 + h->env = mutt_read_rfc822_header (f, h, 0, 0);
5336 + unlink (tempfile);
5338 + if (h->env->xref != NULL)
5339 + nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
5340 + else if (h->article_num == 0 && msgid)
5342 + snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
5343 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
5344 + h->article_num = atoi (buf + 4);
5350 +static int parse_description (char *line, void *n)
5352 +#define news ((NNTP_SERVER *) n)
5353 + register char *d = line;
5358 + while (*d && *d != '\t' && *d != ' ') d++;
5361 + while (*d && (*d == '\t' || *d == ' ')) d++;
5362 + dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
5363 + if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
5364 + mutt_strcmp (d, data->desc))
5366 + FREE (&data->desc);
5367 + data->desc = safe_strdup (d);
5373 +static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
5377 + if (!option (OPTLOADDESC) || !data || !data->nserv)
5380 + /* Get newsgroup description, if we can */
5381 + if (data->nserv->hasXGTITLE)
5382 + snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
5384 + snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
5385 + if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
5388 + nntp_error ("nntp_get_desc()", buf);
5394 + * XOVER returns a tab separated list of:
5395 + * id|subject|from|date|Msgid|references|bytes|lines|xref
5397 + * This has to duplicate some of the functionality of
5398 + * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
5399 + * a limited number of headers which are "parsed" by placement in the list)
5401 +static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
5403 + NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
5407 + hdr->env = mutt_new_envelope();
5408 + hdr->env->newsgroups = safe_strdup (nntp_data->group);
5409 + hdr->content = mutt_new_body();
5410 + hdr->content->type = TYPETEXT;
5411 + hdr->content->subtype = safe_strdup ("plain");
5412 + hdr->content->encoding = ENC7BIT;
5413 + hdr->content->disposition = DISPINLINE;
5414 + hdr->content->length = -1;
5417 + for (x = 0; !done && x < 9; x++)
5419 + /* if from file, need to skip newline character */
5420 + while (*p && *p != '\n' && *p != '\t') p++;
5428 + hdr->article_num = atoi (b);
5429 + nntp_get_status (ctx, hdr, NULL, hdr->article_num);
5432 + hdr->env->subject = safe_strdup (b);
5433 + /* Now we need to do the things which would normally be done in
5434 + * mutt_read_rfc822_header() */
5435 + if (hdr->env->subject)
5437 + regmatch_t pmatch[1];
5439 + rfc2047_decode (&hdr->env->subject);
5441 + if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
5442 + hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
5444 + hdr->env->real_subj = hdr->env->subject;
5448 + rfc822_free_address (&hdr->env->from);
5449 + hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
5450 + rfc2047_decode_adrlist (hdr->env->from);
5453 + hdr->date_sent = mutt_parse_date (b, hdr);
5454 + hdr->received = hdr->date_sent;
5457 + FREE (&hdr->env->message_id);
5458 + hdr->env->message_id = safe_strdup (b);
5461 + mutt_free_list (&hdr->env->references);
5462 + hdr->env->references = mutt_parse_references (b, 0);
5465 + hdr->content->length = atoi (b);
5468 + hdr->lines = atoi (b);
5472 + FREE (&hdr->env->xref);
5473 + b = b + 6; /* skips the "Xref: " */
5474 + hdr->env->xref = safe_strdup (b);
5475 + nntp_parse_xref (ctx, nntp_data->group, b, hdr);
5487 + unsigned int base;
5488 + unsigned int first;
5489 + unsigned int last;
5490 + unsigned short *messages;
5494 +#define fc ((FETCH_CONTEXT *) c)
5495 +static int nntp_fetch_numbers (char *line, void *c)
5501 + num = atoi (line);
5502 + if (num < fc->base || num > fc->last)
5504 + fc->messages[num - fc->base] = 1;
5508 +static int add_xover_line (char *line, void *c)
5510 + unsigned int num, total;
5511 + CONTEXT *ctx = fc->ctx;
5512 + NNTP_DATA *data = (NNTP_DATA *)ctx->data;
5517 + if (ctx->msgcount >= ctx->hdrmax)
5518 + mx_alloc_memory (ctx);
5519 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5520 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
5522 + nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
5523 + num = ctx->hdrs[ctx->msgcount]->article_num;
5525 + if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
5528 + if (num > data->lastLoaded)
5529 + data->lastLoaded = num;
5530 + num = num - fc->first + 1;
5531 + total = fc->last - fc->first + 1;
5532 + if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0))
5533 + mutt_message ("%s %d/%d", fc->msg, num, total);
5536 + mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
5542 +static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
5543 + unsigned int last)
5545 + char buf[HUGE_STRING];
5546 + char *msg = _("Fetching message headers...");
5547 + NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
5551 + unsigned int current;
5555 + /* if empty group or nothing to do */
5556 + if (!last || first > last)
5559 + /* fetch list of articles */
5563 + fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
5564 + if (nntp_data->nserv->hasLISTGROUP)
5566 + mutt_message _("Fetching list of articles...");
5567 + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5568 + if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
5570 + mutt_error (_("LISTGROUP command failed: %s"), buf);
5572 + nntp_error ("nntp_fetch_headers()", buf);
5574 + FREE (&fc.messages);
5580 + for (num = 0; num < last - first + 1; num++)
5581 + fc.messages[num] = 1;
5584 + /* CACHE: must be loaded xover cache here */
5585 + num = nntp_data->lastCached - first + 1;
5586 + if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
5588 + nntp_cache_expand (buf, nntp_data->cache);
5589 + mutt_message _("Fetching headers from cache...");
5590 + if ((f = safe_fopen (buf, "r")))
5594 + /* counting number of lines */
5595 + while (fgets (buf, sizeof (buf), f) != NULL)
5598 + while (r > num && fgets (buf, sizeof (buf), f) != NULL)
5600 + oldmsgcount = ctx->msgcount;
5602 + fc.last = first + num - 1;
5604 + while (fgets (buf, sizeof (buf), f) != NULL)
5605 + add_xover_line (buf, &fc);
5607 + nntp_data->lastLoaded = fc.last;
5608 + first = fc.last + 1;
5609 + if (ctx->msgcount > oldmsgcount)
5610 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5613 + nntp_delete_cache (nntp_data);
5615 + num = last - first + 1;
5618 + FREE (&fc.messages);
5623 + * Without XOVER, we have to fetch each article header and parse
5624 + * it. With XOVER, we ask for all of them
5626 + mutt_message (msg);
5627 + if (nntp_data->nserv->hasXOVER)
5629 + oldmsgcount = ctx->msgcount;
5633 + snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last);
5634 + ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
5635 + if (ctx->msgcount > oldmsgcount)
5636 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
5639 + mutt_error (_("XOVER command failed: %s"), buf);
5641 + nntp_error ("nntp_fetch_headers()", buf);
5643 + FREE (&fc.messages);
5649 + for (current = first; current <= last; current++)
5653 + ret = current - first + 1;
5654 + mutt_message ("%s %d/%d", msg, ret, num);
5656 + if (!fc.messages[current - fc.base])
5659 + if (ctx->msgcount >= ctx->hdrmax)
5660 + mx_alloc_memory (ctx);
5661 + h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5662 + h->index = ctx->msgcount;
5664 + ret = nntp_read_header (ctx, NULL, current);
5665 + if (ret == 0) /* Got article. Fetch next header */
5667 + nntp_get_status (ctx, h, NULL, h->article_num);
5669 + mx_update_context (ctx, 1);
5672 + mutt_free_header (&h); /* skip it */
5675 + FREE (&fc.messages);
5679 + if (current > nntp_data->lastLoaded)
5680 + nntp_data->lastLoaded = current;
5682 + FREE (&fc.messages);
5683 + nntp_data->lastLoaded = last;
5684 + mutt_clear_error ();
5689 + * currently, nntp "mailbox" is "newsgroup"
5691 +int nntp_open_mailbox (CONTEXT *ctx)
5693 + NNTP_DATA *nntp_data;
5694 + NNTP_SERVER *serv;
5695 + char buf[HUGE_STRING];
5696 + char server[LONG_STRING];
5698 + unsigned int first;
5701 + if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
5703 + mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
5709 + nntp_expand_path (server, sizeof (server), &acct);
5710 + if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK)
5713 + CurrentNewsSrv = serv;
5715 + /* create NNTP-specific state struct if nof found in list */
5716 + if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
5718 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
5719 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
5720 + strcpy (nntp_data->group, buf);
5721 + hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
5722 + nntp_add_to_list (serv, nntp_data);
5724 + ctx->data = nntp_data;
5725 + ctx->mx_close = nntp_fastclose_mailbox;
5726 + nntp_data->nserv = serv;
5728 + mutt_message (_("Selecting %s..."), nntp_data->group);
5730 + if (!nntp_data->desc)
5732 + nntp_get_desc (nntp_data, nntp_data->group, NULL);
5733 + if (nntp_data->desc)
5734 + nntp_save_cache_index (serv);
5738 + if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
5741 + nntp_error ("nntp_open_mailbox()", buf);
5746 + if (mutt_strncmp ("211", buf, 3))
5748 + LIST *l = serv->list;
5750 + /* GROUP command failed */
5751 + if (!mutt_strncmp ("411", buf, 3))
5753 + mutt_error (_("Newsgroup %s not found on server %s"),
5754 + nntp_data->group, serv->conn->account.host);
5756 + /* CACHE: delete cache and line from .index */
5757 + nntp_delete_cache (nntp_data);
5758 + hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
5759 + while (l && l->data != (void *) nntp_data) l = l->next;
5769 + sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
5770 + &nntp_data->lastMessage, buf);
5772 + nntp_data->deleted = 0;
5774 + time (&serv->check_time);
5777 + * Check for max adding context. If it is greater than $nntp_context,
5778 + * strip off extra articles
5780 + first = nntp_data->firstMessage;
5781 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
5782 + first = nntp_data->lastMessage - NntpContext + 1;
5784 + nntp_data->lastLoaded = first - 1;
5785 + return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
5788 +int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
5790 + char buf[LONG_STRING];
5791 + char path[_POSIX_PATH_MAX];
5792 + NNTP_CACHE *cache;
5793 + char *m = _("Fetching message...");
5796 + /* see if we already have the message in our cache */
5797 + cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
5799 + /* if everything is fine, assign msg->fp and return */
5800 + if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
5801 + (msg->fp = fopen (cache->path, "r")))
5804 + /* clear the previous entry */
5805 + unlink (cache->path);
5806 + free (cache->path);
5810 + cache->index = ctx->hdrs[msgno]->index;
5811 + mutt_mktemp (path);
5812 + cache->path = safe_strdup (path);
5813 + if (!(msg->fp = safe_fopen (path, "w+")))
5815 + FREE (&cache->path);
5819 + if (ctx->hdrs[msgno]->article_num == 0)
5820 + snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
5821 + ctx->hdrs[msgno]->env->message_id);
5823 + snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
5824 + ctx->hdrs[msgno]->article_num);
5826 + ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
5827 + msg->fp, ctx->tagged);
5830 + mutt_error (_("Article %d not found on server"),
5831 + ctx->hdrs[msgno]->article_num);
5832 + dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
5839 + FREE (&cache->path);
5843 + mutt_free_envelope (&ctx->hdrs[msgno]->env);
5844 + ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
5845 + /* fix content length */
5846 + fseek(msg->fp, 0, SEEK_END);
5847 + ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
5848 + ctx->hdrs[msgno]->content->offset;
5850 + /* this is called in mutt before the open which fetches the message,
5851 + * which is probably wrong, but we just call it again here to handle
5852 + * the problem instead of fixing it.
5854 + mutt_parse_mime_message (ctx, ctx->hdrs[msgno]);
5856 + /* These would normally be updated in mx_update_context(), but the
5857 + * full headers aren't parsed with XOVER, so the information wasn't
5860 +#if defined(HAVE_PGP) || defined(HAVE_SMIME)
5861 + ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
5862 +#endif /* HAVE_PGP || HAVE_SMIME */
5864 + mutt_clear_error();
5871 +int nntp_post (const char *msg) {
5872 + char buf[LONG_STRING];
5875 + NNTP_DATA *nntp_data;
5877 + if (Context && Context->magic == M_NNTP)
5878 + nntp_data = (NNTP_DATA *)Context->data;
5881 + if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
5882 + !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
5884 + mutt_error (_("Can't post article. No connection to news server."));
5887 + nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
5890 + if (!(f = safe_fopen (msg, "r")))
5892 + mutt_error (_("Can't post article. Unable to open %s"), msg);
5896 + strfcpy (buf, "POST\r\n", sizeof (buf));
5897 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5899 + mutt_error (_("Can't post article. Connection to %s lost."),
5900 + nntp_data->nserv->conn->account.host);
5903 + if (buf[0] != '3')
5905 + mutt_error (_("Can't post article: %s"), buf);
5911 + while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
5913 + len = strlen (buf);
5914 + if (buf[len - 1] == '\n')
5916 + buf[len - 1] = '\r';
5921 + if (buf[1] == '.')
5922 + mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR);
5924 + mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR);
5928 + if (buf[strlen (buf) - 1] != '\n')
5929 + mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR);
5930 + mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR);
5931 + if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
5933 + mutt_error (_("Can't post article. Connection to %s lost."),
5934 + nntp_data->nserv->conn->account.host);
5937 + if (buf[0] != '2')
5939 + mutt_error (_("Can't post article: %s"), buf);
5946 +/* nntp_logout_all: close all open connections. */
5947 +void nntp_logout_all (void)
5949 + char buf[LONG_STRING];
5952 + conn = mutt_socket_head ();
5956 + CONNECTION *next = conn->next;
5958 + if (conn->account.type == M_ACCT_TYPE_NNTP)
5960 + mutt_message (_("Closing connection to %s..."), conn->account.host);
5961 + mutt_socket_write (conn, "QUIT\r\n");
5962 + mutt_socket_readln (buf, sizeof (buf), conn);
5963 + mutt_clear_error ();
5964 + mutt_socket_close (conn);
5965 + mutt_socket_free (conn);
5972 +static void nntp_free_acache (NNTP_DATA *data)
5976 + for (i = 0; i < NNTP_CACHE_LEN; i++)
5978 + if (data->acache[i].path)
5980 + unlink (data->acache[i].path);
5981 + FREE (&data->acache[i].path);
5986 +void nntp_delete_data (void *p)
5988 + NNTP_DATA *data = (NNTP_DATA *)p;
5992 + FREE (&data->entries);
5993 + FREE (&data->desc);
5994 + FREE (&data->cache);
5995 + nntp_free_acache (data);
5999 +int nntp_sync_mailbox (CONTEXT *ctx)
6001 + NNTP_DATA *data = ctx->data;
6003 + /* CACHE: update cache and .index files */
6004 + if ((option (OPTSAVEUNSUB) || data->subscribed))
6005 + nntp_save_cache_group (ctx);
6006 + nntp_free_acache (data);
6008 + data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
6012 +int nntp_fastclose_mailbox (CONTEXT *ctx)
6014 + NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
6018 + nntp_free_acache (data);
6019 + if (!data->nserv || !data->nserv->newsgroups || !data->group)
6021 + nntp_save_cache_index (data->nserv);
6022 + if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
6024 + nntp_delete_data (data);
6028 +/* commit changes and terminate connection */
6029 +int nntp_close_mailbox (CONTEXT *ctx)
6033 + mutt_message _("Quitting newsgroup...");
6036 + NNTP_DATA *data = (NNTP_DATA *) ctx->data;
6039 + if (data->nserv && data->nserv->conn && ctx->unread)
6041 + ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
6043 + mutt_newsgroup_catchup (data->nserv, data->group);
6048 + nntp_sync_mailbox (ctx);
6049 + if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
6051 + NNTP_SERVER *news;
6053 + news = ((NNTP_DATA *)ctx->data)->nserv;
6054 + newsrc_gen_entries (ctx);
6055 + ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
6056 + mutt_newsrc_update (news);
6058 + mutt_clear_error();
6062 +/* use the GROUP command to poll for new mail */
6063 +static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
6065 + char buf[LONG_STRING];
6068 + if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL))
6072 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
6075 + nntp_error ("nntp_check_mailbox()", buf);
6079 + if (mutt_strncmp ("211", buf, 3))
6082 + if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
6085 + nntp_error ("nntp_check_mailbox()", buf);
6090 + if (!mutt_strncmp ("211", buf, 3))
6095 + sscanf (buf + 4, "%d %d %d", &count, &first, &last);
6096 + nntp_data->firstMessage = first;
6097 + nntp_data->lastMessage = last;
6098 + if (ctx && last > nntp_data->lastLoaded)
6100 + nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
6101 + time (&nntp_data->nserv->check_time);
6104 + if (!last || (!nntp_data->rc && !nntp_data->lastCached))
6105 + nntp_data->unread = count;
6107 + mutt_newsgroup_stat (nntp_data);
6108 + /* active was renumbered? */
6109 + if (last < nntp_data->lastLoaded)
6111 + if (!nntp_data->max)
6113 + nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
6114 + nntp_data->max = 5;
6116 + nntp_data->lastCached = 0;
6117 + nntp_data->num = 1;
6118 + nntp_data->entries[0].first = 1;
6119 + nntp_data->entries[0].last = 0;
6123 + time (&nntp_data->nserv->check_time);
6127 +int nntp_check_mailbox (CONTEXT *ctx)
6129 + return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
6132 +static int add_group (char *buf, void *serv)
6134 +#define s ((NNTP_SERVER *) serv)
6135 + char group[LONG_STRING], mod, desc[HUGE_STRING];
6137 + NNTP_DATA *nntp_data;
6140 + _checked = n; /* _checked have N, where N = number of groups */
6141 + if (!buf) /* at EOF must be zerouth */
6148 + sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
6151 + if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
6154 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
6155 + nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
6156 + strcpy (nntp_data->group, group);
6157 + nntp_data->nserv = s;
6158 + if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
6159 + s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2);
6160 + hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0);
6161 + nntp_add_to_list (s, nntp_data);
6163 + nntp_data->deleted = 0;
6164 + nntp_data->firstMessage = first;
6165 + nntp_data->lastMessage = last;
6167 + nntp_data->allowed = 1;
6169 + nntp_data->allowed = 0;
6170 + if (nntp_data->desc)
6171 + FREE (&nntp_data->desc);
6173 + nntp_data->desc = safe_strdup (desc);
6174 + if (nntp_data->rc || nntp_data->lastCached)
6175 + mutt_newsgroup_stat (nntp_data);
6176 + else if (nntp_data->lastMessage &&
6177 + nntp_data->firstMessage <= nntp_data->lastMessage)
6178 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
6180 + nntp_data->unread = 0;
6186 +int nntp_check_newgroups (NNTP_SERVER *serv, int force)
6188 + char buf[LONG_STRING];
6189 + char msg[SHORT_STRING];
6190 + NNTP_DATA nntp_data;
6195 + unsigned int count = 0;
6196 + unsigned int total = 0;
6198 + if (!serv || !serv->newgroups_time)
6201 + if (nntp_open_connection (serv) < 0)
6204 + /* check subscribed groups for new news */
6205 + if (option (OPTSHOWNEWNEWS))
6207 + mutt_message _("Checking for new messages...");
6208 + for (l = serv->list; l; l = l->next)
6210 + serv->check_time = 0; /* really check! */
6211 + if (l->data && ((NNTP_DATA *) l->data)->subscribed)
6212 + _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
6218 + mutt_message _("Checking for new newsgroups...");
6219 + now = serv->newgroups_time;
6220 + time (&serv->newgroups_time);
6221 + t = gmtime (&now);
6222 + snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
6223 + (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
6225 + nntp_data.nserv = serv;
6226 + if (Context && Context->magic == M_NNTP)
6227 + nntp_data.group = ((NNTP_DATA *)Context->data)->group;
6229 + nntp_data.group = NULL;
6231 + if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
6232 + add_group, serv, 0) != 0)
6235 + nntp_error ("nntp_check_newgroups()", buf);
6240 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
6241 + mutt_message (msg);
6243 + emp.next = l->next;
6245 + emp.next = serv->list;
6250 + ((NNTP_DATA *) l->data)->new = 1;
6257 + nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
6259 + if (ReadInc && (count % ReadInc == 0))
6260 + mutt_message ("%s %d/%d", msg, count, total);
6263 + nntp_save_cache_index (serv);
6264 + mutt_clear_error ();
6268 +/* Load list of all newsgroups from cache ALL */
6269 +int nntp_get_cache_all (NNTP_SERVER *serv)
6271 + char buf[HUGE_STRING];
6274 + nntp_cache_expand (buf, serv->cache);
6275 + if ((f = safe_fopen (buf, "r")))
6279 + while (fgets (buf, sizeof(buf), f) != NULL)
6281 + if (ReadInc && (i % ReadInc == 0))
6282 + mutt_message (_("Loading list from cache... %d"), i);
6283 + add_group (buf, serv);
6286 + add_group (NULL, NULL);
6288 + mutt_clear_error ();
6293 + FREE (&serv->cache);
6298 +/* Load list of all newsgroups from active */
6299 +int nntp_get_active (NNTP_SERVER *serv)
6301 + char msg[SHORT_STRING];
6302 + NNTP_DATA nntp_data;
6305 + if (nntp_open_connection (serv) < 0)
6308 + snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
6309 + serv->conn->account.host);
6310 + mutt_message (msg);
6311 + time (&serv->newgroups_time);
6312 + nntp_data.nserv = serv;
6313 + nntp_data.group = NULL;
6315 + if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
6318 + nntp_error ("nntp_get_active()", "LIST\r\n");
6323 + strfcpy (msg, _("Loading descriptions..."), sizeof (msg));
6324 + mutt_message (msg);
6325 + nntp_get_desc (&nntp_data, "*", msg);
6327 + for (tmp = serv->list; tmp; tmp = tmp->next)
6329 + NNTP_DATA *data = (NNTP_DATA *)tmp->data;
6331 + if (data && data->deleted && !data->rc)
6333 + nntp_delete_cache (data);
6334 + hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
6338 + nntp_save_cache_index (serv);
6340 + mutt_clear_error ();
6345 + * returns -1 if error ocurred while retrieving header,
6346 + * number of articles which ones exist in context on success.
6348 +int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
6352 + /* if msgid is already in context, don't reload them */
6353 + if (hash_find (ctx->id_hash, msgid))
6355 + if (ctx->msgcount == ctx->hdrmax)
6356 + mx_alloc_memory (ctx);
6357 + ctx->hdrs[ctx->msgcount] = mutt_new_header ();
6358 + ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
6360 + mutt_message (_("Fetching %s from server..."), msgid);
6361 + ret = nntp_read_header (ctx, msgid, 0);
6362 + /* since nntp_read_header() may set read flag, we must reset it */
6363 + ctx->hdrs[ctx->msgcount]->read = 0;
6365 + mutt_free_header (&ctx->hdrs[ctx->msgcount]);
6369 + mx_update_context (ctx, 1);
6380 + unsigned int *child;
6383 +static int check_children (char *s, void *c)
6385 +#define cc ((CHILD_CONTEXT *) c)
6386 + unsigned int i, n;
6388 + if (!s || (n = atoi (s)) == 0)
6390 + for (i = 0; i < cc->ctx->msgcount; i++)
6391 + if (cc->ctx->hdrs[i]->article_num == n)
6393 + if (cc->num >= cc->max)
6394 + safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
6395 + cc->child[cc->num++] = n;
6401 +int nntp_check_children (CONTEXT *ctx, const char *msgid)
6403 + NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
6405 + int i, ret = 0, tmp = 0;
6408 + if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
6409 + !nntp_data->nserv->conn->account.host)
6411 + if (nntp_data->firstMessage > nntp_data->lastLoaded)
6413 + if (!nntp_data->nserv->hasXPAT)
6415 + mutt_error (_("Server %s does not support this operation!"),
6416 + nntp_data->nserv->conn->account.host);
6420 + snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
6421 + nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
6426 + cc.child = safe_malloc (sizeof (unsigned int) * 25);
6427 + if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
6432 + /* dont try to read the xover cache. check_children() already
6433 + * made sure that we dont have the article, so we need to visit
6434 + * the server. Reading the cache at this point is also bad
6435 + * because it would duplicate messages */
6436 + if (option (OPTNEWSCACHE))
6439 + unset_option (OPTNEWSCACHE);
6441 + for (i = 0; i < cc.num; i++)
6443 + if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
6445 + if (ctx->msgcount &&
6446 + ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
6447 + ctx->hdrs[ctx->msgcount - 1]->read = 0;
6450 + set_option (OPTNEWSCACHE);
6454 diff -udprP mutt-1.5.16.orig/nntp.h mutt-1.5.16/nntp.h
6455 --- mutt-1.5.16.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
6456 +++ mutt-1.5.16/nntp.h 2007-06-15 17:12:26.000000000 +0300
6459 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
6460 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
6461 + * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua>
6463 + * This program is free software; you can redistribute it and/or modify
6464 + * it under the terms of the GNU General Public License as published by
6465 + * the Free Software Foundation; either version 2 of the License, or
6466 + * (at your option) any later version.
6468 + * This program is distributed in the hope that it will be useful,
6469 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6470 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6471 + * GNU General Public License for more details.
6473 + * You should have received a copy of the GNU General Public License
6474 + * along with this program; if not, write to the Free Software
6475 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6481 +#include "mutt_socket.h"
6482 +#include "mailbox.h"
6486 +#define NNTP_PORT 119
6487 +#define NNTP_SSL_PORT 563
6489 +/* number of entries in the hash table */
6490 +#define NNTP_CACHE_LEN 10
6507 + unsigned int hasXPAT : 1;
6508 + unsigned int hasXGTITLE : 1;
6509 + unsigned int hasXOVER : 1;
6510 + unsigned int hasLISTGROUP : 1;
6511 + unsigned int status : 3;
6517 + time_t newgroups_time;
6518 + time_t check_time;
6520 + LIST *list; /* list of newsgroups */
6521 + LIST *tail; /* last entry of list */
6527 + unsigned int index;
6533 + NEWSRC_ENTRY *entries;
6534 + unsigned int num; /* number of used entries */
6535 + unsigned int max; /* number of allocated entries */
6536 + unsigned int unread;
6537 + unsigned int firstMessage;
6538 + unsigned int lastMessage;
6539 + unsigned int lastLoaded;
6540 + unsigned int lastCached;
6541 + unsigned int subscribed : 1;
6542 + unsigned int rc : 1;
6543 + unsigned int new : 1;
6544 + unsigned int allowed : 1;
6545 + unsigned int deleted : 1;
6549 + NNTP_SERVER *nserv;
6550 + NNTP_CACHE acache[NNTP_CACHE_LEN];
6553 +/* internal functions */
6554 +int nntp_get_active (NNTP_SERVER *);
6555 +int nntp_get_cache_all (NNTP_SERVER *);
6556 +int nntp_save_cache_index (NNTP_SERVER *);
6557 +int nntp_check_newgroups (NNTP_SERVER *, int);
6558 +int nntp_save_cache_group (CONTEXT *);
6559 +int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
6560 +void newsrc_gen_entries (CONTEXT *);
6561 +void nntp_get_status (CONTEXT *, HEADER *, char *, int);
6562 +void mutt_newsgroup_stat (NNTP_DATA *);
6563 +void nntp_delete_cache (NNTP_DATA *);
6564 +void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
6565 +void nntp_cache_expand (char *, const char *);
6566 +void nntp_delete_data (void *);
6568 +/* exposed interface */
6569 +NNTP_SERVER *mutt_select_newsserver (char *);
6570 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
6571 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
6572 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
6573 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
6574 +void nntp_clear_cacheindex (NNTP_SERVER *);
6575 +int mutt_newsrc_update (NNTP_SERVER *);
6576 +int nntp_open_mailbox (CONTEXT *);
6577 +int nntp_sync_mailbox (CONTEXT *);
6578 +int nntp_check_mailbox (CONTEXT *);
6579 +int nntp_close_mailbox (CONTEXT *);
6580 +int nntp_fastclose_mailbox (CONTEXT *);
6581 +int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
6582 +int nntp_post (const char *);
6583 +int nntp_check_msgid (CONTEXT *, const char *);
6584 +int nntp_check_children (CONTEXT *, const char *);
6585 +void nntp_buffy (char *);
6586 +void nntp_expand_path (char *, size_t, ACCOUNT *);
6587 +void nntp_logout_all ();
6588 +const char *nntp_format_str (char *, size_t, char, const char *, const char *,
6589 + const char *, const char *, unsigned long, format_flag);
6591 +NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
6593 +#endif /* _NNTP_H_ */
6594 diff -udprP mutt-1.5.16.orig/pager.c mutt-1.5.16/pager.c
6595 --- mutt-1.5.16.orig/pager.c 2007-04-16 02:56:26.000000000 +0300
6596 +++ mutt-1.5.16/pager.c 2007-06-15 17:12:26.000000000 +0300
6597 @@ -1055,6 +1055,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
6607 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
6608 int flags, ansi_attr *pa, int cnt,
6609 @@ -1490,6 +1495,16 @@ static struct mapping_t PagerHelpExtra[]
6614 +static struct mapping_t PagerNewsHelpExtra[] = {
6615 + { N_("Post"), OP_POST },
6616 + { N_("Followup"), OP_FOLLOWUP },
6617 + { N_("Del"), OP_DELETE },
6618 + { N_("Next"), OP_MAIN_NEXT_UNDELETED },
6625 /* This pager is actually not so simple as it once was. It now operates in
6626 @@ -1531,6 +1546,10 @@ mutt_pager (const char *banner, const ch
6627 int old_PagerIndexLines; /* some people want to resize it
6628 * while inside the pager... */
6631 + char *followup_to;
6634 if (!(flags & M_SHOWCOLOR))
6635 flags |= M_SHOWFLAT;
6637 @@ -1570,7 +1589,11 @@ mutt_pager (const char *banner, const ch
6638 if (IsHeader (extra))
6640 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
6641 - mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
6642 + mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
6644 + (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
6647 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
6650 @@ -2398,6 +2421,15 @@ search_next:
6652 CHECK_ACL(M_ACL_WRITE, "flag message");
6655 + if (Context->magic == M_NNTP)
6658 + mutt_error _("Can't change 'important' flag on NNTP server.");
6663 mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
6664 redraw = REDRAW_STATUS | REDRAW_INDEX;
6665 if (option (OPTRESOLVE))
6666 @@ -2431,6 +2463,60 @@ search_next:
6667 redraw = REDRAW_FULL;
6672 + CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
6674 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6675 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6676 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6678 + ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
6679 + redraw = REDRAW_FULL;
6682 + case OP_FORWARD_TO_GROUP:
6683 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6685 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6686 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6687 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6689 + if (IsMsgAttach (extra))
6690 + mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6691 + extra->idxlen, extra->bdy, SENDNEWS);
6693 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6694 + redraw = REDRAW_FULL;
6698 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6701 + if (IsMsgAttach (extra))
6702 + followup_to = extra->bdy->hdr->env->followup_to;
6704 + followup_to = extra->hdr->env->followup_to;
6706 + if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
6707 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6709 + if (extra->ctx && extra->ctx->magic == M_NNTP &&
6710 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
6711 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
6713 + if (IsMsgAttach (extra))
6714 + mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
6715 + extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
6717 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
6718 + extra->ctx, extra->hdr);
6719 + redraw = REDRAW_FULL;
6725 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
6727 @@ -2477,7 +2563,7 @@ search_next:
6729 if (IsMsgAttach (extra))
6730 mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
6731 - extra->idxlen, extra->bdy);
6732 + extra->idxlen, extra->bdy, 0);
6734 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
6735 redraw = REDRAW_FULL;
6736 diff -udprP mutt-1.5.16.orig/parse.c mutt-1.5.16/parse.c
6737 --- mutt-1.5.16.orig/parse.c 2007-04-02 00:58:56.000000000 +0300
6738 +++ mutt-1.5.16/parse.c 2007-06-15 17:12:26.000000000 +0300
6739 @@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
6743 -static LIST *mutt_parse_references (char *s, int in_reply_to)
6744 +LIST *mutt_parse_references (char *s, int in_reply_to)
6746 LIST *t, *lst = NULL;
6748 @@ -1068,6 +1068,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6749 e->from = rfc822_parse_adrlist (e->from, p);
6753 + else if (!mutt_strcasecmp (line+1, "ollowup-to"))
6755 + if (!e->followup_to)
6757 + mutt_remove_trailing_ws (p);
6758 + e->followup_to = safe_strdup (mutt_skip_whitespace (p));
6766 @@ -1152,6 +1163,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6772 + if (!mutt_strcasecmp (line + 1, "ewsgroups"))
6774 + FREE (&e->newsgroups);
6775 + mutt_remove_trailing_ws (p);
6776 + e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
6783 + /* field `Organization:' saves only for pager! */
6784 + if (!mutt_strcasecmp (line + 1, "rganization"))
6786 + if (!e->organization && mutt_strcasecmp (p, "unknown"))
6787 + e->organization = safe_strdup (p);
6792 if (!ascii_strcasecmp (line + 1, "eferences"))
6794 @@ -1260,6 +1292,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
6795 e->x_label = safe_strdup(p);
6799 + else if (!mutt_strcasecmp (line + 1, "-comment-to"))
6801 + if (!e->x_comment_to)
6802 + e->x_comment_to = safe_strdup (p);
6805 + else if (!mutt_strcasecmp (line + 1, "ref"))
6808 + e->xref = safe_strdup (p);
6815 diff -udprP mutt-1.5.16.orig/pattern.c mutt-1.5.16/pattern.c
6816 --- mutt-1.5.16.orig/pattern.c 2007-04-08 02:36:55.000000000 +0300
6817 +++ mutt-1.5.16/pattern.c 2007-06-15 17:12:26.000000000 +0300
6818 @@ -91,6 +91,9 @@ Flags[] =
6819 { 'U', M_UNREAD, 0, NULL },
6820 { 'v', M_COLLAPSED, 0, NULL },
6821 { 'V', M_CRYPT_VERIFIED, 0, NULL },
6823 + { 'w', M_NEWSGROUPS, 0, eat_regexp },
6825 { 'x', M_REFERENCE, 0, eat_regexp },
6826 { 'X', M_MIMEATTACH, 0, eat_range },
6827 { 'y', M_XLABEL, 0, eat_regexp },
6828 @@ -1214,6 +1217,10 @@ mutt_pattern_exec (struct pattern_t *pat
6830 case M_UNREFERENCED:
6831 return (pat->not ^ (h->thread && !h->thread->child));
6833 + case M_NEWSGROUPS:
6834 + return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
6837 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
6839 @@ -1282,6 +1289,7 @@ int mutt_pattern_func (int op, char *pro
6840 progress_t progress;
6842 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
6843 + if (prompt || op != M_LIMIT)
6844 if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
6847 diff -udprP mutt-1.5.16.orig/po/POTFILES.in mutt-1.5.16/po/POTFILES.in
6848 --- mutt-1.5.16.orig/po/POTFILES.in 2007-04-02 00:58:57.000000000 +0300
6849 +++ mutt-1.5.16/po/POTFILES.in 2007-06-15 17:12:26.000000000 +0300
6850 @@ -47,6 +47,8 @@ mutt_ssl_gnutls.c
6859 diff -udprP mutt-1.5.16.orig/postpone.c mutt-1.5.16/postpone.c
6860 --- mutt-1.5.16.orig/postpone.c 2007-04-02 00:58:57.000000000 +0300
6861 +++ mutt-1.5.16/postpone.c 2007-06-15 17:12:26.000000000 +0300
6862 @@ -126,15 +126,26 @@ int mutt_num_postponed (int force)
6864 if (LastModify < st.st_mtime)
6867 + int optnews = option (OPTNEWS);
6869 LastModify = st.st_mtime;
6871 if (access (Postponed, R_OK | F_OK) != 0)
6872 return (PostCount = 0);
6875 + unset_option (OPTNEWS);
6877 if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
6880 PostCount = ctx.msgcount;
6881 mx_fastclose_mailbox (&ctx);
6884 + set_option (OPTNEWS);
6889 diff -udprP mutt-1.5.16.orig/protos.h mutt-1.5.16/protos.h
6890 --- mutt-1.5.16.orig/protos.h 2007-04-16 02:56:26.000000000 +0300
6891 +++ mutt-1.5.16/protos.h 2007-06-15 17:12:26.000000000 +0300
6892 @@ -113,6 +113,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
6893 HASH *mutt_make_subj_hash (CONTEXT *);
6895 LIST *mutt_make_references(ENVELOPE *e);
6896 +LIST *mutt_parse_references (char *, int);
6898 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
6899 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
6900 @@ -256,6 +257,7 @@ void mutt_unblock_signals_system (int);
6901 void mutt_update_encoding (BODY *a);
6902 void mutt_version (void);
6903 void mutt_view_attachments (HEADER *);
6904 +void mutt_write_references (LIST *, FILE *);
6905 void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen, int display);
6906 void mutt_set_virtual (CONTEXT *);
6908 diff -udprP mutt-1.5.16.orig/recvattach.c mutt-1.5.16/recvattach.c
6909 --- mutt-1.5.16.orig/recvattach.c 2007-04-16 02:56:26.000000000 +0300
6910 +++ mutt-1.5.16/recvattach.c 2007-06-15 17:12:26.000000000 +0300
6911 @@ -1088,6 +1088,15 @@ void mutt_view_attachments (HEADER *hdr)
6916 + if (Context->magic == M_NNTP)
6919 + mutt_error _("Can't delete attachment from newsserver.");
6924 if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED)
6927 @@ -1179,10 +1188,33 @@ void mutt_view_attachments (HEADER *hdr)
6928 case OP_FORWARD_MESSAGE:
6930 mutt_attach_forward (fp, hdr, idx, idxlen,
6931 - menu->tagprefix ? NULL : idx[menu->current]->content);
6932 + menu->tagprefix ? NULL : idx[menu->current]->content, 0);
6933 menu->redraw = REDRAW_FULL;
6937 + case OP_FORWARD_TO_GROUP:
6939 + mutt_attach_forward (fp, hdr, idx, idxlen,
6940 + menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
6941 + menu->redraw = REDRAW_FULL;
6947 + if (!idx[menu->current]->content->hdr->env->followup_to ||
6948 + mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
6949 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
6951 + mutt_attach_reply (fp, hdr, idx, idxlen,
6952 + menu->tagprefix ? NULL : idx[menu->current]->content,
6953 + SENDNEWS|SENDREPLY);
6954 + menu->redraw = REDRAW_FULL;
6960 case OP_GROUP_REPLY:
6962 diff -udprP mutt-1.5.16.orig/recvcmd.c mutt-1.5.16/recvcmd.c
6963 --- mutt-1.5.16.orig/recvcmd.c 2007-04-02 00:58:57.000000000 +0300
6964 +++ mutt-1.5.16/recvcmd.c 2007-06-15 17:12:26.000000000 +0300
6965 @@ -377,7 +377,7 @@ static BODY ** copy_problematic_attachme
6966 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
6967 ATTACHPTR ** idx, short idxlen,
6970 + short nattach, int flags)
6973 short mime_fwd_all = 0;
6974 @@ -523,7 +523,7 @@ _("Can't decode all tagged attachments.
6977 /* now that we have the template, send it. */
6978 - ci_send_message (0, tmphdr, tmpbody, NULL, parent);
6979 + ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
6983 @@ -550,7 +550,7 @@ _("Can't decode all tagged attachments.
6986 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
6987 - ATTACHPTR ** idx, short idxlen, BODY * cur)
6988 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
6990 HEADER *curhdr = NULL;
6992 @@ -655,23 +655,23 @@ static void attach_forward_msgs (FILE *
6994 mutt_free_header (&tmphdr);
6996 - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
6997 + ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
7002 void mutt_attach_forward (FILE * fp, HEADER * hdr,
7003 - ATTACHPTR ** idx, short idxlen, BODY * cur)
7004 + ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
7009 if (check_all_msg (idx, idxlen, cur, 0) == 0)
7010 - attach_forward_msgs (fp, hdr, idx, idxlen, cur);
7011 + attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
7014 nattach = count_tagged (idx, idxlen);
7015 - attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach);
7016 + attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
7020 @@ -729,28 +729,40 @@ attach_reply_envelope_defaults (ENVELOPE
7026 + if ((flags & SENDNEWS))
7028 - if (mutt_fetch_recips (env, curenv, flags) == -1)
7030 + /* in case followup set Newsgroups: with Followup-To: if it present */
7031 + if (!env->newsgroups && curenv &&
7032 + mutt_strcasecmp (curenv->followup_to, "poster"))
7033 + env->newsgroups = safe_strdup (curenv->followup_to);
7038 - for (i = 0; i < idxlen; i++)
7041 - if (idx[i]->content->tagged
7042 - && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
7043 + if (mutt_fetch_recips (env, curenv, flags) == -1)
7048 + for (i = 0; i < idxlen; i++)
7050 + if (idx[i]->content->tagged
7051 + && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
7056 + if ((flags & SENDLISTREPLY) && !env->to)
7058 + mutt_error _("No mailing lists found!");
7062 + mutt_fix_reply_recipients (env);
7065 - if ((flags & SENDLISTREPLY) && !env->to)
7067 - mutt_error _("No mailing lists found!");
7071 - mutt_fix_reply_recipients (env);
7072 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
7075 @@ -811,6 +823,13 @@ void mutt_attach_reply (FILE * fp, HEADE
7076 char prefix[SHORT_STRING];
7080 + if (flags & SENDNEWS)
7081 + set_option (OPTNEWSSEND);
7083 + unset_option (OPTNEWSSEND);
7086 if (check_all_msg (idx, idxlen, cur, 0) == -1)
7088 nattach = count_tagged (idx, idxlen);
7089 diff -udprP mutt-1.5.16.orig/rfc1524.c mutt-1.5.16/rfc1524.c
7090 --- mutt-1.5.16.orig/rfc1524.c 2007-04-02 00:58:58.000000000 +0300
7091 +++ mutt-1.5.16/rfc1524.c 2007-06-15 17:12:26.000000000 +0300
7092 @@ -569,13 +569,13 @@ int rfc1524_expand_filename (char *namet
7096 -int mutt_rename_file (char *oldfile, char *newfile)
7097 +int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
7101 if (access (oldfile, F_OK) != 0)
7103 - if (access (newfile, F_OK) == 0)
7104 + if (!overwrite && access (newfile, F_OK) == 0)
7106 if ((ofp = fopen (oldfile,"r")) == NULL)
7108 @@ -590,3 +590,8 @@ int mutt_rename_file (char *oldfile, cha
7109 mutt_unlink (oldfile);
7113 +int mutt_rename_file (char *oldfile, char *newfile)
7115 + return _mutt_rename_file (oldfile, newfile, 0);
7117 diff -udprP mutt-1.5.16.orig/rfc1524.h mutt-1.5.16/rfc1524.h
7118 --- mutt-1.5.16.orig/rfc1524.h 2007-04-02 00:58:58.000000000 +0300
7119 +++ mutt-1.5.16/rfc1524.h 2007-06-15 17:12:26.000000000 +0300
7120 @@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char
7121 int rfc1524_expand_filename (char *, char *, char *, size_t);
7122 int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int);
7123 int mutt_rename_file (char *, char *);
7124 +int _mutt_rename_file (char *, char *, int);
7126 #endif /* _RFC1524_H */
7127 diff -udprP mutt-1.5.16.orig/send.c mutt-1.5.16/send.c
7128 --- mutt-1.5.16.orig/send.c 2007-04-10 07:34:53.000000000 +0300
7129 +++ mutt-1.5.16/send.c 2007-06-15 17:12:26.000000000 +0300
7131 #include <sys/types.h>
7139 #include "remailer.h"
7141 @@ -214,17 +218,51 @@ static int edit_address (ADDRESS **a, /*
7145 -static int edit_envelope (ENVELOPE *en)
7146 +static int edit_envelope (ENVELOPE *en, int flags)
7148 char buf[HUGE_STRING];
7149 LIST *uh = UserHeader;
7151 - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
7153 - if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
7155 - if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
7158 + if (option (OPTNEWSSEND))
7160 + if (en->newsgroups)
7161 + strfcpy (buf, en->newsgroups, sizeof (buf));
7164 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
7166 + FREE (&en->newsgroups);
7167 + en->newsgroups = safe_strdup (buf);
7169 + if (en->followup_to)
7170 + strfcpy (buf, en->followup_to, sizeof (buf));
7173 + if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
7175 + FREE (&en->followup_to);
7176 + en->followup_to = safe_strdup (buf);
7178 + if (en->x_comment_to)
7179 + strfcpy (buf, en->x_comment_to, sizeof (buf));
7182 + if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
7184 + FREE (&en->x_comment_to);
7185 + en->x_comment_to = safe_strdup (buf);
7190 + if (edit_address (&en->to, "To: ") == -1 || en->to == NULL)
7192 + if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1)
7194 + if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1)
7200 @@ -260,6 +298,14 @@ static int edit_envelope (ENVELOPE *en)
7205 +char *nntp_get_header (const char *s)
7208 + return safe_strdup (s);
7212 static void process_user_recips (ENVELOPE *env)
7214 LIST *uh = UserHeader;
7215 @@ -272,6 +318,14 @@ static void process_user_recips (ENVELOP
7216 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
7217 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
7218 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
7220 + else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
7221 + env->newsgroups = nntp_get_header (uh->data + 11);
7222 + else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
7223 + env->followup_to = nntp_get_header (uh->data + 12);
7224 + else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
7225 + env->x_comment_to = nntp_get_header (uh->data + 13);
7230 @@ -302,6 +356,12 @@ static void process_user_header (ENVELOP
7231 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
7232 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
7233 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
7235 + ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
7236 + ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
7237 + ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
7239 + ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
7240 ascii_strncasecmp ("subject:", uh->data, 8) != 0)
7243 @@ -645,6 +705,10 @@ void mutt_add_to_reference_headers (ENVE
7248 + if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
7249 + env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
7254 @@ -701,6 +765,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
7256 if (flags & SENDREPLY)
7259 + if ((flags & SENDNEWS))
7261 + /* in case followup set Newsgroups: with Followup-To: if it present */
7262 + if (!env->newsgroups && curenv &&
7263 + mutt_strcasecmp (curenv->followup_to, "poster"))
7264 + env->newsgroups = safe_strdup (curenv->followup_to);
7271 @@ -847,7 +921,18 @@ void mutt_set_followup_to (ENVELOPE *e)
7272 * it hasn't already been set
7275 - if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
7276 + if (!option (OPTFOLLOWUPTO))
7279 + if (option (OPTNEWSSEND))
7281 + if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
7282 + e->followup_to = safe_strdup (e->newsgroups);
7287 + if (!e->mail_followup_to)
7289 if (mutt_is_list_cc (0, e->to, e->cc))
7291 @@ -1008,6 +1093,9 @@ static int send_message (HEADER *msg)
7296 + if (!option (OPTNEWSSEND))
7297 +#endif /* USE_NNTP */
7299 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
7300 msg->env->bcc, tempfile,
7301 @@ -1100,6 +1188,13 @@ ci_send_message (int flags, /* send mod
7306 + if (flags & SENDNEWS)
7307 + set_option (OPTNEWSSEND);
7309 + unset_option (OPTNEWSSEND);
7312 if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
7313 mutt_num_postponed (1))
7315 @@ -1130,6 +1225,22 @@ ci_send_message (int flags, /* send mod
7317 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
7321 + * If postponed message is a news article, it have
7322 + * a "Newsgroups:" header line, then set appropriate flag.
7324 + if (msg->env->newsgroups)
7326 + flags |= SENDNEWS;
7327 + set_option (OPTNEWSSEND);
7331 + flags &= ~SENDNEWS;
7332 + unset_option (OPTNEWSSEND);
7337 if (flags & (SENDPOSTPONED|SENDRESEND))
7338 @@ -1237,11 +1348,16 @@ ci_send_message (int flags, /* send mod
7339 if (flags & SENDREPLY)
7340 mutt_fix_reply_recipients (msg->env);
7343 + if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
7344 + msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
7347 if (! (flags & SENDMAILX) &&
7348 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
7349 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
7351 - if (edit_envelope (msg->env) == -1)
7352 + if (edit_envelope (msg->env, flags) == -1)
7356 @@ -1495,6 +1611,11 @@ main_loop:
7361 + if (flags & SENDNEWS)
7362 + mutt_message _("Article not posted.");
7365 mutt_message _("Mail not sent.");
7368 @@ -1527,6 +1648,9 @@ main_loop:
7373 + if (!(flags & SENDNEWS))
7375 if (!msg->env->to && !msg->env->cc && !msg->env->bcc)
7377 if (! (flags & SENDBATCH))
7378 @@ -1559,6 +1683,19 @@ main_loop:
7379 mutt_error _("No subject specified.");
7383 + if ((flags & SENDNEWS) && !msg->env->subject)
7385 + mutt_error _("No subject specified.");
7389 + if ((flags & SENDNEWS) && !msg->env->newsgroups)
7391 + mutt_error _("No newsgroup specified.");
7396 if (msg->content->next)
7397 msg->content = mutt_make_multipart (msg->content);
7398 @@ -1764,7 +1901,12 @@ full_fcc:
7401 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
7402 - mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
7403 + mutt_message (i != 0 ? _("Sending in background.") :
7405 + (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
7410 if (WithCrypto && (msg->security & ENCRYPT))
7412 diff -udprP mutt-1.5.16.orig/sendlib.c mutt-1.5.16/sendlib.c
7413 --- mutt-1.5.16.orig/sendlib.c 2007-06-10 01:12:38.000000000 +0300
7414 +++ mutt-1.5.16/sendlib.c 2007-06-15 17:12:26.000000000 +0300
7416 #include <sys/wait.h>
7423 #ifdef HAVE_SYSEXITS_H
7424 #include <sysexits.h>
7425 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
7426 @@ -1525,7 +1529,7 @@ void mutt_write_address_list (ADDRESS *a
7427 /* need to write the list in reverse because they are stored in reverse order
7428 * when parsed to speed up threading
7430 -static void write_references (LIST *r, FILE *f)
7431 +void mutt_write_references (LIST *r, FILE *f)
7434 int refcnt = 0, refmax = 0;
7435 @@ -1750,6 +1754,9 @@ int mutt_write_rfc822_header (FILE *fp,
7436 LIST *tmp = env->userhdrs;
7437 int has_agent = 0; /* user defined user-agent header field exists */
7440 + if (!option (OPTNEWSSEND))
7442 if (mode == 0 && !privacy)
7443 fputs (mutt_make_date (buffer, sizeof(buffer)), fp);
7445 @@ -1776,6 +1783,9 @@ int mutt_write_rfc822_header (FILE *fp,
7446 mutt_write_address_list (env->to, fp, 4, 0);
7450 + if (!option (OPTNEWSSEND))
7452 fputs ("To: \n", fp);
7455 @@ -1784,6 +1794,9 @@ int mutt_write_rfc822_header (FILE *fp,
7456 mutt_write_address_list (env->cc, fp, 4, 0);
7460 + if (!option (OPTNEWSSEND))
7462 fputs ("Cc: \n", fp);
7465 @@ -1795,8 +1808,28 @@ int mutt_write_rfc822_header (FILE *fp,
7470 + if (!option (OPTNEWSSEND))
7472 fputs ("Bcc: \n", fp);
7475 + if (env->newsgroups)
7476 + fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
7477 + else if (mode == 1 && option (OPTNEWSSEND))
7478 + fputs ("Newsgroups: \n", fp);
7480 + if (env->followup_to)
7481 + fprintf (fp, "Followup-To: %s\n", env->followup_to);
7482 + else if (mode == 1 && option (OPTNEWSSEND))
7483 + fputs ("Followup-To: \n", fp);
7485 + if (env->x_comment_to)
7486 + fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
7487 + else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
7488 + fputs ("X-Comment-To: \n", fp);
7492 mutt_write_one_header (fp, "Subject", env->subject, NULL, 0);
7494 @@ -1815,6 +1848,9 @@ int mutt_write_rfc822_header (FILE *fp,
7495 fputs ("Reply-To: \n", fp);
7497 if (env->mail_followup_to)
7499 + if (!option (OPTNEWSSEND))
7502 fputs ("Mail-Followup-To: ", fp);
7503 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
7504 @@ -1825,7 +1861,7 @@ int mutt_write_rfc822_header (FILE *fp,
7505 if (env->references)
7507 fputs ("References:", fp);
7508 - write_references (env->references, fp);
7509 + mutt_write_references (env->references, fp);
7513 @@ -1837,7 +1873,7 @@ int mutt_write_rfc822_header (FILE *fp,
7514 if (env->in_reply_to)
7516 fputs ("In-Reply-To:", fp);
7517 - write_references (env->in_reply_to, fp);
7518 + mutt_write_references (env->in_reply_to, fp);
7522 @@ -2153,11 +2189,30 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7523 const char *msg, /* file containing message */
7524 int eightbit) /* message contains 8bit chars */
7526 - char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
7527 + char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
7529 size_t argslen = 0, argsmax = 0;
7533 + if (option (OPTNEWSSEND))
7535 + char cmd[LONG_STRING];
7537 + mutt_FormatString (cmd, sizeof (cmd), 0, NONULL (Inews), nntp_format_str, 0, 0);
7540 + i = nntp_post (msg);
7545 + s = safe_strdup (cmd);
7549 + s = safe_strdup (Sendmail);
7553 while ((ps = strtok (ps, " ")))
7554 @@ -2181,6 +2236,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7559 + if (!option (OPTNEWSSEND))
7562 if (eightbit && option (OPTUSE8BITMIME))
7563 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
7565 @@ -2212,6 +2271,9 @@ mutt_invoke_sendmail (ADDRESS *from, /*
7566 args = add_args (args, &argslen, &argsmax, to);
7567 args = add_args (args, &argslen, &argsmax, cc);
7568 args = add_args (args, &argslen, &argsmax, bcc);
7573 if (argslen == argsmax)
7574 safe_realloc (&args, sizeof (char *) * (++argsmax));
7575 @@ -2344,6 +2406,9 @@ void mutt_prepare_envelope (ENVELOPE *en
7576 rfc2047_encode_adrlist (env->reply_to, "Reply-To");
7580 + if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
7583 rfc2047_encode_string (&env->subject);
7585 @@ -2449,6 +2514,10 @@ int mutt_bounce_message (FILE *fp, HEADE
7587 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
7590 + unset_option (OPTNEWSSEND);
7593 ret = _mutt_bounce_message (fp, h, to, resent_from, from);
7595 rfc822_free_address (&from);
7596 diff -udprP mutt-1.5.16.orig/sort.c mutt-1.5.16/sort.c
7597 --- mutt-1.5.16.orig/sort.c 2007-06-06 19:02:56.000000000 +0300
7598 +++ mutt-1.5.16/sort.c 2007-06-15 17:12:26.000000000 +0300
7599 @@ -151,6 +151,15 @@ int compare_order (const void *a, const
7600 HEADER **ha = (HEADER **) a;
7601 HEADER **hb = (HEADER **) b;
7604 + if ((*ha)->article_num && (*hb)->article_num)
7606 + int result = (*ha)->article_num - (*hb)->article_num;
7607 + AUXSORT(result,a,b);
7608 + return (SORTCODE (result));
7612 /* no need to auxsort because you will never have equality here */
7613 return (SORTCODE ((*ha)->index - (*hb)->index));
7615 diff -udprP mutt-1.5.16.orig/url.c mutt-1.5.16/url.c
7616 --- mutt-1.5.16.orig/url.c 2007-04-11 02:15:42.000000000 +0300
7617 +++ mutt-1.5.16/url.c 2007-06-15 17:12:26.000000000 +0300
7618 @@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] =
7619 { "imaps", U_IMAPS },
7622 + { "news", U_NNTP },
7623 + { "newss", U_NNTPS },
7624 { "mailto", U_MAILTO },
7626 { "smtps", U_SMTPS },
7627 diff -udprP mutt-1.5.16.orig/url.h mutt-1.5.16/url.h
7628 --- mutt-1.5.16.orig/url.h 2007-04-11 02:16:09.000000000 +0300
7629 +++ mutt-1.5.16/url.h 2007-06-15 17:12:26.000000000 +0300
7630 @@ -8,6 +8,8 @@ typedef enum url_scheme