1 WARNING: Run the following script before configure:
9 Vsevolod Volkov <vvv@mutt.org.ua>
12 diff -udprP mutt-1.10.0.orig/ChangeLog.nntp mutt-1.10.0/ChangeLog.nntp
13 --- mutt-1.10.0.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300
14 +++ mutt-1.10.0/ChangeLog.nntp 2018-06-16 17:38:41.196958026 +0300
16 +* Sat Jun 16 2018 Vsevolod Volkov <vvv@mutt.org.ua>
19 +* Thu Apr 19 2018 Vsevolod Volkov <vvv@mutt.org.ua>
22 +* Sat Sep 9 2017 Vsevolod Volkov <vvv@mutt.org.ua>
25 +* Sun Feb 26 2017 Vsevolod Volkov <vvv@mutt.org.ua>
28 +* Sun Dec 18 2016 Vsevolod Volkov <vvv@mutt.org.ua>
31 +* Sun Oct 9 2016 Vsevolod Volkov <vvv@mutt.org.ua>
34 +* Wed Aug 31 2016 Vsevolod Volkov <vvv@mutt.org.ua>
35 +- newsgroups aren't marked as new on first load
37 +* Wed Aug 24 2016 Vsevolod Volkov <vvv@mutt.org.ua>
39 +- fixed new groups marking
40 +- fixed unread messages counter update
42 +* Sat Aug 6 2016 Vsevolod Volkov <vvv@mutt.org.ua>
45 +* Sat Aug 6 2016 Vsevolod Volkov <vvv@mutt.org.ua>
48 +* Wed Apr 6 2016 Vsevolod Volkov <vvv@mutt.org.ua>
50 +- %R changed to %x in format strings
52 +* Wed Nov 25 2015 Vsevolod Volkov <vvv@mutt.org.ua>
54 +- fixed SIGSEGV when reading hcache in some cases
56 +* Tue Nov 10 2015 Vsevolod Volkov <vvv@mutt.org.ua>
57 +- fixed error compiling with nntp and without imap or pop3
58 +- fixed error loading articles after <change-newsgroup> and <quit>
60 +* Wed Sep 2 2015 Vsevolod Volkov <vvv@mutt.org.ua>
62 +- new option nntp_listgroup
63 +- use range in LISTGROUP command if possible
65 +* Thu Mar 13 2014 Vsevolod Volkov <vvv@mutt.org.ua>
68 +* Tue Oct 29 2013 Vsevolod Volkov <vvv@mutt.org.ua>
69 +- minor bug fixed while removing new articles
71 +* Fri Oct 18 2013 Vsevolod Volkov <vvv@mutt.org.ua>
74 +* Tue Nov 27 2012 Vsevolod Volkov <vvv@mutt.org.ua>
75 +- SASL authentication
76 +- new option nntp_authenticators
78 +* Fri Nov 16 2012 Vsevolod Volkov <vvv@mutt.org.ua>
79 +- support of NNTP commands: CAPABILITIES, STARTTLS, LIST NEWSGROUPS,
80 + LIST OVERVIEW.FMT, OVER, DATE
81 +- added bcache support
82 +- newss URI scheme renamed to snews
83 +- removed option nntp_reconnect
85 +* Sun Sep 16 2012 Vsevolod Volkov <vvv@mutt.org.ua>
86 +- internal header caching replaced with hcache
87 +- new option newsgroups_charset
89 +* Wed Sep 16 2010 Vsevolod Volkov <vvv@mutt.org.ua>
92 +* Thu Aug 13 2009 Vsevolod Volkov <vvv@mutt.org.ua>
93 +- fixed writting references in nntp_save_cache_group()
95 +* Tue Jun 15 2009 Vsevolod Volkov <vvv@mutt.org.ua>
98 +* Tue Mar 20 2009 Vsevolod Volkov <vvv@mutt.org.ua>
99 +- save Date: header of recorded outgoing articles
101 +* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua>
104 +* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua>
106 +- fixed SIGSEGV when followup or forward to newsgroup
108 +* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua>
111 +* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua>
112 +- fixed arguments of nntp_format_str()
114 +* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua>
115 +- fixed error selecting news group
117 +* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua>
120 +* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua>
121 +- fixed posting error if $smtp_url is set
122 +- added support of print-style sequence %R (x-comment-to)
124 +* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua>
126 +- nntp://... url changed to news://...
127 +- added indicator of fetching descriptions progress
129 +* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua>
132 +* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua>
135 +* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua>
137 +- fixed reading empty .newsrc
139 +* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua>
142 +* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
145 +* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
148 +* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua>
151 +* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua>
153 +- function mutt_update_list_file() moved to newsrc.c and changed algorithm
155 +* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua>
156 +- fixed error in nntp_logout_all()
158 +* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
159 +- fixed debug output in mutt_newsrc_update()
160 +- added optional support of LISTGROUP command
161 +- fixed typo in nntp_parse_xref()
163 +* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua>
166 +* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
167 +- fixed compose menu
169 +* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua>
172 +* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua>
174 +- added space after newsgroup name in .newsrc file
176 +* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua>
177 +- fixed SIGSEGV when posting article
179 +* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua>
182 +* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua>
184 +- replace safe_free calls by the FREE macro
186 +* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua>
188 +- nntp authentication can be passed after any command
190 +* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua>
193 +* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua>
196 +* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua>
198 +- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>,
199 + <reconstruct-thread> functions
200 +- fixed message about nntp reconnect
201 +- fixed <attach-news-message> function using browser
202 +- added support of Followup-To: poster
203 +- added %n (new articles) in group_index_format
204 +- posting articles without inews by default
206 +* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua>
209 +* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua>
212 +* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua>
214 +- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>)
215 +- added default content disposition
217 +* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua>
220 +* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua>
221 +- update to 1.3.23.2
222 +- fixed segfault if mutt_conn_find() returns null
224 +* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
225 +- update to 1.3.23.1
226 +- added support of LISTGROUP command
227 +- added support for servers with broken overview
228 +- disabled <flag-message> function on news server
229 +- fixed error storing bad authentication information
231 +* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua>
233 +- fixed typo in buffy.c
234 +- added substitution of %s parameter in $inews variable
236 +* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua>
237 +- update to 1.3.22.1
240 +* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua>
243 +* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua>
245 +- removed 'server-hook', use 'account-hook' instead
246 +- fixed error opening NNTP server without newsgroup using -f option
248 +* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua>
251 +* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua>
253 +- fixed typo in nntp_attempt_features()
254 +- changed algorithm of XGTITLE command testing
255 +- disabled writing of NNTP password in debug file
256 +- fixed reading and writing of long newsrc lines
257 +- changed checking of last line while reading lines from server
258 +- fixed possible buffer overrun in nntp_parse_newsrc_line()
259 +- removed checking of XHDR command
260 +- compare NNTP return codes without trailing space
262 +* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua>
264 +- support for 'LIST NEWSGROUPS' command to read descriptions
266 +* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua>
269 +* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua>
272 +* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua>
274 +- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de>
276 +* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua>
279 +* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
280 +- Fixed problem if last article in group is deleted
282 +* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua>
283 +- Fixed checking of XGTITLE command on some servers
285 +* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua>
286 +- Added \r in AUTHINFO commands
288 +* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua>
291 +* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua>
293 +- fixed error opening newsgroup from mutt started with -g or -G
295 +* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua>
297 +- hotkey 'G' (get-message) replaced with '^G'
299 +* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua>
301 +- changed delay displaying error messages from 1 to 2 seconds
302 +- fixed error compiling with nntp and without imap
304 +* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua>
305 +- fixed catchup in index
306 +- fixed nntp_open_mailbox()
308 +* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua>
309 +- functions <edit> and <delete-entry> disabled
310 +- format of news mailbox names changed to url form
311 +- option nntp_attempts removed
312 +- option reconnect_news renamed to nntp_reconnect
313 +- default value of nntp_poll changed from 30 to 60
314 +- error handling improved
316 +* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua>
318 +- new option show_only_unread
319 +- add newsgroup completion
321 +* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
324 +* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
327 +* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
329 +- authentication code update
330 +- fix for changing to newsgroup from mailbox with read messages
331 +- socket code optimization
333 +* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
336 +* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
337 +- don't substitute current newsgroup with deleted new messages
339 +* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
341 +- fix for substitution of newsgroup after reconnection
342 +- fix for loading newsgroups with very long names
343 +- fix for loading more than 32768 newsgroups
345 +* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
348 +* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
351 +* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
354 +* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
357 +* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
360 +* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
363 +* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
364 +- add substitution of newsgroup with new messages by default
366 +* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
367 +- add attach message from newsgroup
368 +- add one-line help in newsreader mode
369 +- disable 'change-dir' command in newsgroups browser
372 +* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
373 +- get default news server name from file /etc/nntpserver
374 +- use case insensitive server names
375 +- add print-style sequence %s to $newsrc
378 +* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
379 +- remove 'X-FTN-Origin' header processing
381 +* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
385 +* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
386 +- fix mutt_select_newsserver()
387 +- remove 'toggle-mode' function
388 +- add 'change-newsgroup' function
390 +* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
393 +* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
394 +- fix error 'bounce' function after 'post'
395 +- add 'forward to newsgroup' function
397 +* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
398 +- 'forward' function works in newsreader mode
399 +- add 'post' and 'followup' functions to pager and attachment menu
400 +- fix active descriptions and allowed flag reload
402 +* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
404 +- remove deleted newsgroups from list
406 +* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
407 +- update .newsrc in browser
409 +* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
410 +- reload .newsrc if externally modified
411 +- fix active cache update
413 +* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
416 +* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
417 +- patch *.update_list_file is not required
418 +- count lines when loading descriptions
419 +- remove cache of unsubscribed newsgroups
421 +* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
422 +- load list of newsgroups from cache faster
424 +* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
427 +* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
428 +- fix unread messages in browser
429 +- fix newsrc_gen_entries()
431 +* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
432 +- fix mutt_newsgroup_stat()
433 +- fix nntp_delete_cache()
434 +- fix nntp_get_status()
435 +- fix check_children()
436 +- fix nntp_fetch_headers()
438 +* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
441 +* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
442 +- fix updating new messages in cache
444 +* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
445 +- change default cache filenames
446 +- fix updating new messages in cache
448 +* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
449 +- fix segmentation fault in news groups browser
451 +* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
454 +* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
457 +* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
458 +- add X-Comment-To editing
459 +- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers
460 +- add variables $ask_followup_to and $ask_x_comment_to
462 +* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua>
464 diff -udprP mutt-1.10.0.orig/OPS mutt-1.10.0/OPS
465 --- mutt-1.10.0.orig/OPS 2018-05-15 00:51:53.000000000 +0300
466 +++ mutt-1.10.0/OPS 2018-06-16 17:22:30.190469794 +0300
467 @@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a
468 OP_BROWSER_NEW_FILE "select a new file in this directory"
469 OP_BROWSER_VIEW_FILE "view file"
470 OP_BROWSER_TELL "display the currently selected file's name"
471 -OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
472 -OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)"
473 +OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)"
474 +OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)"
475 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
476 OP_BUFFY_LIST "list mailboxes with new mail"
477 +OP_CATCHUP "mark all articles in newsgroup as read"
478 OP_CHANGE_DIRECTORY "change directories"
479 OP_CHECK_NEW "check mailboxes for new mail"
480 OP_COMPOSE_ATTACH_FILE "attach file(s) to this message"
481 OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
482 +OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach news article(s) to this message"
483 OP_COMPOSE_EDIT_BCC "edit the BCC list"
484 OP_COMPOSE_EDIT_CC "edit the CC list"
485 OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description"
486 @@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel
487 OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
488 OP_COMPOSE_EDIT_MESSAGE "edit the message"
489 OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
490 +OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list"
491 OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
492 +OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field"
493 +OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field"
494 OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message"
495 OP_COMPOSE_EDIT_TO "edit the TO list"
496 OP_CREATE_MAILBOX "create a new mailbox (IMAP only)"
497 @@ -89,8 +94,13 @@ OP_EXIT "exit this menu"
498 OP_FILTER "filter attachment through a shell command"
499 OP_FIRST_ENTRY "move to the first entry"
500 OP_FLAG_MESSAGE "toggle a message's 'important' flag"
501 +OP_FOLLOWUP "followup to newsgroup"
502 +OP_FORWARD_TO_GROUP "forward to newsgroup"
503 OP_FORWARD_MESSAGE "forward a message with comments"
504 OP_GENERIC_SELECT_ENTRY "select the current entry"
505 +OP_GET_CHILDREN "get all children of the current message"
506 +OP_GET_MESSAGE "get message with Message-Id"
507 +OP_GET_PARENT "get parent of the current message"
508 OP_GROUP_REPLY "reply to all recipients"
509 OP_HALF_DOWN "scroll down 1/2 page"
510 OP_HALF_UP "scroll up 1/2 page"
511 @@ -98,11 +108,14 @@ OP_HELP "this screen"
512 OP_JUMP "jump to an index number"
513 OP_LAST_ENTRY "move to the last entry"
514 OP_LIST_REPLY "reply to specified mailing list"
515 +OP_LOAD_ACTIVE "load list of all newsgroups from NNTP server"
516 OP_MACRO "execute a macro"
517 OP_MAIL "compose a new mail message"
518 OP_MAIN_BREAK_THREAD "break the thread in two"
519 OP_MAIN_CHANGE_FOLDER "open a different folder"
520 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
521 +OP_MAIN_CHANGE_GROUP "open a different newsgroup"
522 +OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
523 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
524 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
525 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
526 @@ -142,6 +155,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of
527 OP_PAGER_SKIP_QUOTED "skip beyond quoted text"
528 OP_PAGER_TOP "jump to the top of the message"
529 OP_PIPE "pipe message/attachment to a shell command"
530 +OP_POST "post message to newsgroup"
531 OP_PREV_ENTRY "move to the previous entry"
532 OP_PREV_LINE "scroll up one line"
533 OP_PREV_PAGE "move to the previous page"
534 @@ -151,6 +165,7 @@ OP_QUERY "query external program for add
535 OP_QUERY_APPEND "append new query results to current results"
536 OP_QUIT "save changes to mailbox and quit"
537 OP_RECALL_MESSAGE "recall a postponed message"
538 +OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
539 OP_REDRAW "clear and redraw the screen"
540 OP_REFORMAT_WINCH "{internal}"
541 OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
542 @@ -165,18 +180,22 @@ OP_SEARCH_TOGGLE "toggle search pattern
543 OP_SHELL_ESCAPE "invoke a command in a subshell"
544 OP_SORT "sort messages"
545 OP_SORT_REVERSE "sort messages in reverse order"
546 +OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern"
547 OP_TAG "tag the current entry"
548 OP_TAG_PREFIX "apply next function to tagged messages"
549 OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
550 OP_TAG_SUBTHREAD "tag the current subthread"
551 OP_TAG_THREAD "tag the current thread"
552 OP_TOGGLE_NEW "toggle a message's 'new' flag"
553 +OP_TOGGLE_READ "toggle view of read messages"
554 OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
555 OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
556 OP_TOP_PAGE "move to the top of the page"
557 +OP_UNCATCHUP "mark all articles in newsgroup as unread"
558 OP_UNDELETE "undelete the current entry"
559 OP_UNDELETE_THREAD "undelete all messages in thread"
560 OP_UNDELETE_SUBTHREAD "undelete all messages in subthread"
561 +OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern"
562 OP_VERSION "show the Mutt version number and date"
563 OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
564 OP_VIEW_ATTACHMENTS "show MIME attachments"
565 diff -udprP mutt-1.10.0.orig/PATCHES mutt-1.10.0/PATCHES
566 --- mutt-1.10.0.orig/PATCHES 2017-12-03 05:10:17.000000000 +0200
567 +++ mutt-1.10.0/PATCHES 2018-06-16 17:22:30.190469794 +0300
570 diff -udprP mutt-1.10.0.orig/account.c mutt-1.10.0/account.c
571 --- mutt-1.10.0.orig/account.c 2017-12-18 22:27:19.000000000 +0200
572 +++ mutt-1.10.0/account.c 2018-06-16 17:22:30.191469778 +0300
573 @@ -51,8 +51,17 @@ int mutt_account_match (const ACCOUNT* a
578 + if (a1->type == MUTT_ACCT_TYPE_NNTP && NntpUser)
582 if (a1->flags & a2->flags & MUTT_ACCT_USER)
583 return (!strcmp (a1->user, a2->user));
585 + if (a1->type == MUTT_ACCT_TYPE_NNTP)
586 + return a1->flags & MUTT_ACCT_USER && a1->user[0] ? 0 : 1;
588 if (a1->flags & MUTT_ACCT_USER)
589 return (!strcmp (a1->user, user));
590 if (a2->flags & MUTT_ACCT_USER)
591 @@ -130,6 +139,16 @@ void mutt_account_tourl (ACCOUNT* accoun
596 + if (account->type == MUTT_ACCT_TYPE_NNTP)
598 + if (account->flags & MUTT_ACCT_SSL)
599 + url->scheme = U_NNTPS;
601 + url->scheme = U_NNTP;
605 url->host = account->host;
606 if (account->flags & MUTT_ACCT_PORT)
607 url->port = account->port;
608 @@ -155,6 +174,10 @@ int mutt_account_getuser (ACCOUNT* accou
609 else if ((account->type == MUTT_ACCT_TYPE_POP) && PopUser)
610 strfcpy (account->user, PopUser, sizeof (account->user));
613 + else if ((account->type == MUTT_ACCT_TYPE_NNTP) && NntpUser)
614 + strfcpy (account->user, NntpUser, sizeof (account->user));
616 else if (option (OPTNOCURSES))
618 /* prompt (defaults to unix username), copy into account->user */
619 @@ -217,6 +240,10 @@ int mutt_account_getpass (ACCOUNT* accou
620 else if ((account->type == MUTT_ACCT_TYPE_SMTP) && SmtpPass)
621 strfcpy (account->pass, SmtpPass, sizeof (account->pass));
624 + else if ((account->type == MUTT_ACCT_TYPE_NNTP) && NntpPass)
625 + strfcpy (account->pass, NntpPass, sizeof (account->pass));
627 else if (option (OPTNOCURSES))
630 diff -udprP mutt-1.10.0.orig/account.h mutt-1.10.0/account.h
631 --- mutt-1.10.0.orig/account.h 2018-05-15 00:51:53.000000000 +0300
632 +++ mutt-1.10.0/account.h 2018-06-16 17:22:30.191469778 +0300
633 @@ -29,7 +29,8 @@ enum
634 MUTT_ACCT_TYPE_NONE = 0,
637 - MUTT_ACCT_TYPE_SMTP
638 + MUTT_ACCT_TYPE_SMTP,
639 + MUTT_ACCT_TYPE_NNTP
643 diff -udprP mutt-1.10.0.orig/attach.h mutt-1.10.0/attach.h
644 --- mutt-1.10.0.orig/attach.h 2017-12-18 22:31:37.000000000 +0200
645 +++ mutt-1.10.0/attach.h 2018-06-16 17:22:30.191469778 +0300
646 @@ -71,7 +71,7 @@ void mutt_print_attachment_list (ATTACH_
648 void mutt_attach_bounce (FILE *, HEADER *, ATTACH_CONTEXT *, BODY *);
649 void mutt_attach_resend (FILE *, HEADER *, ATTACH_CONTEXT *, BODY *);
650 -void mutt_attach_forward (FILE *, HEADER *, ATTACH_CONTEXT *, BODY *);
651 +void mutt_attach_forward (FILE *, HEADER *, ATTACH_CONTEXT *, BODY *, int);
652 void mutt_attach_reply (FILE *, HEADER *, ATTACH_CONTEXT *, BODY *, int);
654 void mutt_actx_add_attach (ATTACH_CONTEXT *actx, ATTACHPTR *attach);
655 diff -udprP mutt-1.10.0.orig/browser.c mutt-1.10.0/browser.c
656 --- mutt-1.10.0.orig/browser.c 2018-05-15 00:51:53.000000000 +0300
657 +++ mutt-1.10.0/browser.c 2018-06-16 17:22:30.192469762 +0300
668 @@ -50,6 +53,19 @@ static const struct mapping_t FolderHelp
673 +static struct mapping_t FolderNewsHelp[] = {
674 + { N_("Exit"), OP_EXIT },
675 + { N_("List"), OP_TOGGLE_MAILBOXES },
676 + { N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
677 + { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
678 + { N_("Catchup"), OP_CATCHUP },
679 + { N_("Mask"), OP_ENTER_MASK },
680 + { N_("Help"), OP_HELP },
685 typedef struct folder_t
687 struct folder_file *ff;
688 @@ -134,9 +150,17 @@ static void browser_sort (struct browser
693 + if (option (OPTNEWS))
696 f = browser_compare_date;
700 + if (option (OPTNEWS))
703 f = browser_compare_size;
706 @@ -367,8 +391,112 @@ folder_format_str (char *dest, size_t de
712 +newsgroup_format_str (char *dest, size_t destlen, size_t col, int cols, char op,
713 + const char *src, const char *fmt, const char *ifstring,
714 + const char *elsestring, unsigned long data, format_flag flags)
716 + char fn[SHORT_STRING], tmp[SHORT_STRING];
717 + FOLDER *folder = (FOLDER *) data;
722 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
723 + snprintf (dest, destlen, tmp, folder->num + 1);
727 + strncpy (fn, folder->ff->name, sizeof(fn) - 1);
728 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
729 + snprintf (dest, destlen, tmp, fn);
733 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
734 + if (folder->ff->nd->subscribed)
735 + snprintf (dest, destlen, tmp, ' ');
737 + snprintf (dest, destlen, tmp, folder->ff->nd->new ? 'N' : 'u');
741 + snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
742 + if (folder->ff->nd->deleted)
743 + snprintf (dest, destlen, tmp, 'D');
745 + snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
749 + if (flags & MUTT_FORMAT_OPTIONAL)
751 + if (folder->ff->nd->unread != 0)
752 + mutt_FormatString (dest, destlen, col, cols, ifstring,
753 + newsgroup_format_str, data, flags);
755 + mutt_FormatString (dest, destlen, col, cols, elsestring,
756 + newsgroup_format_str, data, flags);
758 + else if (Context && Context->data == folder->ff->nd)
760 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
761 + snprintf (dest, destlen, tmp, Context->unread);
765 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
766 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
771 + if (Context && Context->data == folder->ff->nd)
773 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
774 + snprintf (dest, destlen, tmp, Context->new);
776 + else if (option (OPTMARKOLD) &&
777 + folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
778 + folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
780 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
781 + snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
785 + snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
786 + snprintf (dest, destlen, tmp, folder->ff->nd->unread);
791 + if (folder->ff->nd->desc != NULL)
793 + char *buf = safe_strdup (folder->ff->nd->desc);
794 + if (NewsgroupsCharset && *NewsgroupsCharset)
795 + mutt_convert_string (&buf, NewsgroupsCharset, Charset, MUTT_ICONV_HOOK_FROM);
796 + mutt_filter_unprintable (&buf);
798 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
799 + snprintf (dest, destlen, tmp, buf);
804 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
805 + snprintf (dest, destlen, tmp, "");
811 +#endif /* USE_NNTP */
813 static void add_folder (MUTTMENU *m, struct browser_state *state,
814 - const char *name, const struct stat *s, BUFFY *b)
815 + const char *name, const struct stat *s, BUFFY *b,
818 if (state->entrylen == state->entrymax)
820 @@ -406,6 +534,10 @@ static void add_folder (MUTTMENU *m, str
822 (state->entry)[state->entrylen].imap = 0;
825 + if (option (OPTNEWS))
826 + (state->entry)[state->entrylen].nd = (NNTP_DATA *)data;
831 @@ -421,9 +553,35 @@ static void init_state (struct browser_s
832 menu->data = state->entry;
835 +/* get list of all files/newsgroups with mask */
836 static int examine_directory (MUTTMENU *menu, struct browser_state *state,
837 char *d, const char *prefix)
840 + if (option (OPTNEWS))
842 + NNTP_SERVER *nserv = CurrentNewsSrv;
845 +/* mutt_buffy_check (0); */
846 + init_state (state, menu);
848 + for (i = 0; i < nserv->groups_num; i++)
850 + NNTP_DATA *nntp_data = nserv->groups_list[i];
853 + if (prefix && *prefix &&
854 + strncmp (prefix, nntp_data->group, strlen (prefix)))
856 + if (!((regexec (Mask.rx, nntp_data->group, 0, NULL, 0) == 0) ^ Mask.not))
858 + add_folder (menu, state, nntp_data->group, NULL, NULL, nntp_data);
862 +#endif /* USE_NNTP */
867 @@ -492,17 +650,40 @@ static int examine_directory (MUTTMENU *
868 tmp->msg_count = Context->msgcount;
869 tmp->msg_unread = Context->unread;
871 - add_folder (menu, state, de->d_name, &s, tmp);
872 + add_folder (menu, state, de->d_name, &s, tmp, NULL);
876 browser_sort (state);
880 +/* get list of mailboxes/subscribed newsgroups */
881 static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
884 char buffer[LONG_STRING];
887 + if (option (OPTNEWS))
889 + NNTP_SERVER *nserv = CurrentNewsSrv;
892 +/* mutt_buffy_check (0); */
893 + init_state (state, menu);
895 + for (i = 0; i < nserv->groups_num; i++)
897 + NNTP_DATA *nntp_data = nserv->groups_list[i];
898 + if (nntp_data && (nntp_data->new || (nntp_data->subscribed &&
899 + (nntp_data->unread || !option (OPTSHOWONLYUNREAD)))))
900 + add_folder (menu, state, nntp_data->group, NULL, NULL, nntp_data);
906 BUFFY *tmp = Incoming;
909 @@ -527,14 +708,21 @@ static int examine_mailboxes (MUTTMENU *
911 if (mx_is_imap (tmp->path))
913 - add_folder (menu, state, buffer, NULL, tmp);
914 + add_folder (menu, state, buffer, NULL, tmp, NULL);
919 if (mx_is_pop (tmp->path))
921 - add_folder (menu, state, buffer, NULL, tmp);
922 + add_folder (menu, state, buffer, NULL, tmp, NULL);
927 + if (mx_is_nntp (tmp->path))
929 + add_folder (menu, state, buffer, NULL, tmp, NULL);
933 @@ -560,15 +748,20 @@ static int examine_mailboxes (MUTTMENU *
934 s.st_mtime = st2.st_mtime;
937 - add_folder (menu, state, buffer, &s, tmp);
938 + add_folder (menu, state, buffer, &s, tmp, NULL);
940 while ((tmp = tmp->next));
942 browser_sort (state);
946 static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
949 + if (option (OPTNEWS))
950 + return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
952 return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
955 @@ -579,6 +772,12 @@ static void folder_entry (char *s, size_
956 folder.ff = &((struct folder_file *) menu->data)[num];
960 + if (option (OPTNEWS))
961 + mutt_FormatString (s, slen, 0, MuttIndexWindow->cols, NONULL(GroupFormat),
962 + newsgroup_format_str, (unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
965 mutt_FormatString (s, slen, 0, MuttIndexWindow->cols, NONULL(FolderFormat), folder_format_str,
966 (unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
968 @@ -599,6 +798,17 @@ static void init_menu (struct browser_st
973 + if (option (OPTNEWS))
976 + snprintf (title, titlelen, _("Subscribed newsgroups"));
978 + snprintf (title, titlelen, _("Newsgroups on server [%s]"),
979 + CurrentNewsSrv->conn->account.host);
984 snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
986 @@ -654,6 +864,31 @@ void _mutt_select_file (char *f, size_t
988 strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
991 + if (option (OPTNEWS))
994 + strfcpy (prefix, f, sizeof (prefix));
997 + NNTP_SERVER *nserv = CurrentNewsSrv;
1000 + /* default state for news reader mode is browse subscribed newsgroups */
1002 + for (i = 0; i < nserv->groups_num; i++)
1004 + NNTP_DATA *nntp_data = nserv->groups_list[i];
1005 + if (nntp_data && nntp_data->subscribed)
1017 mutt_expand_path (f, flen);
1018 @@ -750,6 +985,9 @@ void _mutt_select_file (char *f, size_t
1019 menu->tag = file_tag;
1021 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
1023 + option (OPTNEWS) ? FolderNewsHelp :
1026 mutt_push_current_menu (menu);
1028 @@ -889,7 +1127,11 @@ void _mutt_select_file (char *f, size_t
1033 + if (buffy || option (OPTNEWS))
1038 strfcpy (f, state.entry[menu->current].name, flen);
1039 mutt_expand_path (f, flen);
1040 @@ -946,14 +1188,6 @@ void _mutt_select_file (char *f, size_t
1044 - case OP_BROWSER_SUBSCRIBE:
1045 - imap_subscribe (state.entry[menu->current].name, 1);
1048 - case OP_BROWSER_UNSUBSCRIBE:
1049 - imap_subscribe (state.entry[menu->current].name, 0);
1052 case OP_BROWSER_TOGGLE_LSUB:
1053 if (option (OPTIMAPLSUB))
1054 unset_option (OPTIMAPLSUB);
1055 @@ -1055,6 +1289,11 @@ void _mutt_select_file (char *f, size_t
1057 case OP_CHANGE_DIRECTORY:
1060 + if (option (OPTNEWS))
1064 strfcpy (buf, LastDir, sizeof (buf));
1066 if (!state.imap_browse)
1067 @@ -1321,6 +1560,209 @@ void _mutt_select_file (char *f, size_t
1069 mutt_error _("Error trying to view file");
1075 + case OP_UNCATCHUP:
1076 + if (option (OPTNEWS))
1078 + struct folder_file *f = &state.entry[menu->current];
1080 + NNTP_DATA *nntp_data;
1082 + rc = nntp_newsrc_parse (CurrentNewsSrv);
1086 + if (i == OP_CATCHUP)
1087 + nntp_data = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
1089 + nntp_data = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
1094 + struct folder_file ff;
1095 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1098 + folder.ff->name = f->name;
1099 + folder.ff->st = NULL;
1100 + folder.ff->is_new = nntp_data->new;
1101 + folder.ff->nntp_data = nntp_data;
1103 + mutt_FormatString (buffer, sizeof (buffer), 0, MuttIndexWindow->cols,
1104 + NONULL(GroupFormat), newsgroup_format_str,
1105 + (unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
1106 + f->desc = safe_strdup (buffer); */
1107 + nntp_newsrc_update (CurrentNewsSrv);
1108 + if (menu->current + 1 < menu->max)
1110 + menu->redraw = REDRAW_MOTION_RESYNCH;
1113 + menu->redraw = REDRAW_INDEX;
1114 + nntp_newsrc_close (CurrentNewsSrv);
1118 + case OP_LOAD_ACTIVE:
1119 + if (option (OPTNEWS))
1121 + NNTP_SERVER *nserv = CurrentNewsSrv;
1124 + if (nntp_newsrc_parse (nserv) < 0)
1127 + for (i = 0; i < nserv->groups_num; i++)
1129 + NNTP_DATA *nntp_data = nserv->groups_list[i];
1131 + nntp_data->deleted = 1;
1133 + nntp_active_fetch (nserv, 1);
1134 + nntp_newsrc_update (nserv);
1135 + nntp_newsrc_close (nserv);
1137 + destroy_state (&state);
1139 + examine_mailboxes (menu, &state);
1141 + examine_directory (menu, &state, NULL, NULL);
1142 + init_menu (&state, menu, title, sizeof (title), buffy);
1145 +#endif /* USE_NNTP */
1147 +#if defined USE_IMAP || defined USE_NNTP
1148 + case OP_BROWSER_SUBSCRIBE:
1149 + case OP_BROWSER_UNSUBSCRIBE:
1152 + case OP_SUBSCRIBE_PATTERN:
1153 + case OP_UNSUBSCRIBE_PATTERN:
1154 + if (option (OPTNEWS))
1156 + NNTP_SERVER *nserv = CurrentNewsSrv;
1157 + NNTP_DATA *nntp_data;
1158 + regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
1160 + int rc, j = menu->current;
1162 + if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
1168 + if (i == OP_SUBSCRIBE_PATTERN)
1169 + snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
1171 + snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
1172 + if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
1178 + err = REGCOMP (rx, s, REG_NOSUB);
1181 + regerror (err, rx, buf, sizeof (buf));
1184 + mutt_error ("%s", buf);
1187 + menu->redraw = REDRAW_FULL;
1190 + else if (!state.entrylen)
1192 + mutt_error _("No newsgroups match the mask");
1196 + rc = nntp_newsrc_parse (nserv);
1200 + for ( ; j < state.entrylen; j++)
1202 + struct folder_file *f = &state.entry[j];
1204 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
1205 + regexec (rx, f->name, 0, NULL, 0) == 0)
1207 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
1208 + nntp_data = mutt_newsgroup_subscribe (nserv, f->name);
1210 + nntp_data = mutt_newsgroup_unsubscribe (nserv, f->name);
1214 + char buffer[_POSIX_PATH_MAX + SHORT_STRING];
1216 + folder.name = f->name;
1218 + folder.new = nntp_data->new;
1219 + folder.nd = nntp_data;
1221 + mutt_FormatString (buffer, sizeof (buffer), 0, MuttIndexWindow->cols,
1222 + NONULL(GroupFormat), newsgroup_format_str,
1223 + (unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
1224 + f->desc = safe_strdup (buffer);
1227 + if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
1229 + if (menu->current + 1 < menu->max)
1231 + menu->redraw = REDRAW_MOTION_RESYNCH;
1235 + if (i == OP_SUBSCRIBE_PATTERN)
1239 + for (i = 0; nserv && i < nserv->groups_num; i++)
1241 + nntp_data = nserv->groups_list[i];
1242 + if (nntp_data && nntp_data->group && !nntp_data->subscribed)
1244 + if (regexec (rx, nntp_data->group, 0, NULL, 0) == 0)
1246 + mutt_newsgroup_subscribe (nserv, nntp_data->group);
1247 + add_folder (menu, &state, nntp_data->group, NULL, NULL, nntp_data);
1251 + init_menu (&state, menu, title, sizeof (title), buffy);
1254 + menu->redraw = REDRAW_FULL;
1255 + nntp_newsrc_update (nserv);
1256 + nntp_clear_cache (nserv);
1257 + nntp_newsrc_close (nserv);
1258 + if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
1264 +#endif /* USE_IMAP && USE_NNTP */
1265 +#endif /* USE_NNTP */
1268 + if (i == OP_BROWSER_SUBSCRIBE)
1269 + imap_subscribe (state.entry[menu->current].name, 1);
1271 + imap_subscribe (state.entry[menu->current].name, 0);
1273 +#endif /* USE_IMAP */
1277 diff -udprP mutt-1.10.0.orig/browser.h mutt-1.10.0/browser.h
1278 --- mutt-1.10.0.orig/browser.h 2017-12-18 22:27:19.000000000 +0200
1279 +++ mutt-1.10.0/browser.h 2018-06-16 17:22:30.192469762 +0300
1282 #define _BROWSER_H 1
1291 @@ -44,6 +48,9 @@ struct folder_file
1293 unsigned has_buffy : 1;
1294 unsigned local : 1; /* folder is on local filesystem */
1298 unsigned tagged : 1;
1301 diff -udprP mutt-1.10.0.orig/buffy.c mutt-1.10.0/buffy.c
1302 --- mutt-1.10.0.orig/buffy.c 2018-04-17 02:31:03.000000000 +0300
1303 +++ mutt-1.10.0/buffy.c 2018-06-16 17:22:30.192469762 +0300
1304 @@ -512,6 +512,9 @@ int mutt_buffy_check (int force)
1306 /* check device ID and serial number instead of comparing paths */
1307 if (!Context || Context->magic == MUTT_IMAP || Context->magic == MUTT_POP
1309 + || Context->magic == MUTT_NNTP
1311 || stat (Context->path, &contex_sb) != 0)
1314 @@ -535,6 +538,11 @@ int mutt_buffy_check (int force)
1315 tmp->magic = MUTT_POP;
1319 + if ((tmp->magic == MUTT_NNTP) || mx_is_nntp (tmp->path))
1320 + tmp->magic = MUTT_NNTP;
1323 if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
1324 (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
1326 @@ -550,7 +558,11 @@ int mutt_buffy_check (int force)
1327 /* check to see if the folder is the currently selected folder
1329 if (!Context || !Context->path ||
1331 + (( tmp->magic == MUTT_IMAP || tmp->magic == MUTT_POP || tmp->magic == MUTT_NNTP )
1333 (( tmp->magic == MUTT_IMAP || tmp->magic == MUTT_POP )
1335 ? mutt_strcmp (tmp->path, Context->path) :
1336 (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)))
1338 diff -udprP mutt-1.10.0.orig/complete.c mutt-1.10.0/complete.c
1339 --- mutt-1.10.0.orig/complete.c 2017-12-03 05:10:17.000000000 +0200
1340 +++ mutt-1.10.0/complete.c 2018-06-16 17:22:30.192469762 +0300
1342 #include "mailbox.h"
1351 @@ -48,9 +51,70 @@ int mutt_complete (char *s, size_t slen)
1352 char filepart[_POSIX_PATH_MAX];
1354 char imap_path[LONG_STRING];
1357 dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
1360 + if (option (OPTNEWS))
1362 + NNTP_SERVER *nserv = CurrentNewsSrv;
1363 + unsigned int n = 0;
1365 + strfcpy (filepart, s, sizeof (filepart));
1367 + /* special case to handle when there is no filepart yet
1368 + * find the first subscribed newsgroup */
1369 + len = mutt_strlen (filepart);
1372 + for (; n < nserv->groups_num; n++)
1374 + NNTP_DATA *nntp_data = nserv->groups_list[n];
1376 + if (nntp_data && nntp_data->subscribed)
1378 + strfcpy (filepart, nntp_data->group, sizeof (filepart));
1386 + for (; n < nserv->groups_num; n++)
1388 + NNTP_DATA *nntp_data = nserv->groups_list[n];
1390 + if (nntp_data && nntp_data->subscribed &&
1391 + mutt_strncmp (nntp_data->group, filepart, len) == 0)
1395 + for (i = 0; filepart[i] && nntp_data->group[i]; i++)
1397 + if (filepart[i] != nntp_data->group[i])
1407 + strfcpy (filepart, nntp_data->group, sizeof (filepart));
1413 + strcpy (s, filepart);
1414 + return (init ? 0 : -1);
1419 /* we can use '/' as a delimiter, imap_complete rewrites it */
1420 if (*s == '=' || *s == '+' || *s == '!')
1422 diff -udprP mutt-1.10.0.orig/compose.c mutt-1.10.0/compose.c
1423 --- mutt-1.10.0.orig/compose.c 2018-04-17 02:31:03.000000000 +0300
1424 +++ mutt-1.10.0/compose.c 2018-06-16 17:22:30.193469746 +0300
1426 #include "mailbox.h"
1428 #include "charset.h"
1432 #include "remailer.h"
1441 #include <sys/stat.h>
1442 @@ -68,10 +73,20 @@ enum
1452 HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
1456 +int HeaderPadding[HDR_XCOMMENTTO + 1] = {0};
1458 int HeaderPadding[HDR_CRYPTINFO + 1] = {0};
1460 int MaxHeaderWidth = 0;
1462 #define HDR_XOFFSET MaxHeaderWidth
1463 @@ -109,6 +124,14 @@ static const char * const Prompts[] =
1464 * than 15-20 character cells.
1468 + /* L10N: Compose menu field. May not want to translate. */
1469 + ,N_("Newsgroups: ")
1470 + /* L10N: Compose menu field. May not want to translate. */
1471 + ,N_("Followup-To: ")
1472 + /* L10N: Compose menu field. May not want to translate. */
1473 + ,N_("X-Comment-To: ")
1477 static const struct mapping_t ComposeHelp[] = {
1478 @@ -126,6 +149,21 @@ static const struct mapping_t ComposeHel
1483 +static struct mapping_t ComposeNewsHelp[] = {
1484 + { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
1485 + { N_("Abort"), OP_EXIT },
1486 + /* L10N: compose menu help line entry */
1487 + { N_("Newsgroups"), OP_COMPOSE_EDIT_NEWSGROUPS },
1488 + /* L10N: compose menu help line entry */
1489 + { N_("Subj"), OP_COMPOSE_EDIT_SUBJECT },
1490 + { N_("Attach file"), OP_COMPOSE_ATTACH_FILE },
1491 + { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
1492 + { N_("Help"), OP_HELP },
1497 static void calc_header_width_padding (int idx, const char *header, int calc_max)
1500 @@ -161,7 +199,14 @@ static void init_header_padding (void)
1501 * the other fields look funny. */
1502 calc_header_width_padding (HDR_CRYPTINFO, _(Prompts[HDR_CRYPTINFO]), 0);
1505 + for (i = HDR_NEWSGROUPS; i <= HDR_XCOMMENTTO; i++)
1506 + calc_header_width_padding (i, _(Prompts[i]), 1);
1508 + for (i = 0; i <= HDR_XCOMMENTTO; i++)
1510 for (i = 0; i <= HDR_CRYPTINFO; i++)
1513 HeaderPadding[i] += MaxHeaderWidth;
1514 if (HeaderPadding[i] < 0)
1515 @@ -357,9 +402,37 @@ static void draw_envelope_addr (int line
1516 static void draw_envelope (HEADER *msg, char *fcc)
1518 draw_envelope_addr (HDR_FROM, msg->env->from);
1520 + if (option (OPTNEWSSEND))
1522 + SETCOLOR (MT_COLOR_COMPOSE_HEADER);
1523 + mutt_window_mvprintw (MuttIndexWindow, HDR_TO, 0,
1524 + "%*s", HeaderPadding[HDR_NEWSGROUPS], _(Prompts[HDR_NEWSGROUPS]));
1526 + mutt_paddstr (W, NONULL (msg->env->newsgroups));
1528 + SETCOLOR (MT_COLOR_COMPOSE_HEADER);
1529 + mutt_window_mvprintw (MuttIndexWindow, HDR_CC, 0,
1530 + "%*s", HeaderPadding[HDR_FOLLOWUPTO], _(Prompts[HDR_FOLLOWUPTO]));
1532 + mutt_paddstr (W, NONULL (msg->env->followup_to));
1534 + if (option (OPTXCOMMENTTO))
1536 + SETCOLOR (MT_COLOR_COMPOSE_HEADER);
1537 + mutt_window_mvprintw (MuttIndexWindow, HDR_BCC, 0,
1538 + "%*s", HeaderPadding[HDR_XCOMMENTTO], _(Prompts[HDR_XCOMMENTTO]));
1540 + mutt_paddstr (W, NONULL (msg->env->x_comment_to));
1546 draw_envelope_addr (HDR_TO, msg->env->to);
1547 draw_envelope_addr (HDR_CC, msg->env->cc);
1548 draw_envelope_addr (HDR_BCC, msg->env->bcc);
1551 SETCOLOR (MT_COLOR_COMPOSE_HEADER);
1552 mutt_window_mvprintw (MuttIndexWindow, HDR_SUBJECT, 0,
1553 @@ -712,6 +785,12 @@ int mutt_compose_menu (HEADER *msg, /*
1554 int oldSort, oldSortAux;
1556 compose_redraw_data_t rd;
1558 + int news = 0; /* is it a news article ? */
1560 + if (option (OPTNEWSSEND))
1564 init_header_padding ();
1566 @@ -722,6 +801,11 @@ int mutt_compose_menu (HEADER *msg, /*
1567 menu->offset = HDR_ATTACH;
1568 menu->make_entry = snd_entry;
1569 menu->tag = mutt_tag_attach;
1572 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
1575 menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
1576 menu->custom_menu_redraw = compose_menu_redraw;
1577 menu->redraw_data = &rd;
1578 @@ -733,6 +817,9 @@ int mutt_compose_menu (HEADER *msg, /*
1583 + unset_option (OPTNEWS); /* for any case */
1585 switch (op = mutt_menuLoop (menu))
1587 case OP_COMPOSE_EDIT_FROM:
1588 @@ -740,6 +827,10 @@ int mutt_compose_menu (HEADER *msg, /*
1589 mutt_message_hook (NULL, msg, MUTT_SEND2HOOK);
1591 case OP_COMPOSE_EDIT_TO:
1596 edit_address_list (HDR_TO, &msg->env->to);
1597 if (option (OPTCRYPTOPPORTUNISTICENCRYPT))
1599 @@ -749,6 +840,10 @@ int mutt_compose_menu (HEADER *msg, /*
1600 mutt_message_hook (NULL, msg, MUTT_SEND2HOOK);
1602 case OP_COMPOSE_EDIT_BCC:
1607 edit_address_list (HDR_BCC, &msg->env->bcc);
1608 if (option (OPTCRYPTOPPORTUNISTICENCRYPT))
1610 @@ -758,6 +853,10 @@ int mutt_compose_menu (HEADER *msg, /*
1611 mutt_message_hook (NULL, msg, MUTT_SEND2HOOK);
1613 case OP_COMPOSE_EDIT_CC:
1618 edit_address_list (HDR_CC, &msg->env->cc);
1619 if (option (OPTCRYPTOPPORTUNISTICENCRYPT))
1621 @@ -766,6 +865,62 @@ int mutt_compose_menu (HEADER *msg, /*
1623 mutt_message_hook (NULL, msg, MUTT_SEND2HOOK);
1626 + case OP_COMPOSE_EDIT_NEWSGROUPS:
1629 + if (msg->env->newsgroups)
1630 + strfcpy (buf, msg->env->newsgroups, sizeof (buf));
1633 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0)
1635 + mutt_str_replace (&msg->env->newsgroups, buf);
1636 + move (HDR_TO, HDR_XOFFSET);
1637 + if (msg->env->newsgroups)
1638 + mutt_paddstr (W, msg->env->newsgroups);
1644 + case OP_COMPOSE_EDIT_FOLLOWUP_TO:
1647 + if (msg->env->followup_to)
1648 + strfcpy (buf, msg->env->followup_to, sizeof (buf));
1651 + if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0)
1653 + mutt_str_replace (&msg->env->followup_to, buf);
1654 + move (HDR_CC, HDR_XOFFSET);
1655 + if (msg->env->followup_to)
1656 + mutt_paddstr (W, msg->env->followup_to);
1662 + case OP_COMPOSE_EDIT_X_COMMENT_TO:
1663 + if (news && option (OPTXCOMMENTTO))
1665 + if (msg->env->x_comment_to)
1666 + strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
1669 + if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0)
1671 + mutt_str_replace (&msg->env->x_comment_to, buf);
1672 + move (HDR_BCC, HDR_XOFFSET);
1673 + if (msg->env->x_comment_to)
1674 + mutt_paddstr (W, msg->env->x_comment_to);
1681 case OP_COMPOSE_EDIT_SUBJECT:
1682 if (msg->env->subject)
1683 strfcpy (buf, msg->env->subject, sizeof (buf));
1684 @@ -910,6 +1065,9 @@ int mutt_compose_menu (HEADER *msg, /*
1687 case OP_COMPOSE_ATTACH_MESSAGE:
1689 + case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
1694 @@ -917,7 +1075,22 @@ int mutt_compose_menu (HEADER *msg, /*
1696 prompt = _("Open mailbox to attach message from");
1699 + unset_option (OPTNEWS);
1700 + if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
1702 + if (!(CurrentNewsSrv = nntp_select_server (NewsServer, 0)))
1705 + prompt = _("Open newsgroup to attach message from");
1706 + set_option (OPTNEWS);
1712 + if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == MUTT_NNTP))
1715 strfcpy (fname, NONULL (Context->path), sizeof (fname));
1716 mutt_pretty_mailbox (fname, sizeof (fname));
1717 @@ -926,6 +1099,11 @@ int mutt_compose_menu (HEADER *msg, /*
1718 if (mutt_enter_fname (prompt, fname, sizeof (fname), 1) == -1 || !fname[0])
1722 + if (option (OPTNEWS))
1723 + nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
1726 mutt_expand_path (fname, sizeof (fname));
1728 if (!mx_is_imap (fname))
1729 @@ -933,6 +1111,9 @@ int mutt_compose_menu (HEADER *msg, /*
1731 if (!mx_is_pop (fname))
1734 + if (!mx_is_nntp (fname) && !option (OPTNEWS))
1736 /* check to make sure the file exists and is readable */
1737 if (access (fname, R_OK) == -1)
1739 diff -udprP mutt-1.10.0.orig/config.h.in mutt-1.10.0/config.h.in
1740 --- mutt-1.10.0.orig/config.h.in 2018-05-15 04:09:08.000000000 +0300
1741 +++ mutt-1.10.0/config.h.in 2018-06-16 17:22:30.193469746 +0300
1743 /* Define if you want support for the IMAP protocol. */
1746 +/* Define if you want support for the NNTP protocol. */
1749 /* Define if you want support for the POP3 protocol. */
1752 diff -udprP mutt-1.10.0.orig/configure.ac mutt-1.10.0/configure.ac
1753 --- mutt-1.10.0.orig/configure.ac 2018-05-15 00:51:53.000000000 +0300
1754 +++ mutt-1.10.0/configure.ac 2018-06-16 17:22:30.193469746 +0300
1755 @@ -633,6 +633,15 @@ AC_ARG_ENABLE(imap, AS_HELP_STRING([--en
1757 AM_CONDITIONAL(BUILD_IMAP, test x$need_imap = xyes)
1759 +AC_ARG_ENABLE(nntp, AC_HELP_STRING([--enable-nntp],[Enable NNTP support]),
1760 +[ if test x$enableval = xyes ; then
1761 + AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ])
1762 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
1768 AC_ARG_ENABLE(smtp, AS_HELP_STRING([--enable-smtp],[include internal SMTP relay support]),
1769 [if test $enableval = yes; then
1770 AC_DEFINE(USE_SMTP, 1, [Include internal SMTP relay support])
1771 @@ -640,7 +649,7 @@ AC_ARG_ENABLE(smtp, AS_HELP_STRING([--en
1775 -if test x"$need_imap" = xyes -o x"$need_pop" = xyes ; then
1776 +if test x"$need_imap" = xyes -o x"$need_pop" = xyes -o x"$need_nntp" = xyes ; then
1777 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
1780 diff -udprP mutt-1.10.0.orig/curs_main.c mutt-1.10.0/curs_main.c
1781 --- mutt-1.10.0.orig/curs_main.c 2018-05-15 00:51:53.000000000 +0300
1782 +++ mutt-1.10.0/curs_main.c 2018-06-16 17:37:28.758111855 +0300
1786 #include "mutt_curses.h"
1788 #include "mutt_menu.h"
1789 #include "mailbox.h"
1790 #include "mapping.h"
1793 #include "mutt_crypt.h"
1802 @@ -547,12 +552,27 @@ static void index_menu_redraw (MUTTMENU
1807 +struct mapping_t IndexNewsHelp[] = {
1808 + { N_("Quit"), OP_QUIT },
1809 + { N_("Del"), OP_DELETE },
1810 + { N_("Undel"), OP_UNDELETE },
1811 + { N_("Save"), OP_SAVE },
1812 + { N_("Post"), OP_POST },
1813 + { N_("Followup"), OP_FOLLOWUP },
1814 + { N_("Catchup"), OP_CATCHUP },
1815 + { N_("Help"), OP_HELP },
1820 /* This function handles the message index window as well as commands returned
1821 * from the pager (MENU_PAGER).
1823 int mutt_index_menu (void)
1825 char buf[LONG_STRING], helpstr[LONG_STRING];
1828 int done = 0; /* controls when to exit the "event" loop */
1830 @@ -571,7 +591,11 @@ int mutt_index_menu (void)
1831 menu->make_entry = index_make_entry;
1832 menu->color = index_color;
1833 menu->current = ci_first_message ();
1834 - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
1835 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
1837 + (Context && (Context->magic == MUTT_NNTP)) ? IndexNewsHelp :
1840 menu->custom_menu_redraw = index_menu_redraw;
1841 mutt_push_current_menu (menu);
1843 @@ -786,6 +810,9 @@ int mutt_index_menu (void)
1844 mutt_curs_set (1); /* fallback from the pager */
1848 + unset_option (OPTNEWS); /* for any case */
1853 @@ -836,6 +863,161 @@ int mutt_index_menu (void)
1854 menu_current_bottom (menu);
1858 + case OP_GET_PARENT:
1862 + case OP_GET_MESSAGE:
1866 + if (Context->magic == MUTT_NNTP)
1870 + if (op == OP_GET_MESSAGE)
1873 + if (mutt_get_field (_("Enter Message-Id: "),
1874 + buf, sizeof (buf), 0) != 0 || !buf[0])
1879 + LIST *ref = CURHDR->env->references;
1882 + mutt_error _("Article has no parent reference.");
1885 + strfcpy (buf, ref->data, sizeof (buf));
1887 + if (!Context->id_hash)
1888 + Context->id_hash = mutt_make_id_hash (Context);
1889 + hdr = hash_find (Context->id_hash, buf);
1892 + if (hdr->virtual != -1)
1894 + menu->current = hdr->virtual;
1895 + menu->redraw = REDRAW_MOTION_RESYNCH;
1897 + else if (hdr->collapsed)
1899 + mutt_uncollapse_thread (Context, hdr);
1900 + mutt_set_virtual (Context);
1901 + menu->current = hdr->virtual;
1902 + menu->redraw = REDRAW_MOTION_RESYNCH;
1905 + mutt_error _("Message is not visible in limited view.");
1911 + mutt_message (_("Fetching %s from server..."), buf);
1912 + rc = nntp_check_msgid (Context, buf);
1915 + hdr = Context->hdrs[Context->msgcount - 1];
1916 + mutt_sort_headers (Context, 0);
1917 + menu->current = hdr->virtual;
1918 + menu->redraw = REDRAW_FULL;
1921 + mutt_error (_("Article %s not found on the server."), buf);
1926 + case OP_GET_CHILDREN:
1927 + case OP_RECONSTRUCT_THREAD:
1932 + if (Context->magic == MUTT_NNTP)
1934 + int oldmsgcount = Context->msgcount;
1935 + int oldindex = CURHDR->index;
1938 + if (!CURHDR->env->message_id)
1940 + mutt_error _("No Message-Id. Unable to perform operation.");
1944 + mutt_message _("Fetching message headers...");
1945 + if (!Context->id_hash)
1946 + Context->id_hash = mutt_make_id_hash (Context);
1947 + strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
1949 + /* trying to find msgid of the root message */
1950 + if (op == OP_RECONSTRUCT_THREAD)
1952 + LIST *ref = CURHDR->env->references;
1955 + if (hash_find (Context->id_hash, ref->data) == NULL)
1957 + rc = nntp_check_msgid (Context, ref->data);
1962 + /* the last msgid in References is the root message */
1964 + strfcpy (buf, ref->data, sizeof (buf));
1969 + /* fetching all child messages */
1971 + rc = nntp_check_children (Context, buf);
1973 + /* at least one message has been loaded */
1974 + if (Context->msgcount > oldmsgcount)
1977 + int i, quiet = Context->quiet;
1980 + Context->quiet = 1;
1981 + mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
1982 + Context->quiet = quiet;
1984 + /* if the root message was retrieved, move to it */
1985 + hdr = hash_find (Context->id_hash, buf);
1987 + menu->current = hdr->virtual;
1989 + /* try to restore old position */
1992 + for (i = 0; i < Context->msgcount; i++)
1994 + if (Context->hdrs[i]->index == oldindex)
1996 + menu->current = Context->hdrs[i]->virtual;
1997 + /* as an added courtesy, recenter the menu
1998 + * with the current entry at the middle of the screen */
1999 + menu_check_recenter (menu);
2000 + menu_current_middle (menu);
2004 + menu->redraw = REDRAW_FULL;
2007 + mutt_error _("No deleted messages found in the thread.");
2015 @@ -946,11 +1128,33 @@ int mutt_index_menu (void)
2019 + case OP_TOGGLE_READ:
2022 menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
2024 - if (mutt_pattern_func (MUTT_LIMIT, _("Limit to messages matching: ")) == 0)
2025 + if (op == OP_TOGGLE_READ)
2027 + char buf[LONG_STRING];
2029 + if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
2031 + snprintf (buf, sizeof (buf), "!~R!~D~s%s",
2032 + Context->pattern ? Context->pattern : ".*");
2033 + set_option (OPTHIDEREAD);
2037 + strfcpy (buf, Context->pattern + 8, sizeof(buf));
2038 + if (!*buf || strncmp (buf, ".*", 2) == 0)
2039 + snprintf (buf, sizeof(buf), "~A");
2040 + unset_option (OPTHIDEREAD);
2042 + FREE (&Context->pattern);
2043 + Context->pattern = safe_strdup (buf);
2045 + if ((op == OP_TOGGLE_READ && mutt_pattern_func (MUTT_LIMIT, NULL) == 0) ||
2046 + mutt_pattern_func (MUTT_LIMIT, _("Limit to messages matching: ")) == 0)
2048 if (menu->oldcurrent >= 0)
2050 @@ -1195,15 +1399,22 @@ int mutt_index_menu (void)
2052 case OP_MAIN_CHANGE_FOLDER:
2053 case OP_MAIN_NEXT_UNREAD_MAILBOX:
2056 - op = OP_MAIN_CHANGE_FOLDER_READONLY;
2058 - /* fallback to the readonly case */
2060 case OP_MAIN_CHANGE_FOLDER_READONLY:
2062 + case OP_MAIN_CHANGE_GROUP:
2063 + case OP_MAIN_CHANGE_GROUP_READONLY:
2064 + unset_option (OPTNEWS);
2066 + if (attach_msg || option (OPTREADONLY) ||
2068 + op == OP_MAIN_CHANGE_GROUP_READONLY ||
2070 + op == OP_MAIN_CHANGE_FOLDER_READONLY)
2071 + flags = MUTT_READONLY;
2075 - if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
2077 cp = _("Open mailbox in read-only mode");
2079 cp = _("Open mailbox");
2080 @@ -1236,6 +1447,22 @@ int mutt_index_menu (void)
2081 strfcpy (buf, Context->path, sizeof (buf));
2082 mutt_pretty_mailbox (buf, sizeof (buf));
2085 + if (op == OP_MAIN_CHANGE_GROUP ||
2086 + op == OP_MAIN_CHANGE_GROUP_READONLY)
2088 + set_option (OPTNEWS);
2089 + CurrentNewsSrv = nntp_select_server (NewsServer, 0);
2090 + if (!CurrentNewsSrv)
2093 + cp = _("Open newsgroup in read-only mode");
2095 + cp = _("Open newsgroup");
2096 + nntp_buffy (buf, sizeof (buf));
2100 mutt_buffy (buf, sizeof (buf));
2102 if (mutt_enter_fname (cp, buf, sizeof (buf), 1) == -1)
2103 @@ -1255,6 +1482,14 @@ int mutt_index_menu (void)
2108 + if (option (OPTNEWS))
2110 + unset_option (OPTNEWS);
2111 + nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
2115 mutt_expand_path (buf, sizeof (buf));
2116 if (mx_get_magic (buf) <= 0)
2118 @@ -1307,9 +1542,7 @@ int mutt_index_menu (void)
2119 * switch statement would need to be run. */
2120 mutt_folder_hook (buf);
2122 - if ((Context = mx_open_mailbox (buf,
2123 - (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
2124 - MUTT_READONLY : 0, NULL)) != NULL)
2125 + if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
2127 menu->current = ci_first_message ();
2129 @@ -1320,6 +1553,12 @@ int mutt_index_menu (void)
2130 mutt_sb_set_open_buffy ();
2134 + /* mutt_buffy_check() must be done with mail-reader mode! */
2135 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
2136 + (Context && (Context->magic == MUTT_NNTP)) ? IndexNewsHelp : IndexHelp);
2139 mutt_clear_error ();
2140 mutt_buffy_check(1); /* force the buffy check after we have changed
2142 @@ -1397,6 +1636,7 @@ int mutt_index_menu (void)
2146 + CHECK_ACL(MUTT_ACL_WRITE, _("Cannot break thread"));
2148 if ((Sort & SORT_MASK) != SORT_THREADS)
2149 mutt_error _("Threading is not enabled.");
2150 @@ -1432,7 +1672,7 @@ int mutt_index_menu (void)
2153 /* L10N: CHECK_ACL */
2154 - CHECK_ACL(MUTT_ACL_DELETE, _("Cannot link threads"));
2155 + CHECK_ACL(MUTT_ACL_WRITE, _("Cannot link threads"));
2157 if ((Sort & SORT_MASK) != SORT_THREADS)
2158 mutt_error _("Threading is not enabled.");
2159 @@ -2068,6 +2308,20 @@ int mutt_index_menu (void)
2168 + if (Context && Context->magic == MUTT_NNTP)
2170 + NNTP_DATA *nntp_data = Context->data;
2171 + if (mutt_newsgroup_catchup (nntp_data->nserv, nntp_data->group))
2172 + menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
2177 case OP_DISPLAY_ADDRESS:
2180 @@ -2326,6 +2580,39 @@ int mutt_index_menu (void)
2181 menu->redraw = REDRAW_FULL;
2186 + case OP_FORWARD_TO_GROUP:
2194 + if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
2195 + mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
2196 + query_quadoption (OPT_FOLLOWUPTOPOSTER,
2197 + _("Reply by mail as poster prefers?")) != MUTT_YES)
2199 + if (Context && Context->magic == MUTT_NNTP &&
2200 + !((NNTP_DATA *)Context->data)->allowed &&
2201 + query_quadoption (OPT_TOMODERATED,
2202 + _("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES)
2204 + if (op == OP_POST)
2205 + ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
2209 + ci_send_message ((op == OP_FOLLOWUP ? SENDREPLY : SENDFORWARD) |
2210 + SENDNEWS, NULL, NULL, Context, tag ? NULL : CURHDR);
2212 + menu->redraw = REDRAW_FULL;
2220 diff -udprP mutt-1.10.0.orig/doc/manual.xml.head mutt-1.10.0/doc/manual.xml.head
2221 --- mutt-1.10.0.orig/doc/manual.xml.head 2018-05-15 00:51:53.000000000 +0300
2222 +++ mutt-1.10.0/doc/manual.xml.head 2018-06-16 17:22:30.195469715 +0300
2223 @@ -1755,6 +1755,26 @@ See also the <link linkend="postpone">$p
2228 +<title>Reading news via NNTP</title>
2231 +If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can
2232 +read news from news server via NNTP. You can open a newsgroup with
2233 +function ``change-newsgroup'' (default: ``i''). Default news server
2234 +can be obtained from <literal>$NNTPSERVER</literal> environment
2235 +variable or from <literal>/etc/nntpserver</literal> file. Like other
2236 +news readers, info about subscribed newsgroups is saved in file by
2237 +<link linkend="newsrc">$newsrc</link> variable. The variable <link
2238 +linkend="news-cache-dir">$news_cache_dir</link> can be used to point
2239 +to a directory. Mutt will create a hierarchy of subdirectories named
2240 +like the account and newsgroup the cache is for. Also the hierarchy
2241 +is used to store header cache if Mutt was compiled with <link
2242 +linkend="header-caching">header cache</link> support.
2249 <chapter id="configuration">
2250 diff -udprP mutt-1.10.0.orig/doc/mutt.man mutt-1.10.0/doc/mutt.man
2251 --- mutt-1.10.0.orig/doc/mutt.man 2018-05-15 00:51:53.000000000 +0300
2252 +++ mutt-1.10.0/doc/mutt.man 2018-06-16 17:22:30.195469715 +0300
2253 @@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent
2258 -[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2260 +[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-g \fIserver\fP] [\-m \fItype\fP] [\-f \fIfile\fP]
2264 @@ -104,6 +104,10 @@ files.
2265 Specify which mailbox to load.
2266 .IP "-F \fImuttrc\fP"
2267 Specify an initialization file to read instead of ~/.muttrc
2268 +.IP "-g \fIserver\fP"
2269 +Start Mutt with a listing of subscribed newsgroups at specified news server.
2271 +Start Mutt with a listing of subscribed newsgroups.
2274 .IP "-H \fIdraft\fP"
2275 diff -udprP mutt-1.10.0.orig/functions.h mutt-1.10.0/functions.h
2276 --- mutt-1.10.0.orig/functions.h 2018-05-15 00:51:53.000000000 +0300
2277 +++ mutt-1.10.0/functions.h 2018-06-16 17:22:30.195469715 +0300
2278 @@ -89,6 +89,10 @@ const struct binding_t OpMain[] = { /* m
2279 { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
2280 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2281 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2283 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2284 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2286 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2287 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
2288 { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" },
2289 @@ -103,7 +107,15 @@ const struct binding_t OpMain[] = { /* m
2290 { "edit-label", OP_EDIT_LABEL, "Y" },
2291 { "edit-type", OP_EDIT_TYPE, "\005" },
2292 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2293 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2295 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2296 + { "followup-message", OP_FOLLOWUP, "F" },
2297 + { "get-children", OP_GET_CHILDREN, NULL },
2298 + { "get-message", OP_GET_MESSAGE, "\007" },
2299 + { "get-parent", OP_GET_PARENT, "\033G" },
2300 + { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL },
2302 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2303 { "group-reply", OP_GROUP_REPLY, "g" },
2305 { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" },
2306 @@ -131,6 +143,9 @@ const struct binding_t OpMain[] = { /* m
2307 { "sort-mailbox", OP_SORT, "o" },
2308 { "sort-reverse", OP_SORT_REVERSE, "O" },
2309 { "print-message", OP_PRINT, "p" },
2311 + { "post-message", OP_POST, "P" },
2313 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2314 { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" },
2315 { "recall-message", OP_RECALL_MESSAGE, "R" },
2316 @@ -150,6 +165,10 @@ const struct binding_t OpMain[] = { /* m
2317 { "show-version", OP_VERSION, "V" },
2318 { "set-flag", OP_MAIN_SET_FLAG, "w" },
2319 { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" },
2320 + { "toggle-read", OP_TOGGLE_READ, "X" },
2322 + { "catchup", OP_CATCHUP, "y" },
2324 { "display-message", OP_DISPLAY_MESSAGE, MUTT_ENTER_S },
2325 { "mark-message", OP_MARK_MSG, "~" },
2326 { "buffy-list", OP_BUFFY_LIST, "." },
2327 @@ -162,7 +181,7 @@ const struct binding_t OpMain[] = { /* m
2328 { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" },
2329 { "next-unread", OP_MAIN_NEXT_UNREAD, NULL },
2330 { "previous-unread", OP_MAIN_PREV_UNREAD, NULL },
2331 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2332 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2333 { "root-message", OP_MAIN_ROOT_MESSAGE, NULL },
2336 @@ -193,6 +212,10 @@ const struct binding_t OpPager[] = { /*
2337 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2338 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
2339 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
2341 + { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" },
2342 + { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
2344 { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL },
2345 { "copy-message", OP_COPY_MESSAGE, "C" },
2346 { "decode-copy", OP_DECODE_COPY, "\033C" },
2347 @@ -204,8 +227,12 @@ const struct binding_t OpPager[] = { /*
2348 { "edit", OP_EDIT_MESSAGE, "e" },
2349 { "edit-label", OP_EDIT_LABEL, "Y" },
2350 { "edit-type", OP_EDIT_TYPE, "\005" },
2352 + { "followup-message", OP_FOLLOWUP, "F" },
2353 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2355 { "forward-message", OP_FORWARD_MESSAGE, "f" },
2356 - { "flag-message", OP_FLAG_MESSAGE, "F" },
2357 + { "flag-message", OP_FLAG_MESSAGE, "\033f" },
2358 { "group-reply", OP_GROUP_REPLY, "g" },
2360 { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL },
2361 @@ -227,6 +254,9 @@ const struct binding_t OpPager[] = { /*
2362 { "sort-mailbox", OP_SORT, "o" },
2363 { "sort-reverse", OP_SORT_REVERSE, "O" },
2364 { "print-message", OP_PRINT, "p" },
2366 + { "post-message", OP_POST, "P" },
2368 { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
2369 { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
2370 { "purge-message", OP_PURGE_MESSAGE, NULL },
2371 @@ -276,7 +306,7 @@ const struct binding_t OpPager[] = { /*
2372 { "half-down", OP_HALF_DOWN, NULL },
2373 { "previous-line", OP_PREV_LINE, NULL },
2374 { "bottom", OP_PAGER_BOTTOM, NULL },
2375 - { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
2376 + { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL },
2377 { "root-message", OP_MAIN_ROOT_MESSAGE, NULL },
2380 @@ -309,6 +339,10 @@ const struct binding_t OpAttach[] = { /*
2381 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
2382 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
2383 { "edit-type", OP_EDIT_TYPE, "\005" },
2385 + { "followup-message", OP_FOLLOWUP, "F" },
2386 + { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" },
2388 { "print-entry", OP_PRINT, "p" },
2389 { "save-entry", OP_SAVE, "s" },
2390 { "pipe-entry", OP_PIPE, "|" },
2391 @@ -334,6 +368,7 @@ const struct binding_t OpAttach[] = { /*
2392 const struct binding_t OpCompose[] = { /* map: compose */
2393 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" },
2394 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" },
2395 + { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
2396 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" },
2397 { "edit-cc", OP_COMPOSE_EDIT_CC, "c" },
2398 { "copy-file", OP_SAVE, "C" },
2399 @@ -353,6 +388,11 @@ const struct binding_t OpCompose[] = { /
2400 { "print-entry", OP_PRINT, "l" },
2401 { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
2402 { "new-mime", OP_COMPOSE_NEW_MIME, "n" },
2404 + { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" },
2405 + { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" },
2406 + { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" },
2408 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
2409 { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" },
2410 { "rename-attachment",OP_COMPOSE_RENAME_ATTACHMENT, "\017" },
2411 @@ -405,14 +445,25 @@ const struct binding_t OpBrowser[] = { /
2412 { "select-new", OP_BROWSER_NEW_FILE, "N" },
2413 { "check-new", OP_CHECK_NEW, NULL },
2414 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
2416 + { "reload-active", OP_LOAD_ACTIVE, "g" },
2417 + { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
2418 + { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
2419 + { "catchup", OP_CATCHUP, "y" },
2420 + { "uncatchup", OP_UNCATCHUP, "Y" },
2422 { "view-file", OP_BROWSER_VIEW_FILE, " " },
2423 { "buffy-list", OP_BUFFY_LIST, "." },
2425 { "create-mailbox", OP_CREATE_MAILBOX, "C" },
2426 { "delete-mailbox", OP_DELETE_MAILBOX, "d" },
2427 { "rename-mailbox", OP_RENAME_MAILBOX, "r" },
2429 +#if defined USE_IMAP || defined USE_NNTP
2430 { "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
2431 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
2434 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
2437 diff -udprP mutt-1.10.0.orig/globals.h mutt-1.10.0/globals.h
2438 --- mutt-1.10.0.orig/globals.h 2018-05-15 00:51:53.000000000 +0300
2439 +++ mutt-1.10.0/globals.h 2018-06-16 17:22:30.196469699 +0300
2440 @@ -71,7 +71,7 @@ WHERE char *Inbox;
2442 WHERE char *MailcapPath;
2443 WHERE char *Maildir;
2444 -#if defined(USE_IMAP) || defined(USE_POP)
2445 +#if defined(USE_IMAP) || defined(USE_POP) || defined(USE_NNTP)
2446 WHERE char *MessageCachedir;
2449 @@ -99,6 +99,17 @@ WHERE char *MixEntryFormat;
2452 WHERE char *Muttrc INITVAL (NULL);
2454 +WHERE char *GroupFormat;
2456 +WHERE char *NewsCacheDir;
2457 +WHERE char *NewsServer;
2458 +WHERE char *NewsgroupsCharset;
2459 +WHERE char *NewsRc;
2460 +WHERE char *NntpAuthenticators;
2461 +WHERE char *NntpUser;
2462 +WHERE char *NntpPass;
2466 WHERE char *PagerFmt;
2467 @@ -207,6 +218,11 @@ extern unsigned char QuadOptions[];
2469 WHERE unsigned short Counter INITVAL (0);
2472 +WHERE short NewsPollTimeout;
2473 +WHERE short NntpContext;
2476 WHERE short ConnectTimeout;
2477 WHERE short ErrorHistSize;
2478 WHERE short HistSize;
2479 diff -udprP mutt-1.10.0.orig/hcache.c mutt-1.10.0/hcache.c
2480 --- mutt-1.10.0.orig/hcache.c 2017-12-18 22:31:37.000000000 +0200
2481 +++ mutt-1.10.0/hcache.c 2018-06-16 17:22:30.196469699 +0300
2482 @@ -534,6 +534,12 @@ dump_envelope(ENVELOPE * e, unsigned cha
2483 d = dump_list(e->in_reply_to, d, off, 0);
2484 d = dump_list(e->userhdrs, d, off, convert);
2487 + d = dump_char(e->xref, d, off, 0);
2488 + d = dump_char(e->followup_to, d, off, 0);
2489 + d = dump_char(e->x_comment_to, d, off, convert);
2495 @@ -570,6 +576,12 @@ restore_envelope(ENVELOPE * e, const uns
2496 restore_list(&e->references, d, off, 0);
2497 restore_list(&e->in_reply_to, d, off, 0);
2498 restore_list(&e->userhdrs, d, off, convert);
2501 + restore_char(&e->xref, d, off, 0);
2502 + restore_char(&e->followup_to, d, off, 0);
2503 + restore_char(&e->x_comment_to, d, off, convert);
2508 diff -udprP mutt-1.10.0.orig/hdrline.c mutt-1.10.0/hdrline.c
2509 --- mutt-1.10.0.orig/hdrline.c 2018-05-15 00:51:53.000000000 +0300
2510 +++ mutt-1.10.0/hdrline.c 2018-06-16 17:22:30.196469699 +0300
2511 @@ -227,6 +227,7 @@ static char *apply_subject_mods (ENVELOP
2512 * %E = number of messages in current thread
2513 * %f = entire from line
2514 * %F = like %n, unless from self
2515 + * %g = newsgroup name (if compiled with NNTP support)
2517 * %l = number of lines in the message
2518 * %L = like %F, except `lists' are displayed first
2519 @@ -243,6 +244,8 @@ static char *apply_subject_mods (ENVELOP
2521 * %u = user (login) name of author
2522 * %v = first name of author, unless from self
2523 + * %W = where user is (organization)
2524 + * %x = `x-comment-to:' field (if present and compiled with NNTP support)
2525 * %X = number of MIME attachments
2526 * %y = `x-label:' field (if present)
2527 * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
2528 @@ -474,6 +477,12 @@ hdr_format_str (char *dest,
2534 + mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
2539 mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
2541 @@ -678,6 +687,22 @@ hdr_format_str (char *dest,
2542 mutt_format_s (dest, destlen, prefix, buf2);
2547 + mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
2548 + else if (!hdr->env->organization)
2555 + mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : "");
2556 + else if (!hdr->env->x_comment_to)
2564 diff -udprP mutt-1.10.0.orig/headers.c mutt-1.10.0/headers.c
2565 --- mutt-1.10.0.orig/headers.c 2017-12-18 22:31:37.000000000 +0200
2566 +++ mutt-1.10.0/headers.c 2018-06-16 17:22:30.196469699 +0300
2567 @@ -115,6 +115,9 @@ void mutt_edit_headers (const char *edit
2568 $edit_headers set, we remove References: as they're likely invalid;
2569 we can simply compare strings as we don't generate References for
2570 multiple Message-Ids in IRT anyways */
2572 + if (!option (OPTNEWSSEND))
2574 if (msg->env->in_reply_to &&
2575 (!n->in_reply_to || mutt_strcmp (n->in_reply_to->data,
2576 msg->env->in_reply_to->data) != 0))
2577 diff -udprP mutt-1.10.0.orig/init.c mutt-1.10.0/init.c
2578 --- mutt-1.10.0.orig/init.c 2018-05-15 00:51:53.000000000 +0300
2579 +++ mutt-1.10.0/init.c 2018-06-16 17:22:30.197469683 +0300
2580 @@ -3445,6 +3445,28 @@ void mutt_init (int skip_sys_rc, LIST *c
2581 Fqdn = safe_strdup(utsname.nodename);
2589 + if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
2592 + fgets (buffer, sizeof (buffer), f);
2596 + while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
2598 + NewsServer = safe_strdup (p);
2602 + if ((p = getenv ("NNTPSERVER")))
2603 + NewsServer = safe_strdup (p);
2606 if ((p = getenv ("MAIL")))
2607 Spoolfile = safe_strdup (p);
2608 else if ((p = getenv ("MAILDIR")))
2609 diff -udprP mutt-1.10.0.orig/init.h mutt-1.10.0/init.h
2610 --- mutt-1.10.0.orig/init.h 2018-05-15 00:51:53.000000000 +0300
2611 +++ mutt-1.10.0/init.h 2018-06-16 17:29:50.406514947 +0300
2612 @@ -200,6 +200,20 @@ struct option_t MuttVars[] = {
2613 ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before
2614 ** editing the body of an outgoing message.
2617 + { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
2620 + ** If set, Mutt will prompt you for follow-up groups before editing
2621 + ** the body of an outgoing message.
2623 + { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
2626 + ** If set, Mutt will prompt you for x-comment-to field before editing
2627 + ** the body of an outgoing message.
2630 { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0},
2633 @@ -372,6 +386,14 @@ struct option_t MuttVars[] = {
2634 ** doesn't make intuitive sense. In those cases, it may be
2635 ** desirable to \fIunset\fP this variable.
2638 + { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, MUTT_ASKYES },
2641 + ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup
2642 + ** as read when you quit the newsgroup (catchup newsgroup).
2645 #if defined(USE_SSL)
2646 { "certificate_file", DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" },
2648 @@ -926,6 +948,16 @@ struct option_t MuttVars[] = {
2649 ** sent to both the list and your address, resulting in two copies
2650 ** of the same email for you.
2653 + { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, MUTT_ASKYES },
2656 + ** If this variable is \fIset\fP and the keyword "poster" is present in
2657 + ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
2658 + ** permitted. The message will be mailed to the submitter of the
2659 + ** message via mail.
2662 { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 },
2665 @@ -1024,6 +1056,26 @@ struct option_t MuttVars[] = {
2666 ** a regular expression that will match the whole name so mutt will expand
2667 ** ``Franklin'' to ``Franklin, Steve''.
2670 + { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" },
2673 + ** This variable allows you to customize the newsgroup browser display to
2674 + ** your personal taste. This string is similar to ``$index_format'', but
2675 + ** has its own set of printf()-like sequences:
2677 + ** .dt %C .dd current newsgroup number
2678 + ** .dt %d .dd description of newsgroup (becomes from server)
2679 + ** .dt %f .dd newsgroup name
2680 + ** .dt %M .dd - if newsgroup not allowed for direct post (moderated for example)
2681 + ** .dt %N .dd N if newsgroup is new, u if unsubscribed, blank otherwise
2682 + ** .dt %n .dd number of new articles in newsgroup
2683 + ** .dt %s .dd number of unread articles in newsgroup
2684 + ** .dt %>X .dd right justify the rest of the string and pad with character "X"
2685 + ** .dt %|X .dd pad to the end of the line with character "X"
2689 { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
2692 @@ -1445,6 +1497,7 @@ struct option_t MuttVars[] = {
2693 ** .dt %E .dd number of messages in current thread
2694 ** .dt %f .dd sender (address + real name), either From: or Return-Path:
2695 ** .dt %F .dd author name, or recipient name if the message is from you
2696 + ** .dt %g .dd newsgroup name (if compiled with NNTP support)
2697 ** .dt %H .dd spam attribute(s) of this message
2698 ** .dt %i .dd message-id of the current message
2699 ** .dt %l .dd number of lines in the message (does not work with maildir,
2700 @@ -1468,6 +1521,8 @@ struct option_t MuttVars[] = {
2701 ** .dt %T .dd the appropriate character from the $$to_chars string
2702 ** .dt %u .dd user (login) name of the author
2703 ** .dt %v .dd first name of the author, or the recipient if the message is from you
2704 + ** .dt %W .dd name of organization of author (``Organization:'' field)
2705 + ** .dt %x .dd ``X-Comment-To:'' field (if present and compiled with NNTP support)
2706 ** .dt %X .dd number of attachments
2707 ** (please see the ``$attachments'' section for possible speed effects)
2708 ** .dt %y .dd ``X-Label:'' field, if present
2709 @@ -1506,6 +1561,25 @@ struct option_t MuttVars[] = {
2710 ** Note that these expandos are supported in
2711 ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too.
2714 + { "inews", DT_PATH, R_NONE, UL &Inews, UL "" },
2717 + ** If set, specifies the program and arguments used to deliver news posted
2718 + ** by Mutt. Otherwise, mutt posts article using current connection to
2719 + ** news server. The following printf-style sequence is understood:
2721 + ** .dt %a .dd account url
2722 + ** .dt %p .dd port
2723 + ** .dt %P .dd port if specified
2724 + ** .dt %s .dd news server name
2725 + ** .dt %S .dd url schema
2726 + ** .dt %u .dd username
2729 + ** Example: set inews="/usr/local/bin/inews -hS"
2732 { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
2735 @@ -1793,6 +1867,15 @@ struct option_t MuttVars[] = {
2736 ** When \fIset\fP, the $$mime_type_query_command will be run before the
2737 ** mime.types lookup.
2740 + { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
2743 + ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
2744 + ** encoded according to RFC2047 to base64. This is useful when message
2745 + ** is Usenet article, because MIME for news is nonstandard feature.
2749 { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
2751 @@ -1847,6 +1930,106 @@ struct option_t MuttVars[] = {
2752 ** See the $$status_format documentation for the values that can be formatted
2753 ** into this command.
2756 + { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
2759 + ** This variable pointing to directory where Mutt will save cached news
2760 + ** articles and headers in. If \fIunset\fP, articles and headers will not be
2761 + ** saved at all and will be reloaded from the server each time.
2763 + { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 },
2766 + ** This variable specifies domain name or address of NNTP server. It
2767 + ** defaults to the news server specified in the environment variable
2768 + ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also
2769 + ** specify username and an alternative port for each news server, ie:
2771 + ** [[s]news://][username[:password]@]server[:port]
2773 + { "newsgroups_charset", DT_STR, R_NONE, UL &NewsgroupsCharset, UL "utf-8" },
2776 + ** Character set of newsgroups descriptions.
2778 + { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
2781 + ** The file, containing info about subscribed newsgroups - names and
2782 + ** indexes of read articles. The following printf-style sequence
2785 + ** .dt %a .dd account url
2786 + ** .dt %p .dd port
2787 + ** .dt %P .dd port if specified
2788 + ** .dt %s .dd news server name
2789 + ** .dt %S .dd url schema
2790 + ** .dt %u .dd username
2793 + { "nntp_authenticators", DT_STR, R_NONE, UL &NntpAuthenticators, UL 0 },
2796 + ** This is a colon-delimited list of authentication methods mutt may
2797 + ** attempt to use to log in to a news server, in the order mutt should
2798 + ** try them. Authentication methods are either ``user'' or any
2799 + ** SASL mechanism, e.g. ``digest-md5'', ``gssapi'' or ``cram-md5''.
2800 + ** This option is case-insensitive. If it's \fIunset\fP (the default)
2801 + ** mutt will try all available methods, in order from most-secure to
2806 + ** set nntp_authenticators="digest-md5:user"
2809 + ** \fBNote:\fP Mutt will only fall back to other authentication methods if
2810 + ** the previous methods are unavailable. If a method is available but
2811 + ** authentication fails, mutt will not connect to the IMAP server.
2813 + { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 },
2816 + ** This variable defines number of articles which will be in index when
2817 + ** newsgroup entered. If active newsgroup have more articles than this
2818 + ** number, oldest articles will be ignored. Also controls how many
2819 + ** articles headers will be saved in cache when you quit newsgroup.
2821 + { "nntp_listgroup", DT_BOOL, R_NONE, OPTLISTGROUP, 1 },
2824 + ** This variable controls whether or not existence of each article is
2825 + ** checked when newsgroup is entered.
2827 + { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
2830 + ** This variable controls whether or not descriptions for each newsgroup
2831 + ** must be loaded when newsgroup is added to list (first time list
2832 + ** loading or new newsgroup adding).
2834 + { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" },
2837 + ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires
2838 + ** authentification, Mutt will prompt you for your account name when you
2839 + ** connect to news server.
2841 + { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" },
2844 + ** Your password for NNTP account.
2846 + { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 },
2849 + ** The time in seconds until any operations on newsgroup except post new
2850 + ** article will cause recheck for new news. If set to 0, Mutt will
2851 + ** recheck newsgroup on each operation in index (stepping, read article,
2855 { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" },
2858 @@ -2395,6 +2578,16 @@ struct option_t MuttVars[] = {
2859 { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 },
2863 + { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, MUTT_ASKYES },
2866 + ** If set to \fIyes\fP, Mutt will post article to newsgroup that have
2867 + ** not permissions to posting (e.g. moderated). \fBNote:\fP if news server
2868 + ** does not support posting to that newsgroup or totally read-only, that
2869 + ** posting will not have an effect.
2872 { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, MUTT_ASKYES },
2875 @@ -2875,6 +3068,28 @@ struct option_t MuttVars[] = {
2876 ** Command to use when spawning a subshell. By default, the user's login
2877 ** shell from \fC/etc/passwd\fP is used.
2880 + { "save_unsubscribed", DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
2883 + ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
2884 + ** ``newsrc'' file and into cache.
2886 + { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
2889 + ** If \fIset\fP, news server will be asked for new newsgroups on entering
2890 + ** the browser. Otherwise, it will be done only once for a news server.
2891 + ** Also controls whether or not number of new articles of subscribed
2892 + ** newsgroups will be then checked.
2894 + { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
2897 + ** If \fIset\fP, only subscribed newsgroups that contain unread articles
2898 + ** will be displayed in browser.
2902 { "sidebar_delim_chars", DT_STR, R_SIDEBAR, UL &SidebarDelimChars, UL "/." },
2904 @@ -4005,6 +4220,14 @@ struct option_t MuttVars[] = {
2905 {"xterm_set_titles", DT_SYN, R_NONE, UL "ts_enabled", 0 },
2909 + { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
2912 + ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full
2913 + ** name of original article author) to article that followuped to newsgroup.
2917 { NULL, 0, 0, 0, 0 }
2919 diff -udprP mutt-1.10.0.orig/keymap.c mutt-1.10.0/keymap.c
2920 --- mutt-1.10.0.orig/keymap.c 2018-02-03 21:18:49.000000000 +0200
2921 +++ mutt-1.10.0/keymap.c 2018-06-16 17:22:30.198469667 +0300
2922 @@ -800,7 +800,6 @@ void km_init (void)
2923 km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE);
2925 km_bindkey ("x", MENU_PAGER, OP_EXIT);
2926 - km_bindkey ("i", MENU_PAGER, OP_EXIT);
2927 km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE);
2928 km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE);
2929 km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE);
2930 diff -udprP mutt-1.10.0.orig/mailbox.h mutt-1.10.0/mailbox.h
2931 --- mutt-1.10.0.orig/mailbox.h 2017-12-18 22:27:19.000000000 +0200
2932 +++ mutt-1.10.0/mailbox.h 2018-06-16 17:22:30.198469667 +0300
2933 @@ -78,6 +78,9 @@ int mx_is_imap (const char *);
2935 int mx_is_pop (const char *);
2938 +int mx_is_nntp (const char *);
2941 int mx_access (const char*, int);
2942 int mx_check_empty (const char *);
2943 diff -udprP mutt-1.10.0.orig/main.c mutt-1.10.0/main.c
2944 --- mutt-1.10.0.orig/main.c 2018-05-15 00:51:53.000000000 +0300
2945 +++ mutt-1.10.0/main.c 2018-06-16 17:22:30.198469667 +0300
2947 #include <idn/stringprep.h>
2954 static const char *ReachingUs = N_("\
2955 To contact the developers, please mail to <mutt-dev@mutt.org>.\n\
2956 To report a bug, please contact the Mutt maintainers via gitlab:\n\
2957 @@ -145,6 +149,8 @@ options:\n\
2958 -e <command>\tspecify a command to be executed after initialization\n\
2959 -f <file>\tspecify which mailbox to read\n\
2960 -F <file>\tspecify an alternate muttrc file\n\
2961 + -g <server>\tspecify a news server (if compiled with NNTP)\n\
2962 + -G\t\tselect a newsgroup (if compiled with NNTP)\n\
2963 -H <file>\tspecify a draft file to read header and body from\n\
2964 -i <file>\tspecify a file which Mutt should include in the body\n\
2965 -m <type>\tspecify a default mailbox type\n\
2966 @@ -298,6 +304,12 @@ static void show_version (void)
2979 @@ -593,6 +605,7 @@ init_extended_keys();
2980 #define MUTT_NOSYSRC (1<<2) /* -n */
2981 #define MUTT_RO (1<<3) /* -R */
2982 #define MUTT_SELECT (1<<4) /* -y */
2983 +#define MUTT_NEWS (1<<5) /* -g and -G */
2985 int main (int argc, char **argv, char **environ)
2987 @@ -682,7 +695,11 @@ int main (int argc, char **argv, char **
2988 argv[nargc++] = argv[optind];
2992 + if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:Ee:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
2994 if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:Ee:H:s:i:hm:npQ:RvxyzZ")) != EOF)
2999 @@ -783,6 +800,20 @@ int main (int argc, char **argv, char **
3000 flags |= MUTT_SELECT;
3004 + case 'g': /* Specify a news server */
3006 + char buf[LONG_STRING];
3008 + snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
3009 + commands = mutt_add_list (commands, buf);
3012 + case 'G': /* List of newsgroups */
3013 + flags |= MUTT_SELECT | MUTT_NEWS;
3018 flags |= MUTT_IGNORE;
3020 @@ -1229,6 +1260,18 @@ int main (int argc, char **argv, char **
3022 else if (flags & MUTT_SELECT)
3025 + if (flags & MUTT_NEWS)
3027 + set_option (OPTNEWS);
3028 + if(!(CurrentNewsSrv = nntp_select_server (NewsServer, 0)))
3030 + mutt_endwin (Errorbuf);
3037 mutt_endwin _("No incoming mailboxes defined.");
3039 @@ -1244,6 +1287,15 @@ int main (int argc, char **argv, char **
3042 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
3045 + if (option (OPTNEWS))
3047 + unset_option (OPTNEWS);
3048 + nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
3052 mutt_expand_path (folder, sizeof (folder));
3054 mutt_str_replace (&CurrentFolder, folder);
3055 diff -udprP mutt-1.10.0.orig/mutt.h mutt-1.10.0/mutt.h
3056 --- mutt-1.10.0.orig/mutt.h 2018-05-15 00:51:53.000000000 +0300
3057 +++ mutt-1.10.0/mutt.h 2018-06-16 17:23:34.827448604 +0300
3058 @@ -254,6 +254,9 @@ enum
3066 /* Options for Mailcap lookup */
3068 @@ -311,6 +314,11 @@ enum
3071 OPT_VERIFYSIG, /* verify PGP signatures */
3075 + OPT_FOLLOWUPTOPOSTER,
3078 /* THIS MUST BE THE LAST VALUE. */
3080 @@ -329,6 +337,7 @@ enum
3081 #define SENDPOSTPONEDFCC (1<<9) /* used by mutt_get_postponed() to signal that the x-mutt-fcc header field was present */
3082 #define SENDNOFREEHEADER (1<<10) /* Used by the -E flag */
3083 #define SENDDRAFTFILE (1<<11) /* Used by the -H flag */
3084 +#define SENDNEWS (1<<12)
3086 /* flags for mutt_compose_menu() */
3087 #define MUTT_COMPOSE_NOFREEHEADER (1<<0)
3088 @@ -351,6 +360,8 @@ enum
3097 @@ -441,6 +452,9 @@ enum
3102 + OPTMIMESUBJECT, /* encode subject line with RFC2047 */
3104 OPTMIMETYPEQUERYFIRST,
3107 @@ -542,6 +556,17 @@ enum
3111 + /* news options */
3115 + OPTSHOWONLYUNREAD,
3122 /* pseudo options */
3124 OPTAUXSORT, /* (pseudo) using auxiliary sort function */
3125 @@ -559,6 +584,7 @@ enum
3126 OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */
3127 OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */
3128 OPTATTACHMSG, /* (pseudo) used by attach-message */
3129 + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */
3130 OPTKEEPQUIET, /* (pseudo) shut up the message and refresh
3131 * functions while we are executing an
3133 @@ -569,6 +595,11 @@ enum
3134 OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
3135 OPTIGNOREMACROEVENTS, /* (pseudo) don't process macro/push/exec events while set */
3138 + OPTNEWS, /* (pseudo) used to change reader mode */
3139 + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */
3145 @@ -649,6 +680,13 @@ typedef struct envelope
3149 + char *organization;
3153 + char *followup_to;
3154 + char *x_comment_to;
3157 LIST *references; /* message references (in reverse order) */
3158 LIST *in_reply_to; /* in-reply-to header content */
3159 @@ -836,7 +874,7 @@ typedef struct header
3160 int refno; /* message number on server */
3163 -#if defined USE_POP || defined USE_IMAP
3164 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3165 void *data; /* driver-specific data */
3168 diff -udprP mutt-1.10.0.orig/mutt_sasl.c mutt-1.10.0/mutt_sasl.c
3169 --- mutt-1.10.0.orig/mutt_sasl.c 2017-12-18 22:31:37.000000000 +0200
3170 +++ mutt-1.10.0/mutt_sasl.c 2018-06-16 17:22:30.199469651 +0300
3171 @@ -192,6 +192,11 @@ int mutt_sasl_client_new (CONNECTION* co
3172 case MUTT_ACCT_TYPE_SMTP:
3176 + case MUTT_ACCT_TYPE_NNTP:
3181 mutt_error (_("Unknown SASL profile"));
3183 diff -udprP mutt-1.10.0.orig/muttlib.c mutt-1.10.0/muttlib.c
3184 --- mutt-1.10.0.orig/muttlib.c 2018-04-17 02:31:03.000000000 +0300
3185 +++ mutt-1.10.0/muttlib.c 2018-06-16 17:22:30.199469651 +0300
3186 @@ -354,7 +354,7 @@ void mutt_free_header (HEADER **h)
3188 mutt_free_list (&(*h)->chain);
3190 -#if defined USE_POP || defined USE_IMAP
3191 +#if defined USE_POP || defined USE_IMAP || defined USE_NNTP
3194 FREE (h); /* __FREE_CHECKED__ */
3195 @@ -740,6 +740,13 @@ void mutt_free_envelope (ENVELOPE **p)
3196 FREE (&(*p)->supersedes);
3198 FREE (&(*p)->x_label);
3199 + FREE (&(*p)->organization);
3201 + FREE (&(*p)->newsgroups);
3202 + FREE (&(*p)->xref);
3203 + FREE (&(*p)->followup_to);
3204 + FREE (&(*p)->x_comment_to);
3207 mutt_buffer_free (&(*p)->spam);
3209 @@ -1663,6 +1670,14 @@ int mutt_save_confirm (const char *s, st
3214 + if (magic == MUTT_NNTP)
3216 + mutt_error _("Can't save message to news server.");
3221 if (stat (s, st) != -1)
3224 diff -udprP mutt-1.10.0.orig/mx.c mutt-1.10.0/mx.c
3225 --- mutt-1.10.0.orig/mx.c 2018-04-17 02:31:03.000000000 +0300
3226 +++ mutt-1.10.0/mx.c 2018-06-16 17:22:30.199469651 +0300
3238 @@ -88,6 +92,10 @@ struct mx_ops* mx_get_ops (int magic)
3239 case MUTT_COMPRESSED:
3240 return &mx_comp_ops;
3244 + return &mx_nntp_ops;
3249 @@ -378,6 +386,22 @@ int mx_is_pop (const char *p)
3254 +int mx_is_nntp (const char *p)
3256 + url_scheme_t scheme;
3261 + scheme = url_check_scheme (p);
3262 + if (scheme == U_NNTP || scheme == U_NNTPS)
3269 int mx_get_magic (const char *path)
3272 @@ -395,6 +419,11 @@ int mx_get_magic (const char *path)
3274 #endif /* USE_POP */
3277 + if (mx_is_nntp (path))
3279 +#endif /* USE_NNTP */
3281 if (stat (path, &st) == -1)
3283 dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
3284 @@ -803,6 +832,25 @@ int mx_close_mailbox (CONTEXT *ctx, int
3289 + if (ctx->unread && ctx->magic == MUTT_NNTP)
3291 + NNTP_DATA *nntp_data = ctx->data;
3293 + if (nntp_data && nntp_data->nserv && nntp_data->group)
3295 + int rc = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
3301 + else if (rc == MUTT_YES)
3302 + mutt_newsgroup_catchup (nntp_data->nserv, nntp_data->group);
3307 for (i = 0; i < ctx->msgcount; i++)
3309 if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read
3310 @@ -810,6 +858,12 @@ int mx_close_mailbox (CONTEXT *ctx, int
3315 + /* don't need to move articles from newsgroup */
3316 + if (ctx->magic == MUTT_NNTP)
3320 if (read_msgs && quadoption (OPT_MOVE) != MUTT_NO)
3323 diff -udprP mutt-1.10.0.orig/mx.h mutt-1.10.0/mx.h
3324 --- mutt-1.10.0.orig/mx.h 2017-12-18 22:31:37.000000000 +0200
3325 +++ mutt-1.10.0/mx.h 2018-06-16 17:22:30.199469651 +0300
3326 @@ -35,6 +35,9 @@ enum
3335 #ifdef USE_COMPRESSED
3336 diff -udprP mutt-1.10.0.orig/newsrc.c mutt-1.10.0/newsrc.c
3337 --- mutt-1.10.0.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300
3338 +++ mutt-1.10.0/newsrc.c 2018-06-16 17:22:30.200469636 +0300
3341 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3342 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
3343 + * Copyright (C) 2000-2017 Vsevolod Volkov <vvv@mutt.org.ua>
3345 + * This program is free software; you can redistribute it and/or modify
3346 + * it under the terms of the GNU General Public License as published by
3347 + * the Free Software Foundation; either version 2 of the License, or
3348 + * (at your option) any later version.
3350 + * This program is distributed in the hope that it will be useful,
3351 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3352 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3353 + * GNU General Public License for more details.
3355 + * You should have received a copy of the GNU General Public License
3356 + * along with this program; if not, write to the Free Software
3357 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3361 +#include "config.h"
3365 +#include "mutt_curses.h"
3369 +#include "mailbox.h"
3371 +#include "rfc822.h"
3372 +#include "rfc1524.h"
3373 +#include "rfc2047.h"
3374 +#include "bcache.h"
3377 +#include "hcache.h"
3380 +#include <unistd.h>
3381 +#include <string.h>
3383 +#include <stdlib.h>
3384 +#include <sys/stat.h>
3385 +#include <sys/types.h>
3386 +#include <dirent.h>
3389 +/* Find NNTP_DATA for given newsgroup or add it */
3390 +static NNTP_DATA *nntp_data_find (NNTP_SERVER *nserv, const char *group)
3392 + NNTP_DATA *nntp_data = hash_find (nserv->groups_hash, group);
3396 + /* create NNTP_DATA structure and add it to hash */
3397 + nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
3398 + nntp_data->group = (char *)nntp_data + sizeof (NNTP_DATA);
3399 + strcpy (nntp_data->group, group);
3400 + nntp_data->nserv = nserv;
3401 + nntp_data->deleted = 1;
3402 + hash_insert (nserv->groups_hash, nntp_data->group, nntp_data);
3404 + /* add NNTP_DATA to list */
3405 + if (nserv->groups_num >= nserv->groups_max)
3407 + nserv->groups_max *= 2;
3408 + safe_realloc (&nserv->groups_list,
3409 + nserv->groups_max * sizeof (nntp_data));
3411 + nserv->groups_list[nserv->groups_num++] = nntp_data;
3416 +/* Remove all temporarily cache files */
3417 +void nntp_acache_free (NNTP_DATA *nntp_data)
3421 + for (i = 0; i < NNTP_ACACHE_LEN; i++)
3423 + if (nntp_data->acache[i].path)
3425 + unlink (nntp_data->acache[i].path);
3426 + FREE (&nntp_data->acache[i].path);
3431 +/* Free NNTP_DATA, used to destroy hash elements */
3432 +void nntp_data_free (void *data)
3434 + NNTP_DATA *nntp_data = data;
3438 + nntp_acache_free (nntp_data);
3439 + mutt_bcache_close (&nntp_data->bcache);
3440 + FREE (&nntp_data->newsrc_ent);
3441 + FREE (&nntp_data->desc);
3445 +/* Unlock and close .newsrc file */
3446 +void nntp_newsrc_close (NNTP_SERVER *nserv)
3448 + if (!nserv->newsrc_fp)
3451 + dprint (1, (debugfile, "Unlocking %s\n", nserv->newsrc_file));
3452 + mx_unlock_file (nserv->newsrc_file, fileno (nserv->newsrc_fp), 0);
3453 + safe_fclose (&nserv->newsrc_fp);
3456 +/* Parse .newsrc file:
3460 +int nntp_newsrc_parse (NNTP_SERVER *nserv)
3466 + /* if file doesn't exist, create it */
3467 + nserv->newsrc_fp = safe_fopen (nserv->newsrc_file, "a");
3468 + safe_fclose (&nserv->newsrc_fp);
3470 + /* open .newsrc */
3471 + nserv->newsrc_fp = safe_fopen (nserv->newsrc_file, "r");
3472 + if (!nserv->newsrc_fp)
3474 + mutt_perror (nserv->newsrc_file);
3480 + dprint (1, (debugfile, "Locking %s\n", nserv->newsrc_file));
3481 + if (mx_lock_file (nserv->newsrc_file, fileno (nserv->newsrc_fp), 0, 0, 1))
3483 + safe_fclose (&nserv->newsrc_fp);
3487 + if (stat (nserv->newsrc_file, &sb))
3489 + mutt_perror (nserv->newsrc_file);
3490 + nntp_newsrc_close (nserv);
3495 + if (nserv->size == sb.st_size && nserv->mtime == sb.st_mtime)
3498 + nserv->size = sb.st_size;
3499 + nserv->mtime = sb.st_mtime;
3500 + nserv->newsrc_modified = 1;
3501 + dprint (1, (debugfile, "Parsing %s\n", nserv->newsrc_file));
3503 + /* .newsrc has been externally modified or hasn't been loaded yet */
3504 + for (i = 0; i < nserv->groups_num; i++)
3506 + NNTP_DATA *nntp_data = nserv->groups_list[i];
3511 + nntp_data->subscribed = 0;
3512 + nntp_data->newsrc_len = 0;
3513 + FREE (&nntp_data->newsrc_ent);
3516 + line = safe_malloc (sb.st_size + 1);
3517 + while (sb.st_size && fgets (line, sb.st_size + 1, nserv->newsrc_fp))
3520 + unsigned int subs = 0, i = 1;
3521 + NNTP_DATA *nntp_data;
3523 + /* find end of newsgroup name */
3524 + p = strpbrk (line, ":!");
3528 + /* ":" - subscribed, "!" - unsubscribed */
3533 + /* get newsgroup data */
3534 + nntp_data = nntp_data_find (nserv, line);
3535 + FREE (&nntp_data->newsrc_ent);
3537 + /* count number of entries */
3542 + nntp_data->newsrc_ent = safe_calloc (i, sizeof (NEWSRC_ENTRY));
3543 + nntp_data->subscribed = subs;
3545 + /* parse entries */
3551 + /* find end of entry */
3552 + p = strchr (p, ',');
3556 + /* first-last or single number */
3557 + h = strchr (b, '-');
3563 + if (sscanf (b, ANUM, &nntp_data->newsrc_ent[i].first) == 1 &&
3564 + sscanf (h, ANUM, &nntp_data->newsrc_ent[i].last) == 1)
3569 + nntp_data->newsrc_ent[i].first = 1;
3570 + nntp_data->newsrc_ent[i].last = 0;
3573 + if (nntp_data->lastMessage == 0)
3574 + nntp_data->lastMessage = nntp_data->newsrc_ent[i - 1].last;
3575 + nntp_data->newsrc_len = i;
3576 + safe_realloc (&nntp_data->newsrc_ent, i * sizeof (NEWSRC_ENTRY));
3577 + nntp_group_unread_stat (nntp_data);
3578 + dprint (2, (debugfile, "nntp_newsrc_parse: %s\n", nntp_data->group));
3584 +/* Generate array of .newsrc entries */
3585 +void nntp_newsrc_gen_entries (CONTEXT *ctx)
3587 + NNTP_DATA *nntp_data = ctx->data;
3588 + anum_t last = 0, first = 1;
3590 + int save_sort = SORT_ORDER;
3591 + unsigned int entries;
3593 + if (Sort != SORT_ORDER)
3596 + Sort = SORT_ORDER;
3597 + mutt_sort_headers (ctx, 0);
3600 + entries = nntp_data->newsrc_len;
3604 + nntp_data->newsrc_ent = safe_calloc (entries, sizeof (NEWSRC_ENTRY));
3607 + /* Set up to fake initial sequence from 1 to the article before the
3608 + * first article in our list */
3609 + nntp_data->newsrc_len = 0;
3611 + for (i = 0; i < ctx->msgcount; i++)
3613 + /* search for first unread */
3616 + /* We don't actually check sequential order, since we mark
3617 + * "missing" entries as read/deleted */
3618 + last = NHDR (ctx->hdrs[i])->article_num;
3619 + if (last >= nntp_data->firstMessage && !ctx->hdrs[i]->deleted &&
3620 + !ctx->hdrs[i]->read)
3622 + if (nntp_data->newsrc_len >= entries)
3625 + safe_realloc (&nntp_data->newsrc_ent, entries * sizeof (NEWSRC_ENTRY));
3627 + nntp_data->newsrc_ent[nntp_data->newsrc_len].first = first;
3628 + nntp_data->newsrc_ent[nntp_data->newsrc_len].last = last - 1;
3629 + nntp_data->newsrc_len++;
3634 + /* search for first read */
3637 + if (ctx->hdrs[i]->deleted || ctx->hdrs[i]->read)
3642 + last = NHDR (ctx->hdrs[i])->article_num;
3646 + if (series && first <= nntp_data->lastLoaded)
3648 + if (nntp_data->newsrc_len >= entries)
3651 + safe_realloc (&nntp_data->newsrc_ent, entries * sizeof (NEWSRC_ENTRY));
3653 + nntp_data->newsrc_ent[nntp_data->newsrc_len].first = first;
3654 + nntp_data->newsrc_ent[nntp_data->newsrc_len].last = nntp_data->lastLoaded;
3655 + nntp_data->newsrc_len++;
3657 + safe_realloc (&nntp_data->newsrc_ent,
3658 + nntp_data->newsrc_len * sizeof (NEWSRC_ENTRY));
3660 + if (save_sort != Sort)
3663 + mutt_sort_headers (ctx, 0);
3667 +/* Update file with new contents */
3668 +static int update_file (char *filename, char *buf)
3671 + char tmpfile[_POSIX_PATH_MAX];
3676 + snprintf (tmpfile, sizeof (tmpfile), "%s.tmp", filename);
3677 + fp = fopen (tmpfile, "w");
3680 + mutt_perror (tmpfile);
3684 + if (fputs (buf, fp) == EOF)
3686 + mutt_perror (tmpfile);
3689 + if (fclose (fp) == EOF)
3691 + mutt_perror (tmpfile);
3696 + if (rename (tmpfile, filename) < 0)
3698 + mutt_perror (filename);
3714 +/* Update .newsrc file */
3715 +int nntp_newsrc_update (NNTP_SERVER *nserv)
3718 + size_t buflen, off;
3725 + buflen = 10 * LONG_STRING;
3726 + buf = safe_calloc (1, buflen);
3729 + /* we will generate full newsrc here */
3730 + for (i = 0; i < nserv->groups_num; i++)
3732 + NNTP_DATA *nntp_data = nserv->groups_list[i];
3735 + if (!nntp_data || !nntp_data->newsrc_ent)
3738 + /* write newsgroup name */
3739 + if (off + strlen (nntp_data->group) + 3 > buflen)
3742 + safe_realloc (&buf, buflen);
3744 + snprintf (buf + off, buflen - off, "%s%c ", nntp_data->group,
3745 + nntp_data->subscribed ? ':' : '!');
3746 + off += strlen (buf + off);
3748 + /* write entries */
3749 + for (n = 0; n < nntp_data->newsrc_len; n++)
3751 + if (off + LONG_STRING > buflen)
3754 + safe_realloc (&buf, buflen);
3758 + if (nntp_data->newsrc_ent[n].first == nntp_data->newsrc_ent[n].last)
3759 + snprintf (buf + off, buflen - off, "%d", nntp_data->newsrc_ent[n].first);
3760 + else if (nntp_data->newsrc_ent[n].first < nntp_data->newsrc_ent[n].last)
3761 + snprintf (buf + off, buflen - off, "%d-%d",
3762 + nntp_data->newsrc_ent[n].first, nntp_data->newsrc_ent[n].last);
3763 + off += strlen (buf + off);
3765 + buf[off++] = '\n';
3769 + /* newrc being fully rewritten */
3770 + dprint (1, (debugfile, "Updating %s\n", nserv->newsrc_file));
3771 + if (nserv->newsrc_file && update_file (nserv->newsrc_file, buf) == 0)
3775 + rc = stat (nserv->newsrc_file, &sb);
3778 + nserv->size = sb.st_size;
3779 + nserv->mtime = sb.st_mtime;
3783 + mutt_perror (nserv->newsrc_file);
3791 +/* Make fully qualified cache file name */
3792 +static void cache_expand (char *dst, size_t dstlen, ACCOUNT *acct, char *src)
3795 + char file[_POSIX_PATH_MAX];
3797 + /* server subdirectory */
3802 + mutt_account_tourl (acct, &url);
3804 + url_ciss_tostring (&url, file, sizeof (file), U_PATH);
3807 + strfcpy (file, src ? src : "", sizeof (file));
3809 + snprintf (dst, dstlen, "%s/%s", NewsCacheDir, file);
3811 + /* remove trailing slash */
3812 + c = dst + strlen (dst) - 1;
3815 + mutt_expand_path (dst, dstlen);
3818 +/* Make fully qualified url from newsgroup name */
3819 +void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
3823 + url.path = safe_strdup (line);
3824 + mutt_account_tourl (acct, &url);
3825 + url_ciss_tostring (&url, line, len, 0);
3829 +/* Parse newsgroup */
3830 +int nntp_add_group (char *line, void *data)
3832 + NNTP_SERVER *nserv = data;
3833 + NNTP_DATA *nntp_data;
3834 + char group[LONG_STRING];
3835 + char desc[HUGE_STRING] = "";
3837 + anum_t first, last;
3839 + if (!nserv || !line)
3842 + if (sscanf (line, "%s " ANUM " " ANUM " %c %[^\n]", group,
3843 + &last, &first, &mod, desc) < 4)
3846 + nntp_data = nntp_data_find (nserv, group);
3847 + nntp_data->deleted = 0;
3848 + nntp_data->firstMessage = first;
3849 + nntp_data->lastMessage = last;
3850 + nntp_data->allowed = mod == 'y' || mod == 'm' ? 1 : 0;
3851 + mutt_str_replace (&nntp_data->desc, desc);
3852 + if (nntp_data->newsrc_ent || nntp_data->lastCached)
3853 + nntp_group_unread_stat (nntp_data);
3854 + else if (nntp_data->lastMessage &&
3855 + nntp_data->firstMessage <= nntp_data->lastMessage)
3856 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
3858 + nntp_data->unread = 0;
3862 +/* Load list of all newsgroups from cache */
3863 +static int active_get_cache (NNTP_SERVER *nserv)
3865 + char buf[HUGE_STRING];
3866 + char file[_POSIX_PATH_MAX];
3870 + cache_expand (file, sizeof (file), &nserv->conn->account, ".active");
3871 + dprint (1, (debugfile, "Parsing %s\n", file));
3872 + fp = safe_fopen (file, "r");
3876 + if (fgets (buf, sizeof (buf), fp) == NULL ||
3877 + sscanf (buf, "%ld%s", &t, file) != 1 || t == 0)
3882 + nserv->newgroups_time = t;
3884 + mutt_message _("Loading list of groups from cache...");
3885 + while (fgets (buf, sizeof (buf), fp))
3886 + nntp_add_group (buf, nserv);
3887 + nntp_add_group (NULL, NULL);
3889 + mutt_clear_error ();
3893 +/* Save list of all newsgroups to cache */
3894 +int nntp_active_save_cache (NNTP_SERVER *nserv)
3896 + char file[_POSIX_PATH_MAX];
3898 + size_t buflen, off;
3902 + if (!nserv->cacheable)
3905 + buflen = 10 * LONG_STRING;
3906 + buf = safe_calloc (1, buflen);
3907 + snprintf (buf, buflen, "%lu\n", (unsigned long)nserv->newgroups_time);
3908 + off = strlen (buf);
3910 + for (i = 0; i < nserv->groups_num; i++)
3912 + NNTP_DATA *nntp_data = nserv->groups_list[i];
3914 + if (!nntp_data || nntp_data->deleted)
3917 + if (off + strlen (nntp_data->group) +
3918 + (nntp_data->desc ? strlen (nntp_data->desc) : 0) + 50 > buflen)
3921 + safe_realloc (&buf, buflen);
3923 + snprintf (buf + off, buflen - off, "%s %d %d %c%s%s\n", nntp_data->group,
3924 + nntp_data->lastMessage, nntp_data->firstMessage,
3925 + nntp_data->allowed ? 'y' : 'n', nntp_data->desc ? " " : "",
3926 + nntp_data->desc ? nntp_data->desc : "");
3927 + off += strlen (buf + off);
3930 + cache_expand (file, sizeof (file), &nserv->conn->account, ".active");
3931 + dprint (1, (debugfile, "Updating %s\n", file));
3932 + rc = update_file (file, buf);
3938 +/* Used by mutt_hcache_open() to compose hcache file name */
3939 +static int nntp_hcache_namer (const char *path, char *dest, size_t destlen)
3941 + return snprintf (dest, destlen, "%s.hcache", path);
3944 +/* Open newsgroup hcache */
3945 +header_cache_t *nntp_hcache_open (NNTP_DATA *nntp_data)
3948 + char file[_POSIX_PATH_MAX];
3950 + if (!nntp_data->nserv || !nntp_data->nserv->cacheable ||
3951 + !nntp_data->nserv->conn || !nntp_data->group ||
3952 + !(nntp_data->newsrc_ent || nntp_data->subscribed ||
3953 + option (OPTSAVEUNSUB)))
3956 + mutt_account_tourl (&nntp_data->nserv->conn->account, &url);
3957 + url.path = nntp_data->group;
3958 + url_ciss_tostring (&url, file, sizeof (file), U_PATH);
3959 + return mutt_hcache_open (NewsCacheDir, file, nntp_hcache_namer);
3962 +/* Remove stale cached headers */
3963 +void nntp_hcache_update (NNTP_DATA *nntp_data, header_cache_t *hc)
3968 + anum_t first, last, current;
3973 + /* fetch previous values of first and last */
3974 + hdata = mutt_hcache_fetch_raw (hc, "index", strlen);
3977 + dprint (2, (debugfile,
3978 + "nntp_hcache_update: mutt_hcache_fetch index: %s\n", hdata));
3979 + if (sscanf (hdata, ANUM " " ANUM, &first, &last) == 2)
3982 + nntp_data->lastCached = last;
3984 + /* clean removed headers from cache */
3985 + for (current = first; current <= last; current++)
3987 + if (current >= nntp_data->firstMessage &&
3988 + current <= nntp_data->lastMessage)
3991 + snprintf (buf, sizeof (buf), "%d", current);
3992 + dprint (2, (debugfile,
3993 + "nntp_hcache_update: mutt_hcache_delete %s\n", buf));
3994 + mutt_hcache_delete (hc, buf, strlen);
4000 + /* store current values of first and last */
4001 + if (!old || nntp_data->firstMessage != first ||
4002 + nntp_data->lastMessage != last)
4004 + snprintf (buf, sizeof (buf), "%u %u", nntp_data->firstMessage,
4005 + nntp_data->lastMessage);
4006 + dprint (2, (debugfile,
4007 + "nntp_hcache_update: mutt_hcache_store index: %s\n", buf));
4008 + mutt_hcache_store_raw (hc, "index", buf, strlen (buf) + 1, strlen);
4013 +/* Remove bcache file */
4014 +static int nntp_bcache_delete (const char *id, body_cache_t *bcache, void *data)
4016 + NNTP_DATA *nntp_data = data;
4020 + if (!nntp_data || sscanf (id, ANUM "%c", &anum, &c) != 1 ||
4021 + anum < nntp_data->firstMessage || anum > nntp_data->lastMessage)
4024 + dprint (2, (debugfile, "nntp_bcache_delete: mutt_bcache_del %s\n", id));
4025 + mutt_bcache_del (bcache, id);
4030 +/* Remove stale cached messages */
4031 +void nntp_bcache_update (NNTP_DATA *nntp_data)
4033 + mutt_bcache_list (nntp_data->bcache, nntp_bcache_delete, nntp_data);
4036 +/* Remove hcache and bcache of newsgroup */
4037 +void nntp_delete_group_cache (NNTP_DATA *nntp_data)
4039 + char file[_POSIX_PATH_MAX];
4041 + if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->cacheable)
4045 + nntp_hcache_namer (nntp_data->group, file, sizeof (file));
4046 + cache_expand (file, sizeof (file), &nntp_data->nserv->conn->account, file);
4048 + nntp_data->lastCached = 0;
4049 + dprint (2, (debugfile, "nntp_delete_group_cache: %s\n", file));
4052 + if (!nntp_data->bcache)
4053 + nntp_data->bcache = mutt_bcache_open (&nntp_data->nserv->conn->account,
4054 + nntp_data->group);
4055 + if (nntp_data->bcache)
4057 + dprint (2, (debugfile, "nntp_delete_group_cache: %s/*\n", nntp_data->group));
4058 + mutt_bcache_list (nntp_data->bcache, nntp_bcache_delete, NULL);
4059 + mutt_bcache_close (&nntp_data->bcache);
4063 +/* Remove hcache and bcache of all unexistent and unsubscribed newsgroups */
4064 +void nntp_clear_cache (NNTP_SERVER *nserv)
4066 + char file[_POSIX_PATH_MAX];
4068 + struct dirent *entry;
4071 + if (!nserv || !nserv->cacheable)
4074 + cache_expand (file, sizeof (file), &nserv->conn->account, NULL);
4075 + dp = opendir (file);
4078 + safe_strncat (file, sizeof (file), "/", 1);
4079 + fp = file + strlen (file);
4080 + while ((entry = readdir (dp)))
4082 + char *group = entry->d_name;
4084 + NNTP_DATA *nntp_data;
4085 + NNTP_DATA nntp_tmp;
4087 + if (mutt_strcmp (group, ".") == 0 ||
4088 + mutt_strcmp (group, "..") == 0)
4091 + safe_strncat (file, sizeof (file), group, strlen (group));
4092 + if (stat (file, &sb))
4096 + if (S_ISREG (sb.st_mode))
4098 + char *ext = group + strlen (group) - 7;
4099 + if (strlen (group) < 8 || mutt_strcmp (ext, ".hcache"))
4105 + if (!S_ISDIR (sb.st_mode))
4108 + nntp_data = hash_find (nserv->groups_hash, group);
4111 + nntp_data = &nntp_tmp;
4112 + nntp_data->nserv = nserv;
4113 + nntp_data->group = group;
4114 + nntp_data->bcache = NULL;
4116 + else if (nntp_data->newsrc_ent || nntp_data->subscribed ||
4117 + option (OPTSAVEUNSUB))
4120 + nntp_delete_group_cache (nntp_data);
4121 + if (S_ISDIR (sb.st_mode))
4124 + dprint (2, (debugfile, "nntp_clear_cache: %s\n", file));
4132 +/* %a = account url
4134 + * %P = port if specified
4135 + * %s = news server name
4137 + * %u = username */
4139 +nntp_format_str (char *dest, size_t destlen, size_t col, int cols, char op,
4140 + const char *src, const char *fmt, const char *ifstring,
4141 + const char *elsestring, unsigned long data, format_flag flags)
4143 + NNTP_SERVER *nserv = (NNTP_SERVER *)data;
4144 + ACCOUNT *acct = &nserv->conn->account;
4146 + char fn[SHORT_STRING], tmp[SHORT_STRING], *p;
4151 + mutt_account_tourl (acct, &url);
4152 + url_ciss_tostring (&url, fn, sizeof (fn), U_PATH);
4153 + p = strchr (fn, '/');
4156 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
4157 + snprintf (dest, destlen, tmp, fn);
4160 + snprintf (tmp, sizeof (tmp), "%%%su", fmt);
4161 + snprintf (dest, destlen, tmp, acct->port);
4165 + if (acct->flags & MUTT_ACCT_PORT)
4167 + snprintf (tmp, sizeof (tmp), "%%%su", fmt);
4168 + snprintf (dest, destlen, tmp, acct->port);
4172 + strncpy (fn, acct->host, sizeof (fn) - 1);
4173 + mutt_strlower (fn);
4174 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
4175 + snprintf (dest, destlen, tmp, fn);
4178 + mutt_account_tourl (acct, &url);
4179 + url_ciss_tostring (&url, fn, sizeof (fn), U_PATH);
4180 + p = strchr (fn, ':');
4183 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
4184 + snprintf (dest, destlen, tmp, fn);
4187 + snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
4188 + snprintf (dest, destlen, tmp, acct->user);
4194 +/* Automatically loads a newsrc into memory, if necessary.
4195 + * Checks the size/mtime of a newsrc file, if it doesn't match, load
4196 + * again. Hmm, if a system has broken mtimes, this might mean the file
4197 + * is reloaded every time, which we'd have to fix. */
4198 +NNTP_SERVER *nntp_select_server (char *server, int leave_lock)
4200 + char file[_POSIX_PATH_MAX];
4205 + NNTP_SERVER *nserv;
4206 + NNTP_DATA *nntp_data;
4210 + if (!server || !*server)
4212 + mutt_error _("No news server defined!");
4217 + /* create account from news server url */
4219 + acct.port = NNTP_PORT;
4220 + acct.type = MUTT_ACCT_TYPE_NNTP;
4221 + snprintf (file, sizeof (file), "%s%s",
4222 + strstr (server, "://") ? "" : "news://", server);
4223 + if (url_parse_ciss (&url, file) < 0 ||
4224 + (url.path && *url.path) ||
4225 + !(url.scheme == U_NNTP || url.scheme == U_NNTPS) ||
4226 + mutt_account_fromurl (&acct, &url) < 0)
4228 + mutt_error (_("%s is an invalid news server specification!"), server);
4232 + if (url.scheme == U_NNTPS)
4234 + acct.flags |= MUTT_ACCT_SSL;
4235 + acct.port = NNTP_SSL_PORT;
4238 + /* find connection by account */
4239 + conn = mutt_conn_find (NULL, &acct);
4242 + if (!(conn->account.flags & MUTT_ACCT_USER) && acct.flags & MUTT_ACCT_USER)
4244 + conn->account.flags |= MUTT_ACCT_USER;
4245 + conn->account.user[0] = '\0';
4248 + /* news server already exists */
4249 + nserv = conn->data;
4252 + if (nserv->status == NNTP_BYE)
4253 + nserv->status = NNTP_NONE;
4254 + if (nntp_open_connection (nserv) < 0)
4257 + rc = nntp_newsrc_parse (nserv);
4261 + /* check for new newsgroups */
4262 + if (!leave_lock && nntp_check_new_groups (nserv) < 0)
4265 + /* .newsrc has been externally modified */
4267 + nntp_clear_cache (nserv);
4268 + if (rc < 0 || !leave_lock)
4269 + nntp_newsrc_close (nserv);
4270 + return rc < 0 ? NULL : nserv;
4273 + /* new news server */
4274 + nserv = safe_calloc (1, sizeof (NNTP_SERVER));
4275 + nserv->conn = conn;
4276 + nserv->groups_hash = hash_create (1009, 0);
4277 + nserv->groups_max = 16;
4278 + nserv->groups_list = safe_malloc (nserv->groups_max * sizeof (nntp_data));
4280 + rc = nntp_open_connection (nserv);
4282 + /* try to create cache directory and enable caching */
4283 + nserv->cacheable = 0;
4284 + if (rc >= 0 && NewsCacheDir && *NewsCacheDir)
4286 + cache_expand (file, sizeof (file), &conn->account, NULL);
4287 + p = *file == '/' ? file + 1 : file;
4290 + p = strchr (p, '/');
4293 + if ((stat (file, &sb) || (sb.st_mode & S_IFDIR) == 0) &&
4294 + mkdir (file, 0700))
4296 + mutt_error (_("Can't create %s: %s."), file, strerror (errno));
4302 + nserv->cacheable = 1;
4309 + /* load .newsrc */
4312 + mutt_FormatString (file, sizeof (file), 0, sizeof (file), NONULL (NewsRc),
4313 + nntp_format_str, (unsigned long)nserv, 0);
4314 + mutt_expand_path (file, sizeof (file));
4315 + nserv->newsrc_file = safe_strdup (file);
4316 + rc = nntp_newsrc_parse (nserv);
4320 + /* try to load list of newsgroups from cache */
4321 + if (nserv->cacheable && active_get_cache (nserv) == 0)
4322 + rc = nntp_check_new_groups (nserv);
4324 + /* load list of newsgroups from server */
4326 + rc = nntp_active_fetch (nserv, 0);
4330 + nntp_clear_cache (nserv);
4333 + /* check cache files */
4334 + if (rc >= 0 && nserv->cacheable)
4336 + struct dirent *entry;
4337 + DIR *dp = opendir (file);
4341 + while ((entry = readdir (dp)))
4343 + header_cache_t *hc;
4345 + char *group = entry->d_name;
4347 + p = group + strlen (group) - 7;
4348 + if (strlen (group) < 8 || strcmp (p, ".hcache"))
4351 + nntp_data = hash_find (nserv->groups_hash, group);
4355 + hc = nntp_hcache_open (nntp_data);
4359 + /* fetch previous values of first and last */
4360 + hdata = mutt_hcache_fetch_raw (hc, "index", strlen);
4363 + anum_t first, last;
4365 + if (sscanf (hdata, ANUM " " ANUM, &first, &last) == 2)
4367 + if (nntp_data->deleted)
4369 + nntp_data->firstMessage = first;
4370 + nntp_data->lastMessage = last;
4372 + if (last >= nntp_data->firstMessage &&
4373 + last <= nntp_data->lastMessage)
4375 + nntp_data->lastCached = last;
4376 + dprint (2, (debugfile, "nntp_select_server: %s lastCached=%u\n",
4377 + nntp_data->group, last));
4382 + mutt_hcache_close (hc);
4389 + if (rc < 0 || !leave_lock)
4390 + nntp_newsrc_close (nserv);
4394 + hash_destroy (&nserv->groups_hash, nntp_data_free);
4395 + FREE (&nserv->groups_list);
4396 + FREE (&nserv->newsrc_file);
4397 + FREE (&nserv->authenticators);
4399 + mutt_socket_close (conn);
4400 + mutt_socket_free (conn);
4404 + conn->data = nserv;
4408 +/* Full status flags are not supported by nntp, but we can fake some of them:
4409 + * Read = a read message number is in the .newsrc
4410 + * New = not read and not cached
4411 + * Old = not read but cached */
4412 +void nntp_article_status (CONTEXT *ctx, HEADER *hdr, char *group, anum_t anum)
4414 + NNTP_DATA *nntp_data = ctx->data;
4418 + nntp_data = hash_find (nntp_data->nserv->groups_hash, group);
4423 + for (i = 0; i < nntp_data->newsrc_len; i++)
4425 + if ((anum >= nntp_data->newsrc_ent[i].first) &&
4426 + (anum <= nntp_data->newsrc_ent[i].last))
4428 + /* can't use mutt_set_flag() because mx_update_context()
4429 + didn't called yet */
4435 + /* article was not cached yet, it's new */
4436 + if (anum > nntp_data->lastCached)
4439 + /* article isn't read but cached, it's old */
4440 + if (option (OPTMARKOLD))
4444 +/* calculate number of unread articles using .newsrc data */
4445 +void nntp_group_unread_stat (NNTP_DATA *nntp_data)
4448 + anum_t first, last;
4450 + nntp_data->unread = 0;
4451 + if (nntp_data->lastMessage == 0 ||
4452 + nntp_data->firstMessage > nntp_data->lastMessage)
4455 + nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
4456 + for (i = 0; i < nntp_data->newsrc_len; i++)
4458 + first = nntp_data->newsrc_ent[i].first;
4459 + if (first < nntp_data->firstMessage)
4460 + first = nntp_data->firstMessage;
4461 + last = nntp_data->newsrc_ent[i].last;
4462 + if (last > nntp_data->lastMessage)
4463 + last = nntp_data->lastMessage;
4464 + if (first <= last)
4465 + nntp_data->unread -= last - first + 1;
4469 +/* Subscribe newsgroup */
4470 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *nserv, char *group)
4472 + NNTP_DATA *nntp_data;
4474 + if (!nserv || !nserv->groups_hash || !group || !*group)
4477 + nntp_data = nntp_data_find (nserv, group);
4478 + nntp_data->subscribed = 1;
4479 + if (!nntp_data->newsrc_ent)
4481 + nntp_data->newsrc_ent = safe_calloc (1, sizeof (NEWSRC_ENTRY));
4482 + nntp_data->newsrc_len = 1;
4483 + nntp_data->newsrc_ent[0].first = 1;
4484 + nntp_data->newsrc_ent[0].last = 0;
4489 +/* Unsubscribe newsgroup */
4490 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *nserv, char *group)
4492 + NNTP_DATA *nntp_data;
4494 + if (!nserv || !nserv->groups_hash || !group || !*group)
4497 + nntp_data = hash_find (nserv->groups_hash, group);
4501 + nntp_data->subscribed = 0;
4502 + if (!option (OPTSAVEUNSUB))
4504 + nntp_data->newsrc_len = 0;
4505 + FREE (&nntp_data->newsrc_ent);
4510 +/* Catchup newsgroup */
4511 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *nserv, char *group)
4513 + NNTP_DATA *nntp_data;
4515 + if (!nserv || !nserv->groups_hash || !group || !*group)
4518 + nntp_data = hash_find (nserv->groups_hash, group);
4522 + if (nntp_data->newsrc_ent)
4524 + safe_realloc (&nntp_data->newsrc_ent, sizeof (NEWSRC_ENTRY));
4525 + nntp_data->newsrc_len = 1;
4526 + nntp_data->newsrc_ent[0].first = 1;
4527 + nntp_data->newsrc_ent[0].last = nntp_data->lastMessage;
4529 + nntp_data->unread = 0;
4530 + if (Context && Context->data == nntp_data)
4534 + for (i = 0; i < Context->msgcount; i++)
4535 + mutt_set_flag (Context, Context->hdrs[i], MUTT_READ, 1);
4540 +/* Uncatchup newsgroup */
4541 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *nserv, char *group)
4543 + NNTP_DATA *nntp_data;
4545 + if (!nserv || !nserv->groups_hash || !group || !*group)
4548 + nntp_data = hash_find (nserv->groups_hash, group);
4552 + if (nntp_data->newsrc_ent)
4554 + safe_realloc (&nntp_data->newsrc_ent, sizeof (NEWSRC_ENTRY));
4555 + nntp_data->newsrc_len = 1;
4556 + nntp_data->newsrc_ent[0].first = 1;
4557 + nntp_data->newsrc_ent[0].last = nntp_data->firstMessage - 1;
4559 + if (Context && Context->data == nntp_data)
4563 + nntp_data->unread = Context->msgcount;
4564 + for (i = 0; i < Context->msgcount; i++)
4565 + mutt_set_flag (Context, Context->hdrs[i], MUTT_READ, 0);
4568 + nntp_data->unread = nntp_data->lastMessage - nntp_data->newsrc_ent[0].last;
4572 +/* Get first newsgroup with new messages */
4573 +void nntp_buffy (char *buf, size_t len)
4577 + for (i = 0; i < CurrentNewsSrv->groups_num; i++)
4579 + NNTP_DATA *nntp_data = CurrentNewsSrv->groups_list[i];
4581 + if (!nntp_data || !nntp_data->subscribed || !nntp_data->unread)
4584 + if (Context && Context->magic == MUTT_NNTP &&
4585 + !mutt_strcmp (nntp_data->group, ((NNTP_DATA *)Context->data)->group))
4587 + unsigned int i, unread = 0;
4589 + for (i = 0; i < Context->msgcount; i++)
4590 + if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
4595 + strfcpy (buf, nntp_data->group, len);
4599 diff -udprP mutt-1.10.0.orig/nntp.c mutt-1.10.0/nntp.c
4600 --- mutt-1.10.0.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300
4601 +++ mutt-1.10.0/nntp.c 2018-06-16 17:22:30.200469636 +0300
4604 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4605 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4606 + * Copyright (C) 2000-2017 Vsevolod Volkov <vvv@mutt.org.ua>
4608 + * This program is free software; you can redistribute it and/or modify
4609 + * it under the terms of the GNU General Public License as published by
4610 + * the Free Software Foundation; either version 2 of the License, or
4611 + * (at your option) any later version.
4613 + * This program is distributed in the hope that it will be useful,
4614 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4615 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4616 + * GNU General Public License for more details.
4618 + * You should have received a copy of the GNU General Public License
4619 + * along with this program; if not, write to the Free Software
4620 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4624 +#include "config.h"
4628 +#include "mutt_curses.h"
4632 +#include "rfc1524.h"
4633 +#include "rfc2047.h"
4634 +#include "mailbox.h"
4635 +#include "mutt_crypt.h"
4638 +#if defined(USE_SSL)
4639 +#include "mutt_ssl.h"
4651 +#include "hcache.h"
4654 +#include <unistd.h>
4655 +#include <string.h>
4657 +#include <stdlib.h>
4660 +#include <sasl/sasl.h>
4661 +#include <sasl/saslutil.h>
4663 +#include "mutt_sasl.h"
4666 +static int nntp_connect_error (NNTP_SERVER *nserv)
4668 + nserv->status = NNTP_NONE;
4669 + mutt_error _("Server closed connection!");
4674 +/* Get capabilities:
4675 + * -1 - error, connection is closed
4676 + * 0 - mode is reader, capabilities setted up
4677 + * 1 - need to switch to reader mode */
4678 +static int nntp_capabilities (NNTP_SERVER *nserv)
4680 + CONNECTION *conn = nserv->conn;
4681 + unsigned int mode_reader = 0;
4682 + char buf[LONG_STRING];
4683 + char authinfo[LONG_STRING] = "";
4685 + nserv->hasCAPABILITIES = 0;
4686 + nserv->hasSTARTTLS = 0;
4687 + nserv->hasDATE = 0;
4688 + nserv->hasLIST_NEWSGROUPS = 0;
4689 + nserv->hasLISTGROUP = 0;
4690 + nserv->hasLISTGROUPrange = 0;
4691 + nserv->hasOVER = 0;
4692 + FREE (&nserv->authenticators);
4694 + if (mutt_socket_write (conn, "CAPABILITIES\r\n") < 0 ||
4695 + mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4696 + return nntp_connect_error (nserv);
4698 + /* no capabilities */
4699 + if (mutt_strncmp ("101", buf, 3))
4701 + nserv->hasCAPABILITIES = 1;
4703 + /* parse capabilities */
4706 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4707 + return nntp_connect_error (nserv);
4708 + if (!mutt_strcmp ("STARTTLS", buf))
4709 + nserv->hasSTARTTLS = 1;
4710 + else if (!mutt_strcmp ("MODE-READER", buf))
4712 + else if (!mutt_strcmp ("READER", buf))
4714 + nserv->hasDATE = 1;
4715 + nserv->hasLISTGROUP = 1;
4716 + nserv->hasLISTGROUPrange = 1;
4718 + else if (!mutt_strncmp ("AUTHINFO ", buf, 9))
4720 + safe_strcat (buf, sizeof (buf), " ");
4721 + strfcpy (authinfo, buf + 8, sizeof (authinfo));
4724 + else if (!mutt_strncmp ("SASL ", buf, 5))
4726 + char *p = buf + 5;
4729 + nserv->authenticators = safe_strdup (p);
4732 + else if (!mutt_strcmp ("OVER", buf))
4733 + nserv->hasOVER = 1;
4734 + else if (!mutt_strncmp ("LIST ", buf, 5))
4736 + char *p = strstr (buf, " NEWSGROUPS");
4740 + if (*p == '\0' || *p == ' ')
4741 + nserv->hasLIST_NEWSGROUPS = 1;
4744 + } while (mutt_strcmp (".", buf));
4747 + if (nserv->authenticators && strcasestr (authinfo, " SASL "))
4748 + strfcpy (buf, nserv->authenticators, sizeof (buf));
4750 + if (strcasestr (authinfo, " USER "))
4753 + safe_strcat (buf, sizeof (buf), " ");
4754 + safe_strcat (buf, sizeof (buf), "USER");
4756 + mutt_str_replace (&nserv->authenticators, buf);
4758 + /* current mode is reader */
4759 + if (nserv->hasDATE)
4762 + /* server is mode-switching, need to switch to reader mode */
4766 + mutt_socket_close (conn);
4767 + nserv->status = NNTP_BYE;
4768 + mutt_error _("Server doesn't support reader mode.");
4773 +char *OverviewFmt =
4779 + "Content-Length:\0"
4783 +/* Detect supported commands */
4784 +static int nntp_attempt_features (NNTP_SERVER *nserv)
4786 + CONNECTION *conn = nserv->conn;
4787 + char buf[LONG_STRING];
4789 + /* no CAPABILITIES, trying DATE, LISTGROUP, LIST NEWSGROUPS */
4790 + if (!nserv->hasCAPABILITIES)
4792 + if (mutt_socket_write (conn, "DATE\r\n") < 0 ||
4793 + mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4794 + return nntp_connect_error (nserv);
4795 + if (mutt_strncmp ("500", buf, 3))
4796 + nserv->hasDATE = 1;
4798 + if (mutt_socket_write (conn, "LISTGROUP\r\n") < 0 ||
4799 + mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4800 + return nntp_connect_error (nserv);
4801 + if (mutt_strncmp ("500", buf, 3))
4802 + nserv->hasLISTGROUP = 1;
4804 + if (mutt_socket_write (conn, "LIST NEWSGROUPS +\r\n") < 0 ||
4805 + mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4806 + return nntp_connect_error (nserv);
4807 + if (mutt_strncmp ("500", buf, 3))
4808 + nserv->hasLIST_NEWSGROUPS = 1;
4809 + if (!mutt_strncmp ("215", buf, 3))
4813 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4814 + return nntp_connect_error (nserv);
4815 + } while (mutt_strcmp (".", buf));
4819 + /* no LIST NEWSGROUPS, trying XGTITLE */
4820 + if (!nserv->hasLIST_NEWSGROUPS)
4822 + if (mutt_socket_write (conn, "XGTITLE\r\n") < 0 ||
4823 + mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4824 + return nntp_connect_error (nserv);
4825 + if (mutt_strncmp ("500", buf, 3))
4826 + nserv->hasXGTITLE = 1;
4829 + /* no OVER, trying XOVER */
4830 + if (!nserv->hasOVER)
4832 + if (mutt_socket_write (conn, "XOVER\r\n") < 0 ||
4833 + mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4834 + return nntp_connect_error (nserv);
4835 + if (mutt_strncmp ("500", buf, 3))
4836 + nserv->hasXOVER = 1;
4839 + /* trying LIST OVERVIEW.FMT */
4840 + if (nserv->hasOVER || nserv->hasXOVER)
4842 + if (mutt_socket_write (conn, "LIST OVERVIEW.FMT\r\n") < 0 ||
4843 + mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4844 + return nntp_connect_error (nserv);
4845 + if (mutt_strncmp ("215", buf, 3))
4846 + nserv->overview_fmt = OverviewFmt;
4849 + int chunk, cont = 0;
4850 + size_t buflen = 2 * LONG_STRING, off = 0, b = 0;
4852 + if (nserv->overview_fmt)
4853 + FREE (&nserv->overview_fmt);
4854 + nserv->overview_fmt = safe_malloc (buflen);
4858 + if (buflen - off < LONG_STRING)
4861 + safe_realloc (&nserv->overview_fmt, buflen);
4864 + chunk = mutt_socket_readln (nserv->overview_fmt + off,
4865 + buflen - off, conn);
4868 + FREE (&nserv->overview_fmt);
4869 + return nntp_connect_error (nserv);
4872 + if (!cont && !mutt_strcmp (".", nserv->overview_fmt + off))
4875 + cont = chunk >= buflen - off ? 1 : 0;
4876 + off += strlen (nserv->overview_fmt + off);
4881 + if (nserv->overview_fmt[b] == ':')
4883 + memmove (nserv->overview_fmt + b,
4884 + nserv->overview_fmt + b + 1, off - b - 1);
4885 + nserv->overview_fmt[off - 1] = ':';
4887 + colon = strchr (nserv->overview_fmt + b, ':');
4889 + nserv->overview_fmt[off++] = ':';
4890 + else if (strcmp (colon + 1, "full"))
4891 + off = colon + 1 - nserv->overview_fmt;
4892 + if (!strcasecmp (nserv->overview_fmt + b, "Bytes:"))
4894 + strcpy (nserv->overview_fmt + b, "Content-Length:");
4895 + off = b + strlen (nserv->overview_fmt + b);
4897 + nserv->overview_fmt[off++] = '\0';
4901 + nserv->overview_fmt[off++] = '\0';
4902 + safe_realloc (&nserv->overview_fmt, off);
4908 +/* Get login, password and authenticate */
4909 +static int nntp_auth (NNTP_SERVER *nserv)
4911 + CONNECTION *conn = nserv->conn;
4912 + char buf[LONG_STRING];
4913 + char authenticators[LONG_STRING] = "USER";
4914 + char *method, *a, *p;
4915 + unsigned char flags = conn->account.flags;
4919 + /* get login and password */
4920 + if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
4921 + mutt_account_getpass (&conn->account) || !conn->account.pass[0])
4924 + /* get list of authenticators */
4925 + if (NntpAuthenticators && *NntpAuthenticators)
4926 + strfcpy (authenticators, NntpAuthenticators, sizeof (authenticators));
4927 + else if (nserv->hasCAPABILITIES)
4929 + strfcpy (authenticators, NONULL (nserv->authenticators),
4930 + sizeof (authenticators));
4931 + p = authenticators;
4939 + p = authenticators;
4942 + *p = ascii_toupper (*p);
4946 + dprint (1, (debugfile,
4947 + "nntp_auth: available methods: %s\n", nserv->authenticators));
4948 + a = authenticators;
4953 + mutt_error _("No authenticators available");
4959 + a = strchr (a, ':');
4963 + /* check authenticator */
4964 + if (nserv->hasCAPABILITIES)
4968 + if (!nserv->authenticators)
4970 + m = strcasestr (nserv->authenticators, method);
4973 + if (m > nserv->authenticators && *(m - 1) != ' ')
4975 + m += strlen (method);
4976 + if (*m != '\0' && *m != ' ')
4979 + dprint (1, (debugfile, "nntp_auth: trying method %s\n", method));
4981 + /* AUTHINFO USER authentication */
4982 + if (!strcmp (method, "USER"))
4984 + mutt_message (_("Authenticating (%s)..."), method);
4985 + snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
4986 + if (mutt_socket_write (conn, buf) < 0 ||
4987 + mutt_socket_readln (buf, sizeof (buf), conn) < 0)
4990 + /* authenticated, password is not required */
4991 + if (!mutt_strncmp ("281", buf, 3))
4994 + /* username accepted, sending password */
4995 + if (!mutt_strncmp ("381", buf, 3))
4998 + if (debuglevel < MUTT_SOCK_LOG_FULL)
4999 + dprint (MUTT_SOCK_LOG_CMD, (debugfile,
5000 + "%d> AUTHINFO PASS *\n", conn->fd));
5002 + snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n",
5003 + conn->account.pass);
5004 + if (mutt_socket_write_d (conn, buf, -1, MUTT_SOCK_LOG_FULL) < 0 ||
5005 + mutt_socket_readln (buf, sizeof (buf), conn) < 0)
5008 + /* authenticated */
5009 + if (!mutt_strncmp ("281", buf, 3))
5013 + /* server doesn't support AUTHINFO USER, trying next method */
5021 + sasl_conn_t *saslconn;
5022 + sasl_interact_t *interaction = NULL;
5024 + char inbuf[LONG_STRING] = "";
5026 + const char *client_out = NULL;
5027 + unsigned int client_len, len;
5029 + if (mutt_sasl_client_new (conn, &saslconn) < 0)
5031 + dprint (1, (debugfile,
5032 + "nntp_auth: error allocating SASL connection.\n"));
5038 + rc = sasl_client_start (saslconn, method, &interaction,
5039 + &client_out, &client_len, &mech);
5040 + if (rc != SASL_INTERACT)
5042 + mutt_sasl_interact (interaction);
5044 + if (rc != SASL_OK && rc != SASL_CONTINUE)
5046 + sasl_dispose (&saslconn);
5047 + dprint (1, (debugfile,
5048 + "nntp_auth: error starting SASL authentication exchange.\n"));
5052 + mutt_message (_("Authenticating (%s)..."), method);
5053 + snprintf (buf, sizeof (buf), "AUTHINFO SASL %s", method);
5055 + /* looping protocol */
5056 + while (rc == SASL_CONTINUE || (rc == SASL_OK && client_len))
5058 + /* send out client response */
5062 + if (debuglevel >= MUTT_SOCK_LOG_FULL)
5064 + char tmp[LONG_STRING];
5065 + memcpy (tmp, client_out, client_len);
5066 + for (p = tmp; p < tmp + client_len; p++)
5072 + dprint (1, (debugfile, "SASL> %s\n", tmp));
5077 + safe_strcat (buf, sizeof (buf), " ");
5078 + len = strlen (buf);
5079 + if (sasl_encode64 (client_out, client_len,
5080 + buf + len, sizeof (buf) - len, &len) != SASL_OK)
5082 + dprint (1, (debugfile,
5083 + "nntp_auth: error base64-encoding client response.\n"));
5088 + safe_strcat (buf, sizeof (buf), "\r\n");
5090 + if (debuglevel < MUTT_SOCK_LOG_FULL)
5092 + if (strchr (buf, ' '))
5093 + dprint (MUTT_SOCK_LOG_CMD, (debugfile, "%d> AUTHINFO SASL %s%s\n",
5094 + conn->fd, method, client_len ? " sasl_data" : ""));
5096 + dprint (MUTT_SOCK_LOG_CMD, (debugfile, "%d> sasl_data\n", conn->fd));
5100 + if (mutt_socket_write_d (conn, buf, -1, MUTT_SOCK_LOG_FULL) < 0 ||
5101 + mutt_socket_readln_d (inbuf, sizeof (inbuf), conn, MUTT_SOCK_LOG_FULL) < 0)
5103 + if (mutt_strncmp (inbuf, "283 ", 4) &&
5104 + mutt_strncmp (inbuf, "383 ", 4))
5107 + if (debuglevel < MUTT_SOCK_LOG_FULL)
5108 + dprint (MUTT_SOCK_LOG_CMD, (debugfile, "%d< %s\n", conn->fd, inbuf));
5113 + if (debuglevel < MUTT_SOCK_LOG_FULL)
5116 + dprint (MUTT_SOCK_LOG_CMD, (debugfile,
5117 + "%d< %s sasl_data\n", conn->fd, inbuf));
5121 + if (!strcmp ("=", inbuf + 4))
5123 + else if (sasl_decode64 (inbuf + 4, strlen (inbuf + 4),
5124 + buf, sizeof (buf) - 1, &len) != SASL_OK)
5126 + dprint (1, (debugfile,
5127 + "nntp_auth: error base64-decoding server response.\n"));
5131 + else if (debuglevel >= MUTT_SOCK_LOG_FULL)
5133 + char tmp[LONG_STRING];
5134 + memcpy (tmp, buf, len);
5135 + for (p = tmp; p < tmp + len; p++)
5141 + dprint (1, (debugfile, "SASL< %s\n", tmp));
5147 + rc = sasl_client_step (saslconn, buf, len,
5148 + &interaction, &client_out, &client_len);
5149 + if (rc != SASL_INTERACT)
5151 + mutt_sasl_interact (interaction);
5153 + if (*inbuf != '3')
5157 + } /* looping protocol */
5159 + if (rc == SASL_OK && client_len == 0 && *inbuf == '2')
5161 + mutt_sasl_setup_conn (conn, saslconn);
5165 + /* terminate SASL sessoin */
5166 + sasl_dispose (&saslconn);
5169 + if (!mutt_strncmp (inbuf, "383 ", 4))
5171 + if (mutt_socket_write (conn, "*\r\n") < 0 ||
5172 + mutt_socket_readln (inbuf, sizeof (inbuf), conn) < 0)
5176 + /* server doesn't support AUTHINFO SASL, trying next method */
5177 + if (*inbuf == '5')
5181 +#endif /* USE_SASL */
5184 + mutt_error (_("%s authentication failed."), method);
5192 + nserv->status = NNTP_BYE;
5193 + conn->account.flags = flags;
5196 + mutt_error _("Server closed connection!");
5200 + mutt_socket_close (conn);
5204 +/* Connect to server, authenticate and get capabilities */
5205 +int nntp_open_connection (NNTP_SERVER *nserv)
5207 + CONNECTION *conn = nserv->conn;
5210 + unsigned int posting = 0, auth = 1;
5212 + if (nserv->status == NNTP_OK)
5214 + if (nserv->status == NNTP_BYE)
5216 + nserv->status = NNTP_NONE;
5218 + if (mutt_socket_open (conn) < 0)
5221 + if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
5222 + return nntp_connect_error (nserv);
5224 + if (!mutt_strncmp ("200", buf, 3))
5226 + else if (mutt_strncmp ("201", buf, 3))
5228 + mutt_socket_close (conn);
5229 + mutt_remove_trailing_ws (buf);
5230 + mutt_error ("%s", buf);
5235 + /* get initial capabilities */
5236 + cap = nntp_capabilities (nserv);
5240 + /* tell news server to switch to mode reader if it isn't so */
5243 + if (mutt_socket_write (conn, "MODE READER\r\n") < 0 ||
5244 + mutt_socket_readln (buf, sizeof (buf), conn) < 0)
5245 + return nntp_connect_error (nserv);
5247 + if (!mutt_strncmp ("200", buf, 3))
5249 + else if (!mutt_strncmp ("201", buf, 3))
5251 + /* error if has capabilities, ignore result if no capabilities */
5252 + else if (nserv->hasCAPABILITIES)
5254 + mutt_socket_close (conn);
5255 + mutt_error _("Could not switch to reader mode.");
5260 + /* recheck capabilities after MODE READER */
5261 + if (nserv->hasCAPABILITIES)
5263 + cap = nntp_capabilities (nserv);
5269 + mutt_message (_("Connected to %s. %s"), conn->account.host,
5270 + posting ? _("Posting is ok.") : _("Posting is NOT ok."));
5273 +#if defined(USE_SSL)
5274 + /* Attempt STARTTLS if available and desired. */
5275 + if (nserv->use_tls != 1 && (nserv->hasSTARTTLS || option (OPTSSLFORCETLS)))
5277 + if (nserv->use_tls == 0)
5278 + nserv->use_tls = option (OPTSSLFORCETLS) ||
5279 + query_quadoption (OPT_SSLSTARTTLS,
5280 + _("Secure connection with TLS?")) == MUTT_YES ? 2 : 1;
5281 + if (nserv->use_tls == 2)
5283 + if (mutt_socket_write (conn, "STARTTLS\r\n") < 0 ||
5284 + mutt_socket_readln (buf, sizeof (buf), conn) < 0)
5285 + return nntp_connect_error (nserv);
5286 + if (mutt_strncmp ("382", buf, 3))
5288 + nserv->use_tls = 0;
5289 + mutt_error ("STARTTLS: %s", buf);
5292 + else if (mutt_ssl_starttls (conn))
5294 + nserv->use_tls = 0;
5295 + nserv->status = NNTP_NONE;
5296 + mutt_socket_close (nserv->conn);
5297 + mutt_error _("Could not negotiate TLS connection");
5303 + /* recheck capabilities after STARTTLS */
5304 + cap = nntp_capabilities (nserv);
5312 + /* authentication required? */
5313 + if (conn->account.flags & MUTT_ACCT_USER)
5315 + if (!conn->account.user[0])
5320 + if (mutt_socket_write (conn, "STAT\r\n") < 0 ||
5321 + mutt_socket_readln (buf, sizeof (buf), conn) < 0)
5322 + return nntp_connect_error (nserv);
5323 + if (mutt_strncmp ("480", buf, 3))
5327 + /* authenticate */
5328 + if (auth && nntp_auth (nserv) < 0)
5331 + /* get final capabilities after authentication */
5332 + if (nserv->hasCAPABILITIES && (auth || cap > 0))
5334 + cap = nntp_capabilities (nserv);
5339 + mutt_socket_close (conn);
5340 + mutt_error _("Could not switch to reader mode.");
5346 + /* attempt features */
5347 + if (nntp_attempt_features (nserv) < 0)
5350 + nserv->status = NNTP_OK;
5354 +/* Send data from buffer and receive answer to same buffer */
5355 +static int nntp_query (NNTP_DATA *nntp_data, char *line, size_t linelen)
5357 + NNTP_SERVER *nserv = nntp_data->nserv;
5358 + char buf[LONG_STRING];
5360 + if (nserv->status == NNTP_BYE)
5365 + if (nserv->status == NNTP_OK)
5370 + rc = mutt_socket_write (nserv->conn, line);
5371 + else if (nntp_data->group)
5373 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", nntp_data->group);
5374 + rc = mutt_socket_write (nserv->conn, buf);
5377 + rc = mutt_socket_readln (buf, sizeof (buf), nserv->conn);
5385 + nserv->status = NNTP_NONE;
5386 + if (nntp_open_connection (nserv) == 0)
5389 + snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
5390 + nserv->conn->account.host);
5391 + if (mutt_yesorno (buf, MUTT_YES) != MUTT_YES)
5393 + nserv->status = NNTP_BYE;
5398 + /* select newsgroup after reconnection */
5399 + if (nntp_data->group)
5401 + snprintf (buf, sizeof (buf), "GROUP %s\r\n", nntp_data->group);
5402 + if (mutt_socket_write (nserv->conn, buf) < 0 ||
5403 + mutt_socket_readln (buf, sizeof (buf), nserv->conn) < 0)
5404 + return nntp_connect_error (nserv);
5410 + strfcpy (line, buf, linelen);
5414 +/* This function calls funct(*line, *data) for each received line,
5415 + * funct(NULL, *data) if rewind(*data) needs, exits when fail or done:
5417 + * 1 - bad response (answer in query buffer)
5418 + * -1 - conection lost
5419 + * -2 - error in funct(*line, *data) */
5420 +static int nntp_fetch_lines (NNTP_DATA *nntp_data, char *query, size_t qlen,
5421 + char *msg, int (*funct) (char *, void *), void *data)
5428 + char buf[LONG_STRING];
5430 + unsigned int lines = 0;
5432 + progress_t progress;
5435 + mutt_progress_init (&progress, msg, MUTT_PROGRESS_MSG, ReadInc, -1);
5437 + strfcpy (buf, query, sizeof (buf));
5438 + if (nntp_query (nntp_data, buf, sizeof (buf)) < 0)
5440 + if (buf[0] != '2')
5442 + strfcpy (query, buf, qlen);
5446 + line = safe_malloc (sizeof (buf));
5452 + int chunk = mutt_socket_readln_d (buf, sizeof (buf),
5453 + nntp_data->nserv->conn, MUTT_SOCK_LOG_HDR);
5456 + nntp_data->nserv->status = NNTP_NONE;
5461 + if (!off && buf[0] == '.')
5463 + if (buf[1] == '\0')
5468 + if (buf[1] == '.')
5472 + strfcpy (line + off, p, sizeof (buf));
5474 + if (chunk >= sizeof (buf))
5475 + off += strlen (p);
5479 + mutt_progress_update (&progress, ++lines, -1);
5481 + if (rc == 0 && funct (line, data) < 0)
5486 + safe_realloc (&line, off + sizeof (buf));
5489 + funct (NULL, data);
5494 +/* Parse newsgroup description */
5495 +static int fetch_description (char *line, void *data)
5497 + NNTP_SERVER *nserv = data;
5498 + NNTP_DATA *nntp_data;
5504 + desc = strpbrk (line, " \t");
5508 + desc += strspn (desc, " \t");
5511 + desc = strchr (line, '\0');
5513 + nntp_data = hash_find (nserv->groups_hash, line);
5514 + if (nntp_data && mutt_strcmp (desc, nntp_data->desc))
5516 + mutt_str_replace (&nntp_data->desc, desc);
5517 + dprint (2, (debugfile, "group: %s, desc: %s\n", line, desc));
5522 +/* Fetch newsgroups descriptions.
5523 + * Returns the same code as nntp_fetch_lines() */
5524 +static int get_description (NNTP_DATA *nntp_data, char *wildmat, char *msg)
5526 + NNTP_SERVER *nserv;
5531 + /* get newsgroup description, if possible */
5532 + nserv = nntp_data->nserv;
5534 + wildmat = nntp_data->group;
5535 + if (nserv->hasLIST_NEWSGROUPS)
5536 + cmd = "LIST NEWSGROUPS";
5537 + else if (nserv->hasXGTITLE)
5542 + snprintf (buf, sizeof (buf), "%s %s\r\n", cmd, wildmat);
5543 + rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), msg,
5544 + fetch_description, nserv);
5547 + mutt_error ("%s: %s", cmd, buf);
5553 +/* Update read flag and set article number if empty */
5554 +static void nntp_parse_xref (CONTEXT *ctx, HEADER *hdr)
5556 + NNTP_DATA *nntp_data = ctx->data;
5559 + buf = p = safe_strdup (hdr->env->xref);
5562 + char *grp, *colon;
5565 + /* skip to next word */
5566 + p += strspn (p, " \t");
5569 + /* skip to end of word */
5570 + p = strpbrk (p, " \t");
5575 + colon = strchr (grp, ':');
5579 + if (sscanf (colon, ANUM, &anum) != 1)
5582 + nntp_article_status (ctx, hdr, grp, anum);
5583 + if (hdr && !NHDR (hdr)->article_num && !mutt_strcmp (nntp_data->group, grp))
5584 + NHDR (hdr)->article_num = anum;
5589 +/* Write line to temporarily file */
5590 +static int fetch_tempfile (char *line, void *data)
5596 + else if (fputs (line, fp) == EOF || fputc ('\n', fp) == EOF)
5607 + unsigned char *messages;
5608 + progress_t progress;
5610 + header_cache_t *hc;
5614 +/* Parse article number */
5615 +static int fetch_numbers (char *line, void *data)
5617 + FETCH_CTX *fc = data;
5622 + if (sscanf (line, ANUM, &anum) != 1)
5624 + if (anum < fc->first || anum > fc->last)
5626 + fc->messages[anum - fc->first] = 1;
5630 +/* Parse overview line */
5631 +static int parse_overview_line (char *line, void *data)
5633 + FETCH_CTX *fc = data;
5634 + CONTEXT *ctx = fc->ctx;
5635 + NNTP_DATA *nntp_data = ctx->data;
5638 + char tempfile[_POSIX_PATH_MAX];
5639 + char *header, *field;
5646 + /* parse article number */
5647 + field = strchr (line, '\t');
5650 + if (sscanf (line, ANUM, &anum) != 1)
5652 + dprint (2, (debugfile, "parse_overview_line: " ANUM "\n", anum));
5654 + /* out of bounds */
5655 + if (anum < fc->first || anum > fc->last)
5658 + /* not in LISTGROUP */
5659 + if (!fc->messages[anum - fc->first])
5663 + mutt_progress_update (&fc->progress, anum - fc->first + 1, -1);
5667 + /* convert overview line to header */
5668 + mutt_mktemp (tempfile, sizeof (tempfile));
5669 + fp = safe_fopen (tempfile, "w+");
5673 + header = nntp_data->nserv->overview_fmt;
5680 + if (strstr (header, ":full") == NULL && fputs (header, fp) == EOF)
5683 + unlink (tempfile);
5686 + header = strchr (header, '\0') + 1;
5689 + field = strchr (field, '\t');
5692 + if (fputs (b, fp) == EOF || fputc ('\n', fp) == EOF)
5695 + unlink (tempfile);
5701 + /* allocate memory for headers */
5702 + if (ctx->msgcount >= ctx->hdrmax)
5703 + mx_alloc_memory (ctx);
5705 + /* parse header */
5706 + hdr = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5707 + hdr->env = mutt_read_rfc822_header (fp, hdr, 0, 0);
5708 + hdr->env->newsgroups = safe_strdup (nntp_data->group);
5709 + hdr->received = hdr->date_sent;
5711 + unlink (tempfile);
5719 + /* try to replace with header from cache */
5720 + snprintf (buf, sizeof (buf), "%d", anum);
5721 + hdata = mutt_hcache_fetch (fc->hc, buf, strlen);
5724 + dprint (2, (debugfile,
5725 + "parse_overview_line: mutt_hcache_fetch %s\n", buf));
5726 + mutt_free_header (&hdr);
5727 + ctx->hdrs[ctx->msgcount] =
5728 + hdr = mutt_hcache_restore (hdata, NULL);
5734 + /* skip header marked as deleted in cache */
5735 + if (hdr->deleted && !fc->restore)
5737 + if (nntp_data->bcache)
5739 + dprint (2, (debugfile,
5740 + "parse_overview_line: mutt_bcache_del %s\n", buf));
5741 + mutt_bcache_del (nntp_data->bcache, buf);
5747 + /* not chached yet, store header */
5750 + dprint (2, (debugfile,
5751 + "parse_overview_line: mutt_hcache_store %s\n", buf));
5752 + mutt_hcache_store (fc->hc, buf, hdr, 0, strlen, MUTT_GENERATE_UIDVALIDITY);
5759 + hdr->index = ctx->msgcount++;
5763 + hdr->data = safe_calloc (1, sizeof (NNTP_HEADER_DATA));
5764 + NHDR (hdr)->article_num = anum;
5769 + nntp_article_status (ctx, hdr, NULL, anum);
5771 + nntp_parse_xref (ctx, hdr);
5773 + if (anum > nntp_data->lastLoaded)
5774 + nntp_data->lastLoaded = anum;
5777 + mutt_free_header (&hdr);
5781 + mutt_progress_update (&fc->progress, anum - fc->first + 1, -1);
5785 +/* Fetch headers */
5786 +static int nntp_fetch_headers (CONTEXT *ctx, void *hc,
5787 + anum_t first, anum_t last, int restore)
5789 + NNTP_DATA *nntp_data = ctx->data;
5792 + char buf[HUGE_STRING];
5794 + int oldmsgcount = ctx->msgcount;
5796 + anum_t first_over = first;
5801 + /* if empty group or nothing to do */
5802 + if (!last || first > last)
5805 + /* init fetch context */
5809 + fc.restore = restore;
5810 + fc.messages = safe_calloc (last - first + 1, sizeof (unsigned char));
5815 + /* fetch list of articles */
5816 + if (option (OPTLISTGROUP) && nntp_data->nserv->hasLISTGROUP &&
5817 + !nntp_data->deleted)
5820 + mutt_message _("Fetching list of articles...");
5821 + if (nntp_data->nserv->hasLISTGROUPrange)
5822 + snprintf (buf, sizeof (buf), "LISTGROUP %s %d-%d\r\n", nntp_data->group,
5825 + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
5826 + rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL,
5827 + fetch_numbers, &fc);
5830 + mutt_error ("LISTGROUP: %s", buf);
5835 + for (current = first; current <= last && rc == 0; current++)
5837 + if (fc.messages[current - first])
5840 + snprintf (buf, sizeof (buf), "%d", current);
5841 + if (nntp_data->bcache)
5843 + dprint (2, (debugfile,
5844 + "nntp_fetch_headers: mutt_bcache_del %s\n", buf));
5845 + mutt_bcache_del (nntp_data->bcache, buf);
5851 + dprint (2, (debugfile,
5852 + "nntp_fetch_headers: mutt_hcache_delete %s\n", buf));
5853 + mutt_hcache_delete (fc.hc, buf, strlen);
5860 + for (current = first; current <= last; current++)
5861 + fc.messages[current - first] = 1;
5863 + /* fetching header from cache or server, or fallback to fetch overview */
5865 + mutt_progress_init (&fc.progress, _("Fetching message headers..."),
5866 + MUTT_PROGRESS_MSG, ReadInc, last - first + 1);
5867 + for (current = first; current <= last && rc == 0; current++)
5870 + mutt_progress_update (&fc.progress, current - first + 1, -1);
5873 + snprintf (buf, sizeof (buf), "%d", current);
5876 + /* delete header from cache that does not exist on server */
5877 + if (!fc.messages[current - first])
5880 + /* allocate memory for headers */
5881 + if (ctx->msgcount >= ctx->hdrmax)
5882 + mx_alloc_memory (ctx);
5885 + /* try to fetch header from cache */
5886 + hdata = mutt_hcache_fetch (fc.hc, buf, strlen);
5889 + dprint (2, (debugfile,
5890 + "nntp_fetch_headers: mutt_hcache_fetch %s\n", buf));
5891 + ctx->hdrs[ctx->msgcount] =
5892 + hdr = mutt_hcache_restore (hdata, NULL);
5896 + /* skip header marked as deleted in cache */
5897 + if (hdr->deleted && !restore)
5899 + mutt_free_header (&hdr);
5900 + if (nntp_data->bcache)
5902 + dprint (2, (debugfile,
5903 + "nntp_fetch_headers: mutt_bcache_del %s\n", buf));
5904 + mutt_bcache_del (nntp_data->bcache, buf);
5915 + /* don't try to fetch header from removed newsgroup */
5916 + if (nntp_data->deleted)
5919 + /* fallback to fetch overview */
5920 + else if (nntp_data->nserv->hasOVER || nntp_data->nserv->hasXOVER)
5921 + if (option (OPTLISTGROUP) && nntp_data->nserv->hasLISTGROUP)
5926 + /* fetch header from server */
5930 + char tempfile[_POSIX_PATH_MAX];
5932 + mutt_mktemp (tempfile, sizeof (tempfile));
5933 + fp = safe_fopen (tempfile, "w+");
5936 + mutt_perror (tempfile);
5938 + unlink (tempfile);
5943 + snprintf (buf, sizeof (buf), "HEAD %d\r\n", current);
5944 + rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL,
5945 + fetch_tempfile, fp);
5949 + unlink (tempfile);
5953 + /* invalid response */
5954 + if (mutt_strncmp ("423", buf, 3))
5956 + mutt_error ("HEAD: %s", buf);
5961 + /* no such article */
5962 + if (nntp_data->bcache)
5964 + snprintf (buf, sizeof (buf), "%d", current);
5965 + dprint (2, (debugfile,
5966 + "nntp_fetch_headers: mutt_bcache_del %s\n", buf));
5967 + mutt_bcache_del (nntp_data->bcache, buf);
5973 + /* parse header */
5974 + hdr = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
5975 + hdr->env = mutt_read_rfc822_header (fp, hdr, 0, 0);
5976 + hdr->received = hdr->date_sent;
5978 + unlink (tempfile);
5981 + /* save header in context */
5982 + hdr->index = ctx->msgcount++;
5986 + hdr->data = safe_calloc (1, sizeof (NNTP_HEADER_DATA));
5987 + NHDR (hdr)->article_num = current;
5992 + nntp_article_status (ctx, hdr, NULL, NHDR (hdr)->article_num);
5994 + nntp_parse_xref (ctx, hdr);
5996 + if (current > nntp_data->lastLoaded)
5997 + nntp_data->lastLoaded = current;
5998 + first_over = current + 1;
6001 + if (!option (OPTLISTGROUP) || !nntp_data->nserv->hasLISTGROUP)
6002 + current = first_over;
6004 + /* fetch overview information */
6005 + if (current <= last && rc == 0 && !nntp_data->deleted) {
6006 + char *cmd = nntp_data->nserv->hasOVER ? "OVER" : "XOVER";
6007 + snprintf (buf, sizeof (buf), "%s %d-%d\r\n", cmd, current, last);
6008 + rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL,
6009 + parse_overview_line, &fc);
6012 + mutt_error ("%s: %s", cmd, buf);
6017 + if (ctx->msgcount > oldmsgcount)
6018 + mx_update_context (ctx, ctx->msgcount - oldmsgcount);
6020 + FREE (&fc.messages);
6023 + mutt_clear_error ();
6027 +/* Open newsgroup */
6028 +static int nntp_open_mailbox (CONTEXT *ctx)
6030 + NNTP_SERVER *nserv;
6031 + NNTP_DATA *nntp_data;
6032 + char buf[HUGE_STRING];
6033 + char server[LONG_STRING];
6037 + anum_t first, last, count = 0;
6040 + strfcpy (buf, ctx->path, sizeof (buf));
6041 + if (url_parse_ciss (&url, buf) < 0 || !url.path ||
6042 + !(url.scheme == U_NNTP || url.scheme == U_NNTPS))
6044 + mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
6050 + url.path = strchr (url.path, '\0');
6051 + url_ciss_tostring (&url, server, sizeof (server), 0);
6052 + nserv = nntp_select_server (server, 1);
6055 + CurrentNewsSrv = nserv;
6057 + /* find news group data structure */
6058 + nntp_data = hash_find (nserv->groups_hash, group);
6061 + nntp_newsrc_close (nserv);
6062 + mutt_error (_("Newsgroup %s not found on the server."), group);
6067 + mutt_bit_unset (ctx->rights, MUTT_ACL_INSERT);
6068 + if (!nntp_data->newsrc_ent && !nntp_data->subscribed &&
6069 + !option (OPTSAVEUNSUB))
6070 + ctx->readonly = 1;
6072 + /* select newsgroup */
6073 + mutt_message (_("Selecting %s..."), group);
6075 + if (nntp_query (nntp_data, buf, sizeof (buf)) < 0)
6077 + nntp_newsrc_close (nserv);
6081 + /* newsgroup not found, remove it */
6082 + if (!mutt_strncmp ("411", buf, 3))
6084 + mutt_error (_("Newsgroup %s has been removed from the server."),
6085 + nntp_data->group);
6086 + if (!nntp_data->deleted)
6088 + nntp_data->deleted = 1;
6089 + nntp_active_save_cache (nserv);
6091 + if (nntp_data->newsrc_ent && !nntp_data->subscribed &&
6092 + !option (OPTSAVEUNSUB))
6094 + FREE (&nntp_data->newsrc_ent);
6095 + nntp_data->newsrc_len = 0;
6096 + nntp_delete_group_cache (nntp_data);
6097 + nntp_newsrc_update (nserv);
6102 + /* parse newsgroup info */
6104 + if (sscanf (buf, "211 " ANUM " " ANUM " " ANUM, &count, &first, &last) != 3)
6106 + nntp_newsrc_close (nserv);
6107 + mutt_error ("GROUP: %s", buf);
6111 + nntp_data->firstMessage = first;
6112 + nntp_data->lastMessage = last;
6113 + nntp_data->deleted = 0;
6115 + /* get description if empty */
6116 + if (option (OPTLOADDESC) && !nntp_data->desc)
6118 + if (get_description (nntp_data, NULL, NULL) < 0)
6120 + nntp_newsrc_close (nserv);
6123 + if (nntp_data->desc)
6124 + nntp_active_save_cache (nserv);
6128 + time (&nserv->check_time);
6129 + ctx->data = nntp_data;
6130 + if (!nntp_data->bcache && (nntp_data->newsrc_ent ||
6131 + nntp_data->subscribed || option (OPTSAVEUNSUB)))
6132 + nntp_data->bcache = mutt_bcache_open (&nserv->conn->account,
6133 + nntp_data->group);
6135 + /* strip off extra articles if adding context is greater than $nntp_context */
6136 + first = nntp_data->firstMessage;
6137 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
6138 + first = nntp_data->lastMessage - NntpContext + 1;
6139 + nntp_data->lastLoaded = first ? first - 1 : 0;
6140 + count = nntp_data->firstMessage;
6141 + nntp_data->firstMessage = first;
6142 + nntp_bcache_update (nntp_data);
6143 + nntp_data->firstMessage = count;
6145 + hc = nntp_hcache_open (nntp_data);
6146 + nntp_hcache_update (nntp_data, hc);
6150 + mutt_bit_unset (ctx->rights, MUTT_ACL_WRITE);
6151 + mutt_bit_unset (ctx->rights, MUTT_ACL_DELETE);
6153 + nntp_newsrc_close (nserv);
6154 + rc = nntp_fetch_headers (ctx, hc, first, nntp_data->lastMessage, 0);
6156 + mutt_hcache_close (hc);
6160 + nntp_data->lastLoaded = nntp_data->lastMessage;
6161 + nserv->newsrc_modified = 0;
6165 +/* Fetch message */
6166 +static int nntp_open_message (CONTEXT *ctx, MESSAGE *msg, int msgno)
6168 + NNTP_DATA *nntp_data = ctx->data;
6169 + NNTP_ACACHE *acache;
6170 + HEADER *hdr = ctx->hdrs[msgno];
6171 + char buf[_POSIX_PATH_MAX];
6173 + char *fetch_msg = _("Fetching message...");
6176 + /* try to get article from cache */
6177 + acache = &nntp_data->acache[hdr->index % NNTP_ACACHE_LEN];
6180 + if (acache->index == hdr->index)
6182 + msg->fp = fopen (acache->path, "r");
6186 + /* clear previous entry */
6189 + unlink (acache->path);
6190 + FREE (&acache->path);
6193 + snprintf (article, sizeof (article), "%d", NHDR (hdr)->article_num);
6194 + msg->fp = mutt_bcache_get (nntp_data->bcache, article);
6197 + if (NHDR (hdr)->parsed)
6202 + /* don't try to fetch article from removed newsgroup */
6203 + if (nntp_data->deleted)
6206 + /* create new cache file */
6207 + mutt_message (fetch_msg);
6208 + msg->fp = mutt_bcache_put (nntp_data->bcache, article, 1);
6211 + mutt_mktemp (buf, sizeof (buf));
6212 + acache->path = safe_strdup (buf);
6213 + acache->index = hdr->index;
6214 + msg->fp = safe_fopen (acache->path, "w+");
6217 + mutt_perror (acache->path);
6218 + unlink (acache->path);
6219 + FREE (&acache->path);
6224 + /* fetch message to cache file */
6225 + snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
6226 + NHDR (hdr)->article_num ? article : hdr->env->message_id);
6227 + rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), fetch_msg,
6228 + fetch_tempfile, msg->fp);
6231 + safe_fclose (&msg->fp);
6234 + unlink (acache->path);
6235 + FREE (&acache->path);
6239 + if (!mutt_strncmp (NHDR (hdr)->article_num ? "423" : "430", buf, 3))
6240 + mutt_error (_("Article %d not found on the server."),
6241 + NHDR (hdr)->article_num ? article : hdr->env->message_id);
6243 + mutt_error ("ARTICLE: %s", buf);
6248 + if (!acache->path)
6249 + mutt_bcache_commit (nntp_data->bcache, article);
6252 + /* replace envelope with new one
6253 + * hash elements must be updated because pointers will be changed */
6254 + if (ctx->id_hash && hdr->env->message_id)
6255 + hash_delete (ctx->id_hash, hdr->env->message_id, hdr, NULL);
6256 + if (ctx->subj_hash && hdr->env->real_subj)
6257 + hash_delete (ctx->subj_hash, hdr->env->real_subj, hdr, NULL);
6259 + mutt_free_envelope (&hdr->env);
6260 + hdr->env = mutt_read_rfc822_header (msg->fp, hdr, 0, 0);
6262 + if (ctx->id_hash && hdr->env->message_id)
6263 + hash_insert (ctx->id_hash, hdr->env->message_id, hdr);
6264 + if (ctx->subj_hash && hdr->env->real_subj)
6265 + hash_insert (ctx->subj_hash, hdr->env->real_subj, hdr);
6267 + /* fix content length */
6268 + fseek (msg->fp, 0, SEEK_END);
6269 + hdr->content->length = ftell (msg->fp) - hdr->content->offset;
6271 + /* this is called in mutt before the open which fetches the message,
6272 + * which is probably wrong, but we just call it again here to handle
6273 + * the problem instead of fixing it */
6274 + NHDR (hdr)->parsed = 1;
6275 + mutt_parse_mime_message (ctx, hdr);
6277 + /* these would normally be updated in mx_update_context(), but the
6278 + * full headers aren't parsed with overview, so the information wasn't
6279 + * available then */
6281 + hdr->security = crypt_query (hdr->content);
6284 + mutt_clear_error();
6288 +/* Close message */
6289 +static int nntp_close_message (CONTEXT *ctx, MESSAGE *msg)
6291 + return safe_fclose (&msg->fp);
6295 +int nntp_post (const char *msg) {
6296 + NNTP_DATA *nntp_data, nntp_tmp;
6298 + char buf[LONG_STRING];
6301 + if (Context && Context->magic == MUTT_NNTP)
6302 + nntp_data = Context->data;
6305 + CurrentNewsSrv = nntp_select_server (NewsServer, 0);
6306 + if (!CurrentNewsSrv)
6309 + nntp_data = &nntp_tmp;
6310 + nntp_data->nserv = CurrentNewsSrv;
6311 + nntp_data->group = NULL;
6314 + fp = safe_fopen (msg, "r");
6317 + mutt_perror (msg);
6321 + strfcpy (buf, "POST\r\n", sizeof (buf));
6322 + if (nntp_query (nntp_data, buf, sizeof (buf)) < 0)
6324 + if (buf[0] != '3')
6326 + mutt_error (_("Can't post article: %s"), buf);
6332 + while (fgets (buf + 1, sizeof (buf) - 2, fp))
6334 + len = strlen (buf);
6335 + if (buf[len - 1] == '\n')
6337 + buf[len - 1] = '\r';
6342 + if (mutt_socket_write_d (nntp_data->nserv->conn,
6343 + buf[1] == '.' ? buf : buf + 1, -1, MUTT_SOCK_LOG_HDR) < 0)
6344 + return nntp_connect_error (nntp_data->nserv);
6348 + if ((buf[strlen (buf) - 1] != '\n' &&
6349 + mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, MUTT_SOCK_LOG_HDR) < 0) ||
6350 + mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, MUTT_SOCK_LOG_HDR) < 0 ||
6351 + mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
6352 + return nntp_connect_error (nntp_data->nserv);
6353 + if (buf[0] != '2')
6355 + mutt_error (_("Can't post article: %s"), buf);
6361 +/* Free up memory associated with the newsgroup context */
6362 +static int nntp_close_mailbox (CONTEXT *ctx)
6364 + NNTP_DATA *nntp_data = ctx->data, *nntp_tmp;
6369 + nntp_data->unread = ctx->unread;
6371 + nntp_acache_free (nntp_data);
6372 + if (!nntp_data->nserv || !nntp_data->nserv->groups_hash || !nntp_data->group)
6375 + nntp_tmp = hash_find (nntp_data->nserv->groups_hash, nntp_data->group);
6376 + if (nntp_tmp == NULL || nntp_tmp != nntp_data)
6377 + nntp_data_free (nntp_data);
6381 +/* Get date and time from server */
6382 +int nntp_date (NNTP_SERVER *nserv, time_t *now)
6384 + if (nserv->hasDATE)
6386 + NNTP_DATA nntp_data;
6387 + char buf[LONG_STRING];
6390 + nntp_data.nserv = nserv;
6391 + nntp_data.group = NULL;
6392 + strfcpy (buf, "DATE\r\n", sizeof (buf));
6393 + if (nntp_query (&nntp_data, buf, sizeof (buf)) < 0)
6396 + if (sscanf (buf, "111 %4d%2d%2d%2d%2d%2d%*s", &tm.tm_year, &tm.tm_mon,
6397 + &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) == 6)
6399 + tm.tm_year -= 1900;
6401 + *now = timegm (&tm);
6404 + dprint (1, (debugfile, "nntp_date: server time is %d\n", *now));
6413 +/* Fetch list of all newsgroups from server */
6414 +int nntp_active_fetch (NNTP_SERVER *nserv, unsigned int new)
6416 + NNTP_DATA nntp_data;
6417 + char msg[SHORT_STRING];
6418 + char buf[LONG_STRING];
6422 + snprintf (msg, sizeof (msg), _("Loading list of groups from server %s..."),
6423 + nserv->conn->account.host);
6424 + mutt_message (msg);
6425 + if (nntp_date (nserv, &nserv->newgroups_time) < 0)
6428 + nntp_data.nserv = nserv;
6429 + nntp_data.group = NULL;
6430 + i = nserv->groups_num;
6431 + strfcpy (buf, "LIST\r\n", sizeof (buf));
6432 + rc = nntp_fetch_lines (&nntp_data, buf, sizeof (buf), msg,
6433 + nntp_add_group, nserv);
6438 + mutt_error ("LIST: %s", buf);
6446 + for (; i < nserv->groups_num; i++)
6448 + NNTP_DATA *nntp_data = nserv->groups_list[i];
6449 + nntp_data->new = 1;
6453 + for (i = 0; i < nserv->groups_num; i++)
6455 + NNTP_DATA *nntp_data = nserv->groups_list[i];
6457 + if (nntp_data && nntp_data->deleted && !nntp_data->newsrc_ent)
6459 + nntp_delete_group_cache (nntp_data);
6460 + hash_delete (nserv->groups_hash, nntp_data->group, NULL, nntp_data_free);
6461 + nserv->groups_list[i] = NULL;
6465 + if (option (OPTLOADDESC))
6466 + rc = get_description (&nntp_data, "*", _("Loading descriptions..."));
6468 + nntp_active_save_cache (nserv);
6471 + mutt_clear_error ();
6475 +/* Check newsgroup for new articles:
6476 + * 1 - new articles found
6478 + * -1 - lost connection */
6479 +static int nntp_group_poll (NNTP_DATA *nntp_data, int update_stat)
6481 + char buf[LONG_STRING] = "";
6482 + anum_t count, first, last;
6484 + /* use GROUP command to poll newsgroup */
6485 + if (nntp_query (nntp_data, buf, sizeof (buf)) < 0)
6487 + if (sscanf (buf, "211 " ANUM " " ANUM " " ANUM, &count, &first, &last) != 3)
6489 + if (first == nntp_data->firstMessage && last == nntp_data->lastMessage)
6492 + /* articles have been renumbered */
6493 + if (last < nntp_data->lastMessage)
6495 + nntp_data->lastCached = 0;
6496 + if (nntp_data->newsrc_len)
6498 + safe_realloc (&nntp_data->newsrc_ent, sizeof (NEWSRC_ENTRY));
6499 + nntp_data->newsrc_len = 1;
6500 + nntp_data->newsrc_ent[0].first = 1;
6501 + nntp_data->newsrc_ent[0].last = 0;
6504 + nntp_data->firstMessage = first;
6505 + nntp_data->lastMessage = last;
6509 + /* update counters */
6510 + else if (!last || (!nntp_data->newsrc_ent && !nntp_data->lastCached))
6511 + nntp_data->unread = count;
6513 + nntp_group_unread_stat (nntp_data);
6517 +/* Check current newsgroup for new articles, leave newsrc locked:
6518 + * MUTT_REOPENED - articles have been renumbered or removed from server
6519 + * MUTT_NEW_MAIL - new articles found
6521 + * -1 - lost connection */
6522 +static int check_mailbox (CONTEXT *ctx)
6524 + NNTP_DATA *nntp_data = ctx->data;
6525 + NNTP_SERVER *nserv = nntp_data->nserv;
6526 + time_t now = time (NULL);
6531 + if (nserv->check_time + NewsPollTimeout > now)
6534 + mutt_message _("Checking for new messages...");
6535 + if (nntp_newsrc_parse (nserv) < 0)
6538 + nserv->check_time = now;
6539 + rc = nntp_group_poll (nntp_data, 0);
6542 + nntp_newsrc_close (nserv);
6546 + nntp_active_save_cache (nserv);
6548 + /* articles have been renumbered, remove all headers */
6549 + if (nntp_data->lastMessage < nntp_data->lastLoaded)
6551 + for (i = 0; i < ctx->msgcount; i++)
6552 + mutt_free_header (&ctx->hdrs[i]);
6553 + ctx->msgcount = 0;
6556 + if (nntp_data->lastMessage < nntp_data->lastLoaded)
6558 + nntp_data->lastLoaded = nntp_data->firstMessage - 1;
6559 + if (NntpContext && nntp_data->lastMessage - nntp_data->lastLoaded >
6561 + nntp_data->lastLoaded = nntp_data->lastMessage - NntpContext;
6563 + ret = MUTT_REOPENED;
6566 + /* .newsrc has been externally modified */
6567 + if (nserv->newsrc_modified)
6571 + unsigned char *messages;
6575 + anum_t first = nntp_data->firstMessage;
6577 + if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext)
6578 + first = nntp_data->lastMessage - NntpContext + 1;
6579 + messages = safe_calloc (nntp_data->lastLoaded - first + 1,
6580 + sizeof (unsigned char));
6581 + hc = nntp_hcache_open (nntp_data);
6582 + nntp_hcache_update (nntp_data, hc);
6585 + /* update flags according to .newsrc */
6586 + for (i = j = 0; i < ctx->msgcount; i++)
6589 + anum = NHDR (ctx->hdrs[i])->article_num;
6592 + /* check hcache for flagged and deleted flags */
6595 + if (anum >= first && anum <= nntp_data->lastLoaded)
6596 + messages[anum - first] = 1;
6598 + snprintf (buf, sizeof (buf), "%d", anum);
6599 + hdata = mutt_hcache_fetch (hc, buf, strlen);
6604 + dprint (2, (debugfile,
6605 + "nntp_check_mailbox: mutt_hcache_fetch %s\n", buf));
6606 + hdr = mutt_hcache_restore (hdata, NULL);
6609 + deleted = hdr->deleted;
6610 + flagged = hdr->flagged;
6611 + mutt_free_header (&hdr);
6613 + /* header marked as deleted, removing from context */
6616 + mutt_set_flag (ctx, ctx->hdrs[i], MUTT_TAG, 0);
6617 + mutt_free_header (&ctx->hdrs[i]);
6624 + if (!ctx->hdrs[i]->changed)
6626 + ctx->hdrs[i]->flagged = flagged;
6627 + ctx->hdrs[i]->read = 0;
6628 + ctx->hdrs[i]->old = 0;
6629 + nntp_article_status (ctx, ctx->hdrs[i], NULL, anum);
6630 + if (!ctx->hdrs[i]->read)
6631 + nntp_parse_xref (ctx, ctx->hdrs[i]);
6633 + ctx->hdrs[j++] = ctx->hdrs[i];
6637 + ctx->msgcount = j;
6639 + /* restore headers without "deleted" flag */
6640 + for (anum = first; anum <= nntp_data->lastLoaded; anum++)
6642 + if (messages[anum - first])
6645 + snprintf (buf, sizeof (buf), "%d", anum);
6646 + hdata = mutt_hcache_fetch (hc, buf, strlen);
6649 + dprint (2, (debugfile,
6650 + "nntp_check_mailbox: mutt_hcache_fetch %s\n", buf));
6651 + if (ctx->msgcount >= ctx->hdrmax)
6652 + mx_alloc_memory (ctx);
6654 + ctx->hdrs[ctx->msgcount] =
6655 + hdr = mutt_hcache_restore (hdata, NULL);
6660 + mutt_free_header (&hdr);
6661 + if (nntp_data->bcache)
6663 + dprint (2, (debugfile,
6664 + "nntp_check_mailbox: mutt_bcache_del %s\n", buf));
6665 + mutt_bcache_del (nntp_data->bcache, buf);
6673 + hdr->data = safe_calloc (1, sizeof (NNTP_HEADER_DATA));
6674 + NHDR (hdr)->article_num = anum;
6675 + nntp_article_status (ctx, hdr, NULL, anum);
6677 + nntp_parse_xref (ctx, hdr);
6683 + nserv->newsrc_modified = 0;
6684 + ret = MUTT_REOPENED;
6687 + /* some headers were removed, context must be updated */
6688 + if (ret == MUTT_REOPENED)
6690 + if (ctx->subj_hash)
6691 + hash_destroy (&ctx->subj_hash, NULL);
6693 + hash_destroy (&ctx->id_hash, NULL);
6694 + mutt_clear_threads (ctx);
6702 + ctx->id_hash = NULL;
6703 + ctx->subj_hash = NULL;
6704 + mx_update_context (ctx, ctx->msgcount);
6707 + /* fetch headers of new articles */
6708 + if (nntp_data->lastMessage > nntp_data->lastLoaded)
6710 + int oldmsgcount = ctx->msgcount;
6711 + int quiet = ctx->quiet;
6716 + hc = nntp_hcache_open (nntp_data);
6717 + nntp_hcache_update (nntp_data, hc);
6720 + rc = nntp_fetch_headers (ctx, hc, nntp_data->lastLoaded + 1,
6721 + nntp_data->lastMessage, 0);
6722 + ctx->quiet = quiet;
6724 + nntp_data->lastLoaded = nntp_data->lastMessage;
6725 + if (ret == 0 && ctx->msgcount > oldmsgcount)
6726 + ret = MUTT_NEW_MAIL;
6730 + mutt_hcache_close (hc);
6733 + nntp_newsrc_close (nserv);
6734 + mutt_clear_error ();
6738 +/* Check current newsgroup for new articles:
6739 + * MUTT_REOPENED - articles have been renumbered or removed from server
6740 + * MUTT_NEW_MAIL - new articles found
6742 + * -1 - lost connection */
6743 +static int nntp_check_mailbox (CONTEXT *ctx, int *index_hint)
6745 + int ret = check_mailbox (ctx);
6748 + NNTP_DATA *nntp_data = ctx->data;
6749 + NNTP_SERVER *nserv = nntp_data->nserv;
6750 + nntp_newsrc_close (nserv);
6755 +/* Save changes to .newsrc and cache */
6756 +static int nntp_sync_mailbox (CONTEXT *ctx, int *index_hint)
6758 + NNTP_DATA *nntp_data = ctx->data;
6761 + header_cache_t *hc;
6764 + /* check for new articles */
6765 + nntp_data->nserv->check_time = 0;
6766 + rc = check_mailbox (ctx);
6771 + nntp_data->lastCached = 0;
6772 + hc = nntp_hcache_open (nntp_data);
6775 + for (i = 0; i < ctx->msgcount; i++)
6777 + HEADER *hdr = ctx->hdrs[i];
6780 + snprintf (buf, sizeof (buf), "%d", NHDR (hdr)->article_num);
6781 + if (nntp_data->bcache && hdr->deleted)
6783 + dprint (2, (debugfile, "nntp_sync_mailbox: mutt_bcache_del %s\n", buf));
6784 + mutt_bcache_del (nntp_data->bcache, buf);
6788 + if (hc && (hdr->changed || hdr->deleted))
6790 + dprint (2, (debugfile, "nntp_sync_mailbox: mutt_hcache_store %s\n", buf));
6791 + mutt_hcache_store (hc, buf, hdr, 0, strlen, MUTT_GENERATE_UIDVALIDITY);
6799 + mutt_hcache_close (hc);
6800 + nntp_data->lastCached = nntp_data->lastLoaded;
6804 + /* save .newsrc entries */
6805 + nntp_newsrc_gen_entries (ctx);
6806 + nntp_newsrc_update (nntp_data->nserv);
6807 + nntp_newsrc_close (nntp_data->nserv);
6811 +/* Check for new groups and new articles in subscribed groups:
6812 + * 1 - new groups found
6813 + * 0 - no new groups
6815 +int nntp_check_new_groups (NNTP_SERVER *nserv)
6817 + NNTP_DATA nntp_data;
6820 + char buf[LONG_STRING];
6821 + char *msg = _("Checking for new newsgroups...");
6823 + int rc, update_active = FALSE;
6825 + if (!nserv || !nserv->newgroups_time)
6828 + /* check subscribed newsgroups for new articles */
6829 + if (option (OPTSHOWNEWNEWS))
6831 + mutt_message _("Checking for new messages...");
6832 + for (i = 0; i < nserv->groups_num; i++)
6834 + NNTP_DATA *nntp_data = nserv->groups_list[i];
6836 + if (nntp_data && nntp_data->subscribed)
6838 + rc = nntp_group_poll (nntp_data, 1);
6842 + update_active = TRUE;
6845 + /* select current newsgroup */
6846 + if (Context && Context->magic == MUTT_NNTP)
6849 + if (nntp_query ((NNTP_DATA *)Context->data, buf, sizeof (buf)) < 0)
6853 + else if (nserv->newgroups_time)
6856 + /* get list of new groups */
6857 + mutt_message (msg);
6858 + if (nntp_date (nserv, &now) < 0)
6860 + nntp_data.nserv = nserv;
6861 + if (Context && Context->magic == MUTT_NNTP)
6862 + nntp_data.group = ((NNTP_DATA *)Context->data)->group;
6864 + nntp_data.group = NULL;
6865 + i = nserv->groups_num;
6866 + tm = gmtime (&nserv->newgroups_time);
6867 + snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
6868 + tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday,
6869 + tm->tm_hour, tm->tm_min, tm->tm_sec);
6870 + rc = nntp_fetch_lines (&nntp_data, buf, sizeof (buf), msg,
6871 + nntp_add_group, nserv);
6876 + mutt_error ("NEWGROUPS: %s", buf);
6882 + /* new groups found */
6884 + if (nserv->groups_num != i)
6886 + int groups_num = i;
6888 + nserv->newgroups_time = now;
6889 + for (; i < nserv->groups_num; i++)
6891 + NNTP_DATA *nntp_data = nserv->groups_list[i];
6892 + nntp_data->new = 1;
6895 + /* loading descriptions */
6896 + if (option (OPTLOADDESC))
6898 + unsigned int count = 0;
6899 + progress_t progress;
6901 + mutt_progress_init (&progress, _("Loading descriptions..."),
6902 + MUTT_PROGRESS_MSG, ReadInc, nserv->groups_num - i);
6903 + for (i = groups_num; i < nserv->groups_num; i++)
6905 + NNTP_DATA *nntp_data = nserv->groups_list[i];
6907 + if (get_description (nntp_data, NULL, NULL) < 0)
6909 + mutt_progress_update (&progress, ++count, -1);
6912 + update_active = TRUE;
6915 + if (update_active)
6916 + nntp_active_save_cache (nserv);
6917 + mutt_clear_error ();
6921 +/* Fetch article by Message-ID:
6923 + * 1 - no such article
6925 +int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
6927 + NNTP_DATA *nntp_data = ctx->data;
6930 + char tempfile[_POSIX_PATH_MAX];
6931 + char buf[LONG_STRING];
6934 + mutt_mktemp (tempfile, sizeof (tempfile));
6935 + fp = safe_fopen (tempfile, "w+");
6938 + mutt_perror (tempfile);
6939 + unlink (tempfile);
6943 + snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
6944 + rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL,
6945 + fetch_tempfile, fp);
6949 + unlink (tempfile);
6952 + if (!mutt_strncmp ("430", buf, 3))
6954 + mutt_error ("HEAD: %s", buf);
6958 + /* parse header */
6959 + if (ctx->msgcount == ctx->hdrmax)
6960 + mx_alloc_memory (ctx);
6961 + hdr = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
6962 + hdr->data = safe_calloc (1, sizeof (NNTP_HEADER_DATA));
6963 + hdr->env = mutt_read_rfc822_header (fp, hdr, 0, 0);
6965 + unlink (tempfile);
6967 + /* get article number */
6968 + if (hdr->env->xref)
6969 + nntp_parse_xref (ctx, hdr);
6972 + snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
6973 + if (nntp_query (nntp_data, buf, sizeof (buf)) < 0)
6975 + mutt_free_header (&hdr);
6978 + sscanf (buf + 4, ANUM, &NHDR (hdr)->article_num);
6986 + hdr->received = hdr->date_sent;
6987 + hdr->index = ctx->msgcount++;
6988 + mx_update_context (ctx, 1);
7000 +/* Parse XPAT line */
7001 +static int fetch_children (char *line, void *data)
7003 + CHILD_CTX *cc = data;
7007 + if (!line || sscanf (line, ANUM, &anum) != 1)
7009 + for (i = 0; i < cc->ctx->msgcount; i++)
7010 + if (NHDR (cc->ctx->hdrs[i])->article_num == anum)
7012 + if (cc->num >= cc->max)
7015 + safe_realloc (&cc->child, sizeof (anum_t) * cc->max);
7017 + cc->child[cc->num++] = anum;
7021 +/* Fetch children of article with the Message-ID */
7022 +int nntp_check_children (CONTEXT *ctx, const char *msgid)
7024 + NNTP_DATA *nntp_data = ctx->data;
7030 + if (!nntp_data || !nntp_data->nserv)
7032 + if (nntp_data->firstMessage > nntp_data->lastLoaded)
7035 + /* init context */
7039 + cc.child = safe_malloc (sizeof (anum_t) * cc.max);
7041 + /* fetch numbers of child messages */
7042 + snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
7043 + nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
7044 + rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL,
7045 + fetch_children, &cc);
7050 + if (mutt_strncmp ("500", buf, 3))
7051 + mutt_error ("XPAT: %s", buf);
7053 + mutt_error _("Unable to find child articles because server does not support XPAT command.");
7058 + /* fetch all found messages */
7059 + quiet = ctx->quiet;
7062 + hc = nntp_hcache_open (nntp_data);
7064 + for (i = 0; i < cc.num; i++)
7066 + rc = nntp_fetch_headers (ctx, hc, cc.child[i], cc.child[i], 1);
7071 + mutt_hcache_close (hc);
7073 + ctx->quiet = quiet;
7075 + return rc < 0 ? -1 : 0;
7078 +struct mx_ops mx_nntp_ops = {
7079 + .open = nntp_open_mailbox,
7080 + .open_append = NULL,
7081 + .close = nntp_close_mailbox,
7082 + .open_msg = nntp_open_message,
7083 + .close_msg = nntp_close_message,
7084 + .check = nntp_check_mailbox,
7085 + .commit_msg = NULL,
7086 + .open_new_msg = NULL,
7087 + .sync = nntp_sync_mailbox,
7089 diff -udprP mutt-1.10.0.orig/nntp.h mutt-1.10.0/nntp.h
7090 --- mutt-1.10.0.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300
7091 +++ mutt-1.10.0/nntp.h 2018-06-16 17:22:30.200469636 +0300
7094 + * Copyright (C) 1998 Brandon Long <blong@fiction.net>
7095 + * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
7096 + * Copyright (C) 2000-2016 Vsevolod Volkov <vvv@mutt.org.ua>
7098 + * This program is free software; you can redistribute it and/or modify
7099 + * it under the terms of the GNU General Public License as published by
7100 + * the Free Software Foundation; either version 2 of the License, or
7101 + * (at your option) any later version.
7103 + * This program is distributed in the hope that it will be useful,
7104 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7105 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7106 + * GNU General Public License for more details.
7108 + * You should have received a copy of the GNU General Public License
7109 + * along with this program; if not, write to the Free Software
7110 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7116 +#include "mutt_socket.h"
7117 +#include "mailbox.h"
7118 +#include "bcache.h"
7121 +#include "hcache.h"
7125 +#include <sys/types.h>
7126 +#include <stdint.h>
7128 +#define NNTP_PORT 119
7129 +#define NNTP_SSL_PORT 563
7131 +/* number of entries in article cache */
7132 +#define NNTP_ACACHE_LEN 10
7134 +/* article number type and format */
7135 +#define anum_t uint32_t
7147 + unsigned int hasCAPABILITIES : 1;
7148 + unsigned int hasSTARTTLS : 1;
7149 + unsigned int hasDATE : 1;
7150 + unsigned int hasLIST_NEWSGROUPS : 1;
7151 + unsigned int hasXGTITLE : 1;
7152 + unsigned int hasLISTGROUP : 1;
7153 + unsigned int hasLISTGROUPrange : 1;
7154 + unsigned int hasOVER : 1;
7155 + unsigned int hasXOVER : 1;
7156 + unsigned int use_tls : 3;
7157 + unsigned int status : 3;
7158 + unsigned int cacheable : 1;
7159 + unsigned int newsrc_modified : 1;
7161 + char *newsrc_file;
7162 + char *authenticators;
7163 + char *overview_fmt;
7166 + time_t newgroups_time;
7167 + time_t check_time;
7168 + unsigned int groups_num;
7169 + unsigned int groups_max;
7170 + void **groups_list;
7171 + HASH *groups_hash;
7183 + unsigned int index;
7191 + anum_t firstMessage;
7192 + anum_t lastMessage;
7193 + anum_t lastLoaded;
7194 + anum_t lastCached;
7196 + unsigned int subscribed : 1;
7197 + unsigned int new : 1;
7198 + unsigned int allowed : 1;
7199 + unsigned int deleted : 1;
7200 + unsigned int newsrc_len;
7201 + NEWSRC_ENTRY *newsrc_ent;
7202 + NNTP_SERVER *nserv;
7203 + NNTP_ACACHE acache[NNTP_ACACHE_LEN];
7204 + body_cache_t *bcache;
7209 + anum_t article_num;
7210 + unsigned int parsed : 1;
7211 +} NNTP_HEADER_DATA;
7213 +#define NHDR(hdr) ((NNTP_HEADER_DATA*)((hdr)->data))
7215 +/* internal functions */
7216 +int nntp_add_group (char *, void *);
7217 +int nntp_active_save_cache (NNTP_SERVER *);
7218 +int nntp_check_new_groups (NNTP_SERVER *);
7219 +int nntp_open_connection (NNTP_SERVER *);
7220 +void nntp_newsrc_gen_entries (CONTEXT *);
7221 +void nntp_bcache_update (NNTP_DATA *);
7222 +void nntp_article_status (CONTEXT *, HEADER *, char *, anum_t);
7223 +void nntp_group_unread_stat (NNTP_DATA *);
7224 +void nntp_data_free (void *);
7225 +void nntp_acache_free (NNTP_DATA *);
7226 +void nntp_delete_group_cache (NNTP_DATA *);
7228 +/* exposed interface */
7229 +NNTP_SERVER *nntp_select_server (char *, int);
7230 +NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
7231 +NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
7232 +NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
7233 +NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
7234 +int nntp_active_fetch (NNTP_SERVER *, unsigned int);
7235 +int nntp_newsrc_update (NNTP_SERVER *);
7236 +int nntp_post (const char *);
7237 +int nntp_check_msgid (CONTEXT *, const char *);
7238 +int nntp_check_children (CONTEXT *, const char *);
7239 +int nntp_newsrc_parse (NNTP_SERVER *);
7240 +void nntp_newsrc_close (NNTP_SERVER *);
7241 +void nntp_buffy (char *, size_t);
7242 +void nntp_expand_path (char *, size_t, ACCOUNT *);
7243 +void nntp_clear_cache (NNTP_SERVER *);
7244 +const char *nntp_format_str (char *, size_t, size_t, int, char, const char *,
7245 + const char *, const char *, const char *,
7246 + unsigned long, format_flag);
7248 +NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
7251 +header_cache_t *nntp_hcache_open (NNTP_DATA *);
7252 +void nntp_hcache_update (NNTP_DATA *, header_cache_t *);
7255 +extern struct mx_ops mx_nntp_ops;
7257 +#endif /* _NNTP_H_ */
7258 diff -udprP mutt-1.10.0.orig/pager.c mutt-1.10.0/pager.c
7259 --- mutt-1.10.0.orig/pager.c 2018-05-15 00:51:53.000000000 +0300
7260 +++ mutt-1.10.0/pager.c 2018-06-16 17:22:30.201469620 +0300
7261 @@ -1114,6 +1114,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos,
7271 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
7272 int flags, ansi_attr *pa, int cnt,
7273 @@ -1584,6 +1589,15 @@ static const struct mapping_t PagerHelpE
7274 { N_("Next"), OP_MAIN_NEXT_UNDELETED },
7278 +static struct mapping_t PagerNewsHelpExtra[] = {
7279 + { N_("Post"), OP_POST },
7280 + { N_("Followup"), OP_FOLLOWUP },
7281 + { N_("Del"), OP_DELETE },
7282 + { N_("Next"), OP_MAIN_NEXT_UNDELETED },
7287 void mutt_clear_pager_position (void)
7289 @@ -1923,6 +1937,10 @@ mutt_pager (const char *banner, const ch
7291 pager_redraw_data_t rd;
7294 + char *followup_to;
7297 if (!(flags & MUTT_SHOWCOLOR))
7298 flags |= MUTT_SHOWFLAT;
7300 @@ -1972,7 +1990,11 @@ mutt_pager (const char *banner, const ch
7301 if (IsHeader (extra))
7303 strfcpy (tmphelp, helpstr, sizeof (tmphelp));
7304 - mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra);
7305 + mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
7307 + (Context && (Context->magic == MUTT_NNTP)) ? PagerNewsHelpExtra :
7310 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
7313 @@ -2639,6 +2661,60 @@ search_next:
7314 pager_menu->redraw = REDRAW_FULL;
7319 + CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
7321 + if (extra->ctx && extra->ctx->magic == MUTT_NNTP &&
7322 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
7323 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES)
7325 + ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
7326 + pager_menu->redraw = REDRAW_FULL;
7329 + case OP_FORWARD_TO_GROUP:
7330 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
7332 + if (extra->ctx && extra->ctx->magic == MUTT_NNTP &&
7333 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
7334 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES)
7336 + if (IsMsgAttach (extra))
7337 + mutt_attach_forward (extra->fp, extra->hdr, extra->actx,
7338 + extra->bdy, SENDNEWS);
7340 + ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
7341 + pager_menu->redraw = REDRAW_FULL;
7345 + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
7348 + if (IsMsgAttach (extra))
7349 + followup_to = extra->bdy->hdr->env->followup_to;
7351 + followup_to = extra->hdr->env->followup_to;
7353 + if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
7354 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != MUTT_YES)
7356 + if (extra->ctx && extra->ctx->magic == MUTT_NNTP &&
7357 + !((NNTP_DATA *)extra->ctx->data)->allowed &&
7358 + query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES)
7360 + if (IsMsgAttach (extra))
7361 + mutt_attach_reply (extra->fp, extra->hdr, extra->actx,
7362 + extra->bdy, SENDNEWS|SENDREPLY);
7364 + ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
7365 + extra->ctx, extra->hdr);
7366 + pager_menu->redraw = REDRAW_FULL;
7372 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
7374 @@ -2684,7 +2760,7 @@ search_next:
7376 if (IsMsgAttach (extra))
7377 mutt_attach_forward (extra->fp, extra->hdr, extra->actx,
7381 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
7382 pager_menu->redraw = REDRAW_FULL;
7383 diff -udprP mutt-1.10.0.orig/parse.c mutt-1.10.0/parse.c
7384 --- mutt-1.10.0.orig/parse.c 2017-12-18 22:31:37.000000000 +0200
7385 +++ mutt-1.10.0/parse.c 2018-06-16 17:22:30.201469620 +0300
7386 @@ -94,7 +94,7 @@ char *mutt_read_rfc822_line (FILE *f, ch
7390 -static LIST *mutt_parse_references (char *s, int in_reply_to)
7391 +LIST *mutt_parse_references (char *s, int in_reply_to)
7393 LIST *t, *lst = NULL;
7395 @@ -1077,6 +1077,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
7396 e->from = rfc822_parse_adrlist (e->from, p);
7400 + else if (!mutt_strcasecmp (line+1, "ollowup-to"))
7402 + if (!e->followup_to)
7404 + mutt_remove_trailing_ws (p);
7405 + e->followup_to = safe_strdup (mutt_skip_whitespace (p));
7413 @@ -1159,6 +1170,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
7419 + if (!mutt_strcasecmp (line + 1, "ewsgroups"))
7421 + FREE (&e->newsgroups);
7422 + mutt_remove_trailing_ws (p);
7423 + e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
7430 + /* field `Organization:' saves only for pager! */
7431 + if (!mutt_strcasecmp (line + 1, "rganization"))
7433 + if (!e->organization && mutt_strcasecmp (p, "unknown"))
7434 + e->organization = safe_strdup (p);
7439 if (!ascii_strcasecmp (line + 1, "eferences"))
7441 @@ -1271,6 +1303,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
7442 e->x_label = safe_strdup(p);
7446 + else if (!mutt_strcasecmp (line + 1, "-comment-to"))
7448 + if (!e->x_comment_to)
7449 + e->x_comment_to = safe_strdup (p);
7452 + else if (!mutt_strcasecmp (line + 1, "ref"))
7455 + e->xref = safe_strdup (p);
7462 diff -udprP mutt-1.10.0.orig/pattern.c mutt-1.10.0/pattern.c
7463 --- mutt-1.10.0.orig/pattern.c 2018-05-15 00:51:53.000000000 +0300
7464 +++ mutt-1.10.0/pattern.c 2018-06-16 17:22:30.201469620 +0300
7465 @@ -94,6 +94,9 @@ Flags[] =
7466 { 'U', MUTT_UNREAD, 0, NULL },
7467 { 'v', MUTT_COLLAPSED, 0, NULL },
7468 { 'V', MUTT_CRYPT_VERIFIED, 0, NULL },
7470 + { 'w', MUTT_NEWSGROUPS, 0, eat_regexp },
7472 { 'x', MUTT_REFERENCE, 0, eat_regexp },
7473 { 'X', MUTT_MIMEATTACH, 0, eat_range },
7474 { 'y', MUTT_XLABEL, 0, eat_regexp },
7475 @@ -1368,6 +1371,10 @@ mutt_pattern_exec (struct pattern_t *pat
7476 return (pat->not ^ match_mime_content_type (pat, ctx, h));
7477 case MUTT_UNREFERENCED:
7478 return (pat->not ^ (h->thread && !h->thread->child));
7480 + case MUTT_NEWSGROUPS:
7481 + return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0));
7484 mutt_error (_("error: unknown op %d (report this error)."), pat->op);
7486 @@ -1449,6 +1456,7 @@ int mutt_pattern_func (int op, char *pro
7487 progress_t progress;
7489 strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
7490 + if (prompt || op != MUTT_LIMIT)
7491 if (mutt_get_field (prompt, buf, sizeof (buf), MUTT_PATTERN | MUTT_CLEAR) != 0 || !buf[0])
7494 diff -udprP mutt-1.10.0.orig/po/POTFILES.in mutt-1.10.0/po/POTFILES.in
7495 --- mutt-1.10.0.orig/po/POTFILES.in 2017-12-18 22:31:37.000000000 +0200
7496 +++ mutt-1.10.0/po/POTFILES.in 2018-06-16 17:22:30.201469620 +0300
7497 @@ -47,6 +47,8 @@ mutt_ssl_gnutls.c
7506 diff -udprP mutt-1.10.0.orig/postpone.c mutt-1.10.0/postpone.c
7507 --- mutt-1.10.0.orig/postpone.c 2018-04-17 02:31:03.000000000 +0300
7508 +++ mutt-1.10.0/postpone.c 2018-06-16 17:22:30.201469620 +0300
7509 @@ -125,15 +125,26 @@ int mutt_num_postponed (int force)
7511 if (LastModify < st.st_mtime)
7514 + int optnews = option (OPTNEWS);
7516 LastModify = st.st_mtime;
7518 if (access (Postponed, R_OK | F_OK) != 0)
7519 return (PostCount = 0);
7522 + unset_option (OPTNEWS);
7524 if (mx_open_mailbox (Postponed, MUTT_NOSORT | MUTT_QUIET, &ctx) == NULL)
7527 PostCount = ctx.msgcount;
7528 mx_fastclose_mailbox (&ctx);
7531 + set_option (OPTNEWS);
7536 diff -udprP mutt-1.10.0.orig/protos.h mutt-1.10.0/protos.h
7537 --- mutt-1.10.0.orig/protos.h 2018-05-15 00:51:53.000000000 +0300
7538 +++ mutt-1.10.0/protos.h 2018-06-16 17:22:30.202469604 +0300
7539 @@ -111,6 +111,7 @@ HASH *mutt_make_id_hash (CONTEXT *);
7540 HASH *mutt_make_subj_hash (CONTEXT *);
7542 LIST *mutt_make_references(ENVELOPE *e);
7543 +LIST *mutt_parse_references (char *, int);
7545 char *mutt_read_rfc822_line (FILE *, char *, size_t *);
7546 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
7547 diff -udprP mutt-1.10.0.orig/recvattach.c mutt-1.10.0/recvattach.c
7548 --- mutt-1.10.0.orig/recvattach.c 2018-05-15 00:51:53.000000000 +0300
7549 +++ mutt-1.10.0/recvattach.c 2018-06-16 17:22:30.202469604 +0300
7550 @@ -1224,6 +1224,15 @@ void mutt_view_attachments (HEADER *hdr)
7555 + if (Context->magic == MUTT_NNTP)
7558 + mutt_error _("Can't delete attachment from news server.");
7563 if (WithCrypto && (hdr->security & ENCRYPT))
7566 @@ -1318,10 +1327,32 @@ void mutt_view_attachments (HEADER *hdr)
7567 case OP_FORWARD_MESSAGE:
7569 mutt_attach_forward (CURATTACH->fp, hdr, actx,
7570 - menu->tagprefix ? NULL : CURATTACH->content);
7571 + menu->tagprefix ? NULL : CURATTACH->content, 0);
7572 menu->redraw = REDRAW_FULL;
7576 + case OP_FORWARD_TO_GROUP:
7578 + mutt_attach_forward (CURATTACH->fp, hdr, actx,
7579 + menu->tagprefix ? NULL : CURATTACH->content, SENDNEWS);
7580 + menu->redraw = REDRAW_FULL;
7586 + if (!CURATTACH->content->hdr->env->followup_to ||
7587 + mutt_strcasecmp (CURATTACH->content->hdr->env->followup_to, "poster") ||
7588 + query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != MUTT_YES)
7590 + mutt_attach_reply (CURATTACH->fp, hdr, actx,
7591 + menu->tagprefix ? NULL : CURATTACH->content, SENDNEWS|SENDREPLY);
7592 + menu->redraw = REDRAW_FULL;
7598 case OP_GROUP_REPLY:
7600 diff -udprP mutt-1.10.0.orig/recvcmd.c mutt-1.10.0/recvcmd.c
7601 --- mutt-1.10.0.orig/recvcmd.c 2017-12-18 22:31:37.000000000 +0200
7602 +++ mutt-1.10.0/recvcmd.c 2018-06-16 17:22:30.202469604 +0300
7603 @@ -398,7 +398,7 @@ static BODY ** copy_problematic_attachme
7604 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
7605 ATTACH_CONTEXT *actx,
7608 + short nattach, int flags)
7611 short mime_fwd_all = 0;
7612 @@ -554,7 +554,7 @@ _("Can't decode all tagged attachments.
7615 /* now that we have the template, send it. */
7616 - ci_send_message (0, tmphdr, tmpbody, NULL, parent_hdr);
7617 + ci_send_message (flags, tmphdr, tmpbody, NULL, parent_hdr);
7621 @@ -581,7 +581,7 @@ _("Can't decode all tagged attachments.
7624 static void attach_forward_msgs (FILE * fp, HEADER * hdr,
7625 - ATTACH_CONTEXT *actx, BODY * cur)
7626 + ATTACH_CONTEXT *actx, BODY * cur, int flags)
7628 HEADER *curhdr = NULL;
7630 @@ -686,23 +686,23 @@ static void attach_forward_msgs (FILE *
7632 mutt_free_header (&tmphdr);
7634 - ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL,
7635 + ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL,
7640 void mutt_attach_forward (FILE * fp, HEADER * hdr,
7641 - ATTACH_CONTEXT *actx, BODY * cur)
7642 + ATTACH_CONTEXT *actx, BODY * cur, int flags)
7647 if (check_all_msg (actx, cur, 0) == 0)
7648 - attach_forward_msgs (fp, hdr, actx, cur);
7649 + attach_forward_msgs (fp, hdr, actx, cur, flags);
7652 nattach = count_tagged (actx);
7653 - attach_forward_bodies (fp, hdr, actx, cur, nattach);
7654 + attach_forward_bodies (fp, hdr, actx, cur, nattach, flags);
7658 @@ -760,6 +760,17 @@ attach_reply_envelope_defaults (ENVELOPE
7663 + if ((flags & SENDNEWS))
7665 + /* in case followup set Newsgroups: with Followup-To: if it present */
7666 + if (!env->newsgroups && curenv &&
7667 + mutt_strcasecmp (curenv->followup_to, "poster"))
7668 + env->newsgroups = safe_strdup (curenv->followup_to);
7675 if (mutt_fetch_recips (env, curenv, flags) == -1)
7676 @@ -782,6 +793,7 @@ attach_reply_envelope_defaults (ENVELOPE
7679 mutt_fix_reply_recipients (env);
7681 mutt_make_misc_reply_headers (env, Context, curhdr, curenv);
7684 @@ -844,6 +856,13 @@ void mutt_attach_reply (FILE * fp, HEADE
7685 char prefix[SHORT_STRING];
7689 + if (flags & SENDNEWS)
7690 + set_option (OPTNEWSSEND);
7692 + unset_option (OPTNEWSSEND);
7695 if (check_all_msg (actx, cur, 0) == -1)
7697 nattach = count_tagged (actx);
7698 diff -udprP mutt-1.10.0.orig/send.c mutt-1.10.0/send.c
7699 --- mutt-1.10.0.orig/send.c 2018-05-15 00:51:53.000000000 +0300
7700 +++ mutt-1.10.0/send.c 2018-06-16 17:22:30.202469604 +0300
7702 #include <sys/types.h>
7711 #include "remailer.h"
7713 @@ -214,17 +219,51 @@ static int edit_address (ADDRESS **a, /*
7717 -static int edit_envelope (ENVELOPE *en)
7718 +static int edit_envelope (ENVELOPE *en, int flags)
7720 char buf[HUGE_STRING];
7721 LIST *uh = UserHeader;
7724 + if (option (OPTNEWSSEND))
7726 + if (en->newsgroups)
7727 + strfcpy (buf, en->newsgroups, sizeof (buf));
7730 + if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
7732 + FREE (&en->newsgroups);
7733 + en->newsgroups = safe_strdup (buf);
7735 + if (en->followup_to)
7736 + strfcpy (buf, en->followup_to, sizeof (buf));
7739 + if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
7741 + FREE (&en->followup_to);
7742 + en->followup_to = safe_strdup (buf);
7744 + if (en->x_comment_to)
7745 + strfcpy (buf, en->x_comment_to, sizeof (buf));
7748 + if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
7750 + FREE (&en->x_comment_to);
7751 + en->x_comment_to = safe_strdup (buf);
7756 if (edit_address (&en->to, _("To: ")) == -1 || en->to == NULL)
7758 if (option (OPTASKCC) && edit_address (&en->cc, _("Cc: ")) == -1)
7760 if (option (OPTASKBCC) && edit_address (&en->bcc, _("Bcc: ")) == -1)
7766 @@ -259,6 +298,14 @@ static int edit_envelope (ENVELOPE *en)
7771 +char *nntp_get_header (const char *s)
7774 + return safe_strdup (s);
7778 static void process_user_recips (ENVELOPE *env)
7780 LIST *uh = UserHeader;
7781 @@ -271,6 +318,14 @@ static void process_user_recips (ENVELOP
7782 env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
7783 else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
7784 env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
7786 + else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
7787 + env->newsgroups = nntp_get_header (uh->data + 11);
7788 + else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
7789 + env->followup_to = nntp_get_header (uh->data + 12);
7790 + else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
7791 + env->x_comment_to = nntp_get_header (uh->data + 13);
7796 @@ -309,6 +364,12 @@ static void process_user_header (ENVELOP
7797 else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
7798 ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
7799 ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
7801 + ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
7802 + ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
7803 + ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
7805 + ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
7806 ascii_strncasecmp ("subject:", uh->data, 8) != 0 &&
7807 ascii_strncasecmp ("return-path:", uh->data, 12) != 0)
7809 @@ -656,6 +717,10 @@ void mutt_add_to_reference_headers (ENVE
7814 + if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
7815 + env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
7820 @@ -718,6 +783,16 @@ envelope_defaults (ENVELOPE *env, CONTEX
7822 if (flags & SENDREPLY)
7825 + if ((flags & SENDNEWS))
7827 + /* in case followup set Newsgroups: with Followup-To: if it present */
7828 + if (!env->newsgroups && curenv &&
7829 + mutt_strcasecmp (curenv->followup_to, "poster"))
7830 + env->newsgroups = safe_strdup (curenv->followup_to);
7837 @@ -864,7 +939,18 @@ void mutt_set_followup_to (ENVELOPE *e)
7838 * it hasn't already been set
7841 - if (option (OPTFOLLOWUPTO) && !e->mail_followup_to)
7842 + if (!option (OPTFOLLOWUPTO))
7845 + if (option (OPTNEWSSEND))
7847 + if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
7848 + e->followup_to = safe_strdup (e->newsgroups);
7853 + if (!e->mail_followup_to)
7855 if (mutt_is_list_cc (0, e->to, e->cc))
7857 @@ -1026,6 +1112,9 @@ static int send_message (HEADER *msg)
7862 + if (!option (OPTNEWSSEND))
7865 return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc,
7866 msg->env->bcc, tempfile,
7867 @@ -1189,6 +1278,13 @@ ci_send_message (int flags, /* send mod
7872 + if (flags & SENDNEWS)
7873 + set_option (OPTNEWSSEND);
7875 + unset_option (OPTNEWSSEND);
7878 if (!flags && !msg && quadoption (OPT_RECALL) != MUTT_NO &&
7879 mutt_num_postponed (1))
7881 @@ -1224,6 +1320,22 @@ ci_send_message (int flags, /* send mod
7883 if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
7887 + * If postponed message is a news article, it have
7888 + * a "Newsgroups:" header line, then set appropriate flag.
7890 + if (msg->env->newsgroups)
7892 + flags |= SENDNEWS;
7893 + set_option (OPTNEWSSEND);
7897 + flags &= ~SENDNEWS;
7898 + unset_option (OPTNEWSSEND);
7903 if (flags & (SENDPOSTPONED|SENDRESEND))
7904 @@ -1325,11 +1437,16 @@ ci_send_message (int flags, /* send mod
7905 if (flags & SENDREPLY)
7906 mutt_fix_reply_recipients (msg->env);
7909 + if ((flags & SENDNEWS) && ctx && ctx->magic == MUTT_NNTP && !msg->env->newsgroups)
7910 + msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
7913 if (! (flags & (SENDMAILX|SENDBATCH)) &&
7914 ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
7915 ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
7917 - if (edit_envelope (msg->env) == -1)
7918 + if (edit_envelope (msg->env, flags) == -1)
7922 @@ -1640,6 +1757,11 @@ main_loop:
7927 + if (flags & SENDNEWS)
7928 + mutt_message _("Article not posted.");
7931 mutt_message _("Mail not sent.");
7934 @@ -1706,6 +1828,9 @@ main_loop:
7939 + if (!(flags & SENDNEWS))
7941 if (!has_recips (msg->env->to) && !has_recips (msg->env->cc) &&
7942 !has_recips (msg->env->bcc))
7944 @@ -1739,6 +1864,19 @@ main_loop:
7945 mutt_error _("No subject specified.");
7949 + if ((flags & SENDNEWS) && !msg->env->subject)
7951 + mutt_error _("No subject specified.");
7955 + if ((flags & SENDNEWS) && !msg->env->newsgroups)
7957 + mutt_error _("No newsgroup specified.");
7962 /* Scan for a mention of an attachment in the message body and
7963 * prompt if there is none. */
7964 @@ -1964,7 +2102,12 @@ full_fcc:
7967 else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
7968 - mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
7969 + mutt_message (i != 0 ? _("Sending in background.") :
7971 + (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
7976 if (WithCrypto && (msg->security & ENCRYPT))
7978 diff -udprP mutt-1.10.0.orig/sendlib.c mutt-1.10.0/sendlib.c
7979 --- mutt-1.10.0.orig/sendlib.c 2018-05-15 00:51:53.000000000 +0300
7980 +++ mutt-1.10.0/sendlib.c 2018-06-16 17:22:30.203469588 +0300
7982 #include <sys/wait.h>
7989 #ifdef HAVE_SYSEXITS_H
7990 #include <sysexits.h>
7991 #else /* Make sure EX_OK is defined <philiph@pobox.com> */
7992 @@ -1576,6 +1580,14 @@ void mutt_write_references (LIST *r, FIL
7995 int refcnt = 0, refmax = 0;
7996 + int multiline = 1;
8005 for ( ; (trim == 0 || refcnt < trim) && r ; r = r->next)
8007 @@ -1586,9 +1598,11 @@ void mutt_write_references (LIST *r, FIL
8009 while (refcnt-- > 0)
8012 + if (multiline || space)
8015 fputs (ref[refcnt]->data, f);
8017 + if (multiline && refcnt >= 1)
8021 @@ -2002,6 +2016,9 @@ int mutt_write_rfc822_header (FILE *fp,
8022 mutt_write_address_list (env->to, fp, 4, 0);
8026 + if (!option (OPTNEWSSEND))
8028 fputs ("To: \n", fp);
8031 @@ -2010,6 +2027,9 @@ int mutt_write_rfc822_header (FILE *fp,
8032 mutt_write_address_list (env->cc, fp, 4, 0);
8036 + if (!option (OPTNEWSSEND))
8038 fputs ("Cc: \n", fp);
8041 @@ -2021,8 +2041,28 @@ int mutt_write_rfc822_header (FILE *fp,
8046 + if (!option (OPTNEWSSEND))
8048 fputs ("Bcc: \n", fp);
8051 + if (env->newsgroups)
8052 + fprintf (fp, "Newsgroups: %s\n", env->newsgroups);
8053 + else if (mode == 1 && option (OPTNEWSSEND))
8054 + fputs ("Newsgroups: \n", fp);
8056 + if (env->followup_to)
8057 + fprintf (fp, "Followup-To: %s\n", env->followup_to);
8058 + else if (mode == 1 && option (OPTNEWSSEND))
8059 + fputs ("Followup-To: \n", fp);
8061 + if (env->x_comment_to)
8062 + fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to);
8063 + else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO))
8064 + fputs ("X-Comment-To: \n", fp);
8068 mutt_write_one_header (fp, "Subject", env->subject, NULL, 0, 0);
8070 @@ -2041,6 +2081,9 @@ int mutt_write_rfc822_header (FILE *fp,
8071 fputs ("Reply-To: \n", fp);
8073 if (env->mail_followup_to)
8075 + if (!option (OPTNEWSSEND))
8078 fputs ("Mail-Followup-To: ", fp);
8079 mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
8080 @@ -2388,6 +2431,24 @@ mutt_invoke_sendmail (ADDRESS *from, /*
8081 size_t extra_argslen = 0, extra_argsmax = 0;
8085 + if (option (OPTNEWSSEND))
8087 + char cmd[LONG_STRING];
8089 + mutt_FormatString (cmd, sizeof (cmd), 0, MuttIndexWindow->cols,
8090 + NONULL (Inews), nntp_format_str, 0, 0);
8093 + i = nntp_post (msg);
8098 + s = safe_strdup (cmd);
8102 /* ensure that $sendmail is set to avoid a crash. http://dev.mutt.org/trac/ticket/3548 */
8105 @@ -2437,6 +2498,10 @@ mutt_invoke_sendmail (ADDRESS *from, /*
8110 + if (!option (OPTNEWSSEND))
8113 if (eightbit && option (OPTUSE8BITMIME))
8114 args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
8116 @@ -2470,6 +2535,9 @@ mutt_invoke_sendmail (ADDRESS *from, /*
8117 args = add_args (args, &argslen, &argsmax, to);
8118 args = add_args (args, &argslen, &argsmax, cc);
8119 args = add_args (args, &argslen, &argsmax, bcc);
8124 if (argslen == argsmax)
8125 safe_realloc (&args, sizeof (char *) * (++argsmax));
8126 @@ -2558,6 +2626,9 @@ void mutt_prepare_envelope (ENVELOPE *en
8127 rfc2047_encode_string (&env->x_label);
8131 + if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
8134 rfc2047_encode_string (&env->subject);
8136 @@ -2678,6 +2749,10 @@ int mutt_bounce_message (FILE *fp, HEADE
8138 rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
8141 + unset_option (OPTNEWSSEND);
8145 * prepare recipient list. idna conversion appears to happen before this
8146 * function is called, since the user receives confirmation of the address
8147 diff -udprP mutt-1.10.0.orig/sort.c mutt-1.10.0/sort.c
8148 --- mutt-1.10.0.orig/sort.c 2017-12-18 22:31:37.000000000 +0200
8149 +++ mutt-1.10.0/sort.c 2018-06-16 17:22:30.203469588 +0300
8152 #include "mutt_idna.h"
8162 @@ -151,6 +156,17 @@ static int compare_order (const void *a,
8163 HEADER **ha = (HEADER **) a;
8164 HEADER **hb = (HEADER **) b;
8167 + if (Context && Context->magic == MUTT_NNTP)
8169 + anum_t na = NHDR (*ha)->article_num;
8170 + anum_t nb = NHDR (*hb)->article_num;
8171 + int result = na == nb ? 0 : na > nb ? 1 : -1;
8172 + AUXSORT (result, a, b);
8173 + return (SORTCODE (result));
8177 /* no need to auxsort because you will never have equality here */
8178 return (SORTCODE ((*ha)->index - (*hb)->index));
8180 diff -udprP mutt-1.10.0.orig/url.c mutt-1.10.0/url.c
8181 --- mutt-1.10.0.orig/url.c 2017-12-18 22:31:37.000000000 +0200
8182 +++ mutt-1.10.0/url.c 2018-06-16 17:22:30.203469588 +0300
8183 @@ -40,6 +40,8 @@ static const struct mapping_t UrlMap[] =
8184 { "imaps", U_IMAPS },
8187 + { "news", U_NNTP },
8188 + { "snews", U_NNTPS },
8189 { "mailto", U_MAILTO },
8191 { "smtps", U_SMTPS },
8192 @@ -224,7 +226,7 @@ int url_ciss_tostring (ciss_url_t* ciss,
8193 safe_strcat (dest, len, "//");
8194 len -= (l = strlen (dest)); dest += l;
8197 + if (ciss->user && (ciss->user[0] || !(flags & U_PATH)))
8200 url_pct_encode (u, sizeof (u), ciss->user);
8201 diff -udprP mutt-1.10.0.orig/url.h mutt-1.10.0/url.h
8202 --- mutt-1.10.0.orig/url.h 2017-12-03 05:10:17.000000000 +0200
8203 +++ mutt-1.10.0/url.h 2018-06-16 17:22:30.203469588 +0300
8204 @@ -8,6 +8,8 @@ typedef enum url_scheme
8213 diff -udprP mutt-1.10.0.orig/Makefile.am mutt-1.10.0/Makefile.am
8214 --- mutt-1.10.0.orig/Makefile.am 2018-05-15 00:51:53.000000000 +0300
8215 +++ mutt-1.10.0/Makefile.am 2018-06-16 17:22:30.203469588 +0300
8216 @@ -60,6 +60,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
8217 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
8218 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
8219 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
8221 sidebar.c smime.c smtp.c utf8.c wcwidth.c \
8222 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
8224 @@ -71,6 +72,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
8225 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
8226 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
8227 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
8228 + nntp.h ChangeLog.nntp \
8229 _mutt_regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
8230 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
8231 README.SSL smime.h group.h \
8232 diff -udprP mutt-1.10.0.orig/Makefile.in mutt-1.10.0/Makefile.in
8233 --- mutt-1.10.0.orig/Makefile.in 2018-05-15 04:08:48.000000000 +0300
8234 +++ mutt-1.10.0/Makefile.in 2018-06-16 17:22:30.203469588 +0300
8235 @@ -504,6 +504,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c
8236 mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
8237 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
8238 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
8240 sidebar.c smime.c smtp.c utf8.c wcwidth.c \
8241 bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h
8243 @@ -515,6 +516,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O
8244 mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
8245 mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
8246 rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \
8247 + nntp.h ChangeLog.nntp \
8248 _mutt_regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
8249 mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
8250 README.SSL smime.h group.h \
8251 @@ -784,6 +786,8 @@ distclean-compile:
8252 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@
8253 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@
8254 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@
8255 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@
8256 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@
8257 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@
8258 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
8259 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@
8260 diff -udprP mutt-1.10.0.orig/configure mutt-1.10.0/configure
8261 --- mutt-1.10.0.orig/configure 2018-05-19 20:34:20.000000000 +0300
8262 +++ mutt-1.10.0/configure 2018-06-16 17:22:30.205469557 +0300
8263 @@ -802,6 +802,7 @@ with_docdir
8271 @@ -1487,6 +1488,7 @@ Optional Features:
8272 Force use of an external dotlock program
8273 --enable-pop Enable POP3 support
8274 --enable-imap Enable IMAP support
8275 + --enable-nntp Enable NNTP support
8276 --enable-smtp include internal SMTP relay support
8277 --enable-debug Enable debugging support
8278 --enable-flock Use flock() to lock files
8279 @@ -9750,6 +9752,20 @@ else
8283 +# Check whether --enable-nntp was given.
8284 +if test "${enable_nntp+set}" = set; then :
8285 + enableval=$enable_nntp; if test x$enableval = xyes ; then
8287 +$as_echo "#define USE_NNTP 1" >>confdefs.h
8289 + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o"
8297 # Check whether --enable-smtp was given.
8298 if test "${enable_smtp+set}" = set; then :
8299 enableval=$enable_smtp; if test $enableval = yes; then
8300 @@ -9762,7 +9778,7 @@ $as_echo "#define USE_SMTP 1" >>confdefs
8304 -if test x"$need_imap" = xyes -o x"$need_pop" = xyes ; then
8305 +if test x"$need_imap" = xyes -o x"$need_pop" = xyes -o x"$need_nntp" = xyes ; then
8306 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
8309 diff -udprP mutt-1.10.0.orig/doc/Muttrc mutt-1.10.0/doc/Muttrc
8310 --- mutt-1.10.0.orig/doc/Muttrc 2018-05-19 20:47:52.000000000 +0300
8311 +++ mutt-1.10.0/doc/Muttrc 2018-06-16 17:22:30.206469541 +0300
8312 @@ -275,6 +275,28 @@ attachments -I message/external-body
8313 # editing the body of an outgoing message.
8316 +# set ask_follow_up=no
8318 +# Name: ask_follow_up
8323 +# If set, Mutt will prompt you for follow-up groups before editing
8324 +# the body of an outgoing message.
8327 +# set ask_x_comment_to=no
8329 +# Name: ask_x_comment_to
8334 +# If set, Mutt will prompt you for x-comment-to field before editing
8335 +# the body of an outgoing message.
8338 # set assumed_charset=""
8340 # Name: assumed_charset
8341 @@ -516,6 +538,17 @@ attachments -I message/external-body
8342 # desirable to unset this variable.
8345 +# set catchup_newsgroup=ask-yes
8347 +# Name: catchup_newsgroup
8352 +# If this variable is set, Mutt will mark all articles in newsgroup
8353 +# as read when you quit the newsgroup (catchup newsgroup).
8356 # set certificate_file="~/.mutt_certificates"
8358 # Name: certificate_file
8359 @@ -1294,6 +1327,19 @@ attachments -I message/external-body
8360 # of the same email for you.
8363 +# set followup_to_poster=ask-yes
8365 +# Name: followup_to_poster
8370 +# If this variable is set and the keyword "poster" is present in
8371 +# Followup-To header, follow-up to newsgroup function is not
8372 +# permitted. The message will be mailed to the submitter of the
8373 +# message via mail.
8379 @@ -1430,6 +1476,27 @@ attachments -I message/external-body
8380 # ``Franklin'' to ``Franklin, Steve''.
8383 +# set group_index_format="%4C %M%N %5s %-45.45f %d"
8385 +# Name: group_index_format
8387 +# Default: "%4C %M%N %5s %-45.45f %d"
8390 +# This variable allows you to customize the newsgroup browser display to
8391 +# your personal taste. This string is similar to ``index_format'', but
8392 +# has its own set of printf()-like sequences:
8393 +# %C current newsgroup number
8394 +# %d description of newsgroup (becomes from server)
8395 +# %f newsgroup name
8396 +# %M - if newsgroup not allowed for direct post (moderated for example)
8397 +# %N N if newsgroup is new, u if unsubscribed, blank otherwise
8398 +# %n number of new articles in newsgroup
8399 +# %s number of unread articles in newsgroup
8400 +# %>X right justify the rest of the string and pad with character "X"
8401 +# %|X pad to the end of the line with character "X"
8407 @@ -2046,6 +2113,7 @@ attachments -I message/external-body
8408 # %E number of messages in current thread
8409 # %f sender (address + real name), either From: or Return-Path:
8410 # %F author name, or recipient name if the message is from you
8411 +# %g newsgroup name (if compiled with NNTP support)
8412 # %H spam attribute(s) of this message
8413 # %i message-id of the current message
8414 # %l number of lines in the message (does not work with maildir,
8415 @@ -2069,6 +2137,8 @@ attachments -I message/external-body
8416 # %T the appropriate character from the $to_chars string
8417 # %u user (login) name of the author
8418 # %v first name of the author, or the recipient if the message is from you
8419 +# %W name of organization of author (``Organization:'' field)
8420 +# %x ``X-Comment-To:'' field (if present and compiled with NNTP support)
8421 # %X number of attachments
8422 # (please see the ``attachments'' section for possible speed effects)
8423 # %y ``X-Label:'' field, if present
8424 @@ -2108,6 +2178,27 @@ attachments -I message/external-body
8425 # ``save-hook'', ``fcc-hook'' and ``fcc-save-hook'', too.
8435 +# If set, specifies the program and arguments used to deliver news posted
8436 +# by Mutt. Otherwise, mutt posts article using current connection to
8437 +# news server. The following printf-style sequence is understood:
8440 +# %P port if specified
8441 +# %s news server name
8446 +# Example: set inews="/usr/local/bin/inews -hS"
8449 # set ispell="/usr/bin/ispell"
8452 @@ -2555,6 +2646,18 @@ attachments -I message/external-body
8453 # mime.types lookup.
8456 +# set mime_subject=yes
8458 +# Name: mime_subject
8463 +# If unset, 8-bit ``subject:'' line in article header will not be
8464 +# encoded according to RFC2047 to base64. This is useful when message
8465 +# is Usenet article, because MIME for news is nonstandard feature.
8468 # set mix_entry_format="%4n %c %-16s %a"
8470 # Name: mix_entry_format
8471 @@ -2633,6 +2736,144 @@ attachments -I message/external-body
8472 # into this command.
8475 +# set news_cache_dir="~/.mutt"
8477 +# Name: news_cache_dir
8479 +# Default: "~/.mutt"
8482 +# This variable pointing to directory where Mutt will save cached news
8483 +# articles and headers in. If unset, articles and headers will not be
8484 +# saved at all and will be reloaded from the server each time.
8487 +# set news_server=""
8489 +# Name: news_server
8494 +# This variable specifies domain name or address of NNTP server. It
8495 +# defaults to the news server specified in the environment variable
8496 +# $NNTPSERVER or contained in the file /etc/nntpserver. You can also
8497 +# specify username and an alternative port for each news server, ie:
8499 +# [[s]news://][username[:password]@]server[:port]
8502 +# set newsgroups_charset="utf-8"
8504 +# Name: newsgroups_charset
8509 +# Character set of newsgroups descriptions.
8512 +# set newsrc="~/.newsrc"
8516 +# Default: "~/.newsrc"
8519 +# The file, containing info about subscribed newsgroups - names and
8520 +# indexes of read articles. The following printf-style sequence
8524 +# %P port if specified
8525 +# %s news server name
8530 +# set nntp_authenticators=""
8532 +# Name: nntp_authenticators
8537 +# This is a colon-delimited list of authentication methods mutt may
8538 +# attempt to use to log in to a news server, in the order mutt should
8539 +# try them. Authentication methods are either ``user'' or any
8540 +# SASL mechanism, e.g. ``digest-md5'', ``gssapi'' or ``cram-md5''.
8541 +# This option is case-insensitive. If it's unset (the default)
8542 +# mutt will try all available methods, in order from most-secure to
8546 +# set nntp_authenticators="digest-md5:user"
8548 +# Note: Mutt will only fall back to other authentication methods if
8549 +# the previous methods are unavailable. If a method is available but
8550 +# authentication fails, mutt will not connect to the IMAP server.
8553 +# set nntp_context=1000
8555 +# Name: nntp_context
8560 +# This variable defines number of articles which will be in index when
8561 +# newsgroup entered. If active newsgroup have more articles than this
8562 +# number, oldest articles will be ignored. Also controls how many
8563 +# articles headers will be saved in cache when you quit newsgroup.
8566 +# set nntp_load_description=yes
8568 +# Name: nntp_load_description
8573 +# This variable controls whether or not descriptions for each newsgroup
8574 +# must be loaded when newsgroup is added to list (first time list
8575 +# loading or new newsgroup adding).
8585 +# Your login name on the NNTP server. If unset and NNTP server requires
8586 +# authentification, Mutt will prompt you for your account name when you
8587 +# connect to news server.
8597 +# Your password for NNTP account.
8607 +# The time in seconds until any operations on newsgroup except post new
8608 +# article will cause recheck for new news. If set to 0, Mutt will
8609 +# recheck newsgroup on each operation in index (stepping, read article,
8613 # set pager="builtin"
8616 @@ -3411,6 +3652,19 @@ attachments -I message/external-body
8617 # string after the inclusion of a message which is being replied to.
8620 +# set post_moderated=ask-yes
8622 +# Name: post_moderated
8627 +# If set to yes, Mutt will post article to newsgroup that have
8628 +# not permissions to posting (e.g. moderated). Note: if news server
8629 +# does not support posting to that newsgroup or totally read-only, that
8630 +# posting will not have an effect.
8633 # set postpone=ask-yes
8636 @@ -4285,6 +4539,41 @@ attachments -I message/external-body
8637 # Chinese characters.
8640 +# set save_unsubscribed=no
8642 +# Name: save_unsubscribed
8647 +# When set, info about unsubscribed newsgroups will be saved into
8648 +# ``newsrc'' file and into cache.
8651 +# set show_new_news=yes
8653 +# Name: show_new_news
8658 +# If set, news server will be asked for new newsgroups on entering
8659 +# the browser. Otherwise, it will be done only once for a news server.
8660 +# Also controls whether or not number of new articles of subscribed
8661 +# newsgroups will be then checked.
8664 +# set show_only_unread=no
8666 +# Name: show_only_unread
8671 +# If set, only subscribed newsgroups that contain unread articles
8672 +# will be displayed in browser.
8675 # set sig_dashes=yes
8678 @@ -5671,3 +5960,14 @@ attachments -I message/external-body
8679 # ``tuning'' section of the manual for performance considerations.
8682 +# set x_comment_to=no
8684 +# Name: x_comment_to
8689 +# If set, Mutt will add ``X-Comment-To:'' field (that contains full
8690 +# name of original article author) to article that followuped to newsgroup.