Mageia Bugzilla – Attachment 5676 Details for
Bug 14707
mutt new security issue CVE-2014-9116
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
Mageia SVN diff for update to 1.5.23
mutt-1.5.21-1.5.23-mgarepo.diff (text/plain), 714.31 KB, created by
Theodoros Kalamatianos
on 2014-12-03 14:53:36 CET
(
hide
)
Description:
Mageia SVN diff for update to 1.5.23
Filename:
MIME Type:
Creator:
Theodoros Kalamatianos
Created:
2014-12-03 14:53:36 CET
Size:
714.31 KB
patch
obsolete
>Index: SOURCES/mutt-1.5.12-indexcolor-3+cb.diff >=================================================================== >--- SOURCES/mutt-1.5.12-indexcolor-3+cb.diff (revision 800495) >+++ SOURCES/mutt-1.5.12-indexcolor-3+cb.diff (working copy) >@@ -1,614 +0,0 @@ >-diff --git a/color.c b/color.c >-index bb6cbb4..c295dc4 100644 >---- a/color.c >-+++ b/color.c >-@@ -35,6 +35,8 @@ int ColorDefs[MT_COLOR_MAX]; >- COLOR_LINE *ColorHdrList = NULL; >- COLOR_LINE *ColorBodyList = NULL; >- COLOR_LINE *ColorIndexList = NULL; >-+COLOR_LINE *ColorIndexSubjectList = NULL; >-+COLOR_LINE *ColorIndexAuthorList = NULL; >- >- /* local to this file */ >- static int ColorQuoteSize; >-@@ -93,6 +95,14 @@ static struct mapping_t Fields[] = >- { "bold", MT_COLOR_BOLD }, >- { "underline", MT_COLOR_UNDERLINE }, >- { "index", MT_COLOR_INDEX }, >-+ { "index_subject", MT_COLOR_INDEX_SUBJECT }, >-+ { "index_author", MT_COLOR_INDEX_AUTHOR }, >-+ { "index_collapsed", MT_COLOR_INDEX_COLLAPSED }, >-+ { "index_date", MT_COLOR_INDEX_DATE }, >-+ { "index_flags", MT_COLOR_INDEX_FLAGS }, >-+ { "index_label", MT_COLOR_INDEX_LABEL }, >-+ { "index_number", MT_COLOR_INDEX_NUMBER }, >-+ { "index_size", MT_COLOR_INDEX_SIZE }, >- { "sidebar_new", MT_COLOR_NEW }, >- { "sidebar_flagged", MT_COLOR_FLAGGED }, >- { NULL, 0 } >-@@ -366,11 +376,54 @@ int mutt_parse_unmono (BUFFER *buf, BUFFER *s, unsigned long data, >- return _mutt_parse_uncolor(buf, s, data, err, 0); >- } >- >-+static void >-+mutt_do_uncolor (BUFFER *buf, BUFFER *s, COLOR_LINE **ColorList, >-+ int *do_cache, int parse_uncolor) >-+{ >-+ COLOR_LINE *tmp, *last = NULL; >-+ >-+ do >-+ { >-+ mutt_extract_token (buf, s, 0); >-+ if (!mutt_strcmp ("*", buf->data)) >-+ { >-+ for (tmp = *ColorList; tmp; ) >-+ { >-+ if (!*do_cache) >-+ *do_cache = 1; >-+ last = tmp; >-+ tmp = tmp->next; >-+ mutt_free_color_line(&last, parse_uncolor); >-+ } >-+ *ColorList = NULL; >-+ } >-+ else >-+ { >-+ for (last = NULL, tmp = *ColorList; tmp; last = tmp, tmp = tmp->next) >-+ { >-+ if (!mutt_strcmp (buf->data, tmp->pattern)) >-+ { >-+ if (!*do_cache) >-+ *do_cache = 1; >-+ dprint(1,(debugfile,"Freeing pattern \"%s\" from ColorList\n", >-+ tmp->pattern)); >-+ if (last) >-+ last->next = tmp->next; >-+ else >-+ *ColorList = tmp->next; >-+ mutt_free_color_line(&tmp, parse_uncolor); >-+ break; >-+ } >-+ } >-+ } >-+ } >-+ while (MoreArgs (s)); >-+} >-+ >- static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, >- BUFFER *err, short parse_uncolor) >- { >- int object = 0, do_cache = 0; >-- COLOR_LINE *tmp, *last = NULL; >- COLOR_LINE **list; >- >- mutt_extract_token (buf, s, 0); >-@@ -381,6 +434,13 @@ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, >- return (-1); >- } >- >-+ if (object > MT_COLOR_INDEX_AUTHOR) /* uncolor index column */ >-+ { >-+ ColorDefs[object] = 0; >-+ set_option (OPTFORCEREDRAWINDEX); >-+ return (0); >-+ } >-+ >- if (mutt_strncmp (buf->data, "index", 5) == 0) >- list = &ColorIndexList; >- else if (mutt_strncmp (buf->data, "body", 4) == 0) >-@@ -424,43 +484,13 @@ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, >- return 0; >- } >- >-- do >-- { >-- mutt_extract_token (buf, s, 0); >-- if (!mutt_strcmp ("*", buf->data)) >-- { >-- for (tmp = *list; tmp; ) >-- { >-- if (!do_cache) >-- do_cache = 1; >-- last = tmp; >-- tmp = tmp->next; >-- mutt_free_color_line(&last, parse_uncolor); >-- } >-- *list = NULL; >-- } >-- else >-- { >-- for (last = NULL, tmp = *list; tmp; last = tmp, tmp = tmp->next) >-- { >-- if (!mutt_strcmp (buf->data, tmp->pattern)) >-- { >-- if (!do_cache) >-- do_cache = 1; >-- dprint(1,(debugfile,"Freeing pattern \"%s\" from color list\n", >-- tmp->pattern)); >-- if (last) >-- last->next = tmp->next; >-- else >-- *list = tmp->next; >-- mutt_free_color_line(&tmp, parse_uncolor); >-- break; >-- } >-- } >-- } >-- } >-- while (MoreArgs (s)); >- >-+ if (object == MT_COLOR_INDEX) >-+ mutt_do_uncolor(buf, s, &ColorIndexList, &do_cache, parse_uncolor); >-+ if (object == MT_COLOR_INDEX_SUBJECT) >-+ mutt_do_uncolor(buf, s, &ColorIndexSubjectList, &do_cache, parse_uncolor); >-+ if (object == MT_COLOR_INDEX_AUTHOR) >-+ mutt_do_uncolor(buf, s, &ColorIndexAuthorList, &do_cache, parse_uncolor); >- >- if (do_cache && !option (OPTNOCURSES)) >- { >-@@ -700,7 +730,7 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err, >- >- /* extract a regular expression if needed */ >- >-- if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY || object == MT_COLOR_INDEX) >-+ if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY || object == MT_COLOR_INDEX || object == MT_COLOR_INDEX_SUBJECT || object == MT_COLOR_INDEX_AUTHOR) >- { >- if (!MoreArgs (s)) >- { >-@@ -744,6 +774,18 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err, >- r = add_pattern (&ColorIndexList, buf->data, 1, fg, bg, attr, err, 1); >- set_option (OPTFORCEREDRAWINDEX); >- } >-+ else if (object == MT_COLOR_INDEX_SUBJECT) >-+ { >-+ r = add_pattern (&ColorIndexSubjectList, buf->data, >-+ 1, fg, bg, attr, err, 1); >-+ set_option (OPTFORCEREDRAWINDEX); >-+ } >-+ else if (object == MT_COLOR_INDEX_AUTHOR) >-+ { >-+ r = add_pattern (&ColorIndexAuthorList, buf->data, >-+ 1, fg, bg, attr, err, 1); >-+ set_option (OPTFORCEREDRAWINDEX); >-+ } >- else if (object == MT_COLOR_QUOTED) >- { >- if (q_level >= ColorQuoteSize) >-@@ -769,7 +811,11 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err, >- ColorQuote[q_level] = fgbgattr_to_color(fg, bg, attr); >- } >- else >-+ { >- ColorDefs[object] = fgbgattr_to_color(fg, bg, attr); >-+ if (object > MT_COLOR_INDEX_AUTHOR) >-+ set_option (OPTFORCEREDRAWINDEX); >-+ } >- >- #ifdef HAVE_COLOR >- # ifdef HAVE_BKGDSET >-diff --git a/curs_lib.c b/curs_lib.c >-index 2427e60..dc01320 100644 >---- a/curs_lib.c >-+++ b/curs_lib.c >-@@ -711,6 +711,7 @@ void mutt_format_string (char *dest, size_t destlen, >- size_t k, k2; >- char scratch[MB_LEN_MAX]; >- mbstate_t mbstate1, mbstate2; >-+ int escaped = 0; >- >- memset(&mbstate1, 0, sizeof (mbstate1)); >- memset(&mbstate2, 0, sizeof (mbstate2)); >-@@ -726,7 +727,15 @@ void mutt_format_string (char *dest, size_t destlen, >- k = (k == (size_t)(-1)) ? 1 : n; >- wc = replacement_char (); >- } >-- if (arboreal && wc < M_TREE_MAX) >-+ if (escaped) { >-+ escaped = 0; >-+ w = 0; >-+ } >-+ else if (arboreal && wc == M_SPECIAL_INDEX) { >-+ escaped = 1; >-+ w = 0; >-+ } >-+ else if (arboreal && wc < M_TREE_MAX) >- w = 1; /* hack */ >- else >- { >-diff --git a/doc/manual.xml.head b/doc/manual.xml.head >-index 74c33da..b9dad0f 100644 >---- a/doc/manual.xml.head >-+++ b/doc/manual.xml.head >-@@ -2470,7 +2470,7 @@ silently truncated at the screen width, and are not wrapped. >- >- <command>color</command> >- <arg choice="plain"> >--<option>index</option> >-+<option>index-object</option> >- </arg> >- <arg choice="plain"> >- <replaceable class="parameter">foreground</replaceable> >-@@ -2485,7 +2485,7 @@ silently truncated at the screen width, and are not wrapped. >- <command>uncolor</command> >- <group choice="req"> >- <arg choice="plain"> >--<option>index</option> >-+<option>index-object</option> >- </arg> >- <arg choice="plain"> >- <option>header</option> >-@@ -2526,6 +2526,14 @@ in the header/body of a message, <emphasis>index</emphasis> matches <emphasis>pa >- <listitem><para>bold (hiliting bold patterns in the body of messages)</para></listitem> >- <listitem><para>error (error messages printed by Mutt)</para></listitem> >- <listitem><para>hdrdefault (default color of the message header in the pager)</para></listitem> >-+<listitem><para>index_author (color of the author name in the index, uses <emphasis>pattern</emphasis>)</para></listitem> >-+<listitem><para>index_collapsed (the number of messages in a collapsed thread in the index)</para></listitem> >-+<listitem><para>index_date (color of the date field in the index)</para></listitem> >-+<listitem><para>index_flags (color of the message flags in the index)</para></listitem> >-+<listitem><para>index_label (color of the message label in the index)</para></listitem> >-+<listitem><para>index_number (color of the message number in the index)</para></listitem> >-+<listitem><para>index_size (color of the message size and line number in the index)</para></listitem> >-+<listitem><para>index_subject (color of the subject in the index, uses <emphasis>pattern</emphasis>)</para></listitem> >- <listitem><para>indicator (arrow or bar used to indicate the current item in a menu)</para></listitem> >- <listitem><para>markers (the <quote>+</quote> markers at the beginning of wrapped lines in the pager)</para></listitem> >- <listitem><para>message (informational messages)</para></listitem> >-diff --git a/hdrline.c b/hdrline.c >-index 23f596e..effae17 100644 >---- a/hdrline.c >-+++ b/hdrline.c >-@@ -103,6 +103,34 @@ static int first_mailing_list (char *buf, size_t buflen, ADDRESS *a) >- return 0; >- } >- >-+/* Takes the color to embed, the buffer to manipulate and the buffer length as >-+ * arguments. >-+ * Returns the number of chars written. */ >-+static size_t add_index_color(char *buf, size_t buflen, >-+ format_flag flags, char color) >-+{ >-+ int len; >-+ >-+ /* only add color markers if we are operating on main index entries. */ >-+ if (!(flags & M_FORMAT_INDEX)) >-+ return 0; >-+ >-+ if (color == MT_COLOR_INDEX) { /* buf might be uninitialized other cases */ >-+ len = mutt_strlen(buf); >-+ buf += len; >-+ buflen -= len; >-+ } >-+ >-+ if (buflen < 2) >-+ return 0; >-+ >-+ buf[0] = M_SPECIAL_INDEX; >-+ buf[1] = color; >-+ buf[2] = '\0'; >-+ >-+ return 2; >-+} >-+ >- static void make_from (ENVELOPE *hdr, char *buf, size_t len, int do_lists) >- { >- int me; >-@@ -256,6 +284,7 @@ hdr_format_str (char *dest, >- #define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 1) >- #define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 2) >- size_t len; >-+ size_t colorlen; >- >- hdr = hfi->hdr; >- ctx = hfi->ctx; >-@@ -307,12 +336,17 @@ hdr_format_str (char *dest, >- break; >- >- case 'c': >-+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE); >- mutt_pretty_size (buf2, sizeof (buf2), (long) hdr->content->length); >-- mutt_format_s (dest, destlen, prefix, buf2); >-+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); >-+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >- break; >- >- case 'C': >-- snprintf (fmt, sizeof (fmt), "%%%sd", prefix); >-+ colorlen = add_index_color(fmt, sizeof(fmt), flags, MT_COLOR_INDEX_NUMBER); >-+ snprintf (fmt+colorlen, sizeof(fmt)-colorlen, "%%%sd", prefix); >-+ add_index_color(fmt+colorlen, sizeof(fmt)-colorlen, flags, MT_COLOR_INDEX); >-+ >- snprintf (dest, destlen, fmt, hdr->msgno + 1); >- break; >- >-@@ -411,7 +445,10 @@ hdr_format_str (char *dest, >- if (do_locales) >- setlocale (LC_TIME, "C"); >- >-- mutt_format_s (dest, destlen, prefix, buf2); >-+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_DATE); >-+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); >-+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >-+ >- if (len > 0 && op != 'd' && op != 'D') /* Skip ending op */ >- src = cp + 1; >- } >-@@ -441,8 +478,10 @@ hdr_format_str (char *dest, >- case 'F': >- if (!optional) >- { >-+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); >- make_from (hdr->env, buf2, sizeof (buf2), 0); >-- mutt_format_s (dest, destlen, prefix, buf2); >-+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); >-+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >- } >- else if (mutt_addr_is_user (hdr->env->from)) >- optional = 0; >-@@ -474,7 +513,9 @@ hdr_format_str (char *dest, >- if (!optional) >- { >- snprintf (fmt, sizeof (fmt), "%%%sd", prefix); >-- snprintf (dest, destlen, fmt, (int) hdr->lines); >-+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE); >-+ snprintf (dest+colorlen, destlen-colorlen, fmt, (int) hdr->lines); >-+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >- } >- else if (hdr->lines <= 0) >- optional = 0; >-@@ -483,8 +524,10 @@ hdr_format_str (char *dest, >- case 'L': >- if (!optional) >- { >-+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); >- make_from (hdr->env, buf2, sizeof (buf2), 1); >-- mutt_format_s (dest, destlen, prefix, buf2); >-+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); >-+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >- } >- else if (!check_for_mailing_list (hdr->env->to, NULL, NULL, 0) && >- !check_for_mailing_list (hdr->env->cc, NULL, NULL, 0)) >-@@ -539,10 +582,16 @@ hdr_format_str (char *dest, >- snprintf (fmt, sizeof (fmt), "%%%sd", prefix); >- if (!optional) >- { >-- if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1) >-- snprintf (dest, destlen, fmt, hdr->num_hidden); >-- else if (is_index && threads) >-- mutt_format_s (dest, destlen, prefix, " "); >-+ colorlen = add_index_color(dest, destlen, flags, >-+ MT_COLOR_INDEX_COLLAPSED); >-+ if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1) { >-+ snprintf (dest+colorlen, destlen-colorlen, fmt, hdr->num_hidden); >-+ add_index_color(dest, destlen-colorlen, flags, MT_COLOR_INDEX); >-+ } >-+ else if (is_index && threads) { >-+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, " "); >-+ add_index_color(dest, destlen-colorlen, flags, MT_COLOR_INDEX); >-+ } >- else >- *dest = '\0'; >- } >-@@ -572,15 +621,23 @@ hdr_format_str (char *dest, >- { >- if (flags & M_FORMAT_FORCESUBJ) >- { >-- mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject)); >-+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT); >-+ mutt_format_s (dest+colorlen, destlen-colorlen, "", >-+ NONULL (hdr->env->subject)); >-+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >-+ >- snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest); >- mutt_format_s_tree (dest, destlen, prefix, buf2); >- } >- else >- mutt_format_s_tree (dest, destlen, prefix, hdr->tree); >- } >-- else >-- mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject)); >-+ else { >-+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT); >-+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, >-+ NONULL (hdr->env->subject)); >-+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >-+ } >- break; >- >- case 'S': >-@@ -683,7 +740,9 @@ hdr_format_str (char *dest, >- hdr->tagged ? '*' : >- (hdr->flagged ? '!' : >- (Tochars && ((i = mutt_user_is_recipient (hdr)) < mutt_strlen (Tochars)) ? Tochars[i] : ' '))); >-- mutt_format_s (dest, destlen, prefix, buf2); >-+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_FLAGS); >-+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); >-+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >- break; >- >- case 'X': >-@@ -703,7 +762,9 @@ hdr_format_str (char *dest, >- if (optional) >- optional = hdr->env->x_label ? 1 : 0; >- >-- mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label)); >-+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL); >-+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label)); >-+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >- break; >- >- case 'Y': >-@@ -729,10 +790,12 @@ hdr_format_str (char *dest, >- if (optional) >- optional = i; >- >-+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL); >- if (i) >-- mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label)); >-+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label)); >- else >-- mutt_format_s (dest, destlen, prefix, ""); >-+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, ""); >-+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >- >- break; >- >-diff --git a/menu.c b/menu.c >-index fa06915..672e5b2 100644 >---- a/menu.c >-+++ b/menu.c >-@@ -35,7 +35,30 @@ extern size_t UngetCount; >- >- char* SearchBuffers[MENU_MAX]; >- >--static void print_enriched_string (int attr, unsigned char *s, int do_color) >-+static int get_color(int index, int type) { >-+ COLOR_LINE *color; >-+ HEADER *hdr = Context->hdrs[index]; >-+ >-+ switch (type) { >-+ case MT_COLOR_INDEX_SUBJECT: >-+ color = ColorIndexSubjectList; >-+ break; >-+ case MT_COLOR_INDEX_AUTHOR: >-+ color = ColorIndexAuthorList; >-+ break; >-+ default: >-+ return ColorDefs[type]; >-+ } >-+ >-+ for (; color; color = color->next) >-+ if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS, >-+ Context, hdr)) >-+ return color->pair; >-+ >-+ return 0; >-+} >-+ >-+static void print_enriched_string (int index, int attr, unsigned char *s, int do_color) >- { >- wchar_t wc; >- size_t k; >-@@ -132,6 +155,18 @@ static void print_enriched_string (int attr, unsigned char *s, int do_color) >- } >- if (do_color) attrset(attr); >- } >-+ else if(*s == M_SPECIAL_INDEX) >-+ { >-+ s++; >-+ if (do_color) { >-+ if (*s == MT_COLOR_INDEX) >-+ attrset(attr); >-+ else >-+ attron(get_color(index, *s)); >-+ } >-+ s++; >-+ n -= 2; >-+ } >- else if ((k = mbrtowc (&wc, (char *)s, n, &mbstate)) > 0) >- { >- addnstr ((char *)s, k); >-@@ -235,7 +270,7 @@ void menu_redraw_index (MUTTMENU *menu) >- addstr (" "); >- } >- >-- print_enriched_string (menu->color(i), (unsigned char *) buf, 1); >-+ print_enriched_string (i, menu->color(i), (unsigned char *) buf, 1); >- SETCOLOR (MT_COLOR_NORMAL); >- } >- else >-@@ -249,7 +284,7 @@ void menu_redraw_index (MUTTMENU *menu) >- } >- >- CLEARLINE_WIN (i - menu->top + menu->offset); >-- print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current); >-+ print_enriched_string (i, menu->color(i), (unsigned char *) buf, i != menu->current); >- SETCOLOR (MT_COLOR_NORMAL); >- BKGDSET (MT_COLOR_NORMAL); >- } >-@@ -286,7 +321,7 @@ void menu_redraw_motion (MUTTMENU *menu) >- menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); >- menu_pad_string (buf, sizeof (buf)); >- move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3); >-- print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); >-+ print_enriched_string (menu->oldcurrent, menu->color(menu->oldcurrent), (unsigned char *) buf, 1); >- SETCOLOR (MT_COLOR_NORMAL); >- } >- >-@@ -304,7 +339,7 @@ void menu_redraw_motion (MUTTMENU *menu) >- clrtoeol (); >- menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); >- menu_pad_string (buf, sizeof (buf)); >-- print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); >-+ print_enriched_string (menu->oldcurrent, menu->color(menu->oldcurrent), (unsigned char *) buf, 1); >- >- /* now draw the new one to reflect the change */ >- menu_make_entry (buf, sizeof (buf), menu, menu->current); >-@@ -313,7 +348,7 @@ void menu_redraw_motion (MUTTMENU *menu) >- ADDCOLOR (MT_COLOR_INDICATOR); >- BKGDSET (MT_COLOR_INDICATOR); >- CLEARLINE_WIN (menu->current - menu->top + menu->offset); >-- print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); >-+ print_enriched_string (menu->current, menu->color(menu->current), (unsigned char *) buf, 0); >- SETCOLOR (MT_COLOR_NORMAL); >- BKGDSET (MT_COLOR_NORMAL); >- } >-@@ -339,7 +374,7 @@ void menu_redraw_current (MUTTMENU *menu) >- attrset (attr); >- addch (' '); >- menu_pad_string (buf, sizeof (buf)); >-- print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 1); >-+ print_enriched_string (menu->current, menu->color(menu->current), (unsigned char *) buf, 1); >- SETCOLOR (MT_COLOR_NORMAL); >- } >- else >-@@ -348,7 +383,7 @@ void menu_redraw_current (MUTTMENU *menu) >- ADDCOLOR (MT_COLOR_INDICATOR); >- BKGDSET (MT_COLOR_INDICATOR); >- clrtoeol (); >-- print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); >-+ print_enriched_string (menu->current, menu->color(menu->current), (unsigned char *) buf, 0); >- SETCOLOR (MT_COLOR_NORMAL); >- BKGDSET (MT_COLOR_NORMAL); >- } >-diff --git a/mutt.h b/mutt.h >-index 755a434..787b398 100644 >---- a/mutt.h >-+++ b/mutt.h >-@@ -168,6 +168,8 @@ typedef enum >- #define M_TREE_MISSING 13 >- #define M_TREE_MAX 14 >- >-+#define M_SPECIAL_INDEX M_TREE_MAX >-+ >- #define M_THREAD_COLLAPSE (1<<0) >- #define M_THREAD_UNCOLLAPSE (1<<1) >- #define M_THREAD_GET_HIDDEN (1<<2) >-diff --git a/mutt_curses.h b/mutt_curses.h >-index 5f61048..ed886b4 100644 >---- a/mutt_curses.h >-+++ b/mutt_curses.h >-@@ -129,6 +129,16 @@ enum >- MT_COLOR_INDEX, >- MT_COLOR_NEW, >- MT_COLOR_FLAGGED, >-+ /* please no non-MT_COLOR_INDEX objects after this point */ >-+ MT_COLOR_INDEX_SUBJECT, >-+ MT_COLOR_INDEX_AUTHOR, >-+ /* below only index coloring stuff that doesn't have a colorline! */ >-+ MT_COLOR_INDEX_COLLAPSED, >-+ MT_COLOR_INDEX_DATE, >-+ MT_COLOR_INDEX_FLAGS, >-+ MT_COLOR_INDEX_LABEL, >-+ MT_COLOR_INDEX_NUMBER, >-+ MT_COLOR_INDEX_SIZE, >- MT_COLOR_MAX >- }; >- >-@@ -182,6 +192,8 @@ extern int ColorDefs[]; >- extern COLOR_LINE *ColorHdrList; >- extern COLOR_LINE *ColorBodyList; >- extern COLOR_LINE *ColorIndexList; >-+extern COLOR_LINE *ColorIndexSubjectList; >-+extern COLOR_LINE *ColorIndexAuthorList; >- >- void ci_init_color (void); >- void ci_start_color (void); >Index: SOURCES/mutt-1.5.20-cve-2014-0467.patch >=================================================================== >--- SOURCES/mutt-1.5.20-cve-2014-0467.patch (revision 800495) >+++ SOURCES/mutt-1.5.20-cve-2014-0467.patch (working copy) >@@ -1,11 +0,0 @@ >-diff -up mutt/copy.c.cve-2014-0467 mutt/copy.c >---- mutt/copy.c.cve-2014-0467 2009-12-14 19:24:59.000000000 +0100 >-+++ mutt/copy.c 2014-03-13 10:29:13.844051152 +0100 >-@@ -254,6 +254,7 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF >- { >- if (!address_header_decode (&this_one)) >- rfc2047_decode (&this_one); >-+ this_one_len = mutt_strlen (this_one); >- } >- >- if (!headers[x]) >Index: SOURCES/mutt-1.5.20-sidebar.patch >=================================================================== >--- SOURCES/mutt-1.5.20-sidebar.patch (revision 800495) >+++ SOURCES/mutt-1.5.20-sidebar.patch (working copy) >@@ -1,1372 +0,0 @@ >-diff -uNp -r mutt-5302767aa6aa.orig/Makefile.am mutt-5302767aa6aa/Makefile.am >---- mutt-5302767aa6aa.orig/Makefile.am Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/Makefile.am Sat Sep 4 20:32:59 2010 >-@@ -32,6 +32,7 @@ mutt_SOURCES = \ >- rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \ >- score.c send.c sendlib.c signal.c sort.c \ >- status.c system.c thread.c charset.c history.c lib.c \ >-+ sidebar.c \ >- muttlib.c editmsg.c mbyte.c \ >- url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c >- >-diff -uNp -r mutt-5302767aa6aa.orig/OPS mutt-5302767aa6aa/OPS >---- mutt-5302767aa6aa.orig/OPS Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/OPS Sat Sep 4 20:32:59 2010 >-@@ -179,3 +179,8 @@ OP_WHAT_KEY "display the keycode for a key press" >- OP_MAIN_SHOW_LIMIT "show currently active limit pattern" >- OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread" >- OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads" >-+OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page" >-+OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page" >-+OP_SIDEBAR_NEXT "go down to next mailbox" >-+OP_SIDEBAR_PREV "go to previous mailbox" >-+OP_SIDEBAR_OPEN "open hilighted mailbox" >-diff -uNp -r mutt-5302767aa6aa.orig/PATCHES mutt-5302767aa6aa/PATCHES >---- mutt-5302767aa6aa.orig/PATCHES Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/PATCHES Sat Sep 4 20:32:59 2010 >-@@ -0,0 +1 @@ >-+patch-1.5.19.sidebar.20090522.txt >-diff -uNp -r mutt-5302767aa6aa.orig/buffy.c mutt-5302767aa6aa/buffy.c >---- mutt-5302767aa6aa.orig/buffy.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/buffy.c Sat Sep 4 20:32:59 2010 >-@@ -320,6 +320,68 @@ static int buffy_maildir_hasnew (BUFFY* mailbox) >- return rc; >- } >- >-+/* update message counts for the sidebar */ >-+void buffy_maildir_update (BUFFY* mailbox) >-+{ >-+ char path[_POSIX_PATH_MAX]; >-+ DIR *dirp; >-+ struct dirent *de; >-+ char *p; >-+ >-+ mailbox->msgcount = 0; >-+ mailbox->msg_unread = 0; >-+ mailbox->msg_flagged = 0; >-+ >-+ snprintf (path, sizeof (path), "%s/new", mailbox->path); >-+ >-+ if ((dirp = opendir (path)) == NULL) >-+ { >-+ mailbox->magic = 0; >-+ return; >-+ } >-+ >-+ while ((de = readdir (dirp)) != NULL) >-+ { >-+ if (*de->d_name == '.') >-+ continue; >-+ >-+ if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) { >-+ mailbox->new = 1; >-+ mailbox->msgcount++; >-+ mailbox->msg_unread++; >-+ } >-+ } >-+ >-+ closedir (dirp); >-+ snprintf (path, sizeof (path), "%s/cur", mailbox->path); >-+ >-+ if ((dirp = opendir (path)) == NULL) >-+ { >-+ mailbox->magic = 0; >-+ return; >-+ } >-+ >-+ while ((de = readdir (dirp)) != NULL) >-+ { >-+ if (*de->d_name == '.') >-+ continue; >-+ >-+ if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) { >-+ mailbox->msgcount++; >-+ if ((p = strstr (de->d_name, ":2,"))) { >-+ if (!strchr (p + 3, 'T')) { >-+ if (!strchr (p + 3, 'S')) >-+ mailbox->msg_unread++; >-+ if (strchr(p + 3, 'F')) >-+ mailbox->msg_flagged++; >-+ } >-+ } >-+ } >-+ } >-+ >-+ closedir (dirp); >-+} >-+ >- /* returns 1 if mailbox has new mail */ >- static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb) >- { >-@@ -348,6 +410,20 @@ static int buffy_mbox_hasnew (BUFFY* mailbox, struct s >- return rc; >- } >- >-+/* update message counts for the sidebar */ >-+void buffy_mbox_update (BUFFY* mailbox) >-+{ >-+ CONTEXT *ctx = NULL; >-+ >-+ ctx = mx_open_mailbox(mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL); >-+ if(ctx) >-+ { >-+ mailbox->msgcount = ctx->msgcount; >-+ mailbox->msg_unread = ctx->unread; >-+ mx_close_mailbox(ctx, 0); >-+ } >-+} >-+ >- int mutt_buffy_check (int force) >- { >- BUFFY *tmp; >-@@ -423,16 +499,19 @@ int mutt_buffy_check (int force) >- { >- case M_MBOX: >- case M_MMDF: >-+ buffy_mbox_update (tmp); >- if (buffy_mbox_hasnew (tmp, &sb) > 0) >- BuffyCount++; >- break; >- >- case M_MAILDIR: >-+ buffy_maildir_update (tmp); >- if (buffy_maildir_hasnew (tmp) > 0) >- BuffyCount++; >- break; >- >- case M_MH: >-+ mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged); >- if ((tmp->new = mh_buffy (tmp->path)) > 0) >- BuffyCount++; >- break; >-diff -uNp -r mutt-5302767aa6aa.orig/buffy.h mutt-5302767aa6aa/buffy.h >---- mutt-5302767aa6aa.orig/buffy.h Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/buffy.h Sat Sep 4 20:32:59 2010 >-@@ -25,7 +25,11 @@ typedef struct buffy_t >- char path[_POSIX_PATH_MAX]; >- off_t size; >- struct buffy_t *next; >-+ struct buffy_t *prev; >- short new; /* mailbox has new mail */ >-+ int msgcount; /* total number of messages */ >-+ int msg_unread; /* number of unread messages */ >-+ int msg_flagged; /* number of flagged messages */ >- short notified; /* user has been notified */ >- short magic; /* mailbox type */ >- short newly_created; /* mbox or mmdf just popped into existence */ >-diff -uNp -r mutt-5302767aa6aa.orig/color.c mutt-5302767aa6aa/color.c >---- mutt-5302767aa6aa.orig/color.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/color.c Sat Sep 4 20:32:59 2010 >-@@ -93,6 +93,8 @@ static struct mapping_t Fields[] = >- { "bold", MT_COLOR_BOLD }, >- { "underline", MT_COLOR_UNDERLINE }, >- { "index", MT_COLOR_INDEX }, >-+ { "sidebar_new", MT_COLOR_NEW }, >-+ { "sidebar_flagged", MT_COLOR_FLAGGED }, >- { NULL, 0 } >- }; >- >-diff -uNp -r mutt-5302767aa6aa.orig/compose.c mutt-5302767aa6aa/compose.c >---- mutt-5302767aa6aa.orig/compose.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/compose.c Sat Sep 4 20:32:59 2010 >-@@ -72,7 +72,7 @@ enum >- >- #define HDR_XOFFSET 14 >- #define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */ >--#define W (COLS - HDR_XOFFSET) >-+#define W (COLS - HDR_XOFFSET - SidebarWidth) >- >- static char *Prompts[] = >- { >-@@ -112,7 +112,7 @@ static void redraw_crypt_lines (HEADER *msg) >- { >- int off = 0; >- >-- mvaddstr (HDR_CRYPT, 0, "Security: "); >-+ mvaddstr (HDR_CRYPT, SidebarWidth, " Security: "); >- >- if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0) >- { >-@@ -144,7 +144,7 @@ static void redraw_crypt_lines (HEADER *msg) >- } >- >- clrtoeol (); >-- move (HDR_CRYPTINFO, 0); >-+ move (HDR_CRYPTINFO, SidebarWidth); >- clrtoeol (); >- >- if ((WithCrypto & APPLICATION_PGP) >-@@ -161,7 +161,7 @@ static void redraw_crypt_lines (HEADER *msg) >- && (msg->security & ENCRYPT) >- && SmimeCryptAlg >- && *SmimeCryptAlg) { >-- mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "), >-+ mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "), >- NONULL(SmimeCryptAlg)); >- off = 20; >- } >-@@ -175,7 +175,7 @@ static void redraw_mix_line (LIST *chain) >- int c; >- char *t; >- >-- mvaddstr (HDR_MIX, 0, " Mix: "); >-+ mvaddstr (HDR_MIX, SidebarWidth, " Mix: "); >- >- if (!chain) >- { >-@@ -190,7 +190,7 @@ static void redraw_mix_line (LIST *chain) >- if (t && t[0] == '0' && t[1] == '\0') >- t = "<random>"; >- >-- if (c + mutt_strlen (t) + 2 >= COLS) >-+ if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth) >- break; >- >- addstr (NONULL(t)); >-@@ -242,7 +242,7 @@ static void draw_envelope_addr (int line, ADDRESS *add >- >- buf[0] = 0; >- rfc822_write_address (buf, sizeof (buf), addr, 1); >-- mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]); >-+ mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]); >- mutt_paddstr (W, buf); >- } >- >-@@ -252,10 +252,10 @@ static void draw_envelope (HEADER *msg, char *fcc) >- } >- } >- #endif >-- mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); >-+ mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); >- mutt_paddstr (W, NONULL (msg->env->subject)); >- draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); >-- mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]); >-+ mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]); >- mutt_paddstr (W, fcc); >- >- if (WithCrypto) >-@@ -266,7 +266,7 @@ static void draw_envelope (HEADER *msg, char *fcc) >- #endif >- >- SETCOLOR (MT_COLOR_STATUS); >-- mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments")); >-+ mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments")); >- BKGDSET (MT_COLOR_STATUS); >- clrtoeol (); >- >-@@ -304,7 +304,7 @@ static int edit_address_list (int line, ADDRESS **addr >- /* redraw the expanded list so the user can see the result */ >- buf[0] = 0; >- rfc822_write_address (buf, sizeof (buf), *addr, 1); >-- move (line, HDR_XOFFSET); >-+ move (line, HDR_XOFFSET+SidebarWidth); >- mutt_paddstr (W, buf); >- >- return 0; >-@@ -549,7 +549,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for >- if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) >- { >- mutt_str_replace (&msg->env->subject, buf); >-- move (HDR_SUBJECT, HDR_XOFFSET); >-+ move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth); >- clrtoeol (); >- if (msg->env->subject) >- mutt_paddstr (W, msg->env->subject); >-@@ -566,7 +566,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for >- { >- strfcpy (fcc, buf, fcclen); >- mutt_pretty_mailbox (fcc, fcclen); >-- move (HDR_FCC, HDR_XOFFSET); >-+ move (HDR_FCC, HDR_XOFFSET + SidebarWidth); >- mutt_paddstr (W, fcc); >- fccSet = 1; >- } >-diff -uNp -r mutt-5302767aa6aa.orig/curs_main.c mutt-5302767aa6aa/curs_main.c >---- mutt-5302767aa6aa.orig/curs_main.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/curs_main.c Sat Sep 4 20:32:59 2010 >-@@ -26,7 +26,9 @@ >- #include "mailbox.h" >- #include "mapping.h" >- #include "sort.h" >-+#include "buffy.h" >- #include "mx.h" >-+#include "sidebar.h" >- >- #ifdef USE_POP >- #include "pop.h" >-@@ -523,8 +525,12 @@ int mutt_index_menu (void) >- menu->redraw |= REDRAW_STATUS; >- if (do_buffy_notify) >- { >-- if (mutt_buffy_notify () && option (OPTBEEPNEW)) >-- beep (); >-+ if (mutt_buffy_notify ()) >-+ { >-+ menu->redraw |= REDRAW_FULL; >-+ if (option (OPTBEEPNEW)) >-+ beep (); >-+ } >- } >- else >- do_buffy_notify = 1; >-@@ -536,6 +542,7 @@ int mutt_index_menu (void) >- if (menu->redraw & REDRAW_FULL) >- { >- menu_redraw_full (menu); >-+ draw_sidebar(menu->menu); >- mutt_show_error (); >- } >- >-@@ -558,10 +565,13 @@ int mutt_index_menu (void) >- >- if (menu->redraw & REDRAW_STATUS) >- { >-+ DrawFullLine = 1; >- menu_status_line (buf, sizeof (buf), menu, NONULL (Status)); >-+ DrawFullLine = 0; >- CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2); >- SETCOLOR (MT_COLOR_STATUS); >- BKGDSET (MT_COLOR_STATUS); >-+ set_buffystats(Context); >- mutt_paddstr (COLS, buf); >- SETCOLOR (MT_COLOR_NORMAL); >- BKGDSET (MT_COLOR_NORMAL); >-@@ -575,7 +585,7 @@ int mutt_index_menu (void) >- menu->oldcurrent = -1; >- >- if (option (OPTARROWCURSOR)) >-- move (menu->current - menu->top + menu->offset, 2); >-+ move (menu->current - menu->top + menu->offset, SidebarWidth + 2); >- else if (option (OPTBRAILLEFRIENDLY)) >- move (menu->current - menu->top + menu->offset, 0); >- else >-@@ -1077,6 +1087,7 @@ int mutt_index_menu (void) >- menu->redraw = REDRAW_FULL; >- break; >- >-+ case OP_SIDEBAR_OPEN: >- case OP_MAIN_CHANGE_FOLDER: >- case OP_MAIN_NEXT_UNREAD_MAILBOX: >- >-@@ -1108,7 +1119,11 @@ int mutt_index_menu (void) >- { >- mutt_buffy (buf, sizeof (buf)); >- >-- if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) >-+ if ( op == OP_SIDEBAR_OPEN ) { >-+ if(!CurBuffy) >-+ break; >-+ strncpy( buf, CurBuffy->path, sizeof(buf) ); >-+ } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) >- { >- if (menu->menu == MENU_PAGER) >- { >-@@ -1126,6 +1141,7 @@ int mutt_index_menu (void) >- } >- >- mutt_expand_path (buf, sizeof (buf)); >-+ set_curbuffy(buf); >- if (mx_get_magic (buf) <= 0) >- { >- mutt_error (_("%s is not a mailbox."), buf); >-@@ -2216,6 +2232,12 @@ int mutt_index_menu (void) >- mutt_what_key(); >- break; >- >-+ case OP_SIDEBAR_SCROLL_UP: >-+ case OP_SIDEBAR_SCROLL_DOWN: >-+ case OP_SIDEBAR_NEXT: >-+ case OP_SIDEBAR_PREV: >-+ scroll_sidebar(op, menu->menu); >-+ break; >- default: >- if (menu->menu == MENU_MAIN) >- km_error_key (MENU_MAIN); >-diff -uNp -r mutt-5302767aa6aa.orig/flags.c mutt-5302767aa6aa/flags.c >---- mutt-5302767aa6aa.orig/flags.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/flags.c Sat Sep 4 20:32:59 2010 >-@@ -22,8 +22,10 @@ >- >- #include "mutt.h" >- #include "mutt_curses.h" >-+#include "mutt_menu.h" >- #include "sort.h" >- #include "mx.h" >-+#include "sidebar.h" >- >- void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) >- { >-@@ -263,6 +265,7 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag >- */ >- if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged)) >- h->searched = 0; >-+ draw_sidebar(0); >- } >- >- void mutt_tag_set_flag (int flag, int bf) >-diff -uNp -r mutt-5302767aa6aa.orig/functions.h mutt-5302767aa6aa/functions.h >---- mutt-5302767aa6aa.orig/functions.h Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/functions.h Sat Sep 4 20:32:59 2010 >-@@ -169,6 +169,11 @@ struct binding_t OpMain[] = { /* map: index */ >- { "decrypt-save", OP_DECRYPT_SAVE, NULL }, >- >- >-+ { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, >-+ { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, >-+ { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, >-+ { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, >-+ { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, >- { NULL, 0, NULL } >- }; >- >-@@ -272,6 +277,11 @@ struct binding_t OpPager[] = { /* map: pager */ >- >- { "what-key", OP_WHAT_KEY, NULL }, >- >-+ { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, >-+ { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, >-+ { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, >-+ { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, >-+ { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, >- { NULL, 0, NULL } >- }; >- >-diff -uNp -r mutt-5302767aa6aa.orig/globals.h mutt-5302767aa6aa/globals.h >---- mutt-5302767aa6aa.orig/globals.h Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/globals.h Sat Sep 4 20:32:59 2010 >-@@ -117,6 +117,7 @@ WHERE short SearchContext; >- WHERE char *SendCharset; >- WHERE char *Sendmail; >- WHERE char *Shell; >-+WHERE char *SidebarDelim; >- WHERE char *Signature; >- WHERE char *SimpleSearch; >- #if USE_SMTP >-@@ -207,6 +208,9 @@ WHERE short ScoreThresholdDelete; >- WHERE short ScoreThresholdRead; >- WHERE short ScoreThresholdFlag; >- >-+WHERE struct buffy_t *CurBuffy INITVAL(0); >-+WHERE short DrawFullLine INITVAL(0); >-+WHERE short SidebarWidth; >- #ifdef USE_IMAP >- WHERE short ImapKeepalive; >- WHERE short ImapPipelineDepth; >-diff -uNp -r mutt-5302767aa6aa.orig/imap/command.c mutt-5302767aa6aa/imap/command.c >---- mutt-5302767aa6aa.orig/imap/command.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/imap/command.c Sat Sep 4 20:32:59 2010 >-@@ -1006,6 +1006,13 @@ static void cmd_parse_status (IMAP_DATA* idata, char* >- opened */ >- status->uidnext = oldun; >- >-+ /* Added to make the sidebar show the correct numbers */ >-+ if (status->messages) >-+ { >-+ inc->msgcount = status->messages; >-+ inc->msg_unread = status->unseen; >-+ } >-+ >- FREE (&value); >- return; >- } >-diff -uNp -r mutt-5302767aa6aa.orig/imap/imap.c mutt-5302767aa6aa/imap/imap.c >---- mutt-5302767aa6aa.orig/imap/imap.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/imap/imap.c Sat Sep 4 20:32:59 2010 >-@@ -1521,7 +1521,7 @@ int imap_buffy_check (int force) >- >- imap_munge_mbox_name (munged, sizeof (munged), name); >- snprintf (command, sizeof (command), >-- "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged); >-+ "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged); >- >- if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0) >- { >-diff -uNp -r mutt-5302767aa6aa.orig/init.h mutt-5302767aa6aa/init.h >---- mutt-5302767aa6aa.orig/init.h Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/init.h Sat Sep 4 20:32:59 2010 >-@@ -1942,6 +1942,27 @@ struct option_t MuttVars[] = { >- ** not used. >- ** (PGP only) >- */ >-+ {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"}, >-+ /* >-+ ** .pp >-+ ** This specifies the delimiter between the sidebar (if visible) and >-+ ** other screens. >-+ */ >-+ { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 }, >-+ /* >-+ ** .pp >-+ ** This specifies whether or not to show sidebar (left-side list of folders). >-+ */ >-+ { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 }, >-+ /* >-+ ** .pp >-+ ** The width of the sidebar. >-+ */ >-+ { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 }, >-+ /* >-+ ** .pp >-+ ** Should the sidebar be sorted. >-+ */ >- { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0}, >- /* >- ** .pp >-diff -uNp -r mutt-5302767aa6aa.orig/mailbox.h mutt-5302767aa6aa/mailbox.h >---- mutt-5302767aa6aa.orig/mailbox.h Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/mailbox.h Sat Sep 4 20:32:59 2010 >-@@ -27,6 +27,7 @@ >- #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses >- * safe_fopen() for mbox-style folders. >- */ >-+#define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */ >- >- /* mx_open_new_message() */ >- #define M_ADD_FROM 1 /* add a From_ line */ >-diff -uNp -r mutt-5302767aa6aa.orig/mbox.c mutt-5302767aa6aa/mbox.c >---- mutt-5302767aa6aa.orig/mbox.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/mbox.c Sat Sep 4 20:32:59 2010 >-@@ -100,6 +100,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx) >- mutt_perror (ctx->path); >- return (-1); >- } >-+ ctx->atime = sb.st_atime; >- ctx->mtime = sb.st_mtime; >- ctx->size = sb.st_size; >- >-@@ -251,6 +252,7 @@ int mbox_parse_mailbox (CONTEXT *ctx) >- >- ctx->size = sb.st_size; >- ctx->mtime = sb.st_mtime; >-+ ctx->atime = sb.st_atime; >- >- #ifdef NFS_ATTRIBUTE_HACK >- if (sb.st_mtime > sb.st_atime) >-diff -uNp -r mutt-5302767aa6aa.orig/menu.c mutt-5302767aa6aa/menu.c >---- mutt-5302767aa6aa.orig/menu.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/menu.c Sat Sep 4 20:32:59 2010 >-@@ -24,6 +24,7 @@ >- #include "mutt_curses.h" >- #include "mutt_menu.h" >- #include "mbyte.h" >-+#include "sidebar.h" >- >- #include <string.h> >- #include <stdlib.h> >-@@ -156,7 +157,7 @@ static void menu_pad_string (char *s, size_t n) >- { >- char *scratch = safe_strdup (s); >- int shift = option (OPTARROWCURSOR) ? 3 : 0; >-- int cols = COLS - shift; >-+ int cols = COLS - shift - SidebarWidth; >- >- mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1); >- s[n - 1] = 0; >-@@ -207,6 +208,7 @@ void menu_redraw_index (MUTTMENU *menu) >- char buf[LONG_STRING]; >- int i; >- >-+ draw_sidebar(1); >- for (i = menu->top; i < menu->top + menu->pagelen; i++) >- { >- if (i < menu->max) >-@@ -217,7 +219,7 @@ void menu_redraw_index (MUTTMENU *menu) >- if (option (OPTARROWCURSOR)) >- { >- attrset (menu->color (i)); >-- CLEARLINE (i - menu->top + menu->offset); >-+ CLEARLINE_WIN (i - menu->top + menu->offset); >- >- if (i == menu->current) >- { >-@@ -246,14 +248,14 @@ void menu_redraw_index (MUTTMENU *menu) >- BKGDSET (MT_COLOR_INDICATOR); >- } >- >-- CLEARLINE (i - menu->top + menu->offset); >-+ CLEARLINE_WIN (i - menu->top + menu->offset); >- print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current); >- SETCOLOR (MT_COLOR_NORMAL); >- BKGDSET (MT_COLOR_NORMAL); >- } >- } >- else >-- CLEARLINE (i - menu->top + menu->offset); >-+ CLEARLINE_WIN (i - menu->top + menu->offset); >- } >- menu->redraw = 0; >- } >-@@ -268,7 +270,7 @@ void menu_redraw_motion (MUTTMENU *menu) >- return; >- } >- >-- move (menu->oldcurrent + menu->offset - menu->top, 0); >-+ move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth); >- SETCOLOR (MT_COLOR_NORMAL); >- BKGDSET (MT_COLOR_NORMAL); >- >-@@ -283,13 +285,13 @@ void menu_redraw_motion (MUTTMENU *menu) >- clrtoeol (); >- menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); >- menu_pad_string (buf, sizeof (buf)); >-- move (menu->oldcurrent + menu->offset - menu->top, 3); >-+ move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3); >- print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); >- SETCOLOR (MT_COLOR_NORMAL); >- } >- >- /* now draw it in the new location */ >-- move (menu->current + menu->offset - menu->top, 0); >-+ move (menu->current + menu->offset - menu->top, SidebarWidth); >- attrset (menu->color (menu->current)); >- ADDCOLOR (MT_COLOR_INDICATOR); >- addstr ("->"); >-@@ -310,7 +312,7 @@ void menu_redraw_motion (MUTTMENU *menu) >- attrset (menu->color (menu->current)); >- ADDCOLOR (MT_COLOR_INDICATOR); >- BKGDSET (MT_COLOR_INDICATOR); >-- CLEARLINE (menu->current - menu->top + menu->offset); >-+ CLEARLINE_WIN (menu->current - menu->top + menu->offset); >- print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); >- SETCOLOR (MT_COLOR_NORMAL); >- BKGDSET (MT_COLOR_NORMAL); >-@@ -322,7 +324,7 @@ void menu_redraw_current (MUTTMENU *menu) >- { >- char buf[LONG_STRING]; >- >-- move (menu->current + menu->offset - menu->top, 0); >-+ move (menu->current + menu->offset - menu->top, SidebarWidth); >- menu_make_entry (buf, sizeof (buf), menu, menu->current); >- menu_pad_string (buf, sizeof (buf)); >- >-@@ -875,7 +877,7 @@ int mutt_menuLoop (MUTTMENU *menu) >- >- >- if (option (OPTARROWCURSOR)) >-- move (menu->current - menu->top + menu->offset, 2); >-+ move (menu->current - menu->top + menu->offset, SidebarWidth + 2); >- else if (option (OPTBRAILLEFRIENDLY)) >- move (menu->current - menu->top + menu->offset, 0); >- else >-diff -uNp -r mutt-5302767aa6aa.orig/mh.c mutt-5302767aa6aa/mh.c >---- mutt-5302767aa6aa.orig/mh.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/mh.c Sat Sep 4 20:33:39 2010 >-@@ -235,11 +235,35 @@ int mh_buffy (const char *path) >- >- if (mh_read_sequences (&mhs, path) < 0) >- return 0; >-+ >- for (i = 0; !r && i <= mhs.max; i++) >-- if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) >-+ if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) { >- r = 1; >-+ } >- mhs_free_sequences (&mhs); >- return r; >-+} >-+ >-+void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged) >-+{ >-+ int i; >-+ struct mh_sequences mhs; >-+ memset (&mhs, 0, sizeof (mhs)); >-+ >-+ if (mh_read_sequences (&mhs, path) < 0) >-+ return; >-+ >-+ msgcount = 0; >-+ msg_unread = 0; >-+ msg_flagged = 0; >-+ for (i = 0; i <= mhs.max; i++) >-+ msgcount++; >-+ if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) { >-+ msg_unread++; >-+ } >-+ if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED) >-+ msg_flagged++; >-+ mhs_free_sequences (&mhs); >- } >- >- static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt) >-diff -uNp -r mutt-5302767aa6aa.orig/mutt.h mutt-5302767aa6aa/mutt.h >---- mutt-5302767aa6aa.orig/mutt.h Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/mutt.h Sat Sep 4 20:32:59 2010 >-@@ -418,6 +418,8 @@ enum >- OPTSAVEEMPTY, >- OPTSAVENAME, >- OPTSCORE, >-+ OPTSIDEBAR, >-+ OPTSIDEBARSORT, >- OPTSIGDASHES, >- OPTSIGONTOP, >- OPTSORTRE, >-@@ -858,6 +859,7 @@ typedef struct _context >- { >- char *path; >- FILE *fp; >-+ time_t atime; >- time_t mtime; >- off_t size; >- off_t vsize; >-@@ -892,6 +894,7 @@ typedef struct _context >- unsigned int quiet : 1; /* inhibit status messages? */ >- unsigned int collapsed : 1; /* are all threads collapsed? */ >- unsigned int closing : 1; /* mailbox is being closed */ >-+ unsigned int peekonly : 1; /* just taking a glance, revert atime */ >- >- /* driver hooks */ >- void *data; /* driver specific data */ >-diff -uNp -r mutt-5302767aa6aa.orig/mutt_curses.h mutt-5302767aa6aa/mutt_curses.h >---- mutt-5302767aa6aa.orig/mutt_curses.h Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/mutt_curses.h Sat Sep 4 20:32:59 2010 >-@@ -64,6 +64,7 @@ >- #undef lines >- #endif /* lines */ >- >-+#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol() >- #define CLEARLINE(x) move(x,0), clrtoeol() >- #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x) >- #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0) >-@@ -126,6 +127,8 @@ enum >- MT_COLOR_BOLD, >- MT_COLOR_UNDERLINE, >- MT_COLOR_INDEX, >-+ MT_COLOR_NEW, >-+ MT_COLOR_FLAGGED, >- MT_COLOR_MAX >- }; >- >-diff -uNp -r mutt-5302767aa6aa.orig/muttlib.c mutt-5302767aa6aa/muttlib.c >---- mutt-5302767aa6aa.orig/muttlib.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/muttlib.c Sat Sep 4 20:32:59 2010 >-@@ -1286,6 +1286,8 @@ void mutt_FormatString (char *dest, /* output buffer >- pl = pw = 1; >- >- /* see if there's room to add content, else ignore */ >-+ if ( DrawFullLine ) >-+ { >- if ((col < COLS && wlen < destlen) || soft) >- { >- int pad; >-@@ -1329,6 +1331,52 @@ void mutt_FormatString (char *dest, /* output buffer >- col += wid; >- src += pl; >- } >-+ } >-+ else >-+ { >-+ if ((col < COLS-SidebarWidth && wlen < destlen) || soft) >-+ { >-+ int pad; >-+ >-+ /* get contents after padding */ >-+ mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags); >-+ len = mutt_strlen (buf); >-+ wid = mutt_strwidth (buf); >-+ >-+ /* try to consume as many columns as we can, if we don't have >-+ * memory for that, use as much memory as possible */ >-+ pad = (COLS - SidebarWidth - col - wid) / pw; >-+ if (pad > 0 && wlen + (pad * pl) + len > destlen) >-+ pad = ((signed)(destlen - wlen - len)) / pl; >-+ if (pad > 0) >-+ { >-+ while (pad--) >-+ { >-+ memcpy (wptr, src, pl); >-+ wptr += pl; >-+ wlen += pl; >-+ col += pw; >-+ } >-+ } >-+ else if (soft && pad < 0) >-+ { >-+ /* \0-terminate dest for length computation in mutt_wstr_trunc() */ >-+ *wptr = 0; >-+ /* make sure right part is at most as wide as display */ >-+ len = mutt_wstr_trunc (buf, destlen, COLS, &wid); >-+ /* truncate left so that right part fits completely in */ >-+ wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col); >-+ wptr = dest + wlen; >-+ } >-+ if (len + wlen > destlen) >-+ len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL); >-+ memcpy (wptr, buf, len); >-+ wptr += len; >-+ wlen += len; >-+ col += wid; >-+ src += pl; >-+ } >-+ } >- break; /* skip rest of input */ >- } >- else if (ch == '|') >-diff -uNp -r mutt-5302767aa6aa.orig/mx.c mutt-5302767aa6aa/mx.c >---- mutt-5302767aa6aa.orig/mx.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/mx.c Sat Sep 4 20:32:59 2010 >-@@ -580,6 +580,7 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int f >- * M_APPEND open mailbox for appending >- * M_READONLY open mailbox in read-only mode >- * M_QUIET only print error messages >-+ * M_PEEK revert atime where applicable >- * ctx if non-null, context struct to use >- */ >- CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx) >-@@ -602,6 +603,8 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, >- ctx->quiet = 1; >- if (flags & M_READONLY) >- ctx->readonly = 1; >-+ if (flags & M_PEEK) >-+ ctx->peekonly = 1; >- >- if (flags & (M_APPEND|M_NEWFOLDER)) >- { >-@@ -701,9 +704,21 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, >- void mx_fastclose_mailbox (CONTEXT *ctx) >- { >- int i; >-+#ifndef BUFFY_SIZE >-+ struct utimbuf ut; >-+#endif >- >- if(!ctx) >- return; >-+#ifndef BUFFY_SIZE >-+ /* fix up the times so buffy won't get confused */ >-+ if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime) >-+ { >-+ ut.actime = ctx->atime; >-+ ut.modtime = ctx->mtime; >-+ utime (ctx->path, &ut); >-+ } >-+#endif >- >- /* never announce that a mailbox we've just left has new mail. #3290 >- * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */ >-diff -uNp -r mutt-5302767aa6aa.orig/mx.h mutt-5302767aa6aa/mx.h >---- mutt-5302767aa6aa.orig/mx.h Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/mx.h Sat Sep 4 20:33:19 2010 >-@@ -58,6 +58,7 @@ int mh_read_dir (CONTEXT *, const char *); >- int mh_sync_mailbox (CONTEXT *, int *); >- int mh_check_mailbox (CONTEXT *, int *); >- int mh_buffy (const char *); >-+void mh_buffy_update (const char *, int *, int *, int *); >- int mh_check_empty (const char *); >- >- int maildir_read_dir (CONTEXT *); >-diff -uNp -r mutt-5302767aa6aa.orig/pager.c mutt-5302767aa6aa/pager.c >---- mutt-5302767aa6aa.orig/pager.c Wed Aug 25 00:30:49 2010 >-+++ mutt-5302767aa6aa/pager.c Sat Sep 4 20:32:59 2010 >-@@ -29,6 +29,7 @@ >- #include "pager.h" >- #include "attach.h" >- #include "mbyte.h" >-+#include "sidebar.h" >- >- #include "mutt_crypt.h" >- >-@@ -1095,6 +1096,7 @@ static int format_line (struct line_t **lineInfo, int >- wchar_t wc; >- mbstate_t mbstate; >- int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap); >-+ wrap_cols -= SidebarWidth; >- >- if (check_attachment_marker ((char *)buf) == 0) >- wrap_cols = COLS; >-@@ -1745,7 +1747,7 @@ mutt_pager (const char *banner, const char *fname, int >- if ((redraw & REDRAW_BODY) || topline != oldtopline) >- { >- do { >-- move (bodyoffset, 0); >-+ move (bodyoffset, SidebarWidth); >- curline = oldtopline = topline; >- lines = 0; >- force_redraw = 0; >-@@ -1758,6 +1760,7 @@ mutt_pager (const char *banner, const char *fname, int >- &QuoteList, &q_level, &force_redraw, &SearchRE) > 0) >- lines++; >- curline++; >-+ move(lines + bodyoffset, SidebarWidth); >- } >- last_offset = lineInfo[curline].offset; >- } while (force_redraw); >-@@ -1771,6 +1774,7 @@ mutt_pager (const char *banner, const char *fname, int >- addch ('~'); >- addch ('\n'); >- lines++; >-+ move(lines + bodyoffset, SidebarWidth); >- } >- /* We are going to update the pager status bar, so it isn't >- * necessary to reset to normal color now. */ >-@@ -1794,21 +1798,21 @@ mutt_pager (const char *banner, const char *fname, int >- /* print out the pager status bar */ >- SETCOLOR (MT_COLOR_STATUS); >- BKGDSET (MT_COLOR_STATUS); >-- CLEARLINE (statusoffset); >-+ CLEARLINE_WIN (statusoffset); >- >- if (IsHeader (extra) || IsMsgAttach (extra)) >- { >-- size_t l1 = COLS * MB_LEN_MAX; >-+ size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX; >- size_t l2 = sizeof (buffer); >- hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr; >- mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT); >-- mutt_paddstr (COLS, buffer); >-+ mutt_paddstr (COLS-SidebarWidth, buffer); >- } >- else >- { >- char bn[STRING]; >- snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str); >-- mutt_paddstr (COLS, bn); >-+ mutt_paddstr (COLS-SidebarWidth, bn); >- } >- BKGDSET (MT_COLOR_NORMAL); >- SETCOLOR (MT_COLOR_NORMAL); >-@@ -1819,18 +1823,23 @@ mutt_pager (const char *banner, const char *fname, int >- /* redraw the pager_index indicator, because the >- * flags for this message might have changed. */ >- menu_redraw_current (index); >-+ draw_sidebar(MENU_PAGER); >- >- /* print out the index status bar */ >- menu_status_line (buffer, sizeof (buffer), index, NONULL(Status)); >- >-- move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0); >-+ move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth); >- SETCOLOR (MT_COLOR_STATUS); >- BKGDSET (MT_COLOR_STATUS); >-- mutt_paddstr (COLS, buffer); >-+ mutt_paddstr (COLS-SidebarWidth, buffer); >- SETCOLOR (MT_COLOR_NORMAL); >- BKGDSET (MT_COLOR_NORMAL); >- } >- >-+ /* if we're not using the index, update every time */ >-+ if ( index == 0 ) >-+ draw_sidebar(MENU_PAGER); >-+ >- redraw = 0; >- >- if (option(OPTBRAILLEFRIENDLY)) { >-@@ -2755,6 +2764,13 @@ search_next: >- case OP_WHAT_KEY: >- mutt_what_key (); >- break; >-+ >-+ case OP_SIDEBAR_SCROLL_UP: >-+ case OP_SIDEBAR_SCROLL_DOWN: >-+ case OP_SIDEBAR_NEXT: >-+ case OP_SIDEBAR_PREV: >-+ scroll_sidebar(ch, MENU_PAGER); >-+ break; >- >- default: >- ch = -1; >-diff -uNp -r mutt-5302767aa6aa.orig/sidebar.c mutt-5302767aa6aa/sidebar.c >---- mutt-5302767aa6aa.orig/sidebar.c Thu Jan 1 01:00:00 1970 >-+++ mutt-5302767aa6aa/sidebar.c Sat Sep 4 20:32:59 2010 >-@@ -0,0 +1,362 @@ >-+/* >-+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> >-+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> >-+ * >-+ * This program is free software; you can redistribute it and/or modify >-+ * it under the terms of the GNU General Public License as published by >-+ * the Free Software Foundation; either version 2 of the License, or >-+ * (at your option) any later version. >-+ * >-+ * This program is distributed in the hope that it will be useful, >-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-+ * GNU General Public License for more details. >-+ * >-+ * You should have received a copy of the GNU General Public License >-+ * along with this program; if not, write to the Free Software >-+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. >-+ */ >-+ >-+ >-+#if HAVE_CONFIG_H >-+# include "config.h" >-+#endif >-+ >-+#include "mutt.h" >-+#include "mutt_menu.h" >-+#include "mutt_curses.h" >-+#include "sidebar.h" >-+#include "buffy.h" >-+#include <libgen.h> >-+#include "keymap.h" >-+#include <stdbool.h> >-+ >-+/*BUFFY *CurBuffy = 0;*/ >-+static BUFFY *TopBuffy = 0; >-+static BUFFY *BottomBuffy = 0; >-+static int known_lines = 0; >-+ >-+static int quick_log10(int n) >-+{ >-+ char string[32]; >-+ sprintf(string, "%d", n); >-+ return strlen(string); >-+} >-+ >-+void calc_boundaries (int menu) >-+{ >-+ BUFFY *tmp = Incoming; >-+ >-+ if ( known_lines != LINES ) { >-+ TopBuffy = BottomBuffy = 0; >-+ known_lines = LINES; >-+ } >-+ for ( ; tmp->next != 0; tmp = tmp->next ) >-+ tmp->next->prev = tmp; >-+ >-+ if (option(OPTSIDEBARSORT)) { >-+ int needsort=1; >-+ BUFFY *prev; >-+ BUFFY *next; >-+ BUFFY *tmp2; >-+ while (needsort==1) { >-+ needsort=0; >-+ tmp = Incoming; >-+ for ( ; tmp ; tmp=tmp->next ) { >-+ if (tmp->next != NULL && strcmp(tmp->path, tmp->next->path) > 0) { >-+ needsort=1; >-+ prev = tmp->prev; >-+ next = tmp->next; >-+ if (prev != NULL) >-+ prev->next = next; >-+ else >-+ Incoming = next; >-+ next->prev = prev; >-+ tmp2 = next->next; >-+ next->next = tmp; >-+ tmp->prev = next; >-+ tmp->next = tmp2; >-+ if (tmp2 != NULL) >-+ tmp2->prev = tmp; >-+ } >-+ } >-+ } >-+ } >-+ >-+ if ( TopBuffy == 0 && BottomBuffy == 0 ) >-+ TopBuffy = Incoming; >-+ if ( BottomBuffy == 0 ) { >-+ int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); >-+ BottomBuffy = TopBuffy; >-+ while ( --count && BottomBuffy->next ) >-+ BottomBuffy = BottomBuffy->next; >-+ } >-+ else if ( TopBuffy == CurBuffy->next ) { >-+ int count = LINES - 2 - (menu != MENU_PAGER); >-+ BottomBuffy = CurBuffy; >-+ tmp = BottomBuffy; >-+ while ( --count && tmp->prev) >-+ tmp = tmp->prev; >-+ TopBuffy = tmp; >-+ } >-+ else if ( BottomBuffy == CurBuffy->prev ) { >-+ int count = LINES - 2 - (menu != MENU_PAGER); >-+ TopBuffy = CurBuffy; >-+ tmp = TopBuffy; >-+ while ( --count && tmp->next ) >-+ tmp = tmp->next; >-+ BottomBuffy = tmp; >-+ } >-+} >-+ >-+char *make_sidebar_entry(char *box, int size, int new, int flagged) >-+{ >-+ static char *entry = 0; >-+ char *c; >-+ int i = 0; >-+ int delim_len = strlen(SidebarDelim); >-+ >-+ c = realloc(entry, SidebarWidth - delim_len + 2); >-+ if ( c ) entry = c; >-+ entry[SidebarWidth - delim_len + 1] = 0; >-+ for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' ); >-+ i = strlen(box); >-+ strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) ); >-+ >-+ if (size == -1) >-+ sprintf(entry + SidebarWidth - delim_len - 3, "?"); >-+ else if ( new ) { >-+ if (flagged > 0) { >-+ sprintf( >-+ entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged), >-+ "% d(%d)[%d]", size, new, flagged); >-+ } else { >-+ sprintf( >-+ entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new), >-+ "% d(%d)", size, new); >-+ } >-+ } else if (flagged > 0) { >-+ sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged); >-+ } else { >-+ sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size); >-+ } >-+ return entry; >-+} >-+ >-+void set_curbuffy(char buf[LONG_STRING]) >-+{ >-+ BUFFY* tmp = CurBuffy = Incoming; >-+ >-+ if (!Incoming) >-+ return; >-+ >-+ while(1) { >-+ if(!strcmp(tmp->path, buf)) { >-+ CurBuffy = tmp; >-+ break; >-+ } >-+ >-+ if(tmp->next) >-+ tmp = tmp->next; >-+ else >-+ break; >-+ } >-+} >-+ >-+int draw_sidebar(int menu) { >-+ >-+ int lines = option(OPTHELP) ? 1 : 0; >-+ BUFFY *tmp; >-+#ifndef USE_SLANG_CURSES >-+ attr_t attrs; >-+#endif >-+ short delim_len = strlen(SidebarDelim); >-+ short color_pair; >-+ >-+ static bool initialized = false; >-+ static int prev_show_value; >-+ static short saveSidebarWidth; >-+ >-+ /* initialize first time */ >-+ if(!initialized) { >-+ prev_show_value = option(OPTSIDEBAR); >-+ saveSidebarWidth = SidebarWidth; >-+ if(!option(OPTSIDEBAR)) SidebarWidth = 0; >-+ initialized = true; >-+ } >-+ >-+ /* save or restore the value SidebarWidth */ >-+ if(prev_show_value != option(OPTSIDEBAR)) { >-+ if(prev_show_value && !option(OPTSIDEBAR)) { >-+ saveSidebarWidth = SidebarWidth; >-+ SidebarWidth = 0; >-+ } else if(!prev_show_value && option(OPTSIDEBAR)) { >-+ SidebarWidth = saveSidebarWidth; >-+ } >-+ prev_show_value = option(OPTSIDEBAR); >-+ } >-+ >-+ >-+// if ( SidebarWidth == 0 ) return 0; >-+ if (SidebarWidth > 0 && option (OPTSIDEBAR) >-+ && delim_len >= SidebarWidth) { >-+ unset_option (OPTSIDEBAR); >-+ /* saveSidebarWidth = SidebarWidth; */ >-+ if (saveSidebarWidth > delim_len) { >-+ SidebarWidth = saveSidebarWidth; >-+ mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar.")); >-+ sleep (2); >-+ } else { >-+ SidebarWidth = 0; >-+ mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value.")); >-+ sleep (4); /* the advise to set a sane value should be seen long enough */ >-+ } >-+ saveSidebarWidth = 0; >-+ return (0); >-+ } >-+ >-+ if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) { >-+ if (SidebarWidth > 0) { >-+ saveSidebarWidth = SidebarWidth; >-+ SidebarWidth = 0; >-+ } >-+ unset_option(OPTSIDEBAR); >-+ return 0; >-+ } >-+ >-+ /* get attributes for divider */ >-+ SETCOLOR(MT_COLOR_STATUS); >-+#ifndef USE_SLANG_CURSES >-+ attr_get(&attrs, &color_pair, 0); >-+#else >-+ color_pair = attr_get(); >-+#endif >-+ SETCOLOR(MT_COLOR_NORMAL); >-+ >-+ /* draw the divider */ >-+ >-+ for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { >-+ move(lines, SidebarWidth - delim_len); >-+ addstr(NONULL(SidebarDelim)); >-+#ifndef USE_SLANG_CURSES >-+ mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL); >-+#endif >-+ } >-+ >-+ if ( Incoming == 0 ) return 0; >-+ lines = option(OPTHELP) ? 1 : 0; /* go back to the top */ >-+ >-+ if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) >-+ calc_boundaries(menu); >-+ if ( CurBuffy == 0 ) CurBuffy = Incoming; >-+ >-+ tmp = TopBuffy; >-+ >-+ SETCOLOR(MT_COLOR_NORMAL); >-+ >-+ for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) { >-+ if ( tmp == CurBuffy ) >-+ SETCOLOR(MT_COLOR_INDICATOR); >-+ else if ( tmp->msg_unread > 0 ) >-+ SETCOLOR(MT_COLOR_NEW); >-+ else if ( tmp->msg_flagged > 0 ) >-+ SETCOLOR(MT_COLOR_FLAGGED); >-+ else >-+ SETCOLOR(MT_COLOR_NORMAL); >-+ >-+ move( lines, 0 ); >-+ if ( Context && !strcmp( tmp->path, Context->path ) ) { >-+ tmp->msg_unread = Context->unread; >-+ tmp->msgcount = Context->msgcount; >-+ tmp->msg_flagged = Context->flagged; >-+ } >-+ // check whether Maildir is a prefix of the current folder's path >-+ short maildir_is_prefix = 0; >-+ if ( (strlen(tmp->path) > strlen(Maildir)) && >-+ (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) ) >-+ maildir_is_prefix = 1; >-+ // calculate depth of current folder and generate its display name with indented spaces >-+ int sidebar_folder_depth = 0; >-+ char *sidebar_folder_name; >-+ sidebar_folder_name = basename(tmp->path); >-+ if ( maildir_is_prefix ) { >-+ char *tmp_folder_name; >-+ int i; >-+ tmp_folder_name = tmp->path + strlen(Maildir); >-+ for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) { >-+ if (tmp_folder_name[i] == '/') sidebar_folder_depth++; >-+ } >-+ if (sidebar_folder_depth > 0) { >-+ sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1); >-+ for (i=0; i < sidebar_folder_depth; i++) >-+ sidebar_folder_name[i]=' '; >-+ sidebar_folder_name[i]=0; >-+ strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth); >-+ } >-+ } >-+ printw( "%.*s", SidebarWidth - delim_len + 1, >-+ make_sidebar_entry(sidebar_folder_name, tmp->msgcount, >-+ tmp->msg_unread, tmp->msg_flagged)); >-+ if (sidebar_folder_depth > 0) >-+ free(sidebar_folder_name); >-+ lines++; >-+ } >-+ SETCOLOR(MT_COLOR_NORMAL); >-+ for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { >-+ int i = 0; >-+ move( lines, 0 ); >-+ for ( ; i < SidebarWidth - delim_len; i++ ) >-+ addch(' '); >-+ } >-+ return 0; >-+} >-+ >-+ >-+void set_buffystats(CONTEXT* Context) >-+{ >-+ BUFFY *tmp = Incoming; >-+ while(tmp) { >-+ if(Context && !strcmp(tmp->path, Context->path)) { >-+ tmp->msg_unread = Context->unread; >-+ tmp->msgcount = Context->msgcount; >-+ break; >-+ } >-+ tmp = tmp->next; >-+ } >-+} >-+ >-+void scroll_sidebar(int op, int menu) >-+{ >-+ if(!SidebarWidth) return; >-+ if(!CurBuffy) return; >-+ >-+ switch (op) { >-+ case OP_SIDEBAR_NEXT: >-+ if ( CurBuffy->next == NULL ) return; >-+ CurBuffy = CurBuffy->next; >-+ break; >-+ case OP_SIDEBAR_PREV: >-+ if ( CurBuffy->prev == NULL ) return; >-+ CurBuffy = CurBuffy->prev; >-+ break; >-+ case OP_SIDEBAR_SCROLL_UP: >-+ CurBuffy = TopBuffy; >-+ if ( CurBuffy != Incoming ) { >-+ calc_boundaries(menu); >-+ CurBuffy = CurBuffy->prev; >-+ } >-+ break; >-+ case OP_SIDEBAR_SCROLL_DOWN: >-+ CurBuffy = BottomBuffy; >-+ if ( CurBuffy->next ) { >-+ calc_boundaries(menu); >-+ CurBuffy = CurBuffy->next; >-+ } >-+ break; >-+ default: >-+ return; >-+ } >-+ calc_boundaries(menu); >-+ draw_sidebar(menu); >-+} >-+ >-diff -uNp -r mutt-5302767aa6aa.orig/sidebar.h mutt-5302767aa6aa/sidebar.h >---- mutt-5302767aa6aa.orig/sidebar.h Thu Jan 1 01:00:00 1970 >-+++ mutt-5302767aa6aa/sidebar.h Sat Sep 4 20:32:59 2010 >-@@ -0,0 +1,36 @@ >-+/* >-+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> >-+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> >-+ * >-+ * This program is free software; you can redistribute it and/or modify >-+ * it under the terms of the GNU General Public License as published by >-+ * the Free Software Foundation; either version 2 of the License, or >-+ * (at your option) any later version. >-+ * >-+ * This program is distributed in the hope that it will be useful, >-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-+ * GNU General Public License for more details. >-+ * >-+ * You should have received a copy of the GNU General Public License >-+ * along with this program; if not, write to the Free Software >-+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. >-+ */ >-+ >-+#ifndef SIDEBAR_H >-+#define SIDEBAR_H >-+ >-+struct MBOX_LIST { >-+ char *path; >-+ int msgcount; >-+ int new; >-+} MBLIST; >-+ >-+/* parameter is whether or not to go to the status line */ >-+/* used for omitting the last | that covers up the status bar in the index */ >-+int draw_sidebar(int); >-+void scroll_sidebar(int, int); >-+void set_curbuffy(char*); >-+void set_buffystats(CONTEXT*); >-+ >-+#endif /* SIDEBAR_H */ >Index: SOURCES/mutt-1.5.21-CVE-2014-9116.patch >=================================================================== >--- SOURCES/mutt-1.5.21-CVE-2014-9116.patch (revision 800495) >+++ SOURCES/mutt-1.5.21-CVE-2014-9116.patch (working copy) >@@ -1,38 +0,0 @@ >-This patches solves the issue raised by CVE-2014-9116 in bug 771125. >-The sendlib patch is incorporated from upstream commit: >-http://dev.mutt.org/trac/changeset/897dcc62e4aa >- >-The lib.c part was written by Antonio Radici <antonio@debian.org> to prevent >-crashes due to this kind of bugs from happening again. >- >-Index: mutt/sendlib.c >-=================================================================== >---- mutt.orig/sendlib.c >-+++ mutt/sendlib.c >-@@ -1814,7 +1814,11 @@ static int write_one_header (FILE *fp, i >- { >- tagbuf = mutt_substrdup (start, t); >- ++t; /* skip over the colon separating the header field name and value */ >-- SKIPWS(t); /* skip over any leading whitespace */ >-+ >-+ /* skip over any leading whitespace (WSP, as defined in RFC5322) */ >-+ while (*t == ' ' || *t == '\t') >-+ t++; >-+ >- valbuf = mutt_substrdup (t, end); >- } >- dprint(4,(debugfile,"mwoh: buf[%s%s] too long, " >-Index: mutt/lib.c >-=================================================================== >---- mutt.orig/lib.c >-+++ mutt/lib.c >-@@ -814,6 +814,9 @@ char *mutt_substrdup (const char *begin, >- size_t len; >- char *p; >- >-+ if (end != NULL && end < begin) >-+ return NULL; >-+ >- if (end) >- len = end - begin; >- else >Index: SOURCES/mutt-1.5.21-automake-1.13.patch >=================================================================== >--- SOURCES/mutt-1.5.21-automake-1.13.patch (revision 800495) >+++ SOURCES/mutt-1.5.21-automake-1.13.patch (working copy) >@@ -1,11 +0,0 @@ >---- mutt-1.5.21/configure.ac.orig 2013-01-12 21:34:28.546475394 -0500 >-+++ mutt-1.5.21/configure.ac 2013-01-12 21:34:50.186931927 -0500 >-@@ -5,7 +5,7 @@ >- >- AC_PREREQ([2.54]) >- AC_INIT([mutt.h]) >--AM_CONFIG_HEADER([config.h]) >-+AC_CONFIG_HEADERS([config.h]) >- >- mutt_cv_version=`cat $srcdir/VERSION` >- AM_INIT_AUTOMAKE(mutt, $mutt_cv_version) >Index: SOURCES/mutt-1.5.21-db5.patch >=================================================================== >--- SOURCES/mutt-1.5.21-db5.patch (revision 800495) >+++ SOURCES/mutt-1.5.21-db5.patch (working copy) >@@ -1,19 +0,0 @@ >---- configure.ac.db 2012-07-27 02:31:55.000000000 +0000 >-+++ configure.ac 2012-07-27 02:38:50.000000000 +0000 >-@@ -27,7 +27,6 @@ >- >- AC_PROG_CC >- AC_ISC_POSIX >--AM_C_PROTOTYPES >- if test "x$U" != "x"; then >- AC_MSG_ERROR(Compiler not ANSI compliant) >- fi >-@@ -997,7 +996,7 @@ >- bdbpfx="$bdbpfx $d/$v" >- done >- done >-- BDB_VERSIONS="db-4 db4 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''" >-+ BDB_VERSIONS="db-5.3 db-5.2 db-5.1 db-5 db-4 db4 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''" >- AC_MSG_CHECKING([for BerkeleyDB > 4.0]) >- for d in $bdbpfx; do >- BDB_INCLUDE_DIR="" >Index: SOURCES/mutt-1.5.21-testcert.patch >=================================================================== >--- SOURCES/mutt-1.5.21-testcert.patch (revision 800495) >+++ SOURCES/mutt-1.5.21-testcert.patch (working copy) >@@ -1,30 +0,0 @@ >-diff -up mutt-1.5.21/mutt_ssl_gnutls.c.old mutt-1.5.21/mutt_ssl_gnutls.c >---- mutt-1.5.21/mutt_ssl_gnutls.c.old 2011-03-23 11:46:28.760386765 +0100 >-+++ mutt-1.5.21/mutt_ssl_gnutls.c 2011-03-23 14:34:45.839456449 +0100 >-@@ -978,6 +978,7 @@ static int tls_check_certificate (CONNEC >- unsigned int cert_list_size = 0; >- gnutls_certificate_status certstat; >- int certerr, i, preauthrc, savedcert, rc = 0; >-+ int rcpeer; >- >- if (gnutls_auth_get_type (state) != GNUTLS_CRD_CERTIFICATE) >- { >-@@ -1003,6 +1004,9 @@ static int tls_check_certificate (CONNEC >- for (i = 0; i < cert_list_size; i++) { >- rc = tls_check_preauth(&cert_list[i], certstat, conn->account.host, i, >- &certerr, &savedcert); >-+ if (i == 0) >-+ rcpeer = rc; >-+ >- preauthrc += rc; >- >- if (savedcert) >-@@ -1028,7 +1032,7 @@ static int tls_check_certificate (CONNEC >- dprint (1, (debugfile, "error trusting certificate %d: %d\n", i, rc)); >- >- certstat = tls_verify_peers (state); >-- if (!certstat) >-+ if (!certstat && !rcpeer) >- return 1; >- } >- } >Index: SOURCES/mutt-1.5.21.tar.gz.asc >=================================================================== >--- SOURCES/mutt-1.5.21.tar.gz.asc (revision 800495) >+++ SOURCES/mutt-1.5.21.tar.gz.asc (working copy) >@@ -1,7 +0,0 @@ >------BEGIN PGP SIGNATURE----- >-Version: GnuPG v1.4.10 (GNU/Linux) >- >-iEYEABECAAYFAkyQ/hIACgkQIigsijWFMDKTLwCfVrohdfnRsVYuOYMsVrSTbb/l >-jzMAn1bdfKuilPChKJ/xDj6mry/wekXB >-=iX+Z >------END PGP SIGNATURE----- >Index: SOURCES/mutt-1.5.23-compressed-mbox.patch >=================================================================== >--- SOURCES/mutt-1.5.23-compressed-mbox.patch (revision 0) >+++ SOURCES/mutt-1.5.23-compressed-mbox.patch (working copy) >@@ -0,0 +1,1303 @@ >+diff -uNr mutt-1.5.23/compress.c mutt-1.5.23.compress/compress.c >+--- mutt-1.5.23/compress.c 1970-01-01 02:00:00.000000000 +0200 >++++ mutt-1.5.23.compress/compress.c 2014-12-03 01:33:43.319607137 +0200 >+@@ -0,0 +1,490 @@ >++/* >++ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com> >++ * >++ * This program is free software; you can redistribute it and/or modify >++ * it under the terms of the GNU General Public License as published by >++ * the Free Software Foundation; either version 2 of the License, or >++ * (at your option) any later version. >++ * >++ * This program is distributed in the hope that it will be useful, >++ * but WITHOUT ANY WARRANTY; without even the implied warranty of >++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >++ * GNU General Public License for more details. >++ * >++ * You should have received a copy of the GNU General Public License >++ * along with this program; if not, write to the Free Software >++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >++ */ >++ >++#if HAVE_CONFIG_H >++# include "config.h" >++#endif >++ >++#include "mutt.h" >++ >++#ifdef USE_COMPRESSED >++ >++#include "mx.h" >++#include "mailbox.h" >++#include "mutt_curses.h" >++ >++#include <errno.h> >++#include <string.h> >++#include <unistd.h> >++#include <sys/stat.h> >++ >++typedef struct >++{ >++ const char *close; /* close-hook command */ >++ const char *open; /* open-hook command */ >++ const char *append; /* append-hook command */ >++ off_t size; /* size of real folder */ >++} COMPRESS_INFO; >++ >++char echo_cmd[HUGE_STRING]; >++ >++/* parameters: >++ * ctx - context to lock >++ * excl - exclusive lock? >++ * retry - should retry if unable to lock? >++ */ >++int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry) >++{ >++ int r; >++ >++ if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0) >++ ctx->locked = 1; >++ else if (retry && !excl) >++ { >++ ctx->readonly = 1; >++ return 0; >++ } >++ >++ return (r); >++} >++ >++void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp) >++{ >++ if (ctx->locked) >++ { >++ fflush (fp); >++ >++ mx_unlock_file (ctx->realpath, fileno (fp), 1); >++ ctx->locked = 0; >++ } >++} >++ >++static int is_new (const char *path) >++{ >++ return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0; >++} >++ >++static const char* find_compress_hook (int type, const char *path) >++{ >++ const char* c = mutt_find_hook (type, path); >++ return (!c || !*c) ? NULL : c; >++} >++ >++int mutt_can_read_compressed (const char *path) >++{ >++ return find_compress_hook (M_OPENHOOK, path) ? 1 : 0; >++} >++ >++/* if the file is new, we really do not append, but create, and so use >++ * close-hook, and not append-hook >++ */ >++static const char* get_append_command (const char *path, const CONTEXT* ctx) >++{ >++ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; >++ return (is_new (path)) ? ci->close : ci->append; >++} >++ >++int mutt_can_append_compressed (const char *path) >++{ >++ int magic; >++ >++ if (is_new (path)) >++ return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0); >++ >++ magic = mx_get_magic (path); >++ >++ if (magic != 0 && magic != M_COMPRESSED) >++ return 0; >++ >++ return (find_compress_hook (M_APPENDHOOK, path) >++ || (find_compress_hook (M_OPENHOOK, path) >++ && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0; >++} >++ >++/* open a compressed mailbox */ >++static COMPRESS_INFO *set_compress_info (CONTEXT *ctx) >++{ >++ COMPRESS_INFO *ci; >++ >++ /* Now lets uncompress this thing */ >++ ci = safe_malloc (sizeof (COMPRESS_INFO)); >++ ctx->compressinfo = (void*) ci; >++ ci->append = find_compress_hook (M_APPENDHOOK, ctx->path); >++ ci->open = find_compress_hook (M_OPENHOOK, ctx->path); >++ ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path); >++ return ci; >++} >++ >++static void set_path (CONTEXT* ctx) >++{ >++ char tmppath[_POSIX_PATH_MAX]; >++ >++ /* Setup the right paths */ >++ ctx->realpath = ctx->path; >++ >++ /* Uncompress to /tmp */ >++ mutt_mktemp (tmppath, sizeof(tmppath)); >++ ctx->path = safe_malloc (strlen (tmppath) + 1); >++ strcpy (ctx->path, tmppath); >++} >++ >++static int get_size (const char* path) >++{ >++ struct stat sb; >++ if (stat (path, &sb) != 0) >++ return 0; >++ return (sb.st_size); >++} >++ >++static void store_size (CONTEXT* ctx) >++{ >++ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; >++ ci->size = get_size (ctx->realpath); >++} >++ >++static const char * >++compresshook_format_str (char *dest, size_t destlen, size_t col, char op, >++ const char *src, const char *fmt, const char *ifstring, >++ const char *elsestring, unsigned long data, >++ format_flag flags) >++{ >++ char tmp[SHORT_STRING]; >++ >++ CONTEXT *ctx = (CONTEXT *) data; >++ switch (op) >++ { >++ case 'f': >++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >++ snprintf (dest, destlen, tmp, ctx->realpath); >++ break; >++ case 't': >++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >++ snprintf (dest, destlen, tmp, ctx->path); >++ break; >++ } >++ return (src); >++} >++ >++/* check that the command has both %f and %t >++ * 0 means OK, -1 means error >++ */ >++int mutt_test_compress_command (const char* cmd) >++{ >++ return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1; >++} >++ >++static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx) >++{ >++ char expanded[_POSIX_PATH_MAX]; >++ mutt_FormatString (expanded, sizeof (expanded), 0, cmd, compresshook_format_str, >++ (unsigned long) ctx, 0); >++ return safe_strdup (expanded); >++} >++ >++int mutt_check_mailbox_compressed (CONTEXT* ctx) >++{ >++ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; >++ if (ci->size != get_size (ctx->realpath)) >++ { >++ FREE (&ctx->compressinfo); >++ FREE (&ctx->realpath); >++ mutt_error _("Mailbox was corrupted!"); >++ return (-1); >++ } >++ return (0); >++} >++ >++int mutt_open_read_compressed (CONTEXT *ctx) >++{ >++ char *cmd; >++ FILE *fp; >++ int rc; >++ >++ COMPRESS_INFO *ci = set_compress_info (ctx); >++ if (!ci->open) { >++ ctx->magic = 0; >++ FREE (ctx->compressinfo); >++ return (-1); >++ } >++ if (!ci->close || access (ctx->path, W_OK) != 0) >++ ctx->readonly = 1; >++ >++ set_path (ctx); >++ store_size (ctx); >++ >++ if (!ctx->quiet) >++ mutt_message (_("Decompressing %s..."), ctx->realpath); >++ >++ cmd = get_compression_cmd (ci->open, ctx); >++ if (cmd == NULL) >++ return (-1); >++ dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd)); >++ >++ if ((fp = fopen (ctx->realpath, "r")) == NULL) >++ { >++ mutt_perror (ctx->realpath); >++ FREE (&cmd); >++ return (-1); >++ } >++ mutt_block_signals (); >++ if (mbox_lock_compressed (ctx, fp, 0, 1) == -1) >++ { >++ fclose (fp); >++ mutt_unblock_signals (); >++ mutt_error _("Unable to lock mailbox!"); >++ FREE (&cmd); >++ return (-1); >++ } >++ >++ endwin (); >++ fflush (stdout); >++ sprintf(echo_cmd,_("echo Decompressing %s..."),ctx->realpath); >++ mutt_system(echo_cmd); >++ rc = mutt_system (cmd); >++ mbox_unlock_compressed (ctx, fp); >++ mutt_unblock_signals (); >++ fclose (fp); >++ >++ if (rc) >++ { >++ mutt_any_key_to_continue (NULL); >++ ctx->magic = 0; >++ FREE (ctx->compressinfo); >++ mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd); >++ } >++ FREE (&cmd); >++ if (rc) >++ return (-1); >++ >++ if (mutt_check_mailbox_compressed (ctx)) >++ return (-1); >++ >++ ctx->magic = mx_get_magic (ctx->path); >++ >++ return (0); >++} >++ >++void restore_path (CONTEXT* ctx) >++{ >++ FREE (&ctx->path); >++ ctx->path = ctx->realpath; >++} >++ >++/* remove the temporary mailbox */ >++void remove_file (CONTEXT* ctx) >++{ >++ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF) >++ remove (ctx->path); >++} >++ >++int mutt_open_append_compressed (CONTEXT *ctx) >++{ >++ FILE *fh; >++ COMPRESS_INFO *ci = set_compress_info (ctx); >++ >++ if (!get_append_command (ctx->path, ctx)) >++ { >++ if (ci->open && ci->close) >++ return (mutt_open_read_compressed (ctx)); >++ >++ ctx->magic = 0; >++ FREE (&ctx->compressinfo); >++ return (-1); >++ } >++ >++ set_path (ctx); >++ >++ ctx->magic = DefaultMagic; >++ >++ if (!is_new (ctx->realpath)) >++ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF) >++ if ((fh = fopen (ctx->path, "w"))) >++ fclose (fh); >++ /* No error checking - the parent function will catch it */ >++ >++ return (0); >++} >++ >++/* close a compressed mailbox */ >++void mutt_fast_close_compressed (CONTEXT *ctx) >++{ >++ dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n", >++ ctx->path)); >++ >++ if (ctx->compressinfo) >++ { >++ if (ctx->fp) >++ fclose (ctx->fp); >++ ctx->fp = NULL; >++ /* if the folder was removed, remove the gzipped folder too */ >++ if (access (ctx->path, F_OK) != 0 && ! option (OPTSAVEEMPTY)) >++ remove (ctx->realpath); >++ else >++ remove_file (ctx); >++ >++ restore_path (ctx); >++ FREE (&ctx->compressinfo); >++ } >++} >++ >++/* return 0 on success, -1 on failure */ >++int mutt_sync_compressed (CONTEXT* ctx) >++{ >++ char *cmd; >++ int rc = 0; >++ FILE *fp; >++ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; >++ >++ if (!ctx->quiet) >++ mutt_message (_("Compressing %s..."), ctx->realpath); >++ >++ cmd = get_compression_cmd (ci->close, ctx); >++ if (cmd == NULL) >++ return (-1); >++ >++ if ((fp = fopen (ctx->realpath, "a")) == NULL) >++ { >++ mutt_perror (ctx->realpath); >++ FREE (&cmd); >++ return (-1); >++ } >++ mutt_block_signals (); >++ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) >++ { >++ fclose (fp); >++ mutt_unblock_signals (); >++ mutt_error _("Unable to lock mailbox!"); >++ >++ store_size (ctx); >++ >++ FREE (&cmd); >++ return (-1); >++ } >++ >++ dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd)); >++ >++ endwin (); >++ fflush (stdout); >++ sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath); >++ mutt_system(echo_cmd); >++ if (mutt_system (cmd)) >++ { >++ mutt_any_key_to_continue (NULL); >++ mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path); >++ rc = -1; >++ } >++ >++ mbox_unlock_compressed (ctx, fp); >++ mutt_unblock_signals (); >++ fclose (fp); >++ >++ FREE (&cmd); >++ >++ store_size (ctx); >++ >++ return (rc); >++} >++ >++int mutt_slow_close_compressed (CONTEXT *ctx) >++{ >++ FILE *fp; >++ const char *append; >++ char *cmd; >++ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; >++ >++ dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n", >++ ctx->path)); >++ >++ if (! (ctx->append >++ && ((append = get_append_command (ctx->realpath, ctx)) >++ || (append = ci->close)))) >++ { /* if we can not or should not append, >++ * we only have to remove the compressed info, because sync was already >++ * called >++ */ >++ mutt_fast_close_compressed (ctx); >++ return (0); >++ } >++ >++ if (ctx->fp) >++ fclose (ctx->fp); >++ ctx->fp = NULL; >++ >++ if (!ctx->quiet) >++ { >++ if (append == ci->close) >++ mutt_message (_("Compressing %s..."), ctx->realpath); >++ else >++ mutt_message (_("Compressed-appending to %s..."), ctx->realpath); >++ } >++ >++ cmd = get_compression_cmd (append, ctx); >++ if (cmd == NULL) >++ return (-1); >++ >++ if ((fp = fopen (ctx->realpath, "a")) == NULL) >++ { >++ mutt_perror (ctx->realpath); >++ FREE (&cmd); >++ return (-1); >++ } >++ mutt_block_signals (); >++ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) >++ { >++ fclose (fp); >++ mutt_unblock_signals (); >++ mutt_error _("Unable to lock mailbox!"); >++ FREE (&cmd); >++ return (-1); >++ } >++ >++ dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd)); >++ >++ endwin (); >++ fflush (stdout); >++ >++ if (append == ci->close) >++ sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath); >++ else >++ sprintf(echo_cmd,_("echo Compressed-appending to %s..."), ctx->realpath); >++ mutt_system(echo_cmd); >++ >++ if (mutt_system (cmd)) >++ { >++ mutt_any_key_to_continue (NULL); >++ mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"), >++ ctx->path); >++ FREE (&cmd); >++ mbox_unlock_compressed (ctx, fp); >++ mutt_unblock_signals (); >++ fclose (fp); >++ return (-1); >++ } >++ >++ mbox_unlock_compressed (ctx, fp); >++ mutt_unblock_signals (); >++ fclose (fp); >++ remove_file (ctx); >++ restore_path (ctx); >++ FREE (&cmd); >++ FREE (&ctx->compressinfo); >++ >++ return (0); >++} >++ >++#endif /* USE_COMPRESSED */ >+diff -uNr mutt-1.5.23/compress.h mutt-1.5.23.compress/compress.h >+--- mutt-1.5.23/compress.h 1970-01-01 02:00:00.000000000 +0200 >++++ mutt-1.5.23.compress/compress.h 2014-12-03 01:33:43.319607137 +0200 >+@@ -0,0 +1,27 @@ >++/* >++ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com> >++ * >++ * This program is free software; you can redistribute it and/or modify >++ * it under the terms of the GNU General Public License as published by >++ * the Free Software Foundation; either version 2 of the License, or >++ * (at your option) any later version. >++ * >++ * This program is distributed in the hope that it will be useful, >++ * but WITHOUT ANY WARRANTY; without even the implied warranty of >++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >++ * GNU General Public License for more details. >++ * >++ * You should have received a copy of the GNU General Public License >++ * along with this program; if not, write to the Free Software >++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >++ */ >++ >++int mutt_can_read_compressed (const char *); >++int mutt_can_append_compressed (const char *); >++int mutt_open_read_compressed (CONTEXT *); >++int mutt_open_append_compressed (CONTEXT *); >++int mutt_slow_close_compressed (CONTEXT *); >++int mutt_sync_compressed (CONTEXT *); >++int mutt_test_compress_command (const char *); >++int mutt_check_mailbox_compressed (CONTEXT *); >++void mutt_fast_close_compressed (CONTEXT *); >+diff -uNr mutt-1.5.23/config.h.in mutt-1.5.23.compress/config.h.in >+--- mutt-1.5.23/config.h.in 2014-03-12 18:27:54.000000000 +0200 >++++ mutt-1.5.23.compress/config.h.in 2014-12-03 01:33:43.319607137 +0200 >+@@ -552,6 +552,9 @@ >+ >+ /* Define to enable Sun mailtool attachments support. */ >+ #undef SUN_ATTACHMENT >++ >++/* The compressed mailboxes support */ >++#undef USE_COMPRESSED >+ >+ /* Define to use dotlocking for mailboxes. */ >+ #undef USE_DOTLOCK >+diff -uNr mutt-1.5.23/configure mutt-1.5.23.compress/configure >+--- mutt-1.5.23/configure 2014-03-12 18:26:45.000000000 +0200 >++++ mutt-1.5.23.compress/configure 2014-12-03 01:33:43.320607147 +0200 >+@@ -1471,6 +1471,7 @@ >+ --disable-warnings Turn off compiler warnings (not recommended) >+ --enable-nfs-fix Work around an NFS with broken attributes caching >+ --enable-mailtool Enable Sun mailtool attachments support >++ --enable-compressed Enable compressed folders support >+ --enable-locales-fix The result of isprint() is unreliable >+ --enable-exact-address Enable regeneration of email addresses >+ --enable-hcache Enable header caching >+@@ -8776,6 +8777,18 @@ >+ fi >+ fi >+ >++ >++# Check whether --enable-compressed or --disable-compressed was given. >++if test "${enable_compressed+set}" = set; then >++ enableval="$enable_compressed" >++ if test x$enableval = xyes; then >++ cat >> confdefs.h <<\EOF >++#define USE_COMPRESSED 1 >++EOF >++ >++ fi >++fi >++ >+ if test $mutt_cv_regex = yes; then >+ >+ $as_echo "#define USE_GNU_REGEX 1" >>confdefs.h >+diff -uNr mutt-1.5.23/configure.ac mutt-1.5.23.compress/configure.ac >+--- mutt-1.5.23/configure.ac 2014-03-12 18:26:40.000000000 +0200 >++++ mutt-1.5.23.compress/configure.ac 2014-12-03 01:33:43.320607147 +0200 >+@@ -806,6 +806,11 @@ >+ [if test x$enableval = xyes; then >+ AC_DEFINE(SUN_ATTACHMENT,1,[ Define to enable Sun mailtool attachments support. ]) >+ fi]) >++AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]), >++ [if test x$enableval = xyes; then >++ AC_DEFINE(USE_COMPRESSED,1,[ Define to enable compressed folders support. ]) >++ fi]) >++ >+ >+ AC_ARG_ENABLE(locales-fix, AS_HELP_STRING([--enable-locales-fix],[The result of isprint() is unreliable]), >+ [if test x$enableval = xyes; then >+diff -uNr mutt-1.5.23/curs_main.c mutt-1.5.23.compress/curs_main.c >+--- mutt-1.5.23/curs_main.c 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23.compress/curs_main.c 2014-12-03 01:33:43.321607156 +0200 >+@@ -1134,6 +1134,11 @@ >+ { >+ int check; >+ >++#ifdef USE_COMPRESSED >++ if (Context->compressinfo && Context->realpath) >++ mutt_str_replace (&LastFolder, Context->realpath); >++ else >++#endif >+ mutt_str_replace (&LastFolder, Context->path); >+ oldcount = Context ? Context->msgcount : 0; >+ >+diff -uNr mutt-1.5.23/doc/Makefile.am mutt-1.5.23.compress/doc/Makefile.am >+--- mutt-1.5.23/doc/Makefile.am 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23.compress/doc/Makefile.am 2014-12-03 01:33:43.321607156 +0200 >+@@ -34,7 +34,8 @@ >+ >+ CHUNKED_DOCFILES = index.html intro.html gettingstarted.html \ >+ configuration.html mimesupport.html advancedusage.html \ >+- optionalfeatures.html security.html tuning.html reference.html miscellany.html >++ optionalfeatures.html security.html tuning.html reference.html miscellany.html \ >++ compressed-folders.html >+ >+ HTML_DOCFILES = manual.html $(CHUNKED_DOCFILES) >+ >+diff -uNr mutt-1.5.23/doc/Makefile.in mutt-1.5.23.compress/doc/Makefile.in >+--- mutt-1.5.23/doc/Makefile.in 2014-03-12 18:26:44.000000000 +0200 >++++ mutt-1.5.23.compress/doc/Makefile.in 2014-12-03 01:33:43.321607156 +0200 >+@@ -326,7 +326,8 @@ >+ >+ CHUNKED_DOCFILES = index.html intro.html gettingstarted.html \ >+ configuration.html mimesupport.html advancedusage.html \ >+- optionalfeatures.html security.html tuning.html reference.html miscellany.html >++ optionalfeatures.html security.html tuning.html reference.html miscellany.html \ >++ compressed-folders.html >+ >+ HTML_DOCFILES = manual.html $(CHUNKED_DOCFILES) >+ BUILT_DISTFILES = stamp-doc-xml stamp-doc-chunked manual.txt $(HTML_DOCFILES) >+diff -uNr mutt-1.5.23/doc/manual.xml.head mutt-1.5.23.compress/doc/manual.xml.head >+--- mutt-1.5.23/doc/manual.xml.head 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23.compress/doc/manual.xml.head 2014-12-03 01:33:43.322607166 +0200 >+@@ -5168,6 +5168,24 @@ >+ () — logical grouping operator >+ </para> >+ </listitem> >++<listitem> >++ >++<para> >++<link linkend="open-hook">open-hook</link> >++</para> >++</listitem> >++<listitem> >++ >++<para> >++<link linkend="close-hook">close-hook</link> >++</para> >++</listitem> >++<listitem> >++ >++<para> >++<link linkend="append-hook">append-hook</link> >++</para> >++</listitem> >+ >+ </itemizedlist> >+ >+@@ -6099,6 +6117,254 @@ >+ >+ </chapter> >+ >++<chapter id="compressed-folders"> >++<title>Compressed folders Support (OPTIONAL)</title> >++ >++<para> >++If Mutt was compiled with compressed folders support (by running the >++<emphasis>configure</emphasis> script with the >++<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders >++stored in an arbitrary format, provided that the user has a script to >++convert from/to this format to one of the accepted. >++</para> >++ >++<para> >++The most common use is to open compressed archived folders e.g. with >++gzip. >++</para> >++ >++<para> >++In addition, the user can provide a script that gets a folder in an >++accepted format and appends its context to the folder in the >++user-defined format, which may be faster than converting the entire >++folder to the accepted format, appending to it and converting back to >++the user-defined format. >++</para> >++ >++<para> >++There are three hooks defined >++(<link linkend="open-hook">open-hook</link>, >++<link linkend="close-hook">close-hook</link> and >++<link linkend="append-hook">append-hook</link>) which define commands >++to uncompress and compress a folder and to append messages to an >++existing compressed folder respectively. >++</para> >++ >++<para> >++For example: >++ >++<screen> >++open-hook \\.gz$ "gzip -cd %f > %t" >++close-hook \\.gz$ "gzip -c %t > %f" >++append-hook \\.gz$ "gzip -c %t >> %f" >++</screen> >++</para> >++ >++<para> >++You do not have to specify all of the commands. If you omit >++<link linkend="append-hook">append-hook</link>, the folder will be open >++and closed again each time you will add to it. If you omit >++<link linkend="close-hook">close-hook</link> (or give empty command), >++the folder will be open in the mode. If you specify >++<link linkend="append-hook">append-hook</link> though you'll be able to >++append to the folder. >++</para> >++ >++<para> >++Note that Mutt will only try to use hooks if the file is not in one of >++the accepted formats. In particular, if the file is empty, mutt >++supposes it is not compressed. This is important because it allows the >++use of programs that do not have well defined extensions. Just use >++``.'' as a regexp. But this may be surprising if your compressing >++script produces empty files. In this situation, unset >++<link linkend="save-empty">$save_empty</link>, so that >++the compressed file will be removed if you delete all of the messages. >++</para> >++ >++<sect1 id="open-hook"> >++<title>Open a compressed mailbox for reading</title> >++ >++<para> >++Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis> >++</para> >++ >++<para> >++The <emphasis>command</emphasis> is the command that can be used for >++opening the folders whose names match <emphasis>regexp</emphasis>. >++</para> >++ >++<para> >++The <emphasis>command</emphasis> string is the printf-like format >++string, and it should accept two parameters: %f, which is >++replaced with the (compressed) folder name, and %t which is >++replaced with the name of the temporary folder to which to write. >++</para> >++ >++<para> >++%f and %t can be repeated any number of times in the >++command string, and all of the entries are replaced with the >++appropriate folder name. In addition, %% is replaced by >++%, as in printf, and any other %anything is left as is. >++</para> >++ >++<para> >++The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis> >++remove the original compressed file. The <emphasis>command</emphasis> >++should return non-zero exit status if it fails, so mutt knows >++something's wrong. >++</para> >++ >++<para> >++Example: >++ >++<screen> >++open-hook \\.gz$ "gzip -cd %f > %t" >++</screen> >++</para> >++ >++<para> >++If the <emphasis>command</emphasis> is empty, this operation is >++disabled for this file type. >++</para> >++ >++</sect1> >++ >++<sect1 id="close-hook"> >++<title>Write a compressed mailbox</title> >++ >++<para> >++Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis> >++</para> >++ >++<para> >++This is used to close the folder that was open with the >++<link linkend="open-hook">open-hook</link> command after some changes >++were made to it. >++</para> >++ >++<para> >++The <emphasis>command</emphasis> string is the command that can be >++used for closing the folders whose names match <emphasis>regexp</emphasis>. >++It has the same format as in the <link linkend="open-hook">open-hook</link> >++command. Temporary folder in this case is the folder previously >++produced by the <link linkend="open-hook">open-hook</link> command. >++</para> >++ >++<para> >++The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis> >++remove the decompressed file. The <emphasis>command</emphasis> should >++return non-zero exit status if it fails, so mutt knows something's >++wrong. >++</para> >++ >++<para> >++Example: >++ >++<screen> >++close-hook \\.gz$ "gzip -c %t > %f" >++</screen> >++</para> >++ >++<para> >++If the <emphasis>command</emphasis> is empty, this operation is >++disabled for this file type, and the file can only be open in the >++readonly mode. >++</para> >++ >++<para> >++<link linkend="close-hook">close-hook</link> is not called when you >++exit from the folder if the folder was not changed. >++</para> >++ >++</sect1> >++ >++<sect1 id="append-hook"> >++<title>Append a message to a compressed mailbox</title> >++ >++<para> >++Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis> >++</para> >++ >++<para> >++This command is used for saving to an existing compressed folder. >++The <emphasis>command</emphasis> is the command that can be used for >++appending to the folders whose names match <emphasis>regexp</emphasis>. >++It has the same format as in the <link linkend="open-hook">open-hook</link> >++command. The temporary folder in this case contains the messages that >++are being appended. >++</para> >++ >++<para> >++The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis> >++remove the decompressed file. The <emphasis>command</emphasis> should >++return non-zero exit status if it fails, so mutt knows something's >++wrong. >++</para> >++ >++<para> >++Example: >++ >++<screen> >++append-hook \\.gz$ "gzip -c %t >> %f" >++</screen> >++</para> >++ >++<para> >++When <link linkend="append-hook">append-hook</link> is used, the folder >++is not opened, which saves time, but this means that we can not find >++out what the folder type is. Thus the default >++(<link linkend="mbox-type">$mbox_type</link>) type is >++always supposed (i.e. this is the format used for the temporary >++folder). >++</para> >++ >++<para> >++If the file does not exist when you save to it, >++<link linkend="close-hook">close-hook</link> is called, and not >++<link linkend="append-hook">append-hook</link>. >++<link linkend="append-hook">append-hook</link> is only for appending >++to existing folders. >++</para> >++ >++<para> >++If the <emphasis>command</emphasis> is empty, this operation is >++disabled for this file type. In this case, the folder will be open and >++closed again (using <link linkend="open-hook">open-hook</link> and >++<link linkend="close-hook">close-hook</link> respectively) each time >++you will add to it. >++</para> >++ >++</sect1> >++ >++<sect1> >++<title>Encrypted folders</title> >++ >++<para> >++The compressed folders support can also be used to handle encrypted >++folders. If you want to encrypt a folder with PGP, you may want to use >++the following hooks: >++ >++<screen> >++open-hook \\.pgp$ "pgp -f < %f > %t" >++close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f" >++</screen> >++</para> >++ >++<para> >++Please note, that PGP does not support appending to an encrypted >++folder, so there is no append-hook defined. >++</para> >++ >++<para> >++<emphasis role="bold">Note:</emphasis> the folder is temporary stored >++decrypted in the /tmp directory, where it can be read by your system >++administrator. So think about the security aspects of this. >++</para> >++ >++</sect1> >++ >++</chapter> >++ >+ <chapter id="mimesupport"> >+ <title>Mutt's MIME Support</title> >+ >+@@ -8433,6 +8699,18 @@ >+ >+ <listitem> >+ <cmdsynopsis> >++<command><link linkend="append-hook">append-hook</link></command> >++<arg choice="plain"> >++<replaceable class="parameter">pattern</replaceable> >++</arg> >++<arg choice="plain"> >++<replaceable class="parameter">command</replaceable> >++</arg> >++</cmdsynopsis> >++</listitem> >++ >++<listitem> >++<cmdsynopsis> >+ <command><link linkend="auto-view">auto_view</link></command> >+ <arg choice="plain"> >+ <replaceable>mimetype</replaceable> >+@@ -8494,6 +8772,18 @@ >+ >+ <listitem> >+ <cmdsynopsis> >++<command><link linkend="close-hook">close-hook</link></command> >++<arg choice="plain"> >++<replaceable class="parameter">pattern</replaceable> >++</arg> >++<arg choice="plain"> >++<replaceable class="parameter">command</replaceable> >++</arg> >++</cmdsynopsis> >++</listitem> >++ >++<listitem> >++<cmdsynopsis> >+ <command><link linkend="color">color</link></command> >+ <arg choice="plain"> >+ <replaceable class="parameter">object</replaceable> >+@@ -8561,6 +8851,18 @@ >+ </cmdsynopsis> >+ </listitem> >+ >++<listitem> >++<cmdsynopsis> >++<command><link linkend="open-hook">open-hook</link></command> >++<arg choice="plain"> >++<replaceable class="parameter">pattern</replaceable> >++</arg> >++<arg choice="plain"> >++<replaceable class="parameter">command</replaceable> >++</arg> >++</cmdsynopsis> >++</listitem> >++ >+ <listitem> >+ <cmdsynopsis> >+ <command><link linkend="crypt-hook">crypt-hook</link></command> >+diff -uNr mutt-1.5.23/doc/Muttrc.head mutt-1.5.23.compress/doc/Muttrc.head >+--- mutt-1.5.23/doc/Muttrc.head 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23.compress/doc/Muttrc.head 2014-12-03 01:33:43.322607166 +0200 >+@@ -29,6 +29,11 @@ >+ macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list" >+ bind browser y exit >+ >++# Use folders which match on \\.gz$ as gzipped folders: >++# open-hook \\.gz$ "gzip -cd %f > %t" >++# close-hook \\.gz$ "gzip -c %t > %f" >++# append-hook \\.gz$ "gzip -c %t >> %f" >++ >+ # If Mutt is unable to determine your site's domain name correctly, you can >+ # set the default here. >+ # >+diff -uNr mutt-1.5.23/doc/muttrc.man.head mutt-1.5.23.compress/doc/muttrc.man.head >+--- mutt-1.5.23/doc/muttrc.man.head 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23.compress/doc/muttrc.man.head 2014-12-03 01:33:43.322607166 +0200 >+@@ -354,6 +354,24 @@ >+ to a certain recipient. The meaning of "key ID" is to be taken >+ broadly: This can be a different e-mail address, a numerical key ID, >+ or even just an arbitrary search string. >++.PP >++.nf >++\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP" >++\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP" >++\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP" >++.fi >++.IP >++These commands provide a way to handle compressed folders. The given >++\fBregexp\fP specifies which folders are taken as compressed (e.g. >++"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder >++(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a >++compressed mail to a compressed folder (\fBappend-hook\fP). The >++\fIcommand\fP string is the >++.BR printf (3) >++like format string, and it should accept two parameters: \fB%f\fP, >++which is replaced with the (compressed) folder name, and \fB%t\fP >++which is replaced with the name of the temporary folder to which to >++write. >+ .TP >+ \fBpush\fP \fIstring\fP >+ This command adds the named \fIstring\fP to the keyboard buffer. >+diff -uNr mutt-1.5.23/hook.c mutt-1.5.23.compress/hook.c >+--- mutt-1.5.23/hook.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23.compress/hook.c 2014-12-03 01:33:43.322607166 +0200 >+@@ -24,6 +24,10 @@ >+ #include "mailbox.h" >+ #include "mutt_crypt.h" >+ >++#ifdef USE_COMPRESSED >++#include "compress.h" >++#endif >++ >+ #include <limits.h> >+ #include <string.h> >+ #include <stdlib.h> >+@@ -92,6 +96,16 @@ >+ memset (&pattern, 0, sizeof (pattern)); >+ pattern.data = safe_strdup (path); >+ } >++#ifdef USE_COMPRESSED >++ else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK)) >++ { >++ if (mutt_test_compress_command (command.data)) >++ { >++ strfcpy (err->data, _("bad formatted command string"), err->dsize); >++ return (-1); >++ } >++ } >++#endif >+ else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK)) >+ && (!WithCrypto || !(data & M_CRYPTHOOK)) >+ ) >+diff -uNr mutt-1.5.23/init.h mutt-1.5.23.compress/init.h >+--- mutt-1.5.23/init.h 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23.compress/init.h 2014-12-03 01:33:43.323607176 +0200 >+@@ -3534,6 +3534,11 @@ >+ { "fcc-hook", mutt_parse_hook, M_FCCHOOK }, >+ { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK }, >+ { "folder-hook", mutt_parse_hook, M_FOLDERHOOK }, >++#ifdef USE_COMPRESSED >++ { "open-hook", mutt_parse_hook, M_OPENHOOK }, >++ { "close-hook", mutt_parse_hook, M_CLOSEHOOK }, >++ { "append-hook", mutt_parse_hook, M_APPENDHOOK }, >++#endif >+ { "group", parse_group, M_GROUP }, >+ { "ungroup", parse_group, M_UNGROUP }, >+ { "hdr_order", parse_list, UL &HeaderOrderList }, >+diff -uNr mutt-1.5.23/main.c mutt-1.5.23.compress/main.c >+--- mutt-1.5.23/main.c 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23.compress/main.c 2014-12-03 01:33:43.323607176 +0200 >+@@ -340,6 +340,12 @@ >+ "-USE_GNU_REGEX " >+ #endif >+ >++#ifdef USE_COMPRESSED >++ "+COMPRESSED " >++#else >++ "-COMPRESSED " >++#endif >++ >+ "\n" >+ >+ #ifdef HAVE_COLOR >+diff -uNr mutt-1.5.23/Makefile.am mutt-1.5.23.compress/Makefile.am >+--- mutt-1.5.23/Makefile.am 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23.compress/Makefile.am 2014-12-03 01:33:43.323607176 +0200 >+@@ -22,6 +22,7 @@ >+ bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@ >+ mutt_SOURCES = \ >+ addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \ >++ compress.c \ >+ crypt.c cryptglue.c \ >+ commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \ >+ edit.c enter.c flags.c init.c filter.c from.c \ >+@@ -62,6 +63,7 @@ >+ >+ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \ >+ configure account.h \ >++ compress.h \ >+ attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \ >+ globals.h hash.h history.h init.h keymap.h mutt_crypt.h \ >+ mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \ >+diff -uNr mutt-1.5.23/Makefile.in mutt-1.5.23.compress/Makefile.in >+--- mutt-1.5.23/Makefile.in 2014-03-12 18:26:44.000000000 +0200 >++++ mutt-1.5.23.compress/Makefile.in 2014-12-03 01:33:43.323607176 +0200 >+@@ -14,6 +14,10 @@ >+ >+ @SET_MAKE@ >+ >++mutt_SOURCES += compress.c >++EXTRA_DIST += compress.h >++mutt_OBJECTS += compress.o >++ >+ >+ VPATH = @srcdir@ >+ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' >+diff -uNr mutt-1.5.23/mbox.c mutt-1.5.23.compress/mbox.c >+--- mutt-1.5.23/mbox.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23.compress/mbox.c 2014-12-03 01:33:43.323607176 +0200 >+@@ -29,6 +29,10 @@ >+ #include "copy.h" >+ #include "mutt_curses.h" >+ >++#ifdef USE_COMPRESSED >++#include "compress.h" >++#endif >++ >+ #include <sys/stat.h> >+ #include <dirent.h> >+ #include <string.h> >+@@ -1069,6 +1073,12 @@ >+ int mbox_close_mailbox (CONTEXT *ctx) >+ { >+ mx_unlock_file (ctx->path, fileno (ctx->fp), 1); >++ >++#ifdef USE_COMPRESSED >++ if (ctx->compressinfo) >++ mutt_slow_close_compressed (ctx); >++#endif >++ >+ mutt_unblock_signals (); >+ mx_fastclose_mailbox (ctx); >+ return 0; >+diff -uNr mutt-1.5.23/mutt.h mutt-1.5.23.compress/mutt.h >+--- mutt-1.5.23/mutt.h 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23.compress/mutt.h 2014-12-03 01:33:43.324607186 +0200 >+@@ -144,6 +144,11 @@ >+ #define M_ACCOUNTHOOK (1<<9) >+ #define M_REPLYHOOK (1<<10) >+ #define M_SEND2HOOK (1<<11) >++#ifdef USE_COMPRESSED >++#define M_OPENHOOK (1<<12) >++#define M_APPENDHOOK (1<<13) >++#define M_CLOSEHOOK (1<<14) >++#endif >+ >+ /* tree characters for linearize_tree and print_enriched_string */ >+ #define M_TREE_LLCORNER 1 >+@@ -887,6 +892,11 @@ >+ >+ unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */ >+ >++#ifdef USE_COMPRESSED >++ void *compressinfo; /* compressed mbox module private data */ >++ char *realpath; /* path to compressed mailbox */ >++#endif /* USE_COMPRESSED */ >++ >+ unsigned int locked : 1; /* is the mailbox locked? */ >+ unsigned int changed : 1; /* mailbox has been modified */ >+ unsigned int readonly : 1; /* don't allow changes to the mailbox */ >+diff -uNr mutt-1.5.23/mx.c mutt-1.5.23.compress/mx.c >+--- mutt-1.5.23/mx.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23.compress/mx.c 2014-12-03 01:33:43.324607186 +0200 >+@@ -30,6 +30,10 @@ >+ #include "keymap.h" >+ #include "url.h" >+ >++#ifdef USE_COMPRESSED >++#include "compress.h" >++#endif >++ >+ #ifdef USE_IMAP >+ #include "imap.h" >+ #endif >+@@ -414,6 +418,11 @@ >+ return (-1); >+ } >+ >++#ifdef USE_COMPRESSED >++ if (magic == 0 && mutt_can_read_compressed (path)) >++ return M_COMPRESSED; >++#endif >++ >+ return (magic); >+ } >+ >+@@ -453,6 +462,13 @@ >+ { >+ struct stat sb; >+ >++#ifdef USE_COMPRESSED >++ /* special case for appending to compressed folders - >++ * even if we can not open them for reading */ >++ if (mutt_can_append_compressed (ctx->path)) >++ mutt_open_append_compressed (ctx); >++#endif >++ >+ ctx->append = 1; >+ >+ #ifdef USE_IMAP >+@@ -617,6 +633,11 @@ >+ >+ ctx->magic = mx_get_magic (path); >+ >++#ifdef USE_COMPRESSED >++ if (ctx->magic == M_COMPRESSED) >++ mutt_open_read_compressed (ctx); >++#endif >++ >+ if(ctx->magic == 0) >+ mutt_error (_("%s is not a mailbox."), path); >+ >+@@ -721,6 +742,10 @@ >+ mutt_free_header (&ctx->hdrs[i]); >+ FREE (&ctx->hdrs); >+ FREE (&ctx->v2r); >++#ifdef USE_COMPRESSED >++ if (ctx->compressinfo) >++ mutt_fast_close_compressed (ctx); >++#endif >+ FREE (&ctx->path); >+ FREE (&ctx->pattern); >+ if (ctx->limit_pattern) >+@@ -773,6 +798,12 @@ >+ >+ if (tmp && tmp->new == 0) >+ mutt_update_mailbox (tmp); >++ >++#ifdef USE_COMPRESSED >++ if (rc == 0 && ctx->compressinfo) >++ return mutt_sync_compressed (ctx); >++#endif >++ >+ return rc; >+ } >+ >+@@ -981,6 +1012,11 @@ >+ !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY)) >+ mx_unlink_empty (ctx->path); >+ >++#ifdef USE_COMPRESSED >++ if (ctx->compressinfo && mutt_slow_close_compressed (ctx)) >++ return (-1); >++#endif >++ >+ mx_fastclose_mailbox (ctx); >+ >+ return 0; >+@@ -1293,6 +1329,11 @@ >+ { >+ int rc; >+ >++#ifdef USE_COMPRESSED >++ if (ctx->compressinfo) >++ return mutt_check_mailbox_compressed (ctx); >++#endif >++ >+ if (ctx) >+ { >+ if (ctx->locked) lock = 0; >+diff -uNr mutt-1.5.23/mx.h mutt-1.5.23.compress/mx.h >+--- mutt-1.5.23/mx.h 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23.compress/mx.h 2014-12-03 01:33:43.324607186 +0200 >+@@ -36,6 +36,9 @@ >+ M_MAILDIR, >+ M_IMAP, >+ M_POP >++#ifdef USE_COMPRESSED >++ , M_COMPRESSED >++#endif >+ }; >+ >+ WHERE short DefaultMagic INITVAL (M_MBOX); >+diff -uNr mutt-1.5.23/PATCHES mutt-1.5.23.compress/PATCHES >+--- mutt-1.5.23/PATCHES 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23.compress/PATCHES 2014-12-03 01:33:43.324607186 +0200 >+@@ -0,0 +1 @@ >++rr.compressed >+diff -uNr mutt-1.5.23/po/POTFILES.in mutt-1.5.23.compress/po/POTFILES.in >+--- mutt-1.5.23/po/POTFILES.in 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23.compress/po/POTFILES.in 2014-12-03 01:33:43.324607186 +0200 >+@@ -8,6 +8,7 @@ >+ color.c >+ commands.c >+ compose.c >++compress.c >+ crypt-gpgme.c >+ crypt.c >+ cryptglue.c >+diff -uNr mutt-1.5.23/status.c mutt-1.5.23.compress/status.c >+--- mutt-1.5.23/status.c 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23.compress/status.c 2014-12-03 01:33:43.324607186 +0200 >+@@ -96,6 +96,14 @@ >+ >+ case 'f': >+ snprintf (fmt, sizeof(fmt), "%%%ss", prefix); >++#ifdef USE_COMPRESSED >++ if (Context && Context->compressinfo && Context->realpath) >++ { >++ strfcpy (tmp, Context->realpath, sizeof (tmp)); >++ mutt_pretty_mailbox (tmp, sizeof (tmp)); >++ } >++ else >++#endif >+ if (Context && Context->path) >+ { >+ strfcpy (tmp, Context->path, sizeof (tmp)); >Index: SOURCES/mutt-1.5.23-db53.patch >=================================================================== >--- SOURCES/mutt-1.5.23-db53.patch (revision 0) >+++ SOURCES/mutt-1.5.23-db53.patch (working copy) >@@ -0,0 +1,56 @@ >+--- configure.ac 2014-03-12 18:26:40.000000000 +0200 >++++ configure.ac.db53 2014-12-03 01:27:18.063896918 +0200 >+@@ -161,7 +161,7 @@ >+ have_smime=no >+ fi >+ ]) >+- >++ >+ if test x$have_smime != xno ; then >+ AC_DEFINE(CRYPT_BACKEND_CLASSIC_SMIME, 1, [Define if you want clasic S/MIME support.]) >+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS smime.o crypt-mod-smime-classic.o" >+@@ -274,7 +274,7 @@ >+ done >+ AC_CHECK_LIB($cf_ncurses, initscr, >+ [MUTTLIBS="$MUTTLIBS -l$cf_ncurses" >+- >++ >+ if test "$cf_ncurses" = ncursesw; then >+ AC_CHECK_HEADERS(ncursesw/ncurses.h,[cf_cv_ncurses_header="ncursesw/ncurses.h"]) >+ else >+@@ -623,7 +623,7 @@ >+ >+ dnl -- imap dependencies -- >+ >+-AC_ARG_WITH(gss, AS_HELP_STRING([--with-gss@<:@=PFX@:>@],[Compile in GSSAPI authentication for IMAP]), >++AC_ARG_WITH(gss, AS_HELP_STRING([--with-gss@<:@=PFX@:>@],[Compile in GSSAPI authentication for IMAP]), >+ gss_prefix="$withval", gss_prefix="no") >+ if test "$gss_prefix" != "no" >+ then >+@@ -721,7 +721,7 @@ >+ AM_CONDITIONAL(USE_SSL, test x$need_ssl = xyes) >+ >+ AC_ARG_WITH(sasl, AS_HELP_STRING([--with-sasl@<:@=PFX@:>@],[Use SASL network security library]), >+- [ >++ [ >+ if test "$with_sasl" != "no" >+ then >+ if test "$need_socket" != "yes" >+@@ -881,7 +881,7 @@ >+ db_requested=bdb >+ fi >+ fi >+- >++ >+ dnl -- Tokyo Cabinet -- >+ if test "$with_tokyocabinet" != "no" \ >+ && test "$db_requested" = auto -o "$db_requested" = tc >+@@ -980,7 +980,7 @@ >+ bdbpfx="$bdbpfx $d/$v" >+ done >+ done >+- BDB_VERSIONS="db-4 db4 db-5 db5 db-5.2 db5.2 db52 db-5.1 db5.1 db51 db-5.0 db5.0 db50 db-4.8 db4.8 db48 db-4.7 db4.7 db47 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''" >++ BDB_VERSIONS="db-4 db4 db-5 db5 db-5.3 db5.3 db53 db-5.2 db5.2 db52 db-5.1 db5.1 db51 db-5.0 db5.0 db50 db-4.8 db4.8 db48 db-4.7 db4.7 db47 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''" >+ AC_MSG_CHECKING([for BerkeleyDB > 4.0]) >+ for d in $bdbpfx; do >+ BDB_INCLUDE_DIR="" >Index: SOURCES/mutt-1.5.23-indexcolor.patch >=================================================================== >--- SOURCES/mutt-1.5.23-indexcolor.patch (revision 0) >+++ SOURCES/mutt-1.5.23-indexcolor.patch (working copy) >@@ -0,0 +1,773 @@ >+diff -uNr mutt-1.5.23.nntp.xterm.sidebar/color.c mutt-1.5.23.nntp.xterm.sidebar.indexcolor/color.c >+--- mutt-1.5.23.nntp.xterm.sidebar/color.c 2014-12-03 02:32:53.217123600 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/color.c 2014-12-03 02:47:07.891519903 +0200 >+@@ -35,6 +35,8 @@ >+ COLOR_LINE *ColorHdrList = NULL; >+ COLOR_LINE *ColorBodyList = NULL; >+ COLOR_LINE *ColorIndexList = NULL; >++COLOR_LINE *ColorIndexSubjectList = NULL; >++COLOR_LINE *ColorIndexAuthorList = NULL; >+ >+ /* local to this file */ >+ static int ColorQuoteSize; >+@@ -93,6 +95,14 @@ >+ { "bold", MT_COLOR_BOLD }, >+ { "underline", MT_COLOR_UNDERLINE }, >+ { "index", MT_COLOR_INDEX }, >++ { "index_subject", MT_COLOR_INDEX_SUBJECT }, >++ { "index_author", MT_COLOR_INDEX_AUTHOR }, >++ { "index_collapsed", MT_COLOR_INDEX_COLLAPSED }, >++ { "index_date", MT_COLOR_INDEX_DATE }, >++ { "index_flags", MT_COLOR_INDEX_FLAGS }, >++ { "index_label", MT_COLOR_INDEX_LABEL }, >++ { "index_number", MT_COLOR_INDEX_NUMBER }, >++ { "index_size", MT_COLOR_INDEX_SIZE }, >+ { "sidebar_new", MT_COLOR_NEW }, >+ { "sidebar_flagged", MT_COLOR_FLAGGED }, >+ { NULL, 0 } >+@@ -366,11 +376,54 @@ >+ return _mutt_parse_uncolor(buf, s, data, err, 0); >+ } >+ >++static void >++mutt_do_uncolor (BUFFER *buf, BUFFER *s, COLOR_LINE **ColorList, >++ int *do_cache, int parse_uncolor) >++{ >++ COLOR_LINE *tmp, *last = NULL; >++ >++ do >++ { >++ mutt_extract_token (buf, s, 0); >++ if (!mutt_strcmp ("*", buf->data)) >++ { >++ for (tmp = *ColorList; tmp; ) >++ { >++ if (!*do_cache) >++ *do_cache = 1; >++ last = tmp; >++ tmp = tmp->next; >++ mutt_free_color_line(&last, parse_uncolor); >++ } >++ *ColorList = NULL; >++ } >++ else >++ { >++ for (last = NULL, tmp = *ColorList; tmp; last = tmp, tmp = tmp->next) >++ { >++ if (!mutt_strcmp (buf->data, tmp->pattern)) >++ { >++ if (!*do_cache) >++ *do_cache = 1; >++ dprint(1,(debugfile,"Freeing pattern \"%s\" from ColorList\n", >++ tmp->pattern)); >++ if (last) >++ last->next = tmp->next; >++ else >++ *ColorList = tmp->next; >++ mutt_free_color_line(&tmp, parse_uncolor); >++ break; >++ } >++ } >++ } >++ } >++ while (MoreArgs (s)); >++} >++ >+ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, >+ BUFFER *err, short parse_uncolor) >+ { >+ int object = 0, do_cache = 0; >+- COLOR_LINE *tmp, *last = NULL; >+ COLOR_LINE **list; >+ >+ mutt_extract_token (buf, s, 0); >+@@ -381,6 +434,13 @@ >+ return (-1); >+ } >+ >++ if (object > MT_COLOR_INDEX_AUTHOR) /* uncolor index column */ >++ { >++ ColorDefs[object] = 0; >++ set_option (OPTFORCEREDRAWINDEX); >++ return (0); >++ } >++ >+ if (mutt_strncmp (buf->data, "index", 5) == 0) >+ list = &ColorIndexList; >+ else if (mutt_strncmp (buf->data, "body", 4) == 0) >+@@ -424,43 +484,13 @@ >+ return 0; >+ } >+ >+- do >+- { >+- mutt_extract_token (buf, s, 0); >+- if (!mutt_strcmp ("*", buf->data)) >+- { >+- for (tmp = *list; tmp; ) >+- { >+- if (!do_cache) >+- do_cache = 1; >+- last = tmp; >+- tmp = tmp->next; >+- mutt_free_color_line(&last, parse_uncolor); >+- } >+- *list = NULL; >+- } >+- else >+- { >+- for (last = NULL, tmp = *list; tmp; last = tmp, tmp = tmp->next) >+- { >+- if (!mutt_strcmp (buf->data, tmp->pattern)) >+- { >+- if (!do_cache) >+- do_cache = 1; >+- dprint(1,(debugfile,"Freeing pattern \"%s\" from color list\n", >+- tmp->pattern)); >+- if (last) >+- last->next = tmp->next; >+- else >+- *list = tmp->next; >+- mutt_free_color_line(&tmp, parse_uncolor); >+- break; >+- } >+- } >+- } >+- } >+- while (MoreArgs (s)); >+ >++ if (object == MT_COLOR_INDEX) >++ mutt_do_uncolor(buf, s, &ColorIndexList, &do_cache, parse_uncolor); >++ if (object == MT_COLOR_INDEX_SUBJECT) >++ mutt_do_uncolor(buf, s, &ColorIndexSubjectList, &do_cache, parse_uncolor); >++ if (object == MT_COLOR_INDEX_AUTHOR) >++ mutt_do_uncolor(buf, s, &ColorIndexAuthorList, &do_cache, parse_uncolor); >+ >+ if (do_cache && !option (OPTNOCURSES)) >+ { >+@@ -700,7 +730,7 @@ >+ >+ /* extract a regular expression if needed */ >+ >+- if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY || object == MT_COLOR_INDEX) >++ if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY || object == MT_COLOR_INDEX || object == MT_COLOR_INDEX_SUBJECT || object == MT_COLOR_INDEX_AUTHOR) >+ { >+ if (!MoreArgs (s)) >+ { >+@@ -744,6 +774,18 @@ >+ r = add_pattern (&ColorIndexList, buf->data, 1, fg, bg, attr, err, 1); >+ set_option (OPTFORCEREDRAWINDEX); >+ } >++ else if (object == MT_COLOR_INDEX_SUBJECT) >++ { >++ r = add_pattern (&ColorIndexSubjectList, buf->data, >++ 1, fg, bg, attr, err, 1); >++ set_option (OPTFORCEREDRAWINDEX); >++ } >++ else if (object == MT_COLOR_INDEX_AUTHOR) >++ { >++ r = add_pattern (&ColorIndexAuthorList, buf->data, >++ 1, fg, bg, attr, err, 1); >++ set_option (OPTFORCEREDRAWINDEX); >++ } >+ else if (object == MT_COLOR_QUOTED) >+ { >+ if (q_level >= ColorQuoteSize) >+@@ -769,7 +811,11 @@ >+ ColorQuote[q_level] = fgbgattr_to_color(fg, bg, attr); >+ } >+ else >++ { >+ ColorDefs[object] = fgbgattr_to_color(fg, bg, attr); >++ if (object > MT_COLOR_INDEX_AUTHOR) >++ set_option (OPTFORCEREDRAWINDEX); >++ } >+ >+ return (r); >+ } >+diff -uNr mutt-1.5.23.nntp.xterm.sidebar/curs_lib.c mutt-1.5.23.nntp.xterm.sidebar.indexcolor/curs_lib.c >+--- mutt-1.5.23.nntp.xterm.sidebar/curs_lib.c 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/curs_lib.c 2014-12-03 02:47:07.891519903 +0200 >+@@ -718,6 +718,7 @@ >+ size_t k, k2; >+ char scratch[MB_LEN_MAX]; >+ mbstate_t mbstate1, mbstate2; >++ int escaped = 0; >+ >+ memset(&mbstate1, 0, sizeof (mbstate1)); >+ memset(&mbstate2, 0, sizeof (mbstate2)); >+@@ -733,7 +734,15 @@ >+ k = (k == (size_t)(-1)) ? 1 : n; >+ wc = replacement_char (); >+ } >+- if (arboreal && wc < M_TREE_MAX) >++ if (escaped) { >++ escaped = 0; >++ w = 0; >++ } >++ else if (arboreal && wc == M_SPECIAL_INDEX) { >++ escaped = 1; >++ w = 0; >++ } >++ else if (arboreal && wc < M_TREE_MAX) >+ w = 1; /* hack */ >+ else >+ { >+diff -uNr mutt-1.5.23.nntp.xterm.sidebar/doc/manual.xml.head mutt-1.5.23.nntp.xterm.sidebar.indexcolor/doc/manual.xml.head >+--- mutt-1.5.23.nntp.xterm.sidebar/doc/manual.xml.head 2014-12-03 02:09:36.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/doc/manual.xml.head 2014-12-03 02:47:07.892519913 +0200 >+@@ -2600,7 +2600,7 @@ >+ >+ <command>color</command> >+ <arg choice="plain"> >+-<option>index</option> >++<option>index-object</option> >+ </arg> >+ <arg choice="plain"> >+ <replaceable class="parameter">foreground</replaceable> >+@@ -2615,7 +2615,7 @@ >+ <command>uncolor</command> >+ <group choice="req"> >+ <arg choice="plain"> >+-<option>index</option> >++<option>index-object</option> >+ </arg> >+ <arg choice="plain"> >+ <option>header</option> >+@@ -2658,6 +2658,14 @@ >+ <listitem><para>bold (highlighting bold patterns in the body of messages)</para></listitem> >+ <listitem><para>error (error messages printed by Mutt)</para></listitem> >+ <listitem><para>hdrdefault (default color of the message header in the pager)</para></listitem> >++<listitem><para>index_author (color of the author name in the index, uses <emphasis>pattern</emphasis>)</para></listitem> >++<listitem><para>index_collapsed (the number of messages in a collapsed thread in the index)</para></listitem> >++<listitem><para>index_date (color of the date field in the index)</para></listitem> >++<listitem><para>index_flags (color of the message flags in the index)</para></listitem> >++<listitem><para>index_label (color of the message label in the index)</para></listitem> >++<listitem><para>index_number (color of the message number in the index)</para></listitem> >++<listitem><para>index_size (color of the message size and line number in the index)</para></listitem> >++<listitem><para>index_subject (color of the subject in the index, uses <emphasis>pattern</emphasis>)</para></listitem> >+ <listitem><para>indicator (arrow or bar used to indicate the current item in a menu)</para></listitem> >+ <listitem><para>markers (the <quote>+</quote> markers at the beginning of wrapped lines in the pager)</para></listitem> >+ <listitem><para>message (informational messages)</para></listitem> >+diff -uNr mutt-1.5.23.nntp.xterm.sidebar/hdrline.c mutt-1.5.23.nntp.xterm.sidebar.indexcolor/hdrline.c >+--- mutt-1.5.23.nntp.xterm.sidebar/hdrline.c 2014-12-03 02:09:36.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/hdrline.c 2014-12-03 02:47:07.892519913 +0200 >+@@ -103,6 +103,34 @@ >+ return 0; >+ } >+ >++/* Takes the color to embed, the buffer to manipulate and the buffer length as >++ * arguments. >++ * Returns the number of chars written. */ >++static size_t add_index_color(char *buf, size_t buflen, >++ format_flag flags, char color) >++{ >++ int len; >++ >++ /* only add color markers if we are operating on main index entries. */ >++ if (!(flags & M_FORMAT_INDEX)) >++ return 0; >++ >++ if (color == MT_COLOR_INDEX) { /* buf might be uninitialized other cases */ >++ len = mutt_strlen(buf); >++ buf += len; >++ buflen -= len; >++ } >++ >++ if (buflen < 2) >++ return 0; >++ >++ buf[0] = M_SPECIAL_INDEX; >++ buf[1] = color; >++ buf[2] = '\0'; >++ >++ return 2; >++} >++ >+ static void make_from (ENVELOPE *hdr, char *buf, size_t len, int do_lists) >+ { >+ int me; >+@@ -256,6 +284,7 @@ >+ #define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 1) >+ #define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 2) >+ size_t len; >++ size_t colorlen; >+ >+ hdr = hfi->hdr; >+ ctx = hfi->ctx; >+@@ -307,12 +336,17 @@ >+ break; >+ >+ case 'c': >++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE); >+ mutt_pretty_size (buf2, sizeof (buf2), (long) hdr->content->length); >+- mutt_format_s (dest, destlen, prefix, buf2); >++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); >++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >+ break; >+ >+ case 'C': >+- snprintf (fmt, sizeof (fmt), "%%%sd", prefix); >++ colorlen = add_index_color(fmt, sizeof(fmt), flags, MT_COLOR_INDEX_NUMBER); >++ snprintf (fmt+colorlen, sizeof(fmt)-colorlen, "%%%sd", prefix); >++ add_index_color(fmt+colorlen, sizeof(fmt)-colorlen, flags, MT_COLOR_INDEX); >++ >+ snprintf (dest, destlen, fmt, hdr->msgno + 1); >+ break; >+ >+@@ -411,7 +445,10 @@ >+ if (do_locales) >+ setlocale (LC_TIME, "C"); >+ >+- mutt_format_s (dest, destlen, prefix, buf2); >++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_DATE); >++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); >++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >++ >+ if (len > 0 && op != 'd' && op != 'D') /* Skip ending op */ >+ src = cp + 1; >+ } >+@@ -441,8 +478,10 @@ >+ case 'F': >+ if (!optional) >+ { >++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); >+ make_from (hdr->env, buf2, sizeof (buf2), 0); >+- mutt_format_s (dest, destlen, prefix, buf2); >++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); >++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >+ } >+ else if (mutt_addr_is_user (hdr->env->from)) >+ optional = 0; >+@@ -474,7 +513,9 @@ >+ if (!optional) >+ { >+ snprintf (fmt, sizeof (fmt), "%%%sd", prefix); >+- snprintf (dest, destlen, fmt, (int) hdr->lines); >++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE); >++ snprintf (dest+colorlen, destlen-colorlen, fmt, (int) hdr->lines); >++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >+ } >+ else if (hdr->lines <= 0) >+ optional = 0; >+@@ -483,8 +524,10 @@ >+ case 'L': >+ if (!optional) >+ { >++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); >+ make_from (hdr->env, buf2, sizeof (buf2), 1); >+- mutt_format_s (dest, destlen, prefix, buf2); >++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); >++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >+ } >+ else if (!check_for_mailing_list (hdr->env->to, NULL, NULL, 0) && >+ !check_for_mailing_list (hdr->env->cc, NULL, NULL, 0)) >+@@ -539,10 +582,16 @@ >+ snprintf (fmt, sizeof (fmt), "%%%sd", prefix); >+ if (!optional) >+ { >+- if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1) >+- snprintf (dest, destlen, fmt, hdr->num_hidden); >+- else if (is_index && threads) >+- mutt_format_s (dest, destlen, prefix, " "); >++ colorlen = add_index_color(dest, destlen, flags, >++ MT_COLOR_INDEX_COLLAPSED); >++ if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1) { >++ snprintf (dest+colorlen, destlen-colorlen, fmt, hdr->num_hidden); >++ add_index_color(dest, destlen-colorlen, flags, MT_COLOR_INDEX); >++ } >++ else if (is_index && threads) { >++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, " "); >++ add_index_color(dest, destlen-colorlen, flags, MT_COLOR_INDEX); >++ } >+ else >+ *dest = '\0'; >+ } >+@@ -572,15 +621,23 @@ >+ { >+ if (flags & M_FORMAT_FORCESUBJ) >+ { >+- mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject)); >++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT); >++ mutt_format_s (dest+colorlen, destlen-colorlen, "", >++ NONULL (hdr->env->subject)); >++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >++ >+ snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest); >+ mutt_format_s_tree (dest, destlen, prefix, buf2); >+ } >+ else >+ mutt_format_s_tree (dest, destlen, prefix, hdr->tree); >+ } >+- else >+- mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject)); >++ else { >++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT); >++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, >++ NONULL (hdr->env->subject)); >++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >++ } >+ break; >+ >+ case 'S': >+@@ -683,7 +740,9 @@ >+ hdr->tagged ? '*' : >+ (hdr->flagged ? '!' : >+ (Tochars && ((i = mutt_user_is_recipient (hdr)) < mutt_strlen (Tochars)) ? Tochars[i] : ' '))); >+- mutt_format_s (dest, destlen, prefix, buf2); >++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_FLAGS); >++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); >++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >+ break; >+ >+ case 'X': >+@@ -703,7 +762,9 @@ >+ if (optional) >+ optional = hdr->env->x_label ? 1 : 0; >+ >+- mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label)); >++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL); >++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label)); >++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >+ break; >+ >+ case 'Y': >+@@ -729,10 +790,12 @@ >+ if (optional) >+ optional = i; >+ >++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL); >+ if (i) >+- mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label)); >++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label)); >+ else >+- mutt_format_s (dest, destlen, prefix, ""); >++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, ""); >++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); >+ >+ break; >+ >+diff -uNr mutt-1.5.23.nntp.xterm.sidebar/menu.c mutt-1.5.23.nntp.xterm.sidebar.indexcolor/menu.c >+--- mutt-1.5.23.nntp.xterm.sidebar/menu.c 2014-12-03 02:32:53.219123620 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/menu.c 2014-12-03 02:50:57.326770229 +0200 >+@@ -30,7 +30,30 @@ >+ >+ char* SearchBuffers[MENU_MAX]; >+ >+-static void print_enriched_string (int attr, unsigned char *s, int do_color) >++static int get_color(int index, int type) { >++ COLOR_LINE *color; >++ HEADER *hdr = Context->hdrs[index]; >++ >++ switch (type) { >++ case MT_COLOR_INDEX_SUBJECT: >++ color = ColorIndexSubjectList; >++ break; >++ case MT_COLOR_INDEX_AUTHOR: >++ color = ColorIndexAuthorList; >++ break; >++ default: >++ return ColorDefs[type]; >++ } >++ >++ for (; color; color = color->next) >++ if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS, >++ Context, hdr)) >++ return color->pair; >++ >++ return 0; >++} >++ >++static void print_enriched_string (int index, int attr, unsigned char *s, int do_color) >+ { >+ wchar_t wc; >+ size_t k; >+@@ -162,6 +185,18 @@ >+ } >+ if (do_color) ATTRSET(attr); >+ } >++ else if(*s == M_SPECIAL_INDEX) >++ { >++ s++; >++ if (do_color) { >++ if (*s == MT_COLOR_INDEX) >++ attrset(attr); >++ else >++ attron(get_color(index, *s)); >++ } >++ s++; >++ n -= 2; >++ } >+ else if ((k = mbrtowc (&wc, (char *)s, n, &mbstate)) > 0) >+ { >+ addnstr ((char *)s, k); >+@@ -172,9 +207,9 @@ >+ } >+ } >+ >+-static void menu_make_entry (char *s, int l, MUTTMENU *menu, int i) >++static void menu_make_entry (char *s, int l, MUTTMENU *menu, int i) >+ { >+- if (menu->dialog) >++ if (menu->dialog) >+ { >+ strncpy (s, menu->dialog[i], l); >+ menu->current = -1; /* hide menubar */ >+@@ -269,7 +304,7 @@ >+ else if (option(OPTARROWCURSOR)) >+ addstr(" "); >+ >+- print_enriched_string (attr, (unsigned char *) buf, do_color); >++ print_enriched_string (i, attr, (unsigned char *) buf, do_color); >+ } >+ else >+ { >+@@ -285,12 +320,12 @@ >+ { >+ char buf[LONG_STRING]; >+ >+- if (menu->dialog) >++ if (menu->dialog) >+ { >+ menu->redraw &= ~REDRAW_MOTION; >+ return; >+ } >+- >++ >+ move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth); >+ ATTRSET(menu->color (menu->oldcurrent)); >+ >+@@ -304,7 +339,7 @@ >+ menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); >+ menu_pad_string (buf, sizeof (buf)); >+ move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3); >+- print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); >++ print_enriched_string (menu->oldcurrent, menu->color(menu->oldcurrent), (unsigned char *) buf, 1); >+ } >+ >+ /* now draw it in the new location */ >+@@ -316,14 +351,14 @@ >+ /* erase the current indicator */ >+ menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); >+ menu_pad_string (buf, sizeof (buf)); >+- print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); >++ print_enriched_string (menu->oldcurrent, menu->color(menu->oldcurrent), (unsigned char *) buf, 1); >+ >+ /* now draw the new one to reflect the change */ >+ menu_make_entry (buf, sizeof (buf), menu, menu->current); >+ menu_pad_string (buf, sizeof (buf)); >+ SETCOLOR(MT_COLOR_INDICATOR); >+ move(menu->current - menu->top + menu->offset, SidebarWidth); >+- print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); >++ print_enriched_string (menu->current, menu->color(menu->current), (unsigned char *) buf, 0); >+ } >+ menu->redraw &= REDRAW_STATUS; >+ NORMAL_COLOR; >+@@ -333,7 +368,7 @@ >+ { >+ char buf[LONG_STRING]; >+ int attr = menu->color (menu->current); >+- >++ >+ move (menu->current + menu->offset - menu->top, SidebarWidth); >+ menu_make_entry (buf, sizeof (buf), menu, menu->current); >+ menu_pad_string (buf, sizeof (buf)); >+@@ -345,19 +380,19 @@ >+ ATTRSET(attr); >+ addch (' '); >+ menu_pad_string (buf, sizeof (buf)); >+- print_enriched_string (attr, (unsigned char *) buf, 1); >++ print_enriched_string (menu->current, attr, (unsigned char *) buf, 1); >+ } >+ else >+- print_enriched_string (attr, (unsigned char *) buf, 0); >++ print_enriched_string (menu->current, attr, (unsigned char *) buf, 0); >+ menu->redraw &= REDRAW_STATUS; >+ NORMAL_COLOR; >+ } >+ >+ static void menu_redraw_prompt (MUTTMENU *menu) >+ { >+- if (menu->dialog) >++ if (menu->dialog) >+ { >+- if (option (OPTMSGERR)) >++ if (option (OPTMSGERR)) >+ { >+ mutt_sleep (1); >+ unset_option (OPTMSGERR); >+@@ -378,13 +413,13 @@ >+ >+ if (!option (OPTMENUMOVEOFF) && menu->max <= menu->pagelen) /* less entries than lines */ >+ { >+- if (menu->top != 0) >++ if (menu->top != 0) >+ { >+ menu->top = 0; >+ set_option (OPTNEEDREDRAW); >+ } >+ } >+- else >++ else >+ { >+ if (option (OPTMENUSCROLL) || (menu->pagelen <= 0) || (c < MenuContext)) >+ { >+@@ -398,7 +433,7 @@ >+ if (menu->current < menu->top + c) >+ menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) / (menu->pagelen - c)) - c; >+ else if ((menu->current >= menu->top + menu->pagelen - c)) >+- menu->top += (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c; >++ menu->top += (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c; >+ } >+ } >+ >+@@ -471,7 +506,7 @@ >+ mutt_error _("You cannot scroll up farther."); >+ } >+ >+-/* >++/* >+ * pageup: jumplen == -pagelen >+ * pagedown: jumplen == pagelen >+ * halfup: jumplen == -pagelen/2 >+@@ -781,18 +816,18 @@ >+ { >+ switch (i) >+ { >+- case OP_NEXT_ENTRY: >++ case OP_NEXT_ENTRY: >+ return OP_NEXT_LINE; >+- case OP_PREV_ENTRY: >++ case OP_PREV_ENTRY: >+ return OP_PREV_LINE; >+- case OP_CURRENT_TOP: case OP_FIRST_ENTRY: >++ case OP_CURRENT_TOP: case OP_FIRST_ENTRY: >+ return OP_TOP_PAGE; >+- case OP_CURRENT_BOTTOM: case OP_LAST_ENTRY: >++ case OP_CURRENT_BOTTOM: case OP_LAST_ENTRY: >+ return OP_BOTTOM_PAGE; >+- case OP_CURRENT_MIDDLE: >+- return OP_MIDDLE_PAGE; >++ case OP_CURRENT_MIDDLE: >++ return OP_MIDDLE_PAGE; >+ } >+- >++ >+ return i; >+ } >+ >+@@ -830,10 +865,10 @@ >+ /* allow the caller to do any local configuration */ >+ return (OP_REDRAW); >+ } >+- >++ >+ if (!menu->dialog) >+ menu_check_recenter (menu); >+- >++ >+ if (menu->redraw & REDRAW_STATUS) >+ menu_redraw_status (menu); >+ if (menu->redraw & REDRAW_INDEX) >+@@ -842,10 +877,10 @@ >+ menu_redraw_motion (menu); >+ else if (menu->redraw == REDRAW_CURRENT) >+ menu_redraw_current (menu); >+- >++ >+ if (menu->dialog) >+ menu_redraw_prompt (menu); >+- >++ >+ return OP_NULL; >+ } >+ >+@@ -860,19 +895,19 @@ >+ unset_option (OPTMENUCALLER); >+ return OP_NULL; >+ } >+- >+- >++ >++ >+ mutt_curs_set (0); >+ >+ if (menu_redraw (menu) == OP_REDRAW) >+ return OP_REDRAW; >+- >++ >+ menu->oldcurrent = menu->current; >+ >+ >+ /* move the cursor out of the way */ >+- >+- >++ >++ >+ if (option (OPTARROWCURSOR)) >+ move (menu->current - menu->top + menu->offset, SidebarWidth + 2); >+ else if (option (OPTBRAILLEFRIENDLY)) >+@@ -881,11 +916,11 @@ >+ move (menu->current - menu->top + menu->offset, COLS - 1); >+ >+ mutt_refresh (); >+- >++ >+ /* try to catch dialog keys before ops */ >+ if (menu->dialog && menu_dialog_dokey (menu, &i) == 0) >+ return i; >+- >++ >+ i = km_dokey (menu->menu); >+ if (i == OP_TAG_PREFIX || i == OP_TAG_PREFIX_COND) >+ { >+@@ -938,7 +973,7 @@ >+ mutt_clear_error (); >+ >+ /* Convert menubar movement to scrolling */ >+- if (menu->dialog) >++ if (menu->dialog) >+ i = menu_dialog_translate_op (i); >+ >+ switch (i) >+diff -uNr mutt-1.5.23.nntp.xterm.sidebar/mutt_curses.h mutt-1.5.23.nntp.xterm.sidebar.indexcolor/mutt_curses.h >+--- mutt-1.5.23.nntp.xterm.sidebar/mutt_curses.h 2014-12-03 02:32:53.219123620 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/mutt_curses.h 2014-12-03 02:47:07.893519923 +0200 >+@@ -123,6 +123,16 @@ >+ MT_COLOR_INDEX, >+ MT_COLOR_NEW, >+ MT_COLOR_FLAGGED, >++ /* please no non-MT_COLOR_INDEX objects after this point */ >++ MT_COLOR_INDEX_SUBJECT, >++ MT_COLOR_INDEX_AUTHOR, >++ /* below only index coloring stuff that doesn't have a colorline! */ >++ MT_COLOR_INDEX_COLLAPSED, >++ MT_COLOR_INDEX_DATE, >++ MT_COLOR_INDEX_FLAGS, >++ MT_COLOR_INDEX_LABEL, >++ MT_COLOR_INDEX_NUMBER, >++ MT_COLOR_INDEX_SIZE, >+ MT_COLOR_MAX >+ }; >+ >+@@ -176,6 +186,8 @@ >+ extern COLOR_LINE *ColorHdrList; >+ extern COLOR_LINE *ColorBodyList; >+ extern COLOR_LINE *ColorIndexList; >++extern COLOR_LINE *ColorIndexSubjectList; >++extern COLOR_LINE *ColorIndexAuthorList; >+ >+ void ci_init_color (void); >+ void ci_start_color (void); >+diff -uNr mutt-1.5.23.nntp.xterm.sidebar/mutt.h mutt-1.5.23.nntp.xterm.sidebar.indexcolor/mutt.h >+--- mutt-1.5.23.nntp.xterm.sidebar/mutt.h 2014-12-03 02:32:53.219123620 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/mutt.h 2014-12-03 02:47:07.893519923 +0200 >+@@ -161,6 +161,8 @@ >+ #define M_TREE_MISSING 13 >+ #define M_TREE_MAX 14 >+ >++#define M_SPECIAL_INDEX M_TREE_MAX >++ >+ #define M_THREAD_COLLAPSE (1<<0) >+ #define M_THREAD_UNCOLLAPSE (1<<1) >+ #define M_THREAD_GET_HIDDEN (1<<2) >Index: SOURCES/mutt-1.5.23-no-sgid.patch >=================================================================== >--- SOURCES/mutt-1.5.23-no-sgid.patch (revision 0) >+++ SOURCES/mutt-1.5.23-no-sgid.patch (working copy) >@@ -0,0 +1,14 @@ >+--- Makefile.am 2014-03-12 18:03:44.000000000 +0200 >++++ Makefile.am.sgid 2014-12-03 01:20:47.748124116 +0200 >+@@ -154,11 +154,6 @@ >+ rm -f $(DESTDIR)$(bindir)/mutt.dotlock ; \ >+ ln -sf $(DESTDIR)$(bindir)/mutt_dotlock $(DESTDIR)$(bindir)/mutt.dotlock ; \ >+ fi >+- if test -f $(DESTDIR)$(bindir)/mutt_dotlock && test x@DOTLOCK_GROUP@ != x ; then \ >+- chgrp @DOTLOCK_GROUP@ $(DESTDIR)$(bindir)/mutt_dotlock && \ >+- chmod @DOTLOCK_PERMISSION@ $(DESTDIR)$(bindir)/mutt_dotlock || \ >+- { echo "Can't fix mutt_dotlock's permissions! This is required to lock mailboxes in the mail spool directory." >&2 ; exit 1 ; } \ >+- fi >+ >+ install-data-local: >+ $(srcdir)/mkinstalldirs $(DESTDIR)$(sysconfdir) >Index: SOURCES/mutt-1.5.23-sidebar.patch >=================================================================== >--- SOURCES/mutt-1.5.23-sidebar.patch (revision 0) >+++ SOURCES/mutt-1.5.23-sidebar.patch (working copy) >@@ -0,0 +1,1697 @@ >+diff -uNr mutt-1.5.23.nntp.xterm/buffy.c mutt-1.5.23.nntp.xterm.sidebar/buffy.c >+--- mutt-1.5.23.nntp.xterm/buffy.c 2014-12-03 02:09:36.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/buffy.c 2014-12-03 02:32:53.217123600 +0200 >+@@ -161,6 +161,49 @@ >+ } >+ } >+ >++static int buffy_compare_name(const void *a, const void *b) { >++ const BUFFY *b1 = * (BUFFY * const *) a; >++ const BUFFY *b2 = * (BUFFY * const *) b; >++ >++ return mutt_strcoll(b1->path, b2->path); >++} >++ >++static BUFFY *buffy_sort(BUFFY *b) >++{ >++ BUFFY *tmp = b; >++ int buffycount = 0; >++ BUFFY **ary; >++ int i; >++ >++ if (!option(OPTSIDEBARSORT)) >++ return b; >++ >++ for (; tmp != NULL; tmp = tmp->next) >++ buffycount++; >++ >++ ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary)); >++ >++ tmp = b; >++ for (i = 0; tmp != NULL; tmp = tmp->next, i++) { >++ ary[i] = tmp; >++ } >++ >++ qsort(ary, buffycount, sizeof(*ary), buffy_compare_name); >++ >++ for (i = 0; i < buffycount - 1; i++) { >++ ary[i]->next = ary[i+1]; >++ } >++ ary[buffycount - 1]->next = NULL; >++ for (i = 1; i < buffycount; i++) { >++ ary[i]->prev = ary[i-1]; >++ } >++ ary[0]->prev = NULL; >++ >++ tmp = ary[0]; >++ free(ary); >++ return tmp; >++} >++ >+ BUFFY *mutt_find_mailbox (const char *path) >+ { >+ BUFFY *tmp = NULL; >+@@ -282,6 +325,7 @@ >+ else >+ (*tmp)->size = 0; >+ } >++ Incoming = buffy_sort(Incoming); >+ return 0; >+ } >+ >+@@ -340,6 +384,68 @@ >+ return rc; >+ } >+ >++/* update message counts for the sidebar */ >++void buffy_maildir_update (BUFFY* mailbox) >++{ >++ char path[_POSIX_PATH_MAX]; >++ DIR *dirp; >++ struct dirent *de; >++ char *p; >++ >++ mailbox->msgcount = 0; >++ mailbox->msg_unread = 0; >++ mailbox->msg_flagged = 0; >++ >++ snprintf (path, sizeof (path), "%s/new", mailbox->path); >++ >++ if ((dirp = opendir (path)) == NULL) >++ { >++ mailbox->magic = 0; >++ return; >++ } >++ >++ while ((de = readdir (dirp)) != NULL) >++ { >++ if (*de->d_name == '.') >++ continue; >++ >++ if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) { >++ mailbox->new = 1; >++ mailbox->msgcount++; >++ mailbox->msg_unread++; >++ } >++ } >++ >++ closedir (dirp); >++ snprintf (path, sizeof (path), "%s/cur", mailbox->path); >++ >++ if ((dirp = opendir (path)) == NULL) >++ { >++ mailbox->magic = 0; >++ return; >++ } >++ >++ while ((de = readdir (dirp)) != NULL) >++ { >++ if (*de->d_name == '.') >++ continue; >++ >++ if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) { >++ mailbox->msgcount++; >++ if ((p = strstr (de->d_name, ":2,"))) { >++ if (!strchr (p + 3, 'T')) { >++ if (!strchr (p + 3, 'S')) >++ mailbox->msg_unread++; >++ if (strchr(p + 3, 'F')) >++ mailbox->msg_flagged++; >++ } >++ } >++ } >++ } >++ >++ closedir (dirp); >++} >++ >+ /* returns 1 if mailbox has new mail */ >+ static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb) >+ { >+@@ -371,6 +477,20 @@ >+ return rc; >+ } >+ >++/* update message counts for the sidebar */ >++void buffy_mbox_update (BUFFY* mailbox) >++{ >++ CONTEXT *ctx = NULL; >++ >++ ctx = mx_open_mailbox(mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL); >++ if(ctx) >++ { >++ mailbox->msgcount = ctx->msgcount; >++ mailbox->msg_unread = ctx->unread; >++ mx_close_mailbox(ctx, 0); >++ } >++} >++ >+ int mutt_buffy_check (int force) >+ { >+ BUFFY *tmp; >+@@ -456,16 +576,19 @@ >+ { >+ case M_MBOX: >+ case M_MMDF: >++ buffy_mbox_update (tmp); >+ if (buffy_mbox_hasnew (tmp, &sb) > 0) >+ BuffyCount++; >+ break; >+ >+ case M_MAILDIR: >++ buffy_maildir_update (tmp); >+ if (buffy_maildir_hasnew (tmp) > 0) >+ BuffyCount++; >+ break; >+ >+ case M_MH: >++ mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged); >+ mh_buffy(tmp); >+ if (tmp->new) >+ BuffyCount++; >+diff -uNr mutt-1.5.23.nntp.xterm/buffy.h mutt-1.5.23.nntp.xterm.sidebar/buffy.h >+--- mutt-1.5.23.nntp.xterm/buffy.h 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/buffy.h 2014-12-03 02:32:53.217123600 +0200 >+@@ -25,7 +25,11 @@ >+ char path[_POSIX_PATH_MAX]; >+ off_t size; >+ struct buffy_t *next; >++ struct buffy_t *prev; >+ short new; /* mailbox has new mail */ >++ int msgcount; /* total number of messages */ >++ int msg_unread; /* number of unread messages */ >++ int msg_flagged; /* number of flagged messages */ >+ short notified; /* user has been notified */ >+ short magic; /* mailbox type */ >+ short newly_created; /* mbox or mmdf just popped into existence */ >+diff -uNr mutt-1.5.23.nntp.xterm/color.c mutt-1.5.23.nntp.xterm.sidebar/color.c >+--- mutt-1.5.23.nntp.xterm/color.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/color.c 2014-12-03 02:32:53.217123600 +0200 >+@@ -93,6 +93,8 @@ >+ { "bold", MT_COLOR_BOLD }, >+ { "underline", MT_COLOR_UNDERLINE }, >+ { "index", MT_COLOR_INDEX }, >++ { "sidebar_new", MT_COLOR_NEW }, >++ { "sidebar_flagged", MT_COLOR_FLAGGED }, >+ { NULL, 0 } >+ }; >+ >+diff -uNr mutt-1.5.23.nntp.xterm/compose.c mutt-1.5.23.nntp.xterm.sidebar/compose.c >+--- mutt-1.5.23.nntp.xterm/compose.c 2014-12-03 02:09:36.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/compose.c 2014-12-03 02:38:03.539176666 +0200 >+@@ -1,21 +1,21 @@ >+ /* >+ * Copyright (C) 1996-2000,2002,2007 Michael R. Elkins <me@mutt.org> >+ * Copyright (C) 2004 g10 Code GmbH >+- * >++ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation; either version 2 of the License, or >+ * (at your option) any later version. >+- * >++ * >+ * This program is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+ * GNU General Public License for more details. >+- * >++ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. >+- */ >++ */ >+ >+ #if HAVE_CONFIG_H >+ # include "config.h" >+@@ -83,7 +83,7 @@ >+ >+ #define HDR_XOFFSET 14 >+ #define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */ >+-#define W (COLS - HDR_XOFFSET) >++#define W (COLS - HDR_XOFFSET - SidebarWidth) >+ >+ static const char * const Prompts[] = >+ { >+@@ -144,7 +144,7 @@ >+ >+ static void redraw_crypt_lines (HEADER *msg) >+ { >+- mvprintw (HDR_CRYPT, 0, TITLE_FMT, "Security: "); >++ mvprintw (HDR_CRYPT, SidebarWidth, TITLE_FMT, "Security: "); >+ >+ if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0) >+ { >+@@ -176,7 +176,7 @@ >+ } >+ >+ clrtoeol (); >+- move (HDR_CRYPTINFO, 0); >++ move (HDR_CRYPTINFO, SidebarWidth); >+ clrtoeol (); >+ >+ if ((WithCrypto & APPLICATION_PGP) >+@@ -194,7 +194,7 @@ >+ && (msg->security & ENCRYPT) >+ && SmimeCryptAlg >+ && *SmimeCryptAlg) { >+- mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "), >++ mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "), >+ NONULL(SmimeCryptAlg)); >+ } >+ } >+@@ -207,7 +207,7 @@ >+ int c; >+ char *t; >+ >+- mvprintw (HDR_MIX, 0, TITLE_FMT, "Mix: "); >++ mvprintw (HDR_MIX, SidebarWidth, TITLE_FMT, "Mix: "); >+ >+ if (!chain) >+ { >+@@ -215,14 +215,14 @@ >+ clrtoeol (); >+ return; >+ } >+- >++ >+ for (c = 12; chain; chain = chain->next) >+ { >+ t = chain->data; >+ if (t && t[0] == '0' && t[1] == '\0') >+ t = "<random>"; >+- >+- if (c + mutt_strlen (t) + 2 >= COLS) >++ >++ if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth) >+ break; >+ >+ addstr (NONULL(t)); >+@@ -251,13 +251,13 @@ >+ pretty, i+1); >+ return -1; >+ } >+- >++ >+ if(idx[i]->content->stamp < st.st_mtime) >+ { >+ mutt_pretty_mailbox(pretty, sizeof (pretty)); >+ snprintf(msg, sizeof(msg), _("%s [#%d] modified. Update encoding?"), >+ pretty, i+1); >+- >++ >+ if((r = mutt_yesorno(msg, M_YES)) == M_YES) >+ mutt_update_encoding(idx[i]->content); >+ else if(r == -1) >+@@ -274,7 +274,7 @@ >+ >+ buf[0] = 0; >+ rfc822_write_address (buf, sizeof (buf), addr, 1); >+- mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]); >++ mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]); >+ mutt_paddstr (W, buf); >+ } >+ >+@@ -292,9 +292,9 @@ >+ } >+ else >+ { >+- mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]); >++ mvprintw (HDR_TO, SidebarWidth, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]); >+ mutt_paddstr (W, NONULL (msg->env->newsgroups)); >+- mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]); >++ mvprintw (HDR_CC, SidebarWidth, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]); >+ mutt_paddstr (W, NONULL (msg->env->followup_to)); >+ if (option (OPTXCOMMENTTO)) >+ { >+@@ -317,7 +317,7 @@ >+ #endif >+ >+ SETCOLOR (MT_COLOR_STATUS); >+- mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments")); >++ mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments")); >+ clrtoeol (); >+ >+ NORMAL_COLOR; >+@@ -327,7 +327,7 @@ >+ { >+ char buf[HUGE_STRING] = ""; /* needs to be large for alias expansion */ >+ char *err = NULL; >+- >++ >+ mutt_addrlist_to_local (*addr); >+ rfc822_write_address (buf, sizeof (buf), *addr, 0); >+ if (mutt_get_field (Prompts[line - 1], buf, sizeof (buf), M_ALIAS) == 0) >+@@ -353,9 +353,9 @@ >+ /* redraw the expanded list so the user can see the result */ >+ buf[0] = 0; >+ rfc822_write_address (buf, sizeof (buf), *addr, 1); >+- move (line, HDR_XOFFSET); >++ move (line, HDR_XOFFSET+SidebarWidth); >+ mutt_paddstr (W, buf); >+- >++ >+ return 0; >+ } >+ >+@@ -390,7 +390,7 @@ >+ for (; x < *idxlen - 1; x++) >+ idx[x] = idx[x+1]; >+ menu->max = --(*idxlen); >+- >++ >+ return (0); >+ } >+ >+@@ -407,13 +407,13 @@ >+ } >+ >+ >+-/* >++/* >+ * cum_attachs_size: Cumulative Attachments Size >+ * >+ * Returns the total number of bytes used by the attachments in the >+ * attachment list _after_ content-transfer-encodings have been >+ * applied. >+- * >++ * >+ */ >+ >+ static unsigned long cum_attachs_size (MUTTMENU *menu) >+@@ -423,7 +423,7 @@ >+ ATTACHPTR **idx = menu->data; >+ CONTENT *info; >+ BODY *b; >+- >++ >+ for (i = 0, s = 0; i < menu->max; i++) >+ { >+ b = idx[i]->content; >+@@ -452,16 +452,16 @@ >+ } >+ >+ /* prototype for use below */ >+-static void compose_status_line (char *buf, size_t buflen, size_t col, MUTTMENU *menu, >++static void compose_status_line (char *buf, size_t buflen, size_t col, MUTTMENU *menu, >+ const char *p); >+ >+ /* >+ * compose_format_str() >+ * >+- * %a = total number of attachments >++ * %a = total number of attachments >+ * %h = hostname [option] >+- * %l = approx. length of current message (in bytes) >+- * %v = Mutt version >++ * %l = approx. length of current message (in bytes) >++ * %v = Mutt version >+ * >+ * This function is similar to status_format_str(). Look at that function for >+ * help when modifying this function. >+@@ -518,10 +518,10 @@ >+ return (src); >+ } >+ >+-static void compose_status_line (char *buf, size_t buflen, size_t col, MUTTMENU *menu, >++static void compose_status_line (char *buf, size_t buflen, size_t col, MUTTMENU *menu, >+ const char *p) >+ { >+- mutt_FormatString (buf, buflen, col, p, compose_format_str, >++ mutt_FormatString (buf, buflen, col, p, compose_format_str, >+ (unsigned long) menu, 0); >+ } >+ >+@@ -575,7 +575,7 @@ >+ else >+ #endif >+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp); >+- >++ >+ while (loop) >+ { >+ #ifdef USE_NNTP >+@@ -614,7 +614,7 @@ >+ break; >+ #endif >+ menu->redraw = edit_address_list (HDR_CC, &msg->env->cc); >+- mutt_message_hook (NULL, msg, M_SEND2HOOK); >++ mutt_message_hook (NULL, msg, M_SEND2HOOK); >+ break; >+ #ifdef USE_NNTP >+ case OP_COMPOSE_EDIT_NEWSGROUPS: >+@@ -685,7 +685,7 @@ >+ if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) >+ { >+ mutt_str_replace (&msg->env->subject, buf); >+- move (HDR_SUBJECT, HDR_XOFFSET); >++ move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth); >+ if (msg->env->subject) >+ mutt_paddstr (W, msg->env->subject); >+ else >+@@ -703,7 +703,7 @@ >+ { >+ strfcpy (fcc, buf, fcclen); >+ mutt_pretty_mailbox (fcc, fcclen); >+- move (HDR_FCC, HDR_XOFFSET); >++ move (HDR_FCC, HDR_XOFFSET + SidebarWidth); >+ mutt_paddstr (W, fcc); >+ fccSet = 1; >+ } >+@@ -764,13 +764,13 @@ >+ >+ case OP_COMPOSE_ATTACH_KEY: >+ if (!(WithCrypto & APPLICATION_PGP)) >+- break; >++ break; >+ if (idxlen == idxmax) >+ { >+ safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5)); >+ menu->data = idx; >+ } >+- >++ >+ idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR)); >+ if ((idx[idxlen]->content = crypt_pgp_make_key_attachment(NULL)) != NULL) >+ { >+@@ -787,7 +787,7 @@ >+ menu->redraw = REDRAW_FULL; >+ unset_option(OPTNEEDREDRAW); >+ } >+- >++ >+ mutt_message_hook (NULL, msg, M_SEND2HOOK); >+ break; >+ >+@@ -830,7 +830,7 @@ >+ FREE (&idx[idxlen]); >+ } >+ } >+- >++ >+ FREE (&files); >+ if (!error) mutt_clear_error (); >+ >+@@ -915,7 +915,7 @@ >+ >+ this = Context; /* remember current folder and sort methods*/ >+ oldSort = Sort; oldSortAux = SortAux; >+- >++ >+ Context = ctx; >+ set_option(OPTATTACHMSG); >+ mutt_message _("Tag the messages you want to attach!"); >+@@ -957,7 +957,7 @@ >+ } >+ menu->redraw |= REDRAW_FULL; >+ >+- if (close == OP_QUIT) >++ if (close == OP_QUIT) >+ mx_close_mailbox (Context, NULL); >+ else >+ mx_fastclose_mailbox (Context); >+@@ -995,9 +995,9 @@ >+ break; >+ >+ #define CURRENT idx[menu->current]->content >+- >++ >+ case OP_COMPOSE_TOGGLE_RECODE: >+- { >++ { >+ CHECK_COUNT; >+ if (!mutt_is_text_part (CURRENT)) >+ { >+@@ -1049,7 +1049,7 @@ >+ } >+ mutt_message_hook (NULL, msg, M_SEND2HOOK); >+ break; >+- >++ >+ case OP_COMPOSE_TOGGLE_DISPOSITION: >+ /* toggle the content-disposition between inline/attachment */ >+ idx[menu->current]->content->disposition = (idx[menu->current]->content->disposition == DISPINLINE) ? DISPATTACH : DISPINLINE; >+@@ -1093,19 +1093,19 @@ >+ /* Note: We don't invoke send2-hook here, since we want to leave >+ * users an opportunity to change settings from the ":" prompt. >+ */ >+- >++ >+ if(check_attachments(idx, idxlen) != 0) >+ { >+ menu->redraw = REDRAW_FULL; >+ break; >+ } >+ >+- >++ >+ #ifdef MIXMASTER >+ if (msg->chain && mix_check_message (msg) != 0) >+ break; >+ #endif >+- >++ >+ if (!fccSet && *fcc) >+ { >+ if ((i = query_quadoption (OPT_COPY, >+@@ -1160,7 +1160,7 @@ >+ >+ /* No send2hook since this doesn't change the message. */ >+ break; >+- >++ >+ case OP_COMPOSE_RENAME_FILE: >+ CHECK_COUNT; >+ strfcpy (fname, idx[menu->current]->content->filename, sizeof (fname)); >+@@ -1177,13 +1177,13 @@ >+ mutt_expand_path (fname, sizeof (fname)); >+ if(mutt_rename_file (idx[menu->current]->content->filename, fname)) >+ break; >+- >++ >+ mutt_str_replace (&idx[menu->current]->content->filename, fname); >+ menu->redraw = REDRAW_CURRENT; >+ >+ if(idx[menu->current]->content->stamp >= st.st_mtime) >+ mutt_stamp_attachment(idx[menu->current]->content); >+- >++ >+ } >+ mutt_message_hook (NULL, msg, M_SEND2HOOK); >+ break; >+@@ -1204,7 +1204,7 @@ >+ >+ /* Call to lookup_mime_type () ? maybe later */ >+ type[0] = 0; >+- if (mutt_get_field ("Content-Type: ", type, sizeof (type), 0) != 0 >++ if (mutt_get_field ("Content-Type: ", type, sizeof (type), 0) != 0 >+ || !type[0]) >+ continue; >+ >+@@ -1253,7 +1253,7 @@ >+ menu->redraw = REDRAW_FULL; >+ } >+ } >+- mutt_message_hook (NULL, msg, M_SEND2HOOK); >++ mutt_message_hook (NULL, msg, M_SEND2HOOK); >+ break; >+ >+ case OP_COMPOSE_EDIT_MIME: >+@@ -1330,7 +1330,7 @@ >+ menu->redraw = REDRAW_FULL; >+ break; >+ } >+- >++ >+ loop = 0; >+ r = 1; >+ break; >+@@ -1423,7 +1423,7 @@ >+ >+ #ifdef MIXMASTER >+ case OP_COMPOSE_MIX: >+- >++ >+ mix_make_chain (&msg->chain, &menu->redraw); >+ mutt_message_hook (NULL, msg, M_SEND2HOOK); >+ break; >+@@ -1432,7 +1432,7 @@ >+ } >+ >+ /* Draw formatted compose status line */ >+- if (menu->redraw & REDRAW_STATUS) >++ if (menu->redraw & REDRAW_STATUS) >+ { >+ compose_status_line (buf, sizeof (buf), 0, menu, NONULL(ComposeFormat)); >+ move(option (OPTSTATUSONTOP) ? 0 : LINES-2, 0); >+@@ -1461,4 +1461,3 @@ >+ >+ return (r); >+ } >+- >+diff -uNr mutt-1.5.23.nntp.xterm/curs_main.c mutt-1.5.23.nntp.xterm.sidebar/curs_main.c >+--- mutt-1.5.23.nntp.xterm/curs_main.c 2014-12-03 02:10:11.933685529 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/curs_main.c 2014-12-03 02:32:53.218123610 +0200 >+@@ -27,7 +27,9 @@ >+ #include "mailbox.h" >+ #include "mapping.h" >+ #include "sort.h" >++#include "buffy.h" >+ #include "mx.h" >++#include "sidebar.h" >+ >+ #ifdef USE_POP >+ #include "pop.h" >+@@ -556,8 +558,12 @@ >+ menu->redraw |= REDRAW_STATUS; >+ if (do_buffy_notify) >+ { >+- if (mutt_buffy_notify () && option (OPTBEEPNEW)) >+- beep (); >++ if (mutt_buffy_notify ()) >++ { >++ menu->redraw |= REDRAW_FULL; >++ if (option (OPTBEEPNEW)) >++ beep (); >++ } >+ } >+ else >+ do_buffy_notify = 1; >+@@ -569,6 +575,7 @@ >+ if (menu->redraw & REDRAW_FULL) >+ { >+ menu_redraw_full (menu); >++ draw_sidebar(menu->menu); >+ mutt_show_error (); >+ } >+ >+@@ -591,9 +598,12 @@ >+ >+ if (menu->redraw & REDRAW_STATUS) >+ { >++ DrawFullLine = 1; >+ menu_status_line (buf, sizeof (buf), menu, NONULL (Status)); >++ DrawFullLine = 0; >+ move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0); >+ SETCOLOR (MT_COLOR_STATUS); >++ set_buffystats(Context); >+ mutt_paddstr (COLS, buf); >+ NORMAL_COLOR; >+ menu->redraw &= ~REDRAW_STATUS; >+@@ -613,7 +623,7 @@ >+ menu->oldcurrent = -1; >+ >+ if (option (OPTARROWCURSOR)) >+- move (menu->current - menu->top + menu->offset, 2); >++ move (menu->current - menu->top + menu->offset, SidebarWidth + 2); >+ else if (option (OPTBRAILLEFRIENDLY)) >+ move (menu->current - menu->top + menu->offset, 0); >+ else >+@@ -1294,6 +1304,7 @@ >+ menu->redraw = REDRAW_FULL; >+ break; >+ >++ case OP_SIDEBAR_OPEN: >+ case OP_MAIN_CHANGE_FOLDER: >+ case OP_MAIN_NEXT_UNREAD_MAILBOX: >+ case OP_MAIN_CHANGE_FOLDER_READONLY: >+@@ -1348,7 +1359,11 @@ >+ #endif >+ mutt_buffy (buf, sizeof (buf)); >+ >+- if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) >++ if ( op == OP_SIDEBAR_OPEN ) { >++ if(!CurBuffy) >++ break; >++ strncpy( buf, CurBuffy->path, sizeof(buf) ); >++ } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) >+ { >+ if (menu->menu == MENU_PAGER) >+ { >+@@ -1374,6 +1389,7 @@ >+ else >+ #endif >+ mutt_expand_path (buf, sizeof (buf)); >++ set_curbuffy(buf); >+ if (mx_get_magic (buf) <= 0) >+ { >+ mutt_error (_("%s is not a mailbox."), buf); >+@@ -2515,6 +2531,12 @@ >+ mutt_what_key(); >+ break; >+ >++ case OP_SIDEBAR_SCROLL_UP: >++ case OP_SIDEBAR_SCROLL_DOWN: >++ case OP_SIDEBAR_NEXT: >++ case OP_SIDEBAR_PREV: >++ scroll_sidebar(op, menu->menu); >++ break; >+ default: >+ if (menu->menu == MENU_MAIN) >+ km_error_key (MENU_MAIN); >+diff -uNr mutt-1.5.23.nntp.xterm/flags.c mutt-1.5.23.nntp.xterm.sidebar/flags.c >+--- mutt-1.5.23.nntp.xterm/flags.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/flags.c 2014-12-03 02:32:53.218123610 +0200 >+@@ -22,8 +22,10 @@ >+ >+ #include "mutt.h" >+ #include "mutt_curses.h" >++#include "mutt_menu.h" >+ #include "sort.h" >+ #include "mx.h" >++#include "sidebar.h" >+ >+ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) >+ { >+@@ -263,6 +265,7 @@ >+ */ >+ if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged)) >+ h->searched = 0; >++ draw_sidebar(0); >+ } >+ >+ void mutt_tag_set_flag (int flag, int bf) >+diff -uNr mutt-1.5.23.nntp.xterm/functions.h mutt-1.5.23.nntp.xterm.sidebar/functions.h >+--- mutt-1.5.23.nntp.xterm/functions.h 2014-12-03 02:09:36.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/functions.h 2014-12-03 02:32:53.218123610 +0200 >+@@ -188,6 +188,11 @@ >+ { "decrypt-save", OP_DECRYPT_SAVE, NULL }, >+ >+ >++ { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, >++ { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, >++ { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, >++ { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, >++ { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, >+ { NULL, 0, NULL } >+ }; >+ >+@@ -302,6 +307,11 @@ >+ >+ { "what-key", OP_WHAT_KEY, NULL }, >+ >++ { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, >++ { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, >++ { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, >++ { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, >++ { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, >+ { NULL, 0, NULL } >+ }; >+ >+diff -uNr mutt-1.5.23.nntp.xterm/globals.h mutt-1.5.23.nntp.xterm.sidebar/globals.h >+--- mutt-1.5.23.nntp.xterm/globals.h 2014-12-03 02:10:11.933685529 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/globals.h 2014-12-03 02:32:53.218123610 +0200 >+@@ -128,6 +128,7 @@ >+ WHERE char *SendCharset; >+ WHERE char *Sendmail; >+ WHERE char *Shell; >++WHERE char *SidebarDelim; >+ WHERE char *Signature; >+ WHERE char *SimpleSearch; >+ #if USE_SMTP >+@@ -226,6 +227,9 @@ >+ WHERE short ScoreThresholdRead; >+ WHERE short ScoreThresholdFlag; >+ >++WHERE struct buffy_t *CurBuffy INITVAL(0); >++WHERE short DrawFullLine INITVAL(0); >++WHERE short SidebarWidth; >+ #ifdef USE_IMAP >+ WHERE short ImapKeepalive; >+ WHERE short ImapPipelineDepth; >+diff -uNr mutt-1.5.23.nntp.xterm/imap/command.c mutt-1.5.23.nntp.xterm.sidebar/imap/command.c >+--- mutt-1.5.23.nntp.xterm/imap/command.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/imap/command.c 2014-12-03 02:32:53.218123610 +0200 >+@@ -1012,6 +1012,13 @@ >+ opened */ >+ status->uidnext = oldun; >+ >++ /* Added to make the sidebar show the correct numbers */ >++ if (status->messages) >++ { >++ inc->msgcount = status->messages; >++ inc->msg_unread = status->unseen; >++ } >++ >+ FREE (&value); >+ return; >+ } >+diff -uNr mutt-1.5.23.nntp.xterm/imap/imap.c mutt-1.5.23.nntp.xterm.sidebar/imap/imap.c >+--- mutt-1.5.23.nntp.xterm/imap/imap.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/imap/imap.c 2014-12-03 02:32:53.218123610 +0200 >+@@ -1514,7 +1514,7 @@ >+ >+ imap_munge_mbox_name (munged, sizeof (munged), name); >+ snprintf (command, sizeof (command), >+- "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged); >++ "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged); >+ >+ if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0) >+ { >+diff -uNr mutt-1.5.23.nntp.xterm/init.h mutt-1.5.23.nntp.xterm.sidebar/init.h >+--- mutt-1.5.23.nntp.xterm/init.h 2014-12-03 02:12:06.273819281 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/init.h 2014-12-03 02:32:53.218123610 +0200 >+@@ -2143,6 +2143,27 @@ >+ ** not used. >+ ** (PGP only) >+ */ >++ {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"}, >++ /* >++ ** .pp >++ ** This specifies the delimiter between the sidebar (if visible) and >++ ** other screens. >++ */ >++ { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 }, >++ /* >++ ** .pp >++ ** This specifies whether or not to show sidebar (left-side list of folders). >++ */ >++ { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 }, >++ /* >++ ** .pp >++ ** This specifies whether or not to sort the sidebar alphabetically. >++ */ >++ { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 }, >++ /* >++ ** .pp >++ ** The width of the sidebar. >++ */ >+ { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0}, >+ /* >+ ** .pp >+diff -uNr mutt-1.5.23.nntp.xterm/mailbox.h mutt-1.5.23.nntp.xterm.sidebar/mailbox.h >+--- mutt-1.5.23.nntp.xterm/mailbox.h 2014-12-03 02:09:36.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/mailbox.h 2014-12-03 02:32:53.219123620 +0200 >+@@ -27,6 +27,7 @@ >+ #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses >+ * safe_fopen() for mbox-style folders. >+ */ >++#define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */ >+ >+ /* mx_open_new_message() */ >+ #define M_ADD_FROM 1 /* add a From_ line */ >+diff -uNr mutt-1.5.23.nntp.xterm/Makefile.am mutt-1.5.23.nntp.xterm.sidebar/Makefile.am >+--- mutt-1.5.23.nntp.xterm/Makefile.am 2014-12-03 02:09:36.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/Makefile.am 2014-12-03 02:32:53.216123590 +0200 >+@@ -32,6 +32,7 @@ >+ rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \ >+ score.c send.c sendlib.c signal.c sort.c \ >+ status.c system.c thread.c charset.c history.c lib.c \ >++ sidebar.c \ >+ muttlib.c editmsg.c mbyte.c \ >+ url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c >+ >+diff -uNr mutt-1.5.23.nntp.xterm/mbox.c mutt-1.5.23.nntp.xterm.sidebar/mbox.c >+--- mutt-1.5.23.nntp.xterm/mbox.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/mbox.c 2014-12-03 02:32:53.219123620 +0200 >+@@ -100,6 +100,7 @@ >+ mutt_perror (ctx->path); >+ return (-1); >+ } >++ ctx->atime = sb.st_atime; >+ ctx->mtime = sb.st_mtime; >+ ctx->size = sb.st_size; >+ >+@@ -251,6 +252,7 @@ >+ >+ ctx->size = sb.st_size; >+ ctx->mtime = sb.st_mtime; >++ ctx->atime = sb.st_atime; >+ >+ #ifdef NFS_ATTRIBUTE_HACK >+ if (sb.st_mtime > sb.st_atime) >+diff -uNr mutt-1.5.23.nntp.xterm/menu.c mutt-1.5.23.nntp.xterm.sidebar/menu.c >+--- mutt-1.5.23.nntp.xterm/menu.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/menu.c 2014-12-03 02:32:53.219123620 +0200 >+@@ -24,6 +24,7 @@ >+ #include "mutt_curses.h" >+ #include "mutt_menu.h" >+ #include "mbyte.h" >++#include "sidebar.h" >+ >+ extern size_t UngetCount; >+ >+@@ -186,7 +187,7 @@ >+ { >+ char *scratch = safe_strdup (s); >+ int shift = option (OPTARROWCURSOR) ? 3 : 0; >+- int cols = COLS - shift; >++ int cols = COLS - shift - SidebarWidth; >+ >+ mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1); >+ s[n - 1] = 0; >+@@ -239,6 +240,7 @@ >+ int do_color; >+ int attr; >+ >++ draw_sidebar(1); >+ for (i = menu->top; i < menu->top + menu->pagelen; i++) >+ { >+ if (i < menu->max) >+@@ -249,7 +251,7 @@ >+ menu_pad_string (buf, sizeof (buf)); >+ >+ ATTRSET(attr); >+- move(i - menu->top + menu->offset, 0); >++ move(i - menu->top + menu->offset, SidebarWidth); >+ do_color = 1; >+ >+ if (i == menu->current) >+@@ -272,7 +274,7 @@ >+ else >+ { >+ NORMAL_COLOR; >+- CLEARLINE(i - menu->top + menu->offset); >++ CLEARLINE_WIN(i - menu->top + menu->offset); >+ } >+ } >+ NORMAL_COLOR; >+@@ -289,7 +291,7 @@ >+ return; >+ } >+ >+- move (menu->oldcurrent + menu->offset - menu->top, 0); >++ move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth); >+ ATTRSET(menu->color (menu->oldcurrent)); >+ >+ if (option (OPTARROWCURSOR)) >+@@ -301,13 +303,13 @@ >+ { >+ menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); >+ menu_pad_string (buf, sizeof (buf)); >+- move (menu->oldcurrent + menu->offset - menu->top, 3); >++ move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3); >+ print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); >+ } >+ >+ /* now draw it in the new location */ >+ SETCOLOR(MT_COLOR_INDICATOR); >+- mvaddstr(menu->current + menu->offset - menu->top, 0, "->"); >++ mvaddstr(menu->current + menu->offset - menu->top, SidebarWidth, "->"); >+ } >+ else >+ { >+@@ -320,7 +322,7 @@ >+ menu_make_entry (buf, sizeof (buf), menu, menu->current); >+ menu_pad_string (buf, sizeof (buf)); >+ SETCOLOR(MT_COLOR_INDICATOR); >+- move(menu->current - menu->top + menu->offset, 0); >++ move(menu->current - menu->top + menu->offset, SidebarWidth); >+ print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); >+ } >+ menu->redraw &= REDRAW_STATUS; >+@@ -332,7 +334,7 @@ >+ char buf[LONG_STRING]; >+ int attr = menu->color (menu->current); >+ >+- move (menu->current + menu->offset - menu->top, 0); >++ move (menu->current + menu->offset - menu->top, SidebarWidth); >+ menu_make_entry (buf, sizeof (buf), menu, menu->current); >+ menu_pad_string (buf, sizeof (buf)); >+ >+@@ -872,7 +874,7 @@ >+ >+ >+ if (option (OPTARROWCURSOR)) >+- move (menu->current - menu->top + menu->offset, 2); >++ move (menu->current - menu->top + menu->offset, SidebarWidth + 2); >+ else if (option (OPTBRAILLEFRIENDLY)) >+ move (menu->current - menu->top + menu->offset, 0); >+ else >+diff -uNr mutt-1.5.23.nntp.xterm/mh.c mutt-1.5.23.nntp.xterm.sidebar/mh.c >+--- mutt-1.5.23.nntp.xterm/mh.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/mh.c 2014-12-03 02:32:53.219123620 +0200 >+@@ -295,6 +295,28 @@ >+ mhs_free_sequences (&mhs); >+ } >+ >++void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged) >++{ >++ int i; >++ struct mh_sequences mhs; >++ memset (&mhs, 0, sizeof (mhs)); >++ >++ if (mh_read_sequences (&mhs, path) < 0) >++ return; >++ >++ msgcount = 0; >++ msg_unread = 0; >++ msg_flagged = 0; >++ for (i = 0; i <= mhs.max; i++) >++ msgcount++; >++ if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) { >++ msg_unread++; >++ } >++ if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED) >++ msg_flagged++; >++ mhs_free_sequences (&mhs); >++} >++ >+ static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt) >+ { >+ int fd; >+diff -uNr mutt-1.5.23.nntp.xterm/mutt_curses.h mutt-1.5.23.nntp.xterm.sidebar/mutt_curses.h >+--- mutt-1.5.23.nntp.xterm/mutt_curses.h 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/mutt_curses.h 2014-12-03 02:32:53.219123620 +0200 >+@@ -64,6 +64,7 @@ >+ #undef lines >+ #endif /* lines */ >+ >++#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol() >+ #define CLEARLINE(x) move(x,0), clrtoeol() >+ #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x) >+ #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0) >+@@ -120,6 +121,8 @@ >+ MT_COLOR_BOLD, >+ MT_COLOR_UNDERLINE, >+ MT_COLOR_INDEX, >++ MT_COLOR_NEW, >++ MT_COLOR_FLAGGED, >+ MT_COLOR_MAX >+ }; >+ >+diff -uNr mutt-1.5.23.nntp.xterm/mutt.h mutt-1.5.23.nntp.xterm.sidebar/mutt.h >+--- mutt-1.5.23.nntp.xterm/mutt.h 2014-12-03 02:10:11.934685539 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/mutt.h 2014-12-03 02:32:53.219123620 +0200 >+@@ -435,6 +435,8 @@ >+ OPTSAVEEMPTY, >+ OPTSAVENAME, >+ OPTSCORE, >++ OPTSIDEBAR, >++ OPTSIDEBARSORT, >+ OPTSIGDASHES, >+ OPTSIGONTOP, >+ OPTSORTRE, >+@@ -899,6 +901,7 @@ >+ { >+ char *path; >+ FILE *fp; >++ time_t atime; >+ time_t mtime; >+ off_t size; >+ off_t vsize; >+@@ -933,6 +936,7 @@ >+ unsigned int quiet : 1; /* inhibit status messages? */ >+ unsigned int collapsed : 1; /* are all threads collapsed? */ >+ unsigned int closing : 1; /* mailbox is being closed */ >++ unsigned int peekonly : 1; /* just taking a glance, revert atime */ >+ >+ /* driver hooks */ >+ void *data; /* driver specific data */ >+diff -uNr mutt-1.5.23.nntp.xterm/muttlib.c mutt-1.5.23.nntp.xterm.sidebar/muttlib.c >+--- mutt-1.5.23.nntp.xterm/muttlib.c 2014-12-03 02:09:36.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/muttlib.c 2014-12-03 02:32:53.219123620 +0200 >+@@ -1288,6 +1288,8 @@ >+ pl = pw = 1; >+ >+ /* see if there's room to add content, else ignore */ >++ if ( DrawFullLine ) >++ { >+ if ((col < COLS && wlen < destlen) || soft) >+ { >+ int pad; >+@@ -1331,6 +1333,52 @@ >+ col += wid; >+ src += pl; >+ } >++ } >++ else >++ { >++ if ((col < COLS-SidebarWidth && wlen < destlen) || soft) >++ { >++ int pad; >++ >++ /* get contents after padding */ >++ mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags); >++ len = mutt_strlen (buf); >++ wid = mutt_strwidth (buf); >++ >++ /* try to consume as many columns as we can, if we don't have >++ * memory for that, use as much memory as possible */ >++ pad = (COLS - SidebarWidth - col - wid) / pw; >++ if (pad > 0 && wlen + (pad * pl) + len > destlen) >++ pad = ((signed)(destlen - wlen - len)) / pl; >++ if (pad > 0) >++ { >++ while (pad--) >++ { >++ memcpy (wptr, src, pl); >++ wptr += pl; >++ wlen += pl; >++ col += pw; >++ } >++ } >++ else if (soft && pad < 0) >++ { >++ /* \0-terminate dest for length computation in mutt_wstr_trunc() */ >++ *wptr = 0; >++ /* make sure right part is at most as wide as display */ >++ len = mutt_wstr_trunc (buf, destlen, COLS, &wid); >++ /* truncate left so that right part fits completely in */ >++ wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col); >++ wptr = dest + wlen; >++ } >++ if (len + wlen > destlen) >++ len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL); >++ memcpy (wptr, buf, len); >++ wptr += len; >++ wlen += len; >++ col += wid; >++ src += pl; >++ } >++ } >+ break; /* skip rest of input */ >+ } >+ else if (ch == '|') >+diff -uNr mutt-1.5.23.nntp.xterm/mx.c mutt-1.5.23.nntp.xterm.sidebar/mx.c >+--- mutt-1.5.23.nntp.xterm/mx.c 2014-12-03 02:09:36.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/mx.c 2014-12-03 02:32:53.220123630 +0200 >+@@ -601,6 +601,7 @@ >+ * M_APPEND open mailbox for appending >+ * M_READONLY open mailbox in read-only mode >+ * M_QUIET only print error messages >++ * M_PEEK revert atime where applicable >+ * ctx if non-null, context struct to use >+ */ >+ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx) >+@@ -623,6 +624,8 @@ >+ ctx->quiet = 1; >+ if (flags & M_READONLY) >+ ctx->readonly = 1; >++ if (flags & M_PEEK) >++ ctx->peekonly = 1; >+ >+ if (flags & (M_APPEND|M_NEWFOLDER)) >+ { >+@@ -728,9 +731,21 @@ >+ void mx_fastclose_mailbox (CONTEXT *ctx) >+ { >+ int i; >++#ifndef BUFFY_SIZE >++ struct utimbuf ut; >++#endif >+ >+ if(!ctx) >+ return; >++#ifndef BUFFY_SIZE >++ /* fix up the times so buffy won't get confused */ >++ if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime) >++ { >++ ut.actime = ctx->atime; >++ ut.modtime = ctx->mtime; >++ utime (ctx->path, &ut); >++ } >++#endif >+ >+ /* never announce that a mailbox we've just left has new mail. #3290 >+ * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */ >+diff -uNr mutt-1.5.23.nntp.xterm/mx.h mutt-1.5.23.nntp.xterm.sidebar/mx.h >+--- mutt-1.5.23.nntp.xterm/mx.h 2014-12-03 02:09:36.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/mx.h 2014-12-03 02:32:53.220123630 +0200 >+@@ -60,6 +60,7 @@ >+ int mh_read_dir (CONTEXT *, const char *); >+ int mh_sync_mailbox (CONTEXT *, int *); >+ int mh_check_mailbox (CONTEXT *, int *); >++void mh_buffy_update (const char *, int *, int *, int *); >+ int mh_check_empty (const char *); >+ >+ int maildir_read_dir (CONTEXT *); >+diff -uNr mutt-1.5.23.nntp.xterm/OPS mutt-1.5.23.nntp.xterm.sidebar/OPS >+--- mutt-1.5.23.nntp.xterm/OPS 2014-12-03 02:09:36.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/OPS 2014-12-03 02:32:53.217123600 +0200 >+@@ -198,3 +198,8 @@ >+ OP_MAIN_SHOW_LIMIT "show currently active limit pattern" >+ OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread" >+ OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads" >++OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page" >++OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page" >++OP_SIDEBAR_NEXT "go down to next mailbox" >++OP_SIDEBAR_PREV "go to previous mailbox" >++OP_SIDEBAR_OPEN "open hilighted mailbox" >+diff -uNr mutt-1.5.23.nntp.xterm/pager.c mutt-1.5.23.nntp.xterm.sidebar/pager.c >+--- mutt-1.5.23.nntp.xterm/pager.c 2014-12-03 02:10:11.934685539 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/pager.c 2014-12-03 02:32:53.220123630 +0200 >+@@ -29,6 +29,7 @@ >+ #include "pager.h" >+ #include "attach.h" >+ #include "mbyte.h" >++#include "sidebar.h" >+ >+ #include "mutt_crypt.h" >+ >+@@ -1100,6 +1101,7 @@ >+ wchar_t wc; >+ mbstate_t mbstate; >+ int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap); >++ wrap_cols -= SidebarWidth; >+ >+ if (check_attachment_marker ((char *)buf) == 0) >+ wrap_cols = COLS; >+@@ -1769,7 +1771,7 @@ >+ if ((redraw & REDRAW_BODY) || topline != oldtopline) >+ { >+ do { >+- move (bodyoffset, 0); >++ move (bodyoffset, SidebarWidth); >+ curline = oldtopline = topline; >+ lines = 0; >+ force_redraw = 0; >+@@ -1782,6 +1784,7 @@ >+ &QuoteList, &q_level, &force_redraw, &SearchRE) > 0) >+ lines++; >+ curline++; >++ move(lines + bodyoffset, SidebarWidth); >+ } >+ last_offset = lineInfo[curline].offset; >+ } while (force_redraw); >+@@ -1794,6 +1797,7 @@ >+ addch ('~'); >+ addch ('\n'); >+ lines++; >++ move(lines + bodyoffset, SidebarWidth); >+ } >+ NORMAL_COLOR; >+ >+@@ -1817,22 +1821,22 @@ >+ strfcpy(pager_progress_str, (topline == 0) ? "all" : "end", sizeof(pager_progress_str)); >+ >+ /* print out the pager status bar */ >+- move (statusoffset, 0); >++ move (statusoffset, SidebarWidth); >+ SETCOLOR (MT_COLOR_STATUS); >+ >+ if (IsHeader (extra) || IsMsgAttach (extra)) >+ { >+- size_t l1 = COLS * MB_LEN_MAX; >++ size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX; >+ size_t l2 = sizeof (buffer); >+ hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr; >+ mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT); >+- mutt_paddstr (COLS, buffer); >++ mutt_paddstr (COLS-SidebarWidth, buffer); >+ } >+ else >+ { >+ char bn[STRING]; >+ snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str); >+- mutt_paddstr (COLS, bn); >++ mutt_paddstr (COLS-SidebarWidth, bn); >+ } >+ NORMAL_COLOR; >+ if (option(OPTXTERMSETTITLES)) >+@@ -1849,16 +1853,21 @@ >+ /* redraw the pager_index indicator, because the >+ * flags for this message might have changed. */ >+ menu_redraw_current (index); >++ draw_sidebar(MENU_PAGER); >+ >+ /* print out the index status bar */ >+ menu_status_line (buffer, sizeof (buffer), index, NONULL(Status)); >+ >+- move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0); >++ move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth); >+ SETCOLOR (MT_COLOR_STATUS); >+- mutt_paddstr (COLS, buffer); >++ mutt_paddstr (COLS-SidebarWidth, buffer); >+ NORMAL_COLOR; >+ } >+ >++ /* if we're not using the index, update every time */ >++ if ( index == 0 ) >++ draw_sidebar(MENU_PAGER); >++ >+ redraw = 0; >+ >+ if (option(OPTBRAILLEFRIENDLY)) { >+@@ -2847,6 +2856,13 @@ >+ mutt_what_key (); >+ break; >+ >++ case OP_SIDEBAR_SCROLL_UP: >++ case OP_SIDEBAR_SCROLL_DOWN: >++ case OP_SIDEBAR_NEXT: >++ case OP_SIDEBAR_PREV: >++ scroll_sidebar(ch, MENU_PAGER); >++ break; >++ >+ default: >+ ch = -1; >+ break; >+diff -uNr mutt-1.5.23.nntp.xterm/sidebar.c mutt-1.5.23.nntp.xterm.sidebar/sidebar.c >+--- mutt-1.5.23.nntp.xterm/sidebar.c 1970-01-01 02:00:00.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/sidebar.c 2014-12-03 02:32:53.220123630 +0200 >+@@ -0,0 +1,333 @@ >++/* >++ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> >++ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> >++ * >++ * This program is free software; you can redistribute it and/or modify >++ * it under the terms of the GNU General Public License as published by >++ * the Free Software Foundation; either version 2 of the License, or >++ * (at your option) any later version. >++ * >++ * This program is distributed in the hope that it will be useful, >++ * but WITHOUT ANY WARRANTY; without even the implied warranty of >++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >++ * GNU General Public License for more details. >++ * >++ * You should have received a copy of the GNU General Public License >++ * along with this program; if not, write to the Free Software >++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. >++ */ >++ >++ >++#if HAVE_CONFIG_H >++# include "config.h" >++#endif >++ >++#include "mutt.h" >++#include "mutt_menu.h" >++#include "mutt_curses.h" >++#include "sidebar.h" >++#include "buffy.h" >++#include <libgen.h> >++#include "keymap.h" >++#include <stdbool.h> >++ >++/*BUFFY *CurBuffy = 0;*/ >++static BUFFY *TopBuffy = 0; >++static BUFFY *BottomBuffy = 0; >++static int known_lines = 0; >++ >++static int quick_log10(int n) >++{ >++ char string[32]; >++ sprintf(string, "%d", n); >++ return strlen(string); >++} >++ >++void calc_boundaries (int menu) >++{ >++ BUFFY *tmp = Incoming; >++ >++ if ( known_lines != LINES ) { >++ TopBuffy = BottomBuffy = 0; >++ known_lines = LINES; >++ } >++ for ( ; tmp->next != 0; tmp = tmp->next ) >++ tmp->next->prev = tmp; >++ >++ if ( TopBuffy == 0 && BottomBuffy == 0 ) >++ TopBuffy = Incoming; >++ if ( BottomBuffy == 0 ) { >++ int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); >++ BottomBuffy = TopBuffy; >++ while ( --count && BottomBuffy->next ) >++ BottomBuffy = BottomBuffy->next; >++ } >++ else if ( TopBuffy == CurBuffy->next ) { >++ int count = LINES - 2 - (menu != MENU_PAGER); >++ BottomBuffy = CurBuffy; >++ tmp = BottomBuffy; >++ while ( --count && tmp->prev) >++ tmp = tmp->prev; >++ TopBuffy = tmp; >++ } >++ else if ( BottomBuffy == CurBuffy->prev ) { >++ int count = LINES - 2 - (menu != MENU_PAGER); >++ TopBuffy = CurBuffy; >++ tmp = TopBuffy; >++ while ( --count && tmp->next ) >++ tmp = tmp->next; >++ BottomBuffy = tmp; >++ } >++} >++ >++char *make_sidebar_entry(char *box, int size, int new, int flagged) >++{ >++ static char *entry = 0; >++ char *c; >++ int i = 0; >++ int delim_len = strlen(SidebarDelim); >++ >++ c = realloc(entry, SidebarWidth - delim_len + 2); >++ if ( c ) entry = c; >++ entry[SidebarWidth - delim_len + 1] = 0; >++ for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' ); >++ i = strlen(box); >++ strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) ); >++ >++ if (size == -1) >++ sprintf(entry + SidebarWidth - delim_len - 3, "?"); >++ else if ( new ) { >++ if (flagged > 0) { >++ sprintf( >++ entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged), >++ "% d(%d)[%d]", size, new, flagged); >++ } else { >++ sprintf( >++ entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new), >++ "% d(%d)", size, new); >++ } >++ } else if (flagged > 0) { >++ sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged); >++ } else { >++ sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size); >++ } >++ return entry; >++} >++ >++void set_curbuffy(char buf[LONG_STRING]) >++{ >++ BUFFY* tmp = CurBuffy = Incoming; >++ >++ if (!Incoming) >++ return; >++ >++ while(1) { >++ if(!strcmp(tmp->path, buf)) { >++ CurBuffy = tmp; >++ break; >++ } >++ >++ if(tmp->next) >++ tmp = tmp->next; >++ else >++ break; >++ } >++} >++ >++int draw_sidebar(int menu) { >++ >++ int lines = option(OPTHELP) ? 1 : 0; >++ BUFFY *tmp; >++#ifndef USE_SLANG_CURSES >++ attr_t attrs; >++#endif >++ short delim_len = strlen(SidebarDelim); >++ short color_pair; >++ >++ static bool initialized = false; >++ static int prev_show_value; >++ static short saveSidebarWidth; >++ >++ /* initialize first time */ >++ if(!initialized) { >++ prev_show_value = option(OPTSIDEBAR); >++ saveSidebarWidth = SidebarWidth; >++ if(!option(OPTSIDEBAR)) SidebarWidth = 0; >++ initialized = true; >++ } >++ >++ /* save or restore the value SidebarWidth */ >++ if(prev_show_value != option(OPTSIDEBAR)) { >++ if(prev_show_value && !option(OPTSIDEBAR)) { >++ saveSidebarWidth = SidebarWidth; >++ SidebarWidth = 0; >++ } else if(!prev_show_value && option(OPTSIDEBAR)) { >++ SidebarWidth = saveSidebarWidth; >++ } >++ prev_show_value = option(OPTSIDEBAR); >++ } >++ >++ >++// if ( SidebarWidth == 0 ) return 0; >++ if (SidebarWidth > 0 && option (OPTSIDEBAR) >++ && delim_len >= SidebarWidth) { >++ unset_option (OPTSIDEBAR); >++ /* saveSidebarWidth = SidebarWidth; */ >++ if (saveSidebarWidth > delim_len) { >++ SidebarWidth = saveSidebarWidth; >++ mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar.")); >++ sleep (2); >++ } else { >++ SidebarWidth = 0; >++ mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value.")); >++ sleep (4); /* the advise to set a sane value should be seen long enough */ >++ } >++ saveSidebarWidth = 0; >++ return (0); >++ } >++ >++ if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) { >++ if (SidebarWidth > 0) { >++ saveSidebarWidth = SidebarWidth; >++ SidebarWidth = 0; >++ } >++ unset_option(OPTSIDEBAR); >++ return 0; >++ } >++ >++ /* get attributes for divider */ >++ SETCOLOR(MT_COLOR_STATUS); >++#ifndef USE_SLANG_CURSES >++ attr_get(&attrs, &color_pair, 0); >++#else >++ color_pair = attr_get(); >++#endif >++ SETCOLOR(MT_COLOR_NORMAL); >++ >++ /* draw the divider */ >++ >++ for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { >++ move(lines, SidebarWidth - delim_len); >++ addstr(NONULL(SidebarDelim)); >++#ifndef USE_SLANG_CURSES >++ mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL); >++#endif >++ } >++ >++ if ( Incoming == 0 ) return 0; >++ lines = option(OPTHELP) ? 1 : 0; /* go back to the top */ >++ >++ if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) >++ calc_boundaries(menu); >++ if ( CurBuffy == 0 ) CurBuffy = Incoming; >++ >++ tmp = TopBuffy; >++ >++ SETCOLOR(MT_COLOR_NORMAL); >++ >++ for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) { >++ if ( tmp == CurBuffy ) >++ SETCOLOR(MT_COLOR_INDICATOR); >++ else if ( tmp->msg_unread > 0 ) >++ SETCOLOR(MT_COLOR_NEW); >++ else if ( tmp->msg_flagged > 0 ) >++ SETCOLOR(MT_COLOR_FLAGGED); >++ else >++ SETCOLOR(MT_COLOR_NORMAL); >++ >++ move( lines, 0 ); >++ if ( Context && !strcmp( tmp->path, Context->path ) ) { >++ tmp->msg_unread = Context->unread; >++ tmp->msgcount = Context->msgcount; >++ tmp->msg_flagged = Context->flagged; >++ } >++ // check whether Maildir is a prefix of the current folder's path >++ short maildir_is_prefix = 0; >++ if ( (strlen(tmp->path) > strlen(Maildir)) && >++ (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) ) >++ maildir_is_prefix = 1; >++ // calculate depth of current folder and generate its display name with indented spaces >++ int sidebar_folder_depth = 0; >++ char *sidebar_folder_name; >++ sidebar_folder_name = basename(tmp->path); >++ if ( maildir_is_prefix ) { >++ char *tmp_folder_name; >++ int i; >++ tmp_folder_name = tmp->path + strlen(Maildir); >++ for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) { >++ if (tmp_folder_name[i] == '/') sidebar_folder_depth++; >++ } >++ if (sidebar_folder_depth > 0) { >++ sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1); >++ for (i=0; i < sidebar_folder_depth; i++) >++ sidebar_folder_name[i]=' '; >++ sidebar_folder_name[i]=0; >++ strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth); >++ } >++ } >++ printw( "%.*s", SidebarWidth - delim_len + 1, >++ make_sidebar_entry(sidebar_folder_name, tmp->msgcount, >++ tmp->msg_unread, tmp->msg_flagged)); >++ if (sidebar_folder_depth > 0) >++ free(sidebar_folder_name); >++ lines++; >++ } >++ SETCOLOR(MT_COLOR_NORMAL); >++ for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { >++ int i = 0; >++ move( lines, 0 ); >++ for ( ; i < SidebarWidth - delim_len; i++ ) >++ addch(' '); >++ } >++ return 0; >++} >++ >++ >++void set_buffystats(CONTEXT* Context) >++{ >++ BUFFY *tmp = Incoming; >++ while(tmp) { >++ if(Context && !strcmp(tmp->path, Context->path)) { >++ tmp->msg_unread = Context->unread; >++ tmp->msgcount = Context->msgcount; >++ break; >++ } >++ tmp = tmp->next; >++ } >++} >++ >++void scroll_sidebar(int op, int menu) >++{ >++ if(!SidebarWidth) return; >++ if(!CurBuffy) return; >++ >++ switch (op) { >++ case OP_SIDEBAR_NEXT: >++ if ( CurBuffy->next == NULL ) return; >++ CurBuffy = CurBuffy->next; >++ break; >++ case OP_SIDEBAR_PREV: >++ if ( CurBuffy->prev == NULL ) return; >++ CurBuffy = CurBuffy->prev; >++ break; >++ case OP_SIDEBAR_SCROLL_UP: >++ CurBuffy = TopBuffy; >++ if ( CurBuffy != Incoming ) { >++ calc_boundaries(menu); >++ CurBuffy = CurBuffy->prev; >++ } >++ break; >++ case OP_SIDEBAR_SCROLL_DOWN: >++ CurBuffy = BottomBuffy; >++ if ( CurBuffy->next ) { >++ calc_boundaries(menu); >++ CurBuffy = CurBuffy->next; >++ } >++ break; >++ default: >++ return; >++ } >++ calc_boundaries(menu); >++ draw_sidebar(menu); >++} >++ >+diff -uNr mutt-1.5.23.nntp.xterm/sidebar.h mutt-1.5.23.nntp.xterm.sidebar/sidebar.h >+--- mutt-1.5.23.nntp.xterm/sidebar.h 1970-01-01 02:00:00.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm.sidebar/sidebar.h 2014-12-03 02:32:53.220123630 +0200 >+@@ -0,0 +1,36 @@ >++/* >++ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> >++ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> >++ * >++ * This program is free software; you can redistribute it and/or modify >++ * it under the terms of the GNU General Public License as published by >++ * the Free Software Foundation; either version 2 of the License, or >++ * (at your option) any later version. >++ * >++ * This program is distributed in the hope that it will be useful, >++ * but WITHOUT ANY WARRANTY; without even the implied warranty of >++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >++ * GNU General Public License for more details. >++ * >++ * You should have received a copy of the GNU General Public License >++ * along with this program; if not, write to the Free Software >++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. >++ */ >++ >++#ifndef SIDEBAR_H >++#define SIDEBAR_H >++ >++struct MBOX_LIST { >++ char *path; >++ int msgcount; >++ int new; >++} MBLIST; >++ >++/* parameter is whether or not to go to the status line */ >++/* used for omitting the last | that covers up the status bar in the index */ >++int draw_sidebar(int); >++void scroll_sidebar(int, int); >++void set_curbuffy(char*); >++void set_buffystats(CONTEXT*); >++ >++#endif /* SIDEBAR_H */ >Index: SOURCES/mutt-1.5.23-ticket-3716-dev.patch >=================================================================== >--- SOURCES/mutt-1.5.23-ticket-3716-dev.patch (revision 0) >+++ SOURCES/mutt-1.5.23-ticket-3716-dev.patch (working copy) >@@ -0,0 +1,41 @@ >+# HG changeset patch >+# User Kevin McCarthy <kevin@8t8.us> >+# Date 1417472349 28800 >+# Mon Dec 01 14:19:09 2014 -0800 >+# Node ID e8e07f3c08e5e83dbeb83ace6649c05042e5ff9c >+# Parent 39d3ddb56d340f66ffd0fe476003645f4cdc30bc >+Change EMAIL_WSP to be space and tab (references #3716) >+ >+This patch fixes CVE-2014-9116 in the development branch, by changing >+EMAIL_WSP, skip_email_wsp(), and is_email_wsp() to define WSP as space >+and tab only. >+ >+Michael reviewed [f251d523ca5a] and the code using these functions, and >+believes they all are used for unfolded headers. Furthermore, it makes >+sense for WSP to match RFC5322. >+ >+Thanks also to Antonio Radici and Tomas Hoger for their analysis and >+patches to mutt, which this patch is based off of. >+ >+diff --git a/lib.h b/lib.h >+--- a/lib.h >++++ b/lib.h >+@@ -93,17 +93,17 @@ >+ #define FMT_CENTER -1 >+ >+ #define FOREVER while (1) >+ >+ /* this macro must check for *c == 0 since isspace(0) has unreliable behavior >+ on some systems */ >+ # define SKIPWS(c) while (*(c) && isspace ((unsigned char) *(c))) c++; >+ >+-#define EMAIL_WSP " \t\r\n" >++#define EMAIL_WSP " \t" >+ >+ /* skip over WSP as defined by RFC5322. This is used primarily for parsing >+ * header fields. */ >+ >+ static inline char *skip_email_wsp(const char *s) >+ { >+ if (s) >+ return (char *)(s + strspn(s, EMAIL_WSP)); >Index: SOURCES/mutt-1.5.23-xterm-title.patch >=================================================================== >--- SOURCES/mutt-1.5.23-xterm-title.patch (revision 0) >+++ SOURCES/mutt-1.5.23-xterm-title.patch (working copy) >@@ -0,0 +1,162 @@ >+diff -uNr mutt-1.5.23.nntp/curs_main.c mutt-1.5.23.nntp.xterm/curs_main.c >+--- mutt-1.5.23.nntp/curs_main.c 2014-12-03 02:09:36.111330033 +0200 >++++ mutt-1.5.23.nntp.xterm/curs_main.c 2014-12-03 02:10:11.933685529 +0200 >+@@ -115,6 +115,19 @@ >+ >+ extern size_t UngetCount; >+ >++#define ASCII_CTRL_G 0x07 >++#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b >++ >++void set_xterm_title_bar(char *title) >++{ >++ fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G); >++} >++ >++void set_xterm_icon_name(char *name) >++{ >++ fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G); >++} >++ >+ void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num) >+ { >+ format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX; >+@@ -584,6 +597,13 @@ >+ mutt_paddstr (COLS, buf); >+ NORMAL_COLOR; >+ menu->redraw &= ~REDRAW_STATUS; >++ if (option(OPTXTERMSETTITLES)) >++ { >++ menu_status_line (buf, sizeof (buf), menu, NONULL (XtermTitle)); >++ set_xterm_title_bar(buf); >++ menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon)); >++ set_xterm_icon_name(buf); >++ } >+ } >+ >+ menu->redraw = 0; >+diff -uNr mutt-1.5.23.nntp/globals.h mutt-1.5.23.nntp.xterm/globals.h >+--- mutt-1.5.23.nntp/globals.h 2014-12-03 02:09:36.112330043 +0200 >++++ mutt-1.5.23.nntp.xterm/globals.h 2014-12-03 02:10:11.933685529 +0200 >+@@ -152,6 +152,8 @@ >+ WHERE char *Tochars; >+ WHERE char *Username; >+ WHERE char *Visual; >++WHERE char *XtermTitle; >++WHERE char *XtermIcon; >+ >+ WHERE char *CurrentFolder; >+ WHERE char *LastFolder; >+diff -uNr mutt-1.5.23.nntp/init.c mutt-1.5.23.nntp.xterm/init.c >+--- mutt-1.5.23.nntp/init.c 2014-12-03 02:09:36.113330053 +0200 >++++ mutt-1.5.23.nntp.xterm/init.c 2014-12-03 02:10:11.933685529 +0200 >+@@ -1818,6 +1818,26 @@ >+ toggle_option (MuttVars[idx].data); >+ else >+ set_option (MuttVars[idx].data); >++ >++ /* sanity check for xterm */ >++ if ((mutt_strcmp (MuttVars[idx].option, "xterm_set_titles") == 0) >++ && option (OPTXTERMSETTITLES)) >++ { >++ char *ep = getenv ("TERM"); >++ /* Make sure that the terminal can take the control codes */ >++ if (ep == NULL) unset_option (MuttVars[idx].data); >++ else if (mutt_strncasecmp (ep, "xterm", 5) && >++ mutt_strncasecmp (ep, "color-xterm", 11) && >++ mutt_strncasecmp (ep, "eterm", 5) && >++ mutt_strncasecmp (ep, "kterm", 5) && >++ mutt_strncasecmp (ep, "nxterm", 6) && >++ mutt_strncasecmp (ep, "putty", 5) && >++ mutt_strncasecmp (ep, "screen", 6) && >++ mutt_strncasecmp (ep, "cygwin", 6) && >++ mutt_strncasecmp (ep, "rxvt", 4) ) >++ unset_option (MuttVars[idx]. data); >++ >++ } >+ } >+ else if (myvar || DTYPE (MuttVars[idx].type) == DT_STR || >+ DTYPE (MuttVars[idx].type) == DT_PATH || >+diff -uNr mutt-1.5.23.nntp/init.h mutt-1.5.23.nntp.xterm/init.h >+--- mutt-1.5.23.nntp/init.h 2014-12-03 02:09:36.113330053 +0200 >++++ mutt-1.5.23.nntp.xterm/init.h 2014-12-03 02:12:06.273819281 +0200 >+@@ -3629,6 +3629,27 @@ >+ ** name of original article author) to article that followuped to newsgroup. >+ */ >+ #endif >++ {"xterm_icon", DT_STR, R_BOTH, UL &XtermIcon, UL "M%?n?AIL&ail?"}, >++ /* >++ ** .pp >++ ** Controls the format of the icon title, as long as xterm_set_titles >++ ** is enabled. This string is identical in formatting to the one used by >++ ** ``$$status_format''. >++ */ >++ {"xterm_set_titles", DT_BOOL, R_BOTH, OPTXTERMSETTITLES, 0}, >++ /* The default must be off to force in the validity checking. */ >++ /* >++ ** .pp >++ ** Controls whether mutt sets the xterm title bar and icon name >++ ** (as long as you are in an appropriate terminal). >++ */ >++ {"xterm_title", DT_STR, R_BOTH, UL &XtermTitle, UL "Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?"}, >++ /* >++ ** .pp >++ ** Controls the format of the title bar of the xterm provided that >++ ** xterm_set_titles has been set. This string is identical in formatting >++ ** to the one used by ``$$status_format''. >++ */ >+ /*--*/ >+ { NULL, 0, 0, 0, 0 } >+ }; >+diff -uNr mutt-1.5.23.nntp/mutt.h mutt-1.5.23.nntp.xterm/mutt.h >+--- mutt-1.5.23.nntp/mutt.h 2014-12-03 02:09:36.114330063 +0200 >++++ mutt-1.5.23.nntp.xterm/mutt.h 2014-12-03 02:10:11.934685539 +0200 >+@@ -463,6 +463,7 @@ >+ OPTWRAPSEARCH, >+ OPTWRITEBCC, /* write out a bcc header? */ >+ OPTXMAILER, >++ OPTXTERMSETTITLES, >+ >+ OPTCRYPTUSEGPGME, >+ OPTCRYPTUSEPKA, >+diff -uNr mutt-1.5.23.nntp/mutt_menu.h mutt-1.5.23.nntp.xterm/mutt_menu.h >+--- mutt-1.5.23.nntp/mutt_menu.h 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm/mutt_menu.h 2014-12-03 02:10:11.934685539 +0200 >+@@ -103,6 +103,8 @@ >+ void menu_current_bottom (MUTTMENU *); >+ void menu_check_recenter (MUTTMENU *); >+ void menu_status_line (char *, size_t, MUTTMENU *, const char *); >++void set_xterm_title_bar (char *title); >++void set_xterm_icon_name (char *name); >+ >+ MUTTMENU *mutt_new_menu (int); >+ void mutt_menuDestroy (MUTTMENU **); >+diff -uNr mutt-1.5.23.nntp/pager.c mutt-1.5.23.nntp.xterm/pager.c >+--- mutt-1.5.23.nntp/pager.c 2014-12-03 02:09:36.116330083 +0200 >++++ mutt-1.5.23.nntp.xterm/pager.c 2014-12-03 02:10:11.934685539 +0200 >+@@ -1835,6 +1835,13 @@ >+ mutt_paddstr (COLS, bn); >+ } >+ NORMAL_COLOR; >++ if (option(OPTXTERMSETTITLES)) >++ { >++ menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermTitle)); >++ set_xterm_title_bar(buffer); >++ menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermIcon)); >++ set_xterm_icon_name(buffer); >++ } >+ } >+ >+ if ((redraw & REDRAW_INDEX) && index) >+diff -uNr mutt-1.5.23.nntp/status.c mutt-1.5.23.nntp.xterm/status.c >+--- mutt-1.5.23.nntp/status.c 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23.nntp.xterm/status.c 2014-12-03 02:10:11.934685539 +0200 >+@@ -195,6 +195,8 @@ >+ break; >+ >+ case 'P': >++ if (!menu) >++ break; >+ if (menu->top + menu->pagelen >= menu->max) >+ cp = menu->top ? "end" : "all"; >+ else >Index: SOURCES/mutt-1.5.23.tar.gz.asc >=================================================================== >--- SOURCES/mutt-1.5.23.tar.gz.asc (revision 0) >+++ SOURCES/mutt-1.5.23.tar.gz.asc (working copy) >@@ -0,0 +1,17 @@ >+-----BEGIN PGP SIGNATURE----- >+Version: GnuPG v2.0.18 (Darwin) >+ >+iQIcBAABAgAGBQJTIIsiAAoJEFHk0k89vdxoVBYP/2S/E6VcqENN3JSk4y9zYdEM >+8IejDRjpeASP/83Q3oZCUi6aSL8UeoRGVH7D7pIE76S5mTIyfDpeAQg/cbORc8H/ >+dMnevaK6MCt2tK2GelV2t2MXo/hZIBn2EozarEcQaiEeZtuljdE2vJiCdkHkotaN >+HjIR2b4fDDkGbTF/ZP+Y/VN/VOIkwUHIPzlznqGrIcvUzKqqnNLPN5w1lkiHMf6V >+DZZsp4cMnVgTVaKPLTD0L5ZPXic/Xgotv6V2PjqVSkYpqUELDa+PDZ93zDe1Ezeo >+1JbpodFm6WXS5DRxL6EcT+/gZLQos/RCVMqnSwaWlJqvJ59mKewEWPUxoHC0tCCA >+S/nwrOhR779ZZ1y0tZHafywxlGw2f7MartK94bHDPjumAjp7Kt+PaXBiv9XohQCN >+LioIgUheAg6DHs36YkWP05F29vMHU8fnK0y7RTlpAo4mvgaIlMUK+rLDe4B2xzG1 >+T650ZWykUbjjBqUTc+xx1sWHYQbF/EOAG/D2HF3HwD30jjQa4mA/S/r69i9sF1xb >+oWcWpbnY+0jsUYUAxorbesw0JHFx+WLxfSbjj91FdGFyPUGLGho4rPQyJnWdI4vn >+Ddeuy3aQQU696MxIKzbwDEsx9kVE6ffiucedCe1qYUvYoB+pa0mEOw6opo88ZGmh >+ApujO5G9POG0ZUCYXfCn >+=PT0u >+-----END PGP SIGNATURE----- >Index: SOURCES/mutt-1.5.5.1-no-sgid.patch >=================================================================== >--- SOURCES/mutt-1.5.5.1-no-sgid.patch (revision 800495) >+++ SOURCES/mutt-1.5.5.1-no-sgid.patch (working copy) >@@ -1,14 +0,0 @@ >---- Makefile.am 2008-05-17 20:04:24.000000000 +0200 >-+++ Makefile.am.oden 2008-12-15 16:05:32.000000000 +0100 >-@@ -136,11 +136,6 @@ >- rm -f $(DESTDIR)$(bindir)/mutt.dotlock ; \ >- ln -sf $(DESTDIR)$(bindir)/mutt_dotlock $(DESTDIR)$(bindir)/mutt.dotlock ; \ >- fi >-- if test -f $(DESTDIR)$(bindir)/mutt_dotlock && test x@DOTLOCK_GROUP@ != x ; then \ >-- chgrp @DOTLOCK_GROUP@ $(DESTDIR)$(bindir)/mutt_dotlock && \ >-- chmod @DOTLOCK_PERMISSION@ $(DESTDIR)$(bindir)/mutt_dotlock || \ >-- { echo "Can't fix mutt_dotlock's permissions!" >&2 ; exit 1 ; } \ >-- fi >- >- install-data-local: >- $(srcdir)/mkinstalldirs $(DESTDIR)$(sysconfdir) >Index: SOURCES/mutt-1.5.5.1-xterm-title.patch >=================================================================== >--- SOURCES/mutt-1.5.5.1-xterm-title.patch (revision 800495) >+++ SOURCES/mutt-1.5.5.1-xterm-title.patch (working copy) >@@ -1,149 +0,0 @@ >-diff -Naurp mutt-1.5.18/curs_main.c mutt-1.5.18.oden/curs_main.c >---- mutt-1.5.18/curs_main.c 2008-12-15 16:13:47.000000000 +0100 >-+++ mutt-1.5.18.oden/curs_main.c 2008-12-15 16:13:31.000000000 +0100 >-@@ -117,6 +117,19 @@ static const char *No_visible = N_("No v >- >- extern size_t UngetCount; >- >-+#define ASCII_CTRL_G 0x07 >-+#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b >-+ >-+static void set_xterm_title_bar(char *title) >-+{ >-+fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G); >-+} >-+ >-+static void set_xterm_icon_name(char *name) >-+{ >-+fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G); >-+} >-+ >- void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num) >- { >- format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX; >-@@ -598,6 +611,13 @@ int mutt_index_menu (void) >- SETCOLOR (MT_COLOR_NORMAL); >- BKGDSET (MT_COLOR_NORMAL); >- menu->redraw &= ~REDRAW_STATUS; >-+ if (option(OPTXTERMSETTITLES)) >-+ { >-+ menu_status_line (buf, sizeof (buf), menu, NONULL (XtermTitle)); >-+ set_xterm_title_bar(buf); >-+ menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon)); >-+ set_xterm_icon_name(buf); >-+ } >- } >- >- menu->redraw = 0; >-diff -Naurp mutt-1.5.18/globals.h mutt-1.5.18.oden/globals.h >---- mutt-1.5.18/globals.h 2008-12-15 16:13:47.000000000 +0100 >-+++ mutt-1.5.18.oden/globals.h 2008-12-15 16:13:31.000000000 +0100 >-@@ -154,6 +154,8 @@ WHERE char *Tempdir; >- WHERE char *Tochars; >- WHERE char *Username; >- WHERE char *Visual; >-+WHERE char *XtermTitle; >-+WHERE char *XtermIcon; >- >- WHERE char *CurrentFolder; >- WHERE char *LastFolder; >-diff -Naurp mutt-1.5.18/init.c mutt-1.5.18.oden/init.c >---- mutt-1.5.18/init.c 2008-12-15 16:13:47.000000000 +0100 >-+++ mutt-1.5.18.oden/init.c 2008-12-15 16:13:31.000000000 +0100 >-@@ -1811,6 +1811,17 @@ static int parse_set (BUFFER *tmp, BUFFE >- toggle_option (MuttVars[idx].data); >- else >- set_option (MuttVars[idx].data); >-+ >-+ /* sanity check for xterm */ >-+ if ((mutt_strcmp (MuttVars[idx].option, "xterm_set_titles") == 0) && option >-+ (OPTXTERMSETTITLES)) >-+ { >-+ char *ep = getenv ("TERM"); >-+ /* Make sure that the terminal can take the control codes */ >-+ if (ep == NULL) unset_option (MuttVars[idx].data); >-+ else if (mutt_strcasecmp (ep, "xterm") != 0) unset_option (MuttVars[idx]. >-+data); >-+ } >- } >- else if (myvar || DTYPE (MuttVars[idx].type) == DT_STR || >- DTYPE (MuttVars[idx].type) == DT_PATH || >-diff -Naurp mutt-1.5.18/init.h mutt-1.5.18.oden/init.h >---- mutt-1.5.18/init.h 2008-12-15 16:13:47.000000000 +0100 >-+++ mutt-1.5.18.oden/init.h 2008-12-15 16:13:31.000000000 +0100 >-@@ -3286,6 +3286,27 @@ struct option_t MuttVars[] = { >- ** name of original article author) to article that followuped to newsgroup. >- */ >- #endif >-+ {"xterm_icon", DT_STR, R_BOTH, UL &XtermIcon, UL "M%?n?AIL&ail?"}, >-+ /* >-+ ** .pp >-+ ** Controls the format of the icon title, as long as xterm_set_titles >-+ ** is enabled. This string is identical in formatting to the one used by >-+ ** ``$$status_format''. >-+ */ >-+ {"xterm_set_titles", DT_BOOL, R_BOTH, OPTXTERMSETTITLES, 0}, >-+ /* >-+ ** .pp >-+ ** Controls whether mutt sets the xterm title bar and icon name >-+ ** (as long as you're in an appropriate terminal). The default must >-+ ** be off to force in the validity checking. >-+ */ >-+ {"xterm_title", DT_STR, R_BOTH, UL &XtermTitle, UL "Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?"}, >-+ /* >-+ ** .pp >-+ ** Controls the format of the title bar of the xterm provided that >-+ ** xterm_set_titles has been set. This string is identical in formatting >-+ ** to the one used by ``$$status_format''. >-+ */ >- /*--*/ >- { NULL } >- }; >-diff -Naurp mutt-1.5.18/mutt.h mutt-1.5.18.oden/mutt.h >---- mutt-1.5.18/mutt.h 2008-12-15 16:13:47.000000000 +0100 >-+++ mutt-1.5.18.oden/mutt.h 2008-12-15 16:13:31.000000000 +0100 >-@@ -477,6 +477,7 @@ enum >- OPTWRAPSEARCH, >- OPTWRITEBCC, /* write out a bcc header? */ >- OPTXMAILER, >-+ OPTXTERMSETTITLES, >- >- OPTCRYPTUSEGPGME, >- OPTCRYPTUSEPKA, >-diff -Naurp mutt-1.5.18/pager.c mutt-1.5.18.oden/pager.c >---- mutt-1.5.18/pager.c 2008-12-15 16:13:47.000000000 +0100 >-+++ mutt-1.5.18.oden/pager.c 2008-12-15 16:13:31.000000000 +0100 >-@@ -90,6 +90,19 @@ static HEADER *OldHdr = NULL; >- break; \ >- } >- >-+#define ASCII_CTRL_G 0x07 >-+#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b >-+ >-+static void set_xterm_title_bar(char *title) >-+{ >-+ fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G); >-+} >-+ >-+static void set_xterm_icon_name(char *name) >-+{ >-+ fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G); >-+} >-+ >- struct q_class_t >- { >- int length; >-@@ -1790,6 +1803,13 @@ mutt_pager (const char *banner, const ch >- mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner); >- BKGDSET (MT_COLOR_NORMAL); >- SETCOLOR (MT_COLOR_NORMAL); >-+ if (option(OPTXTERMSETTITLES)) >-+ { >-+ menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermTitle)); >-+ set_xterm_title_bar(buffer); >-+ menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermIcon)); >-+ set_xterm_icon_name(buffer); >-+ } >- } >- >- if ((redraw & REDRAW_INDEX) && index) >Index: SOURCES/patch-1.5.20.rr.compressed >=================================================================== >--- SOURCES/patch-1.5.20.rr.compressed (revision 800495) >+++ SOURCES/patch-1.5.20.rr.compressed (working copy) >@@ -1,1303 +0,0 @@ >-diff -udprP mutt-1.5.20.orig/compress.c mutt-1.5.20/compress.c >---- mutt-1.5.20.orig/compress.c 1970-01-01 03:00:00.000000000 +0300 >-+++ mutt-1.5.20/compress.c 2009-06-15 20:31:21.000000000 +0300 >-@@ -0,0 +1,490 @@ >-+/* >-+ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com> >-+ * >-+ * This program is free software; you can redistribute it and/or modify >-+ * it under the terms of the GNU General Public License as published by >-+ * the Free Software Foundation; either version 2 of the License, or >-+ * (at your option) any later version. >-+ * >-+ * This program is distributed in the hope that it will be useful, >-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-+ * GNU General Public License for more details. >-+ * >-+ * You should have received a copy of the GNU General Public License >-+ * along with this program; if not, write to the Free Software >-+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >-+ */ >-+ >-+#if HAVE_CONFIG_H >-+# include "config.h" >-+#endif >-+ >-+#include "mutt.h" >-+ >-+#ifdef USE_COMPRESSED >-+ >-+#include "mx.h" >-+#include "mailbox.h" >-+#include "mutt_curses.h" >-+ >-+#include <errno.h> >-+#include <string.h> >-+#include <unistd.h> >-+#include <sys/stat.h> >-+ >-+typedef struct >-+{ >-+ const char *close; /* close-hook command */ >-+ const char *open; /* open-hook command */ >-+ const char *append; /* append-hook command */ >-+ off_t size; /* size of real folder */ >-+} COMPRESS_INFO; >-+ >-+char echo_cmd[HUGE_STRING]; >-+ >-+/* parameters: >-+ * ctx - context to lock >-+ * excl - exclusive lock? >-+ * retry - should retry if unable to lock? >-+ */ >-+int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry) >-+{ >-+ int r; >-+ >-+ if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0) >-+ ctx->locked = 1; >-+ else if (retry && !excl) >-+ { >-+ ctx->readonly = 1; >-+ return 0; >-+ } >-+ >-+ return (r); >-+} >-+ >-+void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp) >-+{ >-+ if (ctx->locked) >-+ { >-+ fflush (fp); >-+ >-+ mx_unlock_file (ctx->realpath, fileno (fp), 1); >-+ ctx->locked = 0; >-+ } >-+} >-+ >-+static int is_new (const char *path) >-+{ >-+ return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0; >-+} >-+ >-+static const char* find_compress_hook (int type, const char *path) >-+{ >-+ const char* c = mutt_find_hook (type, path); >-+ return (!c || !*c) ? NULL : c; >-+} >-+ >-+int mutt_can_read_compressed (const char *path) >-+{ >-+ return find_compress_hook (M_OPENHOOK, path) ? 1 : 0; >-+} >-+ >-+/* if the file is new, we really do not append, but create, and so use >-+ * close-hook, and not append-hook >-+ */ >-+static const char* get_append_command (const char *path, const CONTEXT* ctx) >-+{ >-+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; >-+ return (is_new (path)) ? ci->close : ci->append; >-+} >-+ >-+int mutt_can_append_compressed (const char *path) >-+{ >-+ int magic; >-+ >-+ if (is_new (path)) >-+ return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0); >-+ >-+ magic = mx_get_magic (path); >-+ >-+ if (magic != 0 && magic != M_COMPRESSED) >-+ return 0; >-+ >-+ return (find_compress_hook (M_APPENDHOOK, path) >-+ || (find_compress_hook (M_OPENHOOK, path) >-+ && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0; >-+} >-+ >-+/* open a compressed mailbox */ >-+static COMPRESS_INFO *set_compress_info (CONTEXT *ctx) >-+{ >-+ COMPRESS_INFO *ci; >-+ >-+ /* Now lets uncompress this thing */ >-+ ci = safe_malloc (sizeof (COMPRESS_INFO)); >-+ ctx->compressinfo = (void*) ci; >-+ ci->append = find_compress_hook (M_APPENDHOOK, ctx->path); >-+ ci->open = find_compress_hook (M_OPENHOOK, ctx->path); >-+ ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path); >-+ return ci; >-+} >-+ >-+static void set_path (CONTEXT* ctx) >-+{ >-+ char tmppath[_POSIX_PATH_MAX]; >-+ >-+ /* Setup the right paths */ >-+ ctx->realpath = ctx->path; >-+ >-+ /* Uncompress to /tmp */ >-+ mutt_mktemp (tmppath, sizeof(tmppath)); >-+ ctx->path = safe_malloc (strlen (tmppath) + 1); >-+ strcpy (ctx->path, tmppath); >-+} >-+ >-+static int get_size (const char* path) >-+{ >-+ struct stat sb; >-+ if (stat (path, &sb) != 0) >-+ return 0; >-+ return (sb.st_size); >-+} >-+ >-+static void store_size (CONTEXT* ctx) >-+{ >-+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; >-+ ci->size = get_size (ctx->realpath); >-+} >-+ >-+static const char * >-+compresshook_format_str (char *dest, size_t destlen, size_t col, char op, >-+ const char *src, const char *fmt, const char *ifstring, >-+ const char *elsestring, unsigned long data, >-+ format_flag flags) >-+{ >-+ char tmp[SHORT_STRING]; >-+ >-+ CONTEXT *ctx = (CONTEXT *) data; >-+ switch (op) >-+ { >-+ case 'f': >-+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >-+ snprintf (dest, destlen, tmp, ctx->realpath); >-+ break; >-+ case 't': >-+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >-+ snprintf (dest, destlen, tmp, ctx->path); >-+ break; >-+ } >-+ return (src); >-+} >-+ >-+/* check that the command has both %f and %t >-+ * 0 means OK, -1 means error >-+ */ >-+int mutt_test_compress_command (const char* cmd) >-+{ >-+ return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1; >-+} >-+ >-+static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx) >-+{ >-+ char expanded[_POSIX_PATH_MAX]; >-+ mutt_FormatString (expanded, sizeof (expanded), 0, cmd, compresshook_format_str, >-+ (unsigned long) ctx, 0); >-+ return safe_strdup (expanded); >-+} >-+ >-+int mutt_check_mailbox_compressed (CONTEXT* ctx) >-+{ >-+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; >-+ if (ci->size != get_size (ctx->realpath)) >-+ { >-+ FREE (&ctx->compressinfo); >-+ FREE (&ctx->realpath); >-+ mutt_error _("Mailbox was corrupted!"); >-+ return (-1); >-+ } >-+ return (0); >-+} >-+ >-+int mutt_open_read_compressed (CONTEXT *ctx) >-+{ >-+ char *cmd; >-+ FILE *fp; >-+ int rc; >-+ >-+ COMPRESS_INFO *ci = set_compress_info (ctx); >-+ if (!ci->open) { >-+ ctx->magic = 0; >-+ FREE (ctx->compressinfo); >-+ return (-1); >-+ } >-+ if (!ci->close || access (ctx->path, W_OK) != 0) >-+ ctx->readonly = 1; >-+ >-+ set_path (ctx); >-+ store_size (ctx); >-+ >-+ if (!ctx->quiet) >-+ mutt_message (_("Decompressing %s..."), ctx->realpath); >-+ >-+ cmd = get_compression_cmd (ci->open, ctx); >-+ if (cmd == NULL) >-+ return (-1); >-+ dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd)); >-+ >-+ if ((fp = fopen (ctx->realpath, "r")) == NULL) >-+ { >-+ mutt_perror (ctx->realpath); >-+ FREE (&cmd); >-+ return (-1); >-+ } >-+ mutt_block_signals (); >-+ if (mbox_lock_compressed (ctx, fp, 0, 1) == -1) >-+ { >-+ fclose (fp); >-+ mutt_unblock_signals (); >-+ mutt_error _("Unable to lock mailbox!"); >-+ FREE (&cmd); >-+ return (-1); >-+ } >-+ >-+ endwin (); >-+ fflush (stdout); >-+ sprintf(echo_cmd,_("echo Decompressing %s..."),ctx->realpath); >-+ mutt_system(echo_cmd); >-+ rc = mutt_system (cmd); >-+ mbox_unlock_compressed (ctx, fp); >-+ mutt_unblock_signals (); >-+ fclose (fp); >-+ >-+ if (rc) >-+ { >-+ mutt_any_key_to_continue (NULL); >-+ ctx->magic = 0; >-+ FREE (ctx->compressinfo); >-+ mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd); >-+ } >-+ FREE (&cmd); >-+ if (rc) >-+ return (-1); >-+ >-+ if (mutt_check_mailbox_compressed (ctx)) >-+ return (-1); >-+ >-+ ctx->magic = mx_get_magic (ctx->path); >-+ >-+ return (0); >-+} >-+ >-+void restore_path (CONTEXT* ctx) >-+{ >-+ FREE (&ctx->path); >-+ ctx->path = ctx->realpath; >-+} >-+ >-+/* remove the temporary mailbox */ >-+void remove_file (CONTEXT* ctx) >-+{ >-+ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF) >-+ remove (ctx->path); >-+} >-+ >-+int mutt_open_append_compressed (CONTEXT *ctx) >-+{ >-+ FILE *fh; >-+ COMPRESS_INFO *ci = set_compress_info (ctx); >-+ >-+ if (!get_append_command (ctx->path, ctx)) >-+ { >-+ if (ci->open && ci->close) >-+ return (mutt_open_read_compressed (ctx)); >-+ >-+ ctx->magic = 0; >-+ FREE (&ctx->compressinfo); >-+ return (-1); >-+ } >-+ >-+ set_path (ctx); >-+ >-+ ctx->magic = DefaultMagic; >-+ >-+ if (!is_new (ctx->realpath)) >-+ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF) >-+ if ((fh = fopen (ctx->path, "w"))) >-+ fclose (fh); >-+ /* No error checking - the parent function will catch it */ >-+ >-+ return (0); >-+} >-+ >-+/* close a compressed mailbox */ >-+void mutt_fast_close_compressed (CONTEXT *ctx) >-+{ >-+ dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n", >-+ ctx->path)); >-+ >-+ if (ctx->compressinfo) >-+ { >-+ if (ctx->fp) >-+ fclose (ctx->fp); >-+ ctx->fp = NULL; >-+ /* if the folder was removed, remove the gzipped folder too */ >-+ if (access (ctx->path, F_OK) != 0 && ! option (OPTSAVEEMPTY)) >-+ remove (ctx->realpath); >-+ else >-+ remove_file (ctx); >-+ >-+ restore_path (ctx); >-+ FREE (&ctx->compressinfo); >-+ } >-+} >-+ >-+/* return 0 on success, -1 on failure */ >-+int mutt_sync_compressed (CONTEXT* ctx) >-+{ >-+ char *cmd; >-+ int rc = 0; >-+ FILE *fp; >-+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; >-+ >-+ if (!ctx->quiet) >-+ mutt_message (_("Compressing %s..."), ctx->realpath); >-+ >-+ cmd = get_compression_cmd (ci->close, ctx); >-+ if (cmd == NULL) >-+ return (-1); >-+ >-+ if ((fp = fopen (ctx->realpath, "a")) == NULL) >-+ { >-+ mutt_perror (ctx->realpath); >-+ FREE (&cmd); >-+ return (-1); >-+ } >-+ mutt_block_signals (); >-+ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) >-+ { >-+ fclose (fp); >-+ mutt_unblock_signals (); >-+ mutt_error _("Unable to lock mailbox!"); >-+ >-+ store_size (ctx); >-+ >-+ FREE (&cmd); >-+ return (-1); >-+ } >-+ >-+ dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd)); >-+ >-+ endwin (); >-+ fflush (stdout); >-+ sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath); >-+ mutt_system(echo_cmd); >-+ if (mutt_system (cmd)) >-+ { >-+ mutt_any_key_to_continue (NULL); >-+ mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path); >-+ rc = -1; >-+ } >-+ >-+ mbox_unlock_compressed (ctx, fp); >-+ mutt_unblock_signals (); >-+ fclose (fp); >-+ >-+ FREE (&cmd); >-+ >-+ store_size (ctx); >-+ >-+ return (rc); >-+} >-+ >-+int mutt_slow_close_compressed (CONTEXT *ctx) >-+{ >-+ FILE *fp; >-+ const char *append; >-+ char *cmd; >-+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; >-+ >-+ dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n", >-+ ctx->path)); >-+ >-+ if (! (ctx->append >-+ && ((append = get_append_command (ctx->realpath, ctx)) >-+ || (append = ci->close)))) >-+ { /* if we can not or should not append, >-+ * we only have to remove the compressed info, because sync was already >-+ * called >-+ */ >-+ mutt_fast_close_compressed (ctx); >-+ return (0); >-+ } >-+ >-+ if (ctx->fp) >-+ fclose (ctx->fp); >-+ ctx->fp = NULL; >-+ >-+ if (!ctx->quiet) >-+ { >-+ if (append == ci->close) >-+ mutt_message (_("Compressing %s..."), ctx->realpath); >-+ else >-+ mutt_message (_("Compressed-appending to %s..."), ctx->realpath); >-+ } >-+ >-+ cmd = get_compression_cmd (append, ctx); >-+ if (cmd == NULL) >-+ return (-1); >-+ >-+ if ((fp = fopen (ctx->realpath, "a")) == NULL) >-+ { >-+ mutt_perror (ctx->realpath); >-+ FREE (&cmd); >-+ return (-1); >-+ } >-+ mutt_block_signals (); >-+ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) >-+ { >-+ fclose (fp); >-+ mutt_unblock_signals (); >-+ mutt_error _("Unable to lock mailbox!"); >-+ FREE (&cmd); >-+ return (-1); >-+ } >-+ >-+ dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd)); >-+ >-+ endwin (); >-+ fflush (stdout); >-+ >-+ if (append == ci->close) >-+ sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath); >-+ else >-+ sprintf(echo_cmd,_("echo Compressed-appending to %s..."), ctx->realpath); >-+ mutt_system(echo_cmd); >-+ >-+ if (mutt_system (cmd)) >-+ { >-+ mutt_any_key_to_continue (NULL); >-+ mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"), >-+ ctx->path); >-+ FREE (&cmd); >-+ mbox_unlock_compressed (ctx, fp); >-+ mutt_unblock_signals (); >-+ fclose (fp); >-+ return (-1); >-+ } >-+ >-+ mbox_unlock_compressed (ctx, fp); >-+ mutt_unblock_signals (); >-+ fclose (fp); >-+ remove_file (ctx); >-+ restore_path (ctx); >-+ FREE (&cmd); >-+ FREE (&ctx->compressinfo); >-+ >-+ return (0); >-+} >-+ >-+#endif /* USE_COMPRESSED */ >-diff -udprP mutt-1.5.20.orig/compress.h mutt-1.5.20/compress.h >---- mutt-1.5.20.orig/compress.h 1970-01-01 03:00:00.000000000 +0300 >-+++ mutt-1.5.20/compress.h 2009-06-15 20:31:21.000000000 +0300 >-@@ -0,0 +1,27 @@ >-+/* >-+ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com> >-+ * >-+ * This program is free software; you can redistribute it and/or modify >-+ * it under the terms of the GNU General Public License as published by >-+ * the Free Software Foundation; either version 2 of the License, or >-+ * (at your option) any later version. >-+ * >-+ * This program is distributed in the hope that it will be useful, >-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-+ * GNU General Public License for more details. >-+ * >-+ * You should have received a copy of the GNU General Public License >-+ * along with this program; if not, write to the Free Software >-+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >-+ */ >-+ >-+int mutt_can_read_compressed (const char *); >-+int mutt_can_append_compressed (const char *); >-+int mutt_open_read_compressed (CONTEXT *); >-+int mutt_open_append_compressed (CONTEXT *); >-+int mutt_slow_close_compressed (CONTEXT *); >-+int mutt_sync_compressed (CONTEXT *); >-+int mutt_test_compress_command (const char *); >-+int mutt_check_mailbox_compressed (CONTEXT *); >-+void mutt_fast_close_compressed (CONTEXT *); >-diff -udprP mutt-1.5.20.orig/config.h.in mutt-1.5.20/config.h.in >---- mutt-1.5.20.orig/config.h.in 2009-06-09 09:51:15.000000000 +0300 >-+++ mutt-1.5.20/config.h.in 2009-06-15 20:31:21.000000000 +0300 >-@@ -540,6 +540,9 @@ >- >- /* Define to enable Sun mailtool attachments support. */ >- #undef SUN_ATTACHMENT >-+ >-+/* The compressed mailboxes support */ >-+#undef USE_COMPRESSED >- >- /* Define to use dotlocking for mailboxes. */ >- #undef USE_DOTLOCK >-diff -udprP mutt-1.5.20.orig/configure mutt-1.5.20/configure >---- mutt-1.5.20.orig/configure 2009-06-09 09:50:42.000000000 +0300 >-+++ mutt-1.5.20/configure 2009-06-15 20:31:21.000000000 +0300 >-@@ -1434,6 +1434,7 @@ Optional Features: >- --disable-warnings Turn off compiler warnings (not recommended) >- --enable-nfs-fix Work around an NFS with broken attributes caching >- --enable-mailtool Enable Sun mailtool attachments support >-+ --enable-compressed Enable compressed folders support >- --enable-locales-fix The result of isprint() is unreliable >- --enable-exact-address Enable regeneration of email addresses >- --enable-hcache Enable header caching >-@@ -8650,6 +8651,18 @@ $as_echo "$mutt_cv_regex_broken" >&6; } >- fi >- fi >- >-+ >-+# Check whether --enable-compressed or --disable-compressed was given. >-+if test "${enable_compressed+set}" = set; then >-+ enableval="$enable_compressed" >-+ if test x$enableval = xyes; then >-+ cat >> confdefs.h <<\EOF >-+#define USE_COMPRESSED 1 >-+EOF >-+ >-+ fi >-+fi >-+ >- if test $mutt_cv_regex = yes; then >- >- $as_echo "#define USE_GNU_REGEX 1" >>confdefs.h >-diff -udprP mutt-1.5.20.orig/configure.ac mutt-1.5.20/configure.ac >---- mutt-1.5.20.orig/configure.ac 2009-06-09 09:50:33.000000000 +0300 >-+++ mutt-1.5.20/configure.ac 2009-06-15 20:31:21.000000000 +0300 >-@@ -806,6 +806,11 @@ AC_ARG_ENABLE(mailtool, AC_HELP_STRING([ >- AC_DEFINE(SUN_ATTACHMENT,1,[ Define to enable Sun mailtool attachments support. ]) >- fi]) >- >-+AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]), >-+ [if test x$enableval = xyes; then >-+ AC_DEFINE(USE_COMPRESSED,1,[ Define to enable compressed folders support. ]) >-+ fi]) >-+ >- AC_ARG_ENABLE(locales-fix, AC_HELP_STRING([--enable-locales-fix], [The result of isprint() is unreliable]), >- [if test x$enableval = xyes; then >- AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ]) >-diff -udprP mutt-1.5.20.orig/curs_main.c mutt-1.5.20/curs_main.c >---- mutt-1.5.20.orig/curs_main.c 2009-06-14 05:48:36.000000000 +0300 >-+++ mutt-1.5.20/curs_main.c 2009-06-15 20:31:21.000000000 +0300 >-@@ -1133,6 +1133,11 @@ int mutt_index_menu (void) >- { >- int check; >- >-+#ifdef USE_COMPRESSED >-+ if (Context->compressinfo && Context->realpath) >-+ mutt_str_replace (&LastFolder, Context->realpath); >-+ else >-+#endif >- mutt_str_replace (&LastFolder, Context->path); >- oldcount = Context ? Context->msgcount : 0; >- >-diff -udprP mutt-1.5.20.orig/doc/Makefile.am mutt-1.5.20/doc/Makefile.am >---- mutt-1.5.20.orig/doc/Makefile.am 2009-06-01 05:23:14.000000000 +0300 >-+++ mutt-1.5.20/doc/Makefile.am 2009-06-15 20:33:19.000000000 +0300 >-@@ -32,7 +32,8 @@ EXTRA_DIST = dotlock.man \ >- >- CHUNKED_DOCFILES = index.html intro.html gettingstarted.html \ >- configuration.html mimesupport.html advancedusage.html \ >-- optionalfeatures.html security.html tuning.html reference.html miscellany.html >-+ optionalfeatures.html security.html tuning.html reference.html miscellany.html \ >-+ compressed-folders.html >- >- HTML_DOCFILES = manual.html $(CHUNKED_DOCFILES) >- >-diff -udprP mutt-1.5.20.orig/doc/Makefile.in mutt-1.5.20/doc/Makefile.in >---- mutt-1.5.20.orig/doc/Makefile.in 2009-06-09 09:50:43.000000000 +0300 >-+++ mutt-1.5.20/doc/Makefile.in 2009-06-15 20:34:01.000000000 +0300 >-@@ -237,7 +237,8 @@ EXTRA_DIST = dotlock.man \ >- >- CHUNKED_DOCFILES = index.html intro.html gettingstarted.html \ >- configuration.html mimesupport.html advancedusage.html \ >-- optionalfeatures.html security.html tuning.html reference.html miscellany.html >-+ optionalfeatures.html security.html tuning.html reference.html miscellany.html \ >-+ compressed-folders.html >- >- HTML_DOCFILES = manual.html $(CHUNKED_DOCFILES) >- BUILT_DISTFILES = stamp-doc-xml stamp-doc-chunked manual.txt $(HTML_DOCFILES) >-diff -udprP mutt-1.5.20.orig/doc/manual.xml.head mutt-1.5.20/doc/manual.xml.head >---- mutt-1.5.20.orig/doc/manual.xml.head 2009-05-30 20:20:08.000000000 +0300 >-+++ mutt-1.5.20/doc/manual.xml.head 2009-06-15 20:31:21.000000000 +0300 >-@@ -5163,6 +5163,24 @@ patterns: >- () — logical grouping operator >- </para> >- </listitem> >-+<listitem> >-+ >-+<para> >-+<link linkend="open-hook">open-hook</link> >-+</para> >-+</listitem> >-+<listitem> >-+ >-+<para> >-+<link linkend="close-hook">close-hook</link> >-+</para> >-+</listitem> >-+<listitem> >-+ >-+<para> >-+<link linkend="append-hook">append-hook</link> >-+</para> >-+</listitem> >- >- </itemizedlist> >- >-@@ -6094,6 +6112,254 @@ this selection. Highest priority has the >- >- </chapter> >- >-+<chapter id="compressed-folders"> >-+<title>Compressed folders Support (OPTIONAL)</title> >-+ >-+<para> >-+If Mutt was compiled with compressed folders support (by running the >-+<emphasis>configure</emphasis> script with the >-+<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders >-+stored in an arbitrary format, provided that the user has a script to >-+convert from/to this format to one of the accepted. >-+</para> >-+ >-+<para> >-+The most common use is to open compressed archived folders e.g. with >-+gzip. >-+</para> >-+ >-+<para> >-+In addition, the user can provide a script that gets a folder in an >-+accepted format and appends its context to the folder in the >-+user-defined format, which may be faster than converting the entire >-+folder to the accepted format, appending to it and converting back to >-+the user-defined format. >-+</para> >-+ >-+<para> >-+There are three hooks defined >-+(<link linkend="open-hook">open-hook</link>, >-+<link linkend="close-hook">close-hook</link> and >-+<link linkend="append-hook">append-hook</link>) which define commands >-+to uncompress and compress a folder and to append messages to an >-+existing compressed folder respectively. >-+</para> >-+ >-+<para> >-+For example: >-+ >-+<screen> >-+open-hook \\.gz$ "gzip -cd %f > %t" >-+close-hook \\.gz$ "gzip -c %t > %f" >-+append-hook \\.gz$ "gzip -c %t >> %f" >-+</screen> >-+</para> >-+ >-+<para> >-+You do not have to specify all of the commands. If you omit >-+<link linkend="append-hook">append-hook</link>, the folder will be open >-+and closed again each time you will add to it. If you omit >-+<link linkend="close-hook">close-hook</link> (or give empty command), >-+the folder will be open in the mode. If you specify >-+<link linkend="append-hook">append-hook</link> though you'll be able to >-+append to the folder. >-+</para> >-+ >-+<para> >-+Note that Mutt will only try to use hooks if the file is not in one of >-+the accepted formats. In particular, if the file is empty, mutt >-+supposes it is not compressed. This is important because it allows the >-+use of programs that do not have well defined extensions. Just use >-+``.'' as a regexp. But this may be surprising if your compressing >-+script produces empty files. In this situation, unset >-+<link linkend="save-empty">$save_empty</link>, so that >-+the compressed file will be removed if you delete all of the messages. >-+</para> >-+ >-+<sect1 id="open-hook"> >-+<title>Open a compressed mailbox for reading</title> >-+ >-+<para> >-+Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis> >-+</para> >-+ >-+<para> >-+The <emphasis>command</emphasis> is the command that can be used for >-+opening the folders whose names match <emphasis>regexp</emphasis>. >-+</para> >-+ >-+<para> >-+The <emphasis>command</emphasis> string is the printf-like format >-+string, and it should accept two parameters: %f, which is >-+replaced with the (compressed) folder name, and %t which is >-+replaced with the name of the temporary folder to which to write. >-+</para> >-+ >-+<para> >-+%f and %t can be repeated any number of times in the >-+command string, and all of the entries are replaced with the >-+appropriate folder name. In addition, %% is replaced by >-+%, as in printf, and any other %anything is left as is. >-+</para> >-+ >-+<para> >-+The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis> >-+remove the original compressed file. The <emphasis>command</emphasis> >-+should return non-zero exit status if it fails, so mutt knows >-+something's wrong. >-+</para> >-+ >-+<para> >-+Example: >-+ >-+<screen> >-+open-hook \\.gz$ "gzip -cd %f > %t" >-+</screen> >-+</para> >-+ >-+<para> >-+If the <emphasis>command</emphasis> is empty, this operation is >-+disabled for this file type. >-+</para> >-+ >-+</sect1> >-+ >-+<sect1 id="close-hook"> >-+<title>Write a compressed mailbox</title> >-+ >-+<para> >-+Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis> >-+</para> >-+ >-+<para> >-+This is used to close the folder that was open with the >-+<link linkend="open-hook">open-hook</link> command after some changes >-+were made to it. >-+</para> >-+ >-+<para> >-+The <emphasis>command</emphasis> string is the command that can be >-+used for closing the folders whose names match <emphasis>regexp</emphasis>. >-+It has the same format as in the <link linkend="open-hook">open-hook</link> >-+command. Temporary folder in this case is the folder previously >-+produced by the <link linkend="open-hook">open-hook</link> command. >-+</para> >-+ >-+<para> >-+The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis> >-+remove the decompressed file. The <emphasis>command</emphasis> should >-+return non-zero exit status if it fails, so mutt knows something's >-+wrong. >-+</para> >-+ >-+<para> >-+Example: >-+ >-+<screen> >-+close-hook \\.gz$ "gzip -c %t > %f" >-+</screen> >-+</para> >-+ >-+<para> >-+If the <emphasis>command</emphasis> is empty, this operation is >-+disabled for this file type, and the file can only be open in the >-+readonly mode. >-+</para> >-+ >-+<para> >-+<link linkend="close-hook">close-hook</link> is not called when you >-+exit from the folder if the folder was not changed. >-+</para> >-+ >-+</sect1> >-+ >-+<sect1 id="append-hook"> >-+<title>Append a message to a compressed mailbox</title> >-+ >-+<para> >-+Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis> >-+</para> >-+ >-+<para> >-+This command is used for saving to an existing compressed folder. >-+The <emphasis>command</emphasis> is the command that can be used for >-+appending to the folders whose names match <emphasis>regexp</emphasis>. >-+It has the same format as in the <link linkend="open-hook">open-hook</link> >-+command. The temporary folder in this case contains the messages that >-+are being appended. >-+</para> >-+ >-+<para> >-+The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis> >-+remove the decompressed file. The <emphasis>command</emphasis> should >-+return non-zero exit status if it fails, so mutt knows something's >-+wrong. >-+</para> >-+ >-+<para> >-+Example: >-+ >-+<screen> >-+append-hook \\.gz$ "gzip -c %t >> %f" >-+</screen> >-+</para> >-+ >-+<para> >-+When <link linkend="append-hook">append-hook</link> is used, the folder >-+is not opened, which saves time, but this means that we can not find >-+out what the folder type is. Thus the default >-+(<link linkend="mbox-type">$mbox_type</link>) type is >-+always supposed (i.e. this is the format used for the temporary >-+folder). >-+</para> >-+ >-+<para> >-+If the file does not exist when you save to it, >-+<link linkend="close-hook">close-hook</link> is called, and not >-+<link linkend="append-hook">append-hook</link>. >-+<link linkend="append-hook">append-hook</link> is only for appending >-+to existing folders. >-+</para> >-+ >-+<para> >-+If the <emphasis>command</emphasis> is empty, this operation is >-+disabled for this file type. In this case, the folder will be open and >-+closed again (using <link linkend="open-hook">open-hook</link> and >-+<link linkend="close-hook">close-hook</link> respectively) each time >-+you will add to it. >-+</para> >-+ >-+</sect1> >-+ >-+<sect1> >-+<title>Encrypted folders</title> >-+ >-+<para> >-+The compressed folders support can also be used to handle encrypted >-+folders. If you want to encrypt a folder with PGP, you may want to use >-+the following hooks: >-+ >-+<screen> >-+open-hook \\.pgp$ "pgp -f < %f > %t" >-+close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f" >-+</screen> >-+</para> >-+ >-+<para> >-+Please note, that PGP does not support appending to an encrypted >-+folder, so there is no append-hook defined. >-+</para> >-+ >-+<para> >-+<emphasis role="bold">Note:</emphasis> the folder is temporary stored >-+decrypted in the /tmp directory, where it can be read by your system >-+administrator. So think about the security aspects of this. >-+</para> >-+ >-+</sect1> >-+ >-+</chapter> >-+ >- <chapter id="mimesupport"> >- <title>Mutt's MIME Support</title> >- >-@@ -8428,6 +8694,18 @@ The following are the commands understoo >- >- <listitem> >- <cmdsynopsis> >-+<command><link linkend="append-hook">append-hook</link></command> >-+<arg choice="plain"> >-+<replaceable class="parameter">pattern</replaceable> >-+</arg> >-+<arg choice="plain"> >-+<replaceable class="parameter">command</replaceable> >-+</arg> >-+</cmdsynopsis> >-+</listitem> >-+ >-+<listitem> >-+<cmdsynopsis> >- <command><link linkend="auto-view">auto_view</link></command> >- <arg choice="plain"> >- <replaceable>mimetype</replaceable> >-@@ -8489,6 +8755,18 @@ The following are the commands understoo >- >- <listitem> >- <cmdsynopsis> >-+<command><link linkend="close-hook">close-hook</link></command> >-+<arg choice="plain"> >-+<replaceable class="parameter">pattern</replaceable> >-+</arg> >-+<arg choice="plain"> >-+<replaceable class="parameter">command</replaceable> >-+</arg> >-+</cmdsynopsis> >-+</listitem> >-+ >-+<listitem> >-+<cmdsynopsis> >- <command><link linkend="color">color</link></command> >- <arg choice="plain"> >- <replaceable class="parameter">object</replaceable> >-@@ -8558,6 +8836,18 @@ The following are the commands understoo >- >- <listitem> >- <cmdsynopsis> >-+<command><link linkend="open-hook">open-hook</link></command> >-+<arg choice="plain"> >-+<replaceable class="parameter">pattern</replaceable> >-+</arg> >-+<arg choice="plain"> >-+<replaceable class="parameter">command</replaceable> >-+</arg> >-+</cmdsynopsis> >-+</listitem> >-+ >-+<listitem> >-+<cmdsynopsis> >- <command><link linkend="crypt-hook">crypt-hook</link></command> >- <arg choice="plain"> >- <replaceable class="parameter">pattern</replaceable> >-diff -udprP mutt-1.5.20.orig/doc/Muttrc.head mutt-1.5.20/doc/Muttrc.head >---- mutt-1.5.20.orig/doc/Muttrc.head 2008-11-11 21:55:46.000000000 +0200 >-+++ mutt-1.5.20/doc/Muttrc.head 2009-06-15 20:31:21.000000000 +0300 >-@@ -29,6 +29,11 @@ macro generic,pager <F1> "<shell-escape> >- macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list" >- bind browser y exit >- >-+# Use folders which match on \\.gz$ as gzipped folders: >-+# open-hook \\.gz$ "gzip -cd %f > %t" >-+# close-hook \\.gz$ "gzip -c %t > %f" >-+# append-hook \\.gz$ "gzip -c %t >> %f" >-+ >- # If Mutt is unable to determine your site's domain name correctly, you can >- # set the default here. >- # >-diff -udprP mutt-1.5.20.orig/doc/muttrc.man.head mutt-1.5.20/doc/muttrc.man.head >---- mutt-1.5.20.orig/doc/muttrc.man.head 2009-04-13 19:24:55.000000000 +0300 >-+++ mutt-1.5.20/doc/muttrc.man.head 2009-06-15 20:31:21.000000000 +0300 >-@@ -346,6 +346,24 @@ specify the ID of the public key to be u >- to a certain recipient. The meaning of "key ID" is to be taken >- broadly: This can be a different e-mail address, a numerical key ID, >- or even just an arbitrary search string. >-+.PP >-+.nf >-+\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP" >-+\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP" >-+\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP" >-+.fi >-+.IP >-+These commands provide a way to handle compressed folders. The given >-+\fBregexp\fP specifies which folders are taken as compressed (e.g. >-+"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder >-+(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a >-+compressed mail to a compressed folder (\fBappend-hook\fP). The >-+\fIcommand\fP string is the >-+.BR printf (3) >-+like format string, and it should accept two parameters: \fB%f\fP, >-+which is replaced with the (compressed) folder name, and \fB%t\fP >-+which is replaced with the name of the temporary folder to which to >-+write. >- .TP >- \fBpush\fP \fIstring\fP >- This command adds the named \fIstring\fP to the keyboard buffer. >-diff -udprP mutt-1.5.20.orig/hook.c mutt-1.5.20/hook.c >---- mutt-1.5.20.orig/hook.c 2009-01-13 16:47:49.000000000 +0200 >-+++ mutt-1.5.20/hook.c 2009-06-15 20:31:21.000000000 +0300 >-@@ -24,6 +24,10 @@ >- #include "mailbox.h" >- #include "mutt_crypt.h" >- >-+#ifdef USE_COMPRESSED >-+#include "compress.h" >-+#endif >-+ >- #include <limits.h> >- #include <string.h> >- #include <stdlib.h> >-@@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER >- memset (&pattern, 0, sizeof (pattern)); >- pattern.data = safe_strdup (path); >- } >-+#ifdef USE_COMPRESSED >-+ else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK)) >-+ { >-+ if (mutt_test_compress_command (command.data)) >-+ { >-+ strfcpy (err->data, _("bad formatted command string"), err->dsize); >-+ return (-1); >-+ } >-+ } >-+#endif >- else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK)) >- && (!WithCrypto || !(data & M_CRYPTHOOK)) >- ) >-diff -udprP mutt-1.5.20.orig/init.h mutt-1.5.20/init.h >---- mutt-1.5.20.orig/init.h 2009-06-14 00:35:21.000000000 +0300 >-+++ mutt-1.5.20/init.h 2009-06-15 20:31:21.000000000 +0300 >-@@ -3486,6 +3486,11 @@ struct command_t Commands[] = { >- { "fcc-hook", mutt_parse_hook, M_FCCHOOK }, >- { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK }, >- { "folder-hook", mutt_parse_hook, M_FOLDERHOOK }, >-+#ifdef USE_COMPRESSED >-+ { "open-hook", mutt_parse_hook, M_OPENHOOK }, >-+ { "close-hook", mutt_parse_hook, M_CLOSEHOOK }, >-+ { "append-hook", mutt_parse_hook, M_APPENDHOOK }, >-+#endif >- { "group", parse_group, M_GROUP }, >- { "ungroup", parse_group, M_UNGROUP }, >- { "hdr_order", parse_list, UL &HeaderOrderList }, >-diff -udprP mutt-1.5.20.orig/main.c mutt-1.5.20/main.c >---- mutt-1.5.20.orig/main.c 2009-06-01 19:29:32.000000000 +0300 >-+++ mutt-1.5.20/main.c 2009-06-15 20:31:21.000000000 +0300 >-@@ -310,6 +310,12 @@ static void show_version (void) >- "-USE_GNU_REGEX " >- #endif >- >-+#ifdef USE_COMPRESSED >-+ "+COMPRESSED " >-+#else >-+ "-COMPRESSED " >-+#endif >-+ >- "\n" >- >- #ifdef HAVE_COLOR >-diff -udprP mutt-1.5.20.orig/Makefile.am mutt-1.5.20/Makefile.am >---- mutt-1.5.20.orig/Makefile.am 2009-01-05 04:11:29.000000000 +0200 >-+++ mutt-1.5.20/Makefile.am 2009-06-15 20:31:21.000000000 +0300 >-@@ -22,6 +22,7 @@ BUILT_SOURCES = keymap_defs.h patchlist. >- bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@ >- mutt_SOURCES = \ >- addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \ >-+ compress.c \ >- crypt.c cryptglue.c \ >- commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \ >- edit.c enter.c flags.c init.c filter.c from.c \ >-@@ -62,6 +63,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c >- >- EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \ >- configure account.h \ >-+ compress.h \ >- attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \ >- globals.h hash.h history.h init.h keymap.h mutt_crypt.h \ >- mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \ >-diff -udprP mutt-1.5.20.orig/Makefile.in mutt-1.5.20/Makefile.in >---- mutt-1.5.20.orig/Makefile.in 2009-06-09 09:50:44.000000000 +0300 >-+++ mutt-1.5.20/Makefile.in 2009-06-15 20:31:21.000000000 +0300 >-@@ -15,6 +15,10 @@ >- >- @SET_MAKE@ >- >-+mutt_SOURCES += compress.c >-+EXTRA_DIST += compress.h >-+mutt_OBJECTS += compress.o >-+ >- >- VPATH = @srcdir@ >- pkgdatadir = $(datadir)/@PACKAGE@ >-diff -udprP mutt-1.5.20.orig/mbox.c mutt-1.5.20/mbox.c >---- mutt-1.5.20.orig/mbox.c 2009-06-11 07:29:41.000000000 +0300 >-+++ mutt-1.5.20/mbox.c 2009-06-15 20:31:21.000000000 +0300 >-@@ -29,6 +29,10 @@ >- #include "copy.h" >- #include "mutt_curses.h" >- >-+#ifdef USE_COMPRESSED >-+#include "compress.h" >-+#endif >-+ >- #include <sys/stat.h> >- #include <dirent.h> >- #include <string.h> >-@@ -1070,6 +1074,12 @@ bail: /* Come here in case of disaster >- int mbox_close_mailbox (CONTEXT *ctx) >- { >- mx_unlock_file (ctx->path, fileno (ctx->fp), 1); >-+ >-+#ifdef USE_COMPRESSED >-+ if (ctx->compressinfo) >-+ mutt_slow_close_compressed (ctx); >-+#endif >-+ >- mutt_unblock_signals (); >- mx_fastclose_mailbox (ctx); >- return 0; >-diff -udprP mutt-1.5.20.orig/mutt.h mutt-1.5.20/mutt.h >---- mutt-1.5.20.orig/mutt.h 2009-06-13 01:15:42.000000000 +0300 >-+++ mutt-1.5.20/mutt.h 2009-06-15 20:31:21.000000000 +0300 >-@@ -146,6 +146,11 @@ typedef enum >- #define M_ACCOUNTHOOK (1<<9) >- #define M_REPLYHOOK (1<<10) >- #define M_SEND2HOOK (1<<11) >-+#ifdef USE_COMPRESSED >-+#define M_OPENHOOK (1<<12) >-+#define M_APPENDHOOK (1<<13) >-+#define M_CLOSEHOOK (1<<14) >-+#endif >- >- /* tree characters for linearize_tree and print_enriched_string */ >- #define M_TREE_LLCORNER 1 >-@@ -885,6 +890,11 @@ typedef struct _context >- >- unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */ >- >-+#ifdef USE_COMPRESSED >-+ void *compressinfo; /* compressed mbox module private data */ >-+ char *realpath; /* path to compressed mailbox */ >-+#endif /* USE_COMPRESSED */ >-+ >- unsigned int locked : 1; /* is the mailbox locked? */ >- unsigned int changed : 1; /* mailbox has been modified */ >- unsigned int readonly : 1; /* don't allow changes to the mailbox */ >-diff -udprP mutt-1.5.20.orig/mx.c mutt-1.5.20/mx.c >---- mutt-1.5.20.orig/mx.c 2009-06-11 07:29:41.000000000 +0300 >-+++ mutt-1.5.20/mx.c 2009-06-15 20:31:21.000000000 +0300 >-@@ -30,6 +30,10 @@ >- #include "keymap.h" >- #include "url.h" >- >-+#ifdef USE_COMPRESSED >-+#include "compress.h" >-+#endif >-+ >- #ifdef USE_IMAP >- #include "imap.h" >- #endif >-@@ -414,6 +418,11 @@ int mx_get_magic (const char *path) >- return (-1); >- } >- >-+#ifdef USE_COMPRESSED >-+ if (magic == 0 && mutt_can_read_compressed (path)) >-+ return M_COMPRESSED; >-+#endif >-+ >- return (magic); >- } >- >-@@ -453,6 +462,13 @@ static int mx_open_mailbox_append (CONTE >- { >- struct stat sb; >- >-+#ifdef USE_COMPRESSED >-+ /* special case for appending to compressed folders - >-+ * even if we can not open them for reading */ >-+ if (mutt_can_append_compressed (ctx->path)) >-+ mutt_open_append_compressed (ctx); >-+#endif >-+ >- ctx->append = 1; >- >- #ifdef USE_IMAP >-@@ -617,6 +633,11 @@ CONTEXT *mx_open_mailbox (const char *pa >- >- ctx->magic = mx_get_magic (path); >- >-+#ifdef USE_COMPRESSED >-+ if (ctx->magic == M_COMPRESSED) >-+ mutt_open_read_compressed (ctx); >-+#endif >-+ >- if(ctx->magic == 0) >- mutt_error (_("%s is not a mailbox."), path); >- >-@@ -721,6 +742,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx) >- mutt_free_header (&ctx->hdrs[i]); >- FREE (&ctx->hdrs); >- FREE (&ctx->v2r); >-+#ifdef USE_COMPRESSED >-+ if (ctx->compressinfo) >-+ mutt_fast_close_compressed (ctx); >-+#endif >- FREE (&ctx->path); >- FREE (&ctx->pattern); >- if (ctx->limit_pattern) >-@@ -773,6 +798,12 @@ static int sync_mailbox (CONTEXT *ctx, i >- >- if (tmp && tmp->new == 0) >- mutt_update_mailbox (tmp); >-+ >-+#ifdef USE_COMPRESSED >-+ if (rc == 0 && ctx->compressinfo) >-+ return mutt_sync_compressed (ctx); >-+#endif >-+ >- return rc; >- } >- >-@@ -981,6 +1012,11 @@ int mx_close_mailbox (CONTEXT *ctx, int >- !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY)) >- mx_unlink_empty (ctx->path); >- >-+#ifdef USE_COMPRESSED >-+ if (ctx->compressinfo && mutt_slow_close_compressed (ctx)) >-+ return (-1); >-+#endif >-+ >- mx_fastclose_mailbox (ctx); >- >- return 0; >-@@ -1293,6 +1329,11 @@ int mx_check_mailbox (CONTEXT *ctx, int >- { >- int rc; >- >-+#ifdef USE_COMPRESSED >-+ if (ctx->compressinfo) >-+ return mutt_check_mailbox_compressed (ctx); >-+#endif >-+ >- if (ctx) >- { >- if (ctx->locked) lock = 0; >-diff -udprP mutt-1.5.20.orig/mx.h mutt-1.5.20/mx.h >---- mutt-1.5.20.orig/mx.h 2008-11-11 21:55:47.000000000 +0200 >-+++ mutt-1.5.20/mx.h 2009-06-15 20:31:21.000000000 +0300 >-@@ -36,6 +36,9 @@ enum >- M_MAILDIR, >- M_IMAP, >- M_POP >-+#ifdef USE_COMPRESSED >-+ , M_COMPRESSED >-+#endif >- }; >- >- WHERE short DefaultMagic INITVAL (M_MBOX); >-diff -udprP mutt-1.5.20.orig/PATCHES mutt-1.5.20/PATCHES >---- mutt-1.5.20.orig/PATCHES 2008-11-11 21:55:46.000000000 +0200 >-+++ mutt-1.5.20/PATCHES 2009-06-15 20:31:21.000000000 +0300 >-@@ -0,0 +1 @@ >-+rr.compressed >-diff -udprP mutt-1.5.20.orig/po/POTFILES.in mutt-1.5.20/po/POTFILES.in >---- mutt-1.5.20.orig/po/POTFILES.in 2008-11-11 21:55:47.000000000 +0200 >-+++ mutt-1.5.20/po/POTFILES.in 2009-06-15 20:31:21.000000000 +0300 >-@@ -8,6 +8,7 @@ charset.c >- color.c >- commands.c >- compose.c >-+compress.c >- crypt-gpgme.c >- crypt.c >- cryptglue.c >-diff -udprP mutt-1.5.20.orig/status.c mutt-1.5.20/status.c >---- mutt-1.5.20.orig/status.c 2009-01-05 01:14:53.000000000 +0200 >-+++ mutt-1.5.20/status.c 2009-06-15 20:31:21.000000000 +0300 >-@@ -96,6 +96,14 @@ status_format_str (char *buf, size_t buf >- >- case 'f': >- snprintf (fmt, sizeof(fmt), "%%%ss", prefix); >-+#ifdef USE_COMPRESSED >-+ if (Context && Context->compressinfo && Context->realpath) >-+ { >-+ strfcpy (tmp, Context->realpath, sizeof (tmp)); >-+ mutt_pretty_mailbox (tmp, sizeof (tmp)); >-+ } >-+ else >-+#endif >- if (Context && Context->path) >- { >- strfcpy (tmp, Context->path, sizeof (tmp)); >Index: SOURCES/patch-1.5.20.vvv.nntp >=================================================================== >--- SOURCES/patch-1.5.20.vvv.nntp (revision 800495) >+++ SOURCES/patch-1.5.20.vvv.nntp (working copy) >@@ -1,7566 +0,0 @@ >-WARNING: Run the following script before configure: >- >-aclocal -I m4 >-autoheader >-automake --foreign >-autoconf >- >--- >-Vsevolod Volkov <vvv@mutt.org.ua> >- >- >-diff -udprP mutt-1.5.20.orig/ChangeLog.nntp mutt-1.5.20/ChangeLog.nntp >---- mutt-1.5.20.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300 >-+++ mutt-1.5.20/ChangeLog.nntp 2009-06-15 21:56:06.000000000 +0300 >-@@ -0,0 +1,369 @@ >-+* Tue Jun 15 2009 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.20 >-+ >-+* Tue Mar 20 2009 Vsevolod Volkov <vvv@mutt.org.ua> >-+- save Date: header of recorded outgoing articles >-+ >-+* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.19 >-+ >-+* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.18 >-+- fixed SIGSEGV when followup or forward to newsgroup >-+ >-+* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.17 >-+ >-+* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua> >-+- fixed arguments of nntp_format_str() >-+ >-+* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua> >-+- fixed error selecting news group >-+ >-+* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.16 >-+ >-+* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua> >-+- fixed posting error if $smtp_url is set >-+- added support of print-style sequence %R (x-comment-to) >-+ >-+* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.15 >-+- nntp://... url changed to news://... >-+- added indicator of fetching descriptions progress >-+ >-+* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.14 >-+ >-+* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.13 >-+ >-+* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.12 >-+- fixed reading empty .newsrc >-+ >-+* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.11 >-+ >-+* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.10 >-+ >-+* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.9 >-+ >-+* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.8 >-+ >-+* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.7 >-+- function mutt_update_list_file() moved to newsrc.c and changed algorithm >-+ >-+* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua> >-+- fixed error in nntp_logout_all() >-+ >-+* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua> >-+- fixed debug output in mutt_newsrc_update() >-+- added optional support of LISTGROUP command >-+- fixed typo in nntp_parse_xref() >-+ >-+* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.6 >-+ >-+* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua> >-+- fixed compose menu >-+ >-+* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.5.1 >-+ >-+* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.5 >-+- added space after newsgroup name in .newsrc file >-+ >-+* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua> >-+- nntp patch: fixed SIGSEGV when posting article >-+ >-+* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.4 >-+ >-+* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.3 >-+- replace safe_free calls by the FREE macro >-+ >-+* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.2 >-+- nntp authentication can be passed after any command >-+ >-+* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.5.1 >-+ >-+* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.99 >-+ >-+* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.28 >-+- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>, >-+ <reconstruct-thread> functions >-+- fixed message about nntp reconnect >-+- fixed <attach-news-message> function using browser >-+- added support of Followup-To: poster >-+- added %n (new articles) in group_index_format >-+- posting articles without inews by default >-+ >-+* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.27 >-+ >-+* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.26 >-+ >-+* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.25 >-+- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>) >-+- added default content disposition >-+ >-+* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.24 >-+ >-+* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.23.2 >-+- fixed segfault if mutt_conn_find() returns null >-+ >-+* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.23.1 >-+- added support of LISTGROUP command >-+- added support for servers with broken overview >-+- disabled <flag-message> function on news server >-+- fixed error storing bad authentication information >-+ >-+* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.23 >-+- fixed typo in buffy.c >-+- added substitution of %s parameter in $inews variable >-+ >-+* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.22.1 >-+- update to 1.3.22 >-+ >-+* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.21 >-+ >-+* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.20 >-+- removed 'server-hook', use 'account-hook' instead >-+- fixed error opening NNTP server without newsgroup using -f option >-+ >-+* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.19 >-+ >-+* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.18 >-+- fixed typo in nntp_attempt_features() >-+- changed algorithm of XGTITLE command testing >-+- disabled writing of NNTP password in debug file >-+- fixed reading and writing of long newsrc lines >-+- changed checking of last line while reading lines from server >-+- fixed possible buffer overrun in nntp_parse_newsrc_line() >-+- removed checking of XHDR command >-+- compare NNTP return codes without trailing space >-+ >-+* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.17 >-+- support for 'LIST NEWSGROUPS' command to read descriptions >-+ >-+* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.16 >-+ >-+* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.15 >-+ >-+* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.14 >-+- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de> >-+ >-+* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.13 >-+ >-+* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua> >-+- Fixed problem if last article in group is deleted >-+ >-+* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua> >-+- Fixed checking of XGTITLE command on some servers >-+ >-+* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua> >-+- Added \r in AUTHINFO commands >-+ >-+* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.12 >-+ >-+* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.11 >-+- fixed error opening newsgroup from mutt started with -g or -G >-+ >-+* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.10 >-+- hotkey 'G' (get-message) replaced with '^G' >-+ >-+* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.9 >-+- changed delay displaying error messages from 1 to 2 seconds >-+- fixed error compiling with nntp and without imap >-+ >-+* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua> >-+- fixed catchup in index >-+- fixed nntp_open_mailbox() >-+ >-+* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua> >-+- functions <edit> and <delete-entry> disabled >-+- format of news mailbox names changed to url form >-+- option nntp_attempts removed >-+- option reconnect_news renamed to nntp_reconnect >-+- default value of nntp_poll changed from 30 to 60 >-+- error handling improved >-+ >-+* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua> >-+- update to 1.3.8 >-+- new option show_only_unread >-+- add newsgroup completion >-+ >-+* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.3.7 >-+ >-+* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.3.6 >-+ >-+* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.3.5 >-+- authentication code update >-+- fix for changing to newsgroup from mailbox with read messages >-+- socket code optimization >-+ >-+* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.3.4 >-+ >-+* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- don't substitute current newsgroup with deleted new messages >-+ >-+* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.3.3 >-+- fix for substitution of newsgroup after reconnection >-+- fix for loading newsgroups with very long names >-+- fix for loading more than 32768 newsgroups >-+ >-+* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.3.2 >-+ >-+* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.3.1 >-+ >-+* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.3 >-+ >-+* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.2 >-+ >-+* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.1.14 >-+ >-+* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.1.12 >-+ >-+* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- add substitution of newsgroup with new messages by default >-+ >-+* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- add attach message from newsgroup >-+- add one-line help in newsreader mode >-+- disable 'change-dir' command in newsgroups browser >-+- add -G option >-+ >-+* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- get default newsserver name from file /etc/nntpserver >-+- use case insensitive server names >-+- add print-style sequence %s to $newsrc >-+- add -g option >-+ >-+* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- remove 'X-FTN-Origin' header processing >-+ >-+* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.1.11 >-+- update to 1.1.10 >-+ >-+* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- fix mutt_select_newsserver() >-+- remove 'toggle-mode' function >-+- add 'change-newsgroup' function >-+ >-+* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- fix server-hook >-+ >-+* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- fix error 'bounce' function after 'post' >-+- add 'forward to newsgroup' function >-+ >-+* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- 'forward' function works in newsreader mode >-+- add 'post' and 'followup' functions to pager and attachment menu >-+- fix active descriptions and allowed flag reload >-+ >-+* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.1.9 >-+- remove deleted newsgroups from list >-+ >-+* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update .newsrc in browser >-+ >-+* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- reload .newsrc if externally modified >-+- fix active cache update >-+ >-+* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.1.8 >-+ >-+* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- patch *.update_list_file is not required >-+- count lines when loading descriptions >-+- remove cache of unsubscribed newsgroups >-+ >-+* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- load list of newsgroups from cache faster >-+ >-+* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.1.7 >-+ >-+* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- fix unread messages in browser >-+- fix newsrc_gen_entries() >-+ >-+* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- fix mutt_newsgroup_stat() >-+- fix nntp_delete_cache() >-+- fix nntp_get_status() >-+- fix check_children() >-+- fix nntp_fetch_headers() >-+ >-+* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.1.5 >-+ >-+* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- fix updating new messages in cache >-+ >-+* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- change default cache filenames >-+- fix updating new messages in cache >-+ >-+* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- fix segmentation fault in news groups browser >-+ >-+* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.1.4 >-+ >-+* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.1.3 >-+ >-+* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- add X-Comment-To editing >-+- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers >-+- add variables $ask_followup_to and $ask_x_comment_to >-+ >-+* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >-+- update to 1.1.2 >-diff -udprP mutt-1.5.20.orig/OPS mutt-1.5.20/OPS >---- mutt-1.5.20.orig/OPS 2009-05-13 08:01:13.000000000 +0300 >-+++ mutt-1.5.20/OPS 2009-06-15 21:05:24.000000000 +0300 >-@@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a >- OP_BROWSER_NEW_FILE "select a new file in this directory" >- OP_BROWSER_VIEW_FILE "view file" >- OP_BROWSER_TELL "display the currently selected file's name" >--OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)" >--OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)" >-+OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)" >-+OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)" >- OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)" >- OP_BUFFY_LIST "list mailboxes with new mail" >-+OP_CATCHUP "mark all articles in newsgroup as read" >- OP_CHANGE_DIRECTORY "change directories" >- OP_CHECK_NEW "check mailboxes for new mail" >- OP_COMPOSE_ATTACH_FILE "attach file(s) to this message" >- OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message" >-+OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message" >- OP_COMPOSE_EDIT_BCC "edit the BCC list" >- OP_COMPOSE_EDIT_CC "edit the CC list" >- OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description" >-@@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel >- OP_COMPOSE_EDIT_HEADERS "edit the message with headers" >- OP_COMPOSE_EDIT_MESSAGE "edit the message" >- OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry" >-+OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list" >- OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field" >-+OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field" >-+OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field" >- OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message" >- OP_COMPOSE_EDIT_TO "edit the TO list" >- OP_CREATE_MAILBOX "create a new mailbox (IMAP only)" >-@@ -85,8 +90,13 @@ OP_EXIT "exit this menu" >- OP_FILTER "filter attachment through a shell command" >- OP_FIRST_ENTRY "move to the first entry" >- OP_FLAG_MESSAGE "toggle a message's 'important' flag" >-+OP_FOLLOWUP "followup to newsgroup" >-+OP_FORWARD_TO_GROUP "forward to newsgroup" >- OP_FORWARD_MESSAGE "forward a message with comments" >- OP_GENERIC_SELECT_ENTRY "select the current entry" >-+OP_GET_CHILDREN "get all children of the current message" >-+OP_GET_MESSAGE "get message with Message-Id" >-+OP_GET_PARENT "get parent of the current message" >- OP_GROUP_REPLY "reply to all recipients" >- OP_HALF_DOWN "scroll down 1/2 page" >- OP_HALF_UP "scroll up 1/2 page" >-@@ -94,11 +104,14 @@ OP_HELP "this screen" >- OP_JUMP "jump to an index number" >- OP_LAST_ENTRY "move to the last entry" >- OP_LIST_REPLY "reply to specified mailing list" >-+OP_LOAD_ACTIVE "load active file from NNTP server" >- OP_MACRO "execute a macro" >- OP_MAIL "compose a new mail message" >- OP_MAIN_BREAK_THREAD "break the thread in two" >- OP_MAIN_CHANGE_FOLDER "open a different folder" >- OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode" >-+OP_MAIN_CHANGE_GROUP "open a different newsgroup" >-+OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode" >- OP_MAIN_CLEAR_FLAG "clear a status flag from a message" >- OP_MAIN_DELETE_PATTERN "delete messages matching a pattern" >- OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server" >-@@ -138,6 +151,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of >- OP_PAGER_SKIP_QUOTED "skip beyond quoted text" >- OP_PAGER_TOP "jump to the top of the message" >- OP_PIPE "pipe message/attachment to a shell command" >-+OP_POST "post message to newsgroup" >- OP_PREV_ENTRY "move to the previous entry" >- OP_PREV_LINE "scroll up one line" >- OP_PREV_PAGE "move to the previous page" >-@@ -146,6 +160,7 @@ OP_QUERY "query external program for add >- OP_QUERY_APPEND "append new query results to current results" >- OP_QUIT "save changes to mailbox and quit" >- OP_RECALL_MESSAGE "recall a postponed message" >-+OP_RECONSTRUCT_THREAD "reconstruct thread containing current message" >- OP_REDRAW "clear and redraw the screen" >- OP_REFORMAT_WINCH "{internal}" >- OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)" >-@@ -160,18 +175,22 @@ OP_SEARCH_TOGGLE "toggle search pattern >- OP_SHELL_ESCAPE "invoke a command in a subshell" >- OP_SORT "sort messages" >- OP_SORT_REVERSE "sort messages in reverse order" >-+OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern" >- OP_TAG "tag the current entry" >- OP_TAG_PREFIX "apply next function to tagged messages" >- OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages" >- OP_TAG_SUBTHREAD "tag the current subthread" >- OP_TAG_THREAD "tag the current thread" >- OP_TOGGLE_NEW "toggle a message's 'new' flag" >-+OP_TOGGLE_READ "toggle view of read messages" >- OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten" >- OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files" >- OP_TOP_PAGE "move to the top of the page" >-+OP_UNCATCHUP "mark all articles in newsgroup as unread" >- OP_UNDELETE "undelete the current entry" >- OP_UNDELETE_THREAD "undelete all messages in thread" >- OP_UNDELETE_SUBTHREAD "undelete all messages in subthread" >-+OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern" >- OP_VERSION "show the Mutt version number and date" >- OP_VIEW_ATTACH "view attachment using mailcap entry if necessary" >- OP_VIEW_ATTACHMENTS "show MIME attachments" >-diff -udprP mutt-1.5.20.orig/PATCHES mutt-1.5.20/PATCHES >---- mutt-1.5.20.orig/PATCHES 2008-11-11 21:55:46.000000000 +0200 >-+++ mutt-1.5.20/PATCHES 2009-06-15 21:05:24.000000000 +0300 >-@@ -0,0 +1 @@ >-+vvv.nntp >-diff -udprP mutt-1.5.20.orig/account.c mutt-1.5.20/account.c >---- mutt-1.5.20.orig/account.c 2008-11-11 21:55:46.000000000 +0200 >-+++ mutt-1.5.20/account.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -51,6 +51,11 @@ int mutt_account_match (const ACCOUNT* a >- user = PopUser; >- #endif >- >-+#ifdef USE_NNTP >-+ if (a1->type == M_ACCT_TYPE_NNTP && NntpUser) >-+ user = NntpUser; >-+#endif >-+ >- if (a1->flags & a2->flags & M_ACCT_USER) >- return (!strcmp (a1->user, a2->user)); >- if (a1->flags & M_ACCT_USER) >-@@ -130,6 +135,16 @@ void mutt_account_tourl (ACCOUNT* accoun >- } >- #endif >- >-+#ifdef USE_NNTP >-+ if (account->type == M_ACCT_TYPE_NNTP) >-+ { >-+ if (account->flags & M_ACCT_SSL) >-+ url->scheme = U_NNTPS; >-+ else >-+ url->scheme = U_NNTP; >-+ } >-+#endif >-+ >- url->host = account->host; >- if (account->flags & M_ACCT_PORT) >- url->port = account->port; >-@@ -155,6 +170,10 @@ int mutt_account_getuser (ACCOUNT* accou >- else if ((account->type == M_ACCT_TYPE_POP) && PopUser) >- strfcpy (account->user, PopUser, sizeof (account->user)); >- #endif >-+#ifdef USE_NNTP >-+ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser) >-+ strfcpy (account->user, NntpUser, sizeof (account->user)); >-+#endif >- else if (option (OPTNOCURSES)) >- return -1; >- /* prompt (defaults to unix username), copy into account->user */ >-@@ -215,6 +234,10 @@ int mutt_account_getpass (ACCOUNT* accou >- else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass) >- strfcpy (account->pass, SmtpPass, sizeof (account->pass)); >- #endif >-+#ifdef USE_NNTP >-+ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass) >-+ strfcpy (account->pass, NntpPass, sizeof (account->pass)); >-+#endif >- else if (option (OPTNOCURSES)) >- return -1; >- else >-diff -udprP mutt-1.5.20.orig/account.h mutt-1.5.20/account.h >---- mutt-1.5.20.orig/account.h 2008-11-11 21:55:46.000000000 +0200 >-+++ mutt-1.5.20/account.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -29,7 +29,8 @@ enum >- M_ACCT_TYPE_NONE = 0, >- M_ACCT_TYPE_IMAP, >- M_ACCT_TYPE_POP, >-- M_ACCT_TYPE_SMTP >-+ M_ACCT_TYPE_SMTP, >-+ M_ACCT_TYPE_NNTP >- }; >- >- /* account flags */ >-diff -udprP mutt-1.5.20.orig/attach.h mutt-1.5.20/attach.h >---- mutt-1.5.20.orig/attach.h 2008-11-11 21:55:46.000000000 +0200 >-+++ mutt-1.5.20/attach.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f >- >- void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *); >- void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *); >--void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *); >-+void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int); >- void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int); >- >- #endif /* _ATTACH_H_ */ >-diff -udprP mutt-1.5.20.orig/browser.c mutt-1.5.20/browser.c >---- mutt-1.5.20.orig/browser.c 2009-06-11 20:52:54.000000000 +0300 >-+++ mutt-1.5.20/browser.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -32,6 +32,9 @@ >- #ifdef USE_IMAP >- #include "imap.h" >- #endif >-+#ifdef USE_NNTP >-+#include "nntp.h" >-+#endif >- >- #include <stdlib.h> >- #include <dirent.h> >-@@ -49,6 +52,19 @@ static struct mapping_t FolderHelp[] = { >- { NULL, 0 } >- }; >- >-+#ifdef USE_NNTP >-+static struct mapping_t FolderNewsHelp[] = { >-+ { N_("Exit"), OP_EXIT }, >-+ { N_("List"), OP_TOGGLE_MAILBOXES }, >-+ { N_("Subscribe"), OP_BROWSER_SUBSCRIBE }, >-+ { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE }, >-+ { N_("Catchup"), OP_CATCHUP }, >-+ { N_("Mask"), OP_ENTER_MASK }, >-+ { N_("Help"), OP_HELP }, >-+ { NULL } >-+}; >-+#endif >-+ >- typedef struct folder_t >- { >- struct folder_file *ff; >-@@ -114,9 +130,17 @@ static void browser_sort (struct browser >- case SORT_ORDER: >- return; >- case SORT_DATE: >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ return; >-+#endif >- f = browser_compare_date; >- break; >- case SORT_SIZE: >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ return; >-+#endif >- f = browser_compare_size; >- break; >- case SORT_SUBJECT: >-@@ -307,8 +331,106 @@ folder_format_str (char *dest, size_t de >- return (src); >- } >- >-+#ifdef USE_NNTP >-+static const char * >-+newsgroup_format_str (char *dest, size_t destlen, size_t col, char op, const char *src, >-+ const char *fmt, const char *ifstring, const char *elsestring, >-+ unsigned long data, format_flag flags) >-+{ >-+ char fn[SHORT_STRING], tmp[SHORT_STRING]; >-+ FOLDER *folder = (FOLDER *) data; >-+ >-+ switch (op) >-+ { >-+ case 'C': >-+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); >-+ snprintf (dest, destlen, tmp, folder->num + 1); >-+ break; >-+ >-+ case 'f': >-+ strncpy (fn, folder->ff->name, sizeof(fn) - 1); >-+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >-+ snprintf (dest, destlen, tmp, fn); >-+ break; >-+ >-+ case 'N': >-+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt); >-+ if (folder->ff->nd->subscribed) >-+ snprintf (dest, destlen, tmp, ' '); >-+ else >-+ snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u'); >-+ break; >-+ >-+ case 'M': >-+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt); >-+ if (folder->ff->nd->deleted) >-+ snprintf (dest, destlen, tmp, 'D'); >-+ else >-+ snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-'); >-+ break; >-+ >-+ case 's': >-+ if (flags & M_FORMAT_OPTIONAL) >-+ { >-+ if (folder->ff->nd->unread != 0) >-+ mutt_FormatString (dest, destlen, col, ifstring, newsgroup_format_str, >-+ data, flags); >-+ else >-+ mutt_FormatString (dest, destlen, col, elsestring, newsgroup_format_str, >-+ data, flags); >-+ } >-+ else if (Context && Context->data == folder->ff->nd) >-+ { >-+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); >-+ snprintf (dest, destlen, tmp, Context->unread); >-+ } >-+ else >-+ { >-+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); >-+ snprintf (dest, destlen, tmp, folder->ff->nd->unread); >-+ } >-+ break; >-+ >-+ case 'n': >-+ if (Context && Context->data == folder->ff->nd) >-+ { >-+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); >-+ snprintf (dest, destlen, tmp, Context->new); >-+ } >-+ else if (option (OPTMARKOLD) && >-+ folder->ff->nd->lastCached >= folder->ff->nd->firstMessage && >-+ folder->ff->nd->lastCached <= folder->ff->nd->lastMessage) >-+ { >-+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); >-+ snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached); >-+ } >-+ else >-+ { >-+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); >-+ snprintf (dest, destlen, tmp, folder->ff->nd->unread); >-+ } >-+ break; >-+ >-+ case 'd': >-+ if (folder->ff->nd->desc != NULL) >-+ { >-+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >-+ snprintf (dest, destlen, tmp, folder->ff->nd->desc); >-+ } >-+ else >-+ { >-+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >-+ snprintf (dest, destlen, tmp, ""); >-+ } >-+ break; >-+ } >-+ return (src); >-+} >-+#endif /* USE_NNTP */ >-+ >- static void add_folder (MUTTMENU *m, struct browser_state *state, >-- const char *name, const struct stat *s, int new) >-+ const char *name, const struct stat *s, >-+ void *data, int new) >- { >- if (state->entrylen == state->entrymax) >- { >-@@ -337,6 +459,10 @@ static void add_folder (MUTTMENU *m, str >- #ifdef USE_IMAP >- (state->entry)[state->entrylen].imap = 0; >- #endif >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ (state->entry)[state->entrylen].nd = (NNTP_DATA *) data; >-+#endif >- (state->entrylen)++; >- } >- >-@@ -352,9 +478,35 @@ static void init_state (struct browser_s >- menu->data = state->entry; >- } >- >-+/* get list of all files/newsgroups with mask */ >- static int examine_directory (MUTTMENU *menu, struct browser_state *state, >- char *d, const char *prefix) >- { >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ { >-+ LIST *tmp; >-+ NNTP_DATA *data; >-+ NNTP_SERVER *news = CurrentNewsSrv; >-+ >-+/* mutt_buffy_check (0); */ >-+ init_state (state, menu); >-+ >-+ for (tmp = news->list; tmp; tmp = tmp->next) >-+ { >-+ if (!(data = (NNTP_DATA *)tmp->data)) >-+ continue; >-+ if (prefix && *prefix && strncmp (prefix, data->group, >-+ strlen (prefix)) != 0) >-+ continue; >-+ if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not)) >-+ continue; >-+ add_folder (menu, state, data->group, NULL, data, data->new); >-+ } >-+ } >-+ else >-+#endif /* USE_NNTP */ >-+ { >- struct stat s; >- DIR *dp; >- struct dirent *de; >-@@ -415,17 +567,40 @@ static int examine_directory (MUTTMENU * >- tmp = Incoming; >- while (tmp && mutt_strcmp (buffer, tmp->path)) >- tmp = tmp->next; >-- add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0); >-+ add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0); >-+ } >-+ closedir (dp); >- } >-- closedir (dp); >- browser_sort (state); >- return 0; >- } >- >-+/* get list of mailboxes/subscribed newsgroups */ >- static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state) >- { >- struct stat s; >- char buffer[LONG_STRING]; >-+ >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ { >-+ LIST *tmp; >-+ NNTP_DATA *data; >-+ NNTP_SERVER *news = CurrentNewsSrv; >-+ >-+/* mutt_buffy_check (0); */ >-+ init_state (state, menu); >-+ >-+ for (tmp = news->list; tmp; tmp = tmp->next) >-+ { >-+ if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new || >-+ (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread)))) >-+ add_folder (menu, state, data->group, NULL, data, data->new); >-+ } >-+ } >-+ else >-+#endif >-+ { >- BUFFY *tmp = Incoming; >- #ifdef USE_IMAP >- struct mailbox_state mbox; >-@@ -443,14 +618,21 @@ static int examine_mailboxes (MUTTMENU * >- if (mx_is_imap (tmp->path)) >- { >- imap_mailbox_state (tmp->path, &mbox); >-- add_folder (menu, state, tmp->path, NULL, mbox.new); >-+ add_folder (menu, state, tmp->path, NULL, NULL, mbox.new); >- continue; >- } >- #endif >- #ifdef USE_POP >- if (mx_is_pop (tmp->path)) >- { >-- add_folder (menu, state, tmp->path, NULL, tmp->new); >-+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); >-+ continue; >-+ } >-+#endif >-+#ifdef USE_NNTP >-+ if (mx_is_nntp (tmp->path)) >-+ { >-+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); >- continue; >- } >- #endif >-@@ -479,15 +661,20 @@ static int examine_mailboxes (MUTTMENU * >- strfcpy (buffer, NONULL(tmp->path), sizeof (buffer)); >- mutt_pretty_mailbox (buffer, sizeof (buffer)); >- >-- add_folder (menu, state, buffer, &s, tmp->new); >-+ add_folder (menu, state, buffer, &s, NULL, tmp->new); >- } >- while ((tmp = tmp->next)); >-+ } >- browser_sort (state); >- return 0; >- } >- >- static int select_file_search (MUTTMENU *menu, regex_t *re, int n) >- { >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0)); >-+#endif >- return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0)); >- } >- >-@@ -498,6 +685,12 @@ static void folder_entry (char *s, size_ >- folder.ff = &((struct folder_file *) menu->data)[num]; >- folder.num = num; >- >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ mutt_FormatString (s, slen, 0, NONULL(GroupFormat), newsgroup_format_str, >-+ (unsigned long) &folder, M_FORMAT_ARROWCURSOR); >-+ else >-+#endif >- mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str, >- (unsigned long) &folder, M_FORMAT_ARROWCURSOR); >- } >-@@ -518,6 +711,17 @@ static void init_menu (struct browser_st >- >- menu->tagged = 0; >- >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ { >-+ if (buffy) >-+ snprintf (title, titlelen, _("Subscribed newsgroups")); >-+ else >-+ snprintf (title, titlelen, _("Newsgroups on server [%s]"), >-+ CurrentNewsSrv->conn->account.host); >-+ } >-+ else >-+#endif >- if (buffy) >- snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0)); >- else >-@@ -573,6 +777,31 @@ void _mutt_select_file (char *f, size_t >- if (!folder) >- strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup)); >- >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ { >-+ if (*f) >-+ strfcpy (prefix, f, sizeof (prefix)); >-+ else >-+ { >-+ LIST *list; >-+ >-+ /* default state for news reader mode is browse subscribed newsgroups */ >-+ buffy = 0; >-+ for (list = CurrentNewsSrv->list; list; list = list->next) >-+ { >-+ NNTP_DATA *data = (NNTP_DATA *) list->data; >-+ >-+ if (data && data->subscribed) >-+ { >-+ buffy = 1; >-+ break; >-+ } >-+ } >-+ } >-+ } >-+ else >-+#endif >- if (*f) >- { >- mutt_expand_path (f, flen); >-@@ -669,6 +898,9 @@ void _mutt_select_file (char *f, size_t >- menu->tag = file_tag; >- >- menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER, >-+#ifdef USE_NNTP >-+ (option (OPTNEWS)) ? FolderNewsHelp : >-+#endif >- FolderHelp); >- >- init_menu (&state, menu, title, sizeof (title), buffy); >-@@ -807,7 +1039,11 @@ void _mutt_select_file (char *f, size_t >- } >- } >- >-+#ifdef USE_NNTP >-+ if (buffy || option (OPTNEWS)) /* news have not path */ >-+#else >- if (buffy) >-+#endif >- { >- strfcpy (f, state.entry[menu->current].name, flen); >- mutt_expand_path (f, flen); >-@@ -865,14 +1101,6 @@ void _mutt_select_file (char *f, size_t >- break; >- >- #ifdef USE_IMAP >-- case OP_BROWSER_SUBSCRIBE: >-- imap_subscribe (state.entry[menu->current].name, 1); >-- break; >-- >-- case OP_BROWSER_UNSUBSCRIBE: >-- imap_subscribe (state.entry[menu->current].name, 0); >-- break; >-- >- case OP_BROWSER_TOGGLE_LSUB: >- if (option (OPTIMAPLSUB)) >- unset_option (OPTIMAPLSUB); >-@@ -973,6 +1201,11 @@ void _mutt_select_file (char *f, size_t >- >- case OP_CHANGE_DIRECTORY: >- >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ break; >-+#endif >-+ >- strfcpy (buf, LastDir, sizeof (buf)); >- #ifdef USE_IMAP >- if (!state.imap_browse) >-@@ -1239,6 +1472,190 @@ void _mutt_select_file (char *f, size_t >- else >- mutt_error _("Error trying to view file"); >- } >-+ break; >-+ >-+#ifdef USE_NNTP >-+ case OP_CATCHUP: >-+ case OP_UNCATCHUP: >-+ if (option (OPTNEWS)) >-+ { >-+ struct folder_file *f = &state.entry[menu->current]; >-+ NNTP_DATA *nd; >-+ >-+ if (i == OP_CATCHUP) >-+ nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name); >-+ else >-+ nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name); >-+ >-+ if (nd) >-+ { >-+/* FOLDER folder; >-+ struct folder_file ff; >-+ char buffer[_POSIX_PATH_MAX + SHORT_STRING]; >-+ >-+ folder.ff = &ff; >-+ folder.ff->name = f->name; >-+ folder.ff->st = NULL; >-+ folder.ff->is_new = nd->new; >-+ folder.ff->nd = nd; >-+ FREE (&f->desc); >-+ mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat), >-+ newsgroup_format_str, (unsigned long) &folder, >-+ M_FORMAT_ARROWCURSOR); >-+ f->desc = safe_strdup (buffer); */ >-+ if (menu->current + 1 < menu->max) >-+ menu->current++; >-+ menu->redraw = REDRAW_MOTION_RESYNCH; >-+ } >-+ } >-+ break; >-+ >-+ case OP_LOAD_ACTIVE: >-+ if (!option (OPTNEWS)) >-+ break; >-+ >-+ { >-+ LIST *tmp; >-+ NNTP_DATA *data; >-+ >-+ for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next) >-+ { >-+ if ((data = (NNTP_DATA *)tmp->data)) >-+ data->deleted = 1; >-+ } >-+ } >-+ nntp_get_active (CurrentNewsSrv); >-+ >-+ destroy_state (&state); >-+ if (buffy) >-+ examine_mailboxes (menu, &state); >-+ else >-+ examine_directory (menu, &state, NULL, NULL); >-+ init_menu (&state, menu, title, sizeof (title), buffy); >-+ break; >-+#endif /* USE_NNTP */ >-+ >-+#if defined USE_IMAP || defined USE_NNTP >-+ case OP_BROWSER_SUBSCRIBE: >-+ case OP_BROWSER_UNSUBSCRIBE: >-+#endif >-+#ifdef USE_NNTP >-+ case OP_SUBSCRIBE_PATTERN: >-+ case OP_UNSUBSCRIBE_PATTERN: >-+ if (option (OPTNEWS)) >-+ { >-+ regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t)); >-+ char *s = buf; >-+ int j = menu->current; >-+ NNTP_DATA *nd; >-+ NNTP_SERVER *news = CurrentNewsSrv; >-+ >-+ if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN) >-+ { >-+ char tmp[STRING]; >-+ int err; >-+ >-+ buf[0] = 0; >-+ if (i == OP_SUBSCRIBE_PATTERN) >-+ snprintf (tmp, sizeof (tmp), _("Subscribe pattern: ")); >-+ else >-+ snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: ")); >-+ if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) >-+ { >-+ FREE (&rx); >-+ break; >-+ } >-+ >-+ if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) >-+ { >-+ regerror (err, rx, buf, sizeof (buf)); >-+ regfree (rx); >-+ FREE (&rx); >-+ mutt_error ("%s", buf); >-+ break; >-+ } >-+ menu->redraw = REDRAW_FULL; >-+ j = 0; >-+ } >-+ else if (!state.entrylen) >-+ { >-+ mutt_error _("No newsgroups match the mask"); >-+ break; >-+ } >-+ >-+ for ( ; j < state.entrylen; j++) >-+ { >-+ struct folder_file *f = &state.entry[j]; >-+ >-+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE || >-+ regexec (rx, f->name, 0, NULL, 0) == 0) >-+ { >-+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN) >-+ nd = mutt_newsgroup_subscribe (news, f->name); >-+ else >-+ nd = mutt_newsgroup_unsubscribe (news, f->name); >-+/* if (nd) >-+ { >-+ FOLDER folder; >-+ char buffer[_POSIX_PATH_MAX + SHORT_STRING]; >-+ >-+ folder.name = f->name; >-+ folder.f = NULL; >-+ folder.new = nd->new; >-+ folder.nd = nd; >-+ FREE (&f->desc); >-+ mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat), >-+ newsgroup_format_str, (unsigned long) &folder, >-+ M_FORMAT_ARROWCURSOR); >-+ f->desc = safe_strdup (buffer); >-+ } */ >-+ } >-+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE) >-+ { >-+ if (menu->current + 1 < menu->max) >-+ menu->current++; >-+ menu->redraw = REDRAW_MOTION_RESYNCH; >-+ break; >-+ } >-+ } >-+ if (i == OP_SUBSCRIBE_PATTERN) >-+ { >-+ LIST *grouplist = NULL; >-+ >-+ if (news) >-+ grouplist = news->list; >-+ for (; grouplist; grouplist = grouplist->next) >-+ { >-+ nd = (NNTP_DATA *) grouplist->data; >-+ if (nd && nd->group && !nd->subscribed) >-+ { >-+ if (regexec (rx, nd->group, 0, NULL, 0) == 0) >-+ { >-+ mutt_newsgroup_subscribe (news, nd->group); >-+ add_folder (menu, &state, nd->group, NULL, nd, nd->new); >-+ } >-+ } >-+ } >-+ init_menu (&state, menu, title, sizeof (title), buffy); >-+ } >-+ mutt_newsrc_update (news); >-+ nntp_clear_cacheindex (news); >-+ if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE) >-+ regfree (rx); >-+ FREE (&rx); >-+ } >-+#ifdef USE_IMAP >-+ else >-+#endif /* USE_IMAP && USE_NNTP */ >-+#endif /* USE_NNTP */ >-+#ifdef USE_IMAP >-+ { >-+ if (i == OP_BROWSER_SUBSCRIBE) >-+ imap_subscribe (state.entry[menu->current].name, 1); >-+ else >-+ imap_subscribe (state.entry[menu->current].name, 0); >-+ } >-+#endif /* USE_IMAP */ >- } >- } >- >-diff -udprP mutt-1.5.20.orig/browser.h mutt-1.5.20/browser.h >---- mutt-1.5.20.orig/browser.h 2009-01-05 00:34:12.000000000 +0200 >-+++ mutt-1.5.20/browser.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -19,6 +19,10 @@ >- #ifndef _BROWSER_H >- #define _BROWSER_H 1 >- >-+#ifdef USE_NNTP >-+#include "nntp.h" >-+#endif >-+ >- struct folder_file >- { >- mode_t mode; >-@@ -37,6 +41,9 @@ struct folder_file >- unsigned selectable : 1; >- unsigned inferiors : 1; >- #endif >-+#ifdef USE_NNTP >-+ NNTP_DATA *nd; >-+#endif >- unsigned tagged : 1; >- }; >- >-diff -udprP mutt-1.5.20.orig/buffy.c mutt-1.5.20/buffy.c >---- mutt-1.5.20.orig/buffy.c 2009-06-02 20:16:26.000000000 +0300 >-+++ mutt-1.5.20/buffy.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -403,6 +403,9 @@ int mutt_buffy_check (int force) >- BuffyCount += imap_buffy_check (force); >- #endif >- >-+#ifdef USE_NNTP >-+ if (!Context || Context->magic != M_NNTP) >-+#endif >- /* check device ID and serial number instead of comparing paths */ >- if (!Context || Context->magic == M_IMAP || Context->magic == M_POP >- || stat (Context->path, &contex_sb) != 0) >-@@ -421,6 +424,11 @@ int mutt_buffy_check (int force) >- tmp->magic = M_POP; >- else >- #endif >-+#ifdef USE_NNTP >-+ if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path)) >-+ tmp->magic = M_NNTP; >-+ else >-+#endif >- if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) || >- (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0)) >- { >-@@ -436,7 +444,11 @@ int mutt_buffy_check (int force) >- /* check to see if the folder is the currently selected folder >- * before polling */ >- if (!Context || !Context->path || >-- (( tmp->magic == M_IMAP || tmp->magic == M_POP ) >-+ (( tmp->magic == M_IMAP || tmp->magic == M_POP >-+#ifdef USE_NNTP >-+ || tmp->magic == M_NNTP >-+#endif >-+ ) >- ? mutt_strcmp (tmp->path, Context->path) : >- (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino))) >- { >-diff -udprP mutt-1.5.20.orig/complete.c mutt-1.5.20/complete.c >---- mutt-1.5.20.orig/complete.c 2009-01-05 00:38:16.000000000 +0200 >-+++ mutt-1.5.20/complete.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -25,6 +25,9 @@ >- #include "mailbox.h" >- #include "imap.h" >- #endif >-+#ifdef USE_NNTP >-+#include "nntp.h" >-+#endif >- >- #include <dirent.h> >- #include <string.h> >-@@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen) >- char filepart[_POSIX_PATH_MAX]; >- #ifdef USE_IMAP >- char imap_path[LONG_STRING]; >-+#endif >- >- dprint (2, (debugfile, "mutt_complete: completing %s\n", s)); >- >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ { >-+ LIST *l = CurrentNewsSrv->list; >-+ >-+ strfcpy (filepart, s, sizeof (filepart)); >-+ >-+ /* >-+ * special case to handle when there is no filepart yet. >-+ * find the first subscribed newsgroup >-+ */ >-+ if ((len = mutt_strlen (filepart)) == 0) >-+ { >-+ for (; l; l = l->next) >-+ { >-+ NNTP_DATA *data = (NNTP_DATA *)l->data; >-+ >-+ if (data && data->subscribed) >-+ { >-+ strfcpy (filepart, data->group, sizeof (filepart)); >-+ init++; >-+ l = l->next; >-+ break; >-+ } >-+ } >-+ } >-+ >-+ for (; l; l = l->next) >-+ { >-+ NNTP_DATA *data = (NNTP_DATA *)l->data; >-+ >-+ if (data && data->subscribed && >-+ mutt_strncmp (data->group, filepart, len) == 0) >-+ { >-+ if (init) >-+ { >-+ for (i = 0; filepart[i] && data->group[i]; i++) >-+ { >-+ if (filepart[i] != data->group[i]) >-+ { >-+ filepart[i] = 0; >-+ break; >-+ } >-+ } >-+ filepart[i] = 0; >-+ } >-+ else >-+ { >-+ strfcpy (filepart, data->group, sizeof (filepart)); >-+ init = 1; >-+ } >-+ } >-+ } >-+ >-+ strcpy (s, filepart); >-+ >-+ return (init ? 0 : -1); >-+ } >-+#endif >-+ >-+#ifdef USE_IMAP >- /* we can use '/' as a delimiter, imap_complete rewrites it */ >- if (*s == '=' || *s == '+' || *s == '!') >- { >-diff -udprP mutt-1.5.20.orig/compose.c mutt-1.5.20/compose.c >---- mutt-1.5.20.orig/compose.c 2009-03-31 09:52:43.000000000 +0300 >-+++ mutt-1.5.20/compose.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -32,10 +32,15 @@ >- #include "mailbox.h" >- #include "sort.h" >- #include "charset.h" >-+#include "mx.h" >- >- #ifdef MIXMASTER >- #include "remailer.h" >- #endif >-+ >-+#ifdef USE_NNTP >-+#include "nntp.h" >-+#endif >- >- #include <errno.h> >- #include <string.h> >-@@ -60,18 +65,21 @@ enum >- HDR_REPLYTO, >- HDR_FCC, >- >--#ifdef MIXMASTER >-- HDR_MIX, >--#endif >- >- HDR_CRYPT, >- HDR_CRYPTINFO, >- >-+#ifdef USE_NNTP >-+ HDR_NEWSGROUPS, >-+ HDR_FOLLOWUPTO, >-+ HDR_XCOMMENTTO, >-+#endif >-+ >- HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */ >- }; >- >--#define HDR_XOFFSET 10 >--#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */ >-+#define HDR_XOFFSET 14 >-+#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */ >- #define W (COLS - HDR_XOFFSET) >- >- static char *Prompts[] = >-@@ -83,6 +91,16 @@ static char *Prompts[] = >- "Subject: ", >- "Reply-To: ", >- "Fcc: " >-+#ifdef USE_NNTP >-+#ifdef MIXMASTER >-+ ,"" >-+#endif >-+ ,"" >-+ ,"" >-+ ,"Newsgroups: " >-+ ,"Followup-To: " >-+ ,"X-Comment-To: " >-+#endif >- }; >- >- static struct mapping_t ComposeHelp[] = { >-@@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] = >- { NULL, 0 } >- }; >- >-+#ifdef USE_NNTP >-+static struct mapping_t ComposeNewsHelp[] = { >-+ { N_("Send"), OP_COMPOSE_SEND_MESSAGE }, >-+ { N_("Abort"), OP_EXIT }, >-+ { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS }, >-+ { "Subj", OP_COMPOSE_EDIT_SUBJECT }, >-+ { N_("Attach file"), OP_COMPOSE_ATTACH_FILE }, >-+ { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION }, >-+ { N_("Help"), OP_HELP }, >-+ { NULL } >-+}; >-+#endif >-+ >- static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num) >- { >- mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt, >-@@ -252,9 +283,28 @@ static void draw_envelope_addr (int line >- static void draw_envelope (HEADER *msg, char *fcc) >- { >- draw_envelope_addr (HDR_FROM, msg->env->from); >-+#ifdef USE_NNTP >-+ if (!option (OPTNEWSSEND)) >-+ { >-+#endif >- draw_envelope_addr (HDR_TO, msg->env->to); >- draw_envelope_addr (HDR_CC, msg->env->cc); >- draw_envelope_addr (HDR_BCC, msg->env->bcc); >-+#ifdef USE_NNTP >-+ } >-+ else >-+ { >-+ mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]); >-+ mutt_paddstr (W, NONULL (msg->env->newsgroups)); >-+ mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]); >-+ mutt_paddstr (W, NONULL (msg->env->followup_to)); >-+ if (option (OPTXCOMMENTTO)) >-+ { >-+ mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]); >-+ mutt_paddstr (W, NONULL (msg->env->x_comment_to)); >-+ } >-+ } >-+#endif >- mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); >- mutt_paddstr (W, NONULL (msg->env->subject)); >- draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); >-@@ -507,6 +557,12 @@ int mutt_compose_menu (HEADER *msg, /* >- /* Sort, SortAux could be changed in mutt_index_menu() */ >- int oldSort, oldSortAux; >- struct stat st; >-+#ifdef USE_NNTP >-+ int news = 0; /* is it a news article ? */ >-+ >-+ if (option (OPTNEWSSEND)) >-+ news++; >-+#endif >- >- mutt_attach_init (msg->content); >- idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1); >-@@ -517,10 +573,18 @@ int mutt_compose_menu (HEADER *msg, /* >- menu->make_entry = snd_entry; >- menu->tag = mutt_tag_attach; >- menu->data = idx; >-+#ifdef USE_NNTP >-+ if (news) >-+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp); >-+ else >-+#endif >- menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp); >- >- while (loop) >- { >-+#ifdef USE_NNTP >-+ unset_option (OPTNEWS); /* for any case */ >-+#endif >- switch (op = mutt_menuLoop (menu)) >- { >- case OP_REDRAW: >-@@ -533,17 +597,87 @@ int mutt_compose_menu (HEADER *msg, /* >- mutt_message_hook (NULL, msg, M_SEND2HOOK); >- break; >- case OP_COMPOSE_EDIT_TO: >-+#ifdef USE_NNTP >-+ if (news) >-+ break; >-+#endif >- menu->redraw = edit_address_list (HDR_TO, &msg->env->to); >- mutt_message_hook (NULL, msg, M_SEND2HOOK); >- break; >- case OP_COMPOSE_EDIT_BCC: >-+#ifdef USE_NNTP >-+ if (news) >-+ break; >-+#endif >- menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc); >- mutt_message_hook (NULL, msg, M_SEND2HOOK); >- break; >- case OP_COMPOSE_EDIT_CC: >-+#ifdef USE_NNTP >-+ if (news) >-+ break; >-+#endif >- menu->redraw = edit_address_list (HDR_CC, &msg->env->cc); >- mutt_message_hook (NULL, msg, M_SEND2HOOK); >- break; >-+#ifdef USE_NNTP >-+ case OP_COMPOSE_EDIT_NEWSGROUPS: >-+ if (news) >-+ { >-+ if (msg->env->newsgroups) >-+ strfcpy (buf, msg->env->newsgroups, sizeof (buf)); >-+ else >-+ buf[0] = 0; >-+ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0]) >-+ { >-+ FREE (&msg->env->newsgroups); >-+ mutt_remove_trailing_ws (buf); >-+ msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf)); >-+ move (HDR_TO, HDR_XOFFSET); >-+ clrtoeol (); >-+ if (msg->env->newsgroups) >-+ printw ("%-*.*s", W, W, msg->env->newsgroups); >-+ } >-+ } >-+ break; >-+ >-+ case OP_COMPOSE_EDIT_FOLLOWUP_TO: >-+ if (news) >-+ { >-+ buf[0] = 0; >-+ if (msg->env->followup_to) >-+ strfcpy (buf, msg->env->followup_to, sizeof (buf)); >-+ if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0]) >-+ { >-+ FREE (&msg->env->followup_to); >-+ mutt_remove_trailing_ws (buf); >-+ msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf)); >-+ move (HDR_CC, HDR_XOFFSET); >-+ clrtoeol(); >-+ if (msg->env->followup_to) >-+ printw ("%-*.*s", W, W, msg->env->followup_to); >-+ } >-+ } >-+ break; >-+ >-+ case OP_COMPOSE_EDIT_X_COMMENT_TO: >-+ if (news && option (OPTXCOMMENTTO)) >-+ { >-+ buf[0] = 0; >-+ if (msg->env->x_comment_to) >-+ strfcpy (buf, msg->env->x_comment_to, sizeof (buf)); >-+ if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0]) >-+ { >-+ FREE (&msg->env->x_comment_to); >-+ msg->env->x_comment_to = safe_strdup (buf); >-+ move (HDR_BCC, HDR_XOFFSET); >-+ clrtoeol(); >-+ if (msg->env->x_comment_to) >-+ printw ("%-*.*s", W, W, msg->env->x_comment_to); >-+ } >-+ } >-+ break; >-+#endif >- case OP_COMPOSE_EDIT_SUBJECT: >- if (msg->env->subject) >- strfcpy (buf, msg->env->subject, sizeof (buf)); >-@@ -706,6 +840,9 @@ int mutt_compose_menu (HEADER *msg, /* >- break; >- >- case OP_COMPOSE_ATTACH_MESSAGE: >-+#ifdef USE_NNTP >-+ case OP_COMPOSE_ATTACH_NEWS_MESSAGE: >-+#endif >- { >- char *prompt; >- HEADER *h; >-@@ -713,7 +850,22 @@ int mutt_compose_menu (HEADER *msg, /* >- fname[0] = 0; >- prompt = _("Open mailbox to attach message from"); >- >-+#ifdef USE_NNTP >-+ unset_option (OPTNEWS); >-+ if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE) >-+ { >-+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer))) >-+ break; >-+ >-+ prompt = _("Open newsgroup to attach message from"); >-+ set_option (OPTNEWS); >-+ } >-+#endif >-+ >- if (Context) >-+#ifdef USE_NNTP >-+ if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP)) >-+#endif >- { >- strfcpy (fname, NONULL (Context->path), sizeof (fname)); >- mutt_pretty_mailbox (fname, sizeof (fname)); >-@@ -722,6 +874,11 @@ int mutt_compose_menu (HEADER *msg, /* >- if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0]) >- break; >- >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account); >-+ else >-+#endif >- mutt_expand_path (fname, sizeof (fname)); >- #ifdef USE_IMAP >- if (!mx_is_imap (fname)) >-@@ -729,6 +886,9 @@ int mutt_compose_menu (HEADER *msg, /* >- #ifdef USE_POP >- if (!mx_is_pop (fname)) >- #endif >-+#ifdef USE_NNTP >-+ if (!mx_is_nntp (fname) && !option (OPTNEWS)) >-+#endif >- /* check to make sure the file exists and is readable */ >- if (access (fname, R_OK) == -1) >- { >-diff -udprP mutt-1.5.20.orig/config.h.in mutt-1.5.20/config.h.in >---- mutt-1.5.20.orig/config.h.in 2009-06-09 09:51:15.000000000 +0300 >-+++ mutt-1.5.20/config.h.in 2009-06-15 21:05:24.000000000 +0300 >-@@ -37,6 +37,9 @@ >- significant more memory when defined. */ >- #undef EXACT_ADDRESS >- >-+/* Compiling with newsreading support with NNTP */ >-+#undef USE_NNTP >-+ >- /* program to use for shell commands */ >- #undef EXECSHELL >- >-diff -udprP mutt-1.5.20.orig/configure.ac mutt-1.5.20/configure.ac >---- mutt-1.5.20.orig/configure.ac 2009-06-09 09:50:33.000000000 +0300 >-+++ mutt-1.5.20/configure.ac 2009-06-15 21:05:24.000000000 +0300 >-@@ -599,6 +599,14 @@ if test x"$need_imap" = xyes -o x"$need_ >- MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o" >- fi >- >-+AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support], >-+[ if test x$enableval = xyes ; then >-+ AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ]) >-+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o" >-+ need_socket="yes" >-+ fi >-+]) >-+ >- dnl -- end socket dependencies -- >- >- if test "$need_socket" = "yes" >-diff -udprP mutt-1.5.20.orig/curs_main.c mutt-1.5.20/curs_main.c >---- mutt-1.5.20.orig/curs_main.c 2009-06-14 05:48:36.000000000 +0300 >-+++ mutt-1.5.20/curs_main.c 2009-06-15 21:47:09.000000000 +0300 >-@@ -22,6 +22,7 @@ >- >- #include "mutt.h" >- #include "mutt_curses.h" >-+#include "mx.h" >- #include "mutt_menu.h" >- #include "mailbox.h" >- #include "mapping.h" >-@@ -38,6 +39,10 @@ >- >- #include "mutt_crypt.h" >- >-+#ifdef USE_NNTP >-+#include "nntp.h" >-+#endif >-+ >- >- #include <ctype.h> >- #include <stdlib.h> >-@@ -413,12 +418,27 @@ static struct mapping_t IndexHelp[] = { >- { NULL, 0 } >- }; >- >-+#ifdef USE_NNTP >-+struct mapping_t IndexNewsHelp[] = { >-+ { N_("Quit"), OP_QUIT }, >-+ { N_("Del"), OP_DELETE }, >-+ { N_("Undel"), OP_UNDELETE }, >-+ { N_("Save"), OP_SAVE }, >-+ { N_("Post"), OP_POST }, >-+ { N_("Followup"), OP_FOLLOWUP }, >-+ { N_("Catchup"), OP_CATCHUP }, >-+ { N_("Help"), OP_HELP }, >-+ { NULL } >-+}; >-+#endif >-+ >- /* This function handles the message index window as well as commands returned >- * from the pager (MENU_PAGER). >- */ >- int mutt_index_menu (void) >- { >- char buf[LONG_STRING], helpstr[LONG_STRING]; >-+ int flags; >- int op = OP_NULL; >- int done = 0; /* controls when to exit the "event" loop */ >- int i = 0, j; >-@@ -439,7 +459,11 @@ int mutt_index_menu (void) >- menu->make_entry = index_make_entry; >- menu->color = index_color; >- menu->current = ci_first_message (); >-- menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp); >-+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, >-+#ifdef USE_NNTP >-+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : >-+#endif >-+ IndexHelp); >- >- if (!attach_msg) >- mutt_buffy_check(1); /* force the buffy check after we enter the folder */ >-@@ -690,6 +714,9 @@ int mutt_index_menu (void) >- imap_disallow_reopen (Context); >- #endif >- >-+#ifdef USE_NNTP >-+ unset_option (OPTNEWS); /* for any case */ >-+#endif >- switch (op) >- { >- >-@@ -740,6 +767,120 @@ int mutt_index_menu (void) >- menu_current_bottom (menu); >- break; >- >-+#ifdef USE_NNTP >-+ case OP_GET_MESSAGE: >-+ case OP_GET_PARENT: >-+ CHECK_MSGCOUNT; >-+ if (Context->magic == M_NNTP) >-+ { >-+ HEADER *h; >-+ >-+ if (op == OP_GET_MESSAGE) >-+ { >-+ buf[0] = 0; >-+ if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0 >-+ || !buf[0]) >-+ break; >-+ } >-+ else >-+ { >-+ LIST *ref = CURHDR->env->references; >-+ if (!ref) >-+ { >-+ mutt_error _("Article has no parent reference!"); >-+ break; >-+ } >-+ strfcpy (buf, ref->data, sizeof (buf)); >-+ } >-+ if (!Context->id_hash) >-+ Context->id_hash = mutt_make_id_hash (Context); >-+ if ((h = hash_find (Context->id_hash, buf))) >-+ { >-+ if (h->virtual != -1) >-+ { >-+ menu->current = h->virtual; >-+ menu->redraw = REDRAW_MOTION_RESYNCH; >-+ } >-+ else if (h->collapsed) >-+ { >-+ mutt_uncollapse_thread (Context, h); >-+ mutt_set_virtual (Context); >-+ menu->current = h->virtual; >-+ menu->redraw = REDRAW_MOTION_RESYNCH; >-+ } >-+ else >-+ mutt_error _("Message not visible in limited view."); >-+ } >-+ else >-+ { >-+ if (nntp_check_msgid (Context, buf) == 0) >-+ { >-+ h = Context->hdrs[Context->msgcount-1]; >-+ mutt_sort_headers (Context, 0); >-+ menu->current = h->virtual; >-+ menu->redraw = REDRAW_FULL; >-+ } >-+ else >-+ mutt_error (_("Article %s not found on server"), buf); >-+ } >-+ } >-+ break; >-+ >-+ case OP_GET_CHILDREN: >-+ case OP_RECONSTRUCT_THREAD: >-+ CHECK_MSGCOUNT; >-+ if (Context->magic == M_NNTP) >-+ { >-+ HEADER *h; >-+ int old = CURHDR->index, i; >-+ >-+ if (!CURHDR->env->message_id) >-+ { >-+ mutt_error _("No Message-Id. Unable to perform operation"); >-+ break; >-+ } >-+ >-+ if (!Context->id_hash) >-+ Context->id_hash = mutt_make_id_hash (Context); >-+ strfcpy (buf, CURHDR->env->message_id, sizeof (buf)); >-+ >-+ if (op == OP_RECONSTRUCT_THREAD) >-+ { >-+ LIST *ref = CURHDR->env->references; >-+ while (ref) >-+ { >-+ nntp_check_msgid (Context, ref->data); >-+ /* the last msgid in References is the root message */ >-+ if (!ref->next) >-+ strfcpy (buf, ref->data, sizeof (buf)); >-+ ref = ref->next; >-+ } >-+ } >-+ mutt_message _("Check for children of message..."); >-+ if (nntp_check_children (Context, buf) == 0) >-+ { >-+ mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD)); >-+ h = hash_find (Context->id_hash, buf); >-+ /* if the root message was retrieved, move to it */ >-+ if (h) >-+ menu->current = h->virtual; >-+ else /* try to restore old position */ >-+ for (i = 0; i < Context->msgcount; i++) >-+ if (Context->hdrs[i]->index == old) >-+ { >-+ menu->current = Context->hdrs[i]->virtual; >-+ /* As an added courtesy, recenter the menu >-+ * with the current entry at the middle of the screen */ >-+ menu_check_recenter (menu); >-+ menu_current_middle (menu); >-+ } >-+ } >-+ menu->redraw = REDRAW_FULL; >-+ mutt_clear_error (); >-+ } >-+ break; >-+#endif >-+ >- case OP_JUMP: >- >- CHECK_MSGCOUNT; >-@@ -836,11 +977,33 @@ int mutt_index_menu (void) >- break; >- >- case OP_MAIN_LIMIT: >-+ case OP_TOGGLE_READ: >- >- CHECK_IN_MAILBOX; >- menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ? >- CURHDR->index : -1; >-- if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0) >-+ if (op == OP_TOGGLE_READ) >-+ { >-+ char buf[LONG_STRING]; >-+ >-+ if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0) >-+ { >-+ snprintf (buf, sizeof (buf), "!~R!~D~s%s", >-+ Context->pattern ? Context->pattern : ".*"); >-+ set_option (OPTHIDEREAD); >-+ } >-+ else >-+ { >-+ strfcpy (buf, Context->pattern + 8, sizeof(buf)); >-+ if (!*buf || strncmp (buf, ".*", 2) == 0) >-+ snprintf (buf, sizeof(buf), "~A"); >-+ unset_option (OPTHIDEREAD); >-+ } >-+ FREE (&Context->pattern); >-+ Context->pattern = safe_strdup (buf); >-+ } >-+ if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) || >-+ mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0) >- { >- if (menu->oldcurrent >= 0) >- { >-@@ -1057,15 +1220,22 @@ int mutt_index_menu (void) >- >- case OP_MAIN_CHANGE_FOLDER: >- case OP_MAIN_NEXT_UNREAD_MAILBOX: >-- >-- if (attach_msg) >-- op = OP_MAIN_CHANGE_FOLDER_READONLY; >-- >-- /* fallback to the readonly case */ >-- >- case OP_MAIN_CHANGE_FOLDER_READONLY: >-+#ifdef USE_NNTP >-+ case OP_MAIN_CHANGE_GROUP: >-+ case OP_MAIN_CHANGE_GROUP_READONLY: >-+ unset_option (OPTNEWS); >-+#endif >-+ if (attach_msg || option (OPTREADONLY) || >-+#ifdef USE_NNTP >-+ op == OP_MAIN_CHANGE_GROUP_READONLY || >-+#endif >-+ op == OP_MAIN_CHANGE_FOLDER_READONLY) >-+ flags = M_READONLY; >-+ else >-+ flags = 0; >- >-- if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY)) >-+ if (flags) >- cp = _("Open mailbox in read-only mode"); >- else >- cp = _("Open mailbox"); >-@@ -1084,6 +1254,21 @@ int mutt_index_menu (void) >- } >- else >- { >-+#ifdef USE_NNTP >-+ if (op == OP_MAIN_CHANGE_GROUP || >-+ op == OP_MAIN_CHANGE_GROUP_READONLY) >-+ { >-+ set_option (OPTNEWS); >-+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer))) >-+ break; >-+ if (flags) >-+ cp = _("Open newsgroup in read-only mode"); >-+ else >-+ cp = _("Open newsgroup"); >-+ nntp_buffy (buf); >-+ } >-+ else >-+#endif >- mutt_buffy (buf, sizeof (buf)); >- >- if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) >-@@ -1103,6 +1288,14 @@ int mutt_index_menu (void) >- } >- } >- >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ { >-+ unset_option (OPTNEWS); >-+ nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account); >-+ } >-+ else >-+#endif >- mutt_expand_path (buf, sizeof (buf)); >- if (mx_get_magic (buf) <= 0) >- { >-@@ -1140,15 +1333,18 @@ int mutt_index_menu (void) >- CurrentMenu = MENU_MAIN; >- mutt_folder_hook (buf); >- >-- if ((Context = mx_open_mailbox (buf, >-- (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ? >-- M_READONLY : 0, NULL)) != NULL) >-+ if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL) >- { >- menu->current = ci_first_message (); >- } >- else >- menu->current = 0; >- >-+#ifdef USE_NNTP >-+ /* mutt_buffy_check() must be done with mail-reader mode! */ >-+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, >-+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp); >-+#endif >- mutt_clear_error (); >- mutt_buffy_check(1); /* force the buffy check after we have changed >- the folder */ >-@@ -1519,6 +1715,15 @@ int mutt_index_menu (void) >- CHECK_READONLY; >- CHECK_ACL(M_ACL_WRITE, _("flag message")); >- >-+#ifdef USE_NNTP >-+ if (Context->magic == M_NNTP) >-+ { >-+ mutt_flushinp (); >-+ mutt_error _("Can't change 'important' flag on NNTP server."); >-+ break; >-+ } >-+#endif >-+ >- if (tag) >- { >- for (j = 0; j < Context->vcount; j++) >-@@ -1866,6 +2071,17 @@ int mutt_index_menu (void) >- } >- break; >- >-+#ifdef USE_NNTP >-+ case OP_CATCHUP: >-+ if (Context && Context->magic == M_NNTP) >-+ { >-+ if (mutt_newsgroup_catchup (CurrentNewsSrv, >-+ ((NNTP_DATA *)Context->data)->group)) >-+ menu->redraw = REDRAW_INDEX | REDRAW_STATUS; >-+ } >-+ break; >-+#endif >-+ >- case OP_DISPLAY_ADDRESS: >- >- CHECK_MSGCOUNT; >-@@ -1993,6 +2209,15 @@ int mutt_index_menu (void) >- menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS; >- } >- #endif >-+ >-+#ifdef USE_NNTP >-+ if (Context->magic == M_NNTP) >-+ { >-+ mutt_flushinp (); >-+ mutt_error _("Can't edit message on newsserver."); >-+ break; >-+ } >-+#endif >- >- MAYBE_REDRAW (menu->redraw); >- break; >-@@ -2065,6 +2290,41 @@ int mutt_index_menu (void) >- menu->redraw = REDRAW_FULL; >- break; >- >-+#ifdef USE_NNTP >-+ case OP_FOLLOWUP: >-+ case OP_FORWARD_TO_GROUP: >-+ >-+ CHECK_MSGCOUNT; >-+ CHECK_VISIBLE; >-+ >-+ case OP_POST: >-+ >-+ CHECK_ATTACH; >-+ if (op != OP_FOLLOWUP || !CURHDR->env->followup_to || >-+ mutt_strcasecmp (CURHDR->env->followup_to, "poster") || >-+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES) >-+ { >-+ if (Context && Context->magic == M_NNTP && >-+ !((NNTP_DATA *)Context->data)->allowed && >-+ query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) >-+ break; >-+ if (op == OP_POST) >-+ ci_send_message (SENDNEWS, NULL, NULL, Context, NULL); >-+ else >-+ { >-+ CHECK_MSGCOUNT; >-+ if (op == OP_FOLLOWUP) >-+ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context, >-+ tag ? NULL : CURHDR); >-+ else >-+ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context, >-+ tag ? NULL : CURHDR); >-+ } >-+ menu->redraw = REDRAW_FULL; >-+ break; >-+ } >-+#endif >-+ >- case OP_REPLY: >- >- CHECK_ATTACH; >-@@ -2140,6 +2400,12 @@ int mutt_index_menu (void) >- CHECK_READONLY; >- CHECK_ACL(M_ACL_DELETE, _("undelete message(s)")); >- >-+#ifdef USE_NNTP >-+ /* Close all open NNTP connections */ >-+ if (!attach_msg) >-+ nntp_logout_all (); >-+#endif >-+ >- rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0, >- op == OP_UNDELETE_THREAD ? 0 : 1); >- >-diff -udprP mutt-1.5.20.orig/doc/manual.xml.head mutt-1.5.20/doc/manual.xml.head >---- mutt-1.5.20.orig/doc/manual.xml.head 2009-05-30 20:20:08.000000000 +0300 >-+++ mutt-1.5.20/doc/manual.xml.head 2009-06-15 21:05:24.000000000 +0300 >-@@ -1568,6 +1568,22 @@ fo-table</literal> for details. >- >- </sect2> >- >-+<sect2> >-+<title>Reading news via NNTP</title> >-+ >-+<para> >-+If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can >-+read news from newsserver via NNTP. You can open a newsgroup with >-+function ``change-newsgroup'' (default: ``i''). Default newsserver >-+can be obtained from <emphasis>NNTPSERVER</emphasis> environment >-+variable. Like other news readers, info about subscribed newsgroups >-+is saved in file by <link linkend="newsrc">$newsrc</link> >-+variable. Article headers are cached and can be loaded from file when >-+newsgroup entered instead loading from newsserver. >-+</para> >-+ >-+</sect2> >-+ >- </sect1> >- >- <sect1 id="forwarding-mail"> >-diff -udprP mutt-1.5.20.orig/doc/mutt.man mutt-1.5.20/doc/mutt.man >---- mutt-1.5.20.orig/doc/mutt.man 2009-06-07 03:32:44.000000000 +0300 >-+++ mutt-1.5.20/doc/mutt.man 2009-06-15 21:07:47.000000000 +0300 >-@@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent >- .SH SYNOPSIS >- .PP >- .B mutt >--[\-nRyzZ] >--[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-m \fItype\fP] [\-f \fIfile\fP] >-+[-GnRyzZ] >-+[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-g \fIserver\fP] [\-m \fItype\fP] [\-f \fIfile\fP] >- .PP >- .B mutt >- [\-nx] >-@@ -101,6 +101,10 @@ files. >- Specify which mailbox to load. >- .IP "-F \fImuttrc\fP" >- Specify an initialization file to read instead of ~/.muttrc >-+.IP "-g \fIserver\fP" >-+Start Mutt with a listing of subscribed newsgroups at specified newsserver. >-+.IP "-G" >-+Start Mutt with a listing of subscribed newsgroups. >- .IP "-h" >- Display help. >- .IP "-H \fIdraft\fP" >-diff -udprP mutt-1.5.20.orig/functions.h mutt-1.5.20/functions.h >---- mutt-1.5.20.orig/functions.h 2009-04-30 08:36:17.000000000 +0300 >-+++ mutt-1.5.20/functions.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in >- { "break-thread", OP_MAIN_BREAK_THREAD, "#" }, >- { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" }, >- { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" }, >-+#ifdef USE_NNTP >-+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" }, >-+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" }, >-+#endif >- { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL }, >- { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" }, >- { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" }, >-@@ -101,7 +105,15 @@ struct binding_t OpMain[] = { /* map: in >- { "edit", OP_EDIT_MESSAGE, "e" }, >- { "edit-type", OP_EDIT_TYPE, "\005" }, >- { "forward-message", OP_FORWARD_MESSAGE, "f" }, >-- { "flag-message", OP_FLAG_MESSAGE, "F" }, >-+#ifdef USE_NNTP >-+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" }, >-+ { "followup-message", OP_FOLLOWUP, "F" }, >-+ { "get-children", OP_GET_CHILDREN, NULL }, >-+ { "get-message", OP_GET_MESSAGE, "\007" }, >-+ { "get-parent", OP_GET_PARENT, "\033G" }, >-+ { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL }, >-+#endif >-+ { "flag-message", OP_FLAG_MESSAGE, "\033f" }, >- { "group-reply", OP_GROUP_REPLY, "g" }, >- #ifdef USE_POP >- { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" }, >-@@ -127,6 +139,9 @@ struct binding_t OpMain[] = { /* map: in >- { "sort-mailbox", OP_SORT, "o" }, >- { "sort-reverse", OP_SORT_REVERSE, "O" }, >- { "print-message", OP_PRINT, "p" }, >-+#ifdef USE_NNTP >-+ { "post-message", OP_POST, "P" }, >-+#endif >- { "previous-thread", OP_MAIN_PREV_THREAD, "\020" }, >- { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" }, >- { "recall-message", OP_RECALL_MESSAGE, "R" }, >-@@ -146,6 +161,10 @@ struct binding_t OpMain[] = { /* map: in >- { "show-version", OP_VERSION, "V" }, >- { "set-flag", OP_MAIN_SET_FLAG, "w" }, >- { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" }, >-+ { "toggle-read", OP_TOGGLE_READ, "X" }, >-+#ifdef USE_NNTP >-+ { "catchup", OP_CATCHUP, "y" }, >-+#endif >- { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S }, >- { "buffy-list", OP_BUFFY_LIST, "." }, >- { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" }, >-@@ -157,7 +176,7 @@ struct binding_t OpMain[] = { /* map: in >- { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" }, >- { "next-unread", OP_MAIN_NEXT_UNREAD, NULL }, >- { "previous-unread", OP_MAIN_PREV_UNREAD, NULL }, >-- { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" }, >-+ { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL }, >- >- >- { "extract-keys", OP_EXTRACT_KEYS, "\013" }, >-@@ -177,6 +196,10 @@ struct binding_t OpPager[] = { /* map: p >- { "bounce-message", OP_BOUNCE_MESSAGE, "b" }, >- { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" }, >- { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" }, >-+#ifdef USE_NNTP >-+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" }, >-+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" }, >-+#endif >- { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL }, >- { "copy-message", OP_COPY_MESSAGE, "C" }, >- { "decode-copy", OP_DECODE_COPY, "\033C" }, >-@@ -187,8 +210,12 @@ struct binding_t OpPager[] = { /* map: p >- { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" }, >- { "edit", OP_EDIT_MESSAGE, "e" }, >- { "edit-type", OP_EDIT_TYPE, "\005" }, >-+#ifdef USE_NNTP >-+ { "followup-message", OP_FOLLOWUP, "F" }, >-+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" }, >-+#endif >- { "forward-message", OP_FORWARD_MESSAGE, "f" }, >-- { "flag-message", OP_FLAG_MESSAGE, "F" }, >-+ { "flag-message", OP_FLAG_MESSAGE, "\033f" }, >- { "group-reply", OP_GROUP_REPLY, "g" }, >- #ifdef USE_IMAP >- { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL }, >-@@ -207,6 +234,9 @@ struct binding_t OpPager[] = { /* map: p >- { "next-thread", OP_MAIN_NEXT_THREAD, "\016" }, >- { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" }, >- { "print-message", OP_PRINT, "p" }, >-+#ifdef USE_NNTP >-+ { "post-message", OP_POST, "P" }, >-+#endif >- { "previous-thread", OP_MAIN_PREV_THREAD, "\020" }, >- { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" }, >- { "quit", OP_QUIT, "Q" }, >-@@ -254,7 +284,7 @@ struct binding_t OpPager[] = { /* map: p >- { "half-down", OP_HALF_DOWN, NULL }, >- { "previous-line", OP_PREV_LINE, NULL }, >- { "bottom", OP_PAGER_BOTTOM, NULL }, >-- { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" }, >-+ { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL }, >- >- >- >-@@ -275,6 +305,10 @@ struct binding_t OpAttach[] = { /* map: >- { "bounce-message", OP_BOUNCE_MESSAGE, "b" }, >- { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" }, >- { "edit-type", OP_EDIT_TYPE, "\005" }, >-+#ifdef USE_NNTP >-+ { "followup-message", OP_FOLLOWUP, "F" }, >-+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" }, >-+#endif >- { "print-entry", OP_PRINT, "p" }, >- { "save-entry", OP_SAVE, "s" }, >- { "pipe-entry", OP_PIPE, "|" }, >-@@ -300,6 +334,7 @@ struct binding_t OpAttach[] = { /* map: >- struct binding_t OpCompose[] = { /* map: compose */ >- { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" }, >- { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" }, >-+ { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" }, >- { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" }, >- { "edit-cc", OP_COMPOSE_EDIT_CC, "c" }, >- { "copy-file", OP_SAVE, "C" }, >-@@ -319,6 +354,11 @@ struct binding_t OpCompose[] = { /* map: >- { "print-entry", OP_PRINT, "l" }, >- { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" }, >- { "new-mime", OP_COMPOSE_NEW_MIME, "n" }, >-+#ifdef USE_NNTP >-+ { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" }, >-+ { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" }, >-+ { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" }, >-+#endif >- { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" }, >- { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" }, >- { "rename-file", OP_COMPOSE_RENAME_FILE, "R" }, >-@@ -370,14 +410,25 @@ struct binding_t OpBrowser[] = { /* map: >- { "select-new", OP_BROWSER_NEW_FILE, "N" }, >- { "check-new", OP_CHECK_NEW, NULL }, >- { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" }, >-+#ifdef USE_NNTP >-+ { "reload-active", OP_LOAD_ACTIVE, "g" }, >-+ { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" }, >-+ { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" }, >-+ { "catchup", OP_CATCHUP, "y" }, >-+ { "uncatchup", OP_UNCATCHUP, "Y" }, >-+#endif >- { "view-file", OP_BROWSER_VIEW_FILE, " " }, >- { "buffy-list", OP_BUFFY_LIST, "." }, >- #ifdef USE_IMAP >- { "create-mailbox", OP_CREATE_MAILBOX, "C" }, >- { "delete-mailbox", OP_DELETE_MAILBOX, "d" }, >- { "rename-mailbox", OP_RENAME_MAILBOX, "r" }, >-+#endif >-+#if defined USE_IMAP || defined USE_NNTP >- { "subscribe", OP_BROWSER_SUBSCRIBE, "s" }, >- { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" }, >-+#endif >-+#ifdef USE_IMAP >- { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" }, >- #endif >- { NULL, 0, NULL } >-diff -udprP mutt-1.5.20.orig/globals.h mutt-1.5.20/globals.h >---- mutt-1.5.20.orig/globals.h 2009-06-03 23:48:31.000000000 +0300 >-+++ mutt-1.5.20/globals.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -95,6 +95,15 @@ WHERE char *MixEntryFormat; >- #endif >- >- WHERE char *Muttrc INITVAL (NULL); >-+#ifdef USE_NNTP >-+WHERE char *NewsCacheDir; >-+WHERE char *GroupFormat; >-+WHERE char *Inews; >-+WHERE char *NewsServer; >-+WHERE char *NntpUser; >-+WHERE char *NntpPass; >-+WHERE char *NewsRc; >-+#endif >- WHERE char *Outbox; >- WHERE char *Pager; >- WHERE char *PagerFmt; >-@@ -188,6 +197,11 @@ extern unsigned char QuadOptions[]; >- >- WHERE unsigned short Counter INITVAL (0); >- >-+#ifdef USE_NNTP >-+WHERE short NewsPollTimeout; >-+WHERE short NntpContext; >-+#endif >-+ >- WHERE short ConnectTimeout; >- WHERE short HistSize; >- WHERE short MenuContext; >-diff -udprP mutt-1.5.20.orig/hash.c mutt-1.5.20/hash.c >---- mutt-1.5.20.orig/hash.c 2009-03-31 09:52:43.000000000 +0300 >-+++ mutt-1.5.20/hash.c 2009-06-15 21:19:59.000000000 +0300 >-@@ -57,6 +57,7 @@ HASH *hash_create (int nelem, int lower) >- if (nelem == 0) >- nelem = 2; >- table->nelem = nelem; >-+ table->curnelem = 0; >- table->table = safe_calloc (nelem, sizeof (struct hash_elem *)); >- if (lower) >- { >-@@ -71,6 +72,29 @@ HASH *hash_create (int nelem, int lower) >- return table; >- } >- >-+HASH *hash_resize (HASH *ptr, int nelem, int lower) >-+{ >-+ HASH *table; >-+ struct hash_elem *elem, *tmp; >-+ int i; >-+ >-+ table = hash_create (nelem, lower); >-+ >-+ for (i = 0; i < ptr->nelem; i++) >-+ { >-+ for (elem = ptr->table[i]; elem; ) >-+ { >-+ tmp = elem; >-+ elem = elem->next; >-+ hash_insert (table, tmp->key, tmp->data, 1); >-+ FREE (&tmp); >-+ } >-+ } >-+ FREE (&ptr->table); >-+ FREE (&ptr); >-+ return table; >-+} >-+ >- /* table hash table to update >- * key key to hash on >- * data data to associate with `key' >-@@ -90,6 +114,7 @@ int hash_insert (HASH * table, const cha >- { >- ptr->next = table->table[h]; >- table->table[h] = ptr; >-+ table->curnelem++; >- } >- else >- { >-@@ -112,6 +137,7 @@ int hash_insert (HASH * table, const cha >- else >- table->table[h] = ptr; >- ptr->next = tmp; >-+ table->curnelem++; >- } >- return h; >- } >-@@ -142,6 +168,7 @@ void hash_delete_hash (HASH * table, int >- if (destroy) >- destroy (ptr->data); >- FREE (&ptr); >-+ table->curnelem--; >- >- ptr = *last; >- } >-diff -udprP mutt-1.5.20.orig/hash.h mutt-1.5.20/hash.h >---- mutt-1.5.20.orig/hash.h 2009-03-31 09:52:43.000000000 +0300 >-+++ mutt-1.5.20/hash.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -28,7 +28,7 @@ struct hash_elem >- >- typedef struct >- { >-- int nelem; >-+ int nelem, curnelem; >- struct hash_elem **table; >- unsigned int (*hash_string)(const unsigned char *, unsigned int); >- int (*cmp_string)(const char *, const char *); >-@@ -41,6 +41,7 @@ HASH; >- >- HASH *hash_create (int nelem, int lower); >- int hash_insert (HASH * table, const char *key, void *data, int allow_dup); >-+HASH *hash_resize (HASH * table, int nelem, int lower); >- void *hash_find_hash (const HASH * table, int hash, const char *key); >- void hash_delete_hash (HASH * table, int hash, const char *key, const void *data, >- void (*destroy) (void *)); >-diff -udprP mutt-1.5.20.orig/hdrline.c mutt-1.5.20/hdrline.c >---- mutt-1.5.20.orig/hdrline.c 2009-04-13 19:24:55.000000000 +0300 >-+++ mutt-1.5.20/hdrline.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -211,6 +211,7 @@ int mutt_user_is_recipient (HEADER *h) >- * %E = number of messages in current thread >- * %f = entire from line >- * %F = like %n, unless from self >-+ * %g = newsgroup name (if compiled with nntp support) >- * %i = message-id >- * %l = number of lines in the message >- * %L = like %F, except `lists' are displayed first >-@@ -219,12 +220,14 @@ int mutt_user_is_recipient (HEADER *h) >- * %N = score >- * %O = like %L, except using address instead of name >- * %P = progress indicator for builtin pager >-+ * %R = `x-comment-to:' field (if present and compiled with nntp support) >- * %s = subject >- * %S = short message status (e.g., N/O/D/!/r/-) >- * %t = `to:' field (recipients) >- * %T = $to_chars >- * %u = user (login) name of author >- * %v = first name of author, unless from self >-+ * %W = where user is (organization) >- * %X = number of MIME attachments >- * %y = `x-label:' field (if present) >- * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label) >-@@ -457,6 +460,12 @@ hdr_format_str (char *dest, >- >- break; >- >-+#ifdef USE_NNTP >-+ case 'g': >-+ mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : ""); >-+ break; >-+#endif >-+ >- case 'i': >- mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>"); >- break; >-@@ -548,6 +557,15 @@ hdr_format_str (char *dest, >- strfcpy(dest, NONULL(hfi->pager_progress), destlen); >- break; >- >-+#ifdef USE_NNTP >-+ case 'R': >-+ if (!optional) >-+ mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : ""); >-+ else if (!hdr->env->x_comment_to) >-+ optional = 0; >-+ break; >-+#endif >-+ >- case 's': >- >- if (flags & M_FORMAT_TREE && !hdr->collapsed) >-@@ -637,6 +655,13 @@ hdr_format_str (char *dest, >- mutt_format_s (dest, destlen, prefix, buf2); >- break; >- >-+ case 'W': >-+ if (!optional) >-+ mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : ""); >-+ else if (!hdr->env->organization) >-+ optional = 0; >-+ break; >-+ >- case 'Z': >- >- ch = ' '; >-diff -udprP mutt-1.5.20.orig/headers.c mutt-1.5.20/headers.c >---- mutt-1.5.20.orig/headers.c 2009-04-30 08:36:17.000000000 +0300 >-+++ mutt-1.5.20/headers.c 2009-06-15 21:17:07.000000000 +0300 >-@@ -114,6 +114,9 @@ void mutt_edit_headers (const char *edit >- $edit_headers set, we remove References: as they're likely invalid; >- we can simply compare strings as we don't generate References for >- multiple Message-Ids in IRT anyways */ >-+#ifdef USE_NNTP >-+ if (!option (OPTNEWSSEND)) >-+#endif >- if (!n->in_reply_to || (msg->env->in_reply_to && >- mutt_strcmp (n->in_reply_to->data, >- msg->env->in_reply_to->data) != 0)) >-diff -udprP mutt-1.5.20.orig/init.c mutt-1.5.20/init.c >---- mutt-1.5.20.orig/init.c 2009-06-01 19:29:32.000000000 +0300 >-+++ mutt-1.5.20/init.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -2966,6 +2966,28 @@ void mutt_init (int skip_sys_rc, LIST *c >- else >- Fqdn = safe_strdup(NONULL(Hostname)); >- >-+#ifdef USE_NNTP >-+ { >-+ FILE *f; >-+ char *i; >-+ >-+ if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r"))) >-+ { >-+ buffer[0] = '\0'; >-+ fgets (buffer, sizeof (buffer), f); >-+ p = &buffer; >-+ SKIPWS (p); >-+ i = p; >-+ while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++; >-+ *i = '\0'; >-+ NewsServer = safe_strdup (p); >-+ fclose (f); >-+ } >-+ } >-+ if ((p = getenv ("NNTPSERVER"))) >-+ NewsServer = safe_strdup (p); >-+#endif >-+ >- if ((p = getenv ("MAIL"))) >- Spoolfile = safe_strdup (p); >- else if ((p = getenv ("MAILDIR"))) >-diff -udprP mutt-1.5.20.orig/init.h mutt-1.5.20/init.h >---- mutt-1.5.20.orig/init.h 2009-06-14 00:35:21.000000000 +0300 >-+++ mutt-1.5.20/init.h 2009-06-15 21:15:03.000000000 +0300 >-@@ -176,6 +176,20 @@ struct option_t MuttVars[] = { >- ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before >- ** editing the body of an outgoing message. >- */ >-+#ifdef USE_NNTP >-+ { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 }, >-+ /* >-+ ** .pp >-+ ** If set, Mutt will prompt you for follow-up groups before editing >-+ ** the body of an outgoing message. >-+ */ >-+ { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 }, >-+ /* >-+ ** .pp >-+ ** If set, Mutt will prompt you for x-comment-to field before editing >-+ ** the body of an outgoing message. >-+ */ >-+#endif >- { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0}, >- /* >- ** .pp >-@@ -322,6 +336,14 @@ struct option_t MuttVars[] = { >- ** follow these menus. The option is \fIunset\fP by default because many >- ** visual terminals don't permit making the cursor invisible. >- */ >-+#ifdef USE_NNTP >-+ { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES }, >-+ /* >-+ ** .pp >-+ ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup >-+ ** as read when you quit the newsgroup (catchup newsgroup). >-+ */ >-+#endif >- #if defined(USE_SSL) >- { "certificate_file", DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" }, >- /* >-@@ -797,6 +819,16 @@ struct option_t MuttVars[] = { >- ** sent to both the list and your address, resulting in two copies >- ** of the same email for you. >- */ >-+#ifdef USE_NNTP >-+ { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES }, >-+ /* >-+ ** .pp >-+ ** If this variable is \fIset\fP and the keyword "poster" is present in >-+ ** \fIFollowup-To\fP header, follow-up to newsgroup function is not >-+ ** permitted. The message will be mailed to the submitter of the >-+ ** message via mail. >-+ */ >-+#endif >- { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 }, >- /* >- ** .pp >-@@ -879,6 +911,27 @@ struct option_t MuttVars[] = { >- ** a regular expression that will match the whole name so mutt will expand >- ** ``Franklin'' to ``Franklin, Steve''. >- */ >-+#ifdef USE_NNTP >-+ { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" }, >-+ /* >-+ ** .pp >-+ ** This variable allows you to customize the newsgroup browser display to >-+ ** your personal taste. This string is similar to ``$index_format'', but >-+ ** has its own set of printf()-like sequences: >-+ ** .pp >-+ ** .ts >-+ ** %C current newsgroup number >-+ ** %d description of newsgroup (becomes from server) >-+ ** %f newsgroup name >-+ ** %M - if newsgroup not allowed for direct post (moderated for example) >-+ ** %N N if newsgroup is new, u if unsubscribed, blank otherwise >-+ ** %n number of new articles in newsgroup >-+ ** %s number of unread articles in newsgroup >-+ ** %>X right justify the rest of the string and pad with character "X" >-+ ** %|X pad to the end of the line with character "X" >-+ ** .te >-+ */ >-+#endif >- { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 }, >- /* >- */ >-@@ -1255,6 +1308,7 @@ struct option_t MuttVars[] = { >- ** .dt %E .dd number of messages in current thread >- ** .dt %f .dd sender (address + real name), either From: or Return-Path: >- ** .dt %F .dd author name, or recipient name if the message is from you >-+ ** .dt %g .dd newsgroup name (if compiled with nntp support) >- ** .dt %H .dd spam attribute(s) of this message >- ** .dt %i .dd message-id of the current message >- ** .dt %l .dd number of lines in the message (does not work with maildir, >-@@ -1270,12 +1324,14 @@ struct option_t MuttVars[] = { >- ** stashed the message: list name or recipient name >- ** if not sent to a list >- ** .dt %P .dd progress indicator for the built-in pager (how much of the file has been displayed) >-+ ** .dt %R .dd `x-comment-to:' field (if present and compiled with nntp support) >- ** .dt %s .dd subject of the message >- ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as) >- ** .dt %t .dd ``To:'' field (recipients) >- ** .dt %T .dd the appropriate character from the $$to_chars string >- ** .dt %u .dd user (login) name of the author >- ** .dt %v .dd first name of the author, or the recipient if the message is from you >-+ ** .dt %W .dd name of organization of author (`organization:' field) >- ** .dt %X .dd number of attachments >- ** (please see the ``$attachments'' section for possible speed effects) >- ** .dt %y .dd ``X-Label:'' field, if present >-@@ -1310,6 +1366,21 @@ struct option_t MuttVars[] = { >- ** Note that these expandos are supported in >- ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too. >- */ >-+#ifdef USE_NNTP >-+ { "inews", DT_PATH, R_NONE, UL &Inews, UL "" }, >-+ /* >-+ ** .pp >-+ ** If set, specifies the program and arguments used to deliver news posted >-+ ** by Mutt. Otherwise, mutt posts article using current connection to >-+ ** news server. The following printf-style sequence is understood: >-+ ** .pp >-+ ** .ts >-+ ** %s newsserver name >-+ ** .te >-+ ** .pp >-+ ** Example: set inews="/usr/local/bin/inews -hS" >-+ */ >-+#endif >- { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL }, >- /* >- ** .pp >-@@ -1533,6 +1604,15 @@ struct option_t MuttVars[] = { >- ** menu, attachments which cannot be decoded in a reasonable manner will >- ** be attached to the newly composed message if this option is \fIset\fP. >- */ >-+#ifdef USE_NNTP >-+ { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 }, >-+ /* >-+ ** .pp >-+ ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be >-+ ** encoded according to RFC2047 to base64. This is useful when message >-+ ** is Usenet article, because MIME for news is nonstandard feature. >-+ */ >-+#endif >- #ifdef MIXMASTER >- { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" }, >- /* >-@@ -1580,6 +1660,77 @@ struct option_t MuttVars[] = { >- ** See also $$read_inc, $$write_inc and $$net_inc. >- */ >- #endif >-+#ifdef USE_NNTP >-+ { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" }, >-+ /* >-+ ** .pp >-+ ** This variable pointing to directory where Mutt will save cached news >-+ ** articles headers in. If \fIunset\fP, headers will not be saved at all >-+ ** and will be reloaded each time when you enter to newsgroup. >-+ */ >-+ { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 }, >-+ /* >-+ ** .pp >-+ ** This variable specifies domain name or address of NNTP server. It >-+ ** defaults to the newsserver specified in the environment variable >-+ ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also >-+ ** specify username and an alternative port for each newsserver, ie: >-+ ** .pp >-+ ** [news[s]://][username[:password]@]newsserver[:port] >-+ */ >-+ { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" }, >-+ /* >-+ ** .pp >-+ ** The file, containing info about subscribed newsgroups - names and >-+ ** indexes of read articles. The following printf-style sequence >-+ ** is understood: >-+ ** .pp >-+ ** .ts >-+ ** %s newsserver name >-+ ** .te >-+ */ >-+ { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 }, >-+ /* >-+ ** .pp >-+ ** This variable defines number of articles which will be in index when >-+ ** newsgroup entered. If active newsgroup have more articles than this >-+ ** number, oldest articles will be ignored. Also controls how many >-+ ** articles headers will be saved in cache when you quit newsgroup. >-+ */ >-+ { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 }, >-+ /* >-+ ** .pp >-+ ** This variable controls whether or not descriptions for each newsgroup >-+ ** must be loaded when newsgroup is added to list (first time list >-+ ** loading or new newsgroup adding). >-+ */ >-+ { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" }, >-+ /* >-+ ** .pp >-+ ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires >-+ ** authentification, Mutt will prompt you for your account name when you >-+ ** connect to newsserver. >-+ */ >-+ { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" }, >-+ /* >-+ ** .pp >-+ ** Your password for NNTP account. >-+ */ >-+ { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 }, >-+ /* >-+ ** .pp >-+ ** The time in seconds until any operations on newsgroup except post new >-+ ** article will cause recheck for new news. If set to 0, Mutt will >-+ ** recheck newsgroup on each operation in index (stepping, read article, >-+ ** etc.). >-+ */ >-+ { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES }, >-+ /* >-+ ** .pp >-+ ** Controls whether or not Mutt will try to reconnect to newsserver when >-+ ** connection lost. >-+ */ >-+#endif >- { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" }, >- /* >- ** .pp >-@@ -2079,6 +2230,16 @@ struct option_t MuttVars[] = { >- { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 }, >- /* >- */ >-+#ifdef USE_NNTP >-+ { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES }, >-+ /* >-+ ** .pp >-+ ** If set to \fIyes\fP, Mutt will post article to newsgroup that have >-+ ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver >-+ ** does not support posting to that newsgroup or totally read-only, that >-+ ** posting will not have an effect. >-+ */ >-+#endif >- { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES }, >- /* >- ** .pp >-@@ -2479,6 +2640,28 @@ struct option_t MuttVars[] = { >- ** Command to use when spawning a subshell. By default, the user's login >- ** shell from \fC/etc/passwd\fP is used. >- */ >-+#ifdef USE_NNTP >-+ { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 }, >-+ /* >-+ ** .pp >-+ ** When \fIset\fP, info about unsubscribed newsgroups will be saved into >-+ ** ``newsrc'' file and into cache. >-+ */ >-+ { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 }, >-+ /* >-+ ** .pp >-+ ** If \fIset\fP, newsserver will be asked for new newsgroups on entering >-+ ** the browser. Otherwise, it will be done only once for a newsserver. >-+ ** Also controls whether or not number of new articles of subscribed >-+ ** newsgroups will be then checked. >-+ */ >-+ { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 }, >-+ /* >-+ ** .pp >-+ ** If \fIset\fP, only subscribed newsgroups that contain unread articles >-+ ** will be displayed in browser. >-+ */ >-+#endif >- { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 }, >- /* >- ** .pp >-@@ -3337,6 +3520,14 @@ struct option_t MuttVars[] = { >- ** Also see the $$read_inc, $$net_inc and $$time_inc variables and the >- ** ``$tuning'' section of the manual for performance considerations. >- */ >-+#ifdef USE_NNTP >-+ { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 }, >-+ /* >-+ ** .pp >-+ ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full >-+ ** name of original article author) to article that followuped to newsgroup. >-+ */ >-+#endif >- /*--*/ >- { NULL, 0, 0, 0, 0 } >- }; >-diff -udprP mutt-1.5.20.orig/keymap.c mutt-1.5.20/keymap.c >---- mutt-1.5.20.orig/keymap.c 2008-11-29 23:09:10.000000000 +0200 >-+++ mutt-1.5.20/keymap.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -654,7 +654,6 @@ void km_init (void) >- km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE); >- >- km_bindkey ("x", MENU_PAGER, OP_EXIT); >-- km_bindkey ("i", MENU_PAGER, OP_EXIT); >- km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE); >- km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE); >- km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE); >-diff -udprP mutt-1.5.20.orig/mailbox.h mutt-1.5.20/mailbox.h >---- mutt-1.5.20.orig/mailbox.h 2009-04-30 08:36:17.000000000 +0300 >-+++ mutt-1.5.20/mailbox.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -74,6 +74,9 @@ int mx_is_imap (const char *); >- #ifdef USE_POP >- int mx_is_pop (const char *); >- #endif >-+#ifdef USE_NNTP >-+int mx_is_nntp (const char *); >-+#endif >- >- int mx_access (const char*, int); >- int mx_check_empty (const char *); >-diff -udprP mutt-1.5.20.orig/main.c mutt-1.5.20/main.c >---- mutt-1.5.20.orig/main.c 2009-06-01 19:29:32.000000000 +0300 >-+++ mutt-1.5.20/main.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -60,6 +60,10 @@ >- #include <stringprep.h> >- #endif >- >-+#ifdef USE_NNTP >-+#include "nntp.h" >-+#endif >-+ >- static const char *ReachingUs = N_("\ >- To contact the developers, please mail to <mutt-dev@mutt.org>.\n\ >- To report a bug, please visit http://bugs.mutt.org/.\n"); >-@@ -133,6 +137,8 @@ options:\n\ >- " -e <command>\tspecify a command to be executed after initialization\n\ >- -f <file>\tspecify which mailbox to read\n\ >- -F <file>\tspecify an alternate muttrc file\n\ >-+ -g <server>\tspecify a newsserver (if compiled with NNTP)\n\ >-+ -G\t\tselect a newsgroup (if compiled with NNTP)\n\ >- -H <file>\tspecify a draft file to read header and body from\n\ >- -i <file>\tspecify a file which Mutt should include in the body\n\ >- -m <type>\tspecify a default mailbox type\n\ >-@@ -255,6 +261,12 @@ static void show_version (void) >- "-USE_POP " >- #endif >- >-+#ifdef USE_NNTP >-+ "+USE_NNTP " >-+#else >-+ "-USE_NNTP " >-+#endif >-+ >- #ifdef USE_IMAP >- "+USE_IMAP " >- #else >-@@ -522,6 +534,9 @@ static void start_curses (void) >- #define M_NOSYSRC (1<<2) /* -n */ >- #define M_RO (1<<3) /* -R */ >- #define M_SELECT (1<<4) /* -y */ >-+#ifdef USE_NNTP >-+#define M_NEWS (1<<5) /* -g and -G */ >-+#endif >- >- int main (int argc, char **argv) >- { >-@@ -594,7 +609,11 @@ int main (int argc, char **argv) >- argv[nargc++] = argv[optind]; >- } >- >-+#ifdef USE_NNTP >-+ if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF) >-+#else >- if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF) >-+#endif >- switch (i) >- { >- case 'A': >-@@ -691,6 +710,20 @@ int main (int argc, char **argv) >- flags |= M_SELECT; >- break; >- >-+#ifdef USE_NNTP >-+ case 'g': /* Specify a newsserver */ >-+ { >-+ char buf[LONG_STRING]; >-+ >-+ snprintf (buf, sizeof (buf), "set news_server=%s", optarg); >-+ commands = mutt_add_list (commands, buf); >-+ } >-+ >-+ case 'G': /* List of newsgroups */ >-+ flags |= M_SELECT | M_NEWS; >-+ break; >-+#endif >-+ >- case 'z': >- flags |= M_IGNORE; >- break; >-@@ -978,6 +1011,18 @@ int main (int argc, char **argv) >- } >- else if (flags & M_SELECT) >- { >-+#ifdef USE_NNTP >-+ if (flags & M_NEWS) >-+ { >-+ set_option (OPTNEWS); >-+ if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer))) >-+ { >-+ mutt_endwin (Errorbuf); >-+ exit (1); >-+ } >-+ } >-+ else >-+#endif >- if (!Incoming) { >- mutt_endwin _("No incoming mailboxes defined."); >- exit (1); >-@@ -993,6 +1038,15 @@ int main (int argc, char **argv) >- >- if (!folder[0]) >- strfcpy (folder, NONULL(Spoolfile), sizeof (folder)); >-+ >-+#ifdef USE_NNTP >-+ if (option (OPTNEWS)) >-+ { >-+ unset_option (OPTNEWS); >-+ nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account); >-+ } >-+ else >-+#endif >- mutt_expand_path (folder, sizeof (folder)); >- >- mutt_str_replace (&CurrentFolder, folder); >-diff -udprP mutt-1.5.20.orig/mutt.h mutt-1.5.20/mutt.h >---- mutt-1.5.20.orig/mutt.h 2009-06-13 01:15:42.000000000 +0300 >-+++ mutt-1.5.20/mutt.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -229,6 +229,9 @@ enum >- M_PGP_KEY, >- M_XLABEL, >- M_MIMEATTACH, >-+#ifdef USE_NNTP >-+ M_NEWSGROUPS, >-+#endif >- >- /* Options for Mailcap lookup */ >- M_EDIT, >-@@ -285,6 +288,12 @@ enum >- #endif >- OPT_SUBJECT, >- OPT_VERIFYSIG, /* verify PGP signatures */ >-+#ifdef USE_NNTP >-+ OPT_TOMODERATED, >-+ OPT_NNTPRECONNECT, >-+ OPT_CATCHUP, >-+ OPT_FOLLOWUPTOPOSTER, >-+#endif /* USE_NNTP */ >- >- /* THIS MUST BE THE LAST VALUE. */ >- OPT_MAX >-@@ -300,6 +309,7 @@ enum >- #define SENDMAILX (1<<6) >- #define SENDKEY (1<<7) >- #define SENDRESEND (1<<8) >-+#define SENDNEWS (1<<9) >- >- /* flags to _mutt_select_file() */ >- #define M_SEL_BUFFY (1<<0) >-@@ -319,6 +329,8 @@ enum >- OPTASCIICHARS, >- OPTASKBCC, >- OPTASKCC, >-+ OPTASKFOLLOWUP, >-+ OPTASKXCOMMENTTO, >- OPTATTACHSPLIT, >- OPTAUTOEDIT, >- OPTAUTOTAG, >-@@ -396,6 +408,9 @@ enum >- OPTMETOO, >- OPTMHPURGE, >- OPTMIMEFORWDECODE, >-+#ifdef USE_NNTP >-+ OPTMIMESUBJECT, /* encode subject line with RFC2047 */ >-+#endif >- OPTNARROWTREE, >- OPTPAGERSTOP, >- OPTPIPEDECODE, >-@@ -477,6 +492,16 @@ enum >- OPTPGPAUTOINLINE, >- OPTPGPREPLYINLINE, >- >-+ /* news options */ >-+ >-+#ifdef USE_NNTP >-+ OPTSHOWNEWNEWS, >-+ OPTSHOWONLYUNREAD, >-+ OPTSAVEUNSUB, >-+ OPTLOADDESC, >-+ OPTXCOMMENTTO, >-+#endif /* USE_NNTP */ >-+ >- /* pseudo options */ >- >- OPTAUXSORT, /* (pseudo) using auxillary sort function */ >-@@ -497,6 +522,7 @@ enum >- OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */ >- OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */ >- OPTATTACHMSG, /* (pseudo) used by attach-message */ >-+ OPTHIDEREAD, /* (pseudo) whether or not hide read messages */ >- OPTKEEPQUIET, /* (pseudo) shut up the message and refresh >- * functions while we are executing an >- * external program. >-@@ -507,6 +533,12 @@ enum >- OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */ >- OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */ >- >-+#ifdef USE_NNTP >-+ OPTNEWS, /* (pseudo) used to change reader mode */ >-+ OPTNEWSSEND, /* (pseudo) used to change behavior when posting */ >-+ OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */ >-+#endif >-+ >- OPTMAX >- }; >- >-@@ -585,6 +617,13 @@ typedef struct envelope >- char *supersedes; >- char *date; >- char *x_label; >-+ char *organization; >-+#ifdef USE_NNTP >-+ char *newsgroups; >-+ char *xref; >-+ char *followup_to; >-+ char *x_comment_to; >-+#endif >- BUFFER *spam; >- LIST *references; /* message references (in reverse order) */ >- LIST *in_reply_to; /* in-reply-to header content */ >-@@ -751,6 +790,9 @@ typedef struct header >- ENVELOPE *env; /* envelope information */ >- BODY *content; /* list of MIME parts */ >- char *path; >-+#ifdef USE_NNTP >-+ int article_num; >-+#endif >- >- char *tree; /* character string to print thread tree */ >- THREAD *thread; >-@@ -766,7 +808,7 @@ typedef struct header >- int refno; /* message number on server */ >- #endif >- >--#if defined USE_POP || defined USE_IMAP >-+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP >- void *data; /* driver-specific data */ >- #endif >- >-diff -udprP mutt-1.5.20.orig/muttlib.c mutt-1.5.20/muttlib.c >---- mutt-1.5.20.orig/muttlib.c 2009-05-19 03:11:35.000000000 +0300 >-+++ mutt-1.5.20/muttlib.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -301,7 +301,7 @@ void mutt_free_header (HEADER **h) >- #ifdef MIXMASTER >- mutt_free_list (&(*h)->chain); >- #endif >--#if defined USE_POP || defined USE_IMAP >-+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP >- FREE (&(*h)->data); >- #endif >- FREE (h); /* __FREE_CHECKED__ */ >-@@ -689,6 +689,13 @@ void mutt_free_envelope (ENVELOPE **p) >- FREE (&(*p)->supersedes); >- FREE (&(*p)->date); >- FREE (&(*p)->x_label); >-+ FREE (&(*p)->organization); >-+#ifdef USE_NNTP >-+ FREE (&(*p)->newsgroups); >-+ FREE (&(*p)->xref); >-+ FREE (&(*p)->followup_to); >-+ FREE (&(*p)->x_comment_to); >-+#endif >- >- mutt_buffer_free (&(*p)->spam); >- >-@@ -1470,6 +1477,14 @@ int mutt_save_confirm (const char *s, st >- } >- } >- >-+#ifdef USE_NNTP >-+ if (magic == M_NNTP) >-+ { >-+ mutt_error _("Can't save message to newsserver."); >-+ return 0; >-+ } >-+#endif >-+ >- if (stat (s, st) != -1) >- { >- if (magic == -1) >-diff -udprP mutt-1.5.20.orig/mx.c mutt-1.5.20/mx.c >---- mutt-1.5.20.orig/mx.c 2009-06-11 07:29:41.000000000 +0300 >-+++ mutt-1.5.20/mx.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -343,6 +343,22 @@ int mx_is_pop (const char *p) >- } >- #endif >- >-+#ifdef USE_NNTP >-+int mx_is_nntp (const char *p) >-+{ >-+ url_scheme_t scheme; >-+ >-+ if (!p) >-+ return 0; >-+ >-+ scheme = url_check_scheme (p); >-+ if (scheme == U_NNTP || scheme == U_NNTPS) >-+ return 1; >-+ >-+ return 0; >-+} >-+#endif >-+ >- int mx_get_magic (const char *path) >- { >- struct stat st; >-@@ -360,6 +376,11 @@ int mx_get_magic (const char *path) >- return M_POP; >- #endif /* USE_POP */ >- >-+#ifdef USE_NNTP >-+ if (mx_is_nntp (path)) >-+ return M_NNTP; >-+#endif /* USE_NNTP */ >-+ >- if (stat (path, &st) == -1) >- { >- dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n", >-@@ -669,6 +690,12 @@ CONTEXT *mx_open_mailbox (const char *pa >- break; >- #endif /* USE_POP */ >- >-+#ifdef USE_NNTP >-+ case M_NNTP: >-+ rc = nntp_open_mailbox (ctx); >-+ break; >-+#endif /* USE_NNTP */ >-+ >- default: >- rc = -1; >- break; >-@@ -761,6 +788,12 @@ static int sync_mailbox (CONTEXT *ctx, i >- rc = pop_sync_mailbox (ctx, index_hint); >- break; >- #endif /* USE_POP */ >-+ >-+#ifdef USE_NNTP >-+ case M_NNTP: >-+ rc = nntp_sync_mailbox (ctx); >-+ break; >-+#endif /* USE_NNTP */ >- } >- >- #if 0 >-@@ -787,6 +820,16 @@ int mx_close_mailbox (CONTEXT *ctx, int >- >- ctx->closing = 1; >- >-+#ifdef USE_NNTP >-+ if (ctx->magic == M_NNTP) >-+ { >-+ int ret; >-+ >-+ ret = nntp_close_mailbox (ctx); >-+ mx_fastclose_mailbox (ctx); >-+ return ret; >-+ } >-+#endif >- if (ctx->readonly || ctx->dontwrite) >- { >- /* mailbox is readonly or we don't want to write */ >-@@ -1336,6 +1379,11 @@ int mx_check_mailbox (CONTEXT *ctx, int >- case M_POP: >- return (pop_check_mailbox (ctx, index_hint)); >- #endif /* USE_POP */ >-+ >-+#ifdef USE_NNTP >-+ case M_NNTP: >-+ return (nntp_check_mailbox (ctx)); >-+#endif /* USE_NNTP */ >- } >- } >- >-@@ -1396,6 +1444,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx, >- } >- #endif /* USE_POP */ >- >-+#ifdef USE_NNTP >-+ case M_NNTP: >-+ { >-+ if (nntp_fetch_message (msg, ctx, msgno) != 0) >-+ FREE (&msg); >-+ break; >-+ } >-+#endif /* USE_NNTP */ >-+ >- default: >- dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic)); >- FREE (&msg); >-@@ -1517,7 +1517,11 @@ int mx_close_message (MESSAGE **msg) >- int r = 0; >- >- if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR >-- || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP) >-+ || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP >-+#ifdef USE_NNTP >-+ || (*msg)->magic == M_NNTP >-+#endif >-+ ) >- { >- r = safe_fclose (&(*msg)->fp); >- } >-diff -udprP mutt-1.5.20.orig/mx.h mutt-1.5.20/mx.h >---- mutt-1.5.20.orig/mx.h 2008-11-11 21:55:47.000000000 +0200 >-+++ mutt-1.5.20/mx.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -40,6 +40,9 @@ enum >- #ifdef USE_POP >- , M_POP >- #endif >-+#ifdef USE_NNTP >-+ , M_NNTP >-+#endif >- }; >- >- WHERE short DefaultMagic INITVAL (M_MBOX); >-diff -udprP mutt-1.5.20.orig/newsrc.c mutt-1.5.20/newsrc.c >---- mutt-1.5.20.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300 >-+++ mutt-1.5.20/newsrc.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -0,0 +1,1170 @@ >-+/* >-+ * Copyright (C) 1998 Brandon Long <blong@fiction.net> >-+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net> >-+ * Copyright (C) 2000-2009 Vsevolod Volkov <vvv@mutt.org.ua> >-+ * >-+ * This program is free software; you can redistribute it and/or modify >-+ * it under the terms of the GNU General Public License as published by >-+ * the Free Software Foundation; either version 2 of the License, or >-+ * (at your option) any later version. >-+ * >-+ * This program is distributed in the hope that it will be useful, >-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-+ * GNU General Public License for more details. >-+ * >-+ * You should have received a copy of the GNU General Public License >-+ * along with this program; if not, write to the Free Software >-+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >-+ */ >-+ >-+#if HAVE_CONFIG_H >-+# include "config.h" >-+#endif >-+ >-+#include "mutt.h" >-+#include "mutt_curses.h" >-+#include "sort.h" >-+#include "mx.h" >-+#include "mime.h" >-+#include "mailbox.h" >-+#include "nntp.h" >-+#include "rfc822.h" >-+#include "rfc1524.h" >-+#include "rfc2047.h" >-+ >-+#include <unistd.h> >-+#include <string.h> >-+#include <ctype.h> >-+#include <stdlib.h> >-+#include <sys/stat.h> >-+ >-+void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d) >-+{ >-+ LIST *l; >-+ >-+ if (!s || !d) >-+ return; >-+ >-+ l = safe_calloc (1, sizeof (LIST)); >-+ if (s->list) >-+ s->tail->next = l; >-+ else >-+ s->list = l; >-+ s->tail = l; >-+ l->data = (void *) d; >-+} >-+ >-+static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line) >-+{ >-+ NNTP_DATA *data; >-+ char group[LONG_STRING]; >-+ int x = 1; >-+ char *p = line, *b, *h; >-+ size_t len; >-+ >-+ while (*p) >-+ { >-+ if (*p++ == ',') >-+ x++; >-+ } >-+ >-+ p = line; >-+ while (*p && (*p != ':' && *p != '!')) p++; >-+ if (!*p) >-+ return -1; >-+ len = p + 1 - line; >-+ if (len > sizeof (group)) >-+ len = sizeof (group); >-+ strfcpy (group, line, len); >-+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL) >-+ { >-+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1); >-+ data->group = (char *) data + sizeof (NNTP_DATA); >-+ strcpy (data->group, group); >-+ data->nserv = news; >-+ data->deleted = 1; >-+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2) >-+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0); >-+ hash_insert (news->newsgroups, data->group, data, 0); >-+ nntp_add_to_list (news, data); >-+ } >-+ else >-+ FREE ((void **) &data->entries); >-+ >-+ data->rc = 1; >-+ data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY)); >-+ data->max = x*2; >-+ >-+ if (*p == ':') >-+ data->subscribed = 1; >-+ else >-+ data->subscribed = 0; >-+ >-+ p++; >-+ b = p; >-+ x = 0; >-+ while (*b) >-+ { >-+ while (*p && *p != ',' && *p != '\n') p++; >-+ if (*p) >-+ { >-+ *p = '\0'; >-+ p++; >-+ } >-+ if ((h = strchr(b, '-'))) >-+ { >-+ *h = '\0'; >-+ h++; >-+ data->entries[x].first = atoi(b); >-+ data->entries[x].last = atoi(h); >-+ } >-+ else >-+ { >-+ data->entries[x].first = atoi(b); >-+ data->entries[x].last = data->entries[x].first; >-+ } >-+ b = p; >-+ if (data->entries[x].last != 0) >-+ x++; >-+ } >-+ if (x && !data->lastMessage) >-+ data->lastMessage = data->entries[x-1].last; >-+ data->num = x; >-+ mutt_newsgroup_stat (data); >-+ dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group)); >-+ >-+ return 0; >-+} >-+ >-+static int slurp_newsrc (NNTP_SERVER *news) >-+{ >-+ FILE *fp; >-+ char *buf; >-+ struct stat sb; >-+ >-+ news->stat = stat (news->newsrc, &sb); >-+ news->size = sb.st_size; >-+ news->mtime = sb.st_mtime; >-+ >-+ if ((fp = safe_fopen (news->newsrc, "r")) == NULL) >-+ return -1; >-+ /* hmm, should we use dotlock? */ >-+ if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1)) >-+ { >-+ fclose (fp); >-+ return -1; >-+ } >-+ >-+ buf = safe_malloc (sb.st_size + 1); >-+ while (sb.st_size && fgets (buf, sb.st_size + 1, fp)) >-+ nntp_parse_newsrc_line (news, buf); >-+ FREE (&buf); >-+ >-+ mx_unlock_file (news->newsrc, fileno (fp), 0); >-+ fclose (fp); >-+ return 0; >-+} >-+ >-+void nntp_cache_expand (char *dst, const char *src) >-+{ >-+ snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src); >-+ mutt_expand_path (dst, _POSIX_PATH_MAX); >-+} >-+ >-+/* Loads $news_cache_dir/.index into memory, loads newsserver data >-+ * and newsgroup cache names */ >-+static int nntp_parse_cacheindex (NNTP_SERVER *news) >-+{ >-+ struct stat st; >-+ char buf[HUGE_STRING], *cp; >-+ char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX]; >-+ FILE *index; >-+ NNTP_DATA *data; >-+ int l, m, t; >-+ >-+ /* check is server name defined or not */ >-+ if (!news || !news->conn || !news->conn->account.host) >-+ return -1; >-+ unset_option (OPTNEWSCACHE); >-+ if (!NewsCacheDir || !*NewsCacheDir) >-+ return 0; >-+ >-+ strfcpy (dir, NewsCacheDir, sizeof (dir)); >-+ mutt_expand_path (dir, sizeof(dir)); >-+ >-+ if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0) >-+ { >-+ snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir); >-+ if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+ >-+ S_IRWXO))) >-+ { >-+ mutt_error _("Cache directory not created!"); >-+ return -1; >-+ } >-+ mutt_clear_error(); >-+ } >-+ >-+ set_option (OPTNEWSCACHE); >-+ >-+ FREE (&news->cache); >-+ snprintf (buf, sizeof(buf), "%s/.index", dir); >-+ if (!(index = safe_fopen (buf, "a+"))) >-+ return 0; >-+ rewind (index); >-+ while (fgets (buf, sizeof(buf), index)) >-+ { >-+ buf[strlen(buf) - 1] = 0; /* strip ending '\n' */ >-+ if (!mutt_strncmp (buf, "#: ", 3) && >-+ !mutt_strcasecmp (buf+3, news->conn->account.host)) >-+ break; >-+ } >-+ while (fgets (buf, sizeof(buf), index)) >-+ { >-+ cp = buf; >-+ while (*cp && *cp != ' ') cp++; >-+ if (!*cp) continue; >-+ cp[0] = 0; >-+ if (!mutt_strcmp (buf, "#:")) >-+ break; >-+ sscanf (cp + 1, "%s %d %d", file, &l, &m); >-+ if (!mutt_strcmp (buf, "ALL")) >-+ { >-+ news->cache = safe_strdup (file); >-+ news->newgroups_time = m; >-+ } >-+ else if (news->newsgroups) >-+ { >-+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL) >-+ { >-+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1); >-+ data->group = (char *) data + sizeof (NNTP_DATA); >-+ strcpy(data->group, buf); >-+ data->nserv = news; >-+ data->deleted = 1; >-+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2) >-+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0); >-+ hash_insert (news->newsgroups, data->group, data, 0); >-+ nntp_add_to_list (news, data); >-+ } >-+ data->cache = safe_strdup (file); >-+ t = 0; >-+ if (!data->firstMessage || data->lastMessage < m) >-+ t = 1; >-+ if (!data->firstMessage) >-+ data->firstMessage = l; >-+ if (data->lastMessage < m) >-+ data->lastMessage = m; >-+ data->lastCached = m; >-+ if (t || !data->unread) >-+ mutt_newsgroup_stat (data); >-+ } >-+ } >-+ fclose (index); >-+ return 0; >-+} >-+ >-+const char * >-+nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src, >-+ const char *fmt, const char *ifstring, const char *elsestring, >-+ unsigned long data, format_flag flags) >-+{ >-+ char fn[SHORT_STRING], tmp[SHORT_STRING]; >-+ >-+ switch (op) >-+ { >-+ case 's': >-+ strncpy (fn, NewsServer, sizeof(fn) - 1); >-+ mutt_strlower (fn); >-+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >-+ snprintf (dest, destlen, tmp, fn); >-+ break; >-+ } >-+ return (src); >-+} >-+ >-+/* nntp_parse_url: given an NNPT URL, return host, port, >-+ * username, password and newsgroup will recognise. */ >-+int nntp_parse_url (const char *server, ACCOUNT *acct, >-+ char *group, size_t group_len) >-+{ >-+ ciss_url_t url; >-+ char *c; >-+ int ret = -1; >-+ >-+ /* Defaults */ >-+ acct->flags = 0; >-+ acct->port = NNTP_PORT; >-+ acct->type = M_ACCT_TYPE_NNTP; >-+ >-+ c = safe_strdup (server); >-+ url_parse_ciss (&url, c); >-+ >-+ if (url.scheme == U_NNTP || url.scheme == U_NNTPS) >-+ { >-+ if (url.scheme == U_NNTPS) >-+ { >-+ acct->flags |= M_ACCT_SSL; >-+ acct->port = NNTP_SSL_PORT; >-+ } >-+ >-+ *group = '\0'; >-+ if (url.path) >-+ strfcpy (group, url.path, group_len); >-+ >-+ ret = mutt_account_fromurl (acct, &url); >-+ } >-+ >-+ FREE (&c); >-+ return ret; >-+} >-+ >-+void nntp_expand_path (char *line, size_t len, ACCOUNT *acct) >-+{ >-+ ciss_url_t url; >-+ >-+ url.path = safe_strdup (line); >-+ mutt_account_tourl (acct, &url); >-+ url_ciss_tostring (&url, line, len, 0); >-+ FREE (&url.path); >-+} >-+ >-+/* >-+ * Automatically loads a newsrc into memory, if necessary. >-+ * Checks the size/mtime of a newsrc file, if it doesn't match, load >-+ * again. Hmm, if a system has broken mtimes, this might mean the file >-+ * is reloaded every time, which we'd have to fix. >-+ * >-+ * a newsrc file is a line per newsgroup, with the newsgroup, then a >-+ * ':' denoting subscribed or '!' denoting unsubscribed, then a >-+ * comma separated list of article numbers and ranges. >-+ */ >-+NNTP_SERVER *mutt_select_newsserver (char *server) >-+{ >-+ char file[_POSIX_PATH_MAX]; >-+ char *buf, *p; >-+ LIST *list; >-+ ACCOUNT acct; >-+ NNTP_SERVER *serv; >-+ CONNECTION *conn; >-+ >-+ if (!server || !*server) >-+ { >-+ mutt_error _("No newsserver defined!"); >-+ return NULL; >-+ } >-+ >-+ buf = p = safe_calloc (strlen (server) + 10, sizeof (char)); >-+ if (url_check_scheme (server) == U_UNKNOWN) >-+ { >-+ strcpy (buf, "news://"); >-+ p = strchr (buf, '\0'); >-+ } >-+ strcpy (p, server); >-+ >-+ if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file) >-+ { >-+ FREE (&buf); >-+ mutt_error (_("%s is an invalid newsserver specification!"), server); >-+ return NULL; >-+ } >-+ FREE (&buf); >-+ >-+ conn = mutt_conn_find (NULL, &acct); >-+ if (!conn) >-+ return NULL; >-+ >-+ mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), nntp_format_str, 0, 0); >-+ mutt_expand_path (file, sizeof (file)); >-+ >-+ serv = (NNTP_SERVER *)conn->data; >-+ if (serv) >-+ { >-+ struct stat sb; >-+ >-+ /* externally modified? */ >-+ if (serv->stat != stat (file, &sb) || (!serv->stat && >-+ (serv->size != sb.st_size || serv->mtime != sb.st_mtime))) >-+ { >-+ for (list = serv->list; list; list = list->next) >-+ { >-+ NNTP_DATA *data = (NNTP_DATA *) list->data; >-+ >-+ if (data) >-+ { >-+ data->subscribed = 0; >-+ data->rc = 0; >-+ data->num = 0; >-+ } >-+ } >-+ slurp_newsrc (serv); >-+ nntp_clear_cacheindex (serv); >-+ } >-+ >-+ if (serv->status == NNTP_BYE) >-+ serv->status = NNTP_NONE; >-+ nntp_check_newgroups (serv, 0); >-+ return serv; >-+ } >-+ >-+ /* New newsserver */ >-+ serv = safe_calloc (1, sizeof (NNTP_SERVER)); >-+ serv->conn = conn; >-+ serv->newsrc = safe_strdup (file); >-+ serv->newsgroups = hash_create (1009, 0); >-+ slurp_newsrc (serv); /* load .newsrc */ >-+ nntp_parse_cacheindex (serv); /* load .index */ >-+ if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0) >-+ nntp_check_newgroups (serv, 1); >-+ else if (nntp_get_active (serv) < 0) >-+ { >-+ hash_destroy (&serv->newsgroups, nntp_delete_data); >-+ for (list = serv->list; list; list = list->next) >-+ list->data = NULL; >-+ mutt_free_list (&serv->list); >-+ FREE (&serv->newsrc); >-+ FREE (&serv->cache); >-+ FREE (&serv); >-+ return NULL; >-+ } >-+ nntp_clear_cacheindex (serv); >-+ conn->data = (void *)serv; >-+ >-+ return serv; >-+} >-+ >-+/* >-+ * full status flags are not supported by nntp, but we can fake some >-+ * of them. This is how: >-+ * Read = a read message number is in the .newsrc >-+ * New = a message is new since we last read this newsgroup >-+ * Old = anything else >-+ * So, Read is marked as such in the newsrc, old is anything that is >-+ * "skipped" in the newsrc, and new is anything not in the newsrc nor >-+ * in the cache. By skipped, I mean before the last unread message >-+ */ >-+void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article) >-+{ >-+ NNTP_DATA *data = (NNTP_DATA *) ctx->data; >-+ int x; >-+ >-+ if (group) >-+ data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group); >-+ >-+ if (!data) >-+ { >-+#ifdef DEBUG >-+ if (group) >-+ dprint (3, (debugfile, "newsgroup %s not found\n", group)); >-+#endif >-+ return; >-+ } >-+ >-+ for (x = 0; x < data->num; x++) >-+ { >-+ if ((article >= data->entries[x].first) && >-+ (article <= data->entries[x].last)) >-+ { >-+ /* we cannot use mutt_set_flag() because mx_update_context() >-+ didn't called yet */ >-+ h->read = 1; >-+ return; >-+ } >-+ } >-+ /* If article was not cached yet, it is new! :) */ >-+ if (!data->cache || article > data->lastCached) >-+ return; >-+ /* Old articles are articles which aren't read but an article after them >-+ * has been cached */ >-+ if (option (OPTMARKOLD)) >-+ h->old = 1; >-+} >-+ >-+void mutt_newsgroup_stat (NNTP_DATA *data) >-+{ >-+ int i; >-+ unsigned int first, last; >-+ >-+ data->unread = 0; >-+ if (data->lastMessage == 0 || data->firstMessage > data->lastMessage) >-+ return; >-+ >-+ data->unread = data->lastMessage - data->firstMessage + 1; >-+ for (i = 0; i < data->num; i++) >-+ { >-+ first = data->entries[i].first; >-+ if (first < data->firstMessage) >-+ first = data->firstMessage; >-+ last = data->entries[i].last; >-+ if (last > data->lastMessage) >-+ last = data->lastMessage; >-+ if (first <= last) >-+ data->unread -= last - first + 1; >-+ } >-+} >-+ >-+static int puti (char *line, int num) >-+{ >-+ char *p, s[32]; >-+ >-+ for (p = s; num; ) >-+ { >-+ *p++ = '0' + num % 10; >-+ num /= 10; >-+ } >-+ while (p > s) >-+ *line++ = *--p, num++; >-+ *line = '\0'; >-+ return num; >-+} >-+ >-+static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen) >-+{ >-+ char *line = *pline; >-+ size_t len = *buflen - (*pline - *buf); >-+ int x, i; >-+ >-+ if (len < LONG_STRING * 10) >-+ { >-+ len += *buflen; >-+ *buflen *= 2; >-+ line = *buf; >-+ safe_realloc (buf, *buflen); >-+ line = *buf + (*pline - line); >-+ } >-+ strcpy (line, data->group); >-+ len -= strlen (line) + 1; >-+ line += strlen (line); >-+ *line++ = data->subscribed ? ':' : '!'; >-+ *line++ = ' '; >-+ *line = '\0'; >-+ >-+ for (x = 0; x < data->num; x++) >-+ { >-+ if (len < LONG_STRING) >-+ { >-+ len += *buflen; >-+ *buflen *= 2; >-+ *pline = line; >-+ line = *buf; >-+ safe_realloc (buf, *buflen); >-+ line = *buf + (*pline - line); >-+ } >-+ if (x) >-+ { >-+ *line++ = ','; >-+ len--; >-+ } >-+ >-+#if 0 >-+ if (data->entries[x].first == data->entries[x].last) >-+ snprintf (line, len, "%d%n", data->entries[x].first, &i); >-+ else >-+ snprintf (line, len, "%d-%d%n", >-+ data->entries[x].first, data->entries[x].last, &i); >-+ len -= i; >-+ line += i; >-+#else >-+ i = puti (line, data->entries[x].first); >-+ line +=i; len -= i; >-+ if (data->entries[x].first != data->entries[x].last) >-+ { >-+ *line++ = '-'; >-+ len--; >-+ i = puti (line, data->entries[x].last); >-+ line +=i; len -= i; >-+ } >-+#endif >-+ } >-+ *line++ = '\n'; >-+ *line = '\0'; >-+ *pline = line; >-+} >-+ >-+void newsrc_gen_entries (CONTEXT *ctx) >-+{ >-+ NNTP_DATA *data = (NNTP_DATA *)ctx->data; >-+ int series, x; >-+ unsigned int last = 0, first = 1; >-+ int save_sort = SORT_ORDER; >-+ >-+ if (Sort != SORT_ORDER) >-+ { >-+ save_sort = Sort; >-+ Sort = SORT_ORDER; >-+ mutt_sort_headers (ctx, 0); >-+ } >-+ >-+ if (!data->max) >-+ { >-+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY)); >-+ data->max = 5; >-+ } >-+ >-+ /* >-+ * Set up to fake initial sequence from 1 to the article before the >-+ * first article in our list >-+ */ >-+ data->num = 0; >-+ series = 1; >-+ >-+ for (x = 0; x < ctx->msgcount; x++) >-+ { >-+ if (series) /* search for first unread */ >-+ { >-+ /* >-+ * We don't actually check sequential order, since we mark >-+ * "missing" entries as read/deleted >-+ */ >-+ last = ctx->hdrs[x]->article_num; >-+ if (last >= data->firstMessage && !ctx->hdrs[x]->deleted && >-+ !ctx->hdrs[x]->read) >-+ { >-+ if (data->num >= data->max) >-+ { >-+ data->max = data->max * 2; >-+ safe_realloc (&data->entries, >-+ data->max * sizeof (NEWSRC_ENTRY)); >-+ } >-+ data->entries[data->num].first = first; >-+ data->entries[data->num].last = last - 1; >-+ data->num++; >-+ series = 0; >-+ } >-+ } >-+ else /* search for first read */ >-+ { >-+ if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read) >-+ { >-+ first = last + 1; >-+ series = 1; >-+ } >-+ last = ctx->hdrs[x]->article_num; >-+ } >-+ } >-+ if (series && first <= data->lastLoaded) >-+ { >-+ if (data->num >= data->max) >-+ { >-+ data->max = data->max * 2; >-+ safe_realloc (&data->entries, >-+ data->max * sizeof (NEWSRC_ENTRY)); >-+ } >-+ data->entries[data->num].first = first; >-+ data->entries[data->num].last = data->lastLoaded; >-+ data->num++; >-+ } >-+ >-+ if (save_sort != Sort) >-+ { >-+ Sort = save_sort; >-+ mutt_sort_headers (ctx, 0); >-+ } >-+} >-+ >-+static int mutt_update_list_file (char *filename, char *section, >-+ char *key, char *line) >-+{ >-+ FILE *ifp; >-+ FILE *ofp; >-+ char buf[HUGE_STRING]; >-+ char tmpfile[_POSIX_PATH_MAX]; >-+ char *c; >-+ int ext = 0, done = 0, r = 0; >-+ >-+ /* if file not exist, create it */ >-+ if ((ifp = safe_fopen (filename, "a"))) >-+ fclose (ifp); >-+ dprint (1, (debugfile, "Opening %s\n", filename)); >-+ if (!(ifp = safe_fopen (filename, "r"))) >-+ { >-+ mutt_error (_("Unable to open %s for reading"), filename); >-+ return -1; >-+ } >-+ if (mx_lock_file (filename, fileno (ifp), 0, 0, 1)) >-+ { >-+ fclose (ifp); >-+ mutt_error (_("Unable to lock %s"), filename); >-+ return -1; >-+ } >-+ snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename); >-+ dprint (1, (debugfile, "Opening %s\n", tmpfile)); >-+ if (!(ofp = fopen (tmpfile, "w"))) >-+ { >-+ fclose (ifp); >-+ mutt_error (_("Unable to open %s for writing"), tmpfile); >-+ return -1; >-+ } >-+ >-+ if (section) >-+ { >-+ while (r != EOF && !done && fgets (buf, sizeof (buf), ifp)) >-+ { >-+ r = fputs (buf, ofp); >-+ c = buf; >-+ while (*c && *c != '\n') c++; >-+ c[0] = 0; /* strip EOL */ >-+ if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section)) >-+ done++; >-+ } >-+ if (r != EOF && !done) >-+ { >-+ snprintf (buf, sizeof(buf), "#: %s\n", section); >-+ r = fputs (buf, ofp); >-+ } >-+ done = 0; >-+ } >-+ >-+ while (r != EOF && fgets (buf, sizeof (buf), ifp)) >-+ { >-+ if (ext) >-+ { >-+ c = buf; >-+ while (*c && (*c != '\r') && (*c != '\n')) c++; >-+ c--; >-+ if (*c != '\\') ext = 0; >-+ } >-+ else if ((section && !strncmp (buf, "#: ", 3))) >-+ { >-+ if (!done && line) >-+ { >-+ fputs (line, ofp); >-+ fputc ('\n', ofp); >-+ } >-+ r = fputs (buf, ofp); >-+ done++; >-+ break; >-+ } >-+ else if (key && !strncmp (buf, key, strlen(key)) && >-+ (!*key || buf[strlen(key)] == ' ')) >-+ { >-+ c = buf; >-+ ext = 0; >-+ while (*c && (*c != '\r') && (*c != '\n')) c++; >-+ c--; >-+ if (*c == '\\') ext = 1; >-+ if (!done && line) >-+ { >-+ r = fputs (line, ofp); >-+ if (*key) >-+ r = fputc ('\n', ofp); >-+ done++; >-+ } >-+ } >-+ else >-+ { >-+ r = fputs (buf, ofp); >-+ } >-+ } >-+ >-+ while (r != EOF && fgets (buf, sizeof (buf), ifp)) >-+ r = fputs (buf, ofp); >-+ >-+ /* If there wasn't a line to replace, put it on the end of the file */ >-+ if (r != EOF && !done && line) >-+ { >-+ fputs (line, ofp); >-+ r = fputc ('\n', ofp); >-+ } >-+ mx_unlock_file (filename, fileno (ifp), 0); >-+ fclose (ofp); >-+ fclose (ifp); >-+ if (r == EOF) >-+ { >-+ unlink (tmpfile); >-+ mutt_error (_("Can't write %s"), tmpfile); >-+ return -1; >-+ } >-+ if (rename (tmpfile, filename) < 0) >-+ { >-+ unlink (tmpfile); >-+ mutt_error (_("Can't rename %s to %s"), tmpfile, filename); >-+ return -1; >-+ } >-+ return 0; >-+} >-+ >-+int mutt_newsrc_update (NNTP_SERVER *news) >-+{ >-+ char *buf, *line; >-+ NNTP_DATA *data; >-+ LIST *tmp; >-+ int r = -1; >-+ size_t len, llen; >-+ >-+ if (!news) >-+ return -1; >-+ llen = len = 10 * LONG_STRING; >-+ line = buf = safe_calloc (1, len); >-+ /* we will generate full newsrc here */ >-+ for (tmp = news->list; tmp; tmp = tmp->next) >-+ { >-+ data = (NNTP_DATA *) tmp->data; >-+ if (!data || !data->rc) >-+ continue; >-+ nntp_create_newsrc_line (data, &buf, &line, &llen); >-+ if (*line) >-+ dprint (2, (debugfile, "Added to newsrc: %s\n", line)); >-+ line += strlen (line); >-+ } >-+ /* newrc being fully rewritten */ >-+ if (news->newsrc && >-+ (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0) >-+ { >-+ struct stat st; >-+ >-+ stat (news->newsrc, &st); >-+ news->size = st.st_size; >-+ news->mtime = st.st_mtime; >-+ } >-+ FREE (&buf); >-+ return r; >-+} >-+ >-+static FILE *mutt_mkname (char *s) >-+{ >-+ char buf[_POSIX_PATH_MAX], *pc; >-+ int fd; >-+ FILE *fp; >-+ >-+ nntp_cache_expand (buf, s); >-+ if ((fp = safe_fopen (buf, "w"))) >-+ return fp; >-+ >-+ nntp_cache_expand (buf, "cache-XXXXXX"); >-+ pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */ >-+ if ((fd = mkstemp (buf)) == -1) >-+ return NULL; >-+ strcpy (s, pc); /* generated name */ >-+ return fdopen (fd, "w"); >-+} >-+ >-+/* Updates info into .index file: ALL or about selected newsgroup */ >-+static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data) >-+{ >-+ char buf[LONG_STRING], *key = "ALL"; >-+ char file[_POSIX_PATH_MAX]; >-+ >-+ if (!serv || !serv->conn || !serv->conn->account.host) >-+ return -1; >-+ >-+ if (data && data->group) >-+ { >-+ key = data->group; >-+ snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache, >-+ data->firstMessage, data->lastLoaded); >-+ } >-+ else >-+ { >-+ strfcpy (file, serv->cache, sizeof (file)); >-+ snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time); >-+ } >-+ nntp_cache_expand (file, ".index"); >-+ return mutt_update_list_file (file, serv->conn->account.host, key, buf); >-+} >-+ >-+/* Remove cache files of unsubscribed newsgroups */ >-+void nntp_clear_cacheindex (NNTP_SERVER *news) >-+{ >-+ NNTP_DATA *data; >-+ LIST *tmp; >-+ >-+ if (option (OPTSAVEUNSUB) || !news) >-+ return; >-+ >-+ for (tmp = news->list; tmp; tmp = tmp->next) >-+ { >-+ data = (NNTP_DATA *) tmp->data; >-+ if (!data || data->subscribed || !data->cache) >-+ continue; >-+ nntp_delete_cache (data); >-+ dprint (2, (debugfile, "Removed from .index: %s\n", data->group)); >-+ } >-+ return; >-+} >-+ >-+int nntp_save_cache_index (NNTP_SERVER *news) >-+{ >-+ char buf[HUGE_STRING]; >-+ char file[_POSIX_PATH_MAX]; >-+ NNTP_DATA *d; >-+ FILE *f; >-+ LIST *l; >-+ >-+ if (!news || !news->newsgroups) >-+ return -1; >-+ if (!option (OPTNEWSCACHE)) >-+ return 0; >-+ >-+ if (news->cache) >-+ { >-+ nntp_cache_expand (file, news->cache); >-+ unlink (file); >-+ f = safe_fopen (file, "w"); >-+ } >-+ else >-+ { >-+ strfcpy (buf, news->conn->account.host, sizeof(buf)); >-+ f = mutt_mkname (buf); >-+ news->cache = safe_strdup (buf); >-+ nntp_cache_expand (file, buf); >-+ } >-+ if (!f) >-+ return -1; >-+ >-+ for (l = news->list; l; l = l->next) >-+ { >-+ if ((d = (NNTP_DATA *)l->data) && !d->deleted) >-+ { >-+ if (d->desc) >-+ snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group, >-+ d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n', >-+ d->desc); >-+ else >-+ snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group, >-+ d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n'); >-+ if (fputs (buf, f) == EOF) >-+ { >-+ fclose (f); >-+ unlink (file); >-+ return -1; >-+ } >-+ } >-+ } >-+ fclose (f); >-+ >-+ if (nntp_update_cacheindex (news, NULL)) >-+ { >-+ unlink (file); >-+ return -1; >-+ } >-+ return 0; >-+} >-+ >-+int nntp_save_cache_group (CONTEXT *ctx) >-+{ >-+ char buf[HUGE_STRING], addr[STRING]; >-+ char file[_POSIX_PATH_MAX]; >-+ FILE *f; >-+ HEADER *h; >-+ struct tm *tm; >-+ int i = 0, save = SORT_ORDER; >-+ int prev = 0; >-+ >-+ if (!option (OPTNEWSCACHE)) >-+ return 0; >-+ if (!ctx || !ctx->data || ctx->magic != M_NNTP) >-+ return -1; >-+ >-+ if (((NNTP_DATA *)ctx->data)->cache) >-+ { >-+ nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache); >-+ unlink (file); >-+ f = safe_fopen (file, "w"); >-+ } >-+ else >-+ { >-+ snprintf (buf, sizeof(buf), "%s-%s", >-+ ((NNTP_DATA *)ctx->data)->nserv->conn->account.host, >-+ ((NNTP_DATA *)ctx->data)->group); >-+ f = mutt_mkname (buf); >-+ ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf); >-+ nntp_cache_expand (file, buf); >-+ } >-+ if (!f) >-+ return -1; >-+ >-+ if (Sort != SORT_ORDER) >-+ { >-+ save = Sort; >-+ Sort = SORT_ORDER; >-+ mutt_sort_headers (ctx, 0); >-+ } >-+ >-+ /* Save only $nntp_context messages... */ >-+ ((NNTP_DATA *)ctx->data)->lastCached = 0; >-+ if (NntpContext && ctx->msgcount > NntpContext) >-+ i = ctx->msgcount - NntpContext; >-+ for (; i < ctx->msgcount; i++) >-+ { >-+ if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev) >-+ { >-+ h = ctx->hdrs[i]; >-+ addr[0] = 0; >-+ rfc822_write_address (addr, sizeof(addr), h->env->from, 0); >-+ tm = gmtime (&h->date_sent); >-+ snprintf (buf, sizeof(buf), >-+ "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t", >-+ h->article_num, h->env->subject, addr, tm->tm_mday, >-+ Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min, >-+ tm->tm_sec, h->env->message_id); >-+ fputs (buf, f); >-+ if (h->env->references) >-+ mutt_write_references (h->env->references, f, 10); >-+ snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length, >-+ (int) h->lines, NONULL(h->env->xref)); >-+ if (fputs (buf, f) == EOF) >-+ { >-+ fclose (f); >-+ unlink (file); >-+ return -1; >-+ } >-+ } >-+ prev = ctx->hdrs[i]->article_num; >-+ } >-+ >-+ if (save != Sort) >-+ { >-+ Sort = save; >-+ mutt_sort_headers (ctx, 0); >-+ } >-+ fclose (f); >-+ >-+ if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv, >-+ (NNTP_DATA *)ctx->data)) >-+ { >-+ unlink (file); >-+ return -1; >-+ } >-+ ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded; >-+ return 0; >-+} >-+ >-+void nntp_delete_cache (NNTP_DATA *data) >-+{ >-+ char buf[_POSIX_PATH_MAX]; >-+ >-+ if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv) >-+ return; >-+ >-+ nntp_cache_expand (buf, data->cache); >-+ unlink (buf); >-+ FREE (&data->cache); >-+ data->lastCached = 0; >-+ nntp_cache_expand (buf, ".index"); >-+ mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL); >-+} >-+ >-+NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group) >-+{ >-+ NNTP_DATA *data; >-+ >-+ if (!news || !news->newsgroups || !group || !*group) >-+ return NULL; >-+ if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group))) >-+ { >-+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1); >-+ data->group = (char *) data + sizeof (NNTP_DATA); >-+ strcpy (data->group, group); >-+ data->nserv = news; >-+ data->deleted = 1; >-+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2) >-+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0); >-+ hash_insert (news->newsgroups, data->group, data, 0); >-+ nntp_add_to_list (news, data); >-+ } >-+ if (!data->subscribed) >-+ { >-+ data->subscribed = 1; >-+ data->rc = 1; >-+ } >-+ return data; >-+} >-+ >-+NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group) >-+{ >-+ NNTP_DATA *data; >-+ >-+ if (!news || !news->newsgroups || !group || !*group || >-+ !(data = (NNTP_DATA *)hash_find (news->newsgroups, group))) >-+ return NULL; >-+ if (data->subscribed) >-+ { >-+ data->subscribed = 0; >-+ if (!option (OPTSAVEUNSUB)) >-+ data->rc = 0; >-+ } >-+ return data; >-+} >-+ >-+NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group) >-+{ >-+ NNTP_DATA *data; >-+ >-+ if (!news || !news->newsgroups || !group || !*group || >-+ !(data = (NNTP_DATA *)hash_find (news->newsgroups, group))) >-+ return NULL; >-+ if (!data->max) >-+ { >-+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY)); >-+ data->max = 5; >-+ } >-+ data->num = 1; >-+ data->entries[0].first = 1; >-+ data->unread = 0; >-+ data->entries[0].last = data->lastMessage; >-+ if (Context && Context->data == data) >-+ { >-+ int x; >-+ >-+ for (x = 0; x < Context->msgcount; x++) >-+ mutt_set_flag (Context, Context->hdrs[x], M_READ, 1); >-+ } >-+ return data; >-+} >-+ >-+NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group) >-+{ >-+ NNTP_DATA *data; >-+ >-+ if (!news || !news->newsgroups || !group || !*group || >-+ !(data = (NNTP_DATA *)hash_find (news->newsgroups, group))) >-+ return NULL; >-+ if (!data->max) >-+ { >-+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY)); >-+ data->max = 5; >-+ } >-+ data->num = 1; >-+ data->entries[0].first = 1; >-+ data->entries[0].last = data->firstMessage - 1; >-+ if (Context && Context->data == data) >-+ { >-+ int x; >-+ >-+ data->unread = Context->msgcount; >-+ for (x = 0; x < Context->msgcount; x++) >-+ mutt_set_flag (Context, Context->hdrs[x], M_READ, 0); >-+ } >-+ else >-+ data->unread = data->lastMessage - data->entries[0].last; >-+ return data; >-+} >-+ >-+/* this routine gives the first newsgroup with new messages */ >-+void nntp_buffy (char *s) >-+{ >-+ LIST *list; >-+ >-+ for (list = CurrentNewsSrv->list; list; list = list->next) >-+ { >-+ NNTP_DATA *data = (NNTP_DATA *) list->data; >-+ >-+ if (data && data->subscribed && data->unread) >-+ { >-+ if (Context && Context->magic == M_NNTP && >-+ !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group)) >-+ { >-+ unsigned int i, unread = 0; >-+ >-+ for (i = 0; i < Context->msgcount; i++) >-+ if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted) >-+ unread++; >-+ if (!unread) >-+ continue; >-+ } >-+ strcpy (s, data->group); >-+ break; >-+ } >-+ } >-+} >-diff -udprP mutt-1.5.20.orig/nntp.c mutt-1.5.20/nntp.c >---- mutt-1.5.20.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300 >-+++ mutt-1.5.20/nntp.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -0,0 +1,1588 @@ >-+/* >-+ * Copyright (C) 1998 Brandon Long <blong@fiction.net> >-+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net> >-+ * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua> >-+ * >-+ * This program is free software; you can redistribute it and/or modify >-+ * it under the terms of the GNU General Public License as published by >-+ * the Free Software Foundation; either version 2 of the License, or >-+ * (at your option) any later version. >-+ * >-+ * This program is distributed in the hope that it will be useful, >-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-+ * GNU General Public License for more details. >-+ * >-+ * You should have received a copy of the GNU General Public License >-+ * along with this program; if not, write to the Free Software >-+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >-+ */ >-+ >-+#if HAVE_CONFIG_H >-+# include "config.h" >-+#endif >-+ >-+#include "mutt.h" >-+#include "mutt_curses.h" >-+#include "sort.h" >-+#include "mx.h" >-+#include "mime.h" >-+#include "rfc1524.h" >-+#include "rfc2047.h" >-+#include "mailbox.h" >-+#include "nntp.h" >-+ >-+#ifdef HAVE_PGP >-+#include "pgp.h" >-+#endif >-+ >-+#ifdef HAVE_SMIME >-+#include "smime.h" >-+#endif >-+ >-+#include <unistd.h> >-+#include <string.h> >-+#include <ctype.h> >-+#include <stdlib.h> >-+ >-+static unsigned int _checked = 0; >-+ >-+#ifdef DEBUG >-+static void nntp_error (const char *where, const char *msg) >-+{ >-+ dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg)); >-+} >-+#endif /* DEBUG */ >-+ >-+static int nntp_auth (NNTP_SERVER *serv) >-+{ >-+ CONNECTION *conn = serv->conn; >-+ char buf[STRING]; >-+ unsigned char flags = conn->account.flags; >-+ >-+ if (mutt_account_getuser (&conn->account) || !conn->account.user[0] || >-+ mutt_account_getpass (&conn->account) || !conn->account.pass[0]) >-+ { >-+ conn->account.flags = flags; >-+ return -2; >-+ } >-+ >-+ mutt_message _("Logging in..."); >-+ >-+ snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user); >-+ mutt_socket_write (conn, buf); >-+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >-+ { >-+ conn->account.flags = flags; >-+ return -1; >-+ } >-+ >-+#ifdef DEBUG >-+ /* don't print the password unless we're at the ungodly debugging level */ >-+ if (debuglevel < M_SOCK_LOG_FULL) >-+ dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n")); >-+#endif >-+ snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass); >-+ mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL); >-+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >-+ { >-+ conn->account.flags = flags; >-+ return -1; >-+ } >-+ >-+ if (mutt_strncmp ("281", buf, 3)) >-+ { >-+ conn->account.flags = flags; >-+ mutt_error _("Login failed."); >-+ sleep (2); >-+ return -3; >-+ } >-+ >-+ return 0; >-+} >-+ >-+static int nntp_connect_error (NNTP_SERVER *serv) >-+{ >-+ serv->status = NNTP_NONE; >-+ mutt_socket_close (serv->conn); >-+ mutt_error _("Server closed connection!"); >-+ sleep (2); >-+ return -1; >-+} >-+ >-+static int nntp_connect_and_auth (NNTP_SERVER *serv) >-+{ >-+ CONNECTION *conn = serv->conn; >-+ char buf[STRING]; >-+ int rc; >-+ >-+ serv->status = NNTP_NONE; >-+ >-+ if (mutt_socket_open (conn) < 0) >-+ return -1; >-+ >-+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >-+ return nntp_connect_error (serv); >-+ >-+ if (!mutt_strncmp ("200", buf, 3)) >-+ mutt_message (_("Connected to %s. Posting ok."), conn->account.host); >-+ else if (!mutt_strncmp ("201", buf, 3)) >-+ mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host); >-+ else >-+ { >-+ mutt_socket_close (conn); >-+ mutt_remove_trailing_ws (buf); >-+ mutt_error ("%s", buf); >-+ sleep (2); >-+ return -1; >-+ } >-+ >-+ sleep (1); >-+ >-+ /* Tell INN to switch to mode reader if it isn't so. Ignore all >-+ returned codes and messages. */ >-+ mutt_socket_write (conn, "MODE READER\r\n"); >-+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >-+ return nntp_connect_error (serv); >-+ >-+ mutt_socket_write (conn, "STAT\r\n"); >-+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >-+ return nntp_connect_error (serv); >-+ >-+ if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3)) >-+ { >-+ serv->status = NNTP_OK; >-+ return 0; >-+ } >-+ >-+ rc = nntp_auth (serv); >-+ if (rc == -1) >-+ return nntp_connect_error (serv); >-+ if (rc == -2) >-+ { >-+ mutt_socket_close (conn); >-+ serv->status = NNTP_BYE; >-+ return -1; >-+ } >-+ if (rc < 0) >-+ { >-+ mutt_socket_close (conn); >-+ mutt_error _("Login failed."); >-+ sleep (2); >-+ return -1; >-+ } >-+ serv->status = NNTP_OK; >-+ return 0; >-+} >-+ >-+static int nntp_attempt_features (NNTP_SERVER *serv) >-+{ >-+ char buf[LONG_STRING]; >-+ CONNECTION *conn = serv->conn; >-+ >-+ mutt_socket_write (conn, "XOVER\r\n"); >-+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >-+ return nntp_connect_error (serv); >-+ if (mutt_strncmp ("500", buf, 3)) >-+ serv->hasXOVER = 1; >-+ >-+ mutt_socket_write (conn, "XPAT\r\n"); >-+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >-+ return nntp_connect_error (serv); >-+ if (mutt_strncmp ("500", buf, 3)) >-+ serv->hasXPAT = 1; >-+ >-+ mutt_socket_write (conn, "LISTGROUP\r\n"); >-+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >-+ return nntp_connect_error (serv); >-+ if (mutt_strncmp ("500", buf, 3)) >-+ serv->hasLISTGROUP = 1; >-+ >-+ mutt_socket_write (conn, "XGTITLE +\r\n"); >-+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >-+ return nntp_connect_error (serv); >-+ if (mutt_strncmp ("500", buf, 3)) >-+ serv->hasXGTITLE = 1; >-+ >-+ if (!mutt_strncmp ("282", buf, 3)) >-+ { >-+ do >-+ { >-+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >-+ return nntp_connect_error (serv); >-+ } while (!(buf[0] == '.' && buf[1] == '\0')); >-+ } >-+ >-+ return 0; >-+} >-+ >-+static int nntp_open_connection (NNTP_SERVER *serv) >-+{ >-+ if (serv->status == NNTP_OK) >-+ return 0; >-+ if (serv->status == NNTP_BYE) >-+ return -1; >-+ if (nntp_connect_and_auth (serv) < 0) >-+ return -1; >-+ if (nntp_attempt_features (serv) < 0) >-+ return -1; >-+ return 0; >-+} >-+ >-+static int nntp_reconnect (NNTP_SERVER *serv) >-+{ >-+ char buf[SHORT_STRING]; >-+ >-+ mutt_socket_close (serv->conn); >-+ >-+ FOREVER >-+ { >-+ if (nntp_connect_and_auth (serv) == 0) >-+ return 0; >-+ >-+ snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"), >-+ serv->conn->account.host); >-+ if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES) >-+ { >-+ serv->status = NNTP_BYE; >-+ return -1; >-+ } >-+ } >-+} >-+ >-+/* Send data from line[LONG_STRING] and receive answer to same line */ >-+static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen) >-+{ >-+ char buf[LONG_STRING]; >-+ int done = TRUE; >-+ >-+ if (data->nserv->status == NNTP_BYE) >-+ return -1; >-+ >-+ do >-+ { >-+ if (*line) >-+ { >-+ mutt_socket_write (data->nserv->conn, line); >-+ } >-+ else if (data->group) >-+ { >-+ snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group); >-+ mutt_socket_write (data->nserv->conn, buf); >-+ } >-+ >-+ done = TRUE; >-+ if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0) >-+ { >-+ if (nntp_reconnect (data->nserv) < 0) >-+ return -1; >-+ >-+ if (data->group) >-+ { >-+ snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group); >-+ mutt_socket_write (data->nserv->conn, buf); >-+ if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0) >-+ return -1; >-+ } >-+ if (*line) >-+ done = FALSE; >-+ } >-+ else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0) >-+ return -1; >-+ } while (!done); >-+ >-+ strfcpy (line, buf, linelen); >-+ return 0; >-+} >-+ >-+/* >-+ * This function calls funct(*line, *data) for each received line, >-+ * funct(NULL, *data) if rewind(*data) needs, exits when fail or done. >-+ * Returned codes: >-+ * 0 - successful, >-+ * 1 - correct but not performed (may be, have to be continued), >-+ * -1 - conection lost, >-+ * -2 - invalid command or execution error, >-+ * -3 - error in funct(*line, *data). >-+ */ >-+static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg, >-+ int (*funct) (char *, void *), void *data, int tagged) >-+{ >-+ char buf[LONG_STRING]; >-+ char *inbuf, *p; >-+ int done = FALSE; >-+ int chunk, line; >-+ size_t lenbuf = 0; >-+ int ret; >-+ >-+ do >-+ { >-+ strfcpy (buf, query, sizeof (buf)); >-+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) >-+ return -1; >-+ if (buf[0] == '5') >-+ return -2; >-+ if (buf[0] != '2') >-+ return 1; >-+ >-+ ret = 0; >-+ line = 0; >-+ inbuf = safe_malloc (sizeof (buf)); >-+ >-+ FOREVER >-+ { >-+ chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn, >-+ M_SOCK_LOG_HDR); >-+ if (chunk < 0) >-+ break; >-+ >-+ p = buf; >-+ if (!lenbuf && buf[0] == '.') >-+ { >-+ if (buf[1] == '\0') >-+ { >-+ done = TRUE; >-+ break; >-+ } >-+ if (buf[1] == '.') >-+ p++; >-+ } >-+ >-+ strfcpy (inbuf + lenbuf, p, sizeof (buf)); >-+ >-+ if (chunk >= sizeof (buf)) >-+ { >-+ lenbuf += strlen (p); >-+ } >-+ else >-+ { >-+ line++; >-+ if (msg && ReadInc && (line % ReadInc == 0)) { >-+ if (tagged) >-+ mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line); >-+ else >-+ mutt_message ("%s %d", msg, line); >-+ } >-+ >-+ if (ret == 0 && funct (inbuf, data) < 0) >-+ ret = -3; >-+ lenbuf = 0; >-+ } >-+ >-+ safe_realloc (&inbuf, lenbuf + sizeof (buf)); >-+ } >-+ FREE (&inbuf); >-+ funct (NULL, data); >-+ } >-+ while (!done); >-+ return ret; >-+} >-+ >-+static int nntp_read_tempfile (char *line, void *file) >-+{ >-+ FILE *f = (FILE *)file; >-+ >-+ if (!line) >-+ rewind (f); >-+ else >-+ { >-+ fputs (line, f); >-+ if (fputc ('\n', f) == EOF) >-+ return -1; >-+ } >-+ return 0; >-+} >-+ >-+static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h) >-+{ >-+ register char *p, *b; >-+ register char *colon = NULL; >-+ >-+ b = p = xref; >-+ while (*p) >-+ { >-+ /* skip to next word */ >-+ b = p; >-+ while (*b && ((*b == ' ') || (*b == '\t'))) b++; >-+ p = b; >-+ colon = NULL; >-+ /* skip to end of word */ >-+ while (*p && (*p != ' ') && (*p != '\t')) >-+ { >-+ if (*p == ':') >-+ colon = p; >-+ p++; >-+ } >-+ if (*p) >-+ { >-+ *p = '\0'; >-+ p++; >-+ } >-+ if (colon) >-+ { >-+ *colon = '\0'; >-+ colon++; >-+ nntp_get_status (ctx, h, b, atoi(colon)); >-+ if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0) >-+ h->article_num = atoi(colon); >-+ } >-+ } >-+} >-+ >-+/* >-+ * returns: >-+ * 0 on success >-+ * 1 if article not found >-+ * -1 if read or write error on tempfile or socket >-+ */ >-+static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num) >-+{ >-+ NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data); >-+ FILE *f; >-+ char buf[LONG_STRING]; >-+ char tempfile[_POSIX_PATH_MAX]; >-+ int ret; >-+ HEADER *h = ctx->hdrs[ctx->msgcount]; >-+ >-+ mutt_mktemp (tempfile, sizeof(tempfile)); >-+ if (!(f = safe_fopen (tempfile, "w+"))) >-+ return -1; >-+ >-+ if (!msgid) >-+ snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num); >-+ else >-+ snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid); >-+ >-+ ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0); >-+ if (ret) >-+ { >-+#ifdef DEBUG >-+ if (ret != -1) >-+ dprint(1, (debugfile, "nntp_read_header: %s\n", buf)); >-+#endif >-+ fclose (f); >-+ unlink (tempfile); >-+ return (ret == -1 ? -1 : 1); >-+ } >-+ >-+ h->article_num = article_num; >-+ h->env = mutt_read_rfc822_header (f, h, 0, 0); >-+ fclose (f); >-+ unlink (tempfile); >-+ >-+ if (h->env->xref != NULL) >-+ nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h); >-+ else if (h->article_num == 0 && msgid) >-+ { >-+ snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid); >-+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0) >-+ h->article_num = atoi (buf + 4); >-+ } >-+ >-+ return 0; >-+} >-+ >-+static int parse_description (char *line, void *n) >-+{ >-+#define news ((NNTP_SERVER *) n) >-+ register char *d = line; >-+ NNTP_DATA *data; >-+ >-+ if (!line) >-+ return 0; >-+ while (*d && *d != '\t' && *d != ' ') d++; >-+ *d = 0; >-+ d++; >-+ while (*d && (*d == '\t' || *d == ' ')) d++; >-+ dprint (2, (debugfile, "group: %s, desc: %s\n", line, d)); >-+ if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL && >-+ mutt_strcmp (d, data->desc)) >-+ { >-+ FREE (&data->desc); >-+ data->desc = safe_strdup (d); >-+ } >-+ return 0; >-+#undef news >-+} >-+ >-+static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg) >-+{ >-+ char buf[STRING]; >-+ >-+ if (!option (OPTLOADDESC) || !data || !data->nserv) >-+ return; >-+ >-+ /* Get newsgroup description, if we can */ >-+ if (data->nserv->hasXGTITLE) >-+ snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask); >-+ else >-+ snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask); >-+ if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0) >-+ { >-+#ifdef DEBUG >-+ nntp_error ("nntp_get_desc()", buf); >-+#endif >-+ } >-+} >-+ >-+/* >-+ * XOVER returns a tab separated list of: >-+ * id|subject|from|date|Msgid|references|bytes|lines|xref >-+ * >-+ * This has to duplicate some of the functionality of >-+ * mutt_read_rfc822_header(), since it replaces the call to that (albeit with >-+ * a limited number of headers which are "parsed" by placement in the list) >-+ */ >-+static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr) >-+{ >-+ NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data; >-+ char *p, *b; >-+ int x, done = 0; >-+ >-+ hdr->env = mutt_new_envelope(); >-+ hdr->env->newsgroups = safe_strdup (nntp_data->group); >-+ hdr->content = mutt_new_body(); >-+ hdr->content->type = TYPETEXT; >-+ hdr->content->subtype = safe_strdup ("plain"); >-+ hdr->content->encoding = ENC7BIT; >-+ hdr->content->disposition = DISPINLINE; >-+ hdr->content->length = -1; >-+ b = p = buf; >-+ >-+ for (x = 0; !done && x < 9; x++) >-+ { >-+ /* if from file, need to skip newline character */ >-+ while (*p && *p != '\n' && *p != '\t') p++; >-+ if (!*p) done++; >-+ *p = '\0'; >-+ p++; >-+ switch (x) >-+ { >-+ case 0: >-+ >-+ hdr->article_num = atoi (b); >-+ nntp_get_status (ctx, hdr, NULL, hdr->article_num); >-+ break; >-+ case 1: >-+ hdr->env->subject = safe_strdup (b); >-+ /* Now we need to do the things which would normally be done in >-+ * mutt_read_rfc822_header() */ >-+ if (hdr->env->subject) >-+ { >-+ regmatch_t pmatch[1]; >-+ >-+ rfc2047_decode (&hdr->env->subject); >-+ >-+ if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0) >-+ hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo; >-+ else >-+ hdr->env->real_subj = hdr->env->subject; >-+ } >-+ break; >-+ case 2: >-+ rfc822_free_address (&hdr->env->from); >-+ hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b); >-+ rfc2047_decode_adrlist (hdr->env->from); >-+ break; >-+ case 3: >-+ hdr->date_sent = mutt_parse_date (b, hdr); >-+ hdr->received = hdr->date_sent; >-+ break; >-+ case 4: >-+ FREE (&hdr->env->message_id); >-+ hdr->env->message_id = safe_strdup (b); >-+ break; >-+ case 5: >-+ mutt_free_list (&hdr->env->references); >-+ hdr->env->references = mutt_parse_references (b, 0); >-+ break; >-+ case 6: >-+ hdr->content->length = atoi (b); >-+ break; >-+ case 7: >-+ hdr->lines = atoi (b); >-+ break; >-+ case 8: >-+ if (!hdr->read) >-+ FREE (&hdr->env->xref); >-+ b = b + 6; /* skips the "Xref: " */ >-+ hdr->env->xref = safe_strdup (b); >-+ nntp_parse_xref (ctx, nntp_data->group, b, hdr); >-+ } >-+ if (!*p) >-+ return -1; >-+ b = p; >-+ } >-+ return 0; >-+} >-+ >-+typedef struct >-+{ >-+ CONTEXT *ctx; >-+ unsigned int base; >-+ unsigned int first; >-+ unsigned int last; >-+ unsigned short *messages; >-+ char* msg; >-+} FETCH_CONTEXT; >-+ >-+#define fc ((FETCH_CONTEXT *) c) >-+static int nntp_fetch_numbers (char *line, void *c) >-+{ >-+ unsigned int num; >-+ >-+ if (!line) >-+ return 0; >-+ num = atoi (line); >-+ if (num < fc->base || num > fc->last) >-+ return 0; >-+ fc->messages[num - fc->base] = 1; >-+ return 0; >-+} >-+ >-+static int add_xover_line (char *line, void *c) >-+{ >-+ unsigned int num, total; >-+ CONTEXT *ctx = fc->ctx; >-+ NNTP_DATA *data = (NNTP_DATA *)ctx->data; >-+ >-+ if (!line) >-+ return 0; >-+ >-+ if (ctx->msgcount >= ctx->hdrmax) >-+ mx_alloc_memory (ctx); >-+ ctx->hdrs[ctx->msgcount] = mutt_new_header (); >-+ ctx->hdrs[ctx->msgcount]->index = ctx->msgcount; >-+ >-+ nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]); >-+ num = ctx->hdrs[ctx->msgcount]->article_num; >-+ >-+ if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base]) >-+ { >-+ ctx->msgcount++; >-+ if (num > data->lastLoaded) >-+ data->lastLoaded = num; >-+ num = num - fc->first + 1; >-+ total = fc->last - fc->first + 1; >-+ if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0)) >-+ mutt_message ("%s %d/%d", fc->msg, num, total); >-+ } >-+ else >-+ mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */ >-+ >-+ return 0; >-+} >-+#undef fc >-+ >-+static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first, >-+ unsigned int last) >-+{ >-+ char buf[HUGE_STRING]; >-+ char *msg = _("Fetching message headers..."); >-+ NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data); >-+ int ret; >-+ int num; >-+ int oldmsgcount; >-+ unsigned int current; >-+ FILE *f; >-+ FETCH_CONTEXT fc; >-+ >-+ /* if empty group or nothing to do */ >-+ if (!last || first > last) >-+ return 0; >-+ >-+ /* fetch list of articles */ >-+ fc.ctx = ctx; >-+ fc.base = first; >-+ fc.last = last; >-+ fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short)); >-+ if (nntp_data->nserv->hasLISTGROUP) >-+ { >-+ mutt_message _("Fetching list of articles..."); >-+ snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group); >-+ if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0) >-+ { >-+ mutt_error (_("LISTGROUP command failed: %s"), buf); >-+#ifdef DEBUG >-+ nntp_error ("nntp_fetch_headers()", buf); >-+#endif >-+ FREE (&fc.messages); >-+ return -1; >-+ } >-+ } >-+ else >-+ { >-+ for (num = 0; num < last - first + 1; num++) >-+ fc.messages[num] = 1; >-+ } >-+ >-+ /* CACHE: must be loaded xover cache here */ >-+ num = nntp_data->lastCached - first + 1; >-+ if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0) >-+ { >-+ nntp_cache_expand (buf, nntp_data->cache); >-+ mutt_message _("Fetching headers from cache..."); >-+ if ((f = safe_fopen (buf, "r"))) >-+ { >-+ int r = 0; >-+ >-+ /* counting number of lines */ >-+ while (fgets (buf, sizeof (buf), f) != NULL) >-+ r++; >-+ rewind (f); >-+ while (r > num && fgets (buf, sizeof (buf), f) != NULL) >-+ r--; >-+ oldmsgcount = ctx->msgcount; >-+ fc.first = first; >-+ fc.last = first + num - 1; >-+ fc.msg = NULL; >-+ while (fgets (buf, sizeof (buf), f) != NULL) >-+ add_xover_line (buf, &fc); >-+ fclose (f); >-+ nntp_data->lastLoaded = fc.last; >-+ first = fc.last + 1; >-+ if (ctx->msgcount > oldmsgcount) >-+ mx_update_context (ctx, ctx->msgcount - oldmsgcount); >-+ } >-+ else >-+ nntp_delete_cache (nntp_data); >-+ } >-+ num = last - first + 1; >-+ if (num <= 0) >-+ { >-+ FREE (&fc.messages); >-+ return 0; >-+ } >-+ >-+ /* >-+ * Without XOVER, we have to fetch each article header and parse >-+ * it. With XOVER, we ask for all of them >-+ */ >-+ mutt_message (msg); >-+ if (nntp_data->nserv->hasXOVER) >-+ { >-+ oldmsgcount = ctx->msgcount; >-+ fc.first = first; >-+ fc.last = last; >-+ fc.msg = msg; >-+ snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last); >-+ ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0); >-+ if (ctx->msgcount > oldmsgcount) >-+ mx_update_context (ctx, ctx->msgcount - oldmsgcount); >-+ if (ret != 0) >-+ { >-+ mutt_error (_("XOVER command failed: %s"), buf); >-+#ifdef DEBUG >-+ nntp_error ("nntp_fetch_headers()", buf); >-+#endif >-+ FREE (&fc.messages); >-+ return -1; >-+ } >-+ /* fetched OK */ >-+ } >-+ else >-+ for (current = first; current <= last; current++) >-+ { >-+ HEADER *h; >-+ >-+ ret = current - first + 1; >-+ mutt_message ("%s %d/%d", msg, ret, num); >-+ >-+ if (!fc.messages[current - fc.base]) >-+ continue; >-+ >-+ if (ctx->msgcount >= ctx->hdrmax) >-+ mx_alloc_memory (ctx); >-+ h = ctx->hdrs[ctx->msgcount] = mutt_new_header (); >-+ h->index = ctx->msgcount; >-+ >-+ ret = nntp_read_header (ctx, NULL, current); >-+ if (ret == 0) /* Got article. Fetch next header */ >-+ { >-+ nntp_get_status (ctx, h, NULL, h->article_num); >-+ ctx->msgcount++; >-+ mx_update_context (ctx, 1); >-+ } >-+ else >-+ mutt_free_header (&h); /* skip it */ >-+ if (ret == -1) >-+ { >-+ FREE (&fc.messages); >-+ return -1; >-+ } >-+ >-+ if (current > nntp_data->lastLoaded) >-+ nntp_data->lastLoaded = current; >-+ } >-+ FREE (&fc.messages); >-+ nntp_data->lastLoaded = last; >-+ mutt_clear_error (); >-+ return 0; >-+} >-+ >-+/* >-+ * currently, nntp "mailbox" is "newsgroup" >-+ */ >-+int nntp_open_mailbox (CONTEXT *ctx) >-+{ >-+ NNTP_DATA *nntp_data; >-+ NNTP_SERVER *serv; >-+ char buf[HUGE_STRING]; >-+ char server[LONG_STRING]; >-+ int count = 0; >-+ unsigned int first; >-+ ACCOUNT acct; >-+ >-+ if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf) >-+ { >-+ mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path); >-+ mutt_sleep (2); >-+ return -1; >-+ } >-+ >-+ server[0] = '\0'; >-+ nntp_expand_path (server, sizeof (server), &acct); >-+ if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK) >-+ return -1; >-+ >-+ CurrentNewsSrv = serv; >-+ >-+ /* create NNTP-specific state struct if nof found in list */ >-+ if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL) >-+ { >-+ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1); >-+ nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA); >-+ strcpy (nntp_data->group, buf); >-+ hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0); >-+ nntp_add_to_list (serv, nntp_data); >-+ } >-+ ctx->data = nntp_data; >-+ ctx->mx_close = nntp_fastclose_mailbox; >-+ nntp_data->nserv = serv; >-+ >-+ mutt_message (_("Selecting %s..."), nntp_data->group); >-+ >-+ if (!nntp_data->desc) >-+ { >-+ nntp_get_desc (nntp_data, nntp_data->group, NULL); >-+ if (nntp_data->desc) >-+ nntp_save_cache_index (serv); >-+ } >-+ >-+ buf[0] = 0; >-+ if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0) >-+ { >-+#ifdef DEBUG >-+ nntp_error ("nntp_open_mailbox()", buf); >-+#endif >-+ return -1; >-+ } >-+ >-+ if (mutt_strncmp ("211", buf, 3)) >-+ { >-+ LIST *l = serv->list; >-+ >-+ /* GROUP command failed */ >-+ if (!mutt_strncmp ("411", buf, 3)) >-+ { >-+ mutt_error (_("Newsgroup %s not found on server %s"), >-+ nntp_data->group, serv->conn->account.host); >-+ >-+ /* CACHE: delete cache and line from .index */ >-+ nntp_delete_cache (nntp_data); >-+ hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data); >-+ while (l && l->data != (void *) nntp_data) l = l->next; >-+ if (l) >-+ l->data = NULL; >-+ >-+ sleep (2); >-+ } >-+ >-+ return -1; >-+ } >-+ >-+ sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage, >-+ &nntp_data->lastMessage, buf); >-+ >-+ nntp_data->deleted = 0; >-+ >-+ time (&serv->check_time); >-+ >-+ /* >-+ * Check for max adding context. If it is greater than $nntp_context, >-+ * strip off extra articles >-+ */ >-+ first = nntp_data->firstMessage; >-+ if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext) >-+ first = nntp_data->lastMessage - NntpContext + 1; >-+ if (first) >-+ nntp_data->lastLoaded = first - 1; >-+ return nntp_fetch_headers (ctx, first, nntp_data->lastMessage); >-+} >-+ >-+int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno) >-+{ >-+ char buf[LONG_STRING]; >-+ char path[_POSIX_PATH_MAX]; >-+ NNTP_CACHE *cache; >-+ char *m = _("Fetching message..."); >-+ int ret; >-+ >-+ /* see if we already have the message in our cache */ >-+ cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN]; >-+ >-+ /* if everything is fine, assign msg->fp and return */ >-+ if (cache->path && cache->index == ctx->hdrs[msgno]->index && >-+ (msg->fp = fopen (cache->path, "r"))) >-+ return 0; >-+ >-+ /* clear the previous entry */ >-+ unlink (cache->path); >-+ free (cache->path); >-+ >-+ mutt_message (m); >-+ >-+ cache->index = ctx->hdrs[msgno]->index; >-+ mutt_mktemp (path, sizeof(path)); >-+ cache->path = safe_strdup (path); >-+ if (!(msg->fp = safe_fopen (path, "w+"))) >-+ { >-+ FREE (&cache->path); >-+ return -1; >-+ } >-+ >-+ if (ctx->hdrs[msgno]->article_num == 0) >-+ snprintf (buf, sizeof (buf), "ARTICLE %s\r\n", >-+ ctx->hdrs[msgno]->env->message_id); >-+ else >-+ snprintf (buf, sizeof (buf), "ARTICLE %d\r\n", >-+ ctx->hdrs[msgno]->article_num); >-+ >-+ ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile, >-+ msg->fp, ctx->tagged); >-+ if (ret == 1) >-+ { >-+ mutt_error (_("Article %d not found on server"), >-+ ctx->hdrs[msgno]->article_num); >-+ dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf)); >-+ } >-+ >-+ if (ret) >-+ { >-+ fclose (msg->fp); >-+ unlink (path); >-+ FREE (&cache->path); >-+ return -1; >-+ } >-+ >-+ mutt_free_envelope (&ctx->hdrs[msgno]->env); >-+ ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0); >-+ /* fix content length */ >-+ fseek(msg->fp, 0, SEEK_END); >-+ ctx->hdrs[msgno]->content->length = ftell (msg->fp) - >-+ ctx->hdrs[msgno]->content->offset; >-+ >-+ /* this is called in mutt before the open which fetches the message, >-+ * which is probably wrong, but we just call it again here to handle >-+ * the problem instead of fixing it. >-+ */ >-+ mutt_parse_mime_message (ctx, ctx->hdrs[msgno]); >-+ >-+ /* These would normally be updated in mx_update_context(), but the >-+ * full headers aren't parsed with XOVER, so the information wasn't >-+ * available then. >-+ */ >-+#if defined(HAVE_PGP) || defined(HAVE_SMIME) >-+ ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content); >-+#endif /* HAVE_PGP || HAVE_SMIME */ >-+ >-+ mutt_clear_error(); >-+ rewind (msg->fp); >-+ >-+ return 0; >-+} >-+ >-+/* Post article */ >-+int nntp_post (const char *msg) { >-+ char buf[LONG_STRING]; >-+ size_t len; >-+ FILE *f; >-+ NNTP_DATA *nntp_data; >-+ >-+ if (Context && Context->magic == M_NNTP) >-+ nntp_data = (NNTP_DATA *)Context->data; >-+ else >-+ { >-+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) || >-+ !CurrentNewsSrv->list || !CurrentNewsSrv->list->data) >-+ { >-+ mutt_error (_("Can't post article. No connection to news server.")); >-+ return -1; >-+ } >-+ nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data; >-+ } >-+ >-+ if (!(f = safe_fopen (msg, "r"))) >-+ { >-+ mutt_error (_("Can't post article. Unable to open %s"), msg); >-+ return -1; >-+ } >-+ >-+ strfcpy (buf, "POST\r\n", sizeof (buf)); >-+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) >-+ { >-+ mutt_error (_("Can't post article. Connection to %s lost."), >-+ nntp_data->nserv->conn->account.host); >-+ return -1; >-+ } >-+ if (buf[0] != '3') >-+ { >-+ mutt_error (_("Can't post article: %s"), buf); >-+ return -1; >-+ } >-+ >-+ buf[0] = '.'; >-+ buf[1] = '\0'; >-+ while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL) >-+ { >-+ len = strlen (buf); >-+ if (buf[len - 1] == '\n') >-+ { >-+ buf[len - 1] = '\r'; >-+ buf[len] = '\n'; >-+ len++; >-+ buf[len] = '\0'; >-+ } >-+ if (buf[1] == '.') >-+ mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR); >-+ else >-+ mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR); >-+ } >-+ fclose (f); >-+ >-+ if (buf[strlen (buf) - 1] != '\n') >-+ mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR); >-+ mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR); >-+ if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0) >-+ { >-+ mutt_error (_("Can't post article. Connection to %s lost."), >-+ nntp_data->nserv->conn->account.host); >-+ return -1; >-+ } >-+ if (buf[0] != '2') >-+ { >-+ mutt_error (_("Can't post article: %s"), buf); >-+ return -1; >-+ } >-+ >-+ return 0; >-+} >-+ >-+/* nntp_logout_all: close all open connections. */ >-+void nntp_logout_all (void) >-+{ >-+ char buf[LONG_STRING]; >-+ CONNECTION* conn; >-+ >-+ conn = mutt_socket_head (); >-+ >-+ while (conn) >-+ { >-+ CONNECTION *next = conn->next; >-+ >-+ if (conn->account.type == M_ACCT_TYPE_NNTP) >-+ { >-+ mutt_message (_("Closing connection to %s..."), conn->account.host); >-+ mutt_socket_write (conn, "QUIT\r\n"); >-+ mutt_socket_readln (buf, sizeof (buf), conn); >-+ mutt_clear_error (); >-+ mutt_socket_close (conn); >-+ mutt_socket_free (conn); >-+ } >-+ >-+ conn = next; >-+ } >-+} >-+ >-+static void nntp_free_acache (NNTP_DATA *data) >-+{ >-+ int i; >-+ >-+ for (i = 0; i < NNTP_CACHE_LEN; i++) >-+ { >-+ if (data->acache[i].path) >-+ { >-+ unlink (data->acache[i].path); >-+ FREE (&data->acache[i].path); >-+ } >-+ } >-+} >-+ >-+void nntp_delete_data (void *p) >-+{ >-+ NNTP_DATA *data = (NNTP_DATA *)p; >-+ >-+ if (!p) >-+ return; >-+ FREE (&data->entries); >-+ FREE (&data->desc); >-+ FREE (&data->cache); >-+ nntp_free_acache (data); >-+ FREE (p); >-+} >-+ >-+int nntp_sync_mailbox (CONTEXT *ctx) >-+{ >-+ NNTP_DATA *data = ctx->data; >-+ >-+ /* CACHE: update cache and .index files */ >-+ if ((option (OPTSAVEUNSUB) || data->subscribed)) >-+ nntp_save_cache_group (ctx); >-+ nntp_free_acache (data); >-+ >-+ data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */ >-+ return 0; >-+} >-+ >-+int nntp_fastclose_mailbox (CONTEXT *ctx) >-+{ >-+ NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp; >-+ >-+ if (!data) >-+ return 0; >-+ nntp_free_acache (data); >-+ if (!data->nserv || !data->nserv->newsgroups || !data->group) >-+ return 0; >-+ nntp_save_cache_index (data->nserv); >-+ if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL >-+ || tmp != data) >-+ nntp_delete_data (data); >-+ return 0; >-+} >-+ >-+/* commit changes and terminate connection */ >-+int nntp_close_mailbox (CONTEXT *ctx) >-+{ >-+ if (!ctx) >-+ return -1; >-+ mutt_message _("Quitting newsgroup..."); >-+ if (ctx->data) >-+ { >-+ NNTP_DATA *data = (NNTP_DATA *) ctx->data; >-+ int ret; >-+ >-+ if (data->nserv && data->nserv->conn && ctx->unread) >-+ { >-+ ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?")); >-+ if (ret == M_YES) >-+ mutt_newsgroup_catchup (data->nserv, data->group); >-+ else if (ret < 0) >-+ return -1; >-+ } >-+ } >-+ nntp_sync_mailbox (ctx); >-+ if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv) >-+ { >-+ NNTP_SERVER *news; >-+ >-+ news = ((NNTP_DATA *)ctx->data)->nserv; >-+ newsrc_gen_entries (ctx); >-+ ((NNTP_DATA *)ctx->data)->unread = ctx->unread; >-+ mutt_newsrc_update (news); >-+ } >-+ mutt_clear_error(); >-+ return 0; >-+} >-+ >-+/* use the GROUP command to poll for new mail */ >-+static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data) >-+{ >-+ char buf[LONG_STRING]; >-+ int count = 0; >-+ >-+ if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL)) >-+ return 0; >-+ >-+ buf[0] = 0; >-+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) >-+ { >-+#ifdef DEBUG >-+ nntp_error ("nntp_check_mailbox()", buf); >-+#endif >-+ return -1; >-+ } >-+ if (mutt_strncmp ("211", buf, 3)) >-+ { >-+ buf[0] = 0; >-+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) >-+ { >-+#ifdef DEBUG >-+ nntp_error ("nntp_check_mailbox()", buf); >-+#endif >-+ return -1; >-+ } >-+ } >-+ if (!mutt_strncmp ("211", buf, 3)) >-+ { >-+ int first; >-+ int last; >-+ >-+ sscanf (buf + 4, "%d %d %d", &count, &first, &last); >-+ nntp_data->firstMessage = first; >-+ nntp_data->lastMessage = last; >-+ if (ctx && last > nntp_data->lastLoaded) >-+ { >-+ nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last); >-+ time (&nntp_data->nserv->check_time); >-+ return 1; >-+ } >-+ if (!last || (!nntp_data->rc && !nntp_data->lastCached)) >-+ nntp_data->unread = count; >-+ else >-+ mutt_newsgroup_stat (nntp_data); >-+ /* active was renumbered? */ >-+ if (last < nntp_data->lastLoaded) >-+ { >-+ if (!nntp_data->max) >-+ { >-+ nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY)); >-+ nntp_data->max = 5; >-+ } >-+ nntp_data->lastCached = 0; >-+ nntp_data->num = 1; >-+ nntp_data->entries[0].first = 1; >-+ nntp_data->entries[0].last = 0; >-+ } >-+ } >-+ >-+ time (&nntp_data->nserv->check_time); >-+ return 0; >-+} >-+ >-+int nntp_check_mailbox (CONTEXT *ctx) >-+{ >-+ return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data); >-+} >-+ >-+static int add_group (char *buf, void *serv) >-+{ >-+#define s ((NNTP_SERVER *) serv) >-+ char group[LONG_STRING], mod, desc[HUGE_STRING]; >-+ int first, last; >-+ NNTP_DATA *nntp_data; >-+ static int n = 0; >-+ >-+ _checked = n; /* _checked have N, where N = number of groups */ >-+ if (!buf) /* at EOF must be zerouth */ >-+ n = 0; >-+ >-+ if (!s || !buf) >-+ return 0; >-+ >-+ *desc = 0; >-+ sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc); >-+ if (!group) >-+ return 0; >-+ if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL) >-+ { >-+ n++; >-+ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1); >-+ nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA); >-+ strcpy (nntp_data->group, group); >-+ nntp_data->nserv = s; >-+ if (s->newsgroups->nelem < s->newsgroups->curnelem * 2) >-+ s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2, 0); >-+ hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0); >-+ nntp_add_to_list (s, nntp_data); >-+ } >-+ nntp_data->deleted = 0; >-+ nntp_data->firstMessage = first; >-+ nntp_data->lastMessage = last; >-+ if (mod == 'y') >-+ nntp_data->allowed = 1; >-+ else >-+ nntp_data->allowed = 0; >-+ if (nntp_data->desc) >-+ FREE (&nntp_data->desc); >-+ if (*desc) >-+ nntp_data->desc = safe_strdup (desc); >-+ if (nntp_data->rc || nntp_data->lastCached) >-+ mutt_newsgroup_stat (nntp_data); >-+ else if (nntp_data->lastMessage && >-+ nntp_data->firstMessage <= nntp_data->lastMessage) >-+ nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1; >-+ else >-+ nntp_data->unread = 0; >-+ >-+ return 0; >-+#undef s >-+} >-+ >-+int nntp_check_newgroups (NNTP_SERVER *serv, int force) >-+{ >-+ char buf[LONG_STRING]; >-+ char msg[SHORT_STRING]; >-+ NNTP_DATA nntp_data; >-+ LIST *l; >-+ LIST emp; >-+ time_t now; >-+ struct tm *t; >-+ unsigned int count = 0; >-+ unsigned int total = 0; >-+ >-+ if (!serv || !serv->newgroups_time) >-+ return -1; >-+ >-+ if (nntp_open_connection (serv) < 0) >-+ return -1; >-+ >-+ /* check subscribed groups for new news */ >-+ if (option (OPTSHOWNEWNEWS)) >-+ { >-+ mutt_message _("Checking for new messages..."); >-+ for (l = serv->list; l; l = l->next) >-+ { >-+ serv->check_time = 0; /* really check! */ >-+ if (l->data && ((NNTP_DATA *) l->data)->subscribed) >-+ _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data); >-+ } >-+ } >-+ else if (!force) >-+ return 0; >-+ >-+ mutt_message _("Checking for new newsgroups..."); >-+ now = serv->newgroups_time; >-+ time (&serv->newgroups_time); >-+ t = gmtime (&now); >-+ snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n", >-+ (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, >-+ t->tm_sec); >-+ nntp_data.nserv = serv; >-+ if (Context && Context->magic == M_NNTP) >-+ nntp_data.group = ((NNTP_DATA *)Context->data)->group; >-+ else >-+ nntp_data.group = NULL; >-+ l = serv->tail; >-+ if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."), >-+ add_group, serv, 0) != 0) >-+ { >-+#ifdef DEBUG >-+ nntp_error ("nntp_check_newgroups()", buf); >-+#endif >-+ return -1; >-+ } >-+ >-+ strfcpy (msg, _("Loading descriptions..."), sizeof (msg)); >-+ mutt_message (msg); >-+ if (l) >-+ emp.next = l->next; >-+ else >-+ emp.next = serv->list; >-+ l = &emp; >-+ while (l->next) >-+ { >-+ l = l->next; >-+ ((NNTP_DATA *) l->data)->new = 1; >-+ total++; >-+ } >-+ l = &emp; >-+ while (l->next) >-+ { >-+ l = l->next; >-+ nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL); >-+ count++; >-+ if (ReadInc && (count % ReadInc == 0)) >-+ mutt_message ("%s %d/%d", msg, count, total); >-+ } >-+ if (emp.next) >-+ nntp_save_cache_index (serv); >-+ mutt_clear_error (); >-+ return _checked; >-+} >-+ >-+/* Load list of all newsgroups from cache ALL */ >-+int nntp_get_cache_all (NNTP_SERVER *serv) >-+{ >-+ char buf[HUGE_STRING]; >-+ FILE *f; >-+ >-+ nntp_cache_expand (buf, serv->cache); >-+ if ((f = safe_fopen (buf, "r"))) >-+ { >-+ int i = 0; >-+ >-+ while (fgets (buf, sizeof(buf), f) != NULL) >-+ { >-+ if (ReadInc && (i % ReadInc == 0)) >-+ mutt_message (_("Loading list from cache... %d"), i); >-+ add_group (buf, serv); >-+ i++; >-+ } >-+ add_group (NULL, NULL); >-+ fclose (f); >-+ mutt_clear_error (); >-+ return 0; >-+ } >-+ else >-+ { >-+ FREE (&serv->cache); >-+ return -1; >-+ } >-+} >-+ >-+/* Load list of all newsgroups from active */ >-+int nntp_get_active (NNTP_SERVER *serv) >-+{ >-+ char msg[SHORT_STRING]; >-+ NNTP_DATA nntp_data; >-+ LIST *tmp; >-+ >-+ if (nntp_open_connection (serv) < 0) >-+ return -1; >-+ >-+ snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."), >-+ serv->conn->account.host); >-+ mutt_message (msg); >-+ time (&serv->newgroups_time); >-+ nntp_data.nserv = serv; >-+ nntp_data.group = NULL; >-+ >-+ if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0) >-+ { >-+#ifdef DEBUG >-+ nntp_error ("nntp_get_active()", "LIST\r\n"); >-+#endif >-+ return -1; >-+ } >-+ >-+ strfcpy (msg, _("Loading descriptions..."), sizeof (msg)); >-+ mutt_message (msg); >-+ nntp_get_desc (&nntp_data, "*", msg); >-+ >-+ for (tmp = serv->list; tmp; tmp = tmp->next) >-+ { >-+ NNTP_DATA *data = (NNTP_DATA *)tmp->data; >-+ >-+ if (data && data->deleted && !data->rc) >-+ { >-+ nntp_delete_cache (data); >-+ hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data); >-+ tmp->data = NULL; >-+ } >-+ } >-+ nntp_save_cache_index (serv); >-+ >-+ mutt_clear_error (); >-+ return _checked; >-+} >-+ >-+/* >-+ * returns -1 if error ocurred while retrieving header, >-+ * number of articles which ones exist in context on success. >-+ */ >-+int nntp_check_msgid (CONTEXT *ctx, const char *msgid) >-+{ >-+ int ret; >-+ >-+ /* if msgid is already in context, don't reload them */ >-+ if (hash_find (ctx->id_hash, msgid)) >-+ return 1; >-+ if (ctx->msgcount == ctx->hdrmax) >-+ mx_alloc_memory (ctx); >-+ ctx->hdrs[ctx->msgcount] = mutt_new_header (); >-+ ctx->hdrs[ctx->msgcount]->index = ctx->msgcount; >-+ >-+ mutt_message (_("Fetching %s from server..."), msgid); >-+ ret = nntp_read_header (ctx, msgid, 0); >-+ /* since nntp_read_header() may set read flag, we must reset it */ >-+ ctx->hdrs[ctx->msgcount]->read = 0; >-+ if (ret != 0) >-+ mutt_free_header (&ctx->hdrs[ctx->msgcount]); >-+ else >-+ { >-+ ctx->msgcount++; >-+ mx_update_context (ctx, 1); >-+ ctx->changed = 1; >-+ } >-+ return ret; >-+} >-+ >-+typedef struct >-+{ >-+ CONTEXT *ctx; >-+ unsigned int num; >-+ unsigned int max; >-+ unsigned int *child; >-+} CHILD_CONTEXT; >-+ >-+static int check_children (char *s, void *c) >-+{ >-+#define cc ((CHILD_CONTEXT *) c) >-+ unsigned int i, n; >-+ >-+ if (!s || (n = atoi (s)) == 0) >-+ return 0; >-+ for (i = 0; i < cc->ctx->msgcount; i++) >-+ if (cc->ctx->hdrs[i]->article_num == n) >-+ return 0; >-+ if (cc->num >= cc->max) >-+ safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25)); >-+ cc->child[cc->num++] = n; >-+ >-+ return 0; >-+#undef cc >-+} >-+ >-+int nntp_check_children (CONTEXT *ctx, const char *msgid) >-+{ >-+ NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data; >-+ char buf[STRING]; >-+ int i, ret = 0, tmp = 0; >-+ CHILD_CONTEXT cc; >-+ >-+ if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn || >-+ !nntp_data->nserv->conn->account.host) >-+ return -1; >-+ if (nntp_data->firstMessage > nntp_data->lastLoaded) >-+ return 0; >-+ if (!nntp_data->nserv->hasXPAT) >-+ { >-+ mutt_error (_("Server %s does not support this operation!"), >-+ nntp_data->nserv->conn->account.host); >-+ return -1; >-+ } >-+ >-+ snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n", >-+ nntp_data->firstMessage, nntp_data->lastLoaded, msgid); >-+ >-+ cc.ctx = ctx; >-+ cc.num = 0; >-+ cc.max = 25; >-+ cc.child = safe_malloc (sizeof (unsigned int) * 25); >-+ if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0)) >-+ { >-+ FREE (&cc.child); >-+ return -1; >-+ } >-+ /* dont try to read the xover cache. check_children() already >-+ * made sure that we dont have the article, so we need to visit >-+ * the server. Reading the cache at this point is also bad >-+ * because it would duplicate messages */ >-+ if (option (OPTNEWSCACHE)) >-+ { >-+ tmp++; >-+ unset_option (OPTNEWSCACHE); >-+ } >-+ for (i = 0; i < cc.num; i++) >-+ { >-+ if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i]))) >-+ break; >-+ if (ctx->msgcount && >-+ ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i]) >-+ ctx->hdrs[ctx->msgcount - 1]->read = 0; >-+ } >-+ if (tmp) >-+ set_option (OPTNEWSCACHE); >-+ FREE (&cc.child); >-+ return ret; >-+} >-diff -udprP mutt-1.5.20.orig/nntp.h mutt-1.5.20/nntp.h >---- mutt-1.5.20.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300 >-+++ mutt-1.5.20/nntp.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -0,0 +1,136 @@ >-+/* >-+ * Copyright (C) 1998 Brandon Long <blong@fiction.net> >-+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net> >-+ * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua> >-+ * >-+ * This program is free software; you can redistribute it and/or modify >-+ * it under the terms of the GNU General Public License as published by >-+ * the Free Software Foundation; either version 2 of the License, or >-+ * (at your option) any later version. >-+ * >-+ * This program is distributed in the hope that it will be useful, >-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-+ * GNU General Public License for more details. >-+ * >-+ * You should have received a copy of the GNU General Public License >-+ * along with this program; if not, write to the Free Software >-+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >-+ */ >-+ >-+#ifndef _NNTP_H_ >-+#define _NNTP_H_ 1 >-+ >-+#include "mutt_socket.h" >-+#include "mailbox.h" >-+ >-+#include <time.h> >-+ >-+#define NNTP_PORT 119 >-+#define NNTP_SSL_PORT 563 >-+ >-+/* number of entries in the hash table */ >-+#define NNTP_CACHE_LEN 10 >-+ >-+enum >-+{ >-+ NNTP_NONE = 0, >-+ NNTP_OK, >-+ NNTP_BYE >-+}; >-+ >-+typedef struct >-+{ >-+ int first; >-+ int last; >-+} NEWSRC_ENTRY; >-+ >-+typedef struct >-+{ >-+ unsigned int hasXPAT : 1; >-+ unsigned int hasXGTITLE : 1; >-+ unsigned int hasXOVER : 1; >-+ unsigned int hasLISTGROUP : 1; >-+ unsigned int status : 3; >-+ char *newsrc; >-+ char *cache; >-+ int stat; >-+ off_t size; >-+ time_t mtime; >-+ time_t newgroups_time; >-+ time_t check_time; >-+ HASH *newsgroups; >-+ LIST *list; /* list of newsgroups */ >-+ LIST *tail; /* last entry of list */ >-+ CONNECTION *conn; >-+} NNTP_SERVER; >-+ >-+typedef struct >-+{ >-+ unsigned int index; >-+ char *path; >-+} NNTP_CACHE; >-+ >-+typedef struct >-+{ >-+ NEWSRC_ENTRY *entries; >-+ unsigned int num; /* number of used entries */ >-+ unsigned int max; /* number of allocated entries */ >-+ unsigned int unread; >-+ unsigned int firstMessage; >-+ unsigned int lastMessage; >-+ unsigned int lastLoaded; >-+ unsigned int lastCached; >-+ unsigned int subscribed : 1; >-+ unsigned int rc : 1; >-+ unsigned int new : 1; >-+ unsigned int allowed : 1; >-+ unsigned int deleted : 1; >-+ char *group; >-+ char *desc; >-+ char *cache; >-+ NNTP_SERVER *nserv; >-+ NNTP_CACHE acache[NNTP_CACHE_LEN]; >-+} NNTP_DATA; >-+ >-+/* internal functions */ >-+int nntp_get_active (NNTP_SERVER *); >-+int nntp_get_cache_all (NNTP_SERVER *); >-+int nntp_save_cache_index (NNTP_SERVER *); >-+int nntp_check_newgroups (NNTP_SERVER *, int); >-+int nntp_save_cache_group (CONTEXT *); >-+int nntp_parse_url (const char *, ACCOUNT *, char *, size_t); >-+void newsrc_gen_entries (CONTEXT *); >-+void nntp_get_status (CONTEXT *, HEADER *, char *, int); >-+void mutt_newsgroup_stat (NNTP_DATA *); >-+void nntp_delete_cache (NNTP_DATA *); >-+void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *); >-+void nntp_cache_expand (char *, const char *); >-+void nntp_delete_data (void *); >-+ >-+/* exposed interface */ >-+NNTP_SERVER *mutt_select_newsserver (char *); >-+NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *); >-+NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *); >-+NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *); >-+NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *); >-+void nntp_clear_cacheindex (NNTP_SERVER *); >-+int mutt_newsrc_update (NNTP_SERVER *); >-+int nntp_open_mailbox (CONTEXT *); >-+int nntp_sync_mailbox (CONTEXT *); >-+int nntp_check_mailbox (CONTEXT *); >-+int nntp_close_mailbox (CONTEXT *); >-+int nntp_fastclose_mailbox (CONTEXT *); >-+int nntp_fetch_message (MESSAGE *, CONTEXT *, int); >-+int nntp_post (const char *); >-+int nntp_check_msgid (CONTEXT *, const char *); >-+int nntp_check_children (CONTEXT *, const char *); >-+void nntp_buffy (char *); >-+void nntp_expand_path (char *, size_t, ACCOUNT *); >-+void nntp_logout_all (); >-+const char *nntp_format_str (char *, size_t, size_t, char, const char *, const char *, >-+ const char *, const char *, unsigned long, format_flag); >-+ >-+NNTP_SERVER *CurrentNewsSrv INITVAL (NULL); >-+ >-+#endif /* _NNTP_H_ */ >-diff -udprP mutt-1.5.20.orig/pager.c mutt-1.5.20/pager.c >---- mutt-1.5.20.orig/pager.c 2009-06-03 23:48:31.000000000 +0300 >-+++ mutt-1.5.20/pager.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -1059,6 +1059,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos, >- return b_read; >- } >- >-+#ifdef USE_NNTP >-+#include "mx.h" >-+#include "nntp.h" >-+#endif >-+ >- >- static int format_line (struct line_t **lineInfo, int n, unsigned char *buf, >- int flags, ansi_attr *pa, int cnt, >-@@ -1512,6 +1517,16 @@ static struct mapping_t PagerHelpExtra[] >- { NULL, 0 } >- }; >- >-+#ifdef USE_NNTP >-+static struct mapping_t PagerNewsHelpExtra[] = { >-+ { N_("Post"), OP_POST }, >-+ { N_("Followup"), OP_FOLLOWUP }, >-+ { N_("Del"), OP_DELETE }, >-+ { N_("Next"), OP_MAIN_NEXT_UNDELETED }, >-+ { NULL, 0 } >-+}; >-+#endif >-+ >- >- >- /* This pager is actually not so simple as it once was. It now operates in >-@@ -1553,6 +1568,10 @@ mutt_pager (const char *banner, const ch >- int old_PagerIndexLines; /* some people want to resize it >- * while inside the pager... */ >- >-+#ifdef USE_NNTP >-+ char *followup_to; >-+#endif >-+ >- if (!(flags & M_SHOWCOLOR)) >- flags |= M_SHOWFLAT; >- >-@@ -1592,7 +1611,11 @@ mutt_pager (const char *banner, const ch >- if (IsHeader (extra)) >- { >- strfcpy (tmphelp, helpstr, sizeof (tmphelp)); >-- mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra); >-+ mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, >-+#ifdef USE_NNTP >-+ (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra : >-+#endif >-+ PagerHelpExtra); >- snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer); >- } >- if (!InHelp) >-@@ -2465,6 +2488,15 @@ search_next: >- CHECK_READONLY; >- CHECK_ACL(M_ACL_WRITE, "flag message"); >- >-+#ifdef USE_NNTP >-+ if (Context->magic == M_NNTP) >-+ { >-+ mutt_flushinp (); >-+ mutt_error _("Can't change 'important' flag on NNTP server."); >-+ break; >-+ } >-+#endif >-+ >- mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged); >- redraw = REDRAW_STATUS | REDRAW_INDEX; >- if (option (OPTRESOLVE)) >-@@ -2498,6 +2530,60 @@ search_next: >- redraw = REDRAW_FULL; >- break; >- >-+#ifdef USE_NNTP >-+ case OP_POST: >-+ CHECK_MODE(IsHeader (extra) && !IsAttach (extra)); >-+ CHECK_ATTACH; >-+ if (extra->ctx && extra->ctx->magic == M_NNTP && >-+ !((NNTP_DATA *)extra->ctx->data)->allowed && >-+ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) >-+ break; >-+ ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL); >-+ redraw = REDRAW_FULL; >-+ break; >-+ >-+ case OP_FORWARD_TO_GROUP: >-+ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); >-+ CHECK_ATTACH; >-+ if (extra->ctx && extra->ctx->magic == M_NNTP && >-+ !((NNTP_DATA *)extra->ctx->data)->allowed && >-+ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) >-+ break; >-+ if (IsMsgAttach (extra)) >-+ mutt_attach_forward (extra->fp, extra->hdr, extra->idx, >-+ extra->idxlen, extra->bdy, SENDNEWS); >-+ else >-+ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); >-+ redraw = REDRAW_FULL; >-+ break; >-+ >-+ case OP_FOLLOWUP: >-+ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); >-+ CHECK_ATTACH; >-+ >-+ if (IsMsgAttach (extra)) >-+ followup_to = extra->bdy->hdr->env->followup_to; >-+ else >-+ followup_to = extra->hdr->env->followup_to; >-+ >-+ if (!followup_to || mutt_strcasecmp (followup_to, "poster") || >-+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES) >-+ { >-+ if (extra->ctx && extra->ctx->magic == M_NNTP && >-+ !((NNTP_DATA *)extra->ctx->data)->allowed && >-+ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) >-+ break; >-+ if (IsMsgAttach (extra)) >-+ mutt_attach_reply (extra->fp, extra->hdr, extra->idx, >-+ extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY); >-+ else >-+ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, >-+ extra->ctx, extra->hdr); >-+ redraw = REDRAW_FULL; >-+ break; >-+ } >-+#endif >-+ >- case OP_REPLY: >- CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); >- CHECK_ATTACH; >-@@ -2544,7 +2630,7 @@ search_next: >- CHECK_ATTACH; >- if (IsMsgAttach (extra)) >- mutt_attach_forward (extra->fp, extra->hdr, extra->idx, >-- extra->idxlen, extra->bdy); >-+ extra->idxlen, extra->bdy, 0); >- else >- ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); >- redraw = REDRAW_FULL; >-diff -udprP mutt-1.5.20.orig/parse.c mutt-1.5.20/parse.c >---- mutt-1.5.20.orig/parse.c 2009-06-01 19:29:32.000000000 +0300 >-+++ mutt-1.5.20/parse.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch >- /* not reached */ >- } >- >--static LIST *mutt_parse_references (char *s, int in_reply_to) >-+LIST *mutt_parse_references (char *s, int in_reply_to) >- { >- LIST *t, *lst = NULL; >- char *m; >-@@ -1067,6 +1067,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e, >- e->from = rfc822_parse_adrlist (e->from, p); >- matched = 1; >- } >-+#ifdef USE_NNTP >-+ else if (!mutt_strcasecmp (line+1, "ollowup-to")) >-+ { >-+ if (!e->followup_to) >-+ { >-+ mutt_remove_trailing_ws (p); >-+ e->followup_to = safe_strdup (mutt_skip_whitespace (p)); >-+ } >-+ matched = 1; >-+ } >-+#endif >- break; >- >- case 'i': >-@@ -1149,6 +1160,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e, >- } >- break; >- >-+#ifdef USE_NNTP >-+ case 'n': >-+ if (!mutt_strcasecmp (line + 1, "ewsgroups")) >-+ { >-+ FREE (&e->newsgroups); >-+ mutt_remove_trailing_ws (p); >-+ e->newsgroups = safe_strdup (mutt_skip_whitespace (p)); >-+ matched = 1; >-+ } >-+ break; >-+#endif >-+ >-+ case 'o': >-+ /* field `Organization:' saves only for pager! */ >-+ if (!mutt_strcasecmp (line + 1, "rganization")) >-+ { >-+ if (!e->organization && mutt_strcasecmp (p, "unknown")) >-+ e->organization = safe_strdup (p); >-+ } >-+ break; >-+ >- case 'r': >- if (!ascii_strcasecmp (line + 1, "eferences")) >- { >-@@ -1257,6 +1289,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e, >- e->x_label = safe_strdup(p); >- matched = 1; >- } >-+#ifdef USE_NNTP >-+ else if (!mutt_strcasecmp (line + 1, "-comment-to")) >-+ { >-+ if (!e->x_comment_to) >-+ e->x_comment_to = safe_strdup (p); >-+ matched = 1; >-+ } >-+ else if (!mutt_strcasecmp (line + 1, "ref")) >-+ { >-+ if (!e->xref) >-+ e->xref = safe_strdup (p); >-+ matched = 1; >-+ } >-+#endif >- >- default: >- break; >-diff -udprP mutt-1.5.20.orig/pattern.c mutt-1.5.20/pattern.c >---- mutt-1.5.20.orig/pattern.c 2009-06-03 23:48:31.000000000 +0300 >-+++ mutt-1.5.20/pattern.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -91,6 +91,9 @@ Flags[] = >- { 'U', M_UNREAD, 0, NULL }, >- { 'v', M_COLLAPSED, 0, NULL }, >- { 'V', M_CRYPT_VERIFIED, 0, NULL }, >-+#ifdef USE_NNTP >-+ { 'w', M_NEWSGROUPS, 0, eat_regexp }, >-+#endif >- { 'x', M_REFERENCE, 0, eat_regexp }, >- { 'X', M_MIMEATTACH, 0, eat_range }, >- { 'y', M_XLABEL, 0, eat_regexp }, >-@@ -1204,6 +1207,10 @@ mutt_pattern_exec (struct pattern_t *pat >- } >- case M_UNREFERENCED: >- return (pat->not ^ (h->thread && !h->thread->child)); >-+#ifdef USE_NNTP >-+ case M_NEWSGROUPS: >-+ return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0)); >-+#endif >- } >- mutt_error (_("error: unknown op %d (report this error)."), pat->op); >- return (-1); >-@@ -1285,6 +1292,7 @@ int mutt_pattern_func (int op, char *pro >- progress_t progress; >- >- strfcpy (buf, NONULL (Context->pattern), sizeof (buf)); >-+ if (prompt || op != M_LIMIT) >- if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0]) >- return (-1); >- >-diff -udprP mutt-1.5.20.orig/po/POTFILES.in mutt-1.5.20/po/POTFILES.in >---- mutt-1.5.20.orig/po/POTFILES.in 2008-11-11 21:55:47.000000000 +0200 >-+++ mutt-1.5.20/po/POTFILES.in 2009-06-15 21:05:24.000000000 +0300 >-@@ -46,6 +46,8 @@ mutt_ssl_gnutls.c >- mutt_tunnel.c >- muttlib.c >- mx.c >-+newsrc.c >-+nntp.c >- pager.c >- parse.c >- pattern.c >-diff -udprP mutt-1.5.20.orig/postpone.c mutt-1.5.20/postpone.c >---- mutt-1.5.20.orig/postpone.c 2009-06-14 00:28:37.000000000 +0300 >-+++ mutt-1.5.20/postpone.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -124,15 +124,26 @@ int mutt_num_postponed (int force) >- >- if (LastModify < st.st_mtime) >- { >-+#ifdef USE_NNTP >-+ int optnews = option (OPTNEWS); >-+#endif >- LastModify = st.st_mtime; >- >- if (access (Postponed, R_OK | F_OK) != 0) >- return (PostCount = 0); >-+#ifdef USE_NNTP >-+ if (optnews) >-+ unset_option (OPTNEWS); >-+#endif >- if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL) >- PostCount = 0; >- else >- PostCount = ctx.msgcount; >- mx_fastclose_mailbox (&ctx); >-+#ifdef USE_NNTP >-+ if (optnews) >-+ set_option (OPTNEWS); >-+#endif >- } >- >- return (PostCount); >-diff -udprP mutt-1.5.20.orig/protos.h mutt-1.5.20/protos.h >---- mutt-1.5.20.orig/protos.h 2009-06-13 02:38:52.000000000 +0300 >-+++ mutt-1.5.20/protos.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -115,6 +115,7 @@ HASH *mutt_make_id_hash (CONTEXT *); >- HASH *mutt_make_subj_hash (CONTEXT *); >- >- LIST *mutt_make_references(ENVELOPE *e); >-+LIST *mutt_parse_references (char *, int); >- >- char *mutt_read_rfc822_line (FILE *, char *, size_t *); >- ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short); >-diff -udprP mutt-1.5.20.orig/recvattach.c mutt-1.5.20/recvattach.c >---- mutt-1.5.20.orig/recvattach.c 2009-05-19 03:11:35.000000000 +0300 >-+++ mutt-1.5.20/recvattach.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -1110,6 +1110,15 @@ void mutt_view_attachments (HEADER *hdr) >- } >- #endif >- >-+#ifdef USE_NNTP >-+ if (Context->magic == M_NNTP) >-+ { >-+ mutt_flushinp (); >-+ mutt_error _("Can't delete attachment from newsserver."); >-+ break; >-+ } >-+#endif >-+ >- if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED) >- { >- mutt_message _( >-@@ -1201,10 +1210,33 @@ void mutt_view_attachments (HEADER *hdr) >- case OP_FORWARD_MESSAGE: >- CHECK_ATTACH; >- mutt_attach_forward (fp, hdr, idx, idxlen, >-- menu->tagprefix ? NULL : idx[menu->current]->content); >-+ menu->tagprefix ? NULL : idx[menu->current]->content, 0); >- menu->redraw = REDRAW_FULL; >- break; >- >-+#ifdef USE_NNTP >-+ case OP_FORWARD_TO_GROUP: >-+ CHECK_ATTACH; >-+ mutt_attach_forward (fp, hdr, idx, idxlen, >-+ menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS); >-+ menu->redraw = REDRAW_FULL; >-+ break; >-+ >-+ case OP_FOLLOWUP: >-+ CHECK_ATTACH; >-+ >-+ if (!idx[menu->current]->content->hdr->env->followup_to || >-+ mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") || >-+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES) >-+ { >-+ mutt_attach_reply (fp, hdr, idx, idxlen, >-+ menu->tagprefix ? NULL : idx[menu->current]->content, >-+ SENDNEWS|SENDREPLY); >-+ menu->redraw = REDRAW_FULL; >-+ break; >-+ } >-+#endif >-+ >- case OP_REPLY: >- case OP_GROUP_REPLY: >- case OP_LIST_REPLY: >-diff -udprP mutt-1.5.20.orig/recvcmd.c mutt-1.5.20/recvcmd.c >---- mutt-1.5.20.orig/recvcmd.c 2009-06-12 20:24:17.000000000 +0300 >-+++ mutt-1.5.20/recvcmd.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -401,7 +401,7 @@ static BODY ** copy_problematic_attachme >- static void attach_forward_bodies (FILE * fp, HEADER * hdr, >- ATTACHPTR ** idx, short idxlen, >- BODY * cur, >-- short nattach) >-+ short nattach, int flags) >- { >- short i; >- short mime_fwd_all = 0; >-@@ -547,7 +547,7 @@ _("Can't decode all tagged attachments. >- tmpfp = NULL; >- >- /* now that we have the template, send it. */ >-- ci_send_message (0, tmphdr, tmpbody, NULL, parent); >-+ ci_send_message (flags, tmphdr, tmpbody, NULL, parent); >- return; >- >- bail: >-@@ -574,7 +574,7 @@ _("Can't decode all tagged attachments. >- */ >- >- static void attach_forward_msgs (FILE * fp, HEADER * hdr, >-- ATTACHPTR ** idx, short idxlen, BODY * cur) >-+ ATTACHPTR ** idx, short idxlen, BODY * cur, int flags) >- { >- HEADER *curhdr = NULL; >- HEADER *tmphdr; >-@@ -679,23 +679,23 @@ static void attach_forward_msgs (FILE * >- else >- mutt_free_header (&tmphdr); >- >-- ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL, >-+ ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL, >- NULL, curhdr); >- >- } >- >- void mutt_attach_forward (FILE * fp, HEADER * hdr, >-- ATTACHPTR ** idx, short idxlen, BODY * cur) >-+ ATTACHPTR ** idx, short idxlen, BODY * cur, int flags) >- { >- short nattach; >- >- >- if (check_all_msg (idx, idxlen, cur, 0) == 0) >-- attach_forward_msgs (fp, hdr, idx, idxlen, cur); >-+ attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags); >- else >- { >- nattach = count_tagged (idx, idxlen); >-- attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach); >-+ attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags); >- } >- } >- >-@@ -753,28 +753,40 @@ attach_reply_envelope_defaults (ENVELOPE >- return -1; >- } >- >-- if (parent) >-+#ifdef USE_NNTP >-+ if ((flags & SENDNEWS)) >- { >-- if (mutt_fetch_recips (env, curenv, flags) == -1) >-- return -1; >-+ /* in case followup set Newsgroups: with Followup-To: if it present */ >-+ if (!env->newsgroups && curenv && >-+ mutt_strcasecmp (curenv->followup_to, "poster")) >-+ env->newsgroups = safe_strdup (curenv->followup_to); >- } >- else >-+#endif >- { >-- for (i = 0; i < idxlen; i++) >-+ if (parent) >- { >-- if (idx[i]->content->tagged >-- && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1) >-+ if (mutt_fetch_recips (env, curenv, flags) == -1) >- return -1; >- } >-+ else >-+ { >-+ for (i = 0; i < idxlen; i++) >-+ { >-+ if (idx[i]->content->tagged >-+ && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1) >-+ return -1; >-+ } >-+ } >-+ >-+ if ((flags & SENDLISTREPLY) && !env->to) >-+ { >-+ mutt_error _("No mailing lists found!"); >-+ return (-1); >-+ } >-+ >-+ mutt_fix_reply_recipients (env); >- } >-- >-- if ((flags & SENDLISTREPLY) && !env->to) >-- { >-- mutt_error _("No mailing lists found!"); >-- return (-1); >-- } >-- >-- mutt_fix_reply_recipients (env); >- mutt_make_misc_reply_headers (env, Context, curhdr, curenv); >- >- if (parent) >-@@ -835,6 +847,13 @@ void mutt_attach_reply (FILE * fp, HEADE >- char prefix[SHORT_STRING]; >- int rc; >- >-+#ifdef USE_NNTP >-+ if (flags & SENDNEWS) >-+ set_option (OPTNEWSSEND); >-+ else >-+ unset_option (OPTNEWSSEND); >-+#endif >-+ >- if (check_all_msg (idx, idxlen, cur, 0) == -1) >- { >- nattach = count_tagged (idx, idxlen); >-diff -udprP mutt-1.5.20.orig/rfc1524.c mutt-1.5.20/rfc1524.c >---- mutt-1.5.20.orig/rfc1524.c 2009-05-30 20:20:08.000000000 +0300 >-+++ mutt-1.5.20/rfc1524.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -569,13 +569,13 @@ int rfc1524_expand_filename (char *namet >- * safe_fopen(). >- */ >- >--int mutt_rename_file (char *oldfile, char *newfile) >-+int _mutt_rename_file (char *oldfile, char *newfile, int overwrite) >- { >- FILE *ofp, *nfp; >- >- if (access (oldfile, F_OK) != 0) >- return 1; >-- if (access (newfile, F_OK) == 0) >-+ if (!overwrite && access (newfile, F_OK) == 0) >- return 2; >- if ((ofp = fopen (oldfile,"r")) == NULL) >- return 3; >-@@ -590,3 +590,8 @@ int mutt_rename_file (char *oldfile, cha >- mutt_unlink (oldfile); >- return 0; >- } >-+ >-+int mutt_rename_file (char *oldfile, char *newfile) >-+{ >-+ return _mutt_rename_file (oldfile, newfile, 0); >-+} >-diff -udprP mutt-1.5.20.orig/rfc1524.h mutt-1.5.20/rfc1524.h >---- mutt-1.5.20.orig/rfc1524.h 2008-11-11 21:55:47.000000000 +0200 >-+++ mutt-1.5.20/rfc1524.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char >- int rfc1524_expand_filename (char *, char *, char *, size_t); >- int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int); >- int mutt_rename_file (char *, char *); >-+int _mutt_rename_file (char *, char *, int); >- >- #endif /* _RFC1524_H */ >-diff -udprP mutt-1.5.20.orig/send.c mutt-1.5.20/send.c >---- mutt-1.5.20.orig/send.c 2009-06-13 02:38:52.000000000 +0300 >-+++ mutt-1.5.20/send.c 2009-06-15 21:13:13.000000000 +0300 >-@@ -44,6 +44,11 @@ >- #include <sys/types.h> >- #include <utime.h> >- >-+#ifdef USE_NNTP >-+#include "nntp.h" >-+#include "mx.h" >-+#endif >-+ >- #ifdef MIXMASTER >- #include "remailer.h" >- #endif >-@@ -213,17 +218,51 @@ static int edit_address (ADDRESS **a, /* >- return 0; >- } >- >--static int edit_envelope (ENVELOPE *en) >-+static int edit_envelope (ENVELOPE *en, int flags) >- { >- char buf[HUGE_STRING]; >- LIST *uh = UserHeader; >- >-- if (edit_address (&en->to, "To: ") == -1 || en->to == NULL) >-- return (-1); >-- if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1) >-- return (-1); >-- if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1) >-- return (-1); >-+#ifdef USE_NNTP >-+ if (option (OPTNEWSSEND)) >-+ { >-+ if (en->newsgroups) >-+ strfcpy (buf, en->newsgroups, sizeof (buf)); >-+ else >-+ buf[0] = 0; >-+ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0) >-+ return (-1); >-+ FREE (&en->newsgroups); >-+ en->newsgroups = safe_strdup (buf); >-+ >-+ if (en->followup_to) >-+ strfcpy (buf, en->followup_to, sizeof (buf)); >-+ else >-+ buf[0] = 0; >-+ if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0) >-+ return (-1); >-+ FREE (&en->followup_to); >-+ en->followup_to = safe_strdup (buf); >-+ >-+ if (en->x_comment_to) >-+ strfcpy (buf, en->x_comment_to, sizeof (buf)); >-+ else >-+ buf[0] = 0; >-+ if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0) >-+ return (-1); >-+ FREE (&en->x_comment_to); >-+ en->x_comment_to = safe_strdup (buf); >-+ } >-+ else >-+#endif >-+ { >-+ if (edit_address (&en->to, "To: ") == -1 || en->to == NULL) >-+ return (-1); >-+ if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1) >-+ return (-1); >-+ if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1) >-+ return (-1); >-+ } >- >- if (en->subject) >- { >-@@ -259,6 +298,14 @@ static int edit_envelope (ENVELOPE *en) >- return 0; >- } >- >-+#ifdef USE_NNTP >-+char *nntp_get_header (const char *s) >-+{ >-+ SKIPWS (s); >-+ return safe_strdup (s); >-+} >-+#endif >-+ >- static void process_user_recips (ENVELOPE *env) >- { >- LIST *uh = UserHeader; >-@@ -271,6 +318,14 @@ static void process_user_recips (ENVELOP >- env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3); >- else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0) >- env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4); >-+#ifdef USE_NNTP >-+ else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0) >-+ env->newsgroups = nntp_get_header (uh->data + 11); >-+ else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0) >-+ env->followup_to = nntp_get_header (uh->data + 12); >-+ else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0) >-+ env->x_comment_to = nntp_get_header (uh->data + 13); >-+#endif >- } >- } >- >-@@ -309,6 +364,12 @@ static void process_user_header (ENVELOP >- else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 && >- ascii_strncasecmp ("cc:", uh->data, 3) != 0 && >- ascii_strncasecmp ("bcc:", uh->data, 4) != 0 && >-+#ifdef USE_NNTP >-+ ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 && >-+ ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 && >-+ ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 && >-+#endif >-+ ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 && >- ascii_strncasecmp ("subject:", uh->data, 8) != 0 && >- ascii_strncasecmp ("return-path:", uh->data, 12) != 0) >- { >-@@ -657,6 +718,10 @@ void mutt_add_to_reference_headers (ENVE >- if (pp) *pp = p; >- if (qq) *qq = q; >- >-+#ifdef USE_NNTP >-+ if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from) >-+ env->x_comment_to = safe_strdup (mutt_get_name (curenv->from)); >-+#endif >- } >- >- static void >-@@ -719,6 +784,16 @@ envelope_defaults (ENVELOPE *env, CONTEX >- >- if (flags & SENDREPLY) >- { >-+#ifdef USE_NNTP >-+ if ((flags & SENDNEWS)) >-+ { >-+ /* in case followup set Newsgroups: with Followup-To: if it present */ >-+ if (!env->newsgroups && curenv && >-+ mutt_strcasecmp (curenv->followup_to, "poster")) >-+ env->newsgroups = safe_strdup (curenv->followup_to); >-+ } >-+ else >-+#endif >- if (tag) >- { >- HEADER *h; >-@@ -865,7 +940,18 @@ void mutt_set_followup_to (ENVELOPE *e) >- * it hasn't already been set >- */ >- >-- if (option (OPTFOLLOWUPTO) && !e->mail_followup_to) >-+ if (!option (OPTFOLLOWUPTO)) >-+ return; >-+#ifdef USE_NNTP >-+ if (option (OPTNEWSSEND)) >-+ { >-+ if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ','))) >-+ e->followup_to = safe_strdup (e->newsgroups); >-+ return; >-+ } >-+#endif >-+ >-+ if (!e->mail_followup_to) >- { >- if (mutt_is_list_cc (0, e->to, e->cc)) >- { >-@@ -1026,6 +1112,9 @@ static int send_message (HEADER *msg) >- #endif >- >- #if USE_SMTP >-+#ifdef USE_NNTP >-+ if (!option (OPTNEWSSEND)) >-+#endif /* USE_NNTP */ >- if (SmtpUrl) >- return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc, >- msg->env->bcc, tempfile, >-@@ -1137,6 +1226,13 @@ ci_send_message (int flags, /* send mod >- >- int rv = -1; >- >-+#ifdef USE_NNTP >-+ if (flags & SENDNEWS) >-+ set_option (OPTNEWSSEND); >-+ else >-+ unset_option (OPTNEWSSEND); >-+#endif >-+ >- if (!flags && !msg && quadoption (OPT_RECALL) != M_NO && >- mutt_num_postponed (1)) >- { >-@@ -1167,6 +1263,22 @@ ci_send_message (int flags, /* send mod >- { >- if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0) >- goto cleanup; >-+#ifdef USE_NNTP >-+ /* >-+ * If postponed message is a news article, it have >-+ * a "Newsgroups:" header line, then set appropriate flag. >-+ */ >-+ if (msg->env->newsgroups) >-+ { >-+ flags |= SENDNEWS; >-+ set_option (OPTNEWSSEND); >-+ } >-+ else >-+ { >-+ flags &= ~SENDNEWS; >-+ unset_option (OPTNEWSSEND); >-+ } >-+#endif >- } >- >- if (flags & (SENDPOSTPONED|SENDRESEND)) >-@@ -1278,11 +1390,16 @@ ci_send_message (int flags, /* send mod >- if (flags & SENDREPLY) >- mutt_fix_reply_recipients (msg->env); >- >-+#ifdef USE_NNTP >-+ if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups) >-+ msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group); >-+#endif >-+ >- if (! (flags & (SENDMAILX|SENDBATCH)) && >- ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) && >- ! ((flags & SENDREPLY) && option (OPTFASTREPLY))) >- { >-- if (edit_envelope (msg->env) == -1) >-+ if (edit_envelope (msg->env, flags) == -1) >- goto cleanup; >- } >- >-@@ -1539,6 +1656,11 @@ main_loop: >- if (i == -1) >- { >- /* abort */ >-+#ifdef USE_NNTP >-+ if (flags & SENDNEWS) >-+ mutt_message _("Article not posted."); >-+ else >-+#endif >- mutt_message _("Mail not sent."); >- goto cleanup; >- } >-@@ -1571,6 +1693,9 @@ main_loop: >- } >- } >- >-+#ifdef USE_NNTP >-+ if (!(flags & SENDNEWS)) >-+#endif >- if (!has_recips (msg->env->to) && !has_recips (msg->env->cc) && >- !has_recips (msg->env->bcc)) >- { >-@@ -1604,6 +1729,19 @@ main_loop: >- mutt_error _("No subject specified."); >- goto main_loop; >- } >-+#ifdef USE_NNTP >-+ if ((flags & SENDNEWS) && !msg->env->subject) >-+ { >-+ mutt_error _("No subject specified."); >-+ goto main_loop; >-+ } >-+ >-+ if ((flags & SENDNEWS) && !msg->env->newsgroups) >-+ { >-+ mutt_error _("No newsgroup specified."); >-+ goto main_loop; >-+ } >-+#endif >- >- if (msg->content->next) >- msg->content = mutt_make_multipart (msg->content); >-@@ -1810,7 +1948,12 @@ full_fcc: >- } >- } >- else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX)) >-- mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background.")); >-+ mutt_message (i != 0 ? _("Sending in background.") : >-+#ifdef USE_NNTP >-+ (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent.")); >-+#else >-+ _("Mail sent.")); >-+#endif >- >- if (WithCrypto && (msg->security & ENCRYPT)) >- FREE (&pgpkeylist); >-diff -udprP mutt-1.5.20.orig/sendlib.c mutt-1.5.20/sendlib.c >---- mutt-1.5.20.orig/sendlib.c 2009-06-14 18:46:11.000000000 +0300 >-+++ mutt-1.5.20/sendlib.c 2009-06-15 21:51:17.000000000 +0300 >-@@ -46,6 +46,10 @@ >- #include <sys/wait.h> >- #include <fcntl.h> >- >-+#ifdef USE_NNTP >-+#include "nntp.h" >-+#endif >-+ >- #ifdef HAVE_SYSEXITS_H >- #include <sysexits.h> >- #else /* Make sure EX_OK is defined <philiph@pobox.com> */ >-@@ -1868,6 +1872,9 @@ int mutt_write_rfc822_header (FILE *fp, >- mutt_write_address_list (env->to, fp, 4, 0); >- } >- else if (mode > 0) >-+#ifdef USE_NNTP >-+ if (!option (OPTNEWSSEND)) >-+#endif >- fputs ("To: \n", fp); >- >- if (env->cc) >-@@ -1876,6 +1883,9 @@ int mutt_write_rfc822_header (FILE *fp, >- mutt_write_address_list (env->cc, fp, 4, 0); >- } >- else if (mode > 0) >-+#ifdef USE_NNTP >-+ if (!option (OPTNEWSSEND)) >-+#endif >- fputs ("Cc: \n", fp); >- >- if (env->bcc) >-@@ -1887,8 +1897,28 @@ int mutt_write_rfc822_header (FILE *fp, >- } >- } >- else if (mode > 0) >-+#ifdef USE_NNTP >-+ if (!option (OPTNEWSSEND)) >-+#endif >- fputs ("Bcc: \n", fp); >- >-+#ifdef USE_NNTP >-+ if (env->newsgroups) >-+ fprintf (fp, "Newsgroups: %s\n", env->newsgroups); >-+ else if (mode == 1 && option (OPTNEWSSEND)) >-+ fputs ("Newsgroups: \n", fp); >-+ >-+ if (env->followup_to) >-+ fprintf (fp, "Followup-To: %s\n", env->followup_to); >-+ else if (mode == 1 && option (OPTNEWSSEND)) >-+ fputs ("Followup-To: \n", fp); >-+ >-+ if (env->x_comment_to) >-+ fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to); >-+ else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO)) >-+ fputs ("X-Comment-To: \n", fp); >-+#endif >-+ >- if (env->subject) >- mutt_write_one_header (fp, "Subject", env->subject, NULL, 0, 0); >- else if (mode == 1) >-@@ -1907,6 +1937,9 @@ int mutt_write_rfc822_header (FILE *fp, >- fputs ("Reply-To: \n", fp); >- >- if (env->mail_followup_to) >-+#ifdef USE_NNTP >-+ if (!option (OPTNEWSSEND)) >-+#endif >- { >- fputs ("Mail-Followup-To: ", fp); >- mutt_write_address_list (env->mail_followup_to, fp, 18, 0); >-@@ -2245,11 +2278,30 @@ mutt_invoke_sendmail (ADDRESS *from, /* >- const char *msg, /* file containing message */ >- int eightbit) /* message contains 8bit chars */ >- { >-- char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL; >-+ char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL; >- char **args = NULL; >- size_t argslen = 0, argsmax = 0; >- int i; >- >-+#ifdef USE_NNTP >-+ if (option (OPTNEWSSEND)) >-+ { >-+ char cmd[LONG_STRING]; >-+ >-+ mutt_FormatString (cmd, sizeof (cmd), 0, NONULL (Inews), nntp_format_str, 0, 0); >-+ if (!*cmd) >-+ { >-+ i = nntp_post (msg); >-+ unlink (msg); >-+ return i; >-+ } >-+ >-+ s = safe_strdup (cmd); >-+ } >-+ else >-+#endif >-+ s = safe_strdup (Sendmail); >-+ >- ps = s; >- i = 0; >- while ((ps = strtok (ps, " "))) >-@@ -2273,6 +2325,10 @@ mutt_invoke_sendmail (ADDRESS *from, /* >- i++; >- } >- >-+#ifdef USE_NNTP >-+ if (!option (OPTNEWSSEND)) >-+ { >-+#endif >- if (eightbit && option (OPTUSE8BITMIME)) >- args = add_option (args, &argslen, &argsmax, "-B8BITMIME"); >- >-@@ -2304,6 +2360,9 @@ mutt_invoke_sendmail (ADDRESS *from, /* >- args = add_args (args, &argslen, &argsmax, to); >- args = add_args (args, &argslen, &argsmax, cc); >- args = add_args (args, &argslen, &argsmax, bcc); >-+#ifdef USE_NNTP >-+ } >-+#endif >- >- if (argslen == argsmax) >- safe_realloc (&args, sizeof (char *) * (++argsmax)); >-@@ -2384,6 +2443,9 @@ void mutt_prepare_envelope (ENVELOPE *en >- rfc2047_encode_string (&env->x_label); >- >- if (env->subject) >-+#ifdef USE_NNTP >-+ if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT)) >-+#endif >- { >- rfc2047_encode_string (&env->subject); >- } >-@@ -2504,6 +2566,10 @@ int mutt_bounce_message (FILE *fp, HEADE >- } >- rfc822_write_address (resent_from, sizeof (resent_from), from, 0); >- >-+#ifdef USE_NNTP >-+ unset_option (OPTNEWSSEND); >-+#endif >-+ >- ret = _mutt_bounce_message (fp, h, to, resent_from, from); >- >- rfc822_free_address (&from); >-diff -udprP mutt-1.5.20.orig/sort.c mutt-1.5.20/sort.c >---- mutt-1.5.20.orig/sort.c 2008-11-11 21:55:47.000000000 +0200 >-+++ mutt-1.5.20/sort.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -151,6 +151,15 @@ static int compare_order (const void *a, >- HEADER **ha = (HEADER **) a; >- HEADER **hb = (HEADER **) b; >- >-+#ifdef USE_NNTP >-+ if ((*ha)->article_num && (*hb)->article_num) >-+ { >-+ int result = (*ha)->article_num - (*hb)->article_num; >-+ AUXSORT(result,a,b); >-+ return (SORTCODE (result)); >-+ } >-+ else >-+#endif >- /* no need to auxsort because you will never have equality here */ >- return (SORTCODE ((*ha)->index - (*hb)->index)); >- } >-diff -udprP mutt-1.5.20.orig/url.c mutt-1.5.20/url.c >---- mutt-1.5.20.orig/url.c 2009-06-01 19:29:32.000000000 +0300 >-+++ mutt-1.5.20/url.c 2009-06-15 21:05:24.000000000 +0300 >-@@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] = >- { "imaps", U_IMAPS }, >- { "pop", U_POP }, >- { "pops", U_POPS }, >-+ { "news", U_NNTP }, >-+ { "newss", U_NNTPS }, >- { "mailto", U_MAILTO }, >- { "smtp", U_SMTP }, >- { "smtps", U_SMTPS }, >-diff -udprP mutt-1.5.20.orig/url.h mutt-1.5.20/url.h >---- mutt-1.5.20.orig/url.h 2008-11-11 21:55:47.000000000 +0200 >-+++ mutt-1.5.20/url.h 2009-06-15 21:05:24.000000000 +0300 >-@@ -8,6 +8,8 @@ typedef enum url_scheme >- U_POPS, >- U_IMAP, >- U_IMAPS, >-+ U_NNTP, >-+ U_NNTPS, >- U_SMTP, >- U_SMTPS, >- U_MAILTO, >-diff -udprP mutt-1.5.20.orig/Makefile.am mutt-1.5.20/Makefile.am >---- mutt-1.5.20.orig/Makefile.am 2009-01-05 04:11:29.000000000 +0200 >-+++ mutt-1.5.20/Makefile.am 2009-06-15 21:05:24.000000000 +0300 >-@@ -53,6 +53,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c >- mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \ >- mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \ >- pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \ >-+ nntp.c newsrc.c \ >- smime.c smtp.c utf8.c wcwidth.c \ >- bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h >- >-@@ -64,6 +65,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O >- mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \ >- mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \ >- rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \ >-+ nntp.h ChangeLog.nntp \ >- _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \ >- mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \ >- README.SSL smime.h \ >-diff -udprP mutt-1.5.20.orig/Makefile.in mutt-1.5.20/Makefile.in >---- mutt-1.5.20.orig/Makefile.in 2009-06-09 09:50:44.000000000 +0300 >-+++ mutt-1.5.20/Makefile.in 2009-06-15 21:05:24.000000000 +0300 >-@@ -372,6 +372,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c >- mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \ >- mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \ >- pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \ >-+ nntp.c newsrc.c \ >- smime.c smtp.c utf8.c wcwidth.c \ >- bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h >- >-@@ -383,6 +384,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O >- mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \ >- mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \ >- rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \ >-+ nntp.h ChangeLog.nntp \ >- _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \ >- mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \ >- README.SSL smime.h \ >-@@ -637,6 +639,8 @@ distclean-compile: >- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@ >- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@ >- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@ >-+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@ >-+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@ >- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@ >- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@ >- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@ >-diff -udprP mutt-1.5.20.orig/configure mutt-1.5.20/configure >---- mutt-1.5.20.orig/configure 2009-06-09 09:50:42.000000000 +0300 >-+++ mutt-1.5.20/configure 2009-06-15 21:05:24.000000000 +0300 >-@@ -1478,6 +1478,7 @@ Optional Features: >- Force use of an external dotlock program >- --enable-pop Enable POP3 support >- --enable-imap Enable IMAP support >-+ --enable-nntp Enable NNTP support >- --enable-smtp include internal SMTP relay support >- --enable-debug Enable debugging support >- --enable-flock Use flock() to lock files >-@@ -8523,6 +8524,20 @@ fi >- >- fi >- done >-+# Check whether --enable-nntp or --disable-nntp was given. >-+if test "${enable_nntp+set}" = set; then >-+ enableval="$enable_nntp" >-+ if test x$enableval = xyes ; then >-+ cat >>confdefs.h <<\_ACEOF >-+#define USE_NNTP 1 >-+_ACEOF >-+ >-+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o" >-+ need_socket="yes" >-+ fi >-+ >-+fi; >-+ >- >- >- for ac_func in strftime >-diff -udprP mutt-1.5.20.orig/doc/Muttrc mutt-1.5.20/doc/Muttrc >---- mutt-1.5.20.orig/doc/Muttrc 2009-06-14 21:53:24.000000000 +0300 >-+++ mutt-1.5.20/doc/Muttrc 2009-06-15 21:05:24.000000000 +0300 >-@@ -281,6 +281,28 @@ attachments -I message/external-body >- # of the value as shown above if included. >- # >- # >-+# set ask_follow_up=no >-+# >-+# Name: ask_follow_up >-+# Type: boolean >-+# Default: no >-+# >-+# >-+# If set, Mutt will prompt you for follow-up groups before editing >-+# the body of an outgoing message. >-+# >-+# >-+# set ask_x_comment_to=no >-+# >-+# Name: ask_x_comment_to >-+# Type: boolean >-+# Default: no >-+# >-+# >-+# If set, Mutt will prompt you for x-comment-to field before editing >-+# the body of an outgoing message. >-+# >-+# >- # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] " >- # >- # Name: attach_format >-@@ -466,6 +488,17 @@ attachments -I message/external-body >- # set certificate_file=~/.mutt/certificates >- # >- # >-+# set catchup_newsgroup=ask-yes >-+# >-+# Name: catchup_newsgroup >-+# Type: quadoption >-+# Default: ask-yes >-+# >-+# >-+# If this variable is set, Mutt will mark all articles in newsgroup >-+# as read when you quit the newsgroup (catchup newsgroup). >-+# >-+# >- # set charset="" >- # >- # Name: charset >-@@ -1121,6 +1154,19 @@ attachments -I message/external-body >- # of the same email for you. >- # >- # >-+# set followup_to_poster=ask-yes >-+# >-+# Name: followup_to_poster >-+# Type: quadoption >-+# Default: ask-yes >-+# >-+# >-+# If this variable is set and the keyword "poster" is present in >-+# Followup-To header, follow-up to newsgroup function is not >-+# permitted. The message will be mailed to the submitter of the >-+# message via mail. >-+# >-+# >- # set force_name=no >- # >- # Name: force_name >-@@ -1231,6 +1277,28 @@ attachments -I message/external-body >- # ``Franklin'' to ``Franklin, Steve''. >- # >- # >-+# set group_index_format="%4C %M%N %5s %-45.45f %d" >-+# >-+# Name: group_index_format >-+# Type: string >-+# Default: "%4C %M%N %5s %-45.45f %d" >-+# >-+# >-+# This variable allows you to customize the newsgroup browser display to >-+# your personal taste. This string is similar to ``index_format'', but >-+# has its own set of printf()-like sequences: >-+# >-+# %C current newsgroup number >-+# %d description of newsgroup (becomes from server) >-+# %f newsgroup name >-+# %M - if newsgroup not allowed for direct post (moderated for example) >-+# %N N if newsgroup is new, u if unsubscribed, blank otherwise >-+# %n number of new articles in newsgroup >-+# %s number of unread articles in newsgroup >-+# %>X right justify the rest of the string and pad with character "X" >-+# %|X pad to the end of the line with character "X" >-+# >-+# >- # set hdrs=yes >- # >- # Name: hdrs >-@@ -1779,6 +1847,7 @@ attachments -I message/external-body >- # %E number of messages in current thread >- # %f sender (address + real name), either From: or Return-Path: >- # %F author name, or recipient name if the message is from you >-+# %g newsgroup name (if compiled with nntp support) >- # %H spam attribute(s) of this message >- # %i message-id of the current message >- # %l number of lines in the message (does not work with maildir, >-@@ -1794,12 +1863,14 @@ attachments -I message/external-body >- # stashed the message: list name or recipient name >- # if not sent to a list >- # %P progress indicator for the built-in pager (how much of the file has been displayed) >-+# %R `x-comment-to:' field (if present and compiled with nntp support) >- # %s subject of the message >- # %S status of the message (``N''/``D''/``d''/``!''/``r''/*) >- # %t ``To:'' field (recipients) >- # %T the appropriate character from the $to_chars string >- # %u user (login) name of the author >- # %v first name of the author, or the recipient if the message is from you >-+# %W name of organization of author (`organization:' field) >- # %X number of attachments >- # (please see the ``attachments'' section for possible speed effects) >- # %y ``X-Label:'' field, if present >-@@ -1835,6 +1906,22 @@ attachments -I message/external-body >- # ``save-hook'', ``fcc-hook'' and ``fcc-save-hook'', too. >- # >- # >-+# set inews="" >-+# >-+# Name: inews >-+# Type: path >-+# Default: "" >-+# >-+# >-+# If set, specifies the program and arguments used to deliver news posted >-+# by Mutt. Otherwise, mutt posts article using current connection to >-+# news server. The following printf-style sequence is understood: >-+# >-+# %s newsserver name >-+# >-+# Example: set inews="/usr/local/bin/inews -hS" >-+# >-+# >- # set ispell="ispell" >- # >- # Name: ispell >-@@ -2188,6 +2275,18 @@ attachments -I message/external-body >- # be attached to the newly composed message if this option is set. >- # >- # >-+# set mime_subject=yes >-+# >-+# Name: mime_subject >-+# Type: boolean >-+# Default: yes >-+# >-+# >-+# If unset, 8-bit ``subject:'' line in article header will not be >-+# encoded according to RFC2047 to base64. This is useful when message >-+# is Usenet article, because MIME for news is nonstandard feature. >-+# >-+# >- # set mix_entry_format="%4n %c %-16s %a" >- # >- # Name: mix_entry_format >-@@ -2254,6 +2353,118 @@ attachments -I message/external-body >- # See also $read_inc, $write_inc and $net_inc. >- # >- # >-+# set news_cache_dir="~/.mutt" >-+# >-+# Name: news_cache_dir >-+# Type: path >-+# Default: "~/.mutt" >-+# >-+# >-+# This variable pointing to directory where Mutt will save cached news >-+# articles headers in. If unset, headers will not be saved at all >-+# and will be reloaded each time when you enter to newsgroup. >-+# >-+# >-+# set news_server="" >-+# >-+# Name: news_server >-+# Type: string >-+# Default: "" >-+# >-+# >-+# This variable specifies domain name or address of NNTP server. It >-+# defaults to the newsserver specified in the environment variable >-+# $NNTPSERVER or contained in the file /etc/nntpserver. You can also >-+# specify username and an alternative port for each newsserver, ie: >-+# >-+# [news[s]://][username[:password]@]newsserver[:port] >-+# >-+# >-+# set newsrc="~/.newsrc" >-+# >-+# Name: newsrc >-+# Type: path >-+# Default: "~/.newsrc" >-+# >-+# >-+# The file, containing info about subscribed newsgroups - names and >-+# indexes of read articles. The following printf-style sequence >-+# is understood: >-+# >-+# %s newsserver name >-+# >-+# >-+# set nntp_context=1000 >-+# >-+# Name: nntp_context >-+# Type: number >-+# Default: 1000 >-+# >-+# >-+# This variable defines number of articles which will be in index when >-+# newsgroup entered. If active newsgroup have more articles than this >-+# number, oldest articles will be ignored. Also controls how many >-+# articles headers will be saved in cache when you quit newsgroup. >-+# >-+# >-+# set nntp_load_description=yes >-+# >-+# Name: nntp_load_description >-+# Type: boolean >-+# Default: yes >-+# >-+# >-+# This variable controls whether or not descriptions for each newsgroup >-+# must be loaded when newsgroup is added to list (first time list >-+# loading or new newsgroup adding). >-+# >-+# >-+# set nntp_user="" >-+# >-+# Name: nntp_user >-+# Type: string >-+# Default: "" >-+# >-+# >-+# Your login name on the NNTP server. If unset and NNTP server requires >-+# authentification, Mutt will prompt you for your account name when you >-+# connect to newsserver. >-+# >-+# >-+# set nntp_pass="" >-+# >-+# Name: nntp_pass >-+# Type: string >-+# Default: "" >-+# >-+# >-+# Your password for NNTP account. >-+# >-+# >-+# set nntp_poll=60 >-+# >-+# Name: nntp_poll >-+# Type: number >-+# Default: 60 >-+# >-+# >-+# The time in seconds until any operations on newsgroup except post new >-+# article will cause recheck for new news. If set to 0, Mutt will >-+# recheck newsgroup on each operation in index (stepping, read article, >-+# etc.). >-+# >-+# >-+# set nntp_reconnect=ask-yes >-+# >-+# Name: nntp_reconnect >-+# Type: quadoption >-+# Default: ask-yes >-+# >-+# >-+# Controls whether or not Mutt will try to reconnect to newsserver when >-+# connection lost. >-+# >-+# >- # set pager="builtin" >- # >- # Name: pager >-@@ -2969,6 +3180,19 @@ attachments -I message/external-body >- # string after the inclusion of a message which is being replied to. >- # >- # >-+# set post_moderated=ask-yes >-+# >-+# Name: post_moderated >-+# Type: quadoption >-+# Default: ask-yes >-+# >-+# >-+# If set to yes, Mutt will post article to newsgroup that have >-+# not permissions to posting (e.g. moderated). Note: if newsserver >-+# does not support posting to that newsgroup or totally read-only, that >-+# posting will not have an effect. >-+# >-+# >- # set postpone=ask-yes >- # >- # Name: postpone >-@@ -3543,6 +3767,41 @@ attachments -I message/external-body >- # shell from /etc/passwd is used. >- # >- # >-+# set save_unsubscribed=no >-+# >-+# Name: save_unsubscribed >-+# Type: boolean >-+# Default: no >-+# >-+# >-+# When set, info about unsubscribed newsgroups will be saved into >-+# ``newsrc'' file and into cache. >-+# >-+# >-+# set show_new_news=yes >-+# >-+# Name: show_new_news >-+# Type: boolean >-+# Default: yes >-+# >-+# >-+# If set, newsserver will be asked for new newsgroups on entering >-+# the browser. Otherwise, it will be done only once for a newsserver. >-+# Also controls whether or not number of new articles of subscribed >-+# newsgroups will be then checked. >-+# >-+# >-+# set show_only_unread=no >-+# >-+# Name: show_only_unread >-+# Type: boolean >-+# Default: no >-+# >-+# >-+# If set, only subscribed newsgroups that contain unread articles >-+# will be displayed in browser. >-+# >-+# >- # set sig_dashes=yes >- # >- # Name: sig_dashes >-@@ -4748,3 +5007,14 @@ attachments -I message/external-body >- # ``tuning'' section of the manual for performance considerations. >- # >- # >-+# set x_comment_to=no >-+# >-+# Name: x_comment_to >-+# Type: boolean >-+# Default: no >-+# >-+# >-+# If set, Mutt will add ``X-Comment-To:'' field (that contains full >-+# name of original article author) to article that followuped to newsgroup. >-+# >-+# >Index: SOURCES/patch-1.5.23.vvv.nntp >=================================================================== >--- SOURCES/patch-1.5.23.vvv.nntp (revision 0) >+++ SOURCES/patch-1.5.23.vvv.nntp (working copy) >@@ -0,0 +1,8736 @@ >+WARNING: Run the following script before configure: >+ >+aclocal -I m4 >+autoheader >+automake --foreign >+autoconf >+ >+-- >+Vsevolod Volkov <vvv@mutt.org.ua> >+ >+ >+diff -udprP mutt-1.5.23.orig/ChangeLog.nntp mutt-1.5.23/ChangeLog.nntp >+--- mutt-1.5.23.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300 >++++ mutt-1.5.23/ChangeLog.nntp 2014-03-13 12:50:04.000000000 +0200 >+@@ -0,0 +1,399 @@ >++* Thu Mar 13 2014 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.23 >++ >++* Tue Oct 29 2013 Vsevolod Volkov <vvv@mutt.org.ua> >++- minor bug fixed while removing new articles >++ >++* Fri Oct 18 2013 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.22 >++ >++* Tue Nov 27 2012 Vsevolod Volkov <vvv@mutt.org.ua> >++- SASL authentication >++- new option nntp_authenticators >++ >++* Fri Nov 16 2012 Vsevolod Volkov <vvv@mutt.org.ua> >++- support of NNTP commands: CAPABILITIES, STARTTLS, LIST NEWSGROUPS, >++ LIST OVERVIEW.FMT, OVER, DATE >++- added bcache support >++- newss URI scheme renamed to snews >++- removed option nntp_reconnect >++ >++* Sun Sep 16 2012 Vsevolod Volkov <vvv@mutt.org.ua> >++- internal header caching replaced with hcache >++- new option newsgroups_charset >++ >++* Wed Sep 16 2010 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.21 >++ >++* Thu Aug 13 2009 Vsevolod Volkov <vvv@mutt.org.ua> >++- fixed writting references in nntp_save_cache_group() >++ >++* Tue Jun 15 2009 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.20 >++ >++* Tue Mar 20 2009 Vsevolod Volkov <vvv@mutt.org.ua> >++- save Date: header of recorded outgoing articles >++ >++* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.19 >++ >++* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.18 >++- fixed SIGSEGV when followup or forward to newsgroup >++ >++* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.17 >++ >++* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua> >++- fixed arguments of nntp_format_str() >++ >++* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua> >++- fixed error selecting news group >++ >++* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.16 >++ >++* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua> >++- fixed posting error if $smtp_url is set >++- added support of print-style sequence %R (x-comment-to) >++ >++* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.15 >++- nntp://... url changed to news://... >++- added indicator of fetching descriptions progress >++ >++* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.14 >++ >++* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.13 >++ >++* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.12 >++- fixed reading empty .newsrc >++ >++* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.11 >++ >++* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.10 >++ >++* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.9 >++ >++* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.8 >++ >++* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.7 >++- function mutt_update_list_file() moved to newsrc.c and changed algorithm >++ >++* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua> >++- fixed error in nntp_logout_all() >++ >++* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua> >++- fixed debug output in mutt_newsrc_update() >++- added optional support of LISTGROUP command >++- fixed typo in nntp_parse_xref() >++ >++* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.6 >++ >++* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua> >++- fixed compose menu >++ >++* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.5.1 >++ >++* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.5 >++- added space after newsgroup name in .newsrc file >++ >++* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua> >++- nntp patch: fixed SIGSEGV when posting article >++ >++* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.4 >++ >++* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.3 >++- replace safe_free calls by the FREE macro >++ >++* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.2 >++- nntp authentication can be passed after any command >++ >++* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.5.1 >++ >++* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.99 >++ >++* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.28 >++- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>, >++ <reconstruct-thread> functions >++- fixed message about nntp reconnect >++- fixed <attach-news-message> function using browser >++- added support of Followup-To: poster >++- added %n (new articles) in group_index_format >++- posting articles without inews by default >++ >++* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.27 >++ >++* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.26 >++ >++* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.25 >++- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>) >++- added default content disposition >++ >++* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.24 >++ >++* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.23.2 >++- fixed segfault if mutt_conn_find() returns null >++ >++* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.23.1 >++- added support of LISTGROUP command >++- added support for servers with broken overview >++- disabled <flag-message> function on news server >++- fixed error storing bad authentication information >++ >++* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.23 >++- fixed typo in buffy.c >++- added substitution of %s parameter in $inews variable >++ >++* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.22.1 >++- update to 1.3.22 >++ >++* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.21 >++ >++* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.20 >++- removed 'server-hook', use 'account-hook' instead >++- fixed error opening NNTP server without newsgroup using -f option >++ >++* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.19 >++ >++* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.18 >++- fixed typo in nntp_attempt_features() >++- changed algorithm of XGTITLE command testing >++- disabled writing of NNTP password in debug file >++- fixed reading and writing of long newsrc lines >++- changed checking of last line while reading lines from server >++- fixed possible buffer overrun in nntp_parse_newsrc_line() >++- removed checking of XHDR command >++- compare NNTP return codes without trailing space >++ >++* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.17 >++- support for 'LIST NEWSGROUPS' command to read descriptions >++ >++* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.16 >++ >++* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.15 >++ >++* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.14 >++- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de> >++ >++* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.13 >++ >++* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua> >++- Fixed problem if last article in group is deleted >++ >++* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua> >++- Fixed checking of XGTITLE command on some servers >++ >++* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua> >++- Added \r in AUTHINFO commands >++ >++* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.12 >++ >++* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.11 >++- fixed error opening newsgroup from mutt started with -g or -G >++ >++* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.10 >++- hotkey 'G' (get-message) replaced with '^G' >++ >++* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.9 >++- changed delay displaying error messages from 1 to 2 seconds >++- fixed error compiling with nntp and without imap >++ >++* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua> >++- fixed catchup in index >++- fixed nntp_open_mailbox() >++ >++* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua> >++- functions <edit> and <delete-entry> disabled >++- format of news mailbox names changed to url form >++- option nntp_attempts removed >++- option reconnect_news renamed to nntp_reconnect >++- default value of nntp_poll changed from 30 to 60 >++- error handling improved >++ >++* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua> >++- update to 1.3.8 >++- new option show_only_unread >++- add newsgroup completion >++ >++* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.3.7 >++ >++* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.3.6 >++ >++* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.3.5 >++- authentication code update >++- fix for changing to newsgroup from mailbox with read messages >++- socket code optimization >++ >++* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.3.4 >++ >++* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- don't substitute current newsgroup with deleted new messages >++ >++* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.3.3 >++- fix for substitution of newsgroup after reconnection >++- fix for loading newsgroups with very long names >++- fix for loading more than 32768 newsgroups >++ >++* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.3.2 >++ >++* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.3.1 >++ >++* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.3 >++ >++* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.2 >++ >++* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.1.14 >++ >++* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.1.12 >++ >++* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- add substitution of newsgroup with new messages by default >++ >++* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- add attach message from newsgroup >++- add one-line help in newsreader mode >++- disable 'change-dir' command in newsgroups browser >++- add -G option >++ >++* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- get default news server name from file /etc/nntpserver >++- use case insensitive server names >++- add print-style sequence %s to $newsrc >++- add -g option >++ >++* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- remove 'X-FTN-Origin' header processing >++ >++* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.1.11 >++- update to 1.1.10 >++ >++* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- fix mutt_select_newsserver() >++- remove 'toggle-mode' function >++- add 'change-newsgroup' function >++ >++* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- fix server-hook >++ >++* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- fix error 'bounce' function after 'post' >++- add 'forward to newsgroup' function >++ >++* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- 'forward' function works in newsreader mode >++- add 'post' and 'followup' functions to pager and attachment menu >++- fix active descriptions and allowed flag reload >++ >++* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.1.9 >++- remove deleted newsgroups from list >++ >++* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update .newsrc in browser >++ >++* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- reload .newsrc if externally modified >++- fix active cache update >++ >++* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.1.8 >++ >++* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- patch *.update_list_file is not required >++- count lines when loading descriptions >++- remove cache of unsubscribed newsgroups >++ >++* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- load list of newsgroups from cache faster >++ >++* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.1.7 >++ >++* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- fix unread messages in browser >++- fix newsrc_gen_entries() >++ >++* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- fix mutt_newsgroup_stat() >++- fix nntp_delete_cache() >++- fix nntp_get_status() >++- fix check_children() >++- fix nntp_fetch_headers() >++ >++* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.1.5 >++ >++* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- fix updating new messages in cache >++ >++* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- change default cache filenames >++- fix updating new messages in cache >++ >++* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- fix segmentation fault in news groups browser >++ >++* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.1.4 >++ >++* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.1.3 >++ >++* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- add X-Comment-To editing >++- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers >++- add variables $ask_followup_to and $ask_x_comment_to >++ >++* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> >++- update to 1.1.2 >+diff -udprP mutt-1.5.23.orig/OPS mutt-1.5.23/OPS >+--- mutt-1.5.23.orig/OPS 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/OPS 2014-03-13 12:48:36.000000000 +0200 >+@@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a >+ OP_BROWSER_NEW_FILE "select a new file in this directory" >+ OP_BROWSER_VIEW_FILE "view file" >+ OP_BROWSER_TELL "display the currently selected file's name" >+-OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)" >+-OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)" >++OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)" >++OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)" >+ OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)" >+ OP_BUFFY_LIST "list mailboxes with new mail" >++OP_CATCHUP "mark all articles in newsgroup as read" >+ OP_CHANGE_DIRECTORY "change directories" >+ OP_CHECK_NEW "check mailboxes for new mail" >+ OP_COMPOSE_ATTACH_FILE "attach file(s) to this message" >+ OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message" >++OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach news article(s) to this message" >+ OP_COMPOSE_EDIT_BCC "edit the BCC list" >+ OP_COMPOSE_EDIT_CC "edit the CC list" >+ OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description" >+@@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel >+ OP_COMPOSE_EDIT_HEADERS "edit the message with headers" >+ OP_COMPOSE_EDIT_MESSAGE "edit the message" >+ OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry" >++OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list" >+ OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field" >++OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field" >++OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field" >+ OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message" >+ OP_COMPOSE_EDIT_TO "edit the TO list" >+ OP_CREATE_MAILBOX "create a new mailbox (IMAP only)" >+@@ -85,8 +90,13 @@ OP_EXIT "exit this menu" >+ OP_FILTER "filter attachment through a shell command" >+ OP_FIRST_ENTRY "move to the first entry" >+ OP_FLAG_MESSAGE "toggle a message's 'important' flag" >++OP_FOLLOWUP "followup to newsgroup" >++OP_FORWARD_TO_GROUP "forward to newsgroup" >+ OP_FORWARD_MESSAGE "forward a message with comments" >+ OP_GENERIC_SELECT_ENTRY "select the current entry" >++OP_GET_CHILDREN "get all children of the current message" >++OP_GET_MESSAGE "get message with Message-Id" >++OP_GET_PARENT "get parent of the current message" >+ OP_GROUP_REPLY "reply to all recipients" >+ OP_HALF_DOWN "scroll down 1/2 page" >+ OP_HALF_UP "scroll up 1/2 page" >+@@ -94,11 +104,14 @@ OP_HELP "this screen" >+ OP_JUMP "jump to an index number" >+ OP_LAST_ENTRY "move to the last entry" >+ OP_LIST_REPLY "reply to specified mailing list" >++OP_LOAD_ACTIVE "load list of all newsgroups from NNTP server" >+ OP_MACRO "execute a macro" >+ OP_MAIL "compose a new mail message" >+ OP_MAIN_BREAK_THREAD "break the thread in two" >+ OP_MAIN_CHANGE_FOLDER "open a different folder" >+ OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode" >++OP_MAIN_CHANGE_GROUP "open a different newsgroup" >++OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode" >+ OP_MAIN_CLEAR_FLAG "clear a status flag from a message" >+ OP_MAIN_DELETE_PATTERN "delete messages matching a pattern" >+ OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server" >+@@ -138,6 +151,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of >+ OP_PAGER_SKIP_QUOTED "skip beyond quoted text" >+ OP_PAGER_TOP "jump to the top of the message" >+ OP_PIPE "pipe message/attachment to a shell command" >++OP_POST "post message to newsgroup" >+ OP_PREV_ENTRY "move to the previous entry" >+ OP_PREV_LINE "scroll up one line" >+ OP_PREV_PAGE "move to the previous page" >+@@ -146,6 +160,7 @@ OP_QUERY "query external program for add >+ OP_QUERY_APPEND "append new query results to current results" >+ OP_QUIT "save changes to mailbox and quit" >+ OP_RECALL_MESSAGE "recall a postponed message" >++OP_RECONSTRUCT_THREAD "reconstruct thread containing current message" >+ OP_REDRAW "clear and redraw the screen" >+ OP_REFORMAT_WINCH "{internal}" >+ OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)" >+@@ -160,18 +175,22 @@ OP_SEARCH_TOGGLE "toggle search pattern >+ OP_SHELL_ESCAPE "invoke a command in a subshell" >+ OP_SORT "sort messages" >+ OP_SORT_REVERSE "sort messages in reverse order" >++OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern" >+ OP_TAG "tag the current entry" >+ OP_TAG_PREFIX "apply next function to tagged messages" >+ OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages" >+ OP_TAG_SUBTHREAD "tag the current subthread" >+ OP_TAG_THREAD "tag the current thread" >+ OP_TOGGLE_NEW "toggle a message's 'new' flag" >++OP_TOGGLE_READ "toggle view of read messages" >+ OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten" >+ OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files" >+ OP_TOP_PAGE "move to the top of the page" >++OP_UNCATCHUP "mark all articles in newsgroup as unread" >+ OP_UNDELETE "undelete the current entry" >+ OP_UNDELETE_THREAD "undelete all messages in thread" >+ OP_UNDELETE_SUBTHREAD "undelete all messages in subthread" >++OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern" >+ OP_VERSION "show the Mutt version number and date" >+ OP_VIEW_ATTACH "view attachment using mailcap entry if necessary" >+ OP_VIEW_ATTACHMENTS "show MIME attachments" >+diff -udprP mutt-1.5.23.orig/PATCHES mutt-1.5.23/PATCHES >+--- mutt-1.5.23.orig/PATCHES 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/PATCHES 2014-03-13 12:48:36.000000000 +0200 >+@@ -0,0 +1 @@ >++vvv.nntp >+diff -udprP mutt-1.5.23.orig/account.c mutt-1.5.23/account.c >+--- mutt-1.5.23.orig/account.c 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/account.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -51,8 +51,17 @@ int mutt_account_match (const ACCOUNT* a >+ user = PopUser; >+ #endif >+ >++#ifdef USE_NNTP >++ if (a1->type == M_ACCT_TYPE_NNTP && NntpUser) >++ user = NntpUser; >++#endif >++ >+ if (a1->flags & a2->flags & M_ACCT_USER) >+ return (!strcmp (a1->user, a2->user)); >++#ifdef USE_NNTP >++ if (a1->type == M_ACCT_TYPE_NNTP) >++ return a1->flags & M_ACCT_USER && a1->user[0] ? 0 : 1; >++#endif >+ if (a1->flags & M_ACCT_USER) >+ return (!strcmp (a1->user, user)); >+ if (a2->flags & M_ACCT_USER) >+@@ -130,6 +139,16 @@ void mutt_account_tourl (ACCOUNT* accoun >+ } >+ #endif >+ >++#ifdef USE_NNTP >++ if (account->type == M_ACCT_TYPE_NNTP) >++ { >++ if (account->flags & M_ACCT_SSL) >++ url->scheme = U_NNTPS; >++ else >++ url->scheme = U_NNTP; >++ } >++#endif >++ >+ url->host = account->host; >+ if (account->flags & M_ACCT_PORT) >+ url->port = account->port; >+@@ -155,6 +174,10 @@ int mutt_account_getuser (ACCOUNT* accou >+ else if ((account->type == M_ACCT_TYPE_POP) && PopUser) >+ strfcpy (account->user, PopUser, sizeof (account->user)); >+ #endif >++#ifdef USE_NNTP >++ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser) >++ strfcpy (account->user, NntpUser, sizeof (account->user)); >++#endif >+ else if (option (OPTNOCURSES)) >+ return -1; >+ /* prompt (defaults to unix username), copy into account->user */ >+@@ -217,6 +240,10 @@ int mutt_account_getpass (ACCOUNT* accou >+ else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass) >+ strfcpy (account->pass, SmtpPass, sizeof (account->pass)); >+ #endif >++#ifdef USE_NNTP >++ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass) >++ strfcpy (account->pass, NntpPass, sizeof (account->pass)); >++#endif >+ else if (option (OPTNOCURSES)) >+ return -1; >+ else >+diff -udprP mutt-1.5.23.orig/account.h mutt-1.5.23/account.h >+--- mutt-1.5.23.orig/account.h 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/account.h 2014-03-13 12:48:36.000000000 +0200 >+@@ -29,7 +29,8 @@ enum >+ M_ACCT_TYPE_NONE = 0, >+ M_ACCT_TYPE_IMAP, >+ M_ACCT_TYPE_POP, >+- M_ACCT_TYPE_SMTP >++ M_ACCT_TYPE_SMTP, >++ M_ACCT_TYPE_NNTP >+ }; >+ >+ /* account flags */ >+diff -udprP mutt-1.5.23.orig/attach.h mutt-1.5.23/attach.h >+--- mutt-1.5.23.orig/attach.h 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/attach.h 2014-03-13 12:48:36.000000000 +0200 >+@@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f >+ >+ void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *); >+ void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *); >+-void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *); >++void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int); >+ void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int); >+ >+ #endif /* _ATTACH_H_ */ >+diff -udprP mutt-1.5.23.orig/browser.c mutt-1.5.23/browser.c >+--- mutt-1.5.23.orig/browser.c 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/browser.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -32,6 +32,9 @@ >+ #ifdef USE_IMAP >+ #include "imap.h" >+ #endif >++#ifdef USE_NNTP >++#include "nntp.h" >++#endif >+ >+ #include <stdlib.h> >+ #include <dirent.h> >+@@ -50,6 +53,19 @@ static const struct mapping_t FolderHelp >+ { NULL, 0 } >+ }; >+ >++#ifdef USE_NNTP >++static struct mapping_t FolderNewsHelp[] = { >++ { N_("Exit"), OP_EXIT }, >++ { N_("List"), OP_TOGGLE_MAILBOXES }, >++ { N_("Subscribe"), OP_BROWSER_SUBSCRIBE }, >++ { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE }, >++ { N_("Catchup"), OP_CATCHUP }, >++ { N_("Mask"), OP_ENTER_MASK }, >++ { N_("Help"), OP_HELP }, >++ { NULL, 0 } >++}; >++#endif >++ >+ typedef struct folder_t >+ { >+ struct folder_file *ff; >+@@ -115,9 +131,17 @@ static void browser_sort (struct browser >+ case SORT_ORDER: >+ return; >+ case SORT_DATE: >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ return; >++#endif >+ f = browser_compare_date; >+ break; >+ case SORT_SIZE: >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ return; >++#endif >+ f = browser_compare_size; >+ break; >+ case SORT_SUBJECT: >+@@ -324,8 +348,111 @@ folder_format_str (char *dest, size_t de >+ return (src); >+ } >+ >++#ifdef USE_NNTP >++static const char * >++newsgroup_format_str (char *dest, size_t destlen, size_t col, char op, const char *src, >++ const char *fmt, const char *ifstring, const char *elsestring, >++ unsigned long data, format_flag flags) >++{ >++ char fn[SHORT_STRING], tmp[SHORT_STRING]; >++ FOLDER *folder = (FOLDER *) data; >++ >++ switch (op) >++ { >++ case 'C': >++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); >++ snprintf (dest, destlen, tmp, folder->num + 1); >++ break; >++ >++ case 'f': >++ strncpy (fn, folder->ff->name, sizeof(fn) - 1); >++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >++ snprintf (dest, destlen, tmp, fn); >++ break; >++ >++ case 'N': >++ snprintf (tmp, sizeof (tmp), "%%%sc", fmt); >++ if (folder->ff->nd->subscribed) >++ snprintf (dest, destlen, tmp, ' '); >++ else >++ snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u'); >++ break; >++ >++ case 'M': >++ snprintf (tmp, sizeof (tmp), "%%%sc", fmt); >++ if (folder->ff->nd->deleted) >++ snprintf (dest, destlen, tmp, 'D'); >++ else >++ snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-'); >++ break; >++ >++ case 's': >++ if (flags & M_FORMAT_OPTIONAL) >++ { >++ if (folder->ff->nd->unread != 0) >++ mutt_FormatString (dest, destlen, col, ifstring, newsgroup_format_str, >++ data, flags); >++ else >++ mutt_FormatString (dest, destlen, col, elsestring, newsgroup_format_str, >++ data, flags); >++ } >++ else if (Context && Context->data == folder->ff->nd) >++ { >++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); >++ snprintf (dest, destlen, tmp, Context->unread); >++ } >++ else >++ { >++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); >++ snprintf (dest, destlen, tmp, folder->ff->nd->unread); >++ } >++ break; >++ >++ case 'n': >++ if (Context && Context->data == folder->ff->nd) >++ { >++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); >++ snprintf (dest, destlen, tmp, Context->new); >++ } >++ else if (option (OPTMARKOLD) && >++ folder->ff->nd->lastCached >= folder->ff->nd->firstMessage && >++ folder->ff->nd->lastCached <= folder->ff->nd->lastMessage) >++ { >++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); >++ snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached); >++ } >++ else >++ { >++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); >++ snprintf (dest, destlen, tmp, folder->ff->nd->unread); >++ } >++ break; >++ >++ case 'd': >++ if (folder->ff->nd->desc != NULL) >++ { >++ char *buf = safe_strdup (folder->ff->nd->desc); >++ if (NewsgroupsCharset && *NewsgroupsCharset) >++ mutt_convert_string (&buf, NewsgroupsCharset, Charset, M_ICONV_HOOK_FROM); >++ mutt_filter_unprintable (&buf); >++ >++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >++ snprintf (dest, destlen, tmp, buf); >++ } >++ else >++ { >++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >++ snprintf (dest, destlen, tmp, ""); >++ } >++ break; >++ } >++ return (src); >++} >++#endif /* USE_NNTP */ >++ >+ static void add_folder (MUTTMENU *m, struct browser_state *state, >+- const char *name, const struct stat *s, unsigned int new) >++ const char *name, const struct stat *s, >++ void *data, unsigned int new) >+ { >+ if (state->entrylen == state->entrymax) >+ { >+@@ -354,6 +481,10 @@ static void add_folder (MUTTMENU *m, str >+ #ifdef USE_IMAP >+ (state->entry)[state->entrylen].imap = 0; >+ #endif >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ (state->entry)[state->entrylen].nd = (NNTP_DATA *)data; >++#endif >+ (state->entrylen)++; >+ } >+ >+@@ -369,9 +500,36 @@ static void init_state (struct browser_s >+ menu->data = state->entry; >+ } >+ >++/* get list of all files/newsgroups with mask */ >+ static int examine_directory (MUTTMENU *menu, struct browser_state *state, >+ char *d, const char *prefix) >+ { >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ { >++ NNTP_SERVER *nserv = CurrentNewsSrv; >++ unsigned int i; >++ >++/* mutt_buffy_check (0); */ >++ init_state (state, menu); >++ >++ for (i = 0; i < nserv->groups_num; i++) >++ { >++ NNTP_DATA *nntp_data = nserv->groups_list[i]; >++ if (!nntp_data) >++ continue; >++ if (prefix && *prefix && >++ strncmp (prefix, nntp_data->group, strlen (prefix))) >++ continue; >++ if (!((regexec (Mask.rx, nntp_data->group, 0, NULL, 0) == 0) ^ Mask.not)) >++ continue; >++ add_folder (menu, state, nntp_data->group, NULL, >++ nntp_data, nntp_data->new); >++ } >++ } >++ else >++#endif /* USE_NNTP */ >++ { >+ struct stat s; >+ DIR *dp; >+ struct dirent *de; >+@@ -432,17 +590,41 @@ static int examine_directory (MUTTMENU * >+ tmp = Incoming; >+ while (tmp && mutt_strcmp (buffer, tmp->path)) >+ tmp = tmp->next; >+- add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0); >++ add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0); >+ } >+ closedir (dp); >++ } >+ browser_sort (state); >+ return 0; >+ } >+ >++/* get list of mailboxes/subscribed newsgroups */ >+ static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state) >+ { >+ struct stat s; >+ char buffer[LONG_STRING]; >++ >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ { >++ NNTP_SERVER *nserv = CurrentNewsSrv; >++ unsigned int i; >++ >++/* mutt_buffy_check (0); */ >++ init_state (state, menu); >++ >++ for (i = 0; i < nserv->groups_num; i++) >++ { >++ NNTP_DATA *nntp_data = nserv->groups_list[i]; >++ if (nntp_data && (nntp_data->new || (nntp_data->subscribed && >++ (nntp_data->unread || !option (OPTSHOWONLYUNREAD))))) >++ add_folder (menu, state, nntp_data->group, NULL, >++ nntp_data, nntp_data->new); >++ } >++ } >++ else >++#endif >++ { >+ BUFFY *tmp = Incoming; >+ #ifdef USE_IMAP >+ struct mailbox_state mbox; >+@@ -460,14 +642,21 @@ static int examine_mailboxes (MUTTMENU * >+ if (mx_is_imap (tmp->path)) >+ { >+ imap_mailbox_state (tmp->path, &mbox); >+- add_folder (menu, state, tmp->path, NULL, mbox.new); >++ add_folder (menu, state, tmp->path, NULL, NULL, mbox.new); >+ continue; >+ } >+ #endif >+ #ifdef USE_POP >+ if (mx_is_pop (tmp->path)) >+ { >+- add_folder (menu, state, tmp->path, NULL, tmp->new); >++ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); >++ continue; >++ } >++#endif >++#ifdef USE_NNTP >++ if (mx_is_nntp (tmp->path)) >++ { >++ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); >+ continue; >+ } >+ #endif >+@@ -496,15 +685,20 @@ static int examine_mailboxes (MUTTMENU * >+ strfcpy (buffer, NONULL(tmp->path), sizeof (buffer)); >+ mutt_pretty_mailbox (buffer, sizeof (buffer)); >+ >+- add_folder (menu, state, buffer, &s, tmp->new); >++ add_folder (menu, state, buffer, &s, NULL, tmp->new); >+ } >+ while ((tmp = tmp->next)); >++ } >+ browser_sort (state); >+ return 0; >+ } >+ >+ static int select_file_search (MUTTMENU *menu, regex_t *re, int n) >+ { >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0)); >++#endif >+ return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0)); >+ } >+ >+@@ -515,6 +709,12 @@ static void folder_entry (char *s, size_ >+ folder.ff = &((struct folder_file *) menu->data)[num]; >+ folder.num = num; >+ >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ mutt_FormatString (s, slen, 0, NONULL(GroupFormat), newsgroup_format_str, >++ (unsigned long) &folder, M_FORMAT_ARROWCURSOR); >++ else >++#endif >+ mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str, >+ (unsigned long) &folder, M_FORMAT_ARROWCURSOR); >+ } >+@@ -535,6 +735,17 @@ static void init_menu (struct browser_st >+ >+ menu->tagged = 0; >+ >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ { >++ if (buffy) >++ snprintf (title, titlelen, _("Subscribed newsgroups")); >++ else >++ snprintf (title, titlelen, _("Newsgroups on server [%s]"), >++ CurrentNewsSrv->conn->account.host); >++ } >++ else >++#endif >+ if (buffy) >+ snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0)); >+ else >+@@ -590,6 +801,31 @@ void _mutt_select_file (char *f, size_t >+ if (!folder) >+ strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup)); >+ >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ { >++ if (*f) >++ strfcpy (prefix, f, sizeof (prefix)); >++ else >++ { >++ NNTP_SERVER *nserv = CurrentNewsSrv; >++ unsigned int i; >++ >++ /* default state for news reader mode is browse subscribed newsgroups */ >++ buffy = 0; >++ for (i = 0; i < nserv->groups_num; i++) >++ { >++ NNTP_DATA *nntp_data = nserv->groups_list[i]; >++ if (nntp_data && nntp_data->subscribed) >++ { >++ buffy = 1; >++ break; >++ } >++ } >++ } >++ } >++ else >++#endif >+ if (*f) >+ { >+ mutt_expand_path (f, flen); >+@@ -686,6 +922,9 @@ void _mutt_select_file (char *f, size_t >+ menu->tag = file_tag; >+ >+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER, >++#ifdef USE_NNTP >++ option (OPTNEWS) ? FolderNewsHelp : >++#endif >+ FolderHelp); >+ >+ init_menu (&state, menu, title, sizeof (title), buffy); >+@@ -824,7 +1063,11 @@ void _mutt_select_file (char *f, size_t >+ } >+ } >+ >++#ifdef USE_NNTP >++ if (buffy || option (OPTNEWS)) >++#else >+ if (buffy) >++#endif >+ { >+ strfcpy (f, state.entry[menu->current].name, flen); >+ mutt_expand_path (f, flen); >+@@ -882,14 +1125,6 @@ void _mutt_select_file (char *f, size_t >+ break; >+ >+ #ifdef USE_IMAP >+- case OP_BROWSER_SUBSCRIBE: >+- imap_subscribe (state.entry[menu->current].name, 1); >+- break; >+- >+- case OP_BROWSER_UNSUBSCRIBE: >+- imap_subscribe (state.entry[menu->current].name, 0); >+- break; >+- >+ case OP_BROWSER_TOGGLE_LSUB: >+ if (option (OPTIMAPLSUB)) >+ unset_option (OPTIMAPLSUB); >+@@ -990,6 +1225,11 @@ void _mutt_select_file (char *f, size_t >+ >+ case OP_CHANGE_DIRECTORY: >+ >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ break; >++#endif >++ >+ strfcpy (buf, LastDir, sizeof (buf)); >+ #ifdef USE_IMAP >+ if (!state.imap_browse) >+@@ -1255,6 +1495,210 @@ void _mutt_select_file (char *f, size_t >+ else >+ mutt_error _("Error trying to view file"); >+ } >++ break; >++ >++#ifdef USE_NNTP >++ case OP_CATCHUP: >++ case OP_UNCATCHUP: >++ if (option (OPTNEWS)) >++ { >++ struct folder_file *f = &state.entry[menu->current]; >++ int rc; >++ NNTP_DATA *nntp_data; >++ >++ rc = nntp_newsrc_parse (CurrentNewsSrv); >++ if (rc < 0) >++ break; >++ >++ if (i == OP_CATCHUP) >++ nntp_data = mutt_newsgroup_catchup (CurrentNewsSrv, f->name); >++ else >++ nntp_data = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name); >++ >++ if (nntp_data) >++ { >++/* FOLDER folder; >++ struct folder_file ff; >++ char buffer[_POSIX_PATH_MAX + SHORT_STRING]; >++ >++ folder.ff = &ff; >++ folder.ff->name = f->name; >++ folder.ff->st = NULL; >++ folder.ff->is_new = nntp_data->new; >++ folder.ff->nntp_data = nntp_data; >++ FREE (&f->desc); >++ mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat), >++ newsgroup_format_str, (unsigned long) &folder, >++ M_FORMAT_ARROWCURSOR); >++ f->desc = safe_strdup (buffer); */ >++ nntp_newsrc_update (CurrentNewsSrv); >++ if (menu->current + 1 < menu->max) >++ menu->current++; >++ menu->redraw = REDRAW_MOTION_RESYNCH; >++ } >++ if (rc) >++ menu->redraw = REDRAW_INDEX; >++ nntp_newsrc_close (CurrentNewsSrv); >++ } >++ break; >++ >++ case OP_LOAD_ACTIVE: >++ if (option (OPTNEWS)) >++ { >++ NNTP_SERVER *nserv = CurrentNewsSrv; >++ unsigned int i; >++ >++ if (nntp_newsrc_parse (nserv) < 0) >++ break; >++ >++ for (i = 0; i < nserv->groups_num; i++) >++ { >++ NNTP_DATA *nntp_data = nserv->groups_list[i]; >++ if (nntp_data) >++ nntp_data->deleted = 1; >++ } >++ nntp_active_fetch (nserv); >++ nntp_newsrc_update (nserv); >++ nntp_newsrc_close (nserv); >++ >++ destroy_state (&state); >++ if (buffy) >++ examine_mailboxes (menu, &state); >++ else >++ examine_directory (menu, &state, NULL, NULL); >++ init_menu (&state, menu, title, sizeof (title), buffy); >++ } >++ break; >++#endif /* USE_NNTP */ >++ >++#if defined USE_IMAP || defined USE_NNTP >++ case OP_BROWSER_SUBSCRIBE: >++ case OP_BROWSER_UNSUBSCRIBE: >++#endif >++#ifdef USE_NNTP >++ case OP_SUBSCRIBE_PATTERN: >++ case OP_UNSUBSCRIBE_PATTERN: >++ if (option (OPTNEWS)) >++ { >++ NNTP_SERVER *nserv = CurrentNewsSrv; >++ NNTP_DATA *nntp_data; >++ regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t)); >++ char *s = buf; >++ int rc, j = menu->current; >++ >++ if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN) >++ { >++ char tmp[STRING]; >++ int err; >++ >++ buf[0] = 0; >++ if (i == OP_SUBSCRIBE_PATTERN) >++ snprintf (tmp, sizeof (tmp), _("Subscribe pattern: ")); >++ else >++ snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: ")); >++ if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) >++ { >++ FREE (&rx); >++ break; >++ } >++ >++ err = REGCOMP (rx, s, REG_NOSUB); >++ if (err) >++ { >++ regerror (err, rx, buf, sizeof (buf)); >++ regfree (rx); >++ FREE (&rx); >++ mutt_error ("%s", buf); >++ break; >++ } >++ menu->redraw = REDRAW_FULL; >++ j = 0; >++ } >++ else if (!state.entrylen) >++ { >++ mutt_error _("No newsgroups match the mask"); >++ break; >++ } >++ >++ rc = nntp_newsrc_parse (nserv); >++ if (rc < 0) >++ break; >++ >++ for ( ; j < state.entrylen; j++) >++ { >++ struct folder_file *f = &state.entry[j]; >++ >++ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE || >++ regexec (rx, f->name, 0, NULL, 0) == 0) >++ { >++ if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN) >++ nntp_data = mutt_newsgroup_subscribe (nserv, f->name); >++ else >++ nntp_data = mutt_newsgroup_unsubscribe (nserv, f->name); >++/* if (nntp_data) >++ { >++ FOLDER folder; >++ char buffer[_POSIX_PATH_MAX + SHORT_STRING]; >++ >++ folder.name = f->name; >++ folder.f = NULL; >++ folder.new = nntp_data->new; >++ folder.nd = nntp_data; >++ FREE (&f->desc); >++ mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat), >++ newsgroup_format_str, (unsigned long) &folder, >++ M_FORMAT_ARROWCURSOR); >++ f->desc = safe_strdup (buffer); >++ } */ >++ } >++ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE) >++ { >++ if (menu->current + 1 < menu->max) >++ menu->current++; >++ menu->redraw = REDRAW_MOTION_RESYNCH; >++ break; >++ } >++ } >++ if (i == OP_SUBSCRIBE_PATTERN) >++ { >++ unsigned int i; >++ >++ for (i = 0; nserv && i < nserv->groups_num; i++) >++ { >++ nntp_data = nserv->groups_list[i]; >++ if (nntp_data && nntp_data->group && !nntp_data->subscribed) >++ { >++ if (regexec (rx, nntp_data->group, 0, NULL, 0) == 0) >++ { >++ mutt_newsgroup_subscribe (nserv, nntp_data->group); >++ add_folder (menu, &state, nntp_data->group, NULL, >++ nntp_data, nntp_data->new); >++ } >++ } >++ } >++ init_menu (&state, menu, title, sizeof (title), buffy); >++ } >++ if (rc > 0) >++ menu->redraw = REDRAW_FULL; >++ nntp_newsrc_update (nserv); >++ nntp_clear_cache (nserv); >++ nntp_newsrc_close (nserv); >++ if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE) >++ regfree (rx); >++ FREE (&rx); >++ } >++#ifdef USE_IMAP >++ else >++#endif /* USE_IMAP && USE_NNTP */ >++#endif /* USE_NNTP */ >++#ifdef USE_IMAP >++ { >++ if (i == OP_BROWSER_SUBSCRIBE) >++ imap_subscribe (state.entry[menu->current].name, 1); >++ else >++ imap_subscribe (state.entry[menu->current].name, 0); >++ } >++#endif /* USE_IMAP */ >+ } >+ } >+ >+diff -udprP mutt-1.5.23.orig/browser.h mutt-1.5.23/browser.h >+--- mutt-1.5.23.orig/browser.h 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/browser.h 2014-03-13 12:48:36.000000000 +0200 >+@@ -19,6 +19,10 @@ >+ #ifndef _BROWSER_H >+ #define _BROWSER_H 1 >+ >++#ifdef USE_NNTP >++#include "nntp.h" >++#endif >++ >+ struct folder_file >+ { >+ mode_t mode; >+@@ -37,6 +41,9 @@ struct folder_file >+ unsigned selectable : 1; >+ unsigned inferiors : 1; >+ #endif >++#ifdef USE_NNTP >++ NNTP_DATA *nd; >++#endif >+ unsigned tagged : 1; >+ }; >+ >+diff -udprP mutt-1.5.23.orig/buffy.c mutt-1.5.23/buffy.c >+--- mutt-1.5.23.orig/buffy.c 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/buffy.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -405,6 +405,9 @@ int mutt_buffy_check (int force) >+ >+ /* check device ID and serial number instead of comparing paths */ >+ if (!Context || Context->magic == M_IMAP || Context->magic == M_POP >++#ifdef USE_NNTP >++ || Context->magic == M_NNTP >++#endif >+ || stat (Context->path, &contex_sb) != 0) >+ { >+ contex_sb.st_dev=0; >+@@ -421,6 +424,11 @@ int mutt_buffy_check (int force) >+ tmp->magic = M_POP; >+ else >+ #endif >++#ifdef USE_NNTP >++ if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path)) >++ tmp->magic = M_NNTP; >++ else >++#endif >+ if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) || >+ (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0)) >+ { >+@@ -436,7 +444,11 @@ int mutt_buffy_check (int force) >+ /* check to see if the folder is the currently selected folder >+ * before polling */ >+ if (!Context || !Context->path || >++#ifdef USE_NNTP >++ (( tmp->magic == M_IMAP || tmp->magic == M_POP || tmp->magic == M_NNTP ) >++#else >+ (( tmp->magic == M_IMAP || tmp->magic == M_POP ) >++#endif >+ ? mutt_strcmp (tmp->path, Context->path) : >+ (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino))) >+ { >+diff -udprP mutt-1.5.23.orig/complete.c mutt-1.5.23/complete.c >+--- mutt-1.5.23.orig/complete.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/complete.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -25,6 +25,9 @@ >+ #include "mailbox.h" >+ #include "imap.h" >+ #endif >++#ifdef USE_NNTP >++#include "nntp.h" >++#endif >+ >+ #include <dirent.h> >+ #include <string.h> >+@@ -48,9 +51,70 @@ int mutt_complete (char *s, size_t slen) >+ char filepart[_POSIX_PATH_MAX]; >+ #ifdef USE_IMAP >+ char imap_path[LONG_STRING]; >++#endif >+ >+ dprint (2, (debugfile, "mutt_complete: completing %s\n", s)); >+ >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ { >++ NNTP_SERVER *nserv = CurrentNewsSrv; >++ unsigned int n = 0; >++ >++ strfcpy (filepart, s, sizeof (filepart)); >++ >++ /* special case to handle when there is no filepart yet >++ * find the first subscribed newsgroup */ >++ len = mutt_strlen (filepart); >++ if (len == 0) >++ { >++ for (; n < nserv->groups_num; n++) >++ { >++ NNTP_DATA *nntp_data = nserv->groups_list[n]; >++ >++ if (nntp_data && nntp_data->subscribed) >++ { >++ strfcpy (filepart, nntp_data->group, sizeof (filepart)); >++ init = 1; >++ n++; >++ break; >++ } >++ } >++ } >++ >++ for (; n < nserv->groups_num; n++) >++ { >++ NNTP_DATA *nntp_data = nserv->groups_list[n]; >++ >++ if (nntp_data && nntp_data->subscribed && >++ mutt_strncmp (nntp_data->group, filepart, len) == 0) >++ { >++ if (init) >++ { >++ for (i = 0; filepart[i] && nntp_data->group[i]; i++) >++ { >++ if (filepart[i] != nntp_data->group[i]) >++ { >++ filepart[i] = 0; >++ break; >++ } >++ } >++ filepart[i] = 0; >++ } >++ else >++ { >++ strfcpy (filepart, nntp_data->group, sizeof (filepart)); >++ init = 1; >++ } >++ } >++ } >++ >++ strcpy (s, filepart); >++ return (init ? 0 : -1); >++ } >++#endif >++ >++#ifdef USE_IMAP >+ /* we can use '/' as a delimiter, imap_complete rewrites it */ >+ if (*s == '=' || *s == '+' || *s == '!') >+ { >+diff -udprP mutt-1.5.23.orig/compose.c mutt-1.5.23/compose.c >+--- mutt-1.5.23.orig/compose.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/compose.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -32,11 +32,16 @@ >+ #include "mailbox.h" >+ #include "sort.h" >+ #include "charset.h" >++#include "mx.h" >+ >+ #ifdef MIXMASTER >+ #include "remailer.h" >+ #endif >+ >++#ifdef USE_NNTP >++#include "nntp.h" >++#endif >++ >+ #include <errno.h> >+ #include <string.h> >+ #include <sys/stat.h> >+@@ -67,11 +72,17 @@ enum >+ HDR_CRYPT, >+ HDR_CRYPTINFO, >+ >++#ifdef USE_NNTP >++ HDR_NEWSGROUPS, >++ HDR_FOLLOWUPTO, >++ HDR_XCOMMENTTO, >++#endif >++ >+ HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */ >+ }; >+ >+-#define HDR_XOFFSET 10 >+-#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */ >++#define HDR_XOFFSET 14 >++#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */ >+ #define W (COLS - HDR_XOFFSET) >+ >+ static const char * const Prompts[] = >+@@ -83,6 +94,16 @@ static const char * const Prompts[] = >+ "Subject: ", >+ "Reply-To: ", >+ "Fcc: " >++#ifdef USE_NNTP >++#ifdef MIXMASTER >++ ,"" >++#endif >++ ,"" >++ ,"" >++ ,"Newsgroups: " >++ ,"Followup-To: " >++ ,"X-Comment-To: " >++#endif >+ }; >+ >+ static const struct mapping_t ComposeHelp[] = { >+@@ -97,6 +118,19 @@ static const struct mapping_t ComposeHel >+ { NULL, 0 } >+ }; >+ >++#ifdef USE_NNTP >++static struct mapping_t ComposeNewsHelp[] = { >++ { N_("Send"), OP_COMPOSE_SEND_MESSAGE }, >++ { N_("Abort"), OP_EXIT }, >++ { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS }, >++ { "Subj", OP_COMPOSE_EDIT_SUBJECT }, >++ { N_("Attach file"), OP_COMPOSE_ATTACH_FILE }, >++ { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION }, >++ { N_("Help"), OP_HELP }, >++ { NULL, 0 } >++}; >++#endif >++ >+ static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num) >+ { >+ mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt, >+@@ -110,7 +144,7 @@ static void snd_entry (char *b, size_t b >+ >+ static void redraw_crypt_lines (HEADER *msg) >+ { >+- mvaddstr (HDR_CRYPT, 0, "Security: "); >++ mvprintw (HDR_CRYPT, 0, TITLE_FMT, "Security: "); >+ >+ if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0) >+ { >+@@ -148,10 +182,11 @@ static void redraw_crypt_lines (HEADER * >+ if ((WithCrypto & APPLICATION_PGP) >+ && (msg->security & APPLICATION_PGP) && (msg->security & SIGN)) >+ printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>")); >++ printw (TITLE_FMT "%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>")); >+ >+ if ((WithCrypto & APPLICATION_SMIME) >+ && (msg->security & APPLICATION_SMIME) && (msg->security & SIGN)) { >+- printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>")); >++ printw (TITLE_FMT "%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>")); >+ } >+ >+ if ((WithCrypto & APPLICATION_SMIME) >+@@ -172,7 +207,7 @@ static void redraw_mix_line (LIST *chain >+ int c; >+ char *t; >+ >+- mvaddstr (HDR_MIX, 0, " Mix: "); >++ mvprintw (HDR_MIX, 0, TITLE_FMT, "Mix: "); >+ >+ if (!chain) >+ { >+@@ -246,9 +281,28 @@ static void draw_envelope_addr (int line >+ static void draw_envelope (HEADER *msg, char *fcc) >+ { >+ draw_envelope_addr (HDR_FROM, msg->env->from); >++#ifdef USE_NNTP >++ if (!option (OPTNEWSSEND)) >++ { >++#endif >+ draw_envelope_addr (HDR_TO, msg->env->to); >+ draw_envelope_addr (HDR_CC, msg->env->cc); >+ draw_envelope_addr (HDR_BCC, msg->env->bcc); >++#ifdef USE_NNTP >++ } >++ else >++ { >++ mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]); >++ mutt_paddstr (W, NONULL (msg->env->newsgroups)); >++ mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]); >++ mutt_paddstr (W, NONULL (msg->env->followup_to)); >++ if (option (OPTXCOMMENTTO)) >++ { >++ mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]); >++ mutt_paddstr (W, NONULL (msg->env->x_comment_to)); >++ } >++ } >++#endif >+ mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); >+ mutt_paddstr (W, NONULL (msg->env->subject)); >+ draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); >+@@ -499,6 +553,12 @@ int mutt_compose_menu (HEADER *msg, /* >+ /* Sort, SortAux could be changed in mutt_index_menu() */ >+ int oldSort, oldSortAux; >+ struct stat st; >++#ifdef USE_NNTP >++ int news = 0; /* is it a news article ? */ >++ >++ if (option (OPTNEWSSEND)) >++ news++; >++#endif >+ >+ mutt_attach_init (msg->content); >+ idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1); >+@@ -509,10 +569,18 @@ int mutt_compose_menu (HEADER *msg, /* >+ menu->make_entry = snd_entry; >+ menu->tag = mutt_tag_attach; >+ menu->data = idx; >++#ifdef USE_NNTP >++ if (news) >++ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp); >++ else >++#endif >+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp); >+ >+ while (loop) >+ { >++#ifdef USE_NNTP >++ unset_option (OPTNEWS); /* for any case */ >++#endif >+ switch (op = mutt_menuLoop (menu)) >+ { >+ case OP_REDRAW: >+@@ -525,17 +593,90 @@ int mutt_compose_menu (HEADER *msg, /* >+ mutt_message_hook (NULL, msg, M_SEND2HOOK); >+ break; >+ case OP_COMPOSE_EDIT_TO: >++#ifdef USE_NNTP >++ if (news) >++ break; >++#endif >+ menu->redraw = edit_address_list (HDR_TO, &msg->env->to); >+ mutt_message_hook (NULL, msg, M_SEND2HOOK); >+ break; >+ case OP_COMPOSE_EDIT_BCC: >++#ifdef USE_NNTP >++ if (news) >++ break; >++#endif >+ menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc); >+ mutt_message_hook (NULL, msg, M_SEND2HOOK); >+ break; >+ case OP_COMPOSE_EDIT_CC: >++#ifdef USE_NNTP >++ if (news) >++ break; >++#endif >+ menu->redraw = edit_address_list (HDR_CC, &msg->env->cc); >+ mutt_message_hook (NULL, msg, M_SEND2HOOK); >+ break; >++#ifdef USE_NNTP >++ case OP_COMPOSE_EDIT_NEWSGROUPS: >++ if (news) >++ { >++ if (msg->env->newsgroups) >++ strfcpy (buf, msg->env->newsgroups, sizeof (buf)); >++ else >++ buf[0] = 0; >++ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && >++ buf[0]) >++ { >++ FREE (&msg->env->newsgroups); >++ mutt_remove_trailing_ws (buf); >++ msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf)); >++ move (HDR_TO, HDR_XOFFSET); >++ clrtoeol (); >++ if (msg->env->newsgroups) >++ printw ("%-*.*s", W, W, msg->env->newsgroups); >++ } >++ } >++ break; >++ >++ case OP_COMPOSE_EDIT_FOLLOWUP_TO: >++ if (news) >++ { >++ buf[0] = 0; >++ if (msg->env->followup_to) >++ strfcpy (buf, msg->env->followup_to, sizeof (buf)); >++ if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && >++ buf[0]) >++ { >++ FREE (&msg->env->followup_to); >++ mutt_remove_trailing_ws (buf); >++ msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf)); >++ move (HDR_CC, HDR_XOFFSET); >++ clrtoeol (); >++ if (msg->env->followup_to) >++ printw ("%-*.*s", W, W, msg->env->followup_to); >++ } >++ } >++ break; >++ >++ case OP_COMPOSE_EDIT_X_COMMENT_TO: >++ if (news && option (OPTXCOMMENTTO)) >++ { >++ buf[0] = 0; >++ if (msg->env->x_comment_to) >++ strfcpy (buf, msg->env->x_comment_to, sizeof (buf)); >++ if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && >++ buf[0]) >++ { >++ FREE (&msg->env->x_comment_to); >++ msg->env->x_comment_to = safe_strdup (buf); >++ move (HDR_BCC, HDR_XOFFSET); >++ clrtoeol (); >++ if (msg->env->x_comment_to) >++ printw ("%-*.*s", W, W, msg->env->x_comment_to); >++ } >++ } >++ break; >++#endif >+ case OP_COMPOSE_EDIT_SUBJECT: >+ if (msg->env->subject) >+ strfcpy (buf, msg->env->subject, sizeof (buf)); >+@@ -699,6 +840,9 @@ int mutt_compose_menu (HEADER *msg, /* >+ break; >+ >+ case OP_COMPOSE_ATTACH_MESSAGE: >++#ifdef USE_NNTP >++ case OP_COMPOSE_ATTACH_NEWS_MESSAGE: >++#endif >+ { >+ char *prompt; >+ HEADER *h; >+@@ -706,7 +850,22 @@ int mutt_compose_menu (HEADER *msg, /* >+ fname[0] = 0; >+ prompt = _("Open mailbox to attach message from"); >+ >++#ifdef USE_NNTP >++ unset_option (OPTNEWS); >++ if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE) >++ { >++ if (!(CurrentNewsSrv = nntp_select_server (NewsServer, 0))) >++ break; >++ >++ prompt = _("Open newsgroup to attach message from"); >++ set_option (OPTNEWS); >++ } >++#endif >++ >+ if (Context) >++#ifdef USE_NNTP >++ if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP)) >++#endif >+ { >+ strfcpy (fname, NONULL (Context->path), sizeof (fname)); >+ mutt_pretty_mailbox (fname, sizeof (fname)); >+@@ -715,6 +874,11 @@ int mutt_compose_menu (HEADER *msg, /* >+ if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0]) >+ break; >+ >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account); >++ else >++#endif >+ mutt_expand_path (fname, sizeof (fname)); >+ #ifdef USE_IMAP >+ if (!mx_is_imap (fname)) >+@@ -722,6 +886,9 @@ int mutt_compose_menu (HEADER *msg, /* >+ #ifdef USE_POP >+ if (!mx_is_pop (fname)) >+ #endif >++#ifdef USE_NNTP >++ if (!mx_is_nntp (fname) && !option (OPTNEWS)) >++#endif >+ /* check to make sure the file exists and is readable */ >+ if (access (fname, R_OK) == -1) >+ { >+diff -udprP mutt-1.5.23.orig/config.h.in mutt-1.5.23/config.h.in >+--- mutt-1.5.23.orig/config.h.in 2014-03-12 18:27:54.000000000 +0200 >++++ mutt-1.5.23/config.h.in 2014-03-13 12:48:36.000000000 +0200 >+@@ -574,6 +574,9 @@ >+ /* Define if you want support for the IMAP protocol. */ >+ #undef USE_IMAP >+ >++/* Define if you want support for the NNTP protocol. */ >++#undef USE_NNTP >++ >+ /* Define if you want support for the POP3 protocol. */ >+ #undef USE_POP >+ >+diff -udprP mutt-1.5.23.orig/configure.ac mutt-1.5.23/configure.ac >+--- mutt-1.5.23.orig/configure.ac 2014-03-12 18:26:40.000000000 +0200 >++++ mutt-1.5.23/configure.ac 2014-03-13 12:48:36.000000000 +0200 >+@@ -592,6 +592,15 @@ AC_ARG_ENABLE(imap, AS_HELP_STRING([--en >+ ]) >+ AM_CONDITIONAL(BUILD_IMAP, test x$need_imap = xyes) >+ >++AC_ARG_ENABLE(nntp, AC_HELP_STRING([--enable-nntp],[Enable NNTP support]), >++[ if test x$enableval = xyes ; then >++ AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ]) >++ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o" >++ need_nntp="yes" >++ need_socket="yes" >++ fi >++]) >++ >+ AC_ARG_ENABLE(smtp, AS_HELP_STRING([--enable-smtp],[include internal SMTP relay support]), >+ [if test $enableval = yes; then >+ AC_DEFINE(USE_SMTP, 1, [Include internal SMTP relay support]) >+@@ -599,7 +608,7 @@ AC_ARG_ENABLE(smtp, AS_HELP_STRING([--en >+ need_socket="yes" >+ fi]) >+ >+-if test x"$need_imap" = xyes -o x"$need_pop" = xyes ; then >++if test x"$need_imap" = xyes -o x"$need_pop" = xyes -o x"$need_nntp" = xyes ; then >+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o" >+ fi >+ >+diff -udprP mutt-1.5.23.orig/curs_main.c mutt-1.5.23/curs_main.c >+--- mutt-1.5.23.orig/curs_main.c 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23/curs_main.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -22,6 +22,7 @@ >+ >+ #include "mutt.h" >+ #include "mutt_curses.h" >++#include "mx.h" >+ #include "mutt_menu.h" >+ #include "mailbox.h" >+ #include "mapping.h" >+@@ -38,6 +39,10 @@ >+ >+ #include "mutt_crypt.h" >+ >++#ifdef USE_NNTP >++#include "nntp.h" >++#endif >++ >+ >+ #include <ctype.h> >+ #include <stdlib.h> >+@@ -413,12 +418,27 @@ static const struct mapping_t IndexHelp[ >+ { NULL, 0 } >+ }; >+ >++#ifdef USE_NNTP >++struct mapping_t IndexNewsHelp[] = { >++ { N_("Quit"), OP_QUIT }, >++ { N_("Del"), OP_DELETE }, >++ { N_("Undel"), OP_UNDELETE }, >++ { N_("Save"), OP_SAVE }, >++ { N_("Post"), OP_POST }, >++ { N_("Followup"), OP_FOLLOWUP }, >++ { N_("Catchup"), OP_CATCHUP }, >++ { N_("Help"), OP_HELP }, >++ { NULL, 0 } >++}; >++#endif >++ >+ /* This function handles the message index window as well as commands returned >+ * from the pager (MENU_PAGER). >+ */ >+ int mutt_index_menu (void) >+ { >+ char buf[LONG_STRING], helpstr[LONG_STRING]; >++ int flags; >+ int op = OP_NULL; >+ int done = 0; /* controls when to exit the "event" loop */ >+ int i = 0, j; >+@@ -439,7 +459,11 @@ int mutt_index_menu (void) >+ menu->make_entry = index_make_entry; >+ menu->color = index_color; >+ menu->current = ci_first_message (); >+- menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp); >++ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, >++#ifdef USE_NNTP >++ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : >++#endif >++ IndexHelp); >+ >+ if (!attach_msg) >+ mutt_buffy_check(1); /* force the buffy check after we enter the folder */ >+@@ -680,6 +704,9 @@ int mutt_index_menu (void) >+ mutt_curs_set (1); /* fallback from the pager */ >+ } >+ >++#ifdef USE_NNTP >++ unset_option (OPTNEWS); /* for any case */ >++#endif >+ switch (op) >+ { >+ >+@@ -730,6 +757,161 @@ int mutt_index_menu (void) >+ menu_current_bottom (menu); >+ break; >+ >++#ifdef USE_NNTP >++ case OP_GET_PARENT: >++ CHECK_MSGCOUNT; >++ CHECK_VISIBLE; >++ >++ case OP_GET_MESSAGE: >++ CHECK_IN_MAILBOX; >++ CHECK_READONLY; >++ CHECK_ATTACH; >++ if (Context->magic == M_NNTP) >++ { >++ HEADER *hdr; >++ >++ if (op == OP_GET_MESSAGE) >++ { >++ buf[0] = 0; >++ if (mutt_get_field (_("Enter Message-Id: "), >++ buf, sizeof (buf), 0) != 0 || !buf[0]) >++ break; >++ } >++ else >++ { >++ LIST *ref = CURHDR->env->references; >++ if (!ref) >++ { >++ mutt_error _("Article has no parent reference."); >++ break; >++ } >++ strfcpy (buf, ref->data, sizeof (buf)); >++ } >++ if (!Context->id_hash) >++ Context->id_hash = mutt_make_id_hash (Context); >++ hdr = hash_find (Context->id_hash, buf); >++ if (hdr) >++ { >++ if (hdr->virtual != -1) >++ { >++ menu->current = hdr->virtual; >++ menu->redraw = REDRAW_MOTION_RESYNCH; >++ } >++ else if (hdr->collapsed) >++ { >++ mutt_uncollapse_thread (Context, hdr); >++ mutt_set_virtual (Context); >++ menu->current = hdr->virtual; >++ menu->redraw = REDRAW_MOTION_RESYNCH; >++ } >++ else >++ mutt_error _("Message is not visible in limited view."); >++ } >++ else >++ { >++ int rc; >++ >++ mutt_message (_("Fetching %s from server..."), buf); >++ rc = nntp_check_msgid (Context, buf); >++ if (rc == 0) >++ { >++ hdr = Context->hdrs[Context->msgcount - 1]; >++ mutt_sort_headers (Context, 0); >++ menu->current = hdr->virtual; >++ menu->redraw = REDRAW_FULL; >++ } >++ else if (rc > 0) >++ mutt_error (_("Article %s not found on the server."), buf); >++ } >++ } >++ break; >++ >++ case OP_GET_CHILDREN: >++ case OP_RECONSTRUCT_THREAD: >++ CHECK_MSGCOUNT; >++ CHECK_VISIBLE; >++ CHECK_READONLY; >++ CHECK_ATTACH; >++ if (Context->magic == M_NNTP) >++ { >++ int oldmsgcount = Context->msgcount; >++ int oldindex = CURHDR->index; >++ int rc = 0; >++ >++ if (!CURHDR->env->message_id) >++ { >++ mutt_error _("No Message-Id. Unable to perform operation."); >++ break; >++ } >++ >++ mutt_message _("Fetching message headers..."); >++ if (!Context->id_hash) >++ Context->id_hash = mutt_make_id_hash (Context); >++ strfcpy (buf, CURHDR->env->message_id, sizeof (buf)); >++ >++ /* trying to find msgid of the root message */ >++ if (op == OP_RECONSTRUCT_THREAD) >++ { >++ LIST *ref = CURHDR->env->references; >++ while (ref) >++ { >++ if (hash_find (Context->id_hash, ref->data) == NULL) >++ { >++ rc = nntp_check_msgid (Context, ref->data); >++ if (rc < 0) >++ break; >++ } >++ >++ /* the last msgid in References is the root message */ >++ if (!ref->next) >++ strfcpy (buf, ref->data, sizeof (buf)); >++ ref = ref->next; >++ } >++ } >++ >++ /* fetching all child messages */ >++ if (rc >= 0) >++ rc = nntp_check_children (Context, buf); >++ >++ /* at least one message has been loaded */ >++ if (Context->msgcount > oldmsgcount) >++ { >++ HEADER *hdr; >++ int i, quiet = Context->quiet; >++ >++ if (rc < 0) >++ Context->quiet = 1; >++ mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD)); >++ Context->quiet = quiet; >++ >++ /* if the root message was retrieved, move to it */ >++ hdr = hash_find (Context->id_hash, buf); >++ if (hdr) >++ menu->current = hdr->virtual; >++ >++ /* try to restore old position */ >++ else >++ { >++ for (i = 0; i < Context->msgcount; i++) >++ { >++ if (Context->hdrs[i]->index == oldindex) >++ { >++ menu->current = Context->hdrs[i]->virtual; >++ /* as an added courtesy, recenter the menu >++ * with the current entry at the middle of the screen */ >++ menu_check_recenter (menu); >++ menu_current_middle (menu); >++ } >++ } >++ } >++ menu->redraw = REDRAW_FULL; >++ } >++ else if (rc >= 0) >++ mutt_error _("No deleted messages found in the thread."); >++ } >++ break; >++#endif >++ >+ case OP_JUMP: >+ >+ CHECK_MSGCOUNT; >+@@ -826,11 +1008,33 @@ int mutt_index_menu (void) >+ break; >+ >+ case OP_MAIN_LIMIT: >++ case OP_TOGGLE_READ: >+ >+ CHECK_IN_MAILBOX; >+ menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ? >+ CURHDR->index : -1; >+- if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0) >++ if (op == OP_TOGGLE_READ) >++ { >++ char buf[LONG_STRING]; >++ >++ if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0) >++ { >++ snprintf (buf, sizeof (buf), "!~R!~D~s%s", >++ Context->pattern ? Context->pattern : ".*"); >++ set_option (OPTHIDEREAD); >++ } >++ else >++ { >++ strfcpy (buf, Context->pattern + 8, sizeof(buf)); >++ if (!*buf || strncmp (buf, ".*", 2) == 0) >++ snprintf (buf, sizeof(buf), "~A"); >++ unset_option (OPTHIDEREAD); >++ } >++ FREE (&Context->pattern); >++ Context->pattern = safe_strdup (buf); >++ } >++ if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) || >++ mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0) >+ { >+ if (menu->oldcurrent >= 0) >+ { >+@@ -1072,15 +1276,22 @@ int mutt_index_menu (void) >+ >+ case OP_MAIN_CHANGE_FOLDER: >+ case OP_MAIN_NEXT_UNREAD_MAILBOX: >+- >+- if (attach_msg) >+- op = OP_MAIN_CHANGE_FOLDER_READONLY; >+- >+- /* fallback to the readonly case */ >+- >+ case OP_MAIN_CHANGE_FOLDER_READONLY: >++#ifdef USE_NNTP >++ case OP_MAIN_CHANGE_GROUP: >++ case OP_MAIN_CHANGE_GROUP_READONLY: >++ unset_option (OPTNEWS); >++#endif >++ if (attach_msg || option (OPTREADONLY) || >++#ifdef USE_NNTP >++ op == OP_MAIN_CHANGE_GROUP_READONLY || >++#endif >++ op == OP_MAIN_CHANGE_FOLDER_READONLY) >++ flags = M_READONLY; >++ else >++ flags = 0; >+ >+- if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY)) >++ if (flags) >+ cp = _("Open mailbox in read-only mode"); >+ else >+ cp = _("Open mailbox"); >+@@ -1099,6 +1310,22 @@ int mutt_index_menu (void) >+ } >+ else >+ { >++#ifdef USE_NNTP >++ if (op == OP_MAIN_CHANGE_GROUP || >++ op == OP_MAIN_CHANGE_GROUP_READONLY) >++ { >++ set_option (OPTNEWS); >++ CurrentNewsSrv = nntp_select_server (NewsServer, 0); >++ if (!CurrentNewsSrv) >++ break; >++ if (flags) >++ cp = _("Open newsgroup in read-only mode"); >++ else >++ cp = _("Open newsgroup"); >++ nntp_buffy (buf, sizeof (buf)); >++ } >++ else >++#endif >+ mutt_buffy (buf, sizeof (buf)); >+ >+ if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) >+@@ -1118,6 +1345,14 @@ int mutt_index_menu (void) >+ } >+ } >+ >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ { >++ unset_option (OPTNEWS); >++ nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account); >++ } >++ else >++#endif >+ mutt_expand_path (buf, sizeof (buf)); >+ if (mx_get_magic (buf) <= 0) >+ { >+@@ -1159,15 +1394,18 @@ int mutt_index_menu (void) >+ CurrentMenu = MENU_MAIN; >+ mutt_folder_hook (buf); >+ >+- if ((Context = mx_open_mailbox (buf, >+- (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ? >+- M_READONLY : 0, NULL)) != NULL) >++ if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL) >+ { >+ menu->current = ci_first_message (); >+ } >+ else >+ menu->current = 0; >+ >++#ifdef USE_NNTP >++ /* mutt_buffy_check() must be done with mail-reader mode! */ >++ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, >++ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp); >++#endif >+ mutt_clear_error (); >+ mutt_buffy_check(1); /* force the buffy check after we have changed >+ the folder */ >+@@ -1236,6 +1474,7 @@ int mutt_index_menu (void) >+ CHECK_MSGCOUNT; >+ CHECK_VISIBLE; >+ CHECK_READONLY; >++ CHECK_ACL(M_ACL_WRITE, _("break thread")); >+ >+ if ((Sort & SORT_MASK) != SORT_THREADS) >+ mutt_error _("Threading is not enabled."); >+@@ -1270,7 +1509,7 @@ int mutt_index_menu (void) >+ CHECK_MSGCOUNT; >+ CHECK_VISIBLE; >+ CHECK_READONLY; >+- CHECK_ACL(M_ACL_DELETE, _("link threads")); >++ CHECK_ACL(M_ACL_WRITE, _("link threads")); >+ >+ if ((Sort & SORT_MASK) != SORT_THREADS) >+ mutt_error _("Threading is not enabled."); >+@@ -1887,6 +2126,20 @@ int mutt_index_menu (void) >+ } >+ break; >+ >++#ifdef USE_NNTP >++ case OP_CATCHUP: >++ CHECK_MSGCOUNT; >++ CHECK_READONLY; >++ CHECK_ATTACH >++ if (Context && Context->magic == M_NNTP) >++ { >++ NNTP_DATA *nntp_data = Context->data; >++ if (mutt_newsgroup_catchup (nntp_data->nserv, nntp_data->group)) >++ menu->redraw = REDRAW_INDEX | REDRAW_STATUS; >++ } >++ break; >++#endif >++ >+ case OP_DISPLAY_ADDRESS: >+ >+ CHECK_MSGCOUNT; >+@@ -2091,6 +2344,39 @@ int mutt_index_menu (void) >+ menu->redraw = REDRAW_FULL; >+ break; >+ >++#ifdef USE_NNTP >++ case OP_FOLLOWUP: >++ case OP_FORWARD_TO_GROUP: >++ >++ CHECK_MSGCOUNT; >++ CHECK_VISIBLE; >++ >++ case OP_POST: >++ >++ CHECK_ATTACH; >++ if (op != OP_FOLLOWUP || !CURHDR->env->followup_to || >++ mutt_strcasecmp (CURHDR->env->followup_to, "poster") || >++ query_quadoption (OPT_FOLLOWUPTOPOSTER, >++ _("Reply by mail as poster prefers?")) != M_YES) >++ { >++ if (Context && Context->magic == M_NNTP && >++ !((NNTP_DATA *)Context->data)->allowed && >++ query_quadoption (OPT_TOMODERATED, >++ _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) >++ break; >++ if (op == OP_POST) >++ ci_send_message (SENDNEWS, NULL, NULL, Context, NULL); >++ else >++ { >++ CHECK_MSGCOUNT; >++ ci_send_message ((op == OP_FOLLOWUP ? SENDREPLY : SENDFORWARD) | >++ SENDNEWS, NULL, NULL, Context, tag ? NULL : CURHDR); >++ } >++ menu->redraw = REDRAW_FULL; >++ break; >++ } >++#endif >++ >+ case OP_REPLY: >+ >+ CHECK_ATTACH; >+diff -udprP mutt-1.5.23.orig/doc/manual.xml.head mutt-1.5.23/doc/manual.xml.head >+--- mutt-1.5.23.orig/doc/manual.xml.head 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/doc/manual.xml.head 2014-03-13 12:48:36.000000000 +0200 >+@@ -1694,6 +1694,26 @@ See also the <link linkend="postpone">$p >+ >+ </sect1> >+ >++<sect1 id="nntp"> >++<title>Reading news via NNTP</title> >++ >++<para> >++If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can >++read news from news server via NNTP. You can open a newsgroup with >++function ``change-newsgroup'' (default: ``i''). Default news server >++can be obtained from <literal>$NNTPSERVER</literal> environment >++variable or from <literal>/etc/nntpserver</literal> file. Like other >++news readers, info about subscribed newsgroups is saved in file by >++<link linkend="newsrc">$newsrc</link> variable. The variable <link >++linkend="news-cache-dir">$news_cache_dir</link> can be used to point >++to a directory. Mutt will create a hierarchy of subdirectories named >++like the account and newsgroup the cache is for. Also the hierarchy >++is used to store header cache if Mutt was compiled with <link >++linkend="header-caching">header cache</link> support. >++</para> >++ >++</sect1> >++ >+ </chapter> >+ >+ <chapter id="configuration"> >+diff -udprP mutt-1.5.23.orig/doc/mutt.man mutt-1.5.23/doc/mutt.man >+--- mutt-1.5.23.orig/doc/mutt.man 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/doc/mutt.man 2014-03-13 12:48:36.000000000 +0200 >+@@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent >+ .SH SYNOPSIS >+ .PP >+ .B mutt >+-[\-nRyzZ] >+-[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-m \fItype\fP] [\-f \fIfile\fP] >++[\-GnRyzZ] >++[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-g \fIserver\fP] [\-m \fItype\fP] [\-f \fIfile\fP] >+ .PP >+ .B mutt >+ [\-nx] >+@@ -101,6 +101,10 @@ files. >+ Specify which mailbox to load. >+ .IP "-F \fImuttrc\fP" >+ Specify an initialization file to read instead of ~/.muttrc >++.IP "-g \fIserver\fP" >++Start Mutt with a listing of subscribed newsgroups at specified news server. >++.IP "-G" >++Start Mutt with a listing of subscribed newsgroups. >+ .IP "-h" >+ Display help. >+ .IP "-H \fIdraft\fP" >+diff -udprP mutt-1.5.23.orig/functions.h mutt-1.5.23/functions.h >+--- mutt-1.5.23.orig/functions.h 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/functions.h 2014-03-13 12:48:36.000000000 +0200 >+@@ -88,6 +88,10 @@ const struct binding_t OpMain[] = { /* m >+ { "break-thread", OP_MAIN_BREAK_THREAD, "#" }, >+ { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" }, >+ { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" }, >++#ifdef USE_NNTP >++ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" }, >++ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" }, >++#endif >+ { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL }, >+ { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" }, >+ { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" }, >+@@ -101,7 +105,15 @@ const struct binding_t OpMain[] = { /* m >+ { "edit", OP_EDIT_MESSAGE, "e" }, >+ { "edit-type", OP_EDIT_TYPE, "\005" }, >+ { "forward-message", OP_FORWARD_MESSAGE, "f" }, >+- { "flag-message", OP_FLAG_MESSAGE, "F" }, >++#ifdef USE_NNTP >++ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" }, >++ { "followup-message", OP_FOLLOWUP, "F" }, >++ { "get-children", OP_GET_CHILDREN, NULL }, >++ { "get-message", OP_GET_MESSAGE, "\007" }, >++ { "get-parent", OP_GET_PARENT, "\033G" }, >++ { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL }, >++#endif >++ { "flag-message", OP_FLAG_MESSAGE, "\033f" }, >+ { "group-reply", OP_GROUP_REPLY, "g" }, >+ #ifdef USE_POP >+ { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" }, >+@@ -128,6 +140,9 @@ const struct binding_t OpMain[] = { /* m >+ { "sort-mailbox", OP_SORT, "o" }, >+ { "sort-reverse", OP_SORT_REVERSE, "O" }, >+ { "print-message", OP_PRINT, "p" }, >++#ifdef USE_NNTP >++ { "post-message", OP_POST, "P" }, >++#endif >+ { "previous-thread", OP_MAIN_PREV_THREAD, "\020" }, >+ { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" }, >+ { "recall-message", OP_RECALL_MESSAGE, "R" }, >+@@ -147,6 +162,10 @@ const struct binding_t OpMain[] = { /* m >+ { "show-version", OP_VERSION, "V" }, >+ { "set-flag", OP_MAIN_SET_FLAG, "w" }, >+ { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" }, >++ { "toggle-read", OP_TOGGLE_READ, "X" }, >++#ifdef USE_NNTP >++ { "catchup", OP_CATCHUP, "y" }, >++#endif >+ { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S }, >+ { "buffy-list", OP_BUFFY_LIST, "." }, >+ { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" }, >+@@ -158,7 +177,7 @@ const struct binding_t OpMain[] = { /* m >+ { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" }, >+ { "next-unread", OP_MAIN_NEXT_UNREAD, NULL }, >+ { "previous-unread", OP_MAIN_PREV_UNREAD, NULL }, >+- { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" }, >++ { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL }, >+ >+ >+ { "extract-keys", OP_EXTRACT_KEYS, "\013" }, >+@@ -178,6 +197,10 @@ const struct binding_t OpPager[] = { /* >+ { "bounce-message", OP_BOUNCE_MESSAGE, "b" }, >+ { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" }, >+ { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" }, >++#ifdef USE_NNTP >++ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" }, >++ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" }, >++#endif >+ { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL }, >+ { "copy-message", OP_COPY_MESSAGE, "C" }, >+ { "decode-copy", OP_DECODE_COPY, "\033C" }, >+@@ -188,8 +211,12 @@ const struct binding_t OpPager[] = { /* >+ { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" }, >+ { "edit", OP_EDIT_MESSAGE, "e" }, >+ { "edit-type", OP_EDIT_TYPE, "\005" }, >++#ifdef USE_NNTP >++ { "followup-message", OP_FOLLOWUP, "F" }, >++ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" }, >++#endif >+ { "forward-message", OP_FORWARD_MESSAGE, "f" }, >+- { "flag-message", OP_FLAG_MESSAGE, "F" }, >++ { "flag-message", OP_FLAG_MESSAGE, "\033f" }, >+ { "group-reply", OP_GROUP_REPLY, "g" }, >+ #ifdef USE_IMAP >+ { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL }, >+@@ -211,6 +238,9 @@ const struct binding_t OpPager[] = { /* >+ { "sort-mailbox", OP_SORT, "o" }, >+ { "sort-reverse", OP_SORT_REVERSE, "O" }, >+ { "print-message", OP_PRINT, "p" }, >++#ifdef USE_NNTP >++ { "post-message", OP_POST, "P" }, >++#endif >+ { "previous-thread", OP_MAIN_PREV_THREAD, "\020" }, >+ { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" }, >+ { "quit", OP_QUIT, "Q" }, >+@@ -258,7 +288,7 @@ const struct binding_t OpPager[] = { /* >+ { "half-down", OP_HALF_DOWN, NULL }, >+ { "previous-line", OP_PREV_LINE, NULL }, >+ { "bottom", OP_PAGER_BOTTOM, NULL }, >+- { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" }, >++ { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL }, >+ >+ >+ >+@@ -279,6 +309,10 @@ const struct binding_t OpAttach[] = { /* >+ { "bounce-message", OP_BOUNCE_MESSAGE, "b" }, >+ { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" }, >+ { "edit-type", OP_EDIT_TYPE, "\005" }, >++#ifdef USE_NNTP >++ { "followup-message", OP_FOLLOWUP, "F" }, >++ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" }, >++#endif >+ { "print-entry", OP_PRINT, "p" }, >+ { "save-entry", OP_SAVE, "s" }, >+ { "pipe-entry", OP_PIPE, "|" }, >+@@ -304,6 +338,7 @@ const struct binding_t OpAttach[] = { /* >+ const struct binding_t OpCompose[] = { /* map: compose */ >+ { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" }, >+ { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" }, >++ { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" }, >+ { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" }, >+ { "edit-cc", OP_COMPOSE_EDIT_CC, "c" }, >+ { "copy-file", OP_SAVE, "C" }, >+@@ -323,6 +358,11 @@ const struct binding_t OpCompose[] = { / >+ { "print-entry", OP_PRINT, "l" }, >+ { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" }, >+ { "new-mime", OP_COMPOSE_NEW_MIME, "n" }, >++#ifdef USE_NNTP >++ { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" }, >++ { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" }, >++ { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" }, >++#endif >+ { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" }, >+ { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" }, >+ { "rename-file", OP_COMPOSE_RENAME_FILE, "R" }, >+@@ -374,14 +414,25 @@ const struct binding_t OpBrowser[] = { / >+ { "select-new", OP_BROWSER_NEW_FILE, "N" }, >+ { "check-new", OP_CHECK_NEW, NULL }, >+ { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" }, >++#ifdef USE_NNTP >++ { "reload-active", OP_LOAD_ACTIVE, "g" }, >++ { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" }, >++ { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" }, >++ { "catchup", OP_CATCHUP, "y" }, >++ { "uncatchup", OP_UNCATCHUP, "Y" }, >++#endif >+ { "view-file", OP_BROWSER_VIEW_FILE, " " }, >+ { "buffy-list", OP_BUFFY_LIST, "." }, >+ #ifdef USE_IMAP >+ { "create-mailbox", OP_CREATE_MAILBOX, "C" }, >+ { "delete-mailbox", OP_DELETE_MAILBOX, "d" }, >+ { "rename-mailbox", OP_RENAME_MAILBOX, "r" }, >++#endif >++#if defined USE_IMAP || defined USE_NNTP >+ { "subscribe", OP_BROWSER_SUBSCRIBE, "s" }, >+ { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" }, >++#endif >++#ifdef USE_IMAP >+ { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" }, >+ #endif >+ { NULL, 0, NULL } >+diff -udprP mutt-1.5.23.orig/globals.h mutt-1.5.23/globals.h >+--- mutt-1.5.23.orig/globals.h 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23/globals.h 2014-03-13 12:48:36.000000000 +0200 >+@@ -95,6 +95,17 @@ WHERE char *MixEntryFormat; >+ #endif >+ >+ WHERE char *Muttrc INITVAL (NULL); >++#ifdef USE_NNTP >++WHERE char *GroupFormat; >++WHERE char *Inews; >++WHERE char *NewsCacheDir; >++WHERE char *NewsServer; >++WHERE char *NewsgroupsCharset; >++WHERE char *NewsRc; >++WHERE char *NntpAuthenticators; >++WHERE char *NntpUser; >++WHERE char *NntpPass; >++#endif >+ WHERE char *Outbox; >+ WHERE char *Pager; >+ WHERE char *PagerFmt; >+@@ -188,6 +199,11 @@ extern unsigned char QuadOptions[]; >+ >+ WHERE unsigned short Counter INITVAL (0); >+ >++#ifdef USE_NNTP >++WHERE short NewsPollTimeout; >++WHERE short NntpContext; >++#endif >++ >+ WHERE short ConnectTimeout; >+ WHERE short HistSize; >+ WHERE short MenuContext; >+diff -udprP mutt-1.5.23.orig/hash.c mutt-1.5.23/hash.c >+--- mutt-1.5.23.orig/hash.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/hash.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -57,6 +57,7 @@ HASH *hash_create (int nelem, int lower) >+ if (nelem == 0) >+ nelem = 2; >+ table->nelem = nelem; >++ table->curnelem = 0; >+ table->table = safe_calloc (nelem, sizeof (struct hash_elem *)); >+ if (lower) >+ { >+@@ -71,6 +72,29 @@ HASH *hash_create (int nelem, int lower) >+ return table; >+ } >+ >++HASH *hash_resize (HASH *ptr, int nelem, int lower) >++{ >++ HASH *table; >++ struct hash_elem *elem, *tmp; >++ int i; >++ >++ table = hash_create (nelem, lower); >++ >++ for (i = 0; i < ptr->nelem; i++) >++ { >++ for (elem = ptr->table[i]; elem; ) >++ { >++ tmp = elem; >++ elem = elem->next; >++ hash_insert (table, tmp->key, tmp->data, 1); >++ FREE (&tmp); >++ } >++ } >++ FREE (&ptr->table); >++ FREE (&ptr); >++ return table; >++} >++ >+ /* table hash table to update >+ * key key to hash on >+ * data data to associate with `key' >+@@ -90,6 +114,7 @@ int hash_insert (HASH * table, const cha >+ { >+ ptr->next = table->table[h]; >+ table->table[h] = ptr; >++ table->curnelem++; >+ } >+ else >+ { >+@@ -112,6 +137,7 @@ int hash_insert (HASH * table, const cha >+ else >+ table->table[h] = ptr; >+ ptr->next = tmp; >++ table->curnelem++; >+ } >+ return h; >+ } >+@@ -142,6 +168,7 @@ void hash_delete_hash (HASH * table, int >+ if (destroy) >+ destroy (ptr->data); >+ FREE (&ptr); >++ table->curnelem--; >+ >+ ptr = *last; >+ } >+diff -udprP mutt-1.5.23.orig/hash.h mutt-1.5.23/hash.h >+--- mutt-1.5.23.orig/hash.h 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/hash.h 2014-03-13 12:48:36.000000000 +0200 >+@@ -28,7 +28,7 @@ struct hash_elem >+ >+ typedef struct >+ { >+- int nelem; >++ int nelem, curnelem; >+ struct hash_elem **table; >+ unsigned int (*hash_string)(const unsigned char *, unsigned int); >+ int (*cmp_string)(const char *, const char *); >+@@ -41,6 +41,7 @@ HASH; >+ >+ HASH *hash_create (int nelem, int lower); >+ int hash_insert (HASH * table, const char *key, void *data, int allow_dup); >++HASH *hash_resize (HASH * table, int nelem, int lower); >+ void *hash_find_hash (const HASH * table, int hash, const char *key); >+ void hash_delete_hash (HASH * table, int hash, const char *key, const void *data, >+ void (*destroy) (void *)); >+diff -udprP mutt-1.5.23.orig/hcache.c mutt-1.5.23/hcache.c >+--- mutt-1.5.23.orig/hcache.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/hcache.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -447,6 +447,12 @@ dump_envelope(ENVELOPE * e, unsigned cha >+ d = dump_list(e->in_reply_to, d, off, 0); >+ d = dump_list(e->userhdrs, d, off, convert); >+ >++#ifdef USE_NNTP >++ d = dump_char(e->xref, d, off, 0); >++ d = dump_char(e->followup_to, d, off, 0); >++ d = dump_char(e->x_comment_to, d, off, convert); >++#endif >++ >+ return d; >+ } >+ >+@@ -483,6 +489,12 @@ restore_envelope(ENVELOPE * e, const uns >+ restore_list(&e->references, d, off, 0); >+ restore_list(&e->in_reply_to, d, off, 0); >+ restore_list(&e->userhdrs, d, off, convert); >++ >++#ifdef USE_NNTP >++ restore_char(&e->xref, d, off, 0); >++ restore_char(&e->followup_to, d, off, 0); >++ restore_char(&e->x_comment_to, d, off, convert); >++#endif >+ } >+ >+ static int >+diff -udprP mutt-1.5.23.orig/hdrline.c mutt-1.5.23/hdrline.c >+--- mutt-1.5.23.orig/hdrline.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/hdrline.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -211,6 +211,7 @@ int mutt_user_is_recipient (HEADER *h) >+ * %E = number of messages in current thread >+ * %f = entire from line >+ * %F = like %n, unless from self >++ * %g = newsgroup name (if compiled with NNTP support) >+ * %i = message-id >+ * %l = number of lines in the message >+ * %L = like %F, except `lists' are displayed first >+@@ -219,12 +220,14 @@ int mutt_user_is_recipient (HEADER *h) >+ * %N = score >+ * %O = like %L, except using address instead of name >+ * %P = progress indicator for builtin pager >++ * %R = `x-comment-to:' field (if present and compiled with NNTP support) >+ * %s = subject >+ * %S = short message status (e.g., N/O/D/!/r/-) >+ * %t = `to:' field (recipients) >+ * %T = $to_chars >+ * %u = user (login) name of author >+ * %v = first name of author, unless from self >++ * %W = where user is (organization) >+ * %X = number of MIME attachments >+ * %y = `x-label:' field (if present) >+ * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label) >+@@ -457,6 +460,12 @@ hdr_format_str (char *dest, >+ >+ break; >+ >++#ifdef USE_NNTP >++ case 'g': >++ mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : ""); >++ break; >++#endif >++ >+ case 'i': >+ mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>"); >+ break; >+@@ -548,6 +557,15 @@ hdr_format_str (char *dest, >+ strfcpy(dest, NONULL(hfi->pager_progress), destlen); >+ break; >+ >++#ifdef USE_NNTP >++ case 'R': >++ if (!optional) >++ mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : ""); >++ else if (!hdr->env->x_comment_to) >++ optional = 0; >++ break; >++#endif >++ >+ case 's': >+ >+ if (flags & M_FORMAT_TREE && !hdr->collapsed) >+@@ -637,6 +655,13 @@ hdr_format_str (char *dest, >+ mutt_format_s (dest, destlen, prefix, buf2); >+ break; >+ >++ case 'W': >++ if (!optional) >++ mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : ""); >++ else if (!hdr->env->organization) >++ optional = 0; >++ break; >++ >+ case 'Z': >+ >+ ch = ' '; >+diff -udprP mutt-1.5.23.orig/headers.c mutt-1.5.23/headers.c >+--- mutt-1.5.23.orig/headers.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/headers.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -114,6 +114,9 @@ void mutt_edit_headers (const char *edit >+ $edit_headers set, we remove References: as they're likely invalid; >+ we can simply compare strings as we don't generate References for >+ multiple Message-Ids in IRT anyways */ >++#ifdef USE_NNTP >++ if (!option (OPTNEWSSEND)) >++#endif >+ if (msg->env->in_reply_to && >+ (!n->in_reply_to || mutt_strcmp (n->in_reply_to->data, >+ msg->env->in_reply_to->data) != 0)) >+diff -udprP mutt-1.5.23.orig/init.c mutt-1.5.23/init.c >+--- mutt-1.5.23.orig/init.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/init.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -2980,6 +2980,28 @@ void mutt_init (int skip_sys_rc, LIST *c >+ else >+ Fqdn = safe_strdup(NONULL(Hostname)); >+ >++#ifdef USE_NNTP >++ { >++ FILE *f; >++ char *i; >++ >++ if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r"))) >++ { >++ buffer[0] = '\0'; >++ fgets (buffer, sizeof (buffer), f); >++ p = &buffer; >++ SKIPWS (p); >++ i = p; >++ while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++; >++ *i = '\0'; >++ NewsServer = safe_strdup (p); >++ fclose (f); >++ } >++ } >++ if ((p = getenv ("NNTPSERVER"))) >++ NewsServer = safe_strdup (p); >++#endif >++ >+ if ((p = getenv ("MAIL"))) >+ Spoolfile = safe_strdup (p); >+ else if ((p = getenv ("MAILDIR"))) >+diff -udprP mutt-1.5.23.orig/init.h mutt-1.5.23/init.h >+--- mutt-1.5.23.orig/init.h 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23/init.h 2014-03-13 12:48:36.000000000 +0200 >+@@ -176,6 +176,20 @@ struct option_t MuttVars[] = { >+ ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before >+ ** editing the body of an outgoing message. >+ */ >++#ifdef USE_NNTP >++ { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 }, >++ /* >++ ** .pp >++ ** If set, Mutt will prompt you for follow-up groups before editing >++ ** the body of an outgoing message. >++ */ >++ { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 }, >++ /* >++ ** .pp >++ ** If set, Mutt will prompt you for x-comment-to field before editing >++ ** the body of an outgoing message. >++ */ >++#endif >+ { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0}, >+ /* >+ ** .pp >+@@ -322,6 +336,14 @@ struct option_t MuttVars[] = { >+ ** follow these menus. The option is \fIunset\fP by default because many >+ ** visual terminals don't permit making the cursor invisible. >+ */ >++#ifdef USE_NNTP >++ { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES }, >++ /* >++ ** .pp >++ ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup >++ ** as read when you quit the newsgroup (catchup newsgroup). >++ */ >++#endif >+ #if defined(USE_SSL) >+ { "certificate_file", DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" }, >+ /* >+@@ -809,6 +831,16 @@ struct option_t MuttVars[] = { >+ ** sent to both the list and your address, resulting in two copies >+ ** of the same email for you. >+ */ >++#ifdef USE_NNTP >++ { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES }, >++ /* >++ ** .pp >++ ** If this variable is \fIset\fP and the keyword "poster" is present in >++ ** \fIFollowup-To\fP header, follow-up to newsgroup function is not >++ ** permitted. The message will be mailed to the submitter of the >++ ** message via mail. >++ */ >++#endif >+ { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 }, >+ /* >+ ** .pp >+@@ -891,6 +923,26 @@ struct option_t MuttVars[] = { >+ ** a regular expression that will match the whole name so mutt will expand >+ ** ``Franklin'' to ``Franklin, Steve''. >+ */ >++#ifdef USE_NNTP >++ { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" }, >++ /* >++ ** .pp >++ ** This variable allows you to customize the newsgroup browser display to >++ ** your personal taste. This string is similar to ``$index_format'', but >++ ** has its own set of printf()-like sequences: >++ ** .dl >++ ** .dt %C .dd current newsgroup number >++ ** .dt %d .dd description of newsgroup (becomes from server) >++ ** .dt %f .dd newsgroup name >++ ** .dt %M .dd - if newsgroup not allowed for direct post (moderated for example) >++ ** .dt %N .dd N if newsgroup is new, u if unsubscribed, blank otherwise >++ ** .dt %n .dd number of new articles in newsgroup >++ ** .dt %s .dd number of unread articles in newsgroup >++ ** .dt %>X .dd right justify the rest of the string and pad with character "X" >++ ** .dt %|X .dd pad to the end of the line with character "X" >++ ** .de >++ */ >++#endif >+ { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 }, >+ /* >+ */ >+@@ -1267,6 +1319,7 @@ struct option_t MuttVars[] = { >+ ** .dt %E .dd number of messages in current thread >+ ** .dt %f .dd sender (address + real name), either From: or Return-Path: >+ ** .dt %F .dd author name, or recipient name if the message is from you >++ ** .dt %g .dd newsgroup name (if compiled with NNTP support) >+ ** .dt %H .dd spam attribute(s) of this message >+ ** .dt %i .dd message-id of the current message >+ ** .dt %l .dd number of lines in the message (does not work with maildir, >+@@ -1282,12 +1335,14 @@ struct option_t MuttVars[] = { >+ ** stashed the message: list name or recipient name >+ ** if not sent to a list >+ ** .dt %P .dd progress indicator for the built-in pager (how much of the file has been displayed) >++ ** .dt %R .dd ``X-Comment-To:'' field (if present and compiled with NNTP support) >+ ** .dt %s .dd subject of the message >+ ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as) >+ ** .dt %t .dd ``To:'' field (recipients) >+ ** .dt %T .dd the appropriate character from the $$to_chars string >+ ** .dt %u .dd user (login) name of the author >+ ** .dt %v .dd first name of the author, or the recipient if the message is from you >++ ** .dt %W .dd name of organization of author (``Organization:'' field) >+ ** .dt %X .dd number of attachments >+ ** (please see the ``$attachments'' section for possible speed effects) >+ ** .dt %y .dd ``X-Label:'' field, if present >+@@ -1322,6 +1377,25 @@ struct option_t MuttVars[] = { >+ ** Note that these expandos are supported in >+ ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too. >+ */ >++#ifdef USE_NNTP >++ { "inews", DT_PATH, R_NONE, UL &Inews, UL "" }, >++ /* >++ ** .pp >++ ** If set, specifies the program and arguments used to deliver news posted >++ ** by Mutt. Otherwise, mutt posts article using current connection to >++ ** news server. The following printf-style sequence is understood: >++ ** .dl >++ ** .dt %a .dd account url >++ ** .dt %p .dd port >++ ** .dt %P .dd port if specified >++ ** .dt %s .dd news server name >++ ** .dt %S .dd url schema >++ ** .dt %u .dd username >++ ** .de >++ ** .pp >++ ** Example: set inews="/usr/local/bin/inews -hS" >++ */ >++#endif >+ { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL }, >+ /* >+ ** .pp >+@@ -1556,6 +1630,15 @@ struct option_t MuttVars[] = { >+ ** menu, attachments which cannot be decoded in a reasonable manner will >+ ** be attached to the newly composed message if this option is \fIset\fP. >+ */ >++#ifdef USE_NNTP >++ { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 }, >++ /* >++ ** .pp >++ ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be >++ ** encoded according to RFC2047 to base64. This is useful when message >++ ** is Usenet article, because MIME for news is nonstandard feature. >++ */ >++#endif >+ #ifdef MIXMASTER >+ { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" }, >+ /* >+@@ -1603,6 +1686,100 @@ struct option_t MuttVars[] = { >+ ** See also $$read_inc, $$write_inc and $$net_inc. >+ */ >+ #endif >++#ifdef USE_NNTP >++ { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" }, >++ /* >++ ** .pp >++ ** This variable pointing to directory where Mutt will save cached news >++ ** articles and headers in. If \fIunset\fP, articles and headers will not be >++ ** saved at all and will be reloaded from the server each time. >++ */ >++ { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 }, >++ /* >++ ** .pp >++ ** This variable specifies domain name or address of NNTP server. It >++ ** defaults to the news server specified in the environment variable >++ ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also >++ ** specify username and an alternative port for each news server, ie: >++ ** .pp >++ ** [[s]news://][username[:password]@]server[:port] >++ */ >++ { "newsgroups_charset", DT_STR, R_NONE, UL &NewsgroupsCharset, UL "utf-8" }, >++ /* >++ ** .pp >++ ** Character set of newsgroups descriptions. >++ */ >++ { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" }, >++ /* >++ ** .pp >++ ** The file, containing info about subscribed newsgroups - names and >++ ** indexes of read articles. The following printf-style sequence >++ ** is understood: >++ ** .dl >++ ** .dt %a .dd account url >++ ** .dt %p .dd port >++ ** .dt %P .dd port if specified >++ ** .dt %s .dd news server name >++ ** .dt %S .dd url schema >++ ** .dt %u .dd username >++ ** .de >++ */ >++ { "nntp_authenticators", DT_STR, R_NONE, UL &NntpAuthenticators, UL 0 }, >++ /* >++ ** .pp >++ ** This is a colon-delimited list of authentication methods mutt may >++ ** attempt to use to log in to a news server, in the order mutt should >++ ** try them. Authentication methods are either ``user'' or any >++ ** SASL mechanism, e.g. ``digest-md5'', ``gssapi'' or ``cram-md5''. >++ ** This option is case-insensitive. If it's \fIunset\fP (the default) >++ ** mutt will try all available methods, in order from most-secure to >++ ** least-secure. >++ ** .pp >++ ** Example: >++ ** .ts >++ ** set nntp_authenticators="digest-md5:user" >++ ** .te >++ ** .pp >++ ** \fBNote:\fP Mutt will only fall back to other authentication methods if >++ ** the previous methods are unavailable. If a method is available but >++ ** authentication fails, mutt will not connect to the IMAP server. >++ */ >++ { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 }, >++ /* >++ ** .pp >++ ** This variable defines number of articles which will be in index when >++ ** newsgroup entered. If active newsgroup have more articles than this >++ ** number, oldest articles will be ignored. Also controls how many >++ ** articles headers will be saved in cache when you quit newsgroup. >++ */ >++ { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 }, >++ /* >++ ** .pp >++ ** This variable controls whether or not descriptions for each newsgroup >++ ** must be loaded when newsgroup is added to list (first time list >++ ** loading or new newsgroup adding). >++ */ >++ { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" }, >++ /* >++ ** .pp >++ ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires >++ ** authentification, Mutt will prompt you for your account name when you >++ ** connect to news server. >++ */ >++ { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" }, >++ /* >++ ** .pp >++ ** Your password for NNTP account. >++ */ >++ { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 }, >++ /* >++ ** .pp >++ ** The time in seconds until any operations on newsgroup except post new >++ ** article will cause recheck for new news. If set to 0, Mutt will >++ ** recheck newsgroup on each operation in index (stepping, read article, >++ ** etc.). >++ */ >++#endif >+ { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" }, >+ /* >+ ** .pp >+@@ -2104,6 +2281,16 @@ struct option_t MuttVars[] = { >+ { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 }, >+ /* >+ */ >++#ifdef USE_NNTP >++ { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES }, >++ /* >++ ** .pp >++ ** If set to \fIyes\fP, Mutt will post article to newsgroup that have >++ ** not permissions to posting (e.g. moderated). \fBNote:\fP if news server >++ ** does not support posting to that newsgroup or totally read-only, that >++ ** posting will not have an effect. >++ */ >++#endif >+ { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES }, >+ /* >+ ** .pp >+@@ -2528,6 +2715,28 @@ struct option_t MuttVars[] = { >+ ** Command to use when spawning a subshell. By default, the user's login >+ ** shell from \fC/etc/passwd\fP is used. >+ */ >++#ifdef USE_NNTP >++ { "save_unsubscribed", DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 }, >++ /* >++ ** .pp >++ ** When \fIset\fP, info about unsubscribed newsgroups will be saved into >++ ** ``newsrc'' file and into cache. >++ */ >++ { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 }, >++ /* >++ ** .pp >++ ** If \fIset\fP, news server will be asked for new newsgroups on entering >++ ** the browser. Otherwise, it will be done only once for a news server. >++ ** Also controls whether or not number of new articles of subscribed >++ ** newsgroups will be then checked. >++ */ >++ { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 }, >++ /* >++ ** .pp >++ ** If \fIset\fP, only subscribed newsgroups that contain unread articles >++ ** will be displayed in browser. >++ */ >++#endif >+ { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 }, >+ /* >+ ** .pp >+@@ -3412,6 +3621,14 @@ struct option_t MuttVars[] = { >+ ** Also see the $$read_inc, $$net_inc and $$time_inc variables and the >+ ** ``$tuning'' section of the manual for performance considerations. >+ */ >++#ifdef USE_NNTP >++ { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 }, >++ /* >++ ** .pp >++ ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full >++ ** name of original article author) to article that followuped to newsgroup. >++ */ >++#endif >+ /*--*/ >+ { NULL, 0, 0, 0, 0 } >+ }; >+diff -udprP mutt-1.5.23.orig/keymap.c mutt-1.5.23/keymap.c >+--- mutt-1.5.23.orig/keymap.c 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/keymap.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -784,7 +784,6 @@ void km_init (void) >+ km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE); >+ >+ km_bindkey ("x", MENU_PAGER, OP_EXIT); >+- km_bindkey ("i", MENU_PAGER, OP_EXIT); >+ km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE); >+ km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE); >+ km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE); >+diff -udprP mutt-1.5.23.orig/mailbox.h mutt-1.5.23/mailbox.h >+--- mutt-1.5.23.orig/mailbox.h 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/mailbox.h 2014-03-13 12:48:36.000000000 +0200 >+@@ -74,6 +74,9 @@ int mx_is_imap (const char *); >+ #ifdef USE_POP >+ int mx_is_pop (const char *); >+ #endif >++#ifdef USE_NNTP >++int mx_is_nntp (const char *); >++#endif >+ >+ int mx_access (const char*, int); >+ int mx_check_empty (const char *); >+diff -udprP mutt-1.5.23.orig/main.c mutt-1.5.23/main.c >+--- mutt-1.5.23.orig/main.c 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23/main.c 2014-03-13 12:48:36.000000000 +0200 >+@@ -62,6 +62,10 @@ >+ #include <idn/stringprep.h> >+ #endif >+ >++#ifdef USE_NNTP >++#include "nntp.h" >++#endif >++ >+ static const char *ReachingUs = N_("\ >+ To contact the developers, please mail to <mutt-dev@mutt.org>.\n\ >+ To report a bug, please visit http://bugs.mutt.org/.\n"); >+@@ -136,6 +140,8 @@ options:\n\ >+ " -e <command>\tspecify a command to be executed after initialization\n\ >+ -f <file>\tspecify which mailbox to read\n\ >+ -F <file>\tspecify an alternate muttrc file\n\ >++ -g <server>\tspecify a news server (if compiled with NNTP)\n\ >++ -G\t\tselect a newsgroup (if compiled with NNTP)\n\ >+ -H <file>\tspecify a draft file to read header and body from\n\ >+ -i <file>\tspecify a file which Mutt should include in the body\n\ >+ -m <type>\tspecify a default mailbox type\n\ >+@@ -284,6 +290,12 @@ static void show_version (void) >+ "-USE_POP " >+ #endif >+ >++#ifdef USE_NNTP >++ "+USE_NNTP " >++#else >++ "-USE_NNTP " >++#endif >++ >+ #ifdef USE_IMAP >+ "+USE_IMAP " >+ #else >+@@ -552,6 +564,9 @@ init_extended_keys(); >+ #define M_NOSYSRC (1<<2) /* -n */ >+ #define M_RO (1<<3) /* -R */ >+ #define M_SELECT (1<<4) /* -y */ >++#ifdef USE_NNTP >++#define M_NEWS (1<<5) /* -g and -G */ >++#endif >+ >+ int main (int argc, char **argv) >+ { >+@@ -624,7 +639,11 @@ int main (int argc, char **argv) >+ argv[nargc++] = argv[optind]; >+ } >+ >++#ifdef USE_NNTP >++ if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF) >++#else >+ if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF) >++#endif >+ switch (i) >+ { >+ case 'A': >+@@ -721,6 +740,20 @@ int main (int argc, char **argv) >+ flags |= M_SELECT; >+ break; >+ >++#ifdef USE_NNTP >++ case 'g': /* Specify a news server */ >++ { >++ char buf[LONG_STRING]; >++ >++ snprintf (buf, sizeof (buf), "set news_server=%s", optarg); >++ commands = mutt_add_list (commands, buf); >++ } >++ >++ case 'G': /* List of newsgroups */ >++ flags |= M_SELECT | M_NEWS; >++ break; >++#endif >++ >+ case 'z': >+ flags |= M_IGNORE; >+ break; >+@@ -1008,6 +1041,18 @@ int main (int argc, char **argv) >+ } >+ else if (flags & M_SELECT) >+ { >++#ifdef USE_NNTP >++ if (flags & M_NEWS) >++ { >++ set_option (OPTNEWS); >++ if(!(CurrentNewsSrv = nntp_select_server (NewsServer, 0))) >++ { >++ mutt_endwin (Errorbuf); >++ exit (1); >++ } >++ } >++ else >++#endif >+ if (!Incoming) { >+ mutt_endwin _("No incoming mailboxes defined."); >+ exit (1); >+@@ -1023,6 +1068,15 @@ int main (int argc, char **argv) >+ >+ if (!folder[0]) >+ strfcpy (folder, NONULL(Spoolfile), sizeof (folder)); >++ >++#ifdef USE_NNTP >++ if (option (OPTNEWS)) >++ { >++ unset_option (OPTNEWS); >++ nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account); >++ } >++ else >++#endif >+ mutt_expand_path (folder, sizeof (folder)); >+ >+ mutt_str_replace (&CurrentFolder, folder); >+diff -udprP mutt-1.5.23.orig/mutt.h mutt-1.5.23/mutt.h >+--- mutt-1.5.23.orig/mutt.h 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23/mutt.h 2014-03-13 12:49:30.000000000 +0200 >+@@ -227,6 +227,9 @@ enum >+ M_PGP_KEY, >+ M_XLABEL, >+ M_MIMEATTACH, >++#ifdef USE_NNTP >++ M_NEWSGROUPS, >++#endif >+ >+ /* Options for Mailcap lookup */ >+ M_EDIT, >+@@ -283,6 +286,11 @@ enum >+ #endif >+ OPT_SUBJECT, >+ OPT_VERIFYSIG, /* verify PGP signatures */ >++#ifdef USE_NNTP >++ OPT_TOMODERATED, >++ OPT_CATCHUP, >++ OPT_FOLLOWUPTOPOSTER, >++#endif >+ >+ /* THIS MUST BE THE LAST VALUE. */ >+ OPT_MAX >+@@ -299,6 +307,7 @@ enum >+ #define SENDKEY (1<<7) >+ #define SENDRESEND (1<<8) >+ #define SENDPOSTPONEDFCC (1<<9) /* used by mutt_get_postponed() to signal that the x-mutt-fcc header field was present */ >++#define SENDNEWS (1<<10) >+ >+ /* flags to _mutt_select_file() */ >+ #define M_SEL_BUFFY (1<<0) >+@@ -318,6 +327,8 @@ enum >+ OPTASCIICHARS, >+ OPTASKBCC, >+ OPTASKCC, >++ OPTASKFOLLOWUP, >++ OPTASKXCOMMENTTO, >+ OPTATTACHSPLIT, >+ OPTAUTOEDIT, >+ OPTAUTOTAG, >+@@ -398,6 +409,9 @@ enum >+ OPTMETOO, >+ OPTMHPURGE, >+ OPTMIMEFORWDECODE, >++#ifdef USE_NNTP >++ OPTMIMESUBJECT, /* encode subject line with RFC2047 */ >++#endif >+ OPTNARROWTREE, >+ OPTPAGERSTOP, >+ OPTPIPEDECODE, >+@@ -480,6 +494,16 @@ enum >+ OPTPGPAUTOINLINE, >+ OPTPGPREPLYINLINE, >+ >++ /* news options */ >++ >++#ifdef USE_NNTP >++ OPTSHOWNEWNEWS, >++ OPTSHOWONLYUNREAD, >++ OPTSAVEUNSUB, >++ OPTLOADDESC, >++ OPTXCOMMENTTO, >++#endif >++ >+ /* pseudo options */ >+ >+ OPTAUXSORT, /* (pseudo) using auxiliary sort function */ >+@@ -500,6 +524,7 @@ enum >+ OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */ >+ OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */ >+ OPTATTACHMSG, /* (pseudo) used by attach-message */ >++ OPTHIDEREAD, /* (pseudo) whether or not hide read messages */ >+ OPTKEEPQUIET, /* (pseudo) shut up the message and refresh >+ * functions while we are executing an >+ * external program. >+@@ -510,6 +535,11 @@ enum >+ OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */ >+ OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */ >+ >++#ifdef USE_NNTP >++ OPTNEWS, /* (pseudo) used to change reader mode */ >++ OPTNEWSSEND, /* (pseudo) used to change behavior when posting */ >++#endif >++ >+ OPTMAX >+ }; >+ >+@@ -589,6 +619,13 @@ typedef struct envelope >+ char *supersedes; >+ char *date; >+ char *x_label; >++ char *organization; >++#ifdef USE_NNTP >++ char *newsgroups; >++ char *xref; >++ char *followup_to; >++ char *x_comment_to; >++#endif >+ BUFFER *spam; >+ LIST *references; /* message references (in reverse order) */ >+ LIST *in_reply_to; /* in-reply-to header content */ >+@@ -773,7 +810,7 @@ typedef struct header >+ int refno; /* message number on server */ >+ #endif >+ >+-#if defined USE_POP || defined USE_IMAP >++#if defined USE_POP || defined USE_IMAP || defined USE_NNTP >+ void *data; /* driver-specific data */ >+ #endif >+ >+diff -udprP mutt-1.5.23.orig/mutt_sasl.c mutt-1.5.23/mutt_sasl.c >+--- mutt-1.5.23.orig/mutt_sasl.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/mutt_sasl.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -188,6 +188,11 @@ int mutt_sasl_client_new (CONNECTION* co >+ case M_ACCT_TYPE_SMTP: >+ service = "smtp"; >+ break; >++#ifdef USE_NNTP >++ case M_ACCT_TYPE_NNTP: >++ service = "nntp"; >++ break; >++#endif >+ default: >+ mutt_error (_("Unknown SASL profile")); >+ return -1; >+diff -udprP mutt-1.5.23.orig/muttlib.c mutt-1.5.23/muttlib.c >+--- mutt-1.5.23.orig/muttlib.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/muttlib.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -337,7 +337,7 @@ void mutt_free_header (HEADER **h) >+ #ifdef MIXMASTER >+ mutt_free_list (&(*h)->chain); >+ #endif >+-#if defined USE_POP || defined USE_IMAP >++#if defined USE_POP || defined USE_IMAP || defined USE_NNTP >+ FREE (&(*h)->data); >+ #endif >+ FREE (h); /* __FREE_CHECKED__ */ >+@@ -722,6 +722,13 @@ void mutt_free_envelope (ENVELOPE **p) >+ FREE (&(*p)->supersedes); >+ FREE (&(*p)->date); >+ FREE (&(*p)->x_label); >++ FREE (&(*p)->organization); >++#ifdef USE_NNTP >++ FREE (&(*p)->newsgroups); >++ FREE (&(*p)->xref); >++ FREE (&(*p)->followup_to); >++ FREE (&(*p)->x_comment_to); >++#endif >+ >+ mutt_buffer_free (&(*p)->spam); >+ >+@@ -1520,6 +1527,14 @@ int mutt_save_confirm (const char *s, st >+ } >+ } >+ >++#ifdef USE_NNTP >++ if (magic == M_NNTP) >++ { >++ mutt_error _("Can't save message to news server."); >++ return 0; >++ } >++#endif >++ >+ if (stat (s, st) != -1) >+ { >+ if (magic == -1) >+diff -udprP mutt-1.5.23.orig/mx.c mutt-1.5.23/mx.c >+--- mutt-1.5.23.orig/mx.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/mx.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -343,6 +343,22 @@ int mx_is_pop (const char *p) >+ } >+ #endif >+ >++#ifdef USE_NNTP >++int mx_is_nntp (const char *p) >++{ >++ url_scheme_t scheme; >++ >++ if (!p) >++ return 0; >++ >++ scheme = url_check_scheme (p); >++ if (scheme == U_NNTP || scheme == U_NNTPS) >++ return 1; >++ >++ return 0; >++} >++#endif >++ >+ int mx_get_magic (const char *path) >+ { >+ struct stat st; >+@@ -360,6 +376,11 @@ int mx_get_magic (const char *path) >+ return M_POP; >+ #endif /* USE_POP */ >+ >++#ifdef USE_NNTP >++ if (mx_is_nntp (path)) >++ return M_NNTP; >++#endif /* USE_NNTP */ >++ >+ if (stat (path, &st) == -1) >+ { >+ dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n", >+@@ -668,6 +689,12 @@ CONTEXT *mx_open_mailbox (const char *pa >+ break; >+ #endif /* USE_POP */ >+ >++#ifdef USE_NNTP >++ case M_NNTP: >++ rc = nntp_open_mailbox (ctx); >++ break; >++#endif /* USE_NNTP */ >++ >+ default: >+ rc = -1; >+ break; >+@@ -764,6 +791,12 @@ static int sync_mailbox (CONTEXT *ctx, i >+ rc = pop_sync_mailbox (ctx, index_hint); >+ break; >+ #endif /* USE_POP */ >++ >++#ifdef USE_NNTP >++ case M_NNTP: >++ rc = nntp_sync_mailbox (ctx); >++ break; >++#endif /* USE_NNTP */ >+ } >+ >+ #if 0 >+@@ -807,6 +840,25 @@ int mx_close_mailbox (CONTEXT *ctx, int >+ return 0; >+ } >+ >++#ifdef USE_NNTP >++ if (ctx->unread && ctx->magic == M_NNTP) >++ { >++ NNTP_DATA *nntp_data = ctx->data; >++ >++ if (nntp_data && nntp_data->nserv && nntp_data->group) >++ { >++ int rc = query_quadoption (OPT_CATCHUP, _("Mark all articles read?")); >++ if (rc < 0) >++ { >++ ctx->closing = 0; >++ return -1; >++ } >++ else if (rc == M_YES) >++ mutt_newsgroup_catchup (nntp_data->nserv, nntp_data->group); >++ } >++ } >++#endif >++ >+ for (i = 0; i < ctx->msgcount; i++) >+ { >+ if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read >+@@ -814,6 +866,12 @@ int mx_close_mailbox (CONTEXT *ctx, int >+ read_msgs++; >+ } >+ >++#ifdef USE_NNTP >++ /* don't need to move articles from newsgroup */ >++ if (ctx->magic == M_NNTP) >++ read_msgs = 0; >++#endif >++ >+ if (read_msgs && quadoption (OPT_MOVE) != M_NO) >+ { >+ char *p; >+@@ -1341,6 +1399,11 @@ int mx_check_mailbox (CONTEXT *ctx, int >+ case M_POP: >+ return (pop_check_mailbox (ctx, index_hint)); >+ #endif /* USE_POP */ >++ >++#ifdef USE_NNTP >++ case M_NNTP: >++ return (nntp_check_mailbox (ctx, 0)); >++#endif /* USE_NNTP */ >+ } >+ } >+ >+@@ -1401,6 +1464,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx, >+ } >+ #endif /* USE_POP */ >+ >++#ifdef USE_NNTP >++ case M_NNTP: >++ { >++ if (nntp_fetch_message (msg, ctx, msgno) != 0) >++ FREE (&msg); >++ break; >++ } >++#endif /* USE_NNTP */ >++ >+ default: >+ dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic)); >+ FREE (&msg); >+@@ -1476,6 +1548,9 @@ int mx_close_message (MESSAGE **msg) >+ int r = 0; >+ >+ if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR >++#ifdef USE_NNTP >++ || (*msg)->magic == M_NNTP >++#endif >+ || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP) >+ { >+ r = safe_fclose (&(*msg)->fp); >+diff -udprP mutt-1.5.23.orig/mx.h mutt-1.5.23/mx.h >+--- mutt-1.5.23.orig/mx.h 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/mx.h 2014-03-13 12:48:37.000000000 +0200 >+@@ -34,6 +34,9 @@ enum >+ M_MMDF, >+ M_MH, >+ M_MAILDIR, >++#ifdef USE_NNTP >++ M_NNTP, >++#endif >+ M_IMAP, >+ M_POP >+ }; >+diff -udprP mutt-1.5.23.orig/newsrc.c mutt-1.5.23/newsrc.c >+--- mutt-1.5.23.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300 >++++ mutt-1.5.23/newsrc.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -0,0 +1,1260 @@ >++/* >++ * Copyright (C) 1998 Brandon Long <blong@fiction.net> >++ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net> >++ * Copyright (C) 2000-2012 Vsevolod Volkov <vvv@mutt.org.ua> >++ * >++ * This program is free software; you can redistribute it and/or modify >++ * it under the terms of the GNU General Public License as published by >++ * the Free Software Foundation; either version 2 of the License, or >++ * (at your option) any later version. >++ * >++ * This program is distributed in the hope that it will be useful, >++ * but WITHOUT ANY WARRANTY; without even the implied warranty of >++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >++ * GNU General Public License for more details. >++ * >++ * You should have received a copy of the GNU General Public License >++ * along with this program; if not, write to the Free Software >++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >++ */ >++ >++#if HAVE_CONFIG_H >++#include "config.h" >++#endif >++ >++#include "mutt.h" >++#include "mutt_curses.h" >++#include "sort.h" >++#include "mx.h" >++#include "mime.h" >++#include "mailbox.h" >++#include "nntp.h" >++#include "rfc822.h" >++#include "rfc1524.h" >++#include "rfc2047.h" >++#include "bcache.h" >++ >++#if USE_HCACHE >++#include "hcache.h" >++#endif >++ >++#include <unistd.h> >++#include <string.h> >++#include <ctype.h> >++#include <stdlib.h> >++#include <sys/stat.h> >++#include <sys/types.h> >++#include <dirent.h> >++#include <errno.h> >++ >++/* Find NNTP_DATA for given newsgroup or add it */ >++static NNTP_DATA *nntp_data_find (NNTP_SERVER *nserv, const char *group) >++{ >++ NNTP_DATA *nntp_data = hash_find (nserv->groups_hash, group); >++ >++ if (!nntp_data) >++ { >++ /* create NNTP_DATA structure and add it to hash */ >++ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1); >++ nntp_data->group = (char *)nntp_data + sizeof (NNTP_DATA); >++ strcpy (nntp_data->group, group); >++ nntp_data->nserv = nserv; >++ nntp_data->deleted = 1; >++ if (nserv->groups_hash->nelem < nserv->groups_hash->curnelem * 2) >++ nserv->groups_hash = hash_resize (nserv->groups_hash, >++ nserv->groups_hash->nelem * 2, 0); >++ hash_insert (nserv->groups_hash, nntp_data->group, nntp_data, 0); >++ >++ /* add NNTP_DATA to list */ >++ if (nserv->groups_num >= nserv->groups_max) >++ { >++ nserv->groups_max *= 2; >++ safe_realloc (&nserv->groups_list, >++ nserv->groups_max * sizeof (nntp_data)); >++ } >++ nserv->groups_list[nserv->groups_num++] = nntp_data; >++ } >++ return nntp_data; >++} >++ >++/* Remove all temporarily cache files */ >++void nntp_acache_free (NNTP_DATA *nntp_data) >++{ >++ int i; >++ >++ for (i = 0; i < NNTP_ACACHE_LEN; i++) >++ { >++ if (nntp_data->acache[i].path) >++ { >++ unlink (nntp_data->acache[i].path); >++ FREE (&nntp_data->acache[i].path); >++ } >++ } >++} >++ >++/* Free NNTP_DATA, used to destroy hash elements */ >++void nntp_data_free (void *data) >++{ >++ NNTP_DATA *nntp_data = data; >++ >++ if (!nntp_data) >++ return; >++ nntp_acache_free (nntp_data); >++ mutt_bcache_close (&nntp_data->bcache); >++ FREE (&nntp_data->newsrc_ent); >++ FREE (&nntp_data->desc); >++ FREE (&data); >++} >++ >++/* Unlock and close .newsrc file */ >++void nntp_newsrc_close (NNTP_SERVER *nserv) >++{ >++ if (!nserv->newsrc_fp) >++ return; >++ >++ dprint (1, (debugfile, "Unlocking %s\n", nserv->newsrc_file)); >++ mx_unlock_file (nserv->newsrc_file, fileno (nserv->newsrc_fp), 0); >++ safe_fclose (&nserv->newsrc_fp); >++} >++ >++/* Parse .newsrc file: >++ * 0 - not changed >++ * 1 - parsed >++ * -1 - error */ >++int nntp_newsrc_parse (NNTP_SERVER *nserv) >++{ >++ unsigned int i; >++ char *line; >++ struct stat sb; >++ >++ /* if file doesn't exist, create it */ >++ nserv->newsrc_fp = safe_fopen (nserv->newsrc_file, "a"); >++ safe_fclose (&nserv->newsrc_fp); >++ >++ /* open .newsrc */ >++ nserv->newsrc_fp = safe_fopen (nserv->newsrc_file, "r"); >++ if (!nserv->newsrc_fp) >++ { >++ mutt_perror (nserv->newsrc_file); >++ mutt_sleep (2); >++ return -1; >++ } >++ >++ /* lock it */ >++ dprint (1, (debugfile, "Locking %s\n", nserv->newsrc_file)); >++ if (mx_lock_file (nserv->newsrc_file, fileno (nserv->newsrc_fp), 0, 0, 1)) >++ { >++ safe_fclose (&nserv->newsrc_fp); >++ return -1; >++ } >++ >++ if (stat (nserv->newsrc_file, &sb)) >++ { >++ mutt_perror (nserv->newsrc_file); >++ nntp_newsrc_close (nserv); >++ mutt_sleep (2); >++ return -1; >++ } >++ >++ if (nserv->size == sb.st_size && nserv->mtime == sb.st_mtime) >++ return 0; >++ >++ nserv->size = sb.st_size; >++ nserv->mtime = sb.st_mtime; >++ nserv->newsrc_modified = 1; >++ dprint (1, (debugfile, "Parsing %s\n", nserv->newsrc_file)); >++ >++ /* .newsrc has been externally modified or hasn't been loaded yet */ >++ for (i = 0; i < nserv->groups_num; i++) >++ { >++ NNTP_DATA *nntp_data = nserv->groups_list[i]; >++ >++ if (!nntp_data) >++ continue; >++ >++ nntp_data->subscribed = 0; >++ nntp_data->newsrc_len = 0; >++ FREE (&nntp_data->newsrc_ent); >++ } >++ >++ line = safe_malloc (sb.st_size + 1); >++ while (sb.st_size && fgets (line, sb.st_size + 1, nserv->newsrc_fp)) >++ { >++ char *b, *h, *p; >++ unsigned int subs = 0, i = 1; >++ NNTP_DATA *nntp_data; >++ >++ /* find end of newsgroup name */ >++ p = strpbrk (line, ":!"); >++ if (!p) >++ continue; >++ >++ /* ":" - subscribed, "!" - unsubscribed */ >++ if (*p == ':') >++ subs++; >++ *p++ = '\0'; >++ >++ /* get newsgroup data */ >++ nntp_data = nntp_data_find (nserv, line); >++ FREE (&nntp_data->newsrc_ent); >++ >++ /* count number of entries */ >++ b = p; >++ while (*b) >++ if (*b++ == ',') >++ i++; >++ nntp_data->newsrc_ent = safe_calloc (i, sizeof (NEWSRC_ENTRY)); >++ nntp_data->subscribed = subs; >++ >++ /* parse entries */ >++ i = 0; >++ while (p) >++ { >++ b = p; >++ >++ /* find end of entry */ >++ p = strchr (p, ','); >++ if (p) >++ *p++ = '\0'; >++ >++ /* first-last or single number */ >++ h = strchr (b, '-'); >++ if (h) >++ *h++ = '\0'; >++ else >++ h = b; >++ >++ if (sscanf (b, ANUM, &nntp_data->newsrc_ent[i].first) == 1 && >++ sscanf (h, ANUM, &nntp_data->newsrc_ent[i].last) == 1) >++ i++; >++ } >++ if (i == 0) >++ { >++ nntp_data->newsrc_ent[i].first = 1; >++ nntp_data->newsrc_ent[i].last = 0; >++ i++; >++ } >++ if (nntp_data->lastMessage == 0) >++ nntp_data->lastMessage = nntp_data->newsrc_ent[i - 1].last; >++ nntp_data->newsrc_len = i; >++ safe_realloc (&nntp_data->newsrc_ent, i * sizeof (NEWSRC_ENTRY)); >++ nntp_group_unread_stat (nntp_data); >++ dprint (2, (debugfile, "nntp_newsrc_parse: %s\n", nntp_data->group)); >++ } >++ FREE (&line); >++ return 1; >++} >++ >++/* Generate array of .newsrc entries */ >++void nntp_newsrc_gen_entries (CONTEXT *ctx) >++{ >++ NNTP_DATA *nntp_data = ctx->data; >++ anum_t last = 0, first = 1; >++ int series, i; >++ int save_sort = SORT_ORDER; >++ unsigned int entries; >++ >++ if (Sort != SORT_ORDER) >++ { >++ save_sort = Sort; >++ Sort = SORT_ORDER; >++ mutt_sort_headers (ctx, 0); >++ } >++ >++ entries = nntp_data->newsrc_len; >++ if (!entries) >++ { >++ entries = 5; >++ nntp_data->newsrc_ent = safe_calloc (entries, sizeof (NEWSRC_ENTRY)); >++ } >++ >++ /* Set up to fake initial sequence from 1 to the article before the >++ * first article in our list */ >++ nntp_data->newsrc_len = 0; >++ series = 1; >++ for (i = 0; i < ctx->msgcount; i++) >++ { >++ /* search for first unread */ >++ if (series) >++ { >++ /* We don't actually check sequential order, since we mark >++ * "missing" entries as read/deleted */ >++ last = NHDR (ctx->hdrs[i])->article_num; >++ if (last >= nntp_data->firstMessage && !ctx->hdrs[i]->deleted && >++ !ctx->hdrs[i]->read) >++ { >++ if (nntp_data->newsrc_len >= entries) >++ { >++ entries *= 2; >++ safe_realloc (&nntp_data->newsrc_ent, entries * sizeof (NEWSRC_ENTRY)); >++ } >++ nntp_data->newsrc_ent[nntp_data->newsrc_len].first = first; >++ nntp_data->newsrc_ent[nntp_data->newsrc_len].last = last - 1; >++ nntp_data->newsrc_len++; >++ series = 0; >++ } >++ } >++ >++ /* search for first read */ >++ else >++ { >++ if (ctx->hdrs[i]->deleted || ctx->hdrs[i]->read) >++ { >++ first = last + 1; >++ series = 1; >++ } >++ last = NHDR (ctx->hdrs[i])->article_num; >++ } >++ } >++ >++ if (series && first <= nntp_data->lastLoaded) >++ { >++ if (nntp_data->newsrc_len >= entries) >++ { >++ entries++; >++ safe_realloc (&nntp_data->newsrc_ent, entries * sizeof (NEWSRC_ENTRY)); >++ } >++ nntp_data->newsrc_ent[nntp_data->newsrc_len].first = first; >++ nntp_data->newsrc_ent[nntp_data->newsrc_len].last = nntp_data->lastLoaded; >++ nntp_data->newsrc_len++; >++ } >++ safe_realloc (&nntp_data->newsrc_ent, >++ nntp_data->newsrc_len * sizeof (NEWSRC_ENTRY)); >++ >++ if (save_sort != Sort) >++ { >++ Sort = save_sort; >++ mutt_sort_headers (ctx, 0); >++ } >++} >++ >++/* Update file with new contents */ >++static int update_file (char *filename, char *buf) >++{ >++ FILE *fp; >++ char tmpfile[_POSIX_PATH_MAX]; >++ int rc = -1; >++ >++ while (1) >++ { >++ snprintf (tmpfile, sizeof (tmpfile), "%s.tmp", filename); >++ fp = fopen (tmpfile, "w"); >++ if (!fp) >++ { >++ mutt_perror (tmpfile); >++ *tmpfile = '\0'; >++ break; >++ } >++ if (fputs (buf, fp) == EOF) >++ { >++ mutt_perror (tmpfile); >++ break; >++ } >++ if (fclose (fp) == EOF) >++ { >++ mutt_perror (tmpfile); >++ fp = NULL; >++ break; >++ } >++ fp = NULL; >++ if (rename (tmpfile, filename) < 0) >++ { >++ mutt_perror (filename); >++ break; >++ } >++ *tmpfile = '\0'; >++ rc = 0; >++ break; >++ } >++ if (fp) >++ fclose (fp); >++ if (*tmpfile) >++ unlink (tmpfile); >++ if (rc) >++ mutt_sleep (2); >++ return rc; >++} >++ >++/* Update .newsrc file */ >++int nntp_newsrc_update (NNTP_SERVER *nserv) >++{ >++ char *buf; >++ size_t buflen, off; >++ unsigned int i; >++ int rc = -1; >++ >++ if (!nserv) >++ return -1; >++ >++ buflen = 10 * LONG_STRING; >++ buf = safe_calloc (1, buflen); >++ off = 0; >++ >++ /* we will generate full newsrc here */ >++ for (i = 0; i < nserv->groups_num; i++) >++ { >++ NNTP_DATA *nntp_data = nserv->groups_list[i]; >++ unsigned int n; >++ >++ if (!nntp_data || !nntp_data->newsrc_ent) >++ continue; >++ >++ /* write newsgroup name */ >++ if (off + strlen (nntp_data->group) + 3 > buflen) >++ { >++ buflen *= 2; >++ safe_realloc (&buf, buflen); >++ } >++ snprintf (buf + off, buflen - off, "%s%c ", nntp_data->group, >++ nntp_data->subscribed ? ':' : '!'); >++ off += strlen (buf + off); >++ >++ /* write entries */ >++ for (n = 0; n < nntp_data->newsrc_len; n++) >++ { >++ if (off + LONG_STRING > buflen) >++ { >++ buflen *= 2; >++ safe_realloc (&buf, buflen); >++ } >++ if (n) >++ buf[off++] = ','; >++ if (nntp_data->newsrc_ent[n].first == nntp_data->newsrc_ent[n].last) >++ snprintf (buf + off, buflen - off, "%d", nntp_data->newsrc_ent[n].first); >++ else if (nntp_data->newsrc_ent[n].first < nntp_data->newsrc_ent[n].last) >++ snprintf (buf + off, buflen - off, "%d-%d", >++ nntp_data->newsrc_ent[n].first, nntp_data->newsrc_ent[n].last); >++ off += strlen (buf + off); >++ } >++ buf[off++] = '\n'; >++ } >++ buf[off] = '\0'; >++ >++ /* newrc being fully rewritten */ >++ dprint (1, (debugfile, "Updating %s\n", nserv->newsrc_file)); >++ if (nserv->newsrc_file && update_file (nserv->newsrc_file, buf) == 0) >++ { >++ struct stat sb; >++ >++ rc = stat (nserv->newsrc_file, &sb); >++ if (rc == 0) >++ { >++ nserv->size = sb.st_size; >++ nserv->mtime = sb.st_mtime; >++ } >++ else >++ { >++ mutt_perror (nserv->newsrc_file); >++ mutt_sleep (2); >++ } >++ } >++ FREE (&buf); >++ return rc; >++} >++ >++/* Make fully qualified cache file name */ >++static void cache_expand (char *dst, size_t dstlen, ACCOUNT *acct, char *src) >++{ >++ char *c; >++ char file[_POSIX_PATH_MAX]; >++ >++ /* server subdirectory */ >++ if (acct) >++ { >++ ciss_url_t url; >++ >++ mutt_account_tourl (acct, &url); >++ url.path = src; >++ url_ciss_tostring (&url, file, sizeof (file), U_PATH); >++ } >++ else >++ strfcpy (file, src ? src : "", sizeof (file)); >++ >++ snprintf (dst, dstlen, "%s/%s", NewsCacheDir, file); >++ >++ /* remove trailing slash */ >++ c = dst + strlen (dst) - 1; >++ if (*c == '/') >++ *c = '\0'; >++ mutt_expand_path (dst, dstlen); >++} >++ >++/* Make fully qualified url from newsgroup name */ >++void nntp_expand_path (char *line, size_t len, ACCOUNT *acct) >++{ >++ ciss_url_t url; >++ >++ url.path = safe_strdup (line); >++ mutt_account_tourl (acct, &url); >++ url_ciss_tostring (&url, line, len, 0); >++ FREE (&url.path); >++} >++ >++/* Parse newsgroup */ >++int nntp_add_group (char *line, void *data) >++{ >++ NNTP_SERVER *nserv = data; >++ NNTP_DATA *nntp_data; >++ char group[LONG_STRING]; >++ char desc[HUGE_STRING] = ""; >++ char mod; >++ anum_t first, last; >++ >++ if (!nserv || !line) >++ return 0; >++ >++ if (sscanf (line, "%s " ANUM " " ANUM " %c %[^\n]", group, >++ &last, &first, &mod, desc) < 4) >++ return 0; >++ >++ nntp_data = nntp_data_find (nserv, group); >++ nntp_data->deleted = 0; >++ nntp_data->firstMessage = first; >++ nntp_data->lastMessage = last; >++ nntp_data->allowed = mod == 'y' || mod == 'm' ? 1 : 0; >++ mutt_str_replace (&nntp_data->desc, desc); >++ if (nntp_data->newsrc_ent || nntp_data->lastCached) >++ nntp_group_unread_stat (nntp_data); >++ else if (nntp_data->lastMessage && >++ nntp_data->firstMessage <= nntp_data->lastMessage) >++ nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1; >++ else >++ nntp_data->unread = 0; >++ return 0; >++} >++ >++/* Load list of all newsgroups from cache */ >++static int active_get_cache (NNTP_SERVER *nserv) >++{ >++ char buf[HUGE_STRING]; >++ char file[_POSIX_PATH_MAX]; >++ time_t t; >++ FILE *fp; >++ >++ cache_expand (file, sizeof (file), &nserv->conn->account, ".active"); >++ dprint (1, (debugfile, "Parsing %s\n", file)); >++ fp = safe_fopen (file, "r"); >++ if (!fp) >++ return -1; >++ >++ if (fgets (buf, sizeof (buf), fp) == NULL || >++ sscanf (buf, "%ld%s", &t, file) != 1 || t == 0) >++ { >++ fclose (fp); >++ return -1; >++ } >++ nserv->newgroups_time = t; >++ >++ mutt_message _("Loading list of groups from cache..."); >++ while (fgets (buf, sizeof (buf), fp)) >++ nntp_add_group (buf, nserv); >++ nntp_add_group (NULL, NULL); >++ fclose (fp); >++ mutt_clear_error (); >++ return 0; >++} >++ >++/* Save list of all newsgroups to cache */ >++int nntp_active_save_cache (NNTP_SERVER *nserv) >++{ >++ char file[_POSIX_PATH_MAX]; >++ char *buf; >++ size_t buflen, off; >++ unsigned int i; >++ int rc; >++ >++ if (!nserv->cacheable) >++ return 0; >++ >++ buflen = 10 * LONG_STRING; >++ buf = safe_calloc (1, buflen); >++ snprintf (buf, buflen, "%lu\n", (unsigned long)nserv->newgroups_time); >++ off = strlen (buf); >++ >++ for (i = 0; i < nserv->groups_num; i++) >++ { >++ NNTP_DATA *nntp_data = nserv->groups_list[i]; >++ >++ if (!nntp_data || nntp_data->deleted) >++ continue; >++ >++ if (off + strlen (nntp_data->group) + >++ (nntp_data->desc ? strlen (nntp_data->desc) : 0) + 50 > buflen) >++ { >++ buflen *= 2; >++ safe_realloc (&buf, buflen); >++ } >++ snprintf (buf + off, buflen - off, "%s %d %d %c%s%s\n", nntp_data->group, >++ nntp_data->lastMessage, nntp_data->firstMessage, >++ nntp_data->allowed ? 'y' : 'n', nntp_data->desc ? " " : "", >++ nntp_data->desc ? nntp_data->desc : ""); >++ off += strlen (buf + off); >++ } >++ >++ cache_expand (file, sizeof (file), &nserv->conn->account, ".active"); >++ dprint (1, (debugfile, "Updating %s\n", file)); >++ rc = update_file (file, buf); >++ FREE (&buf); >++ return rc; >++} >++ >++#ifdef USE_HCACHE >++/* Used by mutt_hcache_open() to compose hcache file name */ >++static int nntp_hcache_namer (const char *path, char *dest, size_t destlen) >++{ >++ return snprintf (dest, destlen, "%s.hcache", path); >++} >++ >++/* Open newsgroup hcache */ >++header_cache_t *nntp_hcache_open (NNTP_DATA *nntp_data) >++{ >++ ciss_url_t url; >++ char file[_POSIX_PATH_MAX]; >++ >++ if (!nntp_data->nserv || !nntp_data->nserv->cacheable || >++ !nntp_data->nserv->conn || !nntp_data->group || >++ !(nntp_data->newsrc_ent || nntp_data->subscribed || >++ option (OPTSAVEUNSUB))) >++ return NULL; >++ >++ mutt_account_tourl (&nntp_data->nserv->conn->account, &url); >++ url.path = nntp_data->group; >++ url_ciss_tostring (&url, file, sizeof (file), U_PATH); >++ return mutt_hcache_open (NewsCacheDir, file, nntp_hcache_namer); >++} >++ >++/* Remove stale cached headers */ >++void nntp_hcache_update (NNTP_DATA *nntp_data, header_cache_t *hc) >++{ >++ char buf[16]; >++ int old = 0; >++ void *hdata; >++ anum_t first, last, current; >++ >++ if (!hc) >++ return; >++ >++ /* fetch previous values of first and last */ >++ hdata = mutt_hcache_fetch_raw (hc, "index", strlen); >++ if (hdata) >++ { >++ dprint (2, (debugfile, >++ "nntp_hcache_update: mutt_hcache_fetch index: %s\n", hdata)); >++ if (sscanf (hdata, ANUM " " ANUM, &first, &last) == 2) >++ { >++ old = 1; >++ nntp_data->lastCached = last; >++ >++ /* clean removed headers from cache */ >++ for (current = first; current <= last; current++) >++ { >++ if (current >= nntp_data->firstMessage && >++ current <= nntp_data->lastMessage) >++ continue; >++ >++ snprintf (buf, sizeof (buf), "%d", current); >++ dprint (2, (debugfile, >++ "nntp_hcache_update: mutt_hcache_delete %s\n", buf)); >++ mutt_hcache_delete (hc, buf, strlen); >++ } >++ } >++ } >++ >++ /* store current values of first and last */ >++ if (!old || nntp_data->firstMessage != first || >++ nntp_data->lastMessage != last) >++ { >++ snprintf (buf, sizeof (buf), "%u %u", nntp_data->firstMessage, >++ nntp_data->lastMessage); >++ dprint (2, (debugfile, >++ "nntp_hcache_update: mutt_hcache_store index: %s\n", buf)); >++ mutt_hcache_store_raw (hc, "index", buf, strlen (buf) + 1, strlen); >++ } >++} >++#endif >++ >++/* Remove bcache file */ >++static int nntp_bcache_delete (const char *id, body_cache_t *bcache, void *data) >++{ >++ NNTP_DATA *nntp_data = data; >++ anum_t anum; >++ char c; >++ >++ if (!nntp_data || sscanf (id, ANUM "%c", &anum, &c) != 1 || >++ anum < nntp_data->firstMessage || anum > nntp_data->lastMessage) >++ { >++ if (nntp_data) >++ dprint (2, (debugfile, "nntp_bcache_delete: mutt_bcache_del %s\n", id)); >++ mutt_bcache_del (bcache, id); >++ } >++ return 0; >++} >++ >++/* Remove stale cached messages */ >++void nntp_bcache_update (NNTP_DATA *nntp_data) >++{ >++ mutt_bcache_list (nntp_data->bcache, nntp_bcache_delete, nntp_data); >++} >++ >++/* Remove hcache and bcache of newsgroup */ >++void nntp_delete_group_cache (NNTP_DATA *nntp_data) >++{ >++ char file[_POSIX_PATH_MAX]; >++ >++ if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->cacheable) >++ return; >++ >++#ifdef USE_HCACHE >++ nntp_hcache_namer (nntp_data->group, file, sizeof (file)); >++ cache_expand (file, sizeof (file), &nntp_data->nserv->conn->account, file); >++ unlink (file); >++ nntp_data->lastCached = 0; >++ dprint (2, (debugfile, "nntp_delete_group_cache: %s\n", file)); >++#endif >++ >++ if (!nntp_data->bcache) >++ nntp_data->bcache = mutt_bcache_open (&nntp_data->nserv->conn->account, >++ nntp_data->group); >++ if (nntp_data->bcache) >++ { >++ dprint (2, (debugfile, "nntp_delete_group_cache: %s/*\n", nntp_data->group)); >++ mutt_bcache_list (nntp_data->bcache, nntp_bcache_delete, NULL); >++ mutt_bcache_close (&nntp_data->bcache); >++ } >++} >++ >++/* Remove hcache and bcache of all unexistent and unsubscribed newsgroups */ >++void nntp_clear_cache (NNTP_SERVER *nserv) >++{ >++ char file[_POSIX_PATH_MAX]; >++ char *fp; >++ struct dirent *entry; >++ DIR *dp; >++ >++ if (!nserv || !nserv->cacheable) >++ return; >++ >++ cache_expand (file, sizeof (file), &nserv->conn->account, NULL); >++ dp = opendir (file); >++ if (dp) >++ { >++ safe_strncat (file, sizeof (file), "/", 1); >++ fp = file + strlen (file); >++ while ((entry = readdir (dp))) >++ { >++ char *group = entry->d_name; >++ struct stat sb; >++ NNTP_DATA *nntp_data; >++ NNTP_DATA nntp_tmp; >++ >++ if (mutt_strcmp (group, ".") == 0 || >++ mutt_strcmp (group, "..") == 0) >++ continue; >++ *fp = '\0'; >++ safe_strncat (file, sizeof (file), group, strlen (group)); >++ if (stat (file, &sb)) >++ continue; >++ >++#ifdef USE_HCACHE >++ if (S_ISREG (sb.st_mode)) >++ { >++ char *ext = group + strlen (group) - 7; >++ if (strlen (group) < 8 || mutt_strcmp (ext, ".hcache")) >++ continue; >++ *ext = '\0'; >++ } >++ else >++#endif >++ if (!S_ISDIR (sb.st_mode)) >++ continue; >++ >++ nntp_data = hash_find (nserv->groups_hash, group); >++ if (!nntp_data) >++ { >++ nntp_data = &nntp_tmp; >++ nntp_data->nserv = nserv; >++ nntp_data->group = group; >++ nntp_data->bcache = NULL; >++ } >++ else if (nntp_data->newsrc_ent || nntp_data->subscribed || >++ option (OPTSAVEUNSUB)) >++ continue; >++ >++ nntp_delete_group_cache (nntp_data); >++ if (S_ISDIR (sb.st_mode)) >++ { >++ rmdir (file); >++ dprint (2, (debugfile, "nntp_clear_cache: %s\n", file)); >++ } >++ } >++ closedir (dp); >++ } >++ return; >++} >++ >++/* %a = account url >++ * %p = port >++ * %P = port if specified >++ * %s = news server name >++ * %S = url schema >++ * %u = username */ >++const char * >++nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src, >++ const char *fmt, const char *ifstring, const char *elsestring, >++ unsigned long data, format_flag flags) >++{ >++ NNTP_SERVER *nserv = (NNTP_SERVER *)data; >++ ACCOUNT *acct = &nserv->conn->account; >++ ciss_url_t url; >++ char fn[SHORT_STRING], tmp[SHORT_STRING], *p; >++ >++ switch (op) >++ { >++ case 'a': >++ mutt_account_tourl (acct, &url); >++ url_ciss_tostring (&url, fn, sizeof (fn), U_PATH); >++ p = strchr (fn, '/'); >++ if (p) >++ *p = '\0'; >++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >++ snprintf (dest, destlen, tmp, fn); >++ break; >++ case 'p': >++ snprintf (tmp, sizeof (tmp), "%%%su", fmt); >++ snprintf (dest, destlen, tmp, acct->port); >++ break; >++ case 'P': >++ *dest = '\0'; >++ if (acct->flags & M_ACCT_PORT) >++ { >++ snprintf (tmp, sizeof (tmp), "%%%su", fmt); >++ snprintf (dest, destlen, tmp, acct->port); >++ } >++ break; >++ case 's': >++ strncpy (fn, acct->host, sizeof (fn) - 1); >++ mutt_strlower (fn); >++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >++ snprintf (dest, destlen, tmp, fn); >++ break; >++ case 'S': >++ mutt_account_tourl (acct, &url); >++ url_ciss_tostring (&url, fn, sizeof (fn), U_PATH); >++ p = strchr (fn, ':'); >++ if (p) >++ *p = '\0'; >++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >++ snprintf (dest, destlen, tmp, fn); >++ break; >++ case 'u': >++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); >++ snprintf (dest, destlen, tmp, acct->user); >++ break; >++ } >++ return (src); >++} >++ >++/* Automatically loads a newsrc into memory, if necessary. >++ * Checks the size/mtime of a newsrc file, if it doesn't match, load >++ * again. Hmm, if a system has broken mtimes, this might mean the file >++ * is reloaded every time, which we'd have to fix. */ >++NNTP_SERVER *nntp_select_server (char *server, int leave_lock) >++{ >++ char file[_POSIX_PATH_MAX]; >++ char *p; >++ int rc; >++ struct stat sb; >++ ACCOUNT acct; >++ NNTP_SERVER *nserv; >++ NNTP_DATA *nntp_data; >++ CONNECTION *conn; >++ ciss_url_t url; >++ >++ if (!server || !*server) >++ { >++ mutt_error _("No news server defined!"); >++ mutt_sleep (2); >++ return NULL; >++ } >++ >++ /* create account from news server url */ >++ acct.flags = 0; >++ acct.port = NNTP_PORT; >++ acct.type = M_ACCT_TYPE_NNTP; >++ snprintf (file, sizeof (file), "%s%s", >++ strstr (server, "://") ? "" : "news://", server); >++ if (url_parse_ciss (&url, file) < 0 || >++ (url.path && *url.path) || >++ !(url.scheme == U_NNTP || url.scheme == U_NNTPS) || >++ mutt_account_fromurl (&acct, &url) < 0) >++ { >++ mutt_error (_("%s is an invalid news server specification!"), server); >++ mutt_sleep (2); >++ return NULL; >++ } >++ if (url.scheme == U_NNTPS) >++ { >++ acct.flags |= M_ACCT_SSL; >++ acct.port = NNTP_SSL_PORT; >++ } >++ >++ /* find connection by account */ >++ conn = mutt_conn_find (NULL, &acct); >++ if (!conn) >++ return NULL; >++ if (!(conn->account.flags & M_ACCT_USER) && acct.flags & M_ACCT_USER) >++ { >++ conn->account.flags |= M_ACCT_USER; >++ conn->account.user[0] = '\0'; >++ } >++ >++ /* news server already exists */ >++ nserv = conn->data; >++ if (nserv) >++ { >++ if (nserv->status == NNTP_BYE) >++ nserv->status = NNTP_NONE; >++ if (nntp_open_connection (nserv) < 0) >++ return NULL; >++ >++ rc = nntp_newsrc_parse (nserv); >++ if (rc < 0) >++ return NULL; >++ >++ /* check for new newsgroups */ >++ if (!leave_lock && nntp_check_new_groups (nserv) < 0) >++ rc = -1; >++ >++ /* .newsrc has been externally modified */ >++ if (rc > 0) >++ nntp_clear_cache (nserv); >++ if (rc < 0 || !leave_lock) >++ nntp_newsrc_close (nserv); >++ return rc < 0 ? NULL : nserv; >++ } >++ >++ /* new news server */ >++ nserv = safe_calloc (1, sizeof (NNTP_SERVER)); >++ nserv->conn = conn; >++ nserv->groups_hash = hash_create (1009, 0); >++ nserv->groups_max = 16; >++ nserv->groups_list = safe_malloc (nserv->groups_max * sizeof (nntp_data)); >++ >++ rc = nntp_open_connection (nserv); >++ >++ /* try to create cache directory and enable caching */ >++ nserv->cacheable = 0; >++ if (rc >= 0 && NewsCacheDir && *NewsCacheDir) >++ { >++ cache_expand (file, sizeof (file), &conn->account, NULL); >++ p = *file == '/' ? file + 1 : file; >++ while (1) >++ { >++ p = strchr (p, '/'); >++ if (p) >++ *p = '\0'; >++ if ((stat (file, &sb) || (sb.st_mode & S_IFDIR) == 0) && >++ mkdir (file, 0700)) >++ { >++ mutt_error (_("Can't create %s: %s."), file, strerror (errno)); >++ mutt_sleep (2); >++ break; >++ } >++ if (!p) >++ { >++ nserv->cacheable = 1; >++ break; >++ } >++ *p++ = '/'; >++ } >++ } >++ >++ /* load .newsrc */ >++ if (rc >= 0) >++ { >++ mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), >++ nntp_format_str, (unsigned long)nserv, 0); >++ mutt_expand_path (file, sizeof (file)); >++ nserv->newsrc_file = safe_strdup (file); >++ rc = nntp_newsrc_parse (nserv); >++ } >++ if (rc >= 0) >++ { >++ /* try to load list of newsgroups from cache */ >++ if (nserv->cacheable && active_get_cache (nserv) == 0) >++ rc = nntp_check_new_groups (nserv); >++ >++ /* load list of newsgroups from server */ >++ else >++ rc = nntp_active_fetch (nserv); >++ } >++ >++ if (rc >= 0) >++ nntp_clear_cache (nserv); >++ >++#ifdef USE_HCACHE >++ /* check cache files */ >++ if (rc >= 0 && nserv->cacheable) >++ { >++ struct dirent *entry; >++ DIR *dp = opendir (file); >++ >++ if (dp) >++ { >++ while ((entry = readdir (dp))) >++ { >++ header_cache_t *hc; >++ void *hdata; >++ char *group = entry->d_name; >++ >++ p = group + strlen (group) - 7; >++ if (strlen (group) < 8 || strcmp (p, ".hcache")) >++ continue; >++ *p = '\0'; >++ nntp_data = hash_find (nserv->groups_hash, group); >++ if (!nntp_data) >++ continue; >++ >++ hc = nntp_hcache_open (nntp_data); >++ if (!hc) >++ continue; >++ >++ /* fetch previous values of first and last */ >++ hdata = mutt_hcache_fetch_raw (hc, "index", strlen); >++ if (hdata) >++ { >++ anum_t first, last; >++ >++ if (sscanf (hdata, ANUM " " ANUM, &first, &last) == 2) >++ { >++ if (nntp_data->deleted) >++ { >++ nntp_data->firstMessage = first; >++ nntp_data->lastMessage = last; >++ } >++ if (last >= nntp_data->firstMessage && >++ last <= nntp_data->lastMessage) >++ { >++ nntp_data->lastCached = last; >++ dprint (2, (debugfile, "nntp_select_server: %s lastCached=%u\n", >++ nntp_data->group, last)); >++ } >++ } >++ } >++ mutt_hcache_close (hc); >++ } >++ closedir (dp); >++ } >++ } >++#endif >++ >++ if (rc < 0 || !leave_lock) >++ nntp_newsrc_close (nserv); >++ >++ if (rc < 0) >++ { >++ hash_destroy (&nserv->groups_hash, nntp_data_free); >++ FREE (&nserv->groups_list); >++ FREE (&nserv->newsrc_file); >++ FREE (&nserv->authenticators); >++ FREE (&nserv); >++ mutt_socket_close (conn); >++ mutt_socket_free (conn); >++ return NULL; >++ } >++ >++ conn->data = nserv; >++ return nserv; >++} >++ >++/* Full status flags are not supported by nntp, but we can fake some of them: >++ * Read = a read message number is in the .newsrc >++ * New = not read and not cached >++ * Old = not read but cached */ >++void nntp_article_status (CONTEXT *ctx, HEADER *hdr, char *group, anum_t anum) >++{ >++ NNTP_DATA *nntp_data = ctx->data; >++ unsigned int i; >++ >++ if (group) >++ nntp_data = hash_find (nntp_data->nserv->groups_hash, group); >++ >++ if (!nntp_data) >++ return; >++ >++ for (i = 0; i < nntp_data->newsrc_len; i++) >++ { >++ if ((anum >= nntp_data->newsrc_ent[i].first) && >++ (anum <= nntp_data->newsrc_ent[i].last)) >++ { >++ /* can't use mutt_set_flag() because mx_update_context() >++ didn't called yet */ >++ hdr->read = 1; >++ return; >++ } >++ } >++ >++ /* article was not cached yet, it's new */ >++ if (anum > nntp_data->lastCached) >++ return; >++ >++ /* article isn't read but cached, it's old */ >++ if (option (OPTMARKOLD)) >++ hdr->old = 1; >++} >++ >++/* calculate number of unread articles using .newsrc data */ >++void nntp_group_unread_stat (NNTP_DATA *nntp_data) >++{ >++ unsigned int i; >++ anum_t first, last; >++ >++ nntp_data->unread = 0; >++ if (nntp_data->lastMessage == 0 || >++ nntp_data->firstMessage > nntp_data->lastMessage) >++ return; >++ >++ nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1; >++ for (i = 0; i < nntp_data->newsrc_len; i++) >++ { >++ first = nntp_data->newsrc_ent[i].first; >++ if (first < nntp_data->firstMessage) >++ first = nntp_data->firstMessage; >++ last = nntp_data->newsrc_ent[i].last; >++ if (last > nntp_data->lastMessage) >++ last = nntp_data->lastMessage; >++ if (first <= last) >++ nntp_data->unread -= last - first + 1; >++ } >++} >++ >++/* Subscribe newsgroup */ >++NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *nserv, char *group) >++{ >++ NNTP_DATA *nntp_data; >++ >++ if (!nserv || !nserv->groups_hash || !group || !*group) >++ return NULL; >++ >++ nntp_data = nntp_data_find (nserv, group); >++ nntp_data->subscribed = 1; >++ if (!nntp_data->newsrc_ent) >++ { >++ nntp_data->newsrc_ent = safe_calloc (1, sizeof (NEWSRC_ENTRY)); >++ nntp_data->newsrc_len = 1; >++ nntp_data->newsrc_ent[0].first = 1; >++ nntp_data->newsrc_ent[0].last = 0; >++ } >++ return nntp_data; >++} >++ >++/* Unsubscribe newsgroup */ >++NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *nserv, char *group) >++{ >++ NNTP_DATA *nntp_data; >++ >++ if (!nserv || !nserv->groups_hash || !group || !*group) >++ return NULL; >++ >++ nntp_data = hash_find (nserv->groups_hash, group); >++ if (!nntp_data) >++ return NULL; >++ >++ nntp_data->subscribed = 0; >++ if (!option (OPTSAVEUNSUB)) >++ { >++ nntp_data->newsrc_len = 0; >++ FREE (&nntp_data->newsrc_ent); >++ } >++ return nntp_data; >++} >++ >++/* Catchup newsgroup */ >++NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *nserv, char *group) >++{ >++ NNTP_DATA *nntp_data; >++ >++ if (!nserv || !nserv->groups_hash || !group || !*group) >++ return NULL; >++ >++ nntp_data = hash_find (nserv->groups_hash, group); >++ if (!nntp_data) >++ return NULL; >++ >++ if (nntp_data->newsrc_ent) >++ { >++ safe_realloc (&nntp_data->newsrc_ent, sizeof (NEWSRC_ENTRY)); >++ nntp_data->newsrc_len = 1; >++ nntp_data->newsrc_ent[0].first = 1; >++ nntp_data->newsrc_ent[0].last = nntp_data->lastMessage; >++ } >++ nntp_data->unread = 0; >++ if (Context && Context->data == nntp_data) >++ { >++ unsigned int i; >++ >++ for (i = 0; i < Context->msgcount; i++) >++ mutt_set_flag (Context, Context->hdrs[i], M_READ, 1); >++ } >++ return nntp_data; >++} >++ >++/* Uncatchup newsgroup */ >++NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *nserv, char *group) >++{ >++ NNTP_DATA *nntp_data; >++ >++ if (!nserv || !nserv->groups_hash || !group || !*group) >++ return NULL; >++ >++ nntp_data = hash_find (nserv->groups_hash, group); >++ if (!nntp_data) >++ return NULL; >++ >++ if (nntp_data->newsrc_ent) >++ { >++ safe_realloc (&nntp_data->newsrc_ent, sizeof (NEWSRC_ENTRY)); >++ nntp_data->newsrc_len = 1; >++ nntp_data->newsrc_ent[0].first = 1; >++ nntp_data->newsrc_ent[0].last = nntp_data->firstMessage - 1; >++ } >++ if (Context && Context->data == nntp_data) >++ { >++ unsigned int i; >++ >++ nntp_data->unread = Context->msgcount; >++ for (i = 0; i < Context->msgcount; i++) >++ mutt_set_flag (Context, Context->hdrs[i], M_READ, 0); >++ } >++ else >++ nntp_data->unread = nntp_data->lastMessage - nntp_data->newsrc_ent[0].last; >++ return nntp_data; >++} >++ >++/* Get first newsgroup with new messages */ >++void nntp_buffy (char *buf, size_t len) >++{ >++ unsigned int i; >++ >++ for (i = 0; i < CurrentNewsSrv->groups_num; i++) >++ { >++ NNTP_DATA *nntp_data = CurrentNewsSrv->groups_list[i]; >++ >++ if (!nntp_data || !nntp_data->subscribed || !nntp_data->unread) >++ continue; >++ >++ if (Context && Context->magic == M_NNTP && >++ !mutt_strcmp (nntp_data->group, ((NNTP_DATA *)Context->data)->group)) >++ { >++ unsigned int i, unread = 0; >++ >++ for (i = 0; i < Context->msgcount; i++) >++ if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted) >++ unread++; >++ if (!unread) >++ continue; >++ } >++ strfcpy (buf, nntp_data->group, len); >++ break; >++ } >++} >+diff -udprP mutt-1.5.23.orig/nntp.c mutt-1.5.23/nntp.c >+--- mutt-1.5.23.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300 >++++ mutt-1.5.23/nntp.c 2014-03-13 12:50:04.000000000 +0200 >+@@ -0,0 +1,2404 @@ >++/* >++ * Copyright (C) 1998 Brandon Long <blong@fiction.net> >++ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net> >++ * Copyright (C) 2000-2012 Vsevolod Volkov <vvv@mutt.org.ua> >++ * >++ * This program is free software; you can redistribute it and/or modify >++ * it under the terms of the GNU General Public License as published by >++ * the Free Software Foundation; either version 2 of the License, or >++ * (at your option) any later version. >++ * >++ * This program is distributed in the hope that it will be useful, >++ * but WITHOUT ANY WARRANTY; without even the implied warranty of >++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >++ * GNU General Public License for more details. >++ * >++ * You should have received a copy of the GNU General Public License >++ * along with this program; if not, write to the Free Software >++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >++ */ >++ >++#if HAVE_CONFIG_H >++#include "config.h" >++#endif >++ >++#include "mutt.h" >++#include "mutt_curses.h" >++#include "sort.h" >++#include "mx.h" >++#include "mime.h" >++#include "rfc1524.h" >++#include "rfc2047.h" >++#include "mailbox.h" >++#include "mutt_crypt.h" >++#include "nntp.h" >++ >++#if defined(USE_SSL) >++#include "mutt_ssl.h" >++#endif >++ >++#ifdef HAVE_PGP >++#include "pgp.h" >++#endif >++ >++#ifdef HAVE_SMIME >++#include "smime.h" >++#endif >++ >++#if USE_HCACHE >++#include "hcache.h" >++#endif >++ >++#include <unistd.h> >++#include <string.h> >++#include <ctype.h> >++#include <stdlib.h> >++ >++#ifdef USE_SASL >++#include <sasl/sasl.h> >++#include <sasl/saslutil.h> >++ >++#include "mutt_sasl.h" >++#endif >++ >++static int nntp_connect_error (NNTP_SERVER *nserv) >++{ >++ nserv->status = NNTP_NONE; >++ mutt_error _("Server closed connection!"); >++ mutt_sleep (2); >++ return -1; >++} >++ >++/* Get capabilities: >++ * -1 - error, connection is closed >++ * 0 - mode is reader, capabilities setted up >++ * 1 - need to switch to reader mode */ >++static int nntp_capabilities (NNTP_SERVER *nserv) >++{ >++ CONNECTION *conn = nserv->conn; >++ unsigned int mode_reader = 0; >++ char buf[LONG_STRING]; >++ char authinfo[LONG_STRING] = ""; >++ >++ nserv->hasCAPABILITIES = 0; >++ nserv->hasSTARTTLS = 0; >++ nserv->hasDATE = 0; >++ nserv->hasLIST_NEWSGROUPS = 0; >++ nserv->hasLISTGROUP = 0; >++ nserv->hasOVER = 0; >++ FREE (&nserv->authenticators); >++ >++ if (mutt_socket_write (conn, "CAPABILITIES\r\n") < 0 || >++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ >++ /* no capabilities */ >++ if (mutt_strncmp ("101", buf, 3)) >++ return 1; >++ nserv->hasCAPABILITIES = 1; >++ >++ /* parse capabilities */ >++ do >++ { >++ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ if (!mutt_strcmp ("STARTTLS", buf)) >++ nserv->hasSTARTTLS = 1; >++ else if (!mutt_strcmp ("MODE-READER", buf)) >++ mode_reader = 1; >++ else if (!mutt_strcmp ("READER", buf)) >++ { >++ nserv->hasDATE = 1; >++ nserv->hasLISTGROUP = 1; >++ } >++ else if (!mutt_strncmp ("AUTHINFO ", buf, 9)) >++ { >++ safe_strcat (buf, sizeof (buf), " "); >++ strfcpy (authinfo, buf + 8, sizeof (authinfo)); >++ } >++#ifdef USE_SASL >++ else if (!mutt_strncmp ("SASL ", buf, 5)) >++ { >++ char *p = buf + 5; >++ while (*p == ' ') >++ p++; >++ nserv->authenticators = safe_strdup (p); >++ } >++#endif >++ else if (!mutt_strcmp ("OVER", buf)) >++ nserv->hasOVER = 1; >++ else if (!mutt_strncmp ("LIST ", buf, 5)) >++ { >++ char *p = strstr (buf, " NEWSGROUPS"); >++ if (p) >++ { >++ p += 11; >++ if (*p == '\0' || *p == ' ') >++ nserv->hasLIST_NEWSGROUPS = 1; >++ } >++ } >++ } while (mutt_strcmp (".", buf)); >++ *buf = '\0'; >++#ifdef USE_SASL >++ if (nserv->authenticators && strcasestr (authinfo, " SASL ")) >++ strfcpy (buf, nserv->authenticators, sizeof (buf)); >++#endif >++ if (strcasestr (authinfo, " USER ")) >++ { >++ if (*buf) >++ safe_strcat (buf, sizeof (buf), " "); >++ safe_strcat (buf, sizeof (buf), "USER"); >++ } >++ mutt_str_replace (&nserv->authenticators, buf); >++ >++ /* current mode is reader */ >++ if (nserv->hasLISTGROUP) >++ return 0; >++ >++ /* server is mode-switching, need to switch to reader mode */ >++ if (mode_reader) >++ return 1; >++ >++ mutt_socket_close (conn); >++ nserv->status = NNTP_BYE; >++ mutt_error _("Server doesn't support reader mode."); >++ mutt_sleep (2); >++ return -1; >++} >++ >++char *OverviewFmt = >++ "Subject:\0" >++ "From:\0" >++ "Date:\0" >++ "Message-ID:\0" >++ "References:\0" >++ "Content-Length:\0" >++ "Lines:\0" >++ "\0"; >++ >++/* Detect supported commands */ >++static int nntp_attempt_features (NNTP_SERVER *nserv) >++{ >++ CONNECTION *conn = nserv->conn; >++ char buf[LONG_STRING]; >++ >++ /* no CAPABILITIES, trying DATE, LISTGROUP, LIST NEWSGROUPS */ >++ if (!nserv->hasCAPABILITIES) >++ { >++ if (mutt_socket_write (conn, "DATE\r\n") < 0 || >++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ if (mutt_strncmp ("500", buf, 3)) >++ nserv->hasDATE = 1; >++ >++ if (mutt_socket_write (conn, "LISTGROUP\r\n") < 0 || >++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ if (mutt_strncmp ("500", buf, 3)) >++ nserv->hasLISTGROUP = 1; >++ >++ if (mutt_socket_write (conn, "LIST NEWSGROUPS +\r\n") < 0 || >++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ if (mutt_strncmp ("500", buf, 3)) >++ nserv->hasLIST_NEWSGROUPS = 1; >++ if (!mutt_strncmp ("215", buf, 3)) >++ { >++ do >++ { >++ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ } while (mutt_strcmp (".", buf)); >++ } >++ } >++ >++ /* no LIST NEWSGROUPS, trying XGTITLE */ >++ if (!nserv->hasLIST_NEWSGROUPS) >++ { >++ if (mutt_socket_write (conn, "XGTITLE\r\n") < 0 || >++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ if (mutt_strncmp ("500", buf, 3)) >++ nserv->hasXGTITLE = 1; >++ } >++ >++ /* no OVER, trying XOVER */ >++ if (!nserv->hasOVER) >++ { >++ if (mutt_socket_write (conn, "XOVER\r\n") < 0 || >++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ if (mutt_strncmp ("500", buf, 3)) >++ nserv->hasXOVER = 1; >++ } >++ >++ /* trying LIST OVERVIEW.FMT */ >++ if (nserv->hasOVER || nserv->hasXOVER) >++ { >++ if (mutt_socket_write (conn, "LIST OVERVIEW.FMT\r\n") < 0 || >++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ if (mutt_strncmp ("215", buf, 3)) >++ nserv->overview_fmt = OverviewFmt; >++ else >++ { >++ int chunk, cont = 0; >++ size_t buflen = 2 * LONG_STRING, off = 0, b = 0; >++ >++ if (nserv->overview_fmt) >++ FREE (&nserv->overview_fmt); >++ nserv->overview_fmt = safe_malloc (buflen); >++ >++ while (1) >++ { >++ if (buflen - off < LONG_STRING) >++ { >++ buflen *= 2; >++ safe_realloc (&nserv->overview_fmt, buflen); >++ } >++ >++ chunk = mutt_socket_readln (nserv->overview_fmt + off, >++ buflen - off, conn); >++ if (chunk < 0) >++ { >++ FREE (&nserv->overview_fmt); >++ return nntp_connect_error (nserv); >++ } >++ >++ if (!cont && !mutt_strcmp (".", nserv->overview_fmt + off)) >++ break; >++ >++ cont = chunk >= buflen - off ? 1 : 0; >++ off += strlen (nserv->overview_fmt + off); >++ if (!cont) >++ { >++ char *colon; >++ >++ if (nserv->overview_fmt[b] == ':') >++ { >++ memmove (nserv->overview_fmt + b, >++ nserv->overview_fmt + b + 1, off - b - 1); >++ nserv->overview_fmt[off - 1] = ':'; >++ } >++ colon = strchr (nserv->overview_fmt + b, ':'); >++ if (!colon) >++ nserv->overview_fmt[off++] = ':'; >++ else if (strcmp (colon + 1, "full")) >++ off = colon + 1 - nserv->overview_fmt; >++ if (!strcasecmp (nserv->overview_fmt + b, "Bytes:")) >++ { >++ strcpy (nserv->overview_fmt + b, "Content-Length:"); >++ off = b + strlen (nserv->overview_fmt + b); >++ } >++ nserv->overview_fmt[off++] = '\0'; >++ b = off; >++ } >++ } >++ nserv->overview_fmt[off++] = '\0'; >++ safe_realloc (&nserv->overview_fmt, off); >++ } >++ } >++ return 0; >++} >++ >++/* Get login, password and authenticate */ >++static int nntp_auth (NNTP_SERVER *nserv) >++{ >++ CONNECTION *conn = nserv->conn; >++ char buf[LONG_STRING]; >++ char authenticators[LONG_STRING] = "USER"; >++ char *method, *a, *p; >++ unsigned char flags = conn->account.flags; >++ >++ while (1) >++ { >++ /* get login and password */ >++ if (mutt_account_getuser (&conn->account) || !conn->account.user[0] || >++ mutt_account_getpass (&conn->account) || !conn->account.pass[0]) >++ break; >++ >++ /* get list of authenticators */ >++ if (NntpAuthenticators && *NntpAuthenticators) >++ strfcpy (authenticators, NntpAuthenticators, sizeof (authenticators)); >++ else if (nserv->hasCAPABILITIES) >++ { >++ strfcpy (authenticators, NONULL (nserv->authenticators), >++ sizeof (authenticators)); >++ p = authenticators; >++ while (*p) >++ { >++ if (*p == ' ') >++ *p = ':'; >++ p++; >++ } >++ } >++ p = authenticators; >++ while (*p) >++ { >++ *p = ascii_toupper (*p); >++ p++; >++ } >++ >++ dprint (1, (debugfile, >++ "nntp_auth: available methods: %s\n", nserv->authenticators)); >++ a = authenticators; >++ while (1) >++ { >++ if (!a) >++ { >++ mutt_error _("No authenticators available"); >++ mutt_sleep (2); >++ break; >++ } >++ >++ method = a; >++ a = strchr (a, ':'); >++ if (a) >++ *a++ = '\0'; >++ >++ /* check authenticator */ >++ if (nserv->hasCAPABILITIES) >++ { >++ char *m; >++ >++ if (!nserv->authenticators) >++ continue; >++ m = strcasestr (nserv->authenticators, method); >++ if (!m) >++ continue; >++ if (m > nserv->authenticators && *(m - 1) != ' ') >++ continue; >++ m += strlen (method); >++ if (*m != '\0' && *m != ' ') >++ continue; >++ } >++ dprint (1, (debugfile, "nntp_auth: trying method %s\n", method)); >++ >++ /* AUTHINFO USER authentication */ >++ if (!strcmp (method, "USER")) >++ { >++ mutt_message (_("Authenticating (%s)..."), method); >++ snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user); >++ if (mutt_socket_write (conn, buf) < 0 || >++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ break; >++ >++ /* authenticated, password is not required */ >++ if (!mutt_strncmp ("281", buf, 3)) >++ return 0; >++ >++ /* username accepted, sending password */ >++ if (!mutt_strncmp ("381", buf, 3)) >++ { >++#ifdef DEBUG >++ if (debuglevel < M_SOCK_LOG_FULL) >++ dprint (M_SOCK_LOG_CMD, (debugfile, >++ "%d> AUTHINFO PASS *\n", conn->fd)); >++#endif >++ snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", >++ conn->account.pass); >++ if (mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL) < 0 || >++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ break; >++ >++ /* authenticated */ >++ if (!mutt_strncmp ("281", buf, 3)) >++ return 0; >++ } >++ >++ /* server doesn't support AUTHINFO USER, trying next method */ >++ if (*buf == '5') >++ continue; >++ } >++ >++ else >++ { >++#ifdef USE_SASL >++ sasl_conn_t *saslconn; >++ sasl_interact_t *interaction = NULL; >++ int rc; >++ char inbuf[LONG_STRING] = ""; >++ const char *mech; >++ const char *client_out = NULL; >++ unsigned int client_len, len; >++ >++ if (mutt_sasl_client_new (conn, &saslconn) < 0) >++ { >++ dprint (1, (debugfile, >++ "nntp_auth: error allocating SASL connection.\n")); >++ continue; >++ } >++ >++ while (1) >++ { >++ rc = sasl_client_start (saslconn, method, &interaction, >++ &client_out, &client_len, &mech); >++ if (rc != SASL_INTERACT) >++ break; >++ mutt_sasl_interact (interaction); >++ } >++ if (rc != SASL_OK && rc != SASL_CONTINUE) >++ { >++ sasl_dispose (&saslconn); >++ dprint (1, (debugfile, >++ "nntp_auth: error starting SASL authentication exchange.\n")); >++ continue; >++ } >++ >++ mutt_message (_("Authenticating (%s)..."), method); >++ snprintf (buf, sizeof (buf), "AUTHINFO SASL %s", method); >++ >++ /* looping protocol */ >++ while (rc == SASL_CONTINUE || (rc == SASL_OK && client_len)) >++ { >++ /* send out client response */ >++ if (client_len) >++ { >++#ifdef DEBUG >++ if (debuglevel >= M_SOCK_LOG_FULL) >++ { >++ char tmp[LONG_STRING]; >++ memcpy (tmp, client_out, client_len); >++ for (p = tmp; p < tmp + client_len; p++) >++ { >++ if (*p == '\0') >++ *p = '.'; >++ } >++ *p = '\0'; >++ dprint (1, (debugfile, "SASL> %s\n", tmp)); >++ } >++#endif >++ >++ if (*buf) >++ safe_strcat (buf, sizeof (buf), " "); >++ len = strlen (buf); >++ if (sasl_encode64 (client_out, client_len, >++ buf + len, sizeof (buf) - len, &len) != SASL_OK) >++ { >++ dprint (1, (debugfile, >++ "nntp_auth: error base64-encoding client response.\n")); >++ break; >++ } >++ } >++ >++ safe_strcat (buf, sizeof (buf), "\r\n"); >++#ifdef DEBUG >++ if (debuglevel < M_SOCK_LOG_FULL) >++ { >++ if (strchr (buf, ' ')) >++ dprint (M_SOCK_LOG_CMD, (debugfile, "%d> AUTHINFO SASL %s%s\n", >++ conn->fd, method, client_len ? " sasl_data" : "")); >++ else >++ dprint (M_SOCK_LOG_CMD, (debugfile, "%d> sasl_data\n", conn->fd)); >++ } >++#endif >++ client_len = 0; >++ if (mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL) < 0 || >++ mutt_socket_readln_d (inbuf, sizeof (inbuf), conn, M_SOCK_LOG_FULL) < 0) >++ break; >++ if (mutt_strncmp (inbuf, "283 ", 4) && >++ mutt_strncmp (inbuf, "383 ", 4)) >++ { >++#ifdef DEBUG >++ if (debuglevel < M_SOCK_LOG_FULL) >++ dprint (M_SOCK_LOG_CMD, (debugfile, "%d< %s\n", conn->fd, inbuf)); >++#endif >++ break; >++ } >++#ifdef DEBUG >++ if (debuglevel < M_SOCK_LOG_FULL) >++ { >++ inbuf[3] = '\0'; >++ dprint (M_SOCK_LOG_CMD, (debugfile, >++ "%d< %s sasl_data\n", conn->fd, inbuf)); >++ } >++#endif >++ >++ if (!strcmp ("=", inbuf + 4)) >++ len = 0; >++ else if (sasl_decode64 (inbuf + 4, strlen (inbuf + 4), >++ buf, sizeof (buf) - 1, &len) != SASL_OK) >++ { >++ dprint (1, (debugfile, >++ "nntp_auth: error base64-decoding server response.\n")); >++ break; >++ } >++#ifdef DEBUG >++ else if (debuglevel >= M_SOCK_LOG_FULL) >++ { >++ char tmp[LONG_STRING]; >++ memcpy (tmp, buf, len); >++ for (p = tmp; p < tmp + len; p++) >++ { >++ if (*p == '\0') >++ *p = '.'; >++ } >++ *p = '\0'; >++ dprint (1, (debugfile, "SASL< %s\n", tmp)); >++ } >++#endif >++ >++ while (1) >++ { >++ rc = sasl_client_step (saslconn, buf, len, >++ &interaction, &client_out, &client_len); >++ if (rc != SASL_INTERACT) >++ break; >++ mutt_sasl_interact (interaction); >++ } >++ if (*inbuf != '3') >++ break; >++ >++ *buf = '\0'; >++ } /* looping protocol */ >++ >++ if (rc == SASL_OK && client_len == 0 && *inbuf == '2') >++ { >++ mutt_sasl_setup_conn (conn, saslconn); >++ return 0; >++ } >++ >++ /* terminate SASL sessoin */ >++ sasl_dispose (&saslconn); >++ if (conn->fd < 0) >++ break; >++ if (!mutt_strncmp (inbuf, "383 ", 4)) >++ { >++ if (mutt_socket_write (conn, "*\r\n") < 0 || >++ mutt_socket_readln (inbuf, sizeof (inbuf), conn) < 0) >++ break; >++ } >++ >++ /* server doesn't support AUTHINFO SASL, trying next method */ >++ if (*inbuf == '5') >++ continue; >++#else >++ continue; >++#endif /* USE_SASL */ >++ } >++ >++ mutt_error (_("%s authentication failed."), method); >++ mutt_sleep (2); >++ break; >++ } >++ break; >++ } >++ >++ /* error */ >++ nserv->status = NNTP_BYE; >++ conn->account.flags = flags; >++ if (conn->fd < 0) >++ { >++ mutt_error _("Server closed connection!"); >++ mutt_sleep (2); >++ } >++ else >++ mutt_socket_close (conn); >++ return -1; >++} >++ >++/* Connect to server, authenticate and get capabilities */ >++int nntp_open_connection (NNTP_SERVER *nserv) >++{ >++ CONNECTION *conn = nserv->conn; >++ char buf[STRING]; >++ int cap; >++ unsigned int posting = 0, auth = 1; >++ >++ if (nserv->status == NNTP_OK) >++ return 0; >++ if (nserv->status == NNTP_BYE) >++ return -1; >++ nserv->status = NNTP_NONE; >++ >++ if (mutt_socket_open (conn) < 0) >++ return -1; >++ >++ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ >++ if (!mutt_strncmp ("200", buf, 3)) >++ posting = 1; >++ else if (mutt_strncmp ("201", buf, 3)) >++ { >++ mutt_socket_close (conn); >++ mutt_remove_trailing_ws (buf); >++ mutt_error ("%s", buf); >++ mutt_sleep (2); >++ return -1; >++ } >++ >++ /* get initial capabilities */ >++ cap = nntp_capabilities (nserv); >++ if (cap < 0) >++ return -1; >++ >++ /* tell news server to switch to mode reader if it isn't so */ >++ if (cap > 0) >++ { >++ if (mutt_socket_write (conn, "MODE READER\r\n") < 0 || >++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ >++ if (!mutt_strncmp ("200", buf, 3)) >++ posting = 1; >++ else if (!mutt_strncmp ("201", buf, 3)) >++ posting = 0; >++ /* error if has capabilities, ignore result if no capabilities */ >++ else if (nserv->hasCAPABILITIES) >++ { >++ mutt_socket_close (conn); >++ mutt_error _("Could not switch to reader mode."); >++ mutt_sleep (2); >++ return -1; >++ } >++ >++ /* recheck capabilities after MODE READER */ >++ if (nserv->hasCAPABILITIES) >++ { >++ cap = nntp_capabilities (nserv); >++ if (cap < 0) >++ return -1; >++ } >++ } >++ >++ mutt_message (_("Connected to %s. %s"), conn->account.host, >++ posting ? _("Posting is ok.") : _("Posting is NOT ok.")); >++ mutt_sleep (1); >++ >++#if defined(USE_SSL) >++ /* Attempt STARTTLS if available and desired. */ >++ if (nserv->use_tls != 1 && (nserv->hasSTARTTLS || option (OPTSSLFORCETLS))) >++ { >++ if (nserv->use_tls == 0) >++ nserv->use_tls = option (OPTSSLFORCETLS) || >++ query_quadoption (OPT_SSLSTARTTLS, >++ _("Secure connection with TLS?")) == M_YES ? 2 : 1; >++ if (nserv->use_tls == 2) >++ { >++ if (mutt_socket_write (conn, "STARTTLS\r\n") < 0 || >++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ if (mutt_strncmp ("382", buf, 3)) >++ { >++ nserv->use_tls = 0; >++ mutt_error ("STARTTLS: %s", buf); >++ mutt_sleep (2); >++ } >++ else if (mutt_ssl_starttls (conn)) >++ { >++ nserv->use_tls = 0; >++ nserv->status = NNTP_NONE; >++ mutt_socket_close (nserv->conn); >++ mutt_error _("Could not negotiate TLS connection"); >++ mutt_sleep (2); >++ return -1; >++ } >++ else >++ { >++ /* recheck capabilities after STARTTLS */ >++ cap = nntp_capabilities (nserv); >++ if (cap < 0) >++ return -1; >++ } >++ } >++ } >++#endif >++ >++ /* authentication required? */ >++ if (conn->account.flags & M_ACCT_USER) >++ { >++ if (!conn->account.user[0]) >++ auth = 0; >++ } >++ else >++ { >++ if (mutt_socket_write (conn, "STAT\r\n") < 0 || >++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) >++ return nntp_connect_error (nserv); >++ if (mutt_strncmp ("480", buf, 3)) >++ auth = 0; >++ } >++ >++ /* authenticate */ >++ if (auth && nntp_auth (nserv) < 0) >++ return -1; >++ >++ /* get final capabilities after authentication */ >++ if (nserv->hasCAPABILITIES && (auth || cap > 0)) >++ { >++ cap = nntp_capabilities (nserv); >++ if (cap < 0) >++ return -1; >++ if (cap > 0) >++ { >++ mutt_socket_close (conn); >++ mutt_error _("Could not switch to reader mode."); >++ mutt_sleep (2); >++ return -1; >++ } >++ } >++ >++ /* attempt features */ >++ if (nntp_attempt_features (nserv) < 0) >++ return -1; >++ >++ nserv->status = NNTP_OK; >++ return 0; >++} >++ >++/* Send data from buffer and receive answer to same buffer */ >++static int nntp_query (NNTP_DATA *nntp_data, char *line, size_t linelen) >++{ >++ NNTP_SERVER *nserv = nntp_data->nserv; >++ char buf[LONG_STRING]; >++ >++ if (nserv->status == NNTP_BYE) >++ return -1; >++ >++ while (1) >++ { >++ if (nserv->status == NNTP_OK) >++ { >++ int rc = 0; >++ >++ if (*line) >++ rc = mutt_socket_write (nserv->conn, line); >++ else if (nntp_data->group) >++ { >++ snprintf (buf, sizeof (buf), "GROUP %s\r\n", nntp_data->group); >++ rc = mutt_socket_write (nserv->conn, buf); >++ } >++ if (rc >= 0) >++ rc = mutt_socket_readln (buf, sizeof (buf), nserv->conn); >++ if (rc >= 0) >++ break; >++ } >++ >++ /* reconnect */ >++ while (1) >++ { >++ nserv->status = NNTP_NONE; >++ if (nntp_open_connection (nserv) == 0) >++ break; >++ >++ snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"), >++ nserv->conn->account.host); >++ if (mutt_yesorno (buf, M_YES) != M_YES) >++ { >++ nserv->status = NNTP_BYE; >++ return -1; >++ } >++ } >++ >++ /* select newsgroup after reconnection */ >++ if (nntp_data->group) >++ { >++ snprintf (buf, sizeof (buf), "GROUP %s\r\n", nntp_data->group); >++ if (mutt_socket_write (nserv->conn, buf) < 0 || >++ mutt_socket_readln (buf, sizeof (buf), nserv->conn) < 0) >++ return nntp_connect_error (nserv); >++ } >++ if (!*line) >++ break; >++ } >++ >++ strfcpy (line, buf, linelen); >++ return 0; >++} >++ >++/* This function calls funct(*line, *data) for each received line, >++ * funct(NULL, *data) if rewind(*data) needs, exits when fail or done: >++ * 0 - success >++ * 1 - bad response (answer in query buffer) >++ * -1 - conection lost >++ * -2 - error in funct(*line, *data) */ >++static int nntp_fetch_lines (NNTP_DATA *nntp_data, char *query, size_t qlen, >++ char *msg, int (*funct) (char *, void *), void *data) >++{ >++ int done = FALSE; >++ int rc; >++ >++ while (!done) >++ { >++ char buf[LONG_STRING]; >++ char *line; >++ unsigned int lines = 0; >++ size_t off = 0; >++ progress_t progress; >++ >++ if (msg) >++ mutt_progress_init (&progress, msg, M_PROGRESS_MSG, ReadInc, -1); >++ >++ strfcpy (buf, query, sizeof (buf)); >++ if (nntp_query (nntp_data, buf, sizeof (buf)) < 0) >++ return -1; >++ if (buf[0] != '2') >++ { >++ strfcpy (query, buf, qlen); >++ return 1; >++ } >++ >++ line = safe_malloc (sizeof (buf)); >++ rc = 0; >++ >++ while (1) >++ { >++ char *p; >++ int chunk = mutt_socket_readln_d (buf, sizeof (buf), >++ nntp_data->nserv->conn, M_SOCK_LOG_HDR); >++ if (chunk < 0) >++ { >++ nntp_data->nserv->status = NNTP_NONE; >++ break; >++ } >++ >++ p = buf; >++ if (!off && buf[0] == '.') >++ { >++ if (buf[1] == '\0') >++ { >++ done = TRUE; >++ break; >++ } >++ if (buf[1] == '.') >++ p++; >++ } >++ >++ strfcpy (line + off, p, sizeof (buf)); >++ >++ if (chunk >= sizeof (buf)) >++ off += strlen (p); >++ else >++ { >++ if (msg) >++ mutt_progress_update (&progress, ++lines, -1); >++ >++ if (rc == 0 && funct (line, data) < 0) >++ rc = -2; >++ off = 0; >++ } >++ >++ safe_realloc (&line, off + sizeof (buf)); >++ } >++ FREE (&line); >++ funct (NULL, data); >++ } >++ return rc; >++} >++ >++/* Parse newsgroup description */ >++static int fetch_description (char *line, void *data) >++{ >++ NNTP_SERVER *nserv = data; >++ NNTP_DATA *nntp_data; >++ char *desc; >++ >++ if (!line) >++ return 0; >++ >++ desc = strpbrk (line, " \t"); >++ if (desc) >++ { >++ *desc++ = '\0'; >++ desc += strspn (desc, " \t"); >++ } >++ else >++ desc = strchr (line, '\0'); >++ >++ nntp_data = hash_find (nserv->groups_hash, line); >++ if (nntp_data && mutt_strcmp (desc, nntp_data->desc)) >++ { >++ mutt_str_replace (&nntp_data->desc, desc); >++ dprint (2, (debugfile, "group: %s, desc: %s\n", line, desc)); >++ } >++ return 0; >++} >++ >++/* Fetch newsgroups descriptions. >++ * Returns the same code as nntp_fetch_lines() */ >++static int get_description (NNTP_DATA *nntp_data, char *wildmat, char *msg) >++{ >++ NNTP_SERVER *nserv; >++ char buf[STRING]; >++ char *cmd; >++ int rc; >++ >++ /* get newsgroup description, if possible */ >++ nserv = nntp_data->nserv; >++ if (!wildmat) >++ wildmat = nntp_data->group; >++ if (nserv->hasLIST_NEWSGROUPS) >++ cmd = "LIST NEWSGROUPS"; >++ else if (nserv->hasXGTITLE) >++ cmd = "XGTITLE"; >++ else >++ return 0; >++ >++ snprintf (buf, sizeof (buf), "%s %s\r\n", cmd, wildmat); >++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), msg, >++ fetch_description, nserv); >++ if (rc > 0) >++ { >++ mutt_error ("%s: %s", cmd, buf); >++ mutt_sleep (2); >++ } >++ return rc; >++} >++ >++/* Update read flag and set article number if empty */ >++static void nntp_parse_xref (CONTEXT *ctx, HEADER *hdr) >++{ >++ NNTP_DATA *nntp_data = ctx->data; >++ char *buf, *p; >++ >++ buf = p = safe_strdup (hdr->env->xref); >++ while (p) >++ { >++ char *grp, *colon; >++ anum_t anum; >++ >++ /* skip to next word */ >++ p += strspn (p, " \t"); >++ grp = p; >++ >++ /* skip to end of word */ >++ p = strpbrk (p, " \t"); >++ if (p) >++ *p++ = '\0'; >++ >++ /* find colon */ >++ colon = strchr (grp, ':'); >++ if (!colon) >++ continue; >++ *colon++ = '\0'; >++ if (sscanf (colon, ANUM, &anum) != 1) >++ continue; >++ >++ nntp_article_status (ctx, hdr, grp, anum); >++ if (hdr && !NHDR (hdr)->article_num && !mutt_strcmp (nntp_data->group, grp)) >++ NHDR (hdr)->article_num = anum; >++ } >++ FREE (&buf); >++} >++ >++/* Write line to temporarily file */ >++static int fetch_tempfile (char *line, void *data) >++{ >++ FILE *fp = data; >++ >++ if (!line) >++ rewind (fp); >++ else if (fputs (line, fp) == EOF || fputc ('\n', fp) == EOF) >++ return -1; >++ return 0; >++} >++ >++typedef struct >++{ >++ CONTEXT *ctx; >++ anum_t first; >++ anum_t last; >++ int restore; >++ unsigned char *messages; >++ progress_t progress; >++#ifdef USE_HCACHE >++ header_cache_t *hc; >++#endif >++} FETCH_CTX; >++ >++/* Parse article number */ >++static int fetch_numbers (char *line, void *data) >++{ >++ FETCH_CTX *fc = data; >++ anum_t anum; >++ >++ if (!line) >++ return 0; >++ if (sscanf (line, ANUM, &anum) != 1) >++ return 0; >++ if (anum < fc->first || anum > fc->last) >++ return 0; >++ fc->messages[anum - fc->first] = 1; >++ return 0; >++} >++ >++/* Parse overview line */ >++static int parse_overview_line (char *line, void *data) >++{ >++ FETCH_CTX *fc = data; >++ CONTEXT *ctx = fc->ctx; >++ NNTP_DATA *nntp_data = ctx->data; >++ HEADER *hdr; >++ FILE *fp; >++ char tempfile[_POSIX_PATH_MAX]; >++ char *header, *field; >++ int save = 1; >++ anum_t anum; >++ >++ if (!line) >++ return 0; >++ >++ /* parse article number */ >++ field = strchr (line, '\t'); >++ if (field) >++ *field++ = '\0'; >++ if (sscanf (line, ANUM, &anum) != 1) >++ return 0; >++ dprint (2, (debugfile, "parse_overview_line: " ANUM "\n", anum)); >++ >++ /* out of bounds */ >++ if (anum < fc->first || anum > fc->last) >++ return 0; >++ >++ /* not in LISTGROUP */ >++ if (!fc->messages[anum - fc->first]) >++ { >++ /* progress */ >++ if (!ctx->quiet) >++ mutt_progress_update (&fc->progress, anum - fc->first + 1, -1); >++ return 0; >++ } >++ >++ /* convert overview line to header */ >++ mutt_mktemp (tempfile, sizeof (tempfile)); >++ fp = safe_fopen (tempfile, "w+"); >++ if (!fp) >++ return -1; >++ >++ header = nntp_data->nserv->overview_fmt; >++ while (field) >++ { >++ char *b = field; >++ >++ if (*header) >++ { >++ if (strstr (header, ":full") == NULL && fputs (header, fp) == EOF) >++ { >++ fclose (fp); >++ unlink (tempfile); >++ return -1; >++ } >++ header = strchr (header, '\0') + 1; >++ } >++ >++ field = strchr (field, '\t'); >++ if (field) >++ *field++ = '\0'; >++ if (fputs (b, fp) == EOF || fputc ('\n', fp) == EOF) >++ { >++ fclose (fp); >++ unlink (tempfile); >++ return -1; >++ } >++ } >++ rewind (fp); >++ >++ /* allocate memory for headers */ >++ if (ctx->msgcount >= ctx->hdrmax) >++ mx_alloc_memory (ctx); >++ >++ /* parse header */ >++ hdr = ctx->hdrs[ctx->msgcount] = mutt_new_header (); >++ hdr->env = mutt_read_rfc822_header (fp, hdr, 0, 0); >++ hdr->env->newsgroups = safe_strdup (nntp_data->group); >++ hdr->received = hdr->date_sent; >++ fclose (fp); >++ unlink (tempfile); >++ >++#ifdef USE_HCACHE >++ if (fc->hc) >++ { >++ void *hdata; >++ char buf[16]; >++ >++ /* try to replace with header from cache */ >++ snprintf (buf, sizeof (buf), "%d", anum); >++ hdata = mutt_hcache_fetch (fc->hc, buf, strlen); >++ if (hdata) >++ { >++ dprint (2, (debugfile, >++ "parse_overview_line: mutt_hcache_fetch %s\n", buf)); >++ mutt_free_header (&hdr); >++ ctx->hdrs[ctx->msgcount] = >++ hdr = mutt_hcache_restore (hdata, NULL); >++ hdr->read = 0; >++ hdr->old = 0; >++ >++ /* skip header marked as deleted in cache */ >++ if (hdr->deleted && !fc->restore) >++ { >++ if (nntp_data->bcache) >++ { >++ dprint (2, (debugfile, >++ "parse_overview_line: mutt_bcache_del %s\n", buf)); >++ mutt_bcache_del (nntp_data->bcache, buf); >++ } >++ save = 0; >++ } >++ } >++ >++ /* not chached yet, store header */ >++ else >++ { >++ dprint (2, (debugfile, >++ "parse_overview_line: mutt_hcache_store %s\n", buf)); >++ mutt_hcache_store (fc->hc, buf, hdr, 0, strlen, M_GENERATE_UIDVALIDITY); >++ } >++ } >++#endif >++ >++ if (save) >++ { >++ hdr->index = ctx->msgcount++; >++ hdr->read = 0; >++ hdr->old = 0; >++ hdr->deleted = 0; >++ hdr->data = safe_calloc (1, sizeof (NNTP_HEADER_DATA)); >++ NHDR (hdr)->article_num = anum; >++ if (fc->restore) >++ hdr->changed = 1; >++ else >++ { >++ nntp_article_status (ctx, hdr, NULL, anum); >++ if (!hdr->read) >++ nntp_parse_xref (ctx, hdr); >++ } >++ if (anum > nntp_data->lastLoaded) >++ nntp_data->lastLoaded = anum; >++ } >++ else >++ mutt_free_header (&hdr); >++ >++ /* progress */ >++ if (!ctx->quiet) >++ mutt_progress_update (&fc->progress, anum - fc->first + 1, -1); >++ return 0; >++} >++ >++/* Fetch headers */ >++static int nntp_fetch_headers (CONTEXT *ctx, void *hc, >++ anum_t first, anum_t last, int restore) >++{ >++ NNTP_DATA *nntp_data = ctx->data; >++ FETCH_CTX fc; >++ HEADER *hdr; >++ char buf[HUGE_STRING]; >++ int rc = 0; >++ int oldmsgcount = ctx->msgcount; >++ anum_t current; >++#ifdef USE_HCACHE >++ void *hdata; >++#endif >++ >++ /* if empty group or nothing to do */ >++ if (!last || first > last) >++ return 0; >++ >++ /* init fetch context */ >++ fc.ctx = ctx; >++ fc.first = first; >++ fc.last = last; >++ fc.restore = restore; >++ fc.messages = safe_calloc (last - first + 1, sizeof (unsigned char)); >++#ifdef USE_HCACHE >++ fc.hc = hc; >++#endif >++ >++ /* fetch list of articles */ >++ if (nntp_data->nserv->hasLISTGROUP && !nntp_data->deleted) >++ { >++ if (!ctx->quiet) >++ mutt_message _("Fetching list of articles..."); >++ snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group); >++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL, >++ fetch_numbers, &fc); >++ if (rc > 0) >++ { >++ mutt_error ("LISTGROUP: %s", buf); >++ mutt_sleep (2); >++ } >++ if (rc == 0) >++ { >++ for (current = first; current <= last && rc == 0; current++) >++ { >++ if (fc.messages[current - first]) >++ continue; >++ >++ snprintf (buf, sizeof (buf), "%d", current); >++ if (nntp_data->bcache) >++ { >++ dprint (2, (debugfile, >++ "nntp_fetch_headers: mutt_bcache_del %s\n", buf)); >++ mutt_bcache_del (nntp_data->bcache, buf); >++ } >++ >++#ifdef USE_HCACHE >++ if (fc.hc) >++ { >++ dprint (2, (debugfile, >++ "nntp_fetch_headers: mutt_hcache_delete %s\n", buf)); >++ mutt_hcache_delete (fc.hc, buf, strlen); >++ } >++#endif >++ } >++ } >++ } >++ else >++ for (current = first; current <= last; current++) >++ fc.messages[current - first] = 1; >++ >++ /* fetching header from cache or server, or fallback to fetch overview */ >++ if (!ctx->quiet) >++ mutt_progress_init (&fc.progress, _("Fetching message headers..."), >++ M_PROGRESS_MSG, ReadInc, last - first + 1); >++ for (current = first; current <= last && rc == 0; current++) >++ { >++ if (!ctx->quiet) >++ mutt_progress_update (&fc.progress, current - first + 1, -1); >++ >++#ifdef USE_HCACHE >++ snprintf (buf, sizeof (buf), "%d", current); >++#endif >++ >++ /* delete header from cache that does not exist on server */ >++ if (!fc.messages[current - first]) >++ continue; >++ >++ /* allocate memory for headers */ >++ if (ctx->msgcount >= ctx->hdrmax) >++ mx_alloc_memory (ctx); >++ >++#ifdef USE_HCACHE >++ /* try to fetch header from cache */ >++ hdata = mutt_hcache_fetch (fc.hc, buf, strlen); >++ if (hdata) >++ { >++ dprint (2, (debugfile, >++ "nntp_fetch_headers: mutt_hcache_fetch %s\n", buf)); >++ ctx->hdrs[ctx->msgcount] = >++ hdr = mutt_hcache_restore (hdata, NULL); >++ >++ /* skip header marked as deleted in cache */ >++ if (hdr->deleted && !restore) >++ { >++ mutt_free_header (&hdr); >++ if (nntp_data->bcache) >++ { >++ dprint (2, (debugfile, >++ "nntp_fetch_headers: mutt_bcache_del %s\n", buf)); >++ mutt_bcache_del (nntp_data->bcache, buf); >++ } >++ continue; >++ } >++ >++ hdr->read = 0; >++ hdr->old = 0; >++ } >++ else >++#endif >++ >++ /* don't try to fetch header from removed newsgroup */ >++ if (nntp_data->deleted) >++ continue; >++ >++ /* fallback to fetch overview */ >++ else if (nntp_data->nserv->hasOVER || nntp_data->nserv->hasXOVER) >++ break; >++ >++ /* fetch header from server */ >++ else >++ { >++ FILE *fp; >++ char tempfile[_POSIX_PATH_MAX]; >++ >++ mutt_mktemp (tempfile, sizeof (tempfile)); >++ fp = safe_fopen (tempfile, "w+"); >++ if (!fp) >++ { >++ mutt_perror (tempfile); >++ mutt_sleep (2); >++ unlink (tempfile); >++ rc = -1; >++ break; >++ } >++ >++ snprintf (buf, sizeof (buf), "HEAD %d\r\n", current); >++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL, >++ fetch_tempfile, fp); >++ if (rc) >++ { >++ fclose (fp); >++ unlink (tempfile); >++ if (rc < 0) >++ break; >++ >++ /* invalid response */ >++ if (mutt_strncmp ("423", buf, 3)) >++ { >++ mutt_error ("HEAD: %s", buf); >++ mutt_sleep (2); >++ break; >++ } >++ >++ /* no such article */ >++ if (nntp_data->bcache) >++ { >++ snprintf (buf, sizeof (buf), "%d", current); >++ dprint (2, (debugfile, >++ "nntp_fetch_headers: mutt_bcache_del %s\n", buf)); >++ mutt_bcache_del (nntp_data->bcache, buf); >++ } >++ rc = 0; >++ continue; >++ } >++ >++ /* parse header */ >++ hdr = ctx->hdrs[ctx->msgcount] = mutt_new_header (); >++ hdr->env = mutt_read_rfc822_header (fp, hdr, 0, 0); >++ hdr->received = hdr->date_sent; >++ fclose (fp); >++ unlink (tempfile); >++ } >++ >++ /* save header in context */ >++ hdr->index = ctx->msgcount++; >++ hdr->read = 0; >++ hdr->old = 0; >++ hdr->deleted = 0; >++ hdr->data = safe_calloc (1, sizeof (NNTP_HEADER_DATA)); >++ NHDR (hdr)->article_num = current; >++ if (restore) >++ hdr->changed = 1; >++ else >++ { >++ nntp_article_status (ctx, hdr, NULL, NHDR (hdr)->article_num); >++ if (!hdr->read) >++ nntp_parse_xref (ctx, hdr); >++ } >++ if (current > nntp_data->lastLoaded) >++ nntp_data->lastLoaded = current; >++ } >++ >++ /* fetch overview information */ >++ if (current <= last && rc == 0) { >++ char *cmd = nntp_data->nserv->hasOVER ? "OVER" : "XOVER"; >++ snprintf (buf, sizeof (buf), "%s %d-%d\r\n", cmd, current, last); >++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL, >++ parse_overview_line, &fc); >++ if (rc > 0) >++ { >++ mutt_error ("%s: %s", cmd, buf); >++ mutt_sleep (2); >++ } >++ } >++ >++ if (ctx->msgcount > oldmsgcount) >++ mx_update_context (ctx, ctx->msgcount - oldmsgcount); >++ >++ FREE (&fc.messages); >++ if (rc != 0) >++ return -1; >++ mutt_clear_error (); >++ return 0; >++} >++ >++/* Open newsgroup */ >++int nntp_open_mailbox (CONTEXT *ctx) >++{ >++ NNTP_SERVER *nserv; >++ NNTP_DATA *nntp_data; >++ char buf[HUGE_STRING]; >++ char server[LONG_STRING]; >++ char *group; >++ int rc; >++ void *hc = NULL; >++ anum_t first, last, count = 0; >++ ciss_url_t url; >++ >++ strfcpy (buf, ctx->path, sizeof (buf)); >++ if (url_parse_ciss (&url, buf) < 0 || !url.path || >++ !(url.scheme == U_NNTP || url.scheme == U_NNTPS)) >++ { >++ mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path); >++ mutt_sleep (2); >++ return -1; >++ } >++ >++ group = url.path; >++ url.path = strchr (url.path, '\0'); >++ url_ciss_tostring (&url, server, sizeof (server), 0); >++ nserv = nntp_select_server (server, 1); >++ if (!nserv) >++ return -1; >++ CurrentNewsSrv = nserv; >++ >++ /* find news group data structure */ >++ nntp_data = hash_find (nserv->groups_hash, group); >++ if (!nntp_data) >++ { >++ nntp_newsrc_close (nserv); >++ mutt_error (_("Newsgroup %s not found on the server."), group); >++ mutt_sleep (2); >++ return -1; >++ } >++ >++ mutt_bit_unset (ctx->rights, M_ACL_INSERT); >++ if (!nntp_data->newsrc_ent && !nntp_data->subscribed && >++ !option (OPTSAVEUNSUB)) >++ ctx->readonly = 1; >++ >++ /* select newsgroup */ >++ mutt_message (_("Selecting %s..."), group); >++ buf[0] = '\0'; >++ if (nntp_query (nntp_data, buf, sizeof (buf)) < 0) >++ { >++ nntp_newsrc_close (nserv); >++ return -1; >++ } >++ >++ /* newsgroup not found, remove it */ >++ if (!mutt_strncmp ("411", buf, 3)) >++ { >++ mutt_error (_("Newsgroup %s has been removed from the server."), >++ nntp_data->group); >++ if (!nntp_data->deleted) >++ { >++ nntp_data->deleted = 1; >++ nntp_active_save_cache (nserv); >++ } >++ if (nntp_data->newsrc_ent && !nntp_data->subscribed && >++ !option (OPTSAVEUNSUB)) >++ { >++ FREE (&nntp_data->newsrc_ent); >++ nntp_data->newsrc_len = 0; >++ nntp_delete_group_cache (nntp_data); >++ nntp_newsrc_update (nserv); >++ } >++ mutt_sleep (2); >++ } >++ >++ /* parse newsgroup info */ >++ else { >++ if (sscanf (buf, "211 " ANUM " " ANUM " " ANUM, &count, &first, &last) != 3) >++ { >++ nntp_newsrc_close (nserv); >++ mutt_error ("GROUP: %s", buf); >++ mutt_sleep (2); >++ return -1; >++ } >++ nntp_data->firstMessage = first; >++ nntp_data->lastMessage = last; >++ nntp_data->deleted = 0; >++ >++ /* get description if empty */ >++ if (option (OPTLOADDESC) && !nntp_data->desc) >++ { >++ if (get_description (nntp_data, NULL, NULL) < 0) >++ { >++ nntp_newsrc_close (nserv); >++ return -1; >++ } >++ if (nntp_data->desc) >++ nntp_active_save_cache (nserv); >++ } >++ } >++ >++ time (&nserv->check_time); >++ ctx->data = nntp_data; >++ ctx->mx_close = nntp_fastclose_mailbox; >++ if (!nntp_data->bcache && (nntp_data->newsrc_ent || >++ nntp_data->subscribed || option (OPTSAVEUNSUB))) >++ nntp_data->bcache = mutt_bcache_open (&nserv->conn->account, >++ nntp_data->group); >++ >++ /* strip off extra articles if adding context is greater than $nntp_context */ >++ first = nntp_data->firstMessage; >++ if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext) >++ first = nntp_data->lastMessage - NntpContext + 1; >++ nntp_data->lastLoaded = first ? first - 1 : 0; >++ count = nntp_data->firstMessage; >++ nntp_data->firstMessage = first; >++ nntp_bcache_update (nntp_data); >++ nntp_data->firstMessage = count; >++#ifdef USE_HCACHE >++ hc = nntp_hcache_open (nntp_data); >++ nntp_hcache_update (nntp_data, hc); >++#endif >++ if (!hc) >++ { >++ mutt_bit_unset (ctx->rights, M_ACL_WRITE); >++ mutt_bit_unset (ctx->rights, M_ACL_DELETE); >++ } >++ nntp_newsrc_close (nserv); >++ rc = nntp_fetch_headers (ctx, hc, first, nntp_data->lastMessage, 0); >++#ifdef USE_HCACHE >++ mutt_hcache_close (hc); >++#endif >++ if (rc < 0) >++ return -1; >++ nntp_data->lastLoaded = nntp_data->lastMessage; >++ nserv->newsrc_modified = 0; >++ return 0; >++} >++ >++/* Fetch message */ >++int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno) >++{ >++ NNTP_DATA *nntp_data = ctx->data; >++ NNTP_ACACHE *acache; >++ HEADER *hdr = ctx->hdrs[msgno]; >++ char buf[_POSIX_PATH_MAX]; >++ char article[16]; >++ char *fetch_msg = _("Fetching message..."); >++ int rc; >++ >++ /* try to get article from cache */ >++ acache = &nntp_data->acache[hdr->index % NNTP_ACACHE_LEN]; >++ if (acache->path) >++ { >++ if (acache->index == hdr->index) >++ { >++ msg->fp = fopen (acache->path, "r"); >++ if (msg->fp) >++ return 0; >++ } >++ /* clear previous entry */ >++ else >++ { >++ unlink (acache->path); >++ FREE (&acache->path); >++ } >++ } >++ snprintf (article, sizeof (article), "%d", NHDR (hdr)->article_num); >++ msg->fp = mutt_bcache_get (nntp_data->bcache, article); >++ if (msg->fp) >++ { >++ if (NHDR (hdr)->parsed) >++ return 0; >++ } >++ else >++ { >++ /* don't try to fetch article from removed newsgroup */ >++ if (nntp_data->deleted) >++ return -1; >++ >++ /* create new cache file */ >++ mutt_message (fetch_msg); >++ msg->fp = mutt_bcache_put (nntp_data->bcache, article, 1); >++ if (!msg->fp) >++ { >++ mutt_mktemp (buf, sizeof (buf)); >++ acache->path = safe_strdup (buf); >++ acache->index = hdr->index; >++ msg->fp = safe_fopen (acache->path, "w+"); >++ if (!msg->fp) >++ { >++ mutt_perror (acache->path); >++ unlink (acache->path); >++ FREE (&acache->path); >++ return -1; >++ } >++ } >++ >++ /* fetch message to cache file */ >++ snprintf (buf, sizeof (buf), "ARTICLE %s\r\n", >++ NHDR (hdr)->article_num ? article : hdr->env->message_id); >++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), fetch_msg, >++ fetch_tempfile, msg->fp); >++ if (rc) >++ { >++ safe_fclose (&msg->fp); >++ if (acache->path) >++ { >++ unlink (acache->path); >++ FREE (&acache->path); >++ } >++ if (rc > 0) >++ { >++ if (!mutt_strncmp (NHDR (hdr)->article_num ? "423" : "430", buf, 3)) >++ mutt_error (_("Article %d not found on the server."), >++ NHDR (hdr)->article_num ? article : hdr->env->message_id); >++ else >++ mutt_error ("ARTICLE: %s", buf); >++ } >++ return -1; >++ } >++ >++ if (!acache->path) >++ mutt_bcache_commit (nntp_data->bcache, article); >++ } >++ >++ /* replace envelope with new one >++ * hash elements must be updated because pointers will be changed */ >++ if (ctx->id_hash && hdr->env->message_id) >++ hash_delete (ctx->id_hash, hdr->env->message_id, hdr, NULL); >++ if (ctx->subj_hash && hdr->env->real_subj) >++ hash_delete (ctx->subj_hash, hdr->env->real_subj, hdr, NULL); >++ >++ mutt_free_envelope (&hdr->env); >++ hdr->env = mutt_read_rfc822_header (msg->fp, hdr, 0, 0); >++ >++ if (ctx->id_hash && hdr->env->message_id) >++ hash_insert (ctx->id_hash, hdr->env->message_id, hdr, 0); >++ if (ctx->subj_hash && hdr->env->real_subj) >++ hash_insert (ctx->subj_hash, hdr->env->real_subj, hdr, 1); >++ >++ /* fix content length */ >++ fseek (msg->fp, 0, SEEK_END); >++ hdr->content->length = ftell (msg->fp) - hdr->content->offset; >++ >++ /* this is called in mutt before the open which fetches the message, >++ * which is probably wrong, but we just call it again here to handle >++ * the problem instead of fixing it */ >++ NHDR (hdr)->parsed = 1; >++ mutt_parse_mime_message (ctx, hdr); >++ >++ /* these would normally be updated in mx_update_context(), but the >++ * full headers aren't parsed with overview, so the information wasn't >++ * available then */ >++ if (WithCrypto) >++ hdr->security = crypt_query (hdr->content); >++ >++ rewind (msg->fp); >++ mutt_clear_error(); >++ return 0; >++} >++ >++/* Post article */ >++int nntp_post (const char *msg) { >++ NNTP_DATA *nntp_data, nntp_tmp; >++ FILE *fp; >++ char buf[LONG_STRING]; >++ size_t len; >++ >++ if (Context && Context->magic == M_NNTP) >++ nntp_data = Context->data; >++ else >++ { >++ CurrentNewsSrv = nntp_select_server (NewsServer, 0); >++ if (!CurrentNewsSrv) >++ return -1; >++ >++ nntp_data = &nntp_tmp; >++ nntp_data->nserv = CurrentNewsSrv; >++ nntp_data->group = NULL; >++ } >++ >++ fp = safe_fopen (msg, "r"); >++ if (!fp) >++ { >++ mutt_perror (msg); >++ return -1; >++ } >++ >++ strfcpy (buf, "POST\r\n", sizeof (buf)); >++ if (nntp_query (nntp_data, buf, sizeof (buf)) < 0) >++ return -1; >++ if (buf[0] != '3') >++ { >++ mutt_error (_("Can't post article: %s"), buf); >++ return -1; >++ } >++ >++ buf[0] = '.'; >++ buf[1] = '\0'; >++ while (fgets (buf + 1, sizeof (buf) - 2, fp)) >++ { >++ len = strlen (buf); >++ if (buf[len - 1] == '\n') >++ { >++ buf[len - 1] = '\r'; >++ buf[len] = '\n'; >++ len++; >++ buf[len] = '\0'; >++ } >++ if (mutt_socket_write_d (nntp_data->nserv->conn, >++ buf[1] == '.' ? buf : buf + 1, -1, M_SOCK_LOG_HDR) < 0) >++ return nntp_connect_error (nntp_data->nserv); >++ } >++ fclose (fp); >++ >++ if ((buf[strlen (buf) - 1] != '\n' && >++ mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR) < 0) || >++ mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR) < 0 || >++ mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0) >++ return nntp_connect_error (nntp_data->nserv); >++ if (buf[0] != '2') >++ { >++ mutt_error (_("Can't post article: %s"), buf); >++ return -1; >++ } >++ return 0; >++} >++ >++/* Save changes to .newsrc and cache */ >++int nntp_sync_mailbox (CONTEXT *ctx) >++{ >++ NNTP_DATA *nntp_data = ctx->data; >++ int rc, i; >++#ifdef USE_HCACHE >++ header_cache_t *hc; >++#endif >++ >++ /* check for new articles */ >++ nntp_data->nserv->check_time = 0; >++ rc = nntp_check_mailbox (ctx, 1); >++ if (rc) >++ return rc; >++ >++#ifdef USE_HCACHE >++ nntp_data->lastCached = 0; >++ hc = nntp_hcache_open (nntp_data); >++#endif >++ >++ nntp_data->unread = ctx->unread; >++ for (i = 0; i < ctx->msgcount; i++) >++ { >++ HEADER *hdr = ctx->hdrs[i]; >++ char buf[16]; >++ >++ snprintf (buf, sizeof (buf), "%d", NHDR (hdr)->article_num); >++ if (nntp_data->bcache && hdr->deleted) >++ { >++ dprint (2, (debugfile, "nntp_sync_mailbox: mutt_bcache_del %s\n", buf)); >++ mutt_bcache_del (nntp_data->bcache, buf); >++ } >++ >++#ifdef USE_HCACHE >++ if (hc && (hdr->changed || hdr->deleted)) >++ { >++ if (hdr->deleted && !hdr->read) >++ nntp_data->unread--; >++ dprint (2, (debugfile, "nntp_sync_mailbox: mutt_hcache_store %s\n", buf)); >++ mutt_hcache_store (hc, buf, hdr, 0, strlen, M_GENERATE_UIDVALIDITY); >++ } >++#endif >++ } >++ >++#ifdef USE_HCACHE >++ if (hc) >++ { >++ mutt_hcache_close (hc); >++ nntp_data->lastCached = nntp_data->lastLoaded; >++ } >++#endif >++ >++ /* save .newsrc entries */ >++ nntp_newsrc_gen_entries (ctx); >++ nntp_newsrc_update (nntp_data->nserv); >++ nntp_newsrc_close (nntp_data->nserv); >++ return 0; >++} >++ >++/* Free up memory associated with the newsgroup context */ >++int nntp_fastclose_mailbox (CONTEXT *ctx) >++{ >++ NNTP_DATA *nntp_data = ctx->data, *nntp_tmp; >++ >++ if (!nntp_data) >++ return 0; >++ >++ nntp_acache_free (nntp_data); >++ if (!nntp_data->nserv || !nntp_data->nserv->groups_hash || !nntp_data->group) >++ return 0; >++ >++ nntp_tmp = hash_find (nntp_data->nserv->groups_hash, nntp_data->group); >++ if (nntp_tmp == NULL || nntp_tmp != nntp_data) >++ nntp_data_free (nntp_data); >++ return 0; >++} >++ >++/* Get date and time from server */ >++int nntp_date (NNTP_SERVER *nserv, time_t *now) >++{ >++ if (nserv->hasDATE) >++ { >++ NNTP_DATA nntp_data; >++ char buf[LONG_STRING]; >++ struct tm tm; >++ >++ nntp_data.nserv = nserv; >++ nntp_data.group = NULL; >++ strfcpy (buf, "DATE\r\n", sizeof (buf)); >++ if (nntp_query (&nntp_data, buf, sizeof (buf)) < 0) >++ return -1; >++ >++ if (sscanf (buf, "111 %4d%2d%2d%2d%2d%2d%*s", &tm.tm_year, &tm.tm_mon, >++ &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) == 6) >++ { >++ tm.tm_year -= 1900; >++ tm.tm_mon--; >++ *now = timegm (&tm); >++ if (*now >= 0) >++ { >++ dprint (1, (debugfile, "nntp_date: server time is %d\n", *now)); >++ return 0; >++ } >++ } >++ } >++ time (now); >++ return 0; >++} >++ >++/* Fetch list of all newsgroups from server */ >++int nntp_active_fetch (NNTP_SERVER *nserv) >++{ >++ NNTP_DATA nntp_data; >++ char msg[SHORT_STRING]; >++ char buf[LONG_STRING]; >++ unsigned int i; >++ int rc; >++ >++ snprintf (msg, sizeof (msg), _("Loading list of groups from server %s..."), >++ nserv->conn->account.host); >++ mutt_message (msg); >++ if (nntp_date (nserv, &nserv->newgroups_time) < 0) >++ return -1; >++ >++ nntp_data.nserv = nserv; >++ nntp_data.group = NULL; >++ strfcpy (buf, "LIST\r\n", sizeof (buf)); >++ rc = nntp_fetch_lines (&nntp_data, buf, sizeof (buf), msg, >++ nntp_add_group, nserv); >++ if (rc) >++ { >++ if (rc > 0) >++ { >++ mutt_error ("LIST: %s", buf); >++ mutt_sleep (2); >++ } >++ return -1; >++ } >++ >++ if (option (OPTLOADDESC) && >++ get_description (&nntp_data, "*", _("Loading descriptions...")) < 0) >++ return -1; >++ >++ for (i = 0; i < nserv->groups_num; i++) >++ { >++ NNTP_DATA *nntp_data = nserv->groups_list[i]; >++ >++ if (nntp_data && nntp_data->deleted && !nntp_data->newsrc_ent) >++ { >++ nntp_delete_group_cache (nntp_data); >++ hash_delete (nserv->groups_hash, nntp_data->group, NULL, nntp_data_free); >++ nserv->groups_list[i] = NULL; >++ } >++ } >++ nntp_active_save_cache (nserv); >++ mutt_clear_error (); >++ return 0; >++} >++ >++/* Check newsgroup for new articles: >++ * 1 - new articles found >++ * 0 - no change >++ * -1 - lost connection */ >++static int nntp_group_poll (NNTP_DATA *nntp_data, int update_stat) >++{ >++ char buf[LONG_STRING] = ""; >++ anum_t count, first, last; >++ >++ /* use GROUP command to poll newsgroup */ >++ if (nntp_query (nntp_data, buf, sizeof (buf)) < 0) >++ return -1; >++ if (sscanf (buf, "211 " ANUM " " ANUM " " ANUM, &count, &first, &last) != 3) >++ return 0; >++ if (first == nntp_data->firstMessage && last == nntp_data->lastMessage) >++ return 0; >++ >++ /* articles have been renumbered */ >++ if (last < nntp_data->lastMessage) >++ { >++ nntp_data->lastCached = 0; >++ if (nntp_data->newsrc_len) >++ { >++ safe_realloc (&nntp_data->newsrc_ent, sizeof (NEWSRC_ENTRY)); >++ nntp_data->newsrc_len = 1; >++ nntp_data->newsrc_ent[0].first = 1; >++ nntp_data->newsrc_ent[0].last = 0; >++ } >++ } >++ nntp_data->firstMessage = first; >++ nntp_data->lastMessage = last; >++ if (!update_stat) >++ return 1; >++ >++ /* update counters */ >++ else if (!last || (!nntp_data->newsrc_ent && !nntp_data->lastCached)) >++ nntp_data->unread = count; >++ else >++ nntp_group_unread_stat (nntp_data); >++ return 1; >++} >++ >++/* Check current newsgroup for new articles: >++ * M_REOPENED - articles have been renumbered or removed from server >++ * M_NEW_MAIL - new articles found >++ * 0 - no change >++ * -1 - lost connection */ >++int nntp_check_mailbox (CONTEXT *ctx, int leave_lock) >++{ >++ NNTP_DATA *nntp_data = ctx->data; >++ NNTP_SERVER *nserv = nntp_data->nserv; >++ time_t now = time (NULL); >++ int i, j; >++ int rc, ret = 0; >++ void *hc = NULL; >++ >++ if (nserv->check_time + NewsPollTimeout > now) >++ return 0; >++ >++ mutt_message _("Checking for new messages..."); >++ if (nntp_newsrc_parse (nserv) < 0) >++ return -1; >++ >++ nserv->check_time = now; >++ rc = nntp_group_poll (nntp_data, 0); >++ if (rc < 0) >++ { >++ nntp_newsrc_close (nserv); >++ return -1; >++ } >++ if (rc) >++ nntp_active_save_cache (nserv); >++ >++ /* articles have been renumbered, remove all headers */ >++ if (nntp_data->lastMessage < nntp_data->lastLoaded) >++ { >++ for (i = 0; i < ctx->msgcount; i++) >++ mutt_free_header (&ctx->hdrs[i]); >++ ctx->msgcount = 0; >++ ctx->tagged = 0; >++ >++ if (nntp_data->lastMessage < nntp_data->lastLoaded) >++ { >++ nntp_data->lastLoaded = nntp_data->firstMessage - 1; >++ if (NntpContext && nntp_data->lastMessage - nntp_data->lastLoaded > >++ NntpContext) >++ nntp_data->lastLoaded = nntp_data->lastMessage - NntpContext; >++ } >++ ret = M_REOPENED; >++ } >++ >++ /* .newsrc has been externally modified */ >++ if (nserv->newsrc_modified) >++ { >++ anum_t anum; >++#ifdef USE_HCACHE >++ unsigned char *messages; >++ char buf[16]; >++ void *hdata; >++ HEADER *hdr; >++ anum_t first = nntp_data->firstMessage; >++ >++ if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext) >++ first = nntp_data->lastMessage - NntpContext + 1; >++ messages = safe_calloc (nntp_data->lastLoaded - first + 1, >++ sizeof (unsigned char)); >++ hc = nntp_hcache_open (nntp_data); >++ nntp_hcache_update (nntp_data, hc); >++#endif >++ >++ /* update flags according to .newsrc */ >++ for (i = j = 0; i < ctx->msgcount; i++) >++ { >++ int flagged = 0; >++ anum = NHDR (ctx->hdrs[i])->article_num; >++ >++#ifdef USE_HCACHE >++ /* check hcache for flagged and deleted flags */ >++ if (hc) >++ { >++ if (anum >= first && anum <= nntp_data->lastLoaded) >++ messages[anum - first] = 1; >++ >++ snprintf (buf, sizeof (buf), "%d", anum); >++ hdata = mutt_hcache_fetch (hc, buf, strlen); >++ if (hdata) >++ { >++ int deleted; >++ >++ dprint (2, (debugfile, >++ "nntp_check_mailbox: mutt_hcache_fetch %s\n", buf)); >++ hdr = mutt_hcache_restore (hdata, NULL); >++ deleted = hdr->deleted; >++ flagged = hdr->flagged; >++ mutt_free_header (&hdr); >++ >++ /* header marked as deleted, removing from context */ >++ if (deleted) >++ { >++ mutt_set_flag (ctx, ctx->hdrs[i], M_TAG, 0); >++ mutt_free_header (&ctx->hdrs[i]); >++ continue; >++ } >++ } >++ } >++#endif >++ >++ if (!ctx->hdrs[i]->changed) >++ { >++ ctx->hdrs[i]->flagged = flagged; >++ ctx->hdrs[i]->read = 0; >++ ctx->hdrs[i]->old = 0; >++ nntp_article_status (ctx, ctx->hdrs[i], NULL, anum); >++ if (!ctx->hdrs[i]->read) >++ nntp_parse_xref (ctx, ctx->hdrs[i]); >++ } >++ ctx->hdrs[j++] = ctx->hdrs[i]; >++ } >++ >++#ifdef USE_HCACHE >++ ctx->msgcount = j; >++ >++ /* restore headers without "deleted" flag */ >++ for (anum = first; anum <= nntp_data->lastLoaded; anum++) >++ { >++ if (messages[anum - first]) >++ continue; >++ >++ snprintf (buf, sizeof (buf), "%d", anum); >++ hdata = mutt_hcache_fetch (hc, buf, strlen); >++ if (hdata) >++ { >++ dprint (2, (debugfile, >++ "nntp_check_mailbox: mutt_hcache_fetch %s\n", buf)); >++ if (ctx->msgcount >= ctx->hdrmax) >++ mx_alloc_memory (ctx); >++ >++ ctx->hdrs[ctx->msgcount] = >++ hdr = mutt_hcache_restore (hdata, NULL); >++ if (hdr->deleted) >++ { >++ mutt_free_header (&hdr); >++ if (nntp_data->bcache) >++ { >++ dprint (2, (debugfile, >++ "nntp_check_mailbox: mutt_bcache_del %s\n", buf)); >++ mutt_bcache_del (nntp_data->bcache, buf); >++ } >++ continue; >++ } >++ >++ ctx->msgcount++; >++ hdr->read = 0; >++ hdr->old = 0; >++ hdr->data = safe_calloc (1, sizeof (NNTP_HEADER_DATA)); >++ NHDR (hdr)->article_num = anum; >++ nntp_article_status (ctx, hdr, NULL, anum); >++ if (!hdr->read) >++ nntp_parse_xref (ctx, hdr); >++ } >++ } >++ FREE (&messages); >++#endif >++ >++ nserv->newsrc_modified = 0; >++ ret = M_REOPENED; >++ } >++ >++ /* some headers were removed, context must be updated */ >++ if (ret == M_REOPENED) >++ { >++ if (ctx->subj_hash) >++ hash_destroy (&ctx->subj_hash, NULL); >++ if (ctx->id_hash) >++ hash_destroy (&ctx->id_hash, NULL); >++ mutt_clear_threads (ctx); >++ >++ ctx->vcount = 0; >++ ctx->deleted = 0; >++ ctx->new = 0; >++ ctx->unread = 0; >++ ctx->flagged = 0; >++ ctx->changed = 0; >++ ctx->id_hash = NULL; >++ ctx->subj_hash = NULL; >++ mx_update_context (ctx, ctx->msgcount); >++ } >++ >++ /* fetch headers of new articles */ >++ if (nntp_data->lastMessage > nntp_data->lastLoaded) >++ { >++ int oldmsgcount = ctx->msgcount; >++ int quiet = ctx->quiet; >++ ctx->quiet = 1; >++#ifdef USE_HCACHE >++ if (!hc) >++ { >++ hc = nntp_hcache_open (nntp_data); >++ nntp_hcache_update (nntp_data, hc); >++ } >++#endif >++ rc = nntp_fetch_headers (ctx, hc, nntp_data->lastLoaded + 1, >++ nntp_data->lastMessage, 0); >++ ctx->quiet = quiet; >++ if (rc >= 0) >++ nntp_data->lastLoaded = nntp_data->lastMessage; >++ if (ret == 0 && ctx->msgcount > oldmsgcount) >++ ret = M_NEW_MAIL; >++ } >++ >++#ifdef USE_HCACHE >++ mutt_hcache_close (hc); >++#endif >++ if (ret || !leave_lock) >++ nntp_newsrc_close (nserv); >++ mutt_clear_error (); >++ return ret; >++} >++ >++/* Check for new groups and new articles in subscribed groups: >++ * 1 - new groups found >++ * 0 - no new groups >++ * -1 - error */ >++int nntp_check_new_groups (NNTP_SERVER *nserv) >++{ >++ NNTP_DATA nntp_data; >++ time_t now; >++ struct tm *tm; >++ char buf[LONG_STRING]; >++ char *msg = _("Checking for new newsgroups..."); >++ unsigned int i; >++ int rc, update_active = FALSE; >++ >++ if (!nserv || !nserv->newgroups_time) >++ return -1; >++ >++ /* check subscribed newsgroups for new articles */ >++ if (option (OPTSHOWNEWNEWS)) >++ { >++ mutt_message _("Checking for new messages..."); >++ for (i = 0; i < nserv->groups_num; i++) >++ { >++ NNTP_DATA *nntp_data = nserv->groups_list[i]; >++ >++ if (nntp_data && nntp_data->subscribed) >++ { >++ rc = nntp_group_poll (nntp_data, 1); >++ if (rc < 0) >++ return -1; >++ if (rc > 0) >++ update_active = TRUE; >++ } >++ } >++ } >++ else if (nserv->newgroups_time) >++ return 0; >++ >++ /* get list of new groups */ >++ mutt_message (msg); >++ if (nntp_date (nserv, &now) < 0) >++ return -1; >++ nntp_data.nserv = nserv; >++ if (Context && Context->magic == M_NNTP) >++ nntp_data.group = ((NNTP_DATA *)Context->data)->group; >++ else >++ nntp_data.group = NULL; >++ i = nserv->groups_num; >++ tm = gmtime (&nserv->newgroups_time); >++ snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n", >++ tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday, >++ tm->tm_hour, tm->tm_min, tm->tm_sec); >++ rc = nntp_fetch_lines (&nntp_data, buf, sizeof (buf), msg, >++ nntp_add_group, nserv); >++ if (rc) >++ { >++ if (rc > 0) >++ { >++ mutt_error ("NEWGROUPS: %s", buf); >++ mutt_sleep (2); >++ } >++ return -1; >++ } >++ >++ /* new groups found */ >++ rc = 0; >++ if (nserv->groups_num != i) >++ { >++ nserv->newgroups_time = now; >++ >++ /* loading descriptions */ >++ if (option (OPTLOADDESC)) >++ { >++ unsigned int count = 0; >++ progress_t progress; >++ >++ mutt_progress_init (&progress, _("Loading descriptions..."), >++ M_PROGRESS_MSG, ReadInc, nserv->groups_num - i); >++ for (; i < nserv->groups_num; i++) >++ { >++ NNTP_DATA *nntp_data = nserv->groups_list[i]; >++ >++ if (get_description (nntp_data, NULL, NULL) < 0) >++ return -1; >++ mutt_progress_update (&progress, ++count, -1); >++ } >++ } >++ update_active = TRUE; >++ rc = 1; >++ } >++ if (update_active) >++ nntp_active_save_cache (nserv); >++ mutt_clear_error (); >++ return rc; >++} >++ >++/* Fetch article by Message-ID: >++ * 0 - success >++ * 1 - no such article >++ * -1 - error */ >++int nntp_check_msgid (CONTEXT *ctx, const char *msgid) >++{ >++ NNTP_DATA *nntp_data = ctx->data; >++ HEADER *hdr; >++ FILE *fp; >++ char tempfile[_POSIX_PATH_MAX]; >++ char buf[LONG_STRING]; >++ int rc; >++ >++ mutt_mktemp (tempfile, sizeof (tempfile)); >++ fp = safe_fopen (tempfile, "w+"); >++ if (!fp) >++ { >++ mutt_perror (tempfile); >++ unlink (tempfile); >++ return -1; >++ } >++ >++ snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid); >++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL, >++ fetch_tempfile, fp); >++ if (rc) >++ { >++ fclose (fp); >++ unlink (tempfile); >++ if (rc < 0) >++ return -1; >++ if (!mutt_strncmp ("430", buf, 3)) >++ return 1; >++ mutt_error ("HEAD: %s", buf); >++ return -1; >++ } >++ >++ /* parse header */ >++ if (ctx->msgcount == ctx->hdrmax) >++ mx_alloc_memory (ctx); >++ hdr = ctx->hdrs[ctx->msgcount] = mutt_new_header (); >++ hdr->data = safe_calloc (1, sizeof (NNTP_HEADER_DATA)); >++ hdr->env = mutt_read_rfc822_header (fp, hdr, 0, 0); >++ fclose (fp); >++ unlink (tempfile); >++ >++ /* get article number */ >++ if (hdr->env->xref) >++ nntp_parse_xref (ctx, hdr); >++ else >++ { >++ snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid); >++ if (nntp_query (nntp_data, buf, sizeof (buf)) < 0) >++ { >++ mutt_free_header (&hdr); >++ return -1; >++ } >++ sscanf (buf + 4, ANUM, &NHDR (hdr)->article_num); >++ } >++ >++ /* reset flags */ >++ hdr->read = 0; >++ hdr->old = 0; >++ hdr->deleted = 0; >++ hdr->changed = 1; >++ hdr->received = hdr->date_sent; >++ hdr->index = ctx->msgcount++; >++ mx_update_context (ctx, 1); >++ return 0; >++} >++ >++typedef struct >++{ >++ CONTEXT *ctx; >++ unsigned int num; >++ unsigned int max; >++ anum_t *child; >++} CHILD_CTX; >++ >++/* Parse XPAT line */ >++static int fetch_children (char *line, void *data) >++{ >++ CHILD_CTX *cc = data; >++ anum_t anum; >++ unsigned int i; >++ >++ if (!line || sscanf (line, ANUM, &anum) != 1) >++ return 0; >++ for (i = 0; i < cc->ctx->msgcount; i++) >++ if (NHDR (cc->ctx->hdrs[i])->article_num == anum) >++ return 0; >++ if (cc->num >= cc->max) >++ { >++ cc->max *= 2; >++ safe_realloc (&cc->child, sizeof (anum_t) * cc->max); >++ } >++ cc->child[cc->num++] = anum; >++ return 0; >++} >++ >++/* Fetch children of article with the Message-ID */ >++int nntp_check_children (CONTEXT *ctx, const char *msgid) >++{ >++ NNTP_DATA *nntp_data = ctx->data; >++ CHILD_CTX cc; >++ char buf[STRING]; >++ int i, rc, quiet; >++ void *hc = NULL; >++ >++ if (!nntp_data || !nntp_data->nserv) >++ return -1; >++ if (nntp_data->firstMessage > nntp_data->lastLoaded) >++ return 0; >++ >++ /* init context */ >++ cc.ctx = ctx; >++ cc.num = 0; >++ cc.max = 10; >++ cc.child = safe_malloc (sizeof (anum_t) * cc.max); >++ >++ /* fetch numbers of child messages */ >++ snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n", >++ nntp_data->firstMessage, nntp_data->lastLoaded, msgid); >++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL, >++ fetch_children, &cc); >++ if (rc) >++ { >++ FREE (&cc.child); >++ if (rc > 0) { >++ if (mutt_strncmp ("500", buf, 3)) >++ mutt_error ("XPAT: %s", buf); >++ else >++ mutt_error _("Unable to find child articles because server does not support XPAT command."); >++ } >++ return -1; >++ } >++ >++ /* fetch all found messages */ >++ quiet = ctx->quiet; >++ ctx->quiet = 1; >++#ifdef USE_HCACHE >++ hc = nntp_hcache_open (nntp_data); >++#endif >++ for (i = 0; i < cc.num; i++) >++ { >++ rc = nntp_fetch_headers (ctx, hc, cc.child[i], cc.child[i], 1); >++ if (rc < 0) >++ break; >++ } >++#ifdef USE_HCACHE >++ mutt_hcache_close (hc); >++#endif >++ ctx->quiet = quiet; >++ FREE (&cc.child); >++ return rc < 0 ? -1 : 0; >++} >+diff -udprP mutt-1.5.23.orig/nntp.h mutt-1.5.23/nntp.h >+--- mutt-1.5.23.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300 >++++ mutt-1.5.23/nntp.h 2014-03-13 12:48:37.000000000 +0200 >+@@ -0,0 +1,167 @@ >++/* >++ * Copyright (C) 1998 Brandon Long <blong@fiction.net> >++ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net> >++ * Copyright (C) 2000-2012 Vsevolod Volkov <vvv@mutt.org.ua> >++ * >++ * This program is free software; you can redistribute it and/or modify >++ * it under the terms of the GNU General Public License as published by >++ * the Free Software Foundation; either version 2 of the License, or >++ * (at your option) any later version. >++ * >++ * This program is distributed in the hope that it will be useful, >++ * but WITHOUT ANY WARRANTY; without even the implied warranty of >++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >++ * GNU General Public License for more details. >++ * >++ * You should have received a copy of the GNU General Public License >++ * along with this program; if not, write to the Free Software >++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >++ */ >++ >++#ifndef _NNTP_H_ >++#define _NNTP_H_ 1 >++ >++#include "mutt_socket.h" >++#include "mailbox.h" >++#include "bcache.h" >++ >++#if USE_HCACHE >++#include "hcache.h" >++#endif >++ >++#include <time.h> >++#include <sys/types.h> >++#include <stdint.h> >++ >++#define NNTP_PORT 119 >++#define NNTP_SSL_PORT 563 >++ >++/* number of entries in article cache */ >++#define NNTP_ACACHE_LEN 10 >++ >++/* article number type and format */ >++#define anum_t uint32_t >++#define ANUM "%u" >++ >++enum >++{ >++ NNTP_NONE = 0, >++ NNTP_OK, >++ NNTP_BYE >++}; >++ >++typedef struct >++{ >++ unsigned int hasCAPABILITIES : 1; >++ unsigned int hasSTARTTLS : 1; >++ unsigned int hasDATE : 1; >++ unsigned int hasLIST_NEWSGROUPS : 1; >++ unsigned int hasXGTITLE : 1; >++ unsigned int hasLISTGROUP : 1; >++ unsigned int hasOVER : 1; >++ unsigned int hasXOVER : 1; >++ unsigned int use_tls : 3; >++ unsigned int status : 3; >++ unsigned int cacheable : 1; >++ unsigned int newsrc_modified : 1; >++ FILE *newsrc_fp; >++ char *newsrc_file; >++ char *authenticators; >++ char *overview_fmt; >++ off_t size; >++ time_t mtime; >++ time_t newgroups_time; >++ time_t check_time; >++ unsigned int groups_num; >++ unsigned int groups_max; >++ void **groups_list; >++ HASH *groups_hash; >++ CONNECTION *conn; >++} NNTP_SERVER; >++ >++typedef struct >++{ >++ anum_t first; >++ anum_t last; >++} NEWSRC_ENTRY; >++ >++typedef struct >++{ >++ unsigned int index; >++ char *path; >++} NNTP_ACACHE; >++ >++typedef struct >++{ >++ char *group; >++ char *desc; >++ anum_t firstMessage; >++ anum_t lastMessage; >++ anum_t lastLoaded; >++ anum_t lastCached; >++ anum_t unread; >++ unsigned int subscribed : 1; >++ unsigned int new : 1; >++ unsigned int allowed : 1; >++ unsigned int deleted : 1; >++ unsigned int newsrc_len; >++ NEWSRC_ENTRY *newsrc_ent; >++ NNTP_SERVER *nserv; >++ NNTP_ACACHE acache[NNTP_ACACHE_LEN]; >++ body_cache_t *bcache; >++} NNTP_DATA; >++ >++typedef struct >++{ >++ anum_t article_num; >++ unsigned int parsed : 1; >++} NNTP_HEADER_DATA; >++ >++#define NHDR(hdr) ((NNTP_HEADER_DATA*)((hdr)->data)) >++ >++/* internal functions */ >++int nntp_add_group (char *, void *); >++int nntp_active_save_cache (NNTP_SERVER *); >++int nntp_check_new_groups (NNTP_SERVER *); >++int nntp_fastclose_mailbox (CONTEXT *); >++int nntp_open_connection (NNTP_SERVER *); >++void nntp_newsrc_gen_entries (CONTEXT *); >++void nntp_bcache_update (NNTP_DATA *); >++void nntp_article_status (CONTEXT *, HEADER *, char *, anum_t); >++void nntp_group_unread_stat (NNTP_DATA *); >++void nntp_data_free (void *); >++void nntp_acache_free (NNTP_DATA *); >++void nntp_delete_group_cache (NNTP_DATA *); >++ >++/* exposed interface */ >++NNTP_SERVER *nntp_select_server (char *, int); >++NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *); >++NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *); >++NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *); >++NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *); >++int nntp_active_fetch (NNTP_SERVER *); >++int nntp_newsrc_update (NNTP_SERVER *); >++int nntp_open_mailbox (CONTEXT *); >++int nntp_sync_mailbox (CONTEXT *); >++int nntp_check_mailbox (CONTEXT *, int); >++int nntp_fetch_message (MESSAGE *, CONTEXT *, int); >++int nntp_post (const char *); >++int nntp_check_msgid (CONTEXT *, const char *); >++int nntp_check_children (CONTEXT *, const char *); >++int nntp_newsrc_parse (NNTP_SERVER *); >++void nntp_newsrc_close (NNTP_SERVER *); >++void nntp_buffy (char *, size_t); >++void nntp_expand_path (char *, size_t, ACCOUNT *); >++void nntp_clear_cache (NNTP_SERVER *); >++const char *nntp_format_str (char *, size_t, size_t, char, const char *, >++ const char *, const char *, const char *, >++ unsigned long, format_flag); >++ >++NNTP_SERVER *CurrentNewsSrv INITVAL (NULL); >++ >++#ifdef USE_HCACHE >++header_cache_t *nntp_hcache_open (NNTP_DATA *); >++void nntp_hcache_update (NNTP_DATA *, header_cache_t *); >++#endif >++ >++#endif /* _NNTP_H_ */ >+diff -udprP mutt-1.5.23.orig/pager.c mutt-1.5.23/pager.c >+--- mutt-1.5.23.orig/pager.c 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23/pager.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -1084,6 +1084,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos, >+ return b_read; >+ } >+ >++#ifdef USE_NNTP >++#include "mx.h" >++#include "nntp.h" >++#endif >++ >+ >+ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf, >+ int flags, ansi_attr *pa, int cnt, >+@@ -1541,6 +1546,16 @@ static const struct mapping_t PagerHelpE >+ { NULL, 0 } >+ }; >+ >++#ifdef USE_NNTP >++static struct mapping_t PagerNewsHelpExtra[] = { >++ { N_("Post"), OP_POST }, >++ { N_("Followup"), OP_FOLLOWUP }, >++ { N_("Del"), OP_DELETE }, >++ { N_("Next"), OP_MAIN_NEXT_UNDELETED }, >++ { NULL, 0 } >++}; >++#endif >++ >+ >+ >+ /* This pager is actually not so simple as it once was. It now operates in >+@@ -1582,6 +1597,10 @@ mutt_pager (const char *banner, const ch >+ int old_PagerIndexLines; /* some people want to resize it >+ * while inside the pager... */ >+ >++#ifdef USE_NNTP >++ char *followup_to; >++#endif >++ >+ if (!(flags & M_SHOWCOLOR)) >+ flags |= M_SHOWFLAT; >+ >+@@ -1621,7 +1640,11 @@ mutt_pager (const char *banner, const ch >+ if (IsHeader (extra)) >+ { >+ strfcpy (tmphelp, helpstr, sizeof (tmphelp)); >+- mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra); >++ mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, >++#ifdef USE_NNTP >++ (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra : >++#endif >++ PagerHelpExtra); >+ snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer); >+ } >+ if (!InHelp) >+@@ -2532,6 +2555,60 @@ search_next: >+ redraw = REDRAW_FULL; >+ break; >+ >++#ifdef USE_NNTP >++ case OP_POST: >++ CHECK_MODE(IsHeader (extra) && !IsAttach (extra)); >++ CHECK_ATTACH; >++ if (extra->ctx && extra->ctx->magic == M_NNTP && >++ !((NNTP_DATA *)extra->ctx->data)->allowed && >++ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) >++ break; >++ ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL); >++ redraw = REDRAW_FULL; >++ break; >++ >++ case OP_FORWARD_TO_GROUP: >++ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); >++ CHECK_ATTACH; >++ if (extra->ctx && extra->ctx->magic == M_NNTP && >++ !((NNTP_DATA *)extra->ctx->data)->allowed && >++ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) >++ break; >++ if (IsMsgAttach (extra)) >++ mutt_attach_forward (extra->fp, extra->hdr, extra->idx, >++ extra->idxlen, extra->bdy, SENDNEWS); >++ else >++ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); >++ redraw = REDRAW_FULL; >++ break; >++ >++ case OP_FOLLOWUP: >++ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); >++ CHECK_ATTACH; >++ >++ if (IsMsgAttach (extra)) >++ followup_to = extra->bdy->hdr->env->followup_to; >++ else >++ followup_to = extra->hdr->env->followup_to; >++ >++ if (!followup_to || mutt_strcasecmp (followup_to, "poster") || >++ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES) >++ { >++ if (extra->ctx && extra->ctx->magic == M_NNTP && >++ !((NNTP_DATA *)extra->ctx->data)->allowed && >++ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) >++ break; >++ if (IsMsgAttach (extra)) >++ mutt_attach_reply (extra->fp, extra->hdr, extra->idx, >++ extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY); >++ else >++ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, >++ extra->ctx, extra->hdr); >++ redraw = REDRAW_FULL; >++ break; >++ } >++#endif >++ >+ case OP_REPLY: >+ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); >+ CHECK_ATTACH; >+@@ -2578,7 +2655,7 @@ search_next: >+ CHECK_ATTACH; >+ if (IsMsgAttach (extra)) >+ mutt_attach_forward (extra->fp, extra->hdr, extra->idx, >+- extra->idxlen, extra->bdy); >++ extra->idxlen, extra->bdy, 0); >+ else >+ ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); >+ redraw = REDRAW_FULL; >+diff -udprP mutt-1.5.23.orig/parse.c mutt-1.5.23/parse.c >+--- mutt-1.5.23.orig/parse.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/parse.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch >+ /* not reached */ >+ } >+ >+-static LIST *mutt_parse_references (char *s, int in_reply_to) >++LIST *mutt_parse_references (char *s, int in_reply_to) >+ { >+ LIST *t, *lst = NULL; >+ char *m; >+@@ -1072,6 +1072,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e, >+ e->from = rfc822_parse_adrlist (e->from, p); >+ matched = 1; >+ } >++#ifdef USE_NNTP >++ else if (!mutt_strcasecmp (line+1, "ollowup-to")) >++ { >++ if (!e->followup_to) >++ { >++ mutt_remove_trailing_ws (p); >++ e->followup_to = safe_strdup (mutt_skip_whitespace (p)); >++ } >++ matched = 1; >++ } >++#endif >+ break; >+ >+ case 'i': >+@@ -1154,6 +1165,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e, >+ } >+ break; >+ >++#ifdef USE_NNTP >++ case 'n': >++ if (!mutt_strcasecmp (line + 1, "ewsgroups")) >++ { >++ FREE (&e->newsgroups); >++ mutt_remove_trailing_ws (p); >++ e->newsgroups = safe_strdup (mutt_skip_whitespace (p)); >++ matched = 1; >++ } >++ break; >++#endif >++ >++ case 'o': >++ /* field `Organization:' saves only for pager! */ >++ if (!mutt_strcasecmp (line + 1, "rganization")) >++ { >++ if (!e->organization && mutt_strcasecmp (p, "unknown")) >++ e->organization = safe_strdup (p); >++ } >++ break; >++ >+ case 'r': >+ if (!ascii_strcasecmp (line + 1, "eferences")) >+ { >+@@ -1266,6 +1298,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e, >+ e->x_label = safe_strdup(p); >+ matched = 1; >+ } >++#ifdef USE_NNTP >++ else if (!mutt_strcasecmp (line + 1, "-comment-to")) >++ { >++ if (!e->x_comment_to) >++ e->x_comment_to = safe_strdup (p); >++ matched = 1; >++ } >++ else if (!mutt_strcasecmp (line + 1, "ref")) >++ { >++ if (!e->xref) >++ e->xref = safe_strdup (p); >++ matched = 1; >++ } >++#endif >+ >+ default: >+ break; >+diff -udprP mutt-1.5.23.orig/pattern.c mutt-1.5.23/pattern.c >+--- mutt-1.5.23.orig/pattern.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/pattern.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -92,6 +92,9 @@ Flags[] = >+ { 'U', M_UNREAD, 0, NULL }, >+ { 'v', M_COLLAPSED, 0, NULL }, >+ { 'V', M_CRYPT_VERIFIED, 0, NULL }, >++#ifdef USE_NNTP >++ { 'w', M_NEWSGROUPS, 0, eat_regexp }, >++#endif >+ { 'x', M_REFERENCE, 0, eat_regexp }, >+ { 'X', M_MIMEATTACH, 0, eat_range }, >+ { 'y', M_XLABEL, 0, eat_regexp }, >+@@ -1213,6 +1216,10 @@ mutt_pattern_exec (struct pattern_t *pat >+ } >+ case M_UNREFERENCED: >+ return (pat->not ^ (h->thread && !h->thread->child)); >++#ifdef USE_NNTP >++ case M_NEWSGROUPS: >++ return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0)); >++#endif >+ } >+ mutt_error (_("error: unknown op %d (report this error)."), pat->op); >+ return (-1); >+@@ -1294,6 +1301,7 @@ int mutt_pattern_func (int op, char *pro >+ progress_t progress; >+ >+ strfcpy (buf, NONULL (Context->pattern), sizeof (buf)); >++ if (prompt || op != M_LIMIT) >+ if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0]) >+ return (-1); >+ >+diff -udprP mutt-1.5.23.orig/po/POTFILES.in mutt-1.5.23/po/POTFILES.in >+--- mutt-1.5.23.orig/po/POTFILES.in 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/po/POTFILES.in 2014-03-13 12:48:37.000000000 +0200 >+@@ -46,6 +46,8 @@ mutt_ssl_gnutls.c >+ mutt_tunnel.c >+ muttlib.c >+ mx.c >++newsrc.c >++nntp.c >+ pager.c >+ parse.c >+ pattern.c >+diff -udprP mutt-1.5.23.orig/postpone.c mutt-1.5.23/postpone.c >+--- mutt-1.5.23.orig/postpone.c 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23/postpone.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -125,15 +125,26 @@ int mutt_num_postponed (int force) >+ >+ if (LastModify < st.st_mtime) >+ { >++#ifdef USE_NNTP >++ int optnews = option (OPTNEWS); >++#endif >+ LastModify = st.st_mtime; >+ >+ if (access (Postponed, R_OK | F_OK) != 0) >+ return (PostCount = 0); >++#ifdef USE_NNTP >++ if (optnews) >++ unset_option (OPTNEWS); >++#endif >+ if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL) >+ PostCount = 0; >+ else >+ PostCount = ctx.msgcount; >+ mx_fastclose_mailbox (&ctx); >++#ifdef USE_NNTP >++ if (optnews) >++ set_option (OPTNEWS); >++#endif >+ } >+ >+ return (PostCount); >+diff -udprP mutt-1.5.23.orig/protos.h mutt-1.5.23/protos.h >+--- mutt-1.5.23.orig/protos.h 2014-03-12 18:06:17.000000000 +0200 >++++ mutt-1.5.23/protos.h 2014-03-13 12:48:37.000000000 +0200 >+@@ -111,6 +111,7 @@ HASH *mutt_make_id_hash (CONTEXT *); >+ HASH *mutt_make_subj_hash (CONTEXT *); >+ >+ LIST *mutt_make_references(ENVELOPE *e); >++LIST *mutt_parse_references (char *, int); >+ >+ char *mutt_read_rfc822_line (FILE *, char *, size_t *); >+ ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short); >+diff -udprP mutt-1.5.23.orig/recvattach.c mutt-1.5.23/recvattach.c >+--- mutt-1.5.23.orig/recvattach.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/recvattach.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -1119,6 +1119,15 @@ void mutt_view_attachments (HEADER *hdr) >+ } >+ #endif >+ >++#ifdef USE_NNTP >++ if (Context->magic == M_NNTP) >++ { >++ mutt_flushinp (); >++ mutt_error _("Can't delete attachment from news server."); >++ break; >++ } >++#endif >++ >+ if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED) >+ { >+ mutt_message _( >+@@ -1210,10 +1219,33 @@ void mutt_view_attachments (HEADER *hdr) >+ case OP_FORWARD_MESSAGE: >+ CHECK_ATTACH; >+ mutt_attach_forward (fp, hdr, idx, idxlen, >+- menu->tagprefix ? NULL : idx[menu->current]->content); >++ menu->tagprefix ? NULL : idx[menu->current]->content, 0); >+ menu->redraw = REDRAW_FULL; >+ break; >+ >++#ifdef USE_NNTP >++ case OP_FORWARD_TO_GROUP: >++ CHECK_ATTACH; >++ mutt_attach_forward (fp, hdr, idx, idxlen, >++ menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS); >++ menu->redraw = REDRAW_FULL; >++ break; >++ >++ case OP_FOLLOWUP: >++ CHECK_ATTACH; >++ >++ if (!idx[menu->current]->content->hdr->env->followup_to || >++ mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") || >++ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES) >++ { >++ mutt_attach_reply (fp, hdr, idx, idxlen, >++ menu->tagprefix ? NULL : idx[menu->current]->content, >++ SENDNEWS|SENDREPLY); >++ menu->redraw = REDRAW_FULL; >++ break; >++ } >++#endif >++ >+ case OP_REPLY: >+ case OP_GROUP_REPLY: >+ case OP_LIST_REPLY: >+diff -udprP mutt-1.5.23.orig/recvcmd.c mutt-1.5.23/recvcmd.c >+--- mutt-1.5.23.orig/recvcmd.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/recvcmd.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -401,7 +401,7 @@ static BODY ** copy_problematic_attachme >+ static void attach_forward_bodies (FILE * fp, HEADER * hdr, >+ ATTACHPTR ** idx, short idxlen, >+ BODY * cur, >+- short nattach) >++ short nattach, int flags) >+ { >+ short i; >+ short mime_fwd_all = 0; >+@@ -547,7 +547,7 @@ _("Can't decode all tagged attachments. >+ tmpfp = NULL; >+ >+ /* now that we have the template, send it. */ >+- ci_send_message (0, tmphdr, tmpbody, NULL, parent); >++ ci_send_message (flags, tmphdr, tmpbody, NULL, parent); >+ return; >+ >+ bail: >+@@ -574,7 +574,7 @@ _("Can't decode all tagged attachments. >+ */ >+ >+ static void attach_forward_msgs (FILE * fp, HEADER * hdr, >+- ATTACHPTR ** idx, short idxlen, BODY * cur) >++ ATTACHPTR ** idx, short idxlen, BODY * cur, int flags) >+ { >+ HEADER *curhdr = NULL; >+ HEADER *tmphdr; >+@@ -679,23 +679,23 @@ static void attach_forward_msgs (FILE * >+ else >+ mutt_free_header (&tmphdr); >+ >+- ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL, >++ ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL, >+ NULL, curhdr); >+ >+ } >+ >+ void mutt_attach_forward (FILE * fp, HEADER * hdr, >+- ATTACHPTR ** idx, short idxlen, BODY * cur) >++ ATTACHPTR ** idx, short idxlen, BODY * cur, int flags) >+ { >+ short nattach; >+ >+ >+ if (check_all_msg (idx, idxlen, cur, 0) == 0) >+- attach_forward_msgs (fp, hdr, idx, idxlen, cur); >++ attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags); >+ else >+ { >+ nattach = count_tagged (idx, idxlen); >+- attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach); >++ attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags); >+ } >+ } >+ >+@@ -753,28 +753,40 @@ attach_reply_envelope_defaults (ENVELOPE >+ return -1; >+ } >+ >+- if (parent) >++#ifdef USE_NNTP >++ if ((flags & SENDNEWS)) >+ { >+- if (mutt_fetch_recips (env, curenv, flags) == -1) >+- return -1; >++ /* in case followup set Newsgroups: with Followup-To: if it present */ >++ if (!env->newsgroups && curenv && >++ mutt_strcasecmp (curenv->followup_to, "poster")) >++ env->newsgroups = safe_strdup (curenv->followup_to); >+ } >+ else >++#endif >+ { >+- for (i = 0; i < idxlen; i++) >++ if (parent) >+ { >+- if (idx[i]->content->tagged >+- && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1) >++ if (mutt_fetch_recips (env, curenv, flags) == -1) >+ return -1; >+ } >++ else >++ { >++ for (i = 0; i < idxlen; i++) >++ { >++ if (idx[i]->content->tagged >++ && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1) >++ return -1; >++ } >++ } >++ >++ if ((flags & SENDLISTREPLY) && !env->to) >++ { >++ mutt_error _("No mailing lists found!"); >++ return (-1); >++ } >++ >++ mutt_fix_reply_recipients (env); >+ } >+- >+- if ((flags & SENDLISTREPLY) && !env->to) >+- { >+- mutt_error _("No mailing lists found!"); >+- return (-1); >+- } >+- >+- mutt_fix_reply_recipients (env); >+ mutt_make_misc_reply_headers (env, Context, curhdr, curenv); >+ >+ if (parent) >+@@ -835,6 +847,13 @@ void mutt_attach_reply (FILE * fp, HEADE >+ char prefix[SHORT_STRING]; >+ int rc; >+ >++#ifdef USE_NNTP >++ if (flags & SENDNEWS) >++ set_option (OPTNEWSSEND); >++ else >++ unset_option (OPTNEWSSEND); >++#endif >++ >+ if (check_all_msg (idx, idxlen, cur, 0) == -1) >+ { >+ nattach = count_tagged (idx, idxlen); >+diff -udprP mutt-1.5.23.orig/send.c mutt-1.5.23/send.c >+--- mutt-1.5.23.orig/send.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/send.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -44,6 +44,11 @@ >+ #include <sys/types.h> >+ #include <utime.h> >+ >++#ifdef USE_NNTP >++#include "nntp.h" >++#include "mx.h" >++#endif >++ >+ #ifdef MIXMASTER >+ #include "remailer.h" >+ #endif >+@@ -213,17 +218,51 @@ static int edit_address (ADDRESS **a, /* >+ return 0; >+ } >+ >+-static int edit_envelope (ENVELOPE *en) >++static int edit_envelope (ENVELOPE *en, int flags) >+ { >+ char buf[HUGE_STRING]; >+ LIST *uh = UserHeader; >+ >+- if (edit_address (&en->to, "To: ") == -1 || en->to == NULL) >+- return (-1); >+- if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1) >+- return (-1); >+- if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1) >+- return (-1); >++#ifdef USE_NNTP >++ if (option (OPTNEWSSEND)) >++ { >++ if (en->newsgroups) >++ strfcpy (buf, en->newsgroups, sizeof (buf)); >++ else >++ buf[0] = 0; >++ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0) >++ return (-1); >++ FREE (&en->newsgroups); >++ en->newsgroups = safe_strdup (buf); >++ >++ if (en->followup_to) >++ strfcpy (buf, en->followup_to, sizeof (buf)); >++ else >++ buf[0] = 0; >++ if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0) >++ return (-1); >++ FREE (&en->followup_to); >++ en->followup_to = safe_strdup (buf); >++ >++ if (en->x_comment_to) >++ strfcpy (buf, en->x_comment_to, sizeof (buf)); >++ else >++ buf[0] = 0; >++ if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0) >++ return (-1); >++ FREE (&en->x_comment_to); >++ en->x_comment_to = safe_strdup (buf); >++ } >++ else >++#endif >++ { >++ if (edit_address (&en->to, "To: ") == -1 || en->to == NULL) >++ return (-1); >++ if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1) >++ return (-1); >++ if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1) >++ return (-1); >++ } >+ >+ if (en->subject) >+ { >+@@ -258,6 +297,14 @@ static int edit_envelope (ENVELOPE *en) >+ return 0; >+ } >+ >++#ifdef USE_NNTP >++char *nntp_get_header (const char *s) >++{ >++ SKIPWS (s); >++ return safe_strdup (s); >++} >++#endif >++ >+ static void process_user_recips (ENVELOPE *env) >+ { >+ LIST *uh = UserHeader; >+@@ -270,6 +317,14 @@ static void process_user_recips (ENVELOP >+ env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3); >+ else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0) >+ env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4); >++#ifdef USE_NNTP >++ else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0) >++ env->newsgroups = nntp_get_header (uh->data + 11); >++ else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0) >++ env->followup_to = nntp_get_header (uh->data + 12); >++ else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0) >++ env->x_comment_to = nntp_get_header (uh->data + 13); >++#endif >+ } >+ } >+ >+@@ -308,6 +363,12 @@ static void process_user_header (ENVELOP >+ else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 && >+ ascii_strncasecmp ("cc:", uh->data, 3) != 0 && >+ ascii_strncasecmp ("bcc:", uh->data, 4) != 0 && >++#ifdef USE_NNTP >++ ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 && >++ ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 && >++ ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 && >++#endif >++ ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 && >+ ascii_strncasecmp ("subject:", uh->data, 8) != 0 && >+ ascii_strncasecmp ("return-path:", uh->data, 12) != 0) >+ { >+@@ -656,6 +717,10 @@ void mutt_add_to_reference_headers (ENVE >+ if (pp) *pp = p; >+ if (qq) *qq = q; >+ >++#ifdef USE_NNTP >++ if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from) >++ env->x_comment_to = safe_strdup (mutt_get_name (curenv->from)); >++#endif >+ } >+ >+ static void >+@@ -718,6 +783,16 @@ envelope_defaults (ENVELOPE *env, CONTEX >+ >+ if (flags & SENDREPLY) >+ { >++#ifdef USE_NNTP >++ if ((flags & SENDNEWS)) >++ { >++ /* in case followup set Newsgroups: with Followup-To: if it present */ >++ if (!env->newsgroups && curenv && >++ mutt_strcasecmp (curenv->followup_to, "poster")) >++ env->newsgroups = safe_strdup (curenv->followup_to); >++ } >++ else >++#endif >+ if (tag) >+ { >+ HEADER *h; >+@@ -864,7 +939,18 @@ void mutt_set_followup_to (ENVELOPE *e) >+ * it hasn't already been set >+ */ >+ >+- if (option (OPTFOLLOWUPTO) && !e->mail_followup_to) >++ if (!option (OPTFOLLOWUPTO)) >++ return; >++#ifdef USE_NNTP >++ if (option (OPTNEWSSEND)) >++ { >++ if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ','))) >++ e->followup_to = safe_strdup (e->newsgroups); >++ return; >++ } >++#endif >++ >++ if (!e->mail_followup_to) >+ { >+ if (mutt_is_list_cc (0, e->to, e->cc)) >+ { >+@@ -1026,6 +1112,9 @@ static int send_message (HEADER *msg) >+ #endif >+ >+ #if USE_SMTP >++#ifdef USE_NNTP >++ if (!option (OPTNEWSSEND)) >++#endif >+ if (SmtpUrl) >+ return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc, >+ msg->env->bcc, tempfile, >+@@ -1137,6 +1226,13 @@ ci_send_message (int flags, /* send mod >+ >+ int rv = -1; >+ >++#ifdef USE_NNTP >++ if (flags & SENDNEWS) >++ set_option (OPTNEWSSEND); >++ else >++ unset_option (OPTNEWSSEND); >++#endif >++ >+ if (!flags && !msg && quadoption (OPT_RECALL) != M_NO && >+ mutt_num_postponed (1)) >+ { >+@@ -1167,6 +1263,22 @@ ci_send_message (int flags, /* send mod >+ { >+ if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0) >+ goto cleanup; >++#ifdef USE_NNTP >++ /* >++ * If postponed message is a news article, it have >++ * a "Newsgroups:" header line, then set appropriate flag. >++ */ >++ if (msg->env->newsgroups) >++ { >++ flags |= SENDNEWS; >++ set_option (OPTNEWSSEND); >++ } >++ else >++ { >++ flags &= ~SENDNEWS; >++ unset_option (OPTNEWSSEND); >++ } >++#endif >+ } >+ >+ if (flags & (SENDPOSTPONED|SENDRESEND)) >+@@ -1259,11 +1371,16 @@ ci_send_message (int flags, /* send mod >+ if (flags & SENDREPLY) >+ mutt_fix_reply_recipients (msg->env); >+ >++#ifdef USE_NNTP >++ if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups) >++ msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group); >++#endif >++ >+ if (! (flags & (SENDMAILX|SENDBATCH)) && >+ ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) && >+ ! ((flags & SENDREPLY) && option (OPTFASTREPLY))) >+ { >+- if (edit_envelope (msg->env) == -1) >++ if (edit_envelope (msg->env, flags) == -1) >+ goto cleanup; >+ } >+ >+@@ -1546,6 +1663,11 @@ main_loop: >+ if (i == -1) >+ { >+ /* abort */ >++#ifdef USE_NNTP >++ if (flags & SENDNEWS) >++ mutt_message _("Article not posted."); >++ else >++#endif >+ mutt_message _("Mail not sent."); >+ goto cleanup; >+ } >+@@ -1578,6 +1700,9 @@ main_loop: >+ } >+ } >+ >++#ifdef USE_NNTP >++ if (!(flags & SENDNEWS)) >++#endif >+ if (!has_recips (msg->env->to) && !has_recips (msg->env->cc) && >+ !has_recips (msg->env->bcc)) >+ { >+@@ -1611,6 +1736,19 @@ main_loop: >+ mutt_error _("No subject specified."); >+ goto main_loop; >+ } >++#ifdef USE_NNTP >++ if ((flags & SENDNEWS) && !msg->env->subject) >++ { >++ mutt_error _("No subject specified."); >++ goto main_loop; >++ } >++ >++ if ((flags & SENDNEWS) && !msg->env->newsgroups) >++ { >++ mutt_error _("No newsgroup specified."); >++ goto main_loop; >++ } >++#endif >+ >+ if (msg->content->next) >+ msg->content = mutt_make_multipart (msg->content); >+@@ -1817,7 +1955,12 @@ full_fcc: >+ } >+ } >+ else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX)) >+- mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background.")); >++ mutt_message (i != 0 ? _("Sending in background.") : >++#ifdef USE_NNTP >++ (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent.")); >++#else >++ _("Mail sent.")); >++#endif >+ >+ if (WithCrypto && (msg->security & ENCRYPT)) >+ FREE (&pgpkeylist); >+diff -udprP mutt-1.5.23.orig/sendlib.c mutt-1.5.23/sendlib.c >+--- mutt-1.5.23.orig/sendlib.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/sendlib.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -46,6 +46,10 @@ >+ #include <sys/wait.h> >+ #include <fcntl.h> >+ >++#ifdef USE_NNTP >++#include "nntp.h" >++#endif >++ >+ #ifdef HAVE_SYSEXITS_H >+ #include <sysexits.h> >+ #else /* Make sure EX_OK is defined <philiph@pobox.com> */ >+@@ -1543,6 +1547,14 @@ void mutt_write_references (LIST *r, FIL >+ { >+ LIST **ref = NULL; >+ int refcnt = 0, refmax = 0; >++ int multiline = 1; >++ int space = 0; >++ >++ if (trim < 0) >++ { >++ trim = -trim; >++ multiline = 0; >++ } >+ >+ for ( ; (trim == 0 || refcnt < trim) && r ; r = r->next) >+ { >+@@ -1553,9 +1565,11 @@ void mutt_write_references (LIST *r, FIL >+ >+ while (refcnt-- > 0) >+ { >+- fputc (' ', f); >++ if (multiline || space) >++ fputc (' ', f); >++ space = 1; >+ fputs (ref[refcnt]->data, f); >+- if (refcnt >= 1) >++ if (multiline && refcnt >= 1) >+ fputc ('\n', f); >+ } >+ >+@@ -1962,6 +1976,9 @@ int mutt_write_rfc822_header (FILE *fp, >+ mutt_write_address_list (env->to, fp, 4, 0); >+ } >+ else if (mode > 0) >++#ifdef USE_NNTP >++ if (!option (OPTNEWSSEND)) >++#endif >+ fputs ("To: \n", fp); >+ >+ if (env->cc) >+@@ -1970,6 +1987,9 @@ int mutt_write_rfc822_header (FILE *fp, >+ mutt_write_address_list (env->cc, fp, 4, 0); >+ } >+ else if (mode > 0) >++#ifdef USE_NNTP >++ if (!option (OPTNEWSSEND)) >++#endif >+ fputs ("Cc: \n", fp); >+ >+ if (env->bcc) >+@@ -1981,8 +2001,28 @@ int mutt_write_rfc822_header (FILE *fp, >+ } >+ } >+ else if (mode > 0) >++#ifdef USE_NNTP >++ if (!option (OPTNEWSSEND)) >++#endif >+ fputs ("Bcc: \n", fp); >+ >++#ifdef USE_NNTP >++ if (env->newsgroups) >++ fprintf (fp, "Newsgroups: %s\n", env->newsgroups); >++ else if (mode == 1 && option (OPTNEWSSEND)) >++ fputs ("Newsgroups: \n", fp); >++ >++ if (env->followup_to) >++ fprintf (fp, "Followup-To: %s\n", env->followup_to); >++ else if (mode == 1 && option (OPTNEWSSEND)) >++ fputs ("Followup-To: \n", fp); >++ >++ if (env->x_comment_to) >++ fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to); >++ else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO)) >++ fputs ("X-Comment-To: \n", fp); >++#endif >++ >+ if (env->subject) >+ mutt_write_one_header (fp, "Subject", env->subject, NULL, 0, 0); >+ else if (mode == 1) >+@@ -2001,6 +2041,9 @@ int mutt_write_rfc822_header (FILE *fp, >+ fputs ("Reply-To: \n", fp); >+ >+ if (env->mail_followup_to) >++#ifdef USE_NNTP >++ if (!option (OPTNEWSSEND)) >++#endif >+ { >+ fputs ("Mail-Followup-To: ", fp); >+ mutt_write_address_list (env->mail_followup_to, fp, 18, 0); >+@@ -2344,6 +2387,23 @@ mutt_invoke_sendmail (ADDRESS *from, /* >+ size_t argslen = 0, argsmax = 0; >+ int i; >+ >++#ifdef USE_NNTP >++ if (option (OPTNEWSSEND)) >++ { >++ char cmd[LONG_STRING]; >++ >++ mutt_FormatString (cmd, sizeof (cmd), 0, NONULL (Inews), nntp_format_str, 0, 0); >++ if (!*cmd) >++ { >++ i = nntp_post (msg); >++ unlink (msg); >++ return i; >++ } >++ >++ s = safe_strdup (cmd); >++ } >++#endif >++ >+ /* ensure that $sendmail is set to avoid a crash. http://dev.mutt.org/trac/ticket/3548 */ >+ if (!s) >+ { >+@@ -2374,6 +2434,10 @@ mutt_invoke_sendmail (ADDRESS *from, /* >+ i++; >+ } >+ >++#ifdef USE_NNTP >++ if (!option (OPTNEWSSEND)) >++ { >++#endif >+ if (eightbit && option (OPTUSE8BITMIME)) >+ args = add_option (args, &argslen, &argsmax, "-B8BITMIME"); >+ >+@@ -2405,6 +2469,9 @@ mutt_invoke_sendmail (ADDRESS *from, /* >+ args = add_args (args, &argslen, &argsmax, to); >+ args = add_args (args, &argslen, &argsmax, cc); >+ args = add_args (args, &argslen, &argsmax, bcc); >++#ifdef USE_NNTP >++ } >++#endif >+ >+ if (argslen == argsmax) >+ safe_realloc (&args, sizeof (char *) * (++argsmax)); >+@@ -2485,6 +2552,9 @@ void mutt_prepare_envelope (ENVELOPE *en >+ rfc2047_encode_string (&env->x_label); >+ >+ if (env->subject) >++#ifdef USE_NNTP >++ if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT)) >++#endif >+ { >+ rfc2047_encode_string (&env->subject); >+ } >+@@ -2605,6 +2675,10 @@ int mutt_bounce_message (FILE *fp, HEADE >+ } >+ rfc822_write_address (resent_from, sizeof (resent_from), from, 0); >+ >++#ifdef USE_NNTP >++ unset_option (OPTNEWSSEND); >++#endif >++ >+ /* >+ * prepare recipient list. idna conversion appears to happen before this >+ * function is called, since the user receives confirmation of the address >+diff -udprP mutt-1.5.23.orig/sort.c mutt-1.5.23/sort.c >+--- mutt-1.5.23.orig/sort.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/sort.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -24,6 +24,11 @@ >+ #include "sort.h" >+ #include "mutt_idna.h" >+ >++#ifdef USE_NNTP >++#include "mx.h" >++#include "nntp.h" >++#endif >++ >+ #include <stdlib.h> >+ #include <string.h> >+ #include <ctype.h> >+@@ -151,6 +156,17 @@ static int compare_order (const void *a, >+ HEADER **ha = (HEADER **) a; >+ HEADER **hb = (HEADER **) b; >+ >++#ifdef USE_NNTP >++ if (Context && Context->magic == M_NNTP) >++ { >++ anum_t na = NHDR (*ha)->article_num; >++ anum_t nb = NHDR (*hb)->article_num; >++ int result = na == nb ? 0 : na > nb ? 1 : -1; >++ AUXSORT (result, a, b); >++ return (SORTCODE (result)); >++ } >++ else >++#endif >+ /* no need to auxsort because you will never have equality here */ >+ return (SORTCODE ((*ha)->index - (*hb)->index)); >+ } >+diff -udprP mutt-1.5.23.orig/url.c mutt-1.5.23/url.c >+--- mutt-1.5.23.orig/url.c 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/url.c 2014-03-13 12:48:37.000000000 +0200 >+@@ -39,6 +39,8 @@ static const struct mapping_t UrlMap[] = >+ { "imaps", U_IMAPS }, >+ { "pop", U_POP }, >+ { "pops", U_POPS }, >++ { "news", U_NNTP }, >++ { "snews", U_NNTPS }, >+ { "mailto", U_MAILTO }, >+ { "smtp", U_SMTP }, >+ { "smtps", U_SMTPS }, >+@@ -214,7 +216,7 @@ int url_ciss_tostring (ciss_url_t* ciss, >+ safe_strcat (dest, len, "//"); >+ len -= (l = strlen (dest)); dest += l; >+ >+- if (ciss->user) >++ if (ciss->user && (ciss->user[0] || !(flags & U_PATH))) >+ { >+ char u[STRING]; >+ url_pct_encode (u, sizeof (u), ciss->user); >+diff -udprP mutt-1.5.23.orig/url.h mutt-1.5.23/url.h >+--- mutt-1.5.23.orig/url.h 2014-03-12 18:03:45.000000000 +0200 >++++ mutt-1.5.23/url.h 2014-03-13 12:48:37.000000000 +0200 >+@@ -8,6 +8,8 @@ typedef enum url_scheme >+ U_POPS, >+ U_IMAP, >+ U_IMAPS, >++ U_NNTP, >++ U_NNTPS, >+ U_SMTP, >+ U_SMTPS, >+ U_MAILTO, >+diff -udprP mutt-1.5.23.orig/Makefile.am mutt-1.5.23/Makefile.am >+--- mutt-1.5.23.orig/Makefile.am 2014-03-12 18:03:44.000000000 +0200 >++++ mutt-1.5.23/Makefile.am 2014-03-13 12:48:37.000000000 +0200 >+@@ -57,6 +57,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c >+ mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \ >+ mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \ >+ pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \ >++ nntp.c newsrc.c \ >+ smime.c smtp.c utf8.c wcwidth.c \ >+ bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h >+ >+@@ -68,6 +69,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O >+ mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \ >+ mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \ >+ rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \ >++ nntp.h ChangeLog.nntp \ >+ _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \ >+ mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \ >+ README.SSL smime.h group.h \ >+diff -udprP mutt-1.5.23.orig/Makefile.in mutt-1.5.23/Makefile.in >+--- mutt-1.5.23.orig/Makefile.in 2014-03-12 18:26:44.000000000 +0200 >++++ mutt-1.5.23/Makefile.in 2014-03-13 12:48:37.000000000 +0200 >+@@ -484,6 +484,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c >+ mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \ >+ mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \ >+ pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \ >++ nntp.c newsrc.c \ >+ smime.c smtp.c utf8.c wcwidth.c \ >+ bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h >+ >+@@ -495,6 +496,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O >+ mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \ >+ mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \ >+ rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \ >++ nntp.h ChangeLog.nntp \ >+ _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \ >+ mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \ >+ README.SSL smime.h group.h \ >+@@ -760,6 +762,8 @@ distclean-compile: >+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@ >+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@ >+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@ >++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@ >++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@ >+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@ >+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@ >+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@ >+diff -udprP mutt-1.5.23.orig/configure mutt-1.5.23/configure >+--- mutt-1.5.23.orig/configure 2014-03-12 18:26:45.000000000 +0200 >++++ mutt-1.5.23/configure 2014-03-13 12:48:37.000000000 +0200 >+@@ -796,6 +796,7 @@ with_docdir >+ with_domain >+ enable_pop >+ enable_imap >++enable_nntp >+ enable_smtp >+ with_gss >+ with_ssl >+@@ -1464,6 +1465,7 @@ Optional Features: >+ Force use of an external dotlock program >+ --enable-pop Enable POP3 support >+ --enable-imap Enable IMAP support >++ --enable-nntp Enable NNTP support >+ --enable-smtp include internal SMTP relay support >+ --enable-debug Enable debugging support >+ --enable-flock Use flock() to lock files >+@@ -9047,6 +9049,20 @@ else >+ fi >+ >+ >++# Check whether --enable-nntp was given. >++if test "${enable_nntp+set}" = set; then : >++ enableval=$enable_nntp; if test x$enableval = xyes ; then >++ >++$as_echo "#define USE_NNTP 1" >>confdefs.h >++ >++ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o" >++ need_nntp="yes" >++ need_socket="yes" >++ fi >++ >++fi >++ >++ >+ # Check whether --enable-smtp was given. >+ if test "${enable_smtp+set}" = set; then : >+ enableval=$enable_smtp; if test $enableval = yes; then >+@@ -9059,7 +9075,7 @@ $as_echo "#define USE_SMTP 1" >>confdefs >+ fi >+ >+ >+-if test x"$need_imap" = xyes -o x"$need_pop" = xyes ; then >++if test x"$need_imap" = xyes -o x"$need_pop" = xyes -o x"$need_nntp" = xyes ; then >+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o" >+ fi >+ >+diff -udprP mutt-1.5.23.orig/doc/Muttrc mutt-1.5.23/doc/Muttrc >+--- mutt-1.5.23.orig/doc/Muttrc 2014-03-12 18:27:11.000000000 +0200 >++++ mutt-1.5.23/doc/Muttrc 2014-03-13 12:48:37.000000000 +0200 >+@@ -240,6 +240,28 @@ attachments -I message/external-body >+ # editing the body of an outgoing message. >+ # >+ # >++# set ask_follow_up=no >++# >++# Name: ask_follow_up >++# Type: boolean >++# Default: no >++# >++# >++# If set, Mutt will prompt you for follow-up groups before editing >++# the body of an outgoing message. >++# >++# >++# set ask_x_comment_to=no >++# >++# Name: ask_x_comment_to >++# Type: boolean >++# Default: no >++# >++# >++# If set, Mutt will prompt you for x-comment-to field before editing >++# the body of an outgoing message. >++# >++# >+ # set assumed_charset="" >+ # >+ # Name: assumed_charset >+@@ -445,6 +467,17 @@ attachments -I message/external-body >+ # visual terminals don't permit making the cursor invisible. >+ # >+ # >++# set catchup_newsgroup=ask-yes >++# >++# Name: catchup_newsgroup >++# Type: quadoption >++# Default: ask-yes >++# >++# >++# If this variable is set, Mutt will mark all articles in newsgroup >++# as read when you quit the newsgroup (catchup newsgroup). >++# >++# >+ # set certificate_file="~/.mutt_certificates" >+ # >+ # Name: certificate_file >+@@ -1131,6 +1164,19 @@ attachments -I message/external-body >+ # of the same email for you. >+ # >+ # >++# set followup_to_poster=ask-yes >++# >++# Name: followup_to_poster >++# Type: quadoption >++# Default: ask-yes >++# >++# >++# If this variable is set and the keyword "poster" is present in >++# Followup-To header, follow-up to newsgroup function is not >++# permitted. The message will be mailed to the submitter of the >++# message via mail. >++# >++# >+ # set force_name=no >+ # >+ # Name: force_name >+@@ -1241,6 +1287,27 @@ attachments -I message/external-body >+ # ``Franklin'' to ``Franklin, Steve''. >+ # >+ # >++# set group_index_format="%4C %M%N %5s %-45.45f %d" >++# >++# Name: group_index_format >++# Type: string >++# Default: "%4C %M%N %5s %-45.45f %d" >++# >++# >++# This variable allows you to customize the newsgroup browser display to >++# your personal taste. This string is similar to ``index_format'', but >++# has its own set of printf()-like sequences: >++# %C current newsgroup number >++# %d description of newsgroup (becomes from server) >++# %f newsgroup name >++# %M - if newsgroup not allowed for direct post (moderated for example) >++# %N N if newsgroup is new, u if unsubscribed, blank otherwise >++# %n number of new articles in newsgroup >++# %s number of unread articles in newsgroup >++# %>X right justify the rest of the string and pad with character "X" >++# %|X pad to the end of the line with character "X" >++# >++# >+ # set hdrs=yes >+ # >+ # Name: hdrs >+@@ -1789,6 +1856,7 @@ attachments -I message/external-body >+ # %E number of messages in current thread >+ # %f sender (address + real name), either From: or Return-Path: >+ # %F author name, or recipient name if the message is from you >++# %g newsgroup name (if compiled with NNTP support) >+ # %H spam attribute(s) of this message >+ # %i message-id of the current message >+ # %l number of lines in the message (does not work with maildir, >+@@ -1804,12 +1872,14 @@ attachments -I message/external-body >+ # stashed the message: list name or recipient name >+ # if not sent to a list >+ # %P progress indicator for the built-in pager (how much of the file has been displayed) >++# %R ``X-Comment-To:'' field (if present and compiled with NNTP support) >+ # %s subject of the message >+ # %S status of the message (``N''/``D''/``d''/``!''/``r''/*) >+ # %t ``To:'' field (recipients) >+ # %T the appropriate character from the $to_chars string >+ # %u user (login) name of the author >+ # %v first name of the author, or the recipient if the message is from you >++# %W name of organization of author (``Organization:'' field) >+ # %X number of attachments >+ # (please see the ``attachments'' section for possible speed effects) >+ # %y ``X-Label:'' field, if present >+@@ -1845,6 +1915,27 @@ attachments -I message/external-body >+ # ``save-hook'', ``fcc-hook'' and ``fcc-save-hook'', too. >+ # >+ # >++# set inews="" >++# >++# Name: inews >++# Type: path >++# Default: "" >++# >++# >++# If set, specifies the program and arguments used to deliver news posted >++# by Mutt. Otherwise, mutt posts article using current connection to >++# news server. The following printf-style sequence is understood: >++# %a account url >++# %p port >++# %P port if specified >++# %s news server name >++# %S url schema >++# %u username >++# >++# >++# Example: set inews="/usr/local/bin/inews -hS" >++# >++# >+ # set ispell="ispell" >+ # >+ # Name: ispell >+@@ -2214,6 +2305,18 @@ attachments -I message/external-body >+ # be attached to the newly composed message if this option is set. >+ # >+ # >++# set mime_subject=yes >++# >++# Name: mime_subject >++# Type: boolean >++# Default: yes >++# >++# >++# If unset, 8-bit ``subject:'' line in article header will not be >++# encoded according to RFC2047 to base64. This is useful when message >++# is Usenet article, because MIME for news is nonstandard feature. >++# >++# >+ # set mix_entry_format="%4n %c %-16s %a" >+ # >+ # Name: mix_entry_format >+@@ -2280,6 +2383,144 @@ attachments -I message/external-body >+ # See also $read_inc, $write_inc and $net_inc. >+ # >+ # >++# set news_cache_dir="~/.mutt" >++# >++# Name: news_cache_dir >++# Type: path >++# Default: "~/.mutt" >++# >++# >++# This variable pointing to directory where Mutt will save cached news >++# articles and headers in. If unset, articles and headers will not be >++# saved at all and will be reloaded from the server each time. >++# >++# >++# set news_server="" >++# >++# Name: news_server >++# Type: string >++# Default: "" >++# >++# >++# This variable specifies domain name or address of NNTP server. It >++# defaults to the news server specified in the environment variable >++# $NNTPSERVER or contained in the file /etc/nntpserver. You can also >++# specify username and an alternative port for each news server, ie: >++# >++# [[s]news://][username[:password]@]server[:port] >++# >++# >++# set newsgroups_charset="utf-8" >++# >++# Name: newsgroups_charset >++# Type: string >++# Default: "utf-8" >++# >++# >++# Character set of newsgroups descriptions. >++# >++# >++# set newsrc="~/.newsrc" >++# >++# Name: newsrc >++# Type: path >++# Default: "~/.newsrc" >++# >++# >++# The file, containing info about subscribed newsgroups - names and >++# indexes of read articles. The following printf-style sequence >++# is understood: >++# %a account url >++# %p port >++# %P port if specified >++# %s news server name >++# %S url schema >++# %u username >++# >++# >++# set nntp_authenticators="" >++# >++# Name: nntp_authenticators >++# Type: string >++# Default: "" >++# >++# >++# This is a colon-delimited list of authentication methods mutt may >++# attempt to use to log in to a news server, in the order mutt should >++# try them. Authentication methods are either ``user'' or any >++# SASL mechanism, e.g. ``digest-md5'', ``gssapi'' or ``cram-md5''. >++# This option is case-insensitive. If it's unset (the default) >++# mutt will try all available methods, in order from most-secure to >++# least-secure. >++# >++# Example: >++# set nntp_authenticators="digest-md5:user" >++# >++# Note: Mutt will only fall back to other authentication methods if >++# the previous methods are unavailable. If a method is available but >++# authentication fails, mutt will not connect to the IMAP server. >++# >++# >++# set nntp_context=1000 >++# >++# Name: nntp_context >++# Type: number >++# Default: 1000 >++# >++# >++# This variable defines number of articles which will be in index when >++# newsgroup entered. If active newsgroup have more articles than this >++# number, oldest articles will be ignored. Also controls how many >++# articles headers will be saved in cache when you quit newsgroup. >++# >++# >++# set nntp_load_description=yes >++# >++# Name: nntp_load_description >++# Type: boolean >++# Default: yes >++# >++# >++# This variable controls whether or not descriptions for each newsgroup >++# must be loaded when newsgroup is added to list (first time list >++# loading or new newsgroup adding). >++# >++# >++# set nntp_user="" >++# >++# Name: nntp_user >++# Type: string >++# Default: "" >++# >++# >++# Your login name on the NNTP server. If unset and NNTP server requires >++# authentification, Mutt will prompt you for your account name when you >++# connect to news server. >++# >++# >++# set nntp_pass="" >++# >++# Name: nntp_pass >++# Type: string >++# Default: "" >++# >++# >++# Your password for NNTP account. >++# >++# >++# set nntp_poll=60 >++# >++# Name: nntp_poll >++# Type: number >++# Default: 60 >++# >++# >++# The time in seconds until any operations on newsgroup except post new >++# article will cause recheck for new news. If set to 0, Mutt will >++# recheck newsgroup on each operation in index (stepping, read article, >++# etc.). >++# >++# >+ # set pager="builtin" >+ # >+ # Name: pager >+@@ -2997,6 +3238,19 @@ attachments -I message/external-body >+ # string after the inclusion of a message which is being replied to. >+ # >+ # >++# set post_moderated=ask-yes >++# >++# Name: post_moderated >++# Type: quadoption >++# Default: ask-yes >++# >++# >++# If set to yes, Mutt will post article to newsgroup that have >++# not permissions to posting (e.g. moderated). Note: if news server >++# does not support posting to that newsgroup or totally read-only, that >++# posting will not have an effect. >++# >++# >+ # set postpone=ask-yes >+ # >+ # Name: postpone >+@@ -3605,6 +3859,41 @@ attachments -I message/external-body >+ # shell from /etc/passwd is used. >+ # >+ # >++# set save_unsubscribed=no >++# >++# Name: save_unsubscribed >++# Type: boolean >++# Default: no >++# >++# >++# When set, info about unsubscribed newsgroups will be saved into >++# ``newsrc'' file and into cache. >++# >++# >++# set show_new_news=yes >++# >++# Name: show_new_news >++# Type: boolean >++# Default: yes >++# >++# >++# If set, news server will be asked for new newsgroups on entering >++# the browser. Otherwise, it will be done only once for a news server. >++# Also controls whether or not number of new articles of subscribed >++# newsgroups will be then checked. >++# >++# >++# set show_only_unread=no >++# >++# Name: show_only_unread >++# Type: boolean >++# Default: no >++# >++# >++# If set, only subscribed newsgroups that contain unread articles >++# will be displayed in browser. >++# >++# >+ # set sig_dashes=yes >+ # >+ # Name: sig_dashes >+@@ -4851,3 +5140,14 @@ attachments -I message/external-body >+ # ``tuning'' section of the manual for performance considerations. >+ # >+ # >++# set x_comment_to=no >++# >++# Name: x_comment_to >++# Type: boolean >++# Default: no >++# >++# >++# If set, Mutt will add ``X-Comment-To:'' field (that contains full >++# name of original article author) to article that followuped to newsgroup. >++# >++# >Index: SOURCES/sha1.lst >=================================================================== >--- SOURCES/sha1.lst (revision 800495) >+++ SOURCES/sha1.lst (working copy) >@@ -1,2 +1,2 @@ >-a8475f2618ce5d5d33bff85c0affdf21ab1d76b9 mutt-1.5.21.tar.gz >+8ac821d8b1e25504a31bf5fda9c08d93a4acc862 mutt-1.5.23.tar.gz > bd1ee51559088a0922de0fad897ebb452d280ae1 mutt-Muttrc_compressed_folders.foot.bz2 >Index: SPECS/mutt.spec >=================================================================== >--- SPECS/mutt.spec (revision 800495) >+++ SPECS/mutt.spec (working copy) >@@ -15,8 +15,8 @@ > %global __requires_exclude perl\\(timelocal.pl\\) > > Name: mutt >-Version: 1.5.21 >-Release: %mkrel 16 >+Version: 1.5.23 >+Release: %mkrel 1 > Epoch: 1 > > Summary: Text mode mail user agent >@@ -45,7 +45,7 @@ > Patch2: %{name}-1.5.18-urlview.patch > > # Allow non root users to install mutt >-Patch3: %{name}-1.5.5.1-no-sgid.patch >+Patch3: %{name}-1.5.23-no-sgid.patch > > # Don't include /usr/include/ncurses if not building against normal ncurses > Patch4: %{name}-1.5.5.1-ncurses-include.patch >@@ -58,7 +58,12 @@ > Patch6: mutt-1.5.20-gpg.patch > > # recognize db5 >-Patch7: mutt-1.5.21-db5.patch >+Patch7: mutt-1.5.23-db53.patch >+ >+# Fix segmentation fault on corrupt headers >+# http://dev.mutt.org/trac/ticket/3716 >+Patch8: mutt-1.5.23-ticket-3716-dev.patch >+ > # > # Patch 100- : external patches > # >@@ -65,14 +70,14 @@ > > # Compressed folder support, http://www.spinnaker.de/mutt/compressed/ > # http://www.mutt.org.ua/download/mutt-%{pversion}/patch-%{pversion}.rr.compressed.gz >-Patch100: patch-1.5.20.rr.compressed >+Patch100: mutt-1.5.23-compressed-mbox.patch > > # NNTP support > # http://www.mutt.org.ua/download/mutt-%{version}/patch-%{version}.vvv.nntp.gz >-Patch101: patch-1.5.20.vvv.nntp >+Patch101: patch-1.5.23.vvv.nntp > > # Dynamically set xterm window title / icon name >-Patch104: %{name}-1.5.5.1-xterm-title.patch >+Patch104: %{name}-1.5.23-xterm-title.patch > > # Merged upstream > #Patch107: mutt-1.5.19-nulcert.diff >@@ -79,18 +84,11 @@ > > # Now maintained at http://www.lunar-linux.org/index.php?option=com_content&task=view&id=44 > # Patch adapted from: patch-1.5.20.sidebar.20090619.txt >-Patch108: mutt-1.5.20-sidebar.patch >+Patch108: mutt-1.5.23-sidebar.patch > > # Patch adapted from: http://greek0.net/mutt.html >-Patch109: mutt-1.5.12-indexcolor-3+cb.diff >+Patch109: mutt-1.5.23-indexcolor.patch > >-#testcert CVE-2011-1429 - http://dev.mutt.org/trac/ticket/3506 >-Patch110: mutt-1.5.21-testcert.patch >- >-Patch111: mutt-1.5.21-automake-1.13.patch >-Patch112: mutt-1.5.20-cve-2014-0467.patch >-Patch113: mutt-1.5.21-CVE-2014-9116.patch >- > BuildRequires: bzip2-devel > BuildRequires: linuxdoc-tools > BuildRequires: pkgconfig(ncurses) >@@ -165,6 +163,7 @@ > %patch5 -p1 -b .mailcap > %patch6 -p0 -b .gpg > %patch7 -p0 -b .db >+%patch8 -p1 -b .3716 > %patch100 -p1 -b .cfp > %patch101 -p1 -b .nntp > %patch104 -p1 -b .xterm-title >@@ -171,10 +170,6 @@ > #%patch107 -p0 -b .nulcert > %patch108 -p1 > %patch109 -p1 >-%patch110 -p1 -b .testcert >-%patch111 -p1 >-%patch112 -p1 -b .CVE-2014-0467 >-%patch113 -p1 -b .CVE-2014-9116 > > # needed by nntp patch > autoreconf -fi >@@ -228,12 +223,12 @@ > perl -pi -e 's/ncurses ncursesw/ncurses # ncursesw/' configure > mkdir mutt-normal > pushd mutt-normal >-build >+CPPFLAGS=-DNCURSES_WIDECHAR=0 build > popd > > # build another version enabling wide char support > ### ugly. ugly. >-perl -pi -e 's/ncurses # ncursesw/ncurses ncursesw/' configure >+perl -pi -e 's/ncurses # ncursesw/ncursesw # ncurses/' configure > mkdir mutt-utf-8 > pushd mutt-utf-8 > build
Index: SOURCES/mutt-1.5.12-indexcolor-3+cb.diff =================================================================== --- SOURCES/mutt-1.5.12-indexcolor-3+cb.diff (revision 800495) +++ SOURCES/mutt-1.5.12-indexcolor-3+cb.diff (working copy) @@ -1,614 +0,0 @@ -diff --git a/color.c b/color.c -index bb6cbb4..c295dc4 100644 ---- a/color.c -+++ b/color.c -@@ -35,6 +35,8 @@ int ColorDefs[MT_COLOR_MAX]; - COLOR_LINE *ColorHdrList = NULL; - COLOR_LINE *ColorBodyList = NULL; - COLOR_LINE *ColorIndexList = NULL; -+COLOR_LINE *ColorIndexSubjectList = NULL; -+COLOR_LINE *ColorIndexAuthorList = NULL; - - /* local to this file */ - static int ColorQuoteSize; -@@ -93,6 +95,14 @@ static struct mapping_t Fields[] = - { "bold", MT_COLOR_BOLD }, - { "underline", MT_COLOR_UNDERLINE }, - { "index", MT_COLOR_INDEX }, -+ { "index_subject", MT_COLOR_INDEX_SUBJECT }, -+ { "index_author", MT_COLOR_INDEX_AUTHOR }, -+ { "index_collapsed", MT_COLOR_INDEX_COLLAPSED }, -+ { "index_date", MT_COLOR_INDEX_DATE }, -+ { "index_flags", MT_COLOR_INDEX_FLAGS }, -+ { "index_label", MT_COLOR_INDEX_LABEL }, -+ { "index_number", MT_COLOR_INDEX_NUMBER }, -+ { "index_size", MT_COLOR_INDEX_SIZE }, - { "sidebar_new", MT_COLOR_NEW }, - { "sidebar_flagged", MT_COLOR_FLAGGED }, - { NULL, 0 } -@@ -366,11 +376,54 @@ int mutt_parse_unmono (BUFFER *buf, BUFFER *s, unsigned long data, - return _mutt_parse_uncolor(buf, s, data, err, 0); - } - -+static void -+mutt_do_uncolor (BUFFER *buf, BUFFER *s, COLOR_LINE **ColorList, -+ int *do_cache, int parse_uncolor) -+{ -+ COLOR_LINE *tmp, *last = NULL; -+ -+ do -+ { -+ mutt_extract_token (buf, s, 0); -+ if (!mutt_strcmp ("*", buf->data)) -+ { -+ for (tmp = *ColorList; tmp; ) -+ { -+ if (!*do_cache) -+ *do_cache = 1; -+ last = tmp; -+ tmp = tmp->next; -+ mutt_free_color_line(&last, parse_uncolor); -+ } -+ *ColorList = NULL; -+ } -+ else -+ { -+ for (last = NULL, tmp = *ColorList; tmp; last = tmp, tmp = tmp->next) -+ { -+ if (!mutt_strcmp (buf->data, tmp->pattern)) -+ { -+ if (!*do_cache) -+ *do_cache = 1; -+ dprint(1,(debugfile,"Freeing pattern \"%s\" from ColorList\n", -+ tmp->pattern)); -+ if (last) -+ last->next = tmp->next; -+ else -+ *ColorList = tmp->next; -+ mutt_free_color_line(&tmp, parse_uncolor); -+ break; -+ } -+ } -+ } -+ } -+ while (MoreArgs (s)); -+} -+ - static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, - BUFFER *err, short parse_uncolor) - { - int object = 0, do_cache = 0; -- COLOR_LINE *tmp, *last = NULL; - COLOR_LINE **list; - - mutt_extract_token (buf, s, 0); -@@ -381,6 +434,13 @@ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, - return (-1); - } - -+ if (object > MT_COLOR_INDEX_AUTHOR) /* uncolor index column */ -+ { -+ ColorDefs[object] = 0; -+ set_option (OPTFORCEREDRAWINDEX); -+ return (0); -+ } -+ - if (mutt_strncmp (buf->data, "index", 5) == 0) - list = &ColorIndexList; - else if (mutt_strncmp (buf->data, "body", 4) == 0) -@@ -424,43 +484,13 @@ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, - return 0; - } - -- do -- { -- mutt_extract_token (buf, s, 0); -- if (!mutt_strcmp ("*", buf->data)) -- { -- for (tmp = *list; tmp; ) -- { -- if (!do_cache) -- do_cache = 1; -- last = tmp; -- tmp = tmp->next; -- mutt_free_color_line(&last, parse_uncolor); -- } -- *list = NULL; -- } -- else -- { -- for (last = NULL, tmp = *list; tmp; last = tmp, tmp = tmp->next) -- { -- if (!mutt_strcmp (buf->data, tmp->pattern)) -- { -- if (!do_cache) -- do_cache = 1; -- dprint(1,(debugfile,"Freeing pattern \"%s\" from color list\n", -- tmp->pattern)); -- if (last) -- last->next = tmp->next; -- else -- *list = tmp->next; -- mutt_free_color_line(&tmp, parse_uncolor); -- break; -- } -- } -- } -- } -- while (MoreArgs (s)); - -+ if (object == MT_COLOR_INDEX) -+ mutt_do_uncolor(buf, s, &ColorIndexList, &do_cache, parse_uncolor); -+ if (object == MT_COLOR_INDEX_SUBJECT) -+ mutt_do_uncolor(buf, s, &ColorIndexSubjectList, &do_cache, parse_uncolor); -+ if (object == MT_COLOR_INDEX_AUTHOR) -+ mutt_do_uncolor(buf, s, &ColorIndexAuthorList, &do_cache, parse_uncolor); - - if (do_cache && !option (OPTNOCURSES)) - { -@@ -700,7 +730,7 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err, - - /* extract a regular expression if needed */ - -- if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY || object == MT_COLOR_INDEX) -+ if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY || object == MT_COLOR_INDEX || object == MT_COLOR_INDEX_SUBJECT || object == MT_COLOR_INDEX_AUTHOR) - { - if (!MoreArgs (s)) - { -@@ -744,6 +774,18 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err, - r = add_pattern (&ColorIndexList, buf->data, 1, fg, bg, attr, err, 1); - set_option (OPTFORCEREDRAWINDEX); - } -+ else if (object == MT_COLOR_INDEX_SUBJECT) -+ { -+ r = add_pattern (&ColorIndexSubjectList, buf->data, -+ 1, fg, bg, attr, err, 1); -+ set_option (OPTFORCEREDRAWINDEX); -+ } -+ else if (object == MT_COLOR_INDEX_AUTHOR) -+ { -+ r = add_pattern (&ColorIndexAuthorList, buf->data, -+ 1, fg, bg, attr, err, 1); -+ set_option (OPTFORCEREDRAWINDEX); -+ } - else if (object == MT_COLOR_QUOTED) - { - if (q_level >= ColorQuoteSize) -@@ -769,7 +811,11 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err, - ColorQuote[q_level] = fgbgattr_to_color(fg, bg, attr); - } - else -+ { - ColorDefs[object] = fgbgattr_to_color(fg, bg, attr); -+ if (object > MT_COLOR_INDEX_AUTHOR) -+ set_option (OPTFORCEREDRAWINDEX); -+ } - - #ifdef HAVE_COLOR - # ifdef HAVE_BKGDSET -diff --git a/curs_lib.c b/curs_lib.c -index 2427e60..dc01320 100644 ---- a/curs_lib.c -+++ b/curs_lib.c -@@ -711,6 +711,7 @@ void mutt_format_string (char *dest, size_t destlen, - size_t k, k2; - char scratch[MB_LEN_MAX]; - mbstate_t mbstate1, mbstate2; -+ int escaped = 0; - - memset(&mbstate1, 0, sizeof (mbstate1)); - memset(&mbstate2, 0, sizeof (mbstate2)); -@@ -726,7 +727,15 @@ void mutt_format_string (char *dest, size_t destlen, - k = (k == (size_t)(-1)) ? 1 : n; - wc = replacement_char (); - } -- if (arboreal && wc < M_TREE_MAX) -+ if (escaped) { -+ escaped = 0; -+ w = 0; -+ } -+ else if (arboreal && wc == M_SPECIAL_INDEX) { -+ escaped = 1; -+ w = 0; -+ } -+ else if (arboreal && wc < M_TREE_MAX) - w = 1; /* hack */ - else - { -diff --git a/doc/manual.xml.head b/doc/manual.xml.head -index 74c33da..b9dad0f 100644 ---- a/doc/manual.xml.head -+++ b/doc/manual.xml.head -@@ -2470,7 +2470,7 @@ silently truncated at the screen width, and are not wrapped. - - <command>color</command> - <arg choice="plain"> --<option>index</option> -+<option>index-object</option> - </arg> - <arg choice="plain"> - <replaceable class="parameter">foreground</replaceable> -@@ -2485,7 +2485,7 @@ silently truncated at the screen width, and are not wrapped. - <command>uncolor</command> - <group choice="req"> - <arg choice="plain"> --<option>index</option> -+<option>index-object</option> - </arg> - <arg choice="plain"> - <option>header</option> -@@ -2526,6 +2526,14 @@ in the header/body of a message, <emphasis>index</emphasis> matches <emphasis>pa - <listitem><para>bold (hiliting bold patterns in the body of messages)</para></listitem> - <listitem><para>error (error messages printed by Mutt)</para></listitem> - <listitem><para>hdrdefault (default color of the message header in the pager)</para></listitem> -+<listitem><para>index_author (color of the author name in the index, uses <emphasis>pattern</emphasis>)</para></listitem> -+<listitem><para>index_collapsed (the number of messages in a collapsed thread in the index)</para></listitem> -+<listitem><para>index_date (color of the date field in the index)</para></listitem> -+<listitem><para>index_flags (color of the message flags in the index)</para></listitem> -+<listitem><para>index_label (color of the message label in the index)</para></listitem> -+<listitem><para>index_number (color of the message number in the index)</para></listitem> -+<listitem><para>index_size (color of the message size and line number in the index)</para></listitem> -+<listitem><para>index_subject (color of the subject in the index, uses <emphasis>pattern</emphasis>)</para></listitem> - <listitem><para>indicator (arrow or bar used to indicate the current item in a menu)</para></listitem> - <listitem><para>markers (the <quote>+</quote> markers at the beginning of wrapped lines in the pager)</para></listitem> - <listitem><para>message (informational messages)</para></listitem> -diff --git a/hdrline.c b/hdrline.c -index 23f596e..effae17 100644 ---- a/hdrline.c -+++ b/hdrline.c -@@ -103,6 +103,34 @@ static int first_mailing_list (char *buf, size_t buflen, ADDRESS *a) - return 0; - } - -+/* Takes the color to embed, the buffer to manipulate and the buffer length as -+ * arguments. -+ * Returns the number of chars written. */ -+static size_t add_index_color(char *buf, size_t buflen, -+ format_flag flags, char color) -+{ -+ int len; -+ -+ /* only add color markers if we are operating on main index entries. */ -+ if (!(flags & M_FORMAT_INDEX)) -+ return 0; -+ -+ if (color == MT_COLOR_INDEX) { /* buf might be uninitialized other cases */ -+ len = mutt_strlen(buf); -+ buf += len; -+ buflen -= len; -+ } -+ -+ if (buflen < 2) -+ return 0; -+ -+ buf[0] = M_SPECIAL_INDEX; -+ buf[1] = color; -+ buf[2] = '\0'; -+ -+ return 2; -+} -+ - static void make_from (ENVELOPE *hdr, char *buf, size_t len, int do_lists) - { - int me; -@@ -256,6 +284,7 @@ hdr_format_str (char *dest, - #define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 1) - #define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 2) - size_t len; -+ size_t colorlen; - - hdr = hfi->hdr; - ctx = hfi->ctx; -@@ -307,12 +336,17 @@ hdr_format_str (char *dest, - break; - - case 'c': -+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE); - mutt_pretty_size (buf2, sizeof (buf2), (long) hdr->content->length); -- mutt_format_s (dest, destlen, prefix, buf2); -+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); -+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); - break; - - case 'C': -- snprintf (fmt, sizeof (fmt), "%%%sd", prefix); -+ colorlen = add_index_color(fmt, sizeof(fmt), flags, MT_COLOR_INDEX_NUMBER); -+ snprintf (fmt+colorlen, sizeof(fmt)-colorlen, "%%%sd", prefix); -+ add_index_color(fmt+colorlen, sizeof(fmt)-colorlen, flags, MT_COLOR_INDEX); -+ - snprintf (dest, destlen, fmt, hdr->msgno + 1); - break; - -@@ -411,7 +445,10 @@ hdr_format_str (char *dest, - if (do_locales) - setlocale (LC_TIME, "C"); - -- mutt_format_s (dest, destlen, prefix, buf2); -+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_DATE); -+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); -+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); -+ - if (len > 0 && op != 'd' && op != 'D') /* Skip ending op */ - src = cp + 1; - } -@@ -441,8 +478,10 @@ hdr_format_str (char *dest, - case 'F': - if (!optional) - { -+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); - make_from (hdr->env, buf2, sizeof (buf2), 0); -- mutt_format_s (dest, destlen, prefix, buf2); -+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); -+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); - } - else if (mutt_addr_is_user (hdr->env->from)) - optional = 0; -@@ -474,7 +513,9 @@ hdr_format_str (char *dest, - if (!optional) - { - snprintf (fmt, sizeof (fmt), "%%%sd", prefix); -- snprintf (dest, destlen, fmt, (int) hdr->lines); -+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE); -+ snprintf (dest+colorlen, destlen-colorlen, fmt, (int) hdr->lines); -+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); - } - else if (hdr->lines <= 0) - optional = 0; -@@ -483,8 +524,10 @@ hdr_format_str (char *dest, - case 'L': - if (!optional) - { -+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); - make_from (hdr->env, buf2, sizeof (buf2), 1); -- mutt_format_s (dest, destlen, prefix, buf2); -+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); -+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); - } - else if (!check_for_mailing_list (hdr->env->to, NULL, NULL, 0) && - !check_for_mailing_list (hdr->env->cc, NULL, NULL, 0)) -@@ -539,10 +582,16 @@ hdr_format_str (char *dest, - snprintf (fmt, sizeof (fmt), "%%%sd", prefix); - if (!optional) - { -- if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1) -- snprintf (dest, destlen, fmt, hdr->num_hidden); -- else if (is_index && threads) -- mutt_format_s (dest, destlen, prefix, " "); -+ colorlen = add_index_color(dest, destlen, flags, -+ MT_COLOR_INDEX_COLLAPSED); -+ if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1) { -+ snprintf (dest+colorlen, destlen-colorlen, fmt, hdr->num_hidden); -+ add_index_color(dest, destlen-colorlen, flags, MT_COLOR_INDEX); -+ } -+ else if (is_index && threads) { -+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, " "); -+ add_index_color(dest, destlen-colorlen, flags, MT_COLOR_INDEX); -+ } - else - *dest = '\0'; - } -@@ -572,15 +621,23 @@ hdr_format_str (char *dest, - { - if (flags & M_FORMAT_FORCESUBJ) - { -- mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject)); -+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT); -+ mutt_format_s (dest+colorlen, destlen-colorlen, "", -+ NONULL (hdr->env->subject)); -+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); -+ - snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest); - mutt_format_s_tree (dest, destlen, prefix, buf2); - } - else - mutt_format_s_tree (dest, destlen, prefix, hdr->tree); - } -- else -- mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject)); -+ else { -+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT); -+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, -+ NONULL (hdr->env->subject)); -+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); -+ } - break; - - case 'S': -@@ -683,7 +740,9 @@ hdr_format_str (char *dest, - hdr->tagged ? '*' : - (hdr->flagged ? '!' : - (Tochars && ((i = mutt_user_is_recipient (hdr)) < mutt_strlen (Tochars)) ? Tochars[i] : ' '))); -- mutt_format_s (dest, destlen, prefix, buf2); -+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_FLAGS); -+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); -+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); - break; - - case 'X': -@@ -703,7 +762,9 @@ hdr_format_str (char *dest, - if (optional) - optional = hdr->env->x_label ? 1 : 0; - -- mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label)); -+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL); -+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label)); -+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); - break; - - case 'Y': -@@ -729,10 +790,12 @@ hdr_format_str (char *dest, - if (optional) - optional = i; - -+ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL); - if (i) -- mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label)); -+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label)); - else -- mutt_format_s (dest, destlen, prefix, ""); -+ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, ""); -+ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); - - break; - -diff --git a/menu.c b/menu.c -index fa06915..672e5b2 100644 ---- a/menu.c -+++ b/menu.c -@@ -35,7 +35,30 @@ extern size_t UngetCount; - - char* SearchBuffers[MENU_MAX]; - --static void print_enriched_string (int attr, unsigned char *s, int do_color) -+static int get_color(int index, int type) { -+ COLOR_LINE *color; -+ HEADER *hdr = Context->hdrs[index]; -+ -+ switch (type) { -+ case MT_COLOR_INDEX_SUBJECT: -+ color = ColorIndexSubjectList; -+ break; -+ case MT_COLOR_INDEX_AUTHOR: -+ color = ColorIndexAuthorList; -+ break; -+ default: -+ return ColorDefs[type]; -+ } -+ -+ for (; color; color = color->next) -+ if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS, -+ Context, hdr)) -+ return color->pair; -+ -+ return 0; -+} -+ -+static void print_enriched_string (int index, int attr, unsigned char *s, int do_color) - { - wchar_t wc; - size_t k; -@@ -132,6 +155,18 @@ static void print_enriched_string (int attr, unsigned char *s, int do_color) - } - if (do_color) attrset(attr); - } -+ else if(*s == M_SPECIAL_INDEX) -+ { -+ s++; -+ if (do_color) { -+ if (*s == MT_COLOR_INDEX) -+ attrset(attr); -+ else -+ attron(get_color(index, *s)); -+ } -+ s++; -+ n -= 2; -+ } - else if ((k = mbrtowc (&wc, (char *)s, n, &mbstate)) > 0) - { - addnstr ((char *)s, k); -@@ -235,7 +270,7 @@ void menu_redraw_index (MUTTMENU *menu) - addstr (" "); - } - -- print_enriched_string (menu->color(i), (unsigned char *) buf, 1); -+ print_enriched_string (i, menu->color(i), (unsigned char *) buf, 1); - SETCOLOR (MT_COLOR_NORMAL); - } - else -@@ -249,7 +284,7 @@ void menu_redraw_index (MUTTMENU *menu) - } - - CLEARLINE_WIN (i - menu->top + menu->offset); -- print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current); -+ print_enriched_string (i, menu->color(i), (unsigned char *) buf, i != menu->current); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); - } -@@ -286,7 +321,7 @@ void menu_redraw_motion (MUTTMENU *menu) - menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); - menu_pad_string (buf, sizeof (buf)); - move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3); -- print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); -+ print_enriched_string (menu->oldcurrent, menu->color(menu->oldcurrent), (unsigned char *) buf, 1); - SETCOLOR (MT_COLOR_NORMAL); - } - -@@ -304,7 +339,7 @@ void menu_redraw_motion (MUTTMENU *menu) - clrtoeol (); - menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); - menu_pad_string (buf, sizeof (buf)); -- print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); -+ print_enriched_string (menu->oldcurrent, menu->color(menu->oldcurrent), (unsigned char *) buf, 1); - - /* now draw the new one to reflect the change */ - menu_make_entry (buf, sizeof (buf), menu, menu->current); -@@ -313,7 +348,7 @@ void menu_redraw_motion (MUTTMENU *menu) - ADDCOLOR (MT_COLOR_INDICATOR); - BKGDSET (MT_COLOR_INDICATOR); - CLEARLINE_WIN (menu->current - menu->top + menu->offset); -- print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); -+ print_enriched_string (menu->current, menu->color(menu->current), (unsigned char *) buf, 0); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); - } -@@ -339,7 +374,7 @@ void menu_redraw_current (MUTTMENU *menu) - attrset (attr); - addch (' '); - menu_pad_string (buf, sizeof (buf)); -- print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 1); -+ print_enriched_string (menu->current, menu->color(menu->current), (unsigned char *) buf, 1); - SETCOLOR (MT_COLOR_NORMAL); - } - else -@@ -348,7 +383,7 @@ void menu_redraw_current (MUTTMENU *menu) - ADDCOLOR (MT_COLOR_INDICATOR); - BKGDSET (MT_COLOR_INDICATOR); - clrtoeol (); -- print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); -+ print_enriched_string (menu->current, menu->color(menu->current), (unsigned char *) buf, 0); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); - } -diff --git a/mutt.h b/mutt.h -index 755a434..787b398 100644 ---- a/mutt.h -+++ b/mutt.h -@@ -168,6 +168,8 @@ typedef enum - #define M_TREE_MISSING 13 - #define M_TREE_MAX 14 - -+#define M_SPECIAL_INDEX M_TREE_MAX -+ - #define M_THREAD_COLLAPSE (1<<0) - #define M_THREAD_UNCOLLAPSE (1<<1) - #define M_THREAD_GET_HIDDEN (1<<2) -diff --git a/mutt_curses.h b/mutt_curses.h -index 5f61048..ed886b4 100644 ---- a/mutt_curses.h -+++ b/mutt_curses.h -@@ -129,6 +129,16 @@ enum - MT_COLOR_INDEX, - MT_COLOR_NEW, - MT_COLOR_FLAGGED, -+ /* please no non-MT_COLOR_INDEX objects after this point */ -+ MT_COLOR_INDEX_SUBJECT, -+ MT_COLOR_INDEX_AUTHOR, -+ /* below only index coloring stuff that doesn't have a colorline! */ -+ MT_COLOR_INDEX_COLLAPSED, -+ MT_COLOR_INDEX_DATE, -+ MT_COLOR_INDEX_FLAGS, -+ MT_COLOR_INDEX_LABEL, -+ MT_COLOR_INDEX_NUMBER, -+ MT_COLOR_INDEX_SIZE, - MT_COLOR_MAX - }; - -@@ -182,6 +192,8 @@ extern int ColorDefs[]; - extern COLOR_LINE *ColorHdrList; - extern COLOR_LINE *ColorBodyList; - extern COLOR_LINE *ColorIndexList; -+extern COLOR_LINE *ColorIndexSubjectList; -+extern COLOR_LINE *ColorIndexAuthorList; - - void ci_init_color (void); - void ci_start_color (void); Index: SOURCES/mutt-1.5.20-cve-2014-0467.patch =================================================================== --- SOURCES/mutt-1.5.20-cve-2014-0467.patch (revision 800495) +++ SOURCES/mutt-1.5.20-cve-2014-0467.patch (working copy) @@ -1,11 +0,0 @@ -diff -up mutt/copy.c.cve-2014-0467 mutt/copy.c ---- mutt/copy.c.cve-2014-0467 2009-12-14 19:24:59.000000000 +0100 -+++ mutt/copy.c 2014-03-13 10:29:13.844051152 +0100 -@@ -254,6 +254,7 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF - { - if (!address_header_decode (&this_one)) - rfc2047_decode (&this_one); -+ this_one_len = mutt_strlen (this_one); - } - - if (!headers[x]) Index: SOURCES/mutt-1.5.20-sidebar.patch =================================================================== --- SOURCES/mutt-1.5.20-sidebar.patch (revision 800495) +++ SOURCES/mutt-1.5.20-sidebar.patch (working copy) @@ -1,1372 +0,0 @@ -diff -uNp -r mutt-5302767aa6aa.orig/Makefile.am mutt-5302767aa6aa/Makefile.am ---- mutt-5302767aa6aa.orig/Makefile.am Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/Makefile.am Sat Sep 4 20:32:59 2010 -@@ -32,6 +32,7 @@ mutt_SOURCES = \ - rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \ - score.c send.c sendlib.c signal.c sort.c \ - status.c system.c thread.c charset.c history.c lib.c \ -+ sidebar.c \ - muttlib.c editmsg.c mbyte.c \ - url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c - -diff -uNp -r mutt-5302767aa6aa.orig/OPS mutt-5302767aa6aa/OPS ---- mutt-5302767aa6aa.orig/OPS Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/OPS Sat Sep 4 20:32:59 2010 -@@ -179,3 +179,8 @@ OP_WHAT_KEY "display the keycode for a key press" - OP_MAIN_SHOW_LIMIT "show currently active limit pattern" - OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread" - OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads" -+OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page" -+OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page" -+OP_SIDEBAR_NEXT "go down to next mailbox" -+OP_SIDEBAR_PREV "go to previous mailbox" -+OP_SIDEBAR_OPEN "open hilighted mailbox" -diff -uNp -r mutt-5302767aa6aa.orig/PATCHES mutt-5302767aa6aa/PATCHES ---- mutt-5302767aa6aa.orig/PATCHES Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/PATCHES Sat Sep 4 20:32:59 2010 -@@ -0,0 +1 @@ -+patch-1.5.19.sidebar.20090522.txt -diff -uNp -r mutt-5302767aa6aa.orig/buffy.c mutt-5302767aa6aa/buffy.c ---- mutt-5302767aa6aa.orig/buffy.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/buffy.c Sat Sep 4 20:32:59 2010 -@@ -320,6 +320,68 @@ static int buffy_maildir_hasnew (BUFFY* mailbox) - return rc; - } - -+/* update message counts for the sidebar */ -+void buffy_maildir_update (BUFFY* mailbox) -+{ -+ char path[_POSIX_PATH_MAX]; -+ DIR *dirp; -+ struct dirent *de; -+ char *p; -+ -+ mailbox->msgcount = 0; -+ mailbox->msg_unread = 0; -+ mailbox->msg_flagged = 0; -+ -+ snprintf (path, sizeof (path), "%s/new", mailbox->path); -+ -+ if ((dirp = opendir (path)) == NULL) -+ { -+ mailbox->magic = 0; -+ return; -+ } -+ -+ while ((de = readdir (dirp)) != NULL) -+ { -+ if (*de->d_name == '.') -+ continue; -+ -+ if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) { -+ mailbox->new = 1; -+ mailbox->msgcount++; -+ mailbox->msg_unread++; -+ } -+ } -+ -+ closedir (dirp); -+ snprintf (path, sizeof (path), "%s/cur", mailbox->path); -+ -+ if ((dirp = opendir (path)) == NULL) -+ { -+ mailbox->magic = 0; -+ return; -+ } -+ -+ while ((de = readdir (dirp)) != NULL) -+ { -+ if (*de->d_name == '.') -+ continue; -+ -+ if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) { -+ mailbox->msgcount++; -+ if ((p = strstr (de->d_name, ":2,"))) { -+ if (!strchr (p + 3, 'T')) { -+ if (!strchr (p + 3, 'S')) -+ mailbox->msg_unread++; -+ if (strchr(p + 3, 'F')) -+ mailbox->msg_flagged++; -+ } -+ } -+ } -+ } -+ -+ closedir (dirp); -+} -+ - /* returns 1 if mailbox has new mail */ - static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb) - { -@@ -348,6 +410,20 @@ static int buffy_mbox_hasnew (BUFFY* mailbox, struct s - return rc; - } - -+/* update message counts for the sidebar */ -+void buffy_mbox_update (BUFFY* mailbox) -+{ -+ CONTEXT *ctx = NULL; -+ -+ ctx = mx_open_mailbox(mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL); -+ if(ctx) -+ { -+ mailbox->msgcount = ctx->msgcount; -+ mailbox->msg_unread = ctx->unread; -+ mx_close_mailbox(ctx, 0); -+ } -+} -+ - int mutt_buffy_check (int force) - { - BUFFY *tmp; -@@ -423,16 +499,19 @@ int mutt_buffy_check (int force) - { - case M_MBOX: - case M_MMDF: -+ buffy_mbox_update (tmp); - if (buffy_mbox_hasnew (tmp, &sb) > 0) - BuffyCount++; - break; - - case M_MAILDIR: -+ buffy_maildir_update (tmp); - if (buffy_maildir_hasnew (tmp) > 0) - BuffyCount++; - break; - - case M_MH: -+ mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged); - if ((tmp->new = mh_buffy (tmp->path)) > 0) - BuffyCount++; - break; -diff -uNp -r mutt-5302767aa6aa.orig/buffy.h mutt-5302767aa6aa/buffy.h ---- mutt-5302767aa6aa.orig/buffy.h Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/buffy.h Sat Sep 4 20:32:59 2010 -@@ -25,7 +25,11 @@ typedef struct buffy_t - char path[_POSIX_PATH_MAX]; - off_t size; - struct buffy_t *next; -+ struct buffy_t *prev; - short new; /* mailbox has new mail */ -+ int msgcount; /* total number of messages */ -+ int msg_unread; /* number of unread messages */ -+ int msg_flagged; /* number of flagged messages */ - short notified; /* user has been notified */ - short magic; /* mailbox type */ - short newly_created; /* mbox or mmdf just popped into existence */ -diff -uNp -r mutt-5302767aa6aa.orig/color.c mutt-5302767aa6aa/color.c ---- mutt-5302767aa6aa.orig/color.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/color.c Sat Sep 4 20:32:59 2010 -@@ -93,6 +93,8 @@ static struct mapping_t Fields[] = - { "bold", MT_COLOR_BOLD }, - { "underline", MT_COLOR_UNDERLINE }, - { "index", MT_COLOR_INDEX }, -+ { "sidebar_new", MT_COLOR_NEW }, -+ { "sidebar_flagged", MT_COLOR_FLAGGED }, - { NULL, 0 } - }; - -diff -uNp -r mutt-5302767aa6aa.orig/compose.c mutt-5302767aa6aa/compose.c ---- mutt-5302767aa6aa.orig/compose.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/compose.c Sat Sep 4 20:32:59 2010 -@@ -72,7 +72,7 @@ enum - - #define HDR_XOFFSET 14 - #define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */ --#define W (COLS - HDR_XOFFSET) -+#define W (COLS - HDR_XOFFSET - SidebarWidth) - - static char *Prompts[] = - { -@@ -112,7 +112,7 @@ static void redraw_crypt_lines (HEADER *msg) - { - int off = 0; - -- mvaddstr (HDR_CRYPT, 0, "Security: "); -+ mvaddstr (HDR_CRYPT, SidebarWidth, " Security: "); - - if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0) - { -@@ -144,7 +144,7 @@ static void redraw_crypt_lines (HEADER *msg) - } - - clrtoeol (); -- move (HDR_CRYPTINFO, 0); -+ move (HDR_CRYPTINFO, SidebarWidth); - clrtoeol (); - - if ((WithCrypto & APPLICATION_PGP) -@@ -161,7 +161,7 @@ static void redraw_crypt_lines (HEADER *msg) - && (msg->security & ENCRYPT) - && SmimeCryptAlg - && *SmimeCryptAlg) { -- mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "), -+ mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "), - NONULL(SmimeCryptAlg)); - off = 20; - } -@@ -175,7 +175,7 @@ static void redraw_mix_line (LIST *chain) - int c; - char *t; - -- mvaddstr (HDR_MIX, 0, " Mix: "); -+ mvaddstr (HDR_MIX, SidebarWidth, " Mix: "); - - if (!chain) - { -@@ -190,7 +190,7 @@ static void redraw_mix_line (LIST *chain) - if (t && t[0] == '0' && t[1] == '\0') - t = "<random>"; - -- if (c + mutt_strlen (t) + 2 >= COLS) -+ if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth) - break; - - addstr (NONULL(t)); -@@ -242,7 +242,7 @@ static void draw_envelope_addr (int line, ADDRESS *add - - buf[0] = 0; - rfc822_write_address (buf, sizeof (buf), addr, 1); -- mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]); -+ mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]); - mutt_paddstr (W, buf); - } - -@@ -252,10 +252,10 @@ static void draw_envelope (HEADER *msg, char *fcc) - } - } - #endif -- mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); -+ mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); - mutt_paddstr (W, NONULL (msg->env->subject)); - draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); -- mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]); -+ mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]); - mutt_paddstr (W, fcc); - - if (WithCrypto) -@@ -266,7 +266,7 @@ static void draw_envelope (HEADER *msg, char *fcc) - #endif - - SETCOLOR (MT_COLOR_STATUS); -- mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments")); -+ mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments")); - BKGDSET (MT_COLOR_STATUS); - clrtoeol (); - -@@ -304,7 +304,7 @@ static int edit_address_list (int line, ADDRESS **addr - /* redraw the expanded list so the user can see the result */ - buf[0] = 0; - rfc822_write_address (buf, sizeof (buf), *addr, 1); -- move (line, HDR_XOFFSET); -+ move (line, HDR_XOFFSET+SidebarWidth); - mutt_paddstr (W, buf); - - return 0; -@@ -549,7 +549,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for - if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) - { - mutt_str_replace (&msg->env->subject, buf); -- move (HDR_SUBJECT, HDR_XOFFSET); -+ move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth); - clrtoeol (); - if (msg->env->subject) - mutt_paddstr (W, msg->env->subject); -@@ -566,7 +566,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for - { - strfcpy (fcc, buf, fcclen); - mutt_pretty_mailbox (fcc, fcclen); -- move (HDR_FCC, HDR_XOFFSET); -+ move (HDR_FCC, HDR_XOFFSET + SidebarWidth); - mutt_paddstr (W, fcc); - fccSet = 1; - } -diff -uNp -r mutt-5302767aa6aa.orig/curs_main.c mutt-5302767aa6aa/curs_main.c ---- mutt-5302767aa6aa.orig/curs_main.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/curs_main.c Sat Sep 4 20:32:59 2010 -@@ -26,7 +26,9 @@ - #include "mailbox.h" - #include "mapping.h" - #include "sort.h" -+#include "buffy.h" - #include "mx.h" -+#include "sidebar.h" - - #ifdef USE_POP - #include "pop.h" -@@ -523,8 +525,12 @@ int mutt_index_menu (void) - menu->redraw |= REDRAW_STATUS; - if (do_buffy_notify) - { -- if (mutt_buffy_notify () && option (OPTBEEPNEW)) -- beep (); -+ if (mutt_buffy_notify ()) -+ { -+ menu->redraw |= REDRAW_FULL; -+ if (option (OPTBEEPNEW)) -+ beep (); -+ } - } - else - do_buffy_notify = 1; -@@ -536,6 +542,7 @@ int mutt_index_menu (void) - if (menu->redraw & REDRAW_FULL) - { - menu_redraw_full (menu); -+ draw_sidebar(menu->menu); - mutt_show_error (); - } - -@@ -558,10 +565,13 @@ int mutt_index_menu (void) - - if (menu->redraw & REDRAW_STATUS) - { -+ DrawFullLine = 1; - menu_status_line (buf, sizeof (buf), menu, NONULL (Status)); -+ DrawFullLine = 0; - CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2); - SETCOLOR (MT_COLOR_STATUS); - BKGDSET (MT_COLOR_STATUS); -+ set_buffystats(Context); - mutt_paddstr (COLS, buf); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); -@@ -575,7 +585,7 @@ int mutt_index_menu (void) - menu->oldcurrent = -1; - - if (option (OPTARROWCURSOR)) -- move (menu->current - menu->top + menu->offset, 2); -+ move (menu->current - menu->top + menu->offset, SidebarWidth + 2); - else if (option (OPTBRAILLEFRIENDLY)) - move (menu->current - menu->top + menu->offset, 0); - else -@@ -1077,6 +1087,7 @@ int mutt_index_menu (void) - menu->redraw = REDRAW_FULL; - break; - -+ case OP_SIDEBAR_OPEN: - case OP_MAIN_CHANGE_FOLDER: - case OP_MAIN_NEXT_UNREAD_MAILBOX: - -@@ -1108,7 +1119,11 @@ int mutt_index_menu (void) - { - mutt_buffy (buf, sizeof (buf)); - -- if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) -+ if ( op == OP_SIDEBAR_OPEN ) { -+ if(!CurBuffy) -+ break; -+ strncpy( buf, CurBuffy->path, sizeof(buf) ); -+ } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) - { - if (menu->menu == MENU_PAGER) - { -@@ -1126,6 +1141,7 @@ int mutt_index_menu (void) - } - - mutt_expand_path (buf, sizeof (buf)); -+ set_curbuffy(buf); - if (mx_get_magic (buf) <= 0) - { - mutt_error (_("%s is not a mailbox."), buf); -@@ -2216,6 +2232,12 @@ int mutt_index_menu (void) - mutt_what_key(); - break; - -+ case OP_SIDEBAR_SCROLL_UP: -+ case OP_SIDEBAR_SCROLL_DOWN: -+ case OP_SIDEBAR_NEXT: -+ case OP_SIDEBAR_PREV: -+ scroll_sidebar(op, menu->menu); -+ break; - default: - if (menu->menu == MENU_MAIN) - km_error_key (MENU_MAIN); -diff -uNp -r mutt-5302767aa6aa.orig/flags.c mutt-5302767aa6aa/flags.c ---- mutt-5302767aa6aa.orig/flags.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/flags.c Sat Sep 4 20:32:59 2010 -@@ -22,8 +22,10 @@ - - #include "mutt.h" - #include "mutt_curses.h" -+#include "mutt_menu.h" - #include "sort.h" - #include "mx.h" -+#include "sidebar.h" - - void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) - { -@@ -263,6 +265,7 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag - */ - if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged)) - h->searched = 0; -+ draw_sidebar(0); - } - - void mutt_tag_set_flag (int flag, int bf) -diff -uNp -r mutt-5302767aa6aa.orig/functions.h mutt-5302767aa6aa/functions.h ---- mutt-5302767aa6aa.orig/functions.h Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/functions.h Sat Sep 4 20:32:59 2010 -@@ -169,6 +169,11 @@ struct binding_t OpMain[] = { /* map: index */ - { "decrypt-save", OP_DECRYPT_SAVE, NULL }, - - -+ { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, -+ { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, -+ { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, -+ { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, -+ { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, - { NULL, 0, NULL } - }; - -@@ -272,6 +277,11 @@ struct binding_t OpPager[] = { /* map: pager */ - - { "what-key", OP_WHAT_KEY, NULL }, - -+ { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, -+ { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, -+ { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, -+ { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, -+ { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, - { NULL, 0, NULL } - }; - -diff -uNp -r mutt-5302767aa6aa.orig/globals.h mutt-5302767aa6aa/globals.h ---- mutt-5302767aa6aa.orig/globals.h Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/globals.h Sat Sep 4 20:32:59 2010 -@@ -117,6 +117,7 @@ WHERE short SearchContext; - WHERE char *SendCharset; - WHERE char *Sendmail; - WHERE char *Shell; -+WHERE char *SidebarDelim; - WHERE char *Signature; - WHERE char *SimpleSearch; - #if USE_SMTP -@@ -207,6 +208,9 @@ WHERE short ScoreThresholdDelete; - WHERE short ScoreThresholdRead; - WHERE short ScoreThresholdFlag; - -+WHERE struct buffy_t *CurBuffy INITVAL(0); -+WHERE short DrawFullLine INITVAL(0); -+WHERE short SidebarWidth; - #ifdef USE_IMAP - WHERE short ImapKeepalive; - WHERE short ImapPipelineDepth; -diff -uNp -r mutt-5302767aa6aa.orig/imap/command.c mutt-5302767aa6aa/imap/command.c ---- mutt-5302767aa6aa.orig/imap/command.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/imap/command.c Sat Sep 4 20:32:59 2010 -@@ -1006,6 +1006,13 @@ static void cmd_parse_status (IMAP_DATA* idata, char* - opened */ - status->uidnext = oldun; - -+ /* Added to make the sidebar show the correct numbers */ -+ if (status->messages) -+ { -+ inc->msgcount = status->messages; -+ inc->msg_unread = status->unseen; -+ } -+ - FREE (&value); - return; - } -diff -uNp -r mutt-5302767aa6aa.orig/imap/imap.c mutt-5302767aa6aa/imap/imap.c ---- mutt-5302767aa6aa.orig/imap/imap.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/imap/imap.c Sat Sep 4 20:32:59 2010 -@@ -1521,7 +1521,7 @@ int imap_buffy_check (int force) - - imap_munge_mbox_name (munged, sizeof (munged), name); - snprintf (command, sizeof (command), -- "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged); -+ "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged); - - if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0) - { -diff -uNp -r mutt-5302767aa6aa.orig/init.h mutt-5302767aa6aa/init.h ---- mutt-5302767aa6aa.orig/init.h Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/init.h Sat Sep 4 20:32:59 2010 -@@ -1942,6 +1942,27 @@ struct option_t MuttVars[] = { - ** not used. - ** (PGP only) - */ -+ {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"}, -+ /* -+ ** .pp -+ ** This specifies the delimiter between the sidebar (if visible) and -+ ** other screens. -+ */ -+ { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 }, -+ /* -+ ** .pp -+ ** This specifies whether or not to show sidebar (left-side list of folders). -+ */ -+ { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 }, -+ /* -+ ** .pp -+ ** The width of the sidebar. -+ */ -+ { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 }, -+ /* -+ ** .pp -+ ** Should the sidebar be sorted. -+ */ - { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0}, - /* - ** .pp -diff -uNp -r mutt-5302767aa6aa.orig/mailbox.h mutt-5302767aa6aa/mailbox.h ---- mutt-5302767aa6aa.orig/mailbox.h Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/mailbox.h Sat Sep 4 20:32:59 2010 -@@ -27,6 +27,7 @@ - #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses - * safe_fopen() for mbox-style folders. - */ -+#define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */ - - /* mx_open_new_message() */ - #define M_ADD_FROM 1 /* add a From_ line */ -diff -uNp -r mutt-5302767aa6aa.orig/mbox.c mutt-5302767aa6aa/mbox.c ---- mutt-5302767aa6aa.orig/mbox.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/mbox.c Sat Sep 4 20:32:59 2010 -@@ -100,6 +100,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx) - mutt_perror (ctx->path); - return (-1); - } -+ ctx->atime = sb.st_atime; - ctx->mtime = sb.st_mtime; - ctx->size = sb.st_size; - -@@ -251,6 +252,7 @@ int mbox_parse_mailbox (CONTEXT *ctx) - - ctx->size = sb.st_size; - ctx->mtime = sb.st_mtime; -+ ctx->atime = sb.st_atime; - - #ifdef NFS_ATTRIBUTE_HACK - if (sb.st_mtime > sb.st_atime) -diff -uNp -r mutt-5302767aa6aa.orig/menu.c mutt-5302767aa6aa/menu.c ---- mutt-5302767aa6aa.orig/menu.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/menu.c Sat Sep 4 20:32:59 2010 -@@ -24,6 +24,7 @@ - #include "mutt_curses.h" - #include "mutt_menu.h" - #include "mbyte.h" -+#include "sidebar.h" - - #include <string.h> - #include <stdlib.h> -@@ -156,7 +157,7 @@ static void menu_pad_string (char *s, size_t n) - { - char *scratch = safe_strdup (s); - int shift = option (OPTARROWCURSOR) ? 3 : 0; -- int cols = COLS - shift; -+ int cols = COLS - shift - SidebarWidth; - - mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1); - s[n - 1] = 0; -@@ -207,6 +208,7 @@ void menu_redraw_index (MUTTMENU *menu) - char buf[LONG_STRING]; - int i; - -+ draw_sidebar(1); - for (i = menu->top; i < menu->top + menu->pagelen; i++) - { - if (i < menu->max) -@@ -217,7 +219,7 @@ void menu_redraw_index (MUTTMENU *menu) - if (option (OPTARROWCURSOR)) - { - attrset (menu->color (i)); -- CLEARLINE (i - menu->top + menu->offset); -+ CLEARLINE_WIN (i - menu->top + menu->offset); - - if (i == menu->current) - { -@@ -246,14 +248,14 @@ void menu_redraw_index (MUTTMENU *menu) - BKGDSET (MT_COLOR_INDICATOR); - } - -- CLEARLINE (i - menu->top + menu->offset); -+ CLEARLINE_WIN (i - menu->top + menu->offset); - print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); - } - } - else -- CLEARLINE (i - menu->top + menu->offset); -+ CLEARLINE_WIN (i - menu->top + menu->offset); - } - menu->redraw = 0; - } -@@ -268,7 +270,7 @@ void menu_redraw_motion (MUTTMENU *menu) - return; - } - -- move (menu->oldcurrent + menu->offset - menu->top, 0); -+ move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); - -@@ -283,13 +285,13 @@ void menu_redraw_motion (MUTTMENU *menu) - clrtoeol (); - menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); - menu_pad_string (buf, sizeof (buf)); -- move (menu->oldcurrent + menu->offset - menu->top, 3); -+ move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3); - print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); - SETCOLOR (MT_COLOR_NORMAL); - } - - /* now draw it in the new location */ -- move (menu->current + menu->offset - menu->top, 0); -+ move (menu->current + menu->offset - menu->top, SidebarWidth); - attrset (menu->color (menu->current)); - ADDCOLOR (MT_COLOR_INDICATOR); - addstr ("->"); -@@ -310,7 +312,7 @@ void menu_redraw_motion (MUTTMENU *menu) - attrset (menu->color (menu->current)); - ADDCOLOR (MT_COLOR_INDICATOR); - BKGDSET (MT_COLOR_INDICATOR); -- CLEARLINE (menu->current - menu->top + menu->offset); -+ CLEARLINE_WIN (menu->current - menu->top + menu->offset); - print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); -@@ -322,7 +324,7 @@ void menu_redraw_current (MUTTMENU *menu) - { - char buf[LONG_STRING]; - -- move (menu->current + menu->offset - menu->top, 0); -+ move (menu->current + menu->offset - menu->top, SidebarWidth); - menu_make_entry (buf, sizeof (buf), menu, menu->current); - menu_pad_string (buf, sizeof (buf)); - -@@ -875,7 +877,7 @@ int mutt_menuLoop (MUTTMENU *menu) - - - if (option (OPTARROWCURSOR)) -- move (menu->current - menu->top + menu->offset, 2); -+ move (menu->current - menu->top + menu->offset, SidebarWidth + 2); - else if (option (OPTBRAILLEFRIENDLY)) - move (menu->current - menu->top + menu->offset, 0); - else -diff -uNp -r mutt-5302767aa6aa.orig/mh.c mutt-5302767aa6aa/mh.c ---- mutt-5302767aa6aa.orig/mh.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/mh.c Sat Sep 4 20:33:39 2010 -@@ -235,11 +235,35 @@ int mh_buffy (const char *path) - - if (mh_read_sequences (&mhs, path) < 0) - return 0; -+ - for (i = 0; !r && i <= mhs.max; i++) -- if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) -+ if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) { - r = 1; -+ } - mhs_free_sequences (&mhs); - return r; -+} -+ -+void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged) -+{ -+ int i; -+ struct mh_sequences mhs; -+ memset (&mhs, 0, sizeof (mhs)); -+ -+ if (mh_read_sequences (&mhs, path) < 0) -+ return; -+ -+ msgcount = 0; -+ msg_unread = 0; -+ msg_flagged = 0; -+ for (i = 0; i <= mhs.max; i++) -+ msgcount++; -+ if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) { -+ msg_unread++; -+ } -+ if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED) -+ msg_flagged++; -+ mhs_free_sequences (&mhs); - } - - static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt) -diff -uNp -r mutt-5302767aa6aa.orig/mutt.h mutt-5302767aa6aa/mutt.h ---- mutt-5302767aa6aa.orig/mutt.h Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/mutt.h Sat Sep 4 20:32:59 2010 -@@ -418,6 +418,8 @@ enum - OPTSAVEEMPTY, - OPTSAVENAME, - OPTSCORE, -+ OPTSIDEBAR, -+ OPTSIDEBARSORT, - OPTSIGDASHES, - OPTSIGONTOP, - OPTSORTRE, -@@ -858,6 +859,7 @@ typedef struct _context - { - char *path; - FILE *fp; -+ time_t atime; - time_t mtime; - off_t size; - off_t vsize; -@@ -892,6 +894,7 @@ typedef struct _context - unsigned int quiet : 1; /* inhibit status messages? */ - unsigned int collapsed : 1; /* are all threads collapsed? */ - unsigned int closing : 1; /* mailbox is being closed */ -+ unsigned int peekonly : 1; /* just taking a glance, revert atime */ - - /* driver hooks */ - void *data; /* driver specific data */ -diff -uNp -r mutt-5302767aa6aa.orig/mutt_curses.h mutt-5302767aa6aa/mutt_curses.h ---- mutt-5302767aa6aa.orig/mutt_curses.h Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/mutt_curses.h Sat Sep 4 20:32:59 2010 -@@ -64,6 +64,7 @@ - #undef lines - #endif /* lines */ - -+#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol() - #define CLEARLINE(x) move(x,0), clrtoeol() - #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x) - #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0) -@@ -126,6 +127,8 @@ enum - MT_COLOR_BOLD, - MT_COLOR_UNDERLINE, - MT_COLOR_INDEX, -+ MT_COLOR_NEW, -+ MT_COLOR_FLAGGED, - MT_COLOR_MAX - }; - -diff -uNp -r mutt-5302767aa6aa.orig/muttlib.c mutt-5302767aa6aa/muttlib.c ---- mutt-5302767aa6aa.orig/muttlib.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/muttlib.c Sat Sep 4 20:32:59 2010 -@@ -1286,6 +1286,8 @@ void mutt_FormatString (char *dest, /* output buffer - pl = pw = 1; - - /* see if there's room to add content, else ignore */ -+ if ( DrawFullLine ) -+ { - if ((col < COLS && wlen < destlen) || soft) - { - int pad; -@@ -1329,6 +1331,52 @@ void mutt_FormatString (char *dest, /* output buffer - col += wid; - src += pl; - } -+ } -+ else -+ { -+ if ((col < COLS-SidebarWidth && wlen < destlen) || soft) -+ { -+ int pad; -+ -+ /* get contents after padding */ -+ mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags); -+ len = mutt_strlen (buf); -+ wid = mutt_strwidth (buf); -+ -+ /* try to consume as many columns as we can, if we don't have -+ * memory for that, use as much memory as possible */ -+ pad = (COLS - SidebarWidth - col - wid) / pw; -+ if (pad > 0 && wlen + (pad * pl) + len > destlen) -+ pad = ((signed)(destlen - wlen - len)) / pl; -+ if (pad > 0) -+ { -+ while (pad--) -+ { -+ memcpy (wptr, src, pl); -+ wptr += pl; -+ wlen += pl; -+ col += pw; -+ } -+ } -+ else if (soft && pad < 0) -+ { -+ /* \0-terminate dest for length computation in mutt_wstr_trunc() */ -+ *wptr = 0; -+ /* make sure right part is at most as wide as display */ -+ len = mutt_wstr_trunc (buf, destlen, COLS, &wid); -+ /* truncate left so that right part fits completely in */ -+ wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col); -+ wptr = dest + wlen; -+ } -+ if (len + wlen > destlen) -+ len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL); -+ memcpy (wptr, buf, len); -+ wptr += len; -+ wlen += len; -+ col += wid; -+ src += pl; -+ } -+ } - break; /* skip rest of input */ - } - else if (ch == '|') -diff -uNp -r mutt-5302767aa6aa.orig/mx.c mutt-5302767aa6aa/mx.c ---- mutt-5302767aa6aa.orig/mx.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/mx.c Sat Sep 4 20:32:59 2010 -@@ -580,6 +580,7 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int f - * M_APPEND open mailbox for appending - * M_READONLY open mailbox in read-only mode - * M_QUIET only print error messages -+ * M_PEEK revert atime where applicable - * ctx if non-null, context struct to use - */ - CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx) -@@ -602,6 +603,8 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, - ctx->quiet = 1; - if (flags & M_READONLY) - ctx->readonly = 1; -+ if (flags & M_PEEK) -+ ctx->peekonly = 1; - - if (flags & (M_APPEND|M_NEWFOLDER)) - { -@@ -701,9 +704,21 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, - void mx_fastclose_mailbox (CONTEXT *ctx) - { - int i; -+#ifndef BUFFY_SIZE -+ struct utimbuf ut; -+#endif - - if(!ctx) - return; -+#ifndef BUFFY_SIZE -+ /* fix up the times so buffy won't get confused */ -+ if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime) -+ { -+ ut.actime = ctx->atime; -+ ut.modtime = ctx->mtime; -+ utime (ctx->path, &ut); -+ } -+#endif - - /* never announce that a mailbox we've just left has new mail. #3290 - * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */ -diff -uNp -r mutt-5302767aa6aa.orig/mx.h mutt-5302767aa6aa/mx.h ---- mutt-5302767aa6aa.orig/mx.h Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/mx.h Sat Sep 4 20:33:19 2010 -@@ -58,6 +58,7 @@ int mh_read_dir (CONTEXT *, const char *); - int mh_sync_mailbox (CONTEXT *, int *); - int mh_check_mailbox (CONTEXT *, int *); - int mh_buffy (const char *); -+void mh_buffy_update (const char *, int *, int *, int *); - int mh_check_empty (const char *); - - int maildir_read_dir (CONTEXT *); -diff -uNp -r mutt-5302767aa6aa.orig/pager.c mutt-5302767aa6aa/pager.c ---- mutt-5302767aa6aa.orig/pager.c Wed Aug 25 00:30:49 2010 -+++ mutt-5302767aa6aa/pager.c Sat Sep 4 20:32:59 2010 -@@ -29,6 +29,7 @@ - #include "pager.h" - #include "attach.h" - #include "mbyte.h" -+#include "sidebar.h" - - #include "mutt_crypt.h" - -@@ -1095,6 +1096,7 @@ static int format_line (struct line_t **lineInfo, int - wchar_t wc; - mbstate_t mbstate; - int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap); -+ wrap_cols -= SidebarWidth; - - if (check_attachment_marker ((char *)buf) == 0) - wrap_cols = COLS; -@@ -1745,7 +1747,7 @@ mutt_pager (const char *banner, const char *fname, int - if ((redraw & REDRAW_BODY) || topline != oldtopline) - { - do { -- move (bodyoffset, 0); -+ move (bodyoffset, SidebarWidth); - curline = oldtopline = topline; - lines = 0; - force_redraw = 0; -@@ -1758,6 +1760,7 @@ mutt_pager (const char *banner, const char *fname, int - &QuoteList, &q_level, &force_redraw, &SearchRE) > 0) - lines++; - curline++; -+ move(lines + bodyoffset, SidebarWidth); - } - last_offset = lineInfo[curline].offset; - } while (force_redraw); -@@ -1771,6 +1774,7 @@ mutt_pager (const char *banner, const char *fname, int - addch ('~'); - addch ('\n'); - lines++; -+ move(lines + bodyoffset, SidebarWidth); - } - /* We are going to update the pager status bar, so it isn't - * necessary to reset to normal color now. */ -@@ -1794,21 +1798,21 @@ mutt_pager (const char *banner, const char *fname, int - /* print out the pager status bar */ - SETCOLOR (MT_COLOR_STATUS); - BKGDSET (MT_COLOR_STATUS); -- CLEARLINE (statusoffset); -+ CLEARLINE_WIN (statusoffset); - - if (IsHeader (extra) || IsMsgAttach (extra)) - { -- size_t l1 = COLS * MB_LEN_MAX; -+ size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX; - size_t l2 = sizeof (buffer); - hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr; - mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT); -- mutt_paddstr (COLS, buffer); -+ mutt_paddstr (COLS-SidebarWidth, buffer); - } - else - { - char bn[STRING]; - snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str); -- mutt_paddstr (COLS, bn); -+ mutt_paddstr (COLS-SidebarWidth, bn); - } - BKGDSET (MT_COLOR_NORMAL); - SETCOLOR (MT_COLOR_NORMAL); -@@ -1819,18 +1823,23 @@ mutt_pager (const char *banner, const char *fname, int - /* redraw the pager_index indicator, because the - * flags for this message might have changed. */ - menu_redraw_current (index); -+ draw_sidebar(MENU_PAGER); - - /* print out the index status bar */ - menu_status_line (buffer, sizeof (buffer), index, NONULL(Status)); - -- move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0); -+ move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth); - SETCOLOR (MT_COLOR_STATUS); - BKGDSET (MT_COLOR_STATUS); -- mutt_paddstr (COLS, buffer); -+ mutt_paddstr (COLS-SidebarWidth, buffer); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); - } - -+ /* if we're not using the index, update every time */ -+ if ( index == 0 ) -+ draw_sidebar(MENU_PAGER); -+ - redraw = 0; - - if (option(OPTBRAILLEFRIENDLY)) { -@@ -2755,6 +2764,13 @@ search_next: - case OP_WHAT_KEY: - mutt_what_key (); - break; -+ -+ case OP_SIDEBAR_SCROLL_UP: -+ case OP_SIDEBAR_SCROLL_DOWN: -+ case OP_SIDEBAR_NEXT: -+ case OP_SIDEBAR_PREV: -+ scroll_sidebar(ch, MENU_PAGER); -+ break; - - default: - ch = -1; -diff -uNp -r mutt-5302767aa6aa.orig/sidebar.c mutt-5302767aa6aa/sidebar.c ---- mutt-5302767aa6aa.orig/sidebar.c Thu Jan 1 01:00:00 1970 -+++ mutt-5302767aa6aa/sidebar.c Sat Sep 4 20:32:59 2010 -@@ -0,0 +1,362 @@ -+/* -+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> -+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. -+ */ -+ -+ -+#if HAVE_CONFIG_H -+# include "config.h" -+#endif -+ -+#include "mutt.h" -+#include "mutt_menu.h" -+#include "mutt_curses.h" -+#include "sidebar.h" -+#include "buffy.h" -+#include <libgen.h> -+#include "keymap.h" -+#include <stdbool.h> -+ -+/*BUFFY *CurBuffy = 0;*/ -+static BUFFY *TopBuffy = 0; -+static BUFFY *BottomBuffy = 0; -+static int known_lines = 0; -+ -+static int quick_log10(int n) -+{ -+ char string[32]; -+ sprintf(string, "%d", n); -+ return strlen(string); -+} -+ -+void calc_boundaries (int menu) -+{ -+ BUFFY *tmp = Incoming; -+ -+ if ( known_lines != LINES ) { -+ TopBuffy = BottomBuffy = 0; -+ known_lines = LINES; -+ } -+ for ( ; tmp->next != 0; tmp = tmp->next ) -+ tmp->next->prev = tmp; -+ -+ if (option(OPTSIDEBARSORT)) { -+ int needsort=1; -+ BUFFY *prev; -+ BUFFY *next; -+ BUFFY *tmp2; -+ while (needsort==1) { -+ needsort=0; -+ tmp = Incoming; -+ for ( ; tmp ; tmp=tmp->next ) { -+ if (tmp->next != NULL && strcmp(tmp->path, tmp->next->path) > 0) { -+ needsort=1; -+ prev = tmp->prev; -+ next = tmp->next; -+ if (prev != NULL) -+ prev->next = next; -+ else -+ Incoming = next; -+ next->prev = prev; -+ tmp2 = next->next; -+ next->next = tmp; -+ tmp->prev = next; -+ tmp->next = tmp2; -+ if (tmp2 != NULL) -+ tmp2->prev = tmp; -+ } -+ } -+ } -+ } -+ -+ if ( TopBuffy == 0 && BottomBuffy == 0 ) -+ TopBuffy = Incoming; -+ if ( BottomBuffy == 0 ) { -+ int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); -+ BottomBuffy = TopBuffy; -+ while ( --count && BottomBuffy->next ) -+ BottomBuffy = BottomBuffy->next; -+ } -+ else if ( TopBuffy == CurBuffy->next ) { -+ int count = LINES - 2 - (menu != MENU_PAGER); -+ BottomBuffy = CurBuffy; -+ tmp = BottomBuffy; -+ while ( --count && tmp->prev) -+ tmp = tmp->prev; -+ TopBuffy = tmp; -+ } -+ else if ( BottomBuffy == CurBuffy->prev ) { -+ int count = LINES - 2 - (menu != MENU_PAGER); -+ TopBuffy = CurBuffy; -+ tmp = TopBuffy; -+ while ( --count && tmp->next ) -+ tmp = tmp->next; -+ BottomBuffy = tmp; -+ } -+} -+ -+char *make_sidebar_entry(char *box, int size, int new, int flagged) -+{ -+ static char *entry = 0; -+ char *c; -+ int i = 0; -+ int delim_len = strlen(SidebarDelim); -+ -+ c = realloc(entry, SidebarWidth - delim_len + 2); -+ if ( c ) entry = c; -+ entry[SidebarWidth - delim_len + 1] = 0; -+ for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' ); -+ i = strlen(box); -+ strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) ); -+ -+ if (size == -1) -+ sprintf(entry + SidebarWidth - delim_len - 3, "?"); -+ else if ( new ) { -+ if (flagged > 0) { -+ sprintf( -+ entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged), -+ "% d(%d)[%d]", size, new, flagged); -+ } else { -+ sprintf( -+ entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new), -+ "% d(%d)", size, new); -+ } -+ } else if (flagged > 0) { -+ sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged); -+ } else { -+ sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size); -+ } -+ return entry; -+} -+ -+void set_curbuffy(char buf[LONG_STRING]) -+{ -+ BUFFY* tmp = CurBuffy = Incoming; -+ -+ if (!Incoming) -+ return; -+ -+ while(1) { -+ if(!strcmp(tmp->path, buf)) { -+ CurBuffy = tmp; -+ break; -+ } -+ -+ if(tmp->next) -+ tmp = tmp->next; -+ else -+ break; -+ } -+} -+ -+int draw_sidebar(int menu) { -+ -+ int lines = option(OPTHELP) ? 1 : 0; -+ BUFFY *tmp; -+#ifndef USE_SLANG_CURSES -+ attr_t attrs; -+#endif -+ short delim_len = strlen(SidebarDelim); -+ short color_pair; -+ -+ static bool initialized = false; -+ static int prev_show_value; -+ static short saveSidebarWidth; -+ -+ /* initialize first time */ -+ if(!initialized) { -+ prev_show_value = option(OPTSIDEBAR); -+ saveSidebarWidth = SidebarWidth; -+ if(!option(OPTSIDEBAR)) SidebarWidth = 0; -+ initialized = true; -+ } -+ -+ /* save or restore the value SidebarWidth */ -+ if(prev_show_value != option(OPTSIDEBAR)) { -+ if(prev_show_value && !option(OPTSIDEBAR)) { -+ saveSidebarWidth = SidebarWidth; -+ SidebarWidth = 0; -+ } else if(!prev_show_value && option(OPTSIDEBAR)) { -+ SidebarWidth = saveSidebarWidth; -+ } -+ prev_show_value = option(OPTSIDEBAR); -+ } -+ -+ -+// if ( SidebarWidth == 0 ) return 0; -+ if (SidebarWidth > 0 && option (OPTSIDEBAR) -+ && delim_len >= SidebarWidth) { -+ unset_option (OPTSIDEBAR); -+ /* saveSidebarWidth = SidebarWidth; */ -+ if (saveSidebarWidth > delim_len) { -+ SidebarWidth = saveSidebarWidth; -+ mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar.")); -+ sleep (2); -+ } else { -+ SidebarWidth = 0; -+ mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value.")); -+ sleep (4); /* the advise to set a sane value should be seen long enough */ -+ } -+ saveSidebarWidth = 0; -+ return (0); -+ } -+ -+ if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) { -+ if (SidebarWidth > 0) { -+ saveSidebarWidth = SidebarWidth; -+ SidebarWidth = 0; -+ } -+ unset_option(OPTSIDEBAR); -+ return 0; -+ } -+ -+ /* get attributes for divider */ -+ SETCOLOR(MT_COLOR_STATUS); -+#ifndef USE_SLANG_CURSES -+ attr_get(&attrs, &color_pair, 0); -+#else -+ color_pair = attr_get(); -+#endif -+ SETCOLOR(MT_COLOR_NORMAL); -+ -+ /* draw the divider */ -+ -+ for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { -+ move(lines, SidebarWidth - delim_len); -+ addstr(NONULL(SidebarDelim)); -+#ifndef USE_SLANG_CURSES -+ mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL); -+#endif -+ } -+ -+ if ( Incoming == 0 ) return 0; -+ lines = option(OPTHELP) ? 1 : 0; /* go back to the top */ -+ -+ if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) -+ calc_boundaries(menu); -+ if ( CurBuffy == 0 ) CurBuffy = Incoming; -+ -+ tmp = TopBuffy; -+ -+ SETCOLOR(MT_COLOR_NORMAL); -+ -+ for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) { -+ if ( tmp == CurBuffy ) -+ SETCOLOR(MT_COLOR_INDICATOR); -+ else if ( tmp->msg_unread > 0 ) -+ SETCOLOR(MT_COLOR_NEW); -+ else if ( tmp->msg_flagged > 0 ) -+ SETCOLOR(MT_COLOR_FLAGGED); -+ else -+ SETCOLOR(MT_COLOR_NORMAL); -+ -+ move( lines, 0 ); -+ if ( Context && !strcmp( tmp->path, Context->path ) ) { -+ tmp->msg_unread = Context->unread; -+ tmp->msgcount = Context->msgcount; -+ tmp->msg_flagged = Context->flagged; -+ } -+ // check whether Maildir is a prefix of the current folder's path -+ short maildir_is_prefix = 0; -+ if ( (strlen(tmp->path) > strlen(Maildir)) && -+ (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) ) -+ maildir_is_prefix = 1; -+ // calculate depth of current folder and generate its display name with indented spaces -+ int sidebar_folder_depth = 0; -+ char *sidebar_folder_name; -+ sidebar_folder_name = basename(tmp->path); -+ if ( maildir_is_prefix ) { -+ char *tmp_folder_name; -+ int i; -+ tmp_folder_name = tmp->path + strlen(Maildir); -+ for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) { -+ if (tmp_folder_name[i] == '/') sidebar_folder_depth++; -+ } -+ if (sidebar_folder_depth > 0) { -+ sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1); -+ for (i=0; i < sidebar_folder_depth; i++) -+ sidebar_folder_name[i]=' '; -+ sidebar_folder_name[i]=0; -+ strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth); -+ } -+ } -+ printw( "%.*s", SidebarWidth - delim_len + 1, -+ make_sidebar_entry(sidebar_folder_name, tmp->msgcount, -+ tmp->msg_unread, tmp->msg_flagged)); -+ if (sidebar_folder_depth > 0) -+ free(sidebar_folder_name); -+ lines++; -+ } -+ SETCOLOR(MT_COLOR_NORMAL); -+ for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { -+ int i = 0; -+ move( lines, 0 ); -+ for ( ; i < SidebarWidth - delim_len; i++ ) -+ addch(' '); -+ } -+ return 0; -+} -+ -+ -+void set_buffystats(CONTEXT* Context) -+{ -+ BUFFY *tmp = Incoming; -+ while(tmp) { -+ if(Context && !strcmp(tmp->path, Context->path)) { -+ tmp->msg_unread = Context->unread; -+ tmp->msgcount = Context->msgcount; -+ break; -+ } -+ tmp = tmp->next; -+ } -+} -+ -+void scroll_sidebar(int op, int menu) -+{ -+ if(!SidebarWidth) return; -+ if(!CurBuffy) return; -+ -+ switch (op) { -+ case OP_SIDEBAR_NEXT: -+ if ( CurBuffy->next == NULL ) return; -+ CurBuffy = CurBuffy->next; -+ break; -+ case OP_SIDEBAR_PREV: -+ if ( CurBuffy->prev == NULL ) return; -+ CurBuffy = CurBuffy->prev; -+ break; -+ case OP_SIDEBAR_SCROLL_UP: -+ CurBuffy = TopBuffy; -+ if ( CurBuffy != Incoming ) { -+ calc_boundaries(menu); -+ CurBuffy = CurBuffy->prev; -+ } -+ break; -+ case OP_SIDEBAR_SCROLL_DOWN: -+ CurBuffy = BottomBuffy; -+ if ( CurBuffy->next ) { -+ calc_boundaries(menu); -+ CurBuffy = CurBuffy->next; -+ } -+ break; -+ default: -+ return; -+ } -+ calc_boundaries(menu); -+ draw_sidebar(menu); -+} -+ -diff -uNp -r mutt-5302767aa6aa.orig/sidebar.h mutt-5302767aa6aa/sidebar.h ---- mutt-5302767aa6aa.orig/sidebar.h Thu Jan 1 01:00:00 1970 -+++ mutt-5302767aa6aa/sidebar.h Sat Sep 4 20:32:59 2010 -@@ -0,0 +1,36 @@ -+/* -+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> -+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. -+ */ -+ -+#ifndef SIDEBAR_H -+#define SIDEBAR_H -+ -+struct MBOX_LIST { -+ char *path; -+ int msgcount; -+ int new; -+} MBLIST; -+ -+/* parameter is whether or not to go to the status line */ -+/* used for omitting the last | that covers up the status bar in the index */ -+int draw_sidebar(int); -+void scroll_sidebar(int, int); -+void set_curbuffy(char*); -+void set_buffystats(CONTEXT*); -+ -+#endif /* SIDEBAR_H */ Index: SOURCES/mutt-1.5.21-CVE-2014-9116.patch =================================================================== --- SOURCES/mutt-1.5.21-CVE-2014-9116.patch (revision 800495) +++ SOURCES/mutt-1.5.21-CVE-2014-9116.patch (working copy) @@ -1,38 +0,0 @@ -This patches solves the issue raised by CVE-2014-9116 in bug 771125. -The sendlib patch is incorporated from upstream commit: -http://dev.mutt.org/trac/changeset/897dcc62e4aa - -The lib.c part was written by Antonio Radici <antonio@debian.org> to prevent -crashes due to this kind of bugs from happening again. - -Index: mutt/sendlib.c -=================================================================== ---- mutt.orig/sendlib.c -+++ mutt/sendlib.c -@@ -1814,7 +1814,11 @@ static int write_one_header (FILE *fp, i - { - tagbuf = mutt_substrdup (start, t); - ++t; /* skip over the colon separating the header field name and value */ -- SKIPWS(t); /* skip over any leading whitespace */ -+ -+ /* skip over any leading whitespace (WSP, as defined in RFC5322) */ -+ while (*t == ' ' || *t == '\t') -+ t++; -+ - valbuf = mutt_substrdup (t, end); - } - dprint(4,(debugfile,"mwoh: buf[%s%s] too long, " -Index: mutt/lib.c -=================================================================== ---- mutt.orig/lib.c -+++ mutt/lib.c -@@ -814,6 +814,9 @@ char *mutt_substrdup (const char *begin, - size_t len; - char *p; - -+ if (end != NULL && end < begin) -+ return NULL; -+ - if (end) - len = end - begin; - else Index: SOURCES/mutt-1.5.21-automake-1.13.patch =================================================================== --- SOURCES/mutt-1.5.21-automake-1.13.patch (revision 800495) +++ SOURCES/mutt-1.5.21-automake-1.13.patch (working copy) @@ -1,11 +0,0 @@ ---- mutt-1.5.21/configure.ac.orig 2013-01-12 21:34:28.546475394 -0500 -+++ mutt-1.5.21/configure.ac 2013-01-12 21:34:50.186931927 -0500 -@@ -5,7 +5,7 @@ - - AC_PREREQ([2.54]) - AC_INIT([mutt.h]) --AM_CONFIG_HEADER([config.h]) -+AC_CONFIG_HEADERS([config.h]) - - mutt_cv_version=`cat $srcdir/VERSION` - AM_INIT_AUTOMAKE(mutt, $mutt_cv_version) Index: SOURCES/mutt-1.5.21-db5.patch =================================================================== --- SOURCES/mutt-1.5.21-db5.patch (revision 800495) +++ SOURCES/mutt-1.5.21-db5.patch (working copy) @@ -1,19 +0,0 @@ ---- configure.ac.db 2012-07-27 02:31:55.000000000 +0000 -+++ configure.ac 2012-07-27 02:38:50.000000000 +0000 -@@ -27,7 +27,6 @@ - - AC_PROG_CC - AC_ISC_POSIX --AM_C_PROTOTYPES - if test "x$U" != "x"; then - AC_MSG_ERROR(Compiler not ANSI compliant) - fi -@@ -997,7 +996,7 @@ - bdbpfx="$bdbpfx $d/$v" - done - done -- BDB_VERSIONS="db-4 db4 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''" -+ BDB_VERSIONS="db-5.3 db-5.2 db-5.1 db-5 db-4 db4 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''" - AC_MSG_CHECKING([for BerkeleyDB > 4.0]) - for d in $bdbpfx; do - BDB_INCLUDE_DIR="" Index: SOURCES/mutt-1.5.21-testcert.patch =================================================================== --- SOURCES/mutt-1.5.21-testcert.patch (revision 800495) +++ SOURCES/mutt-1.5.21-testcert.patch (working copy) @@ -1,30 +0,0 @@ -diff -up mutt-1.5.21/mutt_ssl_gnutls.c.old mutt-1.5.21/mutt_ssl_gnutls.c ---- mutt-1.5.21/mutt_ssl_gnutls.c.old 2011-03-23 11:46:28.760386765 +0100 -+++ mutt-1.5.21/mutt_ssl_gnutls.c 2011-03-23 14:34:45.839456449 +0100 -@@ -978,6 +978,7 @@ static int tls_check_certificate (CONNEC - unsigned int cert_list_size = 0; - gnutls_certificate_status certstat; - int certerr, i, preauthrc, savedcert, rc = 0; -+ int rcpeer; - - if (gnutls_auth_get_type (state) != GNUTLS_CRD_CERTIFICATE) - { -@@ -1003,6 +1004,9 @@ static int tls_check_certificate (CONNEC - for (i = 0; i < cert_list_size; i++) { - rc = tls_check_preauth(&cert_list[i], certstat, conn->account.host, i, - &certerr, &savedcert); -+ if (i == 0) -+ rcpeer = rc; -+ - preauthrc += rc; - - if (savedcert) -@@ -1028,7 +1032,7 @@ static int tls_check_certificate (CONNEC - dprint (1, (debugfile, "error trusting certificate %d: %d\n", i, rc)); - - certstat = tls_verify_peers (state); -- if (!certstat) -+ if (!certstat && !rcpeer) - return 1; - } - } Index: SOURCES/mutt-1.5.21.tar.gz.asc =================================================================== --- SOURCES/mutt-1.5.21.tar.gz.asc (revision 800495) +++ SOURCES/mutt-1.5.21.tar.gz.asc (working copy) @@ -1,7 +0,0 @@ ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.10 (GNU/Linux) - -iEYEABECAAYFAkyQ/hIACgkQIigsijWFMDKTLwCfVrohdfnRsVYuOYMsVrSTbb/l -jzMAn1bdfKuilPChKJ/xDj6mry/wekXB -=iX+Z ------END PGP SIGNATURE----- Index: SOURCES/mutt-1.5.23-compressed-mbox.patch =================================================================== --- SOURCES/mutt-1.5.23-compressed-mbox.patch (revision 0) +++ SOURCES/mutt-1.5.23-compressed-mbox.patch (working copy) @@ -0,0 +1,1303 @@ +diff -uNr mutt-1.5.23/compress.c mutt-1.5.23.compress/compress.c +--- mutt-1.5.23/compress.c 1970-01-01 02:00:00.000000000 +0200 ++++ mutt-1.5.23.compress/compress.c 2014-12-03 01:33:43.319607137 +0200 +@@ -0,0 +1,490 @@ ++/* ++ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com> ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++ */ ++ ++#if HAVE_CONFIG_H ++# include "config.h" ++#endif ++ ++#include "mutt.h" ++ ++#ifdef USE_COMPRESSED ++ ++#include "mx.h" ++#include "mailbox.h" ++#include "mutt_curses.h" ++ ++#include <errno.h> ++#include <string.h> ++#include <unistd.h> ++#include <sys/stat.h> ++ ++typedef struct ++{ ++ const char *close; /* close-hook command */ ++ const char *open; /* open-hook command */ ++ const char *append; /* append-hook command */ ++ off_t size; /* size of real folder */ ++} COMPRESS_INFO; ++ ++char echo_cmd[HUGE_STRING]; ++ ++/* parameters: ++ * ctx - context to lock ++ * excl - exclusive lock? ++ * retry - should retry if unable to lock? ++ */ ++int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry) ++{ ++ int r; ++ ++ if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0) ++ ctx->locked = 1; ++ else if (retry && !excl) ++ { ++ ctx->readonly = 1; ++ return 0; ++ } ++ ++ return (r); ++} ++ ++void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp) ++{ ++ if (ctx->locked) ++ { ++ fflush (fp); ++ ++ mx_unlock_file (ctx->realpath, fileno (fp), 1); ++ ctx->locked = 0; ++ } ++} ++ ++static int is_new (const char *path) ++{ ++ return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0; ++} ++ ++static const char* find_compress_hook (int type, const char *path) ++{ ++ const char* c = mutt_find_hook (type, path); ++ return (!c || !*c) ? NULL : c; ++} ++ ++int mutt_can_read_compressed (const char *path) ++{ ++ return find_compress_hook (M_OPENHOOK, path) ? 1 : 0; ++} ++ ++/* if the file is new, we really do not append, but create, and so use ++ * close-hook, and not append-hook ++ */ ++static const char* get_append_command (const char *path, const CONTEXT* ctx) ++{ ++ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; ++ return (is_new (path)) ? ci->close : ci->append; ++} ++ ++int mutt_can_append_compressed (const char *path) ++{ ++ int magic; ++ ++ if (is_new (path)) ++ return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0); ++ ++ magic = mx_get_magic (path); ++ ++ if (magic != 0 && magic != M_COMPRESSED) ++ return 0; ++ ++ return (find_compress_hook (M_APPENDHOOK, path) ++ || (find_compress_hook (M_OPENHOOK, path) ++ && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0; ++} ++ ++/* open a compressed mailbox */ ++static COMPRESS_INFO *set_compress_info (CONTEXT *ctx) ++{ ++ COMPRESS_INFO *ci; ++ ++ /* Now lets uncompress this thing */ ++ ci = safe_malloc (sizeof (COMPRESS_INFO)); ++ ctx->compressinfo = (void*) ci; ++ ci->append = find_compress_hook (M_APPENDHOOK, ctx->path); ++ ci->open = find_compress_hook (M_OPENHOOK, ctx->path); ++ ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path); ++ return ci; ++} ++ ++static void set_path (CONTEXT* ctx) ++{ ++ char tmppath[_POSIX_PATH_MAX]; ++ ++ /* Setup the right paths */ ++ ctx->realpath = ctx->path; ++ ++ /* Uncompress to /tmp */ ++ mutt_mktemp (tmppath, sizeof(tmppath)); ++ ctx->path = safe_malloc (strlen (tmppath) + 1); ++ strcpy (ctx->path, tmppath); ++} ++ ++static int get_size (const char* path) ++{ ++ struct stat sb; ++ if (stat (path, &sb) != 0) ++ return 0; ++ return (sb.st_size); ++} ++ ++static void store_size (CONTEXT* ctx) ++{ ++ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; ++ ci->size = get_size (ctx->realpath); ++} ++ ++static const char * ++compresshook_format_str (char *dest, size_t destlen, size_t col, char op, ++ const char *src, const char *fmt, const char *ifstring, ++ const char *elsestring, unsigned long data, ++ format_flag flags) ++{ ++ char tmp[SHORT_STRING]; ++ ++ CONTEXT *ctx = (CONTEXT *) data; ++ switch (op) ++ { ++ case 'f': ++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); ++ snprintf (dest, destlen, tmp, ctx->realpath); ++ break; ++ case 't': ++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); ++ snprintf (dest, destlen, tmp, ctx->path); ++ break; ++ } ++ return (src); ++} ++ ++/* check that the command has both %f and %t ++ * 0 means OK, -1 means error ++ */ ++int mutt_test_compress_command (const char* cmd) ++{ ++ return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1; ++} ++ ++static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx) ++{ ++ char expanded[_POSIX_PATH_MAX]; ++ mutt_FormatString (expanded, sizeof (expanded), 0, cmd, compresshook_format_str, ++ (unsigned long) ctx, 0); ++ return safe_strdup (expanded); ++} ++ ++int mutt_check_mailbox_compressed (CONTEXT* ctx) ++{ ++ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; ++ if (ci->size != get_size (ctx->realpath)) ++ { ++ FREE (&ctx->compressinfo); ++ FREE (&ctx->realpath); ++ mutt_error _("Mailbox was corrupted!"); ++ return (-1); ++ } ++ return (0); ++} ++ ++int mutt_open_read_compressed (CONTEXT *ctx) ++{ ++ char *cmd; ++ FILE *fp; ++ int rc; ++ ++ COMPRESS_INFO *ci = set_compress_info (ctx); ++ if (!ci->open) { ++ ctx->magic = 0; ++ FREE (ctx->compressinfo); ++ return (-1); ++ } ++ if (!ci->close || access (ctx->path, W_OK) != 0) ++ ctx->readonly = 1; ++ ++ set_path (ctx); ++ store_size (ctx); ++ ++ if (!ctx->quiet) ++ mutt_message (_("Decompressing %s..."), ctx->realpath); ++ ++ cmd = get_compression_cmd (ci->open, ctx); ++ if (cmd == NULL) ++ return (-1); ++ dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd)); ++ ++ if ((fp = fopen (ctx->realpath, "r")) == NULL) ++ { ++ mutt_perror (ctx->realpath); ++ FREE (&cmd); ++ return (-1); ++ } ++ mutt_block_signals (); ++ if (mbox_lock_compressed (ctx, fp, 0, 1) == -1) ++ { ++ fclose (fp); ++ mutt_unblock_signals (); ++ mutt_error _("Unable to lock mailbox!"); ++ FREE (&cmd); ++ return (-1); ++ } ++ ++ endwin (); ++ fflush (stdout); ++ sprintf(echo_cmd,_("echo Decompressing %s..."),ctx->realpath); ++ mutt_system(echo_cmd); ++ rc = mutt_system (cmd); ++ mbox_unlock_compressed (ctx, fp); ++ mutt_unblock_signals (); ++ fclose (fp); ++ ++ if (rc) ++ { ++ mutt_any_key_to_continue (NULL); ++ ctx->magic = 0; ++ FREE (ctx->compressinfo); ++ mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd); ++ } ++ FREE (&cmd); ++ if (rc) ++ return (-1); ++ ++ if (mutt_check_mailbox_compressed (ctx)) ++ return (-1); ++ ++ ctx->magic = mx_get_magic (ctx->path); ++ ++ return (0); ++} ++ ++void restore_path (CONTEXT* ctx) ++{ ++ FREE (&ctx->path); ++ ctx->path = ctx->realpath; ++} ++ ++/* remove the temporary mailbox */ ++void remove_file (CONTEXT* ctx) ++{ ++ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF) ++ remove (ctx->path); ++} ++ ++int mutt_open_append_compressed (CONTEXT *ctx) ++{ ++ FILE *fh; ++ COMPRESS_INFO *ci = set_compress_info (ctx); ++ ++ if (!get_append_command (ctx->path, ctx)) ++ { ++ if (ci->open && ci->close) ++ return (mutt_open_read_compressed (ctx)); ++ ++ ctx->magic = 0; ++ FREE (&ctx->compressinfo); ++ return (-1); ++ } ++ ++ set_path (ctx); ++ ++ ctx->magic = DefaultMagic; ++ ++ if (!is_new (ctx->realpath)) ++ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF) ++ if ((fh = fopen (ctx->path, "w"))) ++ fclose (fh); ++ /* No error checking - the parent function will catch it */ ++ ++ return (0); ++} ++ ++/* close a compressed mailbox */ ++void mutt_fast_close_compressed (CONTEXT *ctx) ++{ ++ dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n", ++ ctx->path)); ++ ++ if (ctx->compressinfo) ++ { ++ if (ctx->fp) ++ fclose (ctx->fp); ++ ctx->fp = NULL; ++ /* if the folder was removed, remove the gzipped folder too */ ++ if (access (ctx->path, F_OK) != 0 && ! option (OPTSAVEEMPTY)) ++ remove (ctx->realpath); ++ else ++ remove_file (ctx); ++ ++ restore_path (ctx); ++ FREE (&ctx->compressinfo); ++ } ++} ++ ++/* return 0 on success, -1 on failure */ ++int mutt_sync_compressed (CONTEXT* ctx) ++{ ++ char *cmd; ++ int rc = 0; ++ FILE *fp; ++ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; ++ ++ if (!ctx->quiet) ++ mutt_message (_("Compressing %s..."), ctx->realpath); ++ ++ cmd = get_compression_cmd (ci->close, ctx); ++ if (cmd == NULL) ++ return (-1); ++ ++ if ((fp = fopen (ctx->realpath, "a")) == NULL) ++ { ++ mutt_perror (ctx->realpath); ++ FREE (&cmd); ++ return (-1); ++ } ++ mutt_block_signals (); ++ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) ++ { ++ fclose (fp); ++ mutt_unblock_signals (); ++ mutt_error _("Unable to lock mailbox!"); ++ ++ store_size (ctx); ++ ++ FREE (&cmd); ++ return (-1); ++ } ++ ++ dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd)); ++ ++ endwin (); ++ fflush (stdout); ++ sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath); ++ mutt_system(echo_cmd); ++ if (mutt_system (cmd)) ++ { ++ mutt_any_key_to_continue (NULL); ++ mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path); ++ rc = -1; ++ } ++ ++ mbox_unlock_compressed (ctx, fp); ++ mutt_unblock_signals (); ++ fclose (fp); ++ ++ FREE (&cmd); ++ ++ store_size (ctx); ++ ++ return (rc); ++} ++ ++int mutt_slow_close_compressed (CONTEXT *ctx) ++{ ++ FILE *fp; ++ const char *append; ++ char *cmd; ++ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; ++ ++ dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n", ++ ctx->path)); ++ ++ if (! (ctx->append ++ && ((append = get_append_command (ctx->realpath, ctx)) ++ || (append = ci->close)))) ++ { /* if we can not or should not append, ++ * we only have to remove the compressed info, because sync was already ++ * called ++ */ ++ mutt_fast_close_compressed (ctx); ++ return (0); ++ } ++ ++ if (ctx->fp) ++ fclose (ctx->fp); ++ ctx->fp = NULL; ++ ++ if (!ctx->quiet) ++ { ++ if (append == ci->close) ++ mutt_message (_("Compressing %s..."), ctx->realpath); ++ else ++ mutt_message (_("Compressed-appending to %s..."), ctx->realpath); ++ } ++ ++ cmd = get_compression_cmd (append, ctx); ++ if (cmd == NULL) ++ return (-1); ++ ++ if ((fp = fopen (ctx->realpath, "a")) == NULL) ++ { ++ mutt_perror (ctx->realpath); ++ FREE (&cmd); ++ return (-1); ++ } ++ mutt_block_signals (); ++ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) ++ { ++ fclose (fp); ++ mutt_unblock_signals (); ++ mutt_error _("Unable to lock mailbox!"); ++ FREE (&cmd); ++ return (-1); ++ } ++ ++ dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd)); ++ ++ endwin (); ++ fflush (stdout); ++ ++ if (append == ci->close) ++ sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath); ++ else ++ sprintf(echo_cmd,_("echo Compressed-appending to %s..."), ctx->realpath); ++ mutt_system(echo_cmd); ++ ++ if (mutt_system (cmd)) ++ { ++ mutt_any_key_to_continue (NULL); ++ mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"), ++ ctx->path); ++ FREE (&cmd); ++ mbox_unlock_compressed (ctx, fp); ++ mutt_unblock_signals (); ++ fclose (fp); ++ return (-1); ++ } ++ ++ mbox_unlock_compressed (ctx, fp); ++ mutt_unblock_signals (); ++ fclose (fp); ++ remove_file (ctx); ++ restore_path (ctx); ++ FREE (&cmd); ++ FREE (&ctx->compressinfo); ++ ++ return (0); ++} ++ ++#endif /* USE_COMPRESSED */ +diff -uNr mutt-1.5.23/compress.h mutt-1.5.23.compress/compress.h +--- mutt-1.5.23/compress.h 1970-01-01 02:00:00.000000000 +0200 ++++ mutt-1.5.23.compress/compress.h 2014-12-03 01:33:43.319607137 +0200 +@@ -0,0 +1,27 @@ ++/* ++ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com> ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++ */ ++ ++int mutt_can_read_compressed (const char *); ++int mutt_can_append_compressed (const char *); ++int mutt_open_read_compressed (CONTEXT *); ++int mutt_open_append_compressed (CONTEXT *); ++int mutt_slow_close_compressed (CONTEXT *); ++int mutt_sync_compressed (CONTEXT *); ++int mutt_test_compress_command (const char *); ++int mutt_check_mailbox_compressed (CONTEXT *); ++void mutt_fast_close_compressed (CONTEXT *); +diff -uNr mutt-1.5.23/config.h.in mutt-1.5.23.compress/config.h.in +--- mutt-1.5.23/config.h.in 2014-03-12 18:27:54.000000000 +0200 ++++ mutt-1.5.23.compress/config.h.in 2014-12-03 01:33:43.319607137 +0200 +@@ -552,6 +552,9 @@ + + /* Define to enable Sun mailtool attachments support. */ + #undef SUN_ATTACHMENT ++ ++/* The compressed mailboxes support */ ++#undef USE_COMPRESSED + + /* Define to use dotlocking for mailboxes. */ + #undef USE_DOTLOCK +diff -uNr mutt-1.5.23/configure mutt-1.5.23.compress/configure +--- mutt-1.5.23/configure 2014-03-12 18:26:45.000000000 +0200 ++++ mutt-1.5.23.compress/configure 2014-12-03 01:33:43.320607147 +0200 +@@ -1471,6 +1471,7 @@ + --disable-warnings Turn off compiler warnings (not recommended) + --enable-nfs-fix Work around an NFS with broken attributes caching + --enable-mailtool Enable Sun mailtool attachments support ++ --enable-compressed Enable compressed folders support + --enable-locales-fix The result of isprint() is unreliable + --enable-exact-address Enable regeneration of email addresses + --enable-hcache Enable header caching +@@ -8776,6 +8777,18 @@ + fi + fi + ++ ++# Check whether --enable-compressed or --disable-compressed was given. ++if test "${enable_compressed+set}" = set; then ++ enableval="$enable_compressed" ++ if test x$enableval = xyes; then ++ cat >> confdefs.h <<\EOF ++#define USE_COMPRESSED 1 ++EOF ++ ++ fi ++fi ++ + if test $mutt_cv_regex = yes; then + + $as_echo "#define USE_GNU_REGEX 1" >>confdefs.h +diff -uNr mutt-1.5.23/configure.ac mutt-1.5.23.compress/configure.ac +--- mutt-1.5.23/configure.ac 2014-03-12 18:26:40.000000000 +0200 ++++ mutt-1.5.23.compress/configure.ac 2014-12-03 01:33:43.320607147 +0200 +@@ -806,6 +806,11 @@ + [if test x$enableval = xyes; then + AC_DEFINE(SUN_ATTACHMENT,1,[ Define to enable Sun mailtool attachments support. ]) + fi]) ++AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]), ++ [if test x$enableval = xyes; then ++ AC_DEFINE(USE_COMPRESSED,1,[ Define to enable compressed folders support. ]) ++ fi]) ++ + + AC_ARG_ENABLE(locales-fix, AS_HELP_STRING([--enable-locales-fix],[The result of isprint() is unreliable]), + [if test x$enableval = xyes; then +diff -uNr mutt-1.5.23/curs_main.c mutt-1.5.23.compress/curs_main.c +--- mutt-1.5.23/curs_main.c 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23.compress/curs_main.c 2014-12-03 01:33:43.321607156 +0200 +@@ -1134,6 +1134,11 @@ + { + int check; + ++#ifdef USE_COMPRESSED ++ if (Context->compressinfo && Context->realpath) ++ mutt_str_replace (&LastFolder, Context->realpath); ++ else ++#endif + mutt_str_replace (&LastFolder, Context->path); + oldcount = Context ? Context->msgcount : 0; + +diff -uNr mutt-1.5.23/doc/Makefile.am mutt-1.5.23.compress/doc/Makefile.am +--- mutt-1.5.23/doc/Makefile.am 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23.compress/doc/Makefile.am 2014-12-03 01:33:43.321607156 +0200 +@@ -34,7 +34,8 @@ + + CHUNKED_DOCFILES = index.html intro.html gettingstarted.html \ + configuration.html mimesupport.html advancedusage.html \ +- optionalfeatures.html security.html tuning.html reference.html miscellany.html ++ optionalfeatures.html security.html tuning.html reference.html miscellany.html \ ++ compressed-folders.html + + HTML_DOCFILES = manual.html $(CHUNKED_DOCFILES) + +diff -uNr mutt-1.5.23/doc/Makefile.in mutt-1.5.23.compress/doc/Makefile.in +--- mutt-1.5.23/doc/Makefile.in 2014-03-12 18:26:44.000000000 +0200 ++++ mutt-1.5.23.compress/doc/Makefile.in 2014-12-03 01:33:43.321607156 +0200 +@@ -326,7 +326,8 @@ + + CHUNKED_DOCFILES = index.html intro.html gettingstarted.html \ + configuration.html mimesupport.html advancedusage.html \ +- optionalfeatures.html security.html tuning.html reference.html miscellany.html ++ optionalfeatures.html security.html tuning.html reference.html miscellany.html \ ++ compressed-folders.html + + HTML_DOCFILES = manual.html $(CHUNKED_DOCFILES) + BUILT_DISTFILES = stamp-doc-xml stamp-doc-chunked manual.txt $(HTML_DOCFILES) +diff -uNr mutt-1.5.23/doc/manual.xml.head mutt-1.5.23.compress/doc/manual.xml.head +--- mutt-1.5.23/doc/manual.xml.head 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23.compress/doc/manual.xml.head 2014-12-03 01:33:43.322607166 +0200 +@@ -5168,6 +5168,24 @@ + () — logical grouping operator + </para> + </listitem> ++<listitem> ++ ++<para> ++<link linkend="open-hook">open-hook</link> ++</para> ++</listitem> ++<listitem> ++ ++<para> ++<link linkend="close-hook">close-hook</link> ++</para> ++</listitem> ++<listitem> ++ ++<para> ++<link linkend="append-hook">append-hook</link> ++</para> ++</listitem> + + </itemizedlist> + +@@ -6099,6 +6117,254 @@ + + </chapter> + ++<chapter id="compressed-folders"> ++<title>Compressed folders Support (OPTIONAL)</title> ++ ++<para> ++If Mutt was compiled with compressed folders support (by running the ++<emphasis>configure</emphasis> script with the ++<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders ++stored in an arbitrary format, provided that the user has a script to ++convert from/to this format to one of the accepted. ++</para> ++ ++<para> ++The most common use is to open compressed archived folders e.g. with ++gzip. ++</para> ++ ++<para> ++In addition, the user can provide a script that gets a folder in an ++accepted format and appends its context to the folder in the ++user-defined format, which may be faster than converting the entire ++folder to the accepted format, appending to it and converting back to ++the user-defined format. ++</para> ++ ++<para> ++There are three hooks defined ++(<link linkend="open-hook">open-hook</link>, ++<link linkend="close-hook">close-hook</link> and ++<link linkend="append-hook">append-hook</link>) which define commands ++to uncompress and compress a folder and to append messages to an ++existing compressed folder respectively. ++</para> ++ ++<para> ++For example: ++ ++<screen> ++open-hook \\.gz$ "gzip -cd %f > %t" ++close-hook \\.gz$ "gzip -c %t > %f" ++append-hook \\.gz$ "gzip -c %t >> %f" ++</screen> ++</para> ++ ++<para> ++You do not have to specify all of the commands. If you omit ++<link linkend="append-hook">append-hook</link>, the folder will be open ++and closed again each time you will add to it. If you omit ++<link linkend="close-hook">close-hook</link> (or give empty command), ++the folder will be open in the mode. If you specify ++<link linkend="append-hook">append-hook</link> though you'll be able to ++append to the folder. ++</para> ++ ++<para> ++Note that Mutt will only try to use hooks if the file is not in one of ++the accepted formats. In particular, if the file is empty, mutt ++supposes it is not compressed. This is important because it allows the ++use of programs that do not have well defined extensions. Just use ++``.'' as a regexp. But this may be surprising if your compressing ++script produces empty files. In this situation, unset ++<link linkend="save-empty">$save_empty</link>, so that ++the compressed file will be removed if you delete all of the messages. ++</para> ++ ++<sect1 id="open-hook"> ++<title>Open a compressed mailbox for reading</title> ++ ++<para> ++Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis> ++</para> ++ ++<para> ++The <emphasis>command</emphasis> is the command that can be used for ++opening the folders whose names match <emphasis>regexp</emphasis>. ++</para> ++ ++<para> ++The <emphasis>command</emphasis> string is the printf-like format ++string, and it should accept two parameters: %f, which is ++replaced with the (compressed) folder name, and %t which is ++replaced with the name of the temporary folder to which to write. ++</para> ++ ++<para> ++%f and %t can be repeated any number of times in the ++command string, and all of the entries are replaced with the ++appropriate folder name. In addition, %% is replaced by ++%, as in printf, and any other %anything is left as is. ++</para> ++ ++<para> ++The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis> ++remove the original compressed file. The <emphasis>command</emphasis> ++should return non-zero exit status if it fails, so mutt knows ++something's wrong. ++</para> ++ ++<para> ++Example: ++ ++<screen> ++open-hook \\.gz$ "gzip -cd %f > %t" ++</screen> ++</para> ++ ++<para> ++If the <emphasis>command</emphasis> is empty, this operation is ++disabled for this file type. ++</para> ++ ++</sect1> ++ ++<sect1 id="close-hook"> ++<title>Write a compressed mailbox</title> ++ ++<para> ++Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis> ++</para> ++ ++<para> ++This is used to close the folder that was open with the ++<link linkend="open-hook">open-hook</link> command after some changes ++were made to it. ++</para> ++ ++<para> ++The <emphasis>command</emphasis> string is the command that can be ++used for closing the folders whose names match <emphasis>regexp</emphasis>. ++It has the same format as in the <link linkend="open-hook">open-hook</link> ++command. Temporary folder in this case is the folder previously ++produced by the <link linkend="open-hook">open-hook</link> command. ++</para> ++ ++<para> ++The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis> ++remove the decompressed file. The <emphasis>command</emphasis> should ++return non-zero exit status if it fails, so mutt knows something's ++wrong. ++</para> ++ ++<para> ++Example: ++ ++<screen> ++close-hook \\.gz$ "gzip -c %t > %f" ++</screen> ++</para> ++ ++<para> ++If the <emphasis>command</emphasis> is empty, this operation is ++disabled for this file type, and the file can only be open in the ++readonly mode. ++</para> ++ ++<para> ++<link linkend="close-hook">close-hook</link> is not called when you ++exit from the folder if the folder was not changed. ++</para> ++ ++</sect1> ++ ++<sect1 id="append-hook"> ++<title>Append a message to a compressed mailbox</title> ++ ++<para> ++Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis> ++</para> ++ ++<para> ++This command is used for saving to an existing compressed folder. ++The <emphasis>command</emphasis> is the command that can be used for ++appending to the folders whose names match <emphasis>regexp</emphasis>. ++It has the same format as in the <link linkend="open-hook">open-hook</link> ++command. The temporary folder in this case contains the messages that ++are being appended. ++</para> ++ ++<para> ++The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis> ++remove the decompressed file. The <emphasis>command</emphasis> should ++return non-zero exit status if it fails, so mutt knows something's ++wrong. ++</para> ++ ++<para> ++Example: ++ ++<screen> ++append-hook \\.gz$ "gzip -c %t >> %f" ++</screen> ++</para> ++ ++<para> ++When <link linkend="append-hook">append-hook</link> is used, the folder ++is not opened, which saves time, but this means that we can not find ++out what the folder type is. Thus the default ++(<link linkend="mbox-type">$mbox_type</link>) type is ++always supposed (i.e. this is the format used for the temporary ++folder). ++</para> ++ ++<para> ++If the file does not exist when you save to it, ++<link linkend="close-hook">close-hook</link> is called, and not ++<link linkend="append-hook">append-hook</link>. ++<link linkend="append-hook">append-hook</link> is only for appending ++to existing folders. ++</para> ++ ++<para> ++If the <emphasis>command</emphasis> is empty, this operation is ++disabled for this file type. In this case, the folder will be open and ++closed again (using <link linkend="open-hook">open-hook</link> and ++<link linkend="close-hook">close-hook</link> respectively) each time ++you will add to it. ++</para> ++ ++</sect1> ++ ++<sect1> ++<title>Encrypted folders</title> ++ ++<para> ++The compressed folders support can also be used to handle encrypted ++folders. If you want to encrypt a folder with PGP, you may want to use ++the following hooks: ++ ++<screen> ++open-hook \\.pgp$ "pgp -f < %f > %t" ++close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f" ++</screen> ++</para> ++ ++<para> ++Please note, that PGP does not support appending to an encrypted ++folder, so there is no append-hook defined. ++</para> ++ ++<para> ++<emphasis role="bold">Note:</emphasis> the folder is temporary stored ++decrypted in the /tmp directory, where it can be read by your system ++administrator. So think about the security aspects of this. ++</para> ++ ++</sect1> ++ ++</chapter> ++ + <chapter id="mimesupport"> + <title>Mutt's MIME Support</title> + +@@ -8433,6 +8699,18 @@ + + <listitem> + <cmdsynopsis> ++<command><link linkend="append-hook">append-hook</link></command> ++<arg choice="plain"> ++<replaceable class="parameter">pattern</replaceable> ++</arg> ++<arg choice="plain"> ++<replaceable class="parameter">command</replaceable> ++</arg> ++</cmdsynopsis> ++</listitem> ++ ++<listitem> ++<cmdsynopsis> + <command><link linkend="auto-view">auto_view</link></command> + <arg choice="plain"> + <replaceable>mimetype</replaceable> +@@ -8494,6 +8772,18 @@ + + <listitem> + <cmdsynopsis> ++<command><link linkend="close-hook">close-hook</link></command> ++<arg choice="plain"> ++<replaceable class="parameter">pattern</replaceable> ++</arg> ++<arg choice="plain"> ++<replaceable class="parameter">command</replaceable> ++</arg> ++</cmdsynopsis> ++</listitem> ++ ++<listitem> ++<cmdsynopsis> + <command><link linkend="color">color</link></command> + <arg choice="plain"> + <replaceable class="parameter">object</replaceable> +@@ -8561,6 +8851,18 @@ + </cmdsynopsis> + </listitem> + ++<listitem> ++<cmdsynopsis> ++<command><link linkend="open-hook">open-hook</link></command> ++<arg choice="plain"> ++<replaceable class="parameter">pattern</replaceable> ++</arg> ++<arg choice="plain"> ++<replaceable class="parameter">command</replaceable> ++</arg> ++</cmdsynopsis> ++</listitem> ++ + <listitem> + <cmdsynopsis> + <command><link linkend="crypt-hook">crypt-hook</link></command> +diff -uNr mutt-1.5.23/doc/Muttrc.head mutt-1.5.23.compress/doc/Muttrc.head +--- mutt-1.5.23/doc/Muttrc.head 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23.compress/doc/Muttrc.head 2014-12-03 01:33:43.322607166 +0200 +@@ -29,6 +29,11 @@ + macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list" + bind browser y exit + ++# Use folders which match on \\.gz$ as gzipped folders: ++# open-hook \\.gz$ "gzip -cd %f > %t" ++# close-hook \\.gz$ "gzip -c %t > %f" ++# append-hook \\.gz$ "gzip -c %t >> %f" ++ + # If Mutt is unable to determine your site's domain name correctly, you can + # set the default here. + # +diff -uNr mutt-1.5.23/doc/muttrc.man.head mutt-1.5.23.compress/doc/muttrc.man.head +--- mutt-1.5.23/doc/muttrc.man.head 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23.compress/doc/muttrc.man.head 2014-12-03 01:33:43.322607166 +0200 +@@ -354,6 +354,24 @@ + to a certain recipient. The meaning of "key ID" is to be taken + broadly: This can be a different e-mail address, a numerical key ID, + or even just an arbitrary search string. ++.PP ++.nf ++\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP" ++\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP" ++\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP" ++.fi ++.IP ++These commands provide a way to handle compressed folders. The given ++\fBregexp\fP specifies which folders are taken as compressed (e.g. ++"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder ++(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a ++compressed mail to a compressed folder (\fBappend-hook\fP). The ++\fIcommand\fP string is the ++.BR printf (3) ++like format string, and it should accept two parameters: \fB%f\fP, ++which is replaced with the (compressed) folder name, and \fB%t\fP ++which is replaced with the name of the temporary folder to which to ++write. + .TP + \fBpush\fP \fIstring\fP + This command adds the named \fIstring\fP to the keyboard buffer. +diff -uNr mutt-1.5.23/hook.c mutt-1.5.23.compress/hook.c +--- mutt-1.5.23/hook.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23.compress/hook.c 2014-12-03 01:33:43.322607166 +0200 +@@ -24,6 +24,10 @@ + #include "mailbox.h" + #include "mutt_crypt.h" + ++#ifdef USE_COMPRESSED ++#include "compress.h" ++#endif ++ + #include <limits.h> + #include <string.h> + #include <stdlib.h> +@@ -92,6 +96,16 @@ + memset (&pattern, 0, sizeof (pattern)); + pattern.data = safe_strdup (path); + } ++#ifdef USE_COMPRESSED ++ else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK)) ++ { ++ if (mutt_test_compress_command (command.data)) ++ { ++ strfcpy (err->data, _("bad formatted command string"), err->dsize); ++ return (-1); ++ } ++ } ++#endif + else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK)) + && (!WithCrypto || !(data & M_CRYPTHOOK)) + ) +diff -uNr mutt-1.5.23/init.h mutt-1.5.23.compress/init.h +--- mutt-1.5.23/init.h 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23.compress/init.h 2014-12-03 01:33:43.323607176 +0200 +@@ -3534,6 +3534,11 @@ + { "fcc-hook", mutt_parse_hook, M_FCCHOOK }, + { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK }, + { "folder-hook", mutt_parse_hook, M_FOLDERHOOK }, ++#ifdef USE_COMPRESSED ++ { "open-hook", mutt_parse_hook, M_OPENHOOK }, ++ { "close-hook", mutt_parse_hook, M_CLOSEHOOK }, ++ { "append-hook", mutt_parse_hook, M_APPENDHOOK }, ++#endif + { "group", parse_group, M_GROUP }, + { "ungroup", parse_group, M_UNGROUP }, + { "hdr_order", parse_list, UL &HeaderOrderList }, +diff -uNr mutt-1.5.23/main.c mutt-1.5.23.compress/main.c +--- mutt-1.5.23/main.c 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23.compress/main.c 2014-12-03 01:33:43.323607176 +0200 +@@ -340,6 +340,12 @@ + "-USE_GNU_REGEX " + #endif + ++#ifdef USE_COMPRESSED ++ "+COMPRESSED " ++#else ++ "-COMPRESSED " ++#endif ++ + "\n" + + #ifdef HAVE_COLOR +diff -uNr mutt-1.5.23/Makefile.am mutt-1.5.23.compress/Makefile.am +--- mutt-1.5.23/Makefile.am 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23.compress/Makefile.am 2014-12-03 01:33:43.323607176 +0200 +@@ -22,6 +22,7 @@ + bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@ + mutt_SOURCES = \ + addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \ ++ compress.c \ + crypt.c cryptglue.c \ + commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \ + edit.c enter.c flags.c init.c filter.c from.c \ +@@ -62,6 +63,7 @@ + + EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \ + configure account.h \ ++ compress.h \ + attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \ + globals.h hash.h history.h init.h keymap.h mutt_crypt.h \ + mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \ +diff -uNr mutt-1.5.23/Makefile.in mutt-1.5.23.compress/Makefile.in +--- mutt-1.5.23/Makefile.in 2014-03-12 18:26:44.000000000 +0200 ++++ mutt-1.5.23.compress/Makefile.in 2014-12-03 01:33:43.323607176 +0200 +@@ -14,6 +14,10 @@ + + @SET_MAKE@ + ++mutt_SOURCES += compress.c ++EXTRA_DIST += compress.h ++mutt_OBJECTS += compress.o ++ + + VPATH = @srcdir@ + am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +diff -uNr mutt-1.5.23/mbox.c mutt-1.5.23.compress/mbox.c +--- mutt-1.5.23/mbox.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23.compress/mbox.c 2014-12-03 01:33:43.323607176 +0200 +@@ -29,6 +29,10 @@ + #include "copy.h" + #include "mutt_curses.h" + ++#ifdef USE_COMPRESSED ++#include "compress.h" ++#endif ++ + #include <sys/stat.h> + #include <dirent.h> + #include <string.h> +@@ -1069,6 +1073,12 @@ + int mbox_close_mailbox (CONTEXT *ctx) + { + mx_unlock_file (ctx->path, fileno (ctx->fp), 1); ++ ++#ifdef USE_COMPRESSED ++ if (ctx->compressinfo) ++ mutt_slow_close_compressed (ctx); ++#endif ++ + mutt_unblock_signals (); + mx_fastclose_mailbox (ctx); + return 0; +diff -uNr mutt-1.5.23/mutt.h mutt-1.5.23.compress/mutt.h +--- mutt-1.5.23/mutt.h 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23.compress/mutt.h 2014-12-03 01:33:43.324607186 +0200 +@@ -144,6 +144,11 @@ + #define M_ACCOUNTHOOK (1<<9) + #define M_REPLYHOOK (1<<10) + #define M_SEND2HOOK (1<<11) ++#ifdef USE_COMPRESSED ++#define M_OPENHOOK (1<<12) ++#define M_APPENDHOOK (1<<13) ++#define M_CLOSEHOOK (1<<14) ++#endif + + /* tree characters for linearize_tree and print_enriched_string */ + #define M_TREE_LLCORNER 1 +@@ -887,6 +892,11 @@ + + unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */ + ++#ifdef USE_COMPRESSED ++ void *compressinfo; /* compressed mbox module private data */ ++ char *realpath; /* path to compressed mailbox */ ++#endif /* USE_COMPRESSED */ ++ + unsigned int locked : 1; /* is the mailbox locked? */ + unsigned int changed : 1; /* mailbox has been modified */ + unsigned int readonly : 1; /* don't allow changes to the mailbox */ +diff -uNr mutt-1.5.23/mx.c mutt-1.5.23.compress/mx.c +--- mutt-1.5.23/mx.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23.compress/mx.c 2014-12-03 01:33:43.324607186 +0200 +@@ -30,6 +30,10 @@ + #include "keymap.h" + #include "url.h" + ++#ifdef USE_COMPRESSED ++#include "compress.h" ++#endif ++ + #ifdef USE_IMAP + #include "imap.h" + #endif +@@ -414,6 +418,11 @@ + return (-1); + } + ++#ifdef USE_COMPRESSED ++ if (magic == 0 && mutt_can_read_compressed (path)) ++ return M_COMPRESSED; ++#endif ++ + return (magic); + } + +@@ -453,6 +462,13 @@ + { + struct stat sb; + ++#ifdef USE_COMPRESSED ++ /* special case for appending to compressed folders - ++ * even if we can not open them for reading */ ++ if (mutt_can_append_compressed (ctx->path)) ++ mutt_open_append_compressed (ctx); ++#endif ++ + ctx->append = 1; + + #ifdef USE_IMAP +@@ -617,6 +633,11 @@ + + ctx->magic = mx_get_magic (path); + ++#ifdef USE_COMPRESSED ++ if (ctx->magic == M_COMPRESSED) ++ mutt_open_read_compressed (ctx); ++#endif ++ + if(ctx->magic == 0) + mutt_error (_("%s is not a mailbox."), path); + +@@ -721,6 +742,10 @@ + mutt_free_header (&ctx->hdrs[i]); + FREE (&ctx->hdrs); + FREE (&ctx->v2r); ++#ifdef USE_COMPRESSED ++ if (ctx->compressinfo) ++ mutt_fast_close_compressed (ctx); ++#endif + FREE (&ctx->path); + FREE (&ctx->pattern); + if (ctx->limit_pattern) +@@ -773,6 +798,12 @@ + + if (tmp && tmp->new == 0) + mutt_update_mailbox (tmp); ++ ++#ifdef USE_COMPRESSED ++ if (rc == 0 && ctx->compressinfo) ++ return mutt_sync_compressed (ctx); ++#endif ++ + return rc; + } + +@@ -981,6 +1012,11 @@ + !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY)) + mx_unlink_empty (ctx->path); + ++#ifdef USE_COMPRESSED ++ if (ctx->compressinfo && mutt_slow_close_compressed (ctx)) ++ return (-1); ++#endif ++ + mx_fastclose_mailbox (ctx); + + return 0; +@@ -1293,6 +1329,11 @@ + { + int rc; + ++#ifdef USE_COMPRESSED ++ if (ctx->compressinfo) ++ return mutt_check_mailbox_compressed (ctx); ++#endif ++ + if (ctx) + { + if (ctx->locked) lock = 0; +diff -uNr mutt-1.5.23/mx.h mutt-1.5.23.compress/mx.h +--- mutt-1.5.23/mx.h 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23.compress/mx.h 2014-12-03 01:33:43.324607186 +0200 +@@ -36,6 +36,9 @@ + M_MAILDIR, + M_IMAP, + M_POP ++#ifdef USE_COMPRESSED ++ , M_COMPRESSED ++#endif + }; + + WHERE short DefaultMagic INITVAL (M_MBOX); +diff -uNr mutt-1.5.23/PATCHES mutt-1.5.23.compress/PATCHES +--- mutt-1.5.23/PATCHES 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23.compress/PATCHES 2014-12-03 01:33:43.324607186 +0200 +@@ -0,0 +1 @@ ++rr.compressed +diff -uNr mutt-1.5.23/po/POTFILES.in mutt-1.5.23.compress/po/POTFILES.in +--- mutt-1.5.23/po/POTFILES.in 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23.compress/po/POTFILES.in 2014-12-03 01:33:43.324607186 +0200 +@@ -8,6 +8,7 @@ + color.c + commands.c + compose.c ++compress.c + crypt-gpgme.c + crypt.c + cryptglue.c +diff -uNr mutt-1.5.23/status.c mutt-1.5.23.compress/status.c +--- mutt-1.5.23/status.c 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23.compress/status.c 2014-12-03 01:33:43.324607186 +0200 +@@ -96,6 +96,14 @@ + + case 'f': + snprintf (fmt, sizeof(fmt), "%%%ss", prefix); ++#ifdef USE_COMPRESSED ++ if (Context && Context->compressinfo && Context->realpath) ++ { ++ strfcpy (tmp, Context->realpath, sizeof (tmp)); ++ mutt_pretty_mailbox (tmp, sizeof (tmp)); ++ } ++ else ++#endif + if (Context && Context->path) + { + strfcpy (tmp, Context->path, sizeof (tmp)); Index: SOURCES/mutt-1.5.23-db53.patch =================================================================== --- SOURCES/mutt-1.5.23-db53.patch (revision 0) +++ SOURCES/mutt-1.5.23-db53.patch (working copy) @@ -0,0 +1,56 @@ +--- configure.ac 2014-03-12 18:26:40.000000000 +0200 ++++ configure.ac.db53 2014-12-03 01:27:18.063896918 +0200 +@@ -161,7 +161,7 @@ + have_smime=no + fi + ]) +- ++ + if test x$have_smime != xno ; then + AC_DEFINE(CRYPT_BACKEND_CLASSIC_SMIME, 1, [Define if you want clasic S/MIME support.]) + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS smime.o crypt-mod-smime-classic.o" +@@ -274,7 +274,7 @@ + done + AC_CHECK_LIB($cf_ncurses, initscr, + [MUTTLIBS="$MUTTLIBS -l$cf_ncurses" +- ++ + if test "$cf_ncurses" = ncursesw; then + AC_CHECK_HEADERS(ncursesw/ncurses.h,[cf_cv_ncurses_header="ncursesw/ncurses.h"]) + else +@@ -623,7 +623,7 @@ + + dnl -- imap dependencies -- + +-AC_ARG_WITH(gss, AS_HELP_STRING([--with-gss@<:@=PFX@:>@],[Compile in GSSAPI authentication for IMAP]), ++AC_ARG_WITH(gss, AS_HELP_STRING([--with-gss@<:@=PFX@:>@],[Compile in GSSAPI authentication for IMAP]), + gss_prefix="$withval", gss_prefix="no") + if test "$gss_prefix" != "no" + then +@@ -721,7 +721,7 @@ + AM_CONDITIONAL(USE_SSL, test x$need_ssl = xyes) + + AC_ARG_WITH(sasl, AS_HELP_STRING([--with-sasl@<:@=PFX@:>@],[Use SASL network security library]), +- [ ++ [ + if test "$with_sasl" != "no" + then + if test "$need_socket" != "yes" +@@ -881,7 +881,7 @@ + db_requested=bdb + fi + fi +- ++ + dnl -- Tokyo Cabinet -- + if test "$with_tokyocabinet" != "no" \ + && test "$db_requested" = auto -o "$db_requested" = tc +@@ -980,7 +980,7 @@ + bdbpfx="$bdbpfx $d/$v" + done + done +- BDB_VERSIONS="db-4 db4 db-5 db5 db-5.2 db5.2 db52 db-5.1 db5.1 db51 db-5.0 db5.0 db50 db-4.8 db4.8 db48 db-4.7 db4.7 db47 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''" ++ BDB_VERSIONS="db-4 db4 db-5 db5 db-5.3 db5.3 db53 db-5.2 db5.2 db52 db-5.1 db5.1 db51 db-5.0 db5.0 db50 db-4.8 db4.8 db48 db-4.7 db4.7 db47 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''" + AC_MSG_CHECKING([for BerkeleyDB > 4.0]) + for d in $bdbpfx; do + BDB_INCLUDE_DIR="" Index: SOURCES/mutt-1.5.23-indexcolor.patch =================================================================== --- SOURCES/mutt-1.5.23-indexcolor.patch (revision 0) +++ SOURCES/mutt-1.5.23-indexcolor.patch (working copy) @@ -0,0 +1,773 @@ +diff -uNr mutt-1.5.23.nntp.xterm.sidebar/color.c mutt-1.5.23.nntp.xterm.sidebar.indexcolor/color.c +--- mutt-1.5.23.nntp.xterm.sidebar/color.c 2014-12-03 02:32:53.217123600 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/color.c 2014-12-03 02:47:07.891519903 +0200 +@@ -35,6 +35,8 @@ + COLOR_LINE *ColorHdrList = NULL; + COLOR_LINE *ColorBodyList = NULL; + COLOR_LINE *ColorIndexList = NULL; ++COLOR_LINE *ColorIndexSubjectList = NULL; ++COLOR_LINE *ColorIndexAuthorList = NULL; + + /* local to this file */ + static int ColorQuoteSize; +@@ -93,6 +95,14 @@ + { "bold", MT_COLOR_BOLD }, + { "underline", MT_COLOR_UNDERLINE }, + { "index", MT_COLOR_INDEX }, ++ { "index_subject", MT_COLOR_INDEX_SUBJECT }, ++ { "index_author", MT_COLOR_INDEX_AUTHOR }, ++ { "index_collapsed", MT_COLOR_INDEX_COLLAPSED }, ++ { "index_date", MT_COLOR_INDEX_DATE }, ++ { "index_flags", MT_COLOR_INDEX_FLAGS }, ++ { "index_label", MT_COLOR_INDEX_LABEL }, ++ { "index_number", MT_COLOR_INDEX_NUMBER }, ++ { "index_size", MT_COLOR_INDEX_SIZE }, + { "sidebar_new", MT_COLOR_NEW }, + { "sidebar_flagged", MT_COLOR_FLAGGED }, + { NULL, 0 } +@@ -366,11 +376,54 @@ + return _mutt_parse_uncolor(buf, s, data, err, 0); + } + ++static void ++mutt_do_uncolor (BUFFER *buf, BUFFER *s, COLOR_LINE **ColorList, ++ int *do_cache, int parse_uncolor) ++{ ++ COLOR_LINE *tmp, *last = NULL; ++ ++ do ++ { ++ mutt_extract_token (buf, s, 0); ++ if (!mutt_strcmp ("*", buf->data)) ++ { ++ for (tmp = *ColorList; tmp; ) ++ { ++ if (!*do_cache) ++ *do_cache = 1; ++ last = tmp; ++ tmp = tmp->next; ++ mutt_free_color_line(&last, parse_uncolor); ++ } ++ *ColorList = NULL; ++ } ++ else ++ { ++ for (last = NULL, tmp = *ColorList; tmp; last = tmp, tmp = tmp->next) ++ { ++ if (!mutt_strcmp (buf->data, tmp->pattern)) ++ { ++ if (!*do_cache) ++ *do_cache = 1; ++ dprint(1,(debugfile,"Freeing pattern \"%s\" from ColorList\n", ++ tmp->pattern)); ++ if (last) ++ last->next = tmp->next; ++ else ++ *ColorList = tmp->next; ++ mutt_free_color_line(&tmp, parse_uncolor); ++ break; ++ } ++ } ++ } ++ } ++ while (MoreArgs (s)); ++} ++ + static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, + BUFFER *err, short parse_uncolor) + { + int object = 0, do_cache = 0; +- COLOR_LINE *tmp, *last = NULL; + COLOR_LINE **list; + + mutt_extract_token (buf, s, 0); +@@ -381,6 +434,13 @@ + return (-1); + } + ++ if (object > MT_COLOR_INDEX_AUTHOR) /* uncolor index column */ ++ { ++ ColorDefs[object] = 0; ++ set_option (OPTFORCEREDRAWINDEX); ++ return (0); ++ } ++ + if (mutt_strncmp (buf->data, "index", 5) == 0) + list = &ColorIndexList; + else if (mutt_strncmp (buf->data, "body", 4) == 0) +@@ -424,43 +484,13 @@ + return 0; + } + +- do +- { +- mutt_extract_token (buf, s, 0); +- if (!mutt_strcmp ("*", buf->data)) +- { +- for (tmp = *list; tmp; ) +- { +- if (!do_cache) +- do_cache = 1; +- last = tmp; +- tmp = tmp->next; +- mutt_free_color_line(&last, parse_uncolor); +- } +- *list = NULL; +- } +- else +- { +- for (last = NULL, tmp = *list; tmp; last = tmp, tmp = tmp->next) +- { +- if (!mutt_strcmp (buf->data, tmp->pattern)) +- { +- if (!do_cache) +- do_cache = 1; +- dprint(1,(debugfile,"Freeing pattern \"%s\" from color list\n", +- tmp->pattern)); +- if (last) +- last->next = tmp->next; +- else +- *list = tmp->next; +- mutt_free_color_line(&tmp, parse_uncolor); +- break; +- } +- } +- } +- } +- while (MoreArgs (s)); + ++ if (object == MT_COLOR_INDEX) ++ mutt_do_uncolor(buf, s, &ColorIndexList, &do_cache, parse_uncolor); ++ if (object == MT_COLOR_INDEX_SUBJECT) ++ mutt_do_uncolor(buf, s, &ColorIndexSubjectList, &do_cache, parse_uncolor); ++ if (object == MT_COLOR_INDEX_AUTHOR) ++ mutt_do_uncolor(buf, s, &ColorIndexAuthorList, &do_cache, parse_uncolor); + + if (do_cache && !option (OPTNOCURSES)) + { +@@ -700,7 +730,7 @@ + + /* extract a regular expression if needed */ + +- if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY || object == MT_COLOR_INDEX) ++ if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY || object == MT_COLOR_INDEX || object == MT_COLOR_INDEX_SUBJECT || object == MT_COLOR_INDEX_AUTHOR) + { + if (!MoreArgs (s)) + { +@@ -744,6 +774,18 @@ + r = add_pattern (&ColorIndexList, buf->data, 1, fg, bg, attr, err, 1); + set_option (OPTFORCEREDRAWINDEX); + } ++ else if (object == MT_COLOR_INDEX_SUBJECT) ++ { ++ r = add_pattern (&ColorIndexSubjectList, buf->data, ++ 1, fg, bg, attr, err, 1); ++ set_option (OPTFORCEREDRAWINDEX); ++ } ++ else if (object == MT_COLOR_INDEX_AUTHOR) ++ { ++ r = add_pattern (&ColorIndexAuthorList, buf->data, ++ 1, fg, bg, attr, err, 1); ++ set_option (OPTFORCEREDRAWINDEX); ++ } + else if (object == MT_COLOR_QUOTED) + { + if (q_level >= ColorQuoteSize) +@@ -769,7 +811,11 @@ + ColorQuote[q_level] = fgbgattr_to_color(fg, bg, attr); + } + else ++ { + ColorDefs[object] = fgbgattr_to_color(fg, bg, attr); ++ if (object > MT_COLOR_INDEX_AUTHOR) ++ set_option (OPTFORCEREDRAWINDEX); ++ } + + return (r); + } +diff -uNr mutt-1.5.23.nntp.xterm.sidebar/curs_lib.c mutt-1.5.23.nntp.xterm.sidebar.indexcolor/curs_lib.c +--- mutt-1.5.23.nntp.xterm.sidebar/curs_lib.c 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/curs_lib.c 2014-12-03 02:47:07.891519903 +0200 +@@ -718,6 +718,7 @@ + size_t k, k2; + char scratch[MB_LEN_MAX]; + mbstate_t mbstate1, mbstate2; ++ int escaped = 0; + + memset(&mbstate1, 0, sizeof (mbstate1)); + memset(&mbstate2, 0, sizeof (mbstate2)); +@@ -733,7 +734,15 @@ + k = (k == (size_t)(-1)) ? 1 : n; + wc = replacement_char (); + } +- if (arboreal && wc < M_TREE_MAX) ++ if (escaped) { ++ escaped = 0; ++ w = 0; ++ } ++ else if (arboreal && wc == M_SPECIAL_INDEX) { ++ escaped = 1; ++ w = 0; ++ } ++ else if (arboreal && wc < M_TREE_MAX) + w = 1; /* hack */ + else + { +diff -uNr mutt-1.5.23.nntp.xterm.sidebar/doc/manual.xml.head mutt-1.5.23.nntp.xterm.sidebar.indexcolor/doc/manual.xml.head +--- mutt-1.5.23.nntp.xterm.sidebar/doc/manual.xml.head 2014-12-03 02:09:36.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/doc/manual.xml.head 2014-12-03 02:47:07.892519913 +0200 +@@ -2600,7 +2600,7 @@ + + <command>color</command> + <arg choice="plain"> +-<option>index</option> ++<option>index-object</option> + </arg> + <arg choice="plain"> + <replaceable class="parameter">foreground</replaceable> +@@ -2615,7 +2615,7 @@ + <command>uncolor</command> + <group choice="req"> + <arg choice="plain"> +-<option>index</option> ++<option>index-object</option> + </arg> + <arg choice="plain"> + <option>header</option> +@@ -2658,6 +2658,14 @@ + <listitem><para>bold (highlighting bold patterns in the body of messages)</para></listitem> + <listitem><para>error (error messages printed by Mutt)</para></listitem> + <listitem><para>hdrdefault (default color of the message header in the pager)</para></listitem> ++<listitem><para>index_author (color of the author name in the index, uses <emphasis>pattern</emphasis>)</para></listitem> ++<listitem><para>index_collapsed (the number of messages in a collapsed thread in the index)</para></listitem> ++<listitem><para>index_date (color of the date field in the index)</para></listitem> ++<listitem><para>index_flags (color of the message flags in the index)</para></listitem> ++<listitem><para>index_label (color of the message label in the index)</para></listitem> ++<listitem><para>index_number (color of the message number in the index)</para></listitem> ++<listitem><para>index_size (color of the message size and line number in the index)</para></listitem> ++<listitem><para>index_subject (color of the subject in the index, uses <emphasis>pattern</emphasis>)</para></listitem> + <listitem><para>indicator (arrow or bar used to indicate the current item in a menu)</para></listitem> + <listitem><para>markers (the <quote>+</quote> markers at the beginning of wrapped lines in the pager)</para></listitem> + <listitem><para>message (informational messages)</para></listitem> +diff -uNr mutt-1.5.23.nntp.xterm.sidebar/hdrline.c mutt-1.5.23.nntp.xterm.sidebar.indexcolor/hdrline.c +--- mutt-1.5.23.nntp.xterm.sidebar/hdrline.c 2014-12-03 02:09:36.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/hdrline.c 2014-12-03 02:47:07.892519913 +0200 +@@ -103,6 +103,34 @@ + return 0; + } + ++/* Takes the color to embed, the buffer to manipulate and the buffer length as ++ * arguments. ++ * Returns the number of chars written. */ ++static size_t add_index_color(char *buf, size_t buflen, ++ format_flag flags, char color) ++{ ++ int len; ++ ++ /* only add color markers if we are operating on main index entries. */ ++ if (!(flags & M_FORMAT_INDEX)) ++ return 0; ++ ++ if (color == MT_COLOR_INDEX) { /* buf might be uninitialized other cases */ ++ len = mutt_strlen(buf); ++ buf += len; ++ buflen -= len; ++ } ++ ++ if (buflen < 2) ++ return 0; ++ ++ buf[0] = M_SPECIAL_INDEX; ++ buf[1] = color; ++ buf[2] = '\0'; ++ ++ return 2; ++} ++ + static void make_from (ENVELOPE *hdr, char *buf, size_t len, int do_lists) + { + int me; +@@ -256,6 +284,7 @@ + #define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 1) + #define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 2) + size_t len; ++ size_t colorlen; + + hdr = hfi->hdr; + ctx = hfi->ctx; +@@ -307,12 +336,17 @@ + break; + + case 'c': ++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE); + mutt_pretty_size (buf2, sizeof (buf2), (long) hdr->content->length); +- mutt_format_s (dest, destlen, prefix, buf2); ++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); ++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); + break; + + case 'C': +- snprintf (fmt, sizeof (fmt), "%%%sd", prefix); ++ colorlen = add_index_color(fmt, sizeof(fmt), flags, MT_COLOR_INDEX_NUMBER); ++ snprintf (fmt+colorlen, sizeof(fmt)-colorlen, "%%%sd", prefix); ++ add_index_color(fmt+colorlen, sizeof(fmt)-colorlen, flags, MT_COLOR_INDEX); ++ + snprintf (dest, destlen, fmt, hdr->msgno + 1); + break; + +@@ -411,7 +445,10 @@ + if (do_locales) + setlocale (LC_TIME, "C"); + +- mutt_format_s (dest, destlen, prefix, buf2); ++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_DATE); ++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); ++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); ++ + if (len > 0 && op != 'd' && op != 'D') /* Skip ending op */ + src = cp + 1; + } +@@ -441,8 +478,10 @@ + case 'F': + if (!optional) + { ++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); + make_from (hdr->env, buf2, sizeof (buf2), 0); +- mutt_format_s (dest, destlen, prefix, buf2); ++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); ++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); + } + else if (mutt_addr_is_user (hdr->env->from)) + optional = 0; +@@ -474,7 +513,9 @@ + if (!optional) + { + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); +- snprintf (dest, destlen, fmt, (int) hdr->lines); ++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE); ++ snprintf (dest+colorlen, destlen-colorlen, fmt, (int) hdr->lines); ++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); + } + else if (hdr->lines <= 0) + optional = 0; +@@ -483,8 +524,10 @@ + case 'L': + if (!optional) + { ++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR); + make_from (hdr->env, buf2, sizeof (buf2), 1); +- mutt_format_s (dest, destlen, prefix, buf2); ++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); ++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); + } + else if (!check_for_mailing_list (hdr->env->to, NULL, NULL, 0) && + !check_for_mailing_list (hdr->env->cc, NULL, NULL, 0)) +@@ -539,10 +582,16 @@ + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); + if (!optional) + { +- if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1) +- snprintf (dest, destlen, fmt, hdr->num_hidden); +- else if (is_index && threads) +- mutt_format_s (dest, destlen, prefix, " "); ++ colorlen = add_index_color(dest, destlen, flags, ++ MT_COLOR_INDEX_COLLAPSED); ++ if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1) { ++ snprintf (dest+colorlen, destlen-colorlen, fmt, hdr->num_hidden); ++ add_index_color(dest, destlen-colorlen, flags, MT_COLOR_INDEX); ++ } ++ else if (is_index && threads) { ++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, " "); ++ add_index_color(dest, destlen-colorlen, flags, MT_COLOR_INDEX); ++ } + else + *dest = '\0'; + } +@@ -572,15 +621,23 @@ + { + if (flags & M_FORMAT_FORCESUBJ) + { +- mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject)); ++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT); ++ mutt_format_s (dest+colorlen, destlen-colorlen, "", ++ NONULL (hdr->env->subject)); ++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); ++ + snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest); + mutt_format_s_tree (dest, destlen, prefix, buf2); + } + else + mutt_format_s_tree (dest, destlen, prefix, hdr->tree); + } +- else +- mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject)); ++ else { ++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT); ++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, ++ NONULL (hdr->env->subject)); ++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); ++ } + break; + + case 'S': +@@ -683,7 +740,9 @@ + hdr->tagged ? '*' : + (hdr->flagged ? '!' : + (Tochars && ((i = mutt_user_is_recipient (hdr)) < mutt_strlen (Tochars)) ? Tochars[i] : ' '))); +- mutt_format_s (dest, destlen, prefix, buf2); ++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_FLAGS); ++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2); ++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); + break; + + case 'X': +@@ -703,7 +762,9 @@ + if (optional) + optional = hdr->env->x_label ? 1 : 0; + +- mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label)); ++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL); ++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label)); ++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); + break; + + case 'Y': +@@ -729,10 +790,12 @@ + if (optional) + optional = i; + ++ colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL); + if (i) +- mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label)); ++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label)); + else +- mutt_format_s (dest, destlen, prefix, ""); ++ mutt_format_s (dest+colorlen, destlen-colorlen, prefix, ""); ++ add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX); + + break; + +diff -uNr mutt-1.5.23.nntp.xterm.sidebar/menu.c mutt-1.5.23.nntp.xterm.sidebar.indexcolor/menu.c +--- mutt-1.5.23.nntp.xterm.sidebar/menu.c 2014-12-03 02:32:53.219123620 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/menu.c 2014-12-03 02:50:57.326770229 +0200 +@@ -30,7 +30,30 @@ + + char* SearchBuffers[MENU_MAX]; + +-static void print_enriched_string (int attr, unsigned char *s, int do_color) ++static int get_color(int index, int type) { ++ COLOR_LINE *color; ++ HEADER *hdr = Context->hdrs[index]; ++ ++ switch (type) { ++ case MT_COLOR_INDEX_SUBJECT: ++ color = ColorIndexSubjectList; ++ break; ++ case MT_COLOR_INDEX_AUTHOR: ++ color = ColorIndexAuthorList; ++ break; ++ default: ++ return ColorDefs[type]; ++ } ++ ++ for (; color; color = color->next) ++ if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS, ++ Context, hdr)) ++ return color->pair; ++ ++ return 0; ++} ++ ++static void print_enriched_string (int index, int attr, unsigned char *s, int do_color) + { + wchar_t wc; + size_t k; +@@ -162,6 +185,18 @@ + } + if (do_color) ATTRSET(attr); + } ++ else if(*s == M_SPECIAL_INDEX) ++ { ++ s++; ++ if (do_color) { ++ if (*s == MT_COLOR_INDEX) ++ attrset(attr); ++ else ++ attron(get_color(index, *s)); ++ } ++ s++; ++ n -= 2; ++ } + else if ((k = mbrtowc (&wc, (char *)s, n, &mbstate)) > 0) + { + addnstr ((char *)s, k); +@@ -172,9 +207,9 @@ + } + } + +-static void menu_make_entry (char *s, int l, MUTTMENU *menu, int i) ++static void menu_make_entry (char *s, int l, MUTTMENU *menu, int i) + { +- if (menu->dialog) ++ if (menu->dialog) + { + strncpy (s, menu->dialog[i], l); + menu->current = -1; /* hide menubar */ +@@ -269,7 +304,7 @@ + else if (option(OPTARROWCURSOR)) + addstr(" "); + +- print_enriched_string (attr, (unsigned char *) buf, do_color); ++ print_enriched_string (i, attr, (unsigned char *) buf, do_color); + } + else + { +@@ -285,12 +320,12 @@ + { + char buf[LONG_STRING]; + +- if (menu->dialog) ++ if (menu->dialog) + { + menu->redraw &= ~REDRAW_MOTION; + return; + } +- ++ + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth); + ATTRSET(menu->color (menu->oldcurrent)); + +@@ -304,7 +339,7 @@ + menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); + menu_pad_string (buf, sizeof (buf)); + move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3); +- print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); ++ print_enriched_string (menu->oldcurrent, menu->color(menu->oldcurrent), (unsigned char *) buf, 1); + } + + /* now draw it in the new location */ +@@ -316,14 +351,14 @@ + /* erase the current indicator */ + menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); + menu_pad_string (buf, sizeof (buf)); +- print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); ++ print_enriched_string (menu->oldcurrent, menu->color(menu->oldcurrent), (unsigned char *) buf, 1); + + /* now draw the new one to reflect the change */ + menu_make_entry (buf, sizeof (buf), menu, menu->current); + menu_pad_string (buf, sizeof (buf)); + SETCOLOR(MT_COLOR_INDICATOR); + move(menu->current - menu->top + menu->offset, SidebarWidth); +- print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); ++ print_enriched_string (menu->current, menu->color(menu->current), (unsigned char *) buf, 0); + } + menu->redraw &= REDRAW_STATUS; + NORMAL_COLOR; +@@ -333,7 +368,7 @@ + { + char buf[LONG_STRING]; + int attr = menu->color (menu->current); +- ++ + move (menu->current + menu->offset - menu->top, SidebarWidth); + menu_make_entry (buf, sizeof (buf), menu, menu->current); + menu_pad_string (buf, sizeof (buf)); +@@ -345,19 +380,19 @@ + ATTRSET(attr); + addch (' '); + menu_pad_string (buf, sizeof (buf)); +- print_enriched_string (attr, (unsigned char *) buf, 1); ++ print_enriched_string (menu->current, attr, (unsigned char *) buf, 1); + } + else +- print_enriched_string (attr, (unsigned char *) buf, 0); ++ print_enriched_string (menu->current, attr, (unsigned char *) buf, 0); + menu->redraw &= REDRAW_STATUS; + NORMAL_COLOR; + } + + static void menu_redraw_prompt (MUTTMENU *menu) + { +- if (menu->dialog) ++ if (menu->dialog) + { +- if (option (OPTMSGERR)) ++ if (option (OPTMSGERR)) + { + mutt_sleep (1); + unset_option (OPTMSGERR); +@@ -378,13 +413,13 @@ + + if (!option (OPTMENUMOVEOFF) && menu->max <= menu->pagelen) /* less entries than lines */ + { +- if (menu->top != 0) ++ if (menu->top != 0) + { + menu->top = 0; + set_option (OPTNEEDREDRAW); + } + } +- else ++ else + { + if (option (OPTMENUSCROLL) || (menu->pagelen <= 0) || (c < MenuContext)) + { +@@ -398,7 +433,7 @@ + if (menu->current < menu->top + c) + menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) / (menu->pagelen - c)) - c; + else if ((menu->current >= menu->top + menu->pagelen - c)) +- menu->top += (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c; ++ menu->top += (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c; + } + } + +@@ -471,7 +506,7 @@ + mutt_error _("You cannot scroll up farther."); + } + +-/* ++/* + * pageup: jumplen == -pagelen + * pagedown: jumplen == pagelen + * halfup: jumplen == -pagelen/2 +@@ -781,18 +816,18 @@ + { + switch (i) + { +- case OP_NEXT_ENTRY: ++ case OP_NEXT_ENTRY: + return OP_NEXT_LINE; +- case OP_PREV_ENTRY: ++ case OP_PREV_ENTRY: + return OP_PREV_LINE; +- case OP_CURRENT_TOP: case OP_FIRST_ENTRY: ++ case OP_CURRENT_TOP: case OP_FIRST_ENTRY: + return OP_TOP_PAGE; +- case OP_CURRENT_BOTTOM: case OP_LAST_ENTRY: ++ case OP_CURRENT_BOTTOM: case OP_LAST_ENTRY: + return OP_BOTTOM_PAGE; +- case OP_CURRENT_MIDDLE: +- return OP_MIDDLE_PAGE; ++ case OP_CURRENT_MIDDLE: ++ return OP_MIDDLE_PAGE; + } +- ++ + return i; + } + +@@ -830,10 +865,10 @@ + /* allow the caller to do any local configuration */ + return (OP_REDRAW); + } +- ++ + if (!menu->dialog) + menu_check_recenter (menu); +- ++ + if (menu->redraw & REDRAW_STATUS) + menu_redraw_status (menu); + if (menu->redraw & REDRAW_INDEX) +@@ -842,10 +877,10 @@ + menu_redraw_motion (menu); + else if (menu->redraw == REDRAW_CURRENT) + menu_redraw_current (menu); +- ++ + if (menu->dialog) + menu_redraw_prompt (menu); +- ++ + return OP_NULL; + } + +@@ -860,19 +895,19 @@ + unset_option (OPTMENUCALLER); + return OP_NULL; + } +- +- ++ ++ + mutt_curs_set (0); + + if (menu_redraw (menu) == OP_REDRAW) + return OP_REDRAW; +- ++ + menu->oldcurrent = menu->current; + + + /* move the cursor out of the way */ +- +- ++ ++ + if (option (OPTARROWCURSOR)) + move (menu->current - menu->top + menu->offset, SidebarWidth + 2); + else if (option (OPTBRAILLEFRIENDLY)) +@@ -881,11 +916,11 @@ + move (menu->current - menu->top + menu->offset, COLS - 1); + + mutt_refresh (); +- ++ + /* try to catch dialog keys before ops */ + if (menu->dialog && menu_dialog_dokey (menu, &i) == 0) + return i; +- ++ + i = km_dokey (menu->menu); + if (i == OP_TAG_PREFIX || i == OP_TAG_PREFIX_COND) + { +@@ -938,7 +973,7 @@ + mutt_clear_error (); + + /* Convert menubar movement to scrolling */ +- if (menu->dialog) ++ if (menu->dialog) + i = menu_dialog_translate_op (i); + + switch (i) +diff -uNr mutt-1.5.23.nntp.xterm.sidebar/mutt_curses.h mutt-1.5.23.nntp.xterm.sidebar.indexcolor/mutt_curses.h +--- mutt-1.5.23.nntp.xterm.sidebar/mutt_curses.h 2014-12-03 02:32:53.219123620 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/mutt_curses.h 2014-12-03 02:47:07.893519923 +0200 +@@ -123,6 +123,16 @@ + MT_COLOR_INDEX, + MT_COLOR_NEW, + MT_COLOR_FLAGGED, ++ /* please no non-MT_COLOR_INDEX objects after this point */ ++ MT_COLOR_INDEX_SUBJECT, ++ MT_COLOR_INDEX_AUTHOR, ++ /* below only index coloring stuff that doesn't have a colorline! */ ++ MT_COLOR_INDEX_COLLAPSED, ++ MT_COLOR_INDEX_DATE, ++ MT_COLOR_INDEX_FLAGS, ++ MT_COLOR_INDEX_LABEL, ++ MT_COLOR_INDEX_NUMBER, ++ MT_COLOR_INDEX_SIZE, + MT_COLOR_MAX + }; + +@@ -176,6 +186,8 @@ + extern COLOR_LINE *ColorHdrList; + extern COLOR_LINE *ColorBodyList; + extern COLOR_LINE *ColorIndexList; ++extern COLOR_LINE *ColorIndexSubjectList; ++extern COLOR_LINE *ColorIndexAuthorList; + + void ci_init_color (void); + void ci_start_color (void); +diff -uNr mutt-1.5.23.nntp.xterm.sidebar/mutt.h mutt-1.5.23.nntp.xterm.sidebar.indexcolor/mutt.h +--- mutt-1.5.23.nntp.xterm.sidebar/mutt.h 2014-12-03 02:32:53.219123620 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar.indexcolor/mutt.h 2014-12-03 02:47:07.893519923 +0200 +@@ -161,6 +161,8 @@ + #define M_TREE_MISSING 13 + #define M_TREE_MAX 14 + ++#define M_SPECIAL_INDEX M_TREE_MAX ++ + #define M_THREAD_COLLAPSE (1<<0) + #define M_THREAD_UNCOLLAPSE (1<<1) + #define M_THREAD_GET_HIDDEN (1<<2) Index: SOURCES/mutt-1.5.23-no-sgid.patch =================================================================== --- SOURCES/mutt-1.5.23-no-sgid.patch (revision 0) +++ SOURCES/mutt-1.5.23-no-sgid.patch (working copy) @@ -0,0 +1,14 @@ +--- Makefile.am 2014-03-12 18:03:44.000000000 +0200 ++++ Makefile.am.sgid 2014-12-03 01:20:47.748124116 +0200 +@@ -154,11 +154,6 @@ + rm -f $(DESTDIR)$(bindir)/mutt.dotlock ; \ + ln -sf $(DESTDIR)$(bindir)/mutt_dotlock $(DESTDIR)$(bindir)/mutt.dotlock ; \ + fi +- if test -f $(DESTDIR)$(bindir)/mutt_dotlock && test x@DOTLOCK_GROUP@ != x ; then \ +- chgrp @DOTLOCK_GROUP@ $(DESTDIR)$(bindir)/mutt_dotlock && \ +- chmod @DOTLOCK_PERMISSION@ $(DESTDIR)$(bindir)/mutt_dotlock || \ +- { echo "Can't fix mutt_dotlock's permissions! This is required to lock mailboxes in the mail spool directory." >&2 ; exit 1 ; } \ +- fi + + install-data-local: + $(srcdir)/mkinstalldirs $(DESTDIR)$(sysconfdir) Index: SOURCES/mutt-1.5.23-sidebar.patch =================================================================== --- SOURCES/mutt-1.5.23-sidebar.patch (revision 0) +++ SOURCES/mutt-1.5.23-sidebar.patch (working copy) @@ -0,0 +1,1697 @@ +diff -uNr mutt-1.5.23.nntp.xterm/buffy.c mutt-1.5.23.nntp.xterm.sidebar/buffy.c +--- mutt-1.5.23.nntp.xterm/buffy.c 2014-12-03 02:09:36.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/buffy.c 2014-12-03 02:32:53.217123600 +0200 +@@ -161,6 +161,49 @@ + } + } + ++static int buffy_compare_name(const void *a, const void *b) { ++ const BUFFY *b1 = * (BUFFY * const *) a; ++ const BUFFY *b2 = * (BUFFY * const *) b; ++ ++ return mutt_strcoll(b1->path, b2->path); ++} ++ ++static BUFFY *buffy_sort(BUFFY *b) ++{ ++ BUFFY *tmp = b; ++ int buffycount = 0; ++ BUFFY **ary; ++ int i; ++ ++ if (!option(OPTSIDEBARSORT)) ++ return b; ++ ++ for (; tmp != NULL; tmp = tmp->next) ++ buffycount++; ++ ++ ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary)); ++ ++ tmp = b; ++ for (i = 0; tmp != NULL; tmp = tmp->next, i++) { ++ ary[i] = tmp; ++ } ++ ++ qsort(ary, buffycount, sizeof(*ary), buffy_compare_name); ++ ++ for (i = 0; i < buffycount - 1; i++) { ++ ary[i]->next = ary[i+1]; ++ } ++ ary[buffycount - 1]->next = NULL; ++ for (i = 1; i < buffycount; i++) { ++ ary[i]->prev = ary[i-1]; ++ } ++ ary[0]->prev = NULL; ++ ++ tmp = ary[0]; ++ free(ary); ++ return tmp; ++} ++ + BUFFY *mutt_find_mailbox (const char *path) + { + BUFFY *tmp = NULL; +@@ -282,6 +325,7 @@ + else + (*tmp)->size = 0; + } ++ Incoming = buffy_sort(Incoming); + return 0; + } + +@@ -340,6 +384,68 @@ + return rc; + } + ++/* update message counts for the sidebar */ ++void buffy_maildir_update (BUFFY* mailbox) ++{ ++ char path[_POSIX_PATH_MAX]; ++ DIR *dirp; ++ struct dirent *de; ++ char *p; ++ ++ mailbox->msgcount = 0; ++ mailbox->msg_unread = 0; ++ mailbox->msg_flagged = 0; ++ ++ snprintf (path, sizeof (path), "%s/new", mailbox->path); ++ ++ if ((dirp = opendir (path)) == NULL) ++ { ++ mailbox->magic = 0; ++ return; ++ } ++ ++ while ((de = readdir (dirp)) != NULL) ++ { ++ if (*de->d_name == '.') ++ continue; ++ ++ if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) { ++ mailbox->new = 1; ++ mailbox->msgcount++; ++ mailbox->msg_unread++; ++ } ++ } ++ ++ closedir (dirp); ++ snprintf (path, sizeof (path), "%s/cur", mailbox->path); ++ ++ if ((dirp = opendir (path)) == NULL) ++ { ++ mailbox->magic = 0; ++ return; ++ } ++ ++ while ((de = readdir (dirp)) != NULL) ++ { ++ if (*de->d_name == '.') ++ continue; ++ ++ if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) { ++ mailbox->msgcount++; ++ if ((p = strstr (de->d_name, ":2,"))) { ++ if (!strchr (p + 3, 'T')) { ++ if (!strchr (p + 3, 'S')) ++ mailbox->msg_unread++; ++ if (strchr(p + 3, 'F')) ++ mailbox->msg_flagged++; ++ } ++ } ++ } ++ } ++ ++ closedir (dirp); ++} ++ + /* returns 1 if mailbox has new mail */ + static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb) + { +@@ -371,6 +477,20 @@ + return rc; + } + ++/* update message counts for the sidebar */ ++void buffy_mbox_update (BUFFY* mailbox) ++{ ++ CONTEXT *ctx = NULL; ++ ++ ctx = mx_open_mailbox(mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL); ++ if(ctx) ++ { ++ mailbox->msgcount = ctx->msgcount; ++ mailbox->msg_unread = ctx->unread; ++ mx_close_mailbox(ctx, 0); ++ } ++} ++ + int mutt_buffy_check (int force) + { + BUFFY *tmp; +@@ -456,16 +576,19 @@ + { + case M_MBOX: + case M_MMDF: ++ buffy_mbox_update (tmp); + if (buffy_mbox_hasnew (tmp, &sb) > 0) + BuffyCount++; + break; + + case M_MAILDIR: ++ buffy_maildir_update (tmp); + if (buffy_maildir_hasnew (tmp) > 0) + BuffyCount++; + break; + + case M_MH: ++ mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged); + mh_buffy(tmp); + if (tmp->new) + BuffyCount++; +diff -uNr mutt-1.5.23.nntp.xterm/buffy.h mutt-1.5.23.nntp.xterm.sidebar/buffy.h +--- mutt-1.5.23.nntp.xterm/buffy.h 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/buffy.h 2014-12-03 02:32:53.217123600 +0200 +@@ -25,7 +25,11 @@ + char path[_POSIX_PATH_MAX]; + off_t size; + struct buffy_t *next; ++ struct buffy_t *prev; + short new; /* mailbox has new mail */ ++ int msgcount; /* total number of messages */ ++ int msg_unread; /* number of unread messages */ ++ int msg_flagged; /* number of flagged messages */ + short notified; /* user has been notified */ + short magic; /* mailbox type */ + short newly_created; /* mbox or mmdf just popped into existence */ +diff -uNr mutt-1.5.23.nntp.xterm/color.c mutt-1.5.23.nntp.xterm.sidebar/color.c +--- mutt-1.5.23.nntp.xterm/color.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/color.c 2014-12-03 02:32:53.217123600 +0200 +@@ -93,6 +93,8 @@ + { "bold", MT_COLOR_BOLD }, + { "underline", MT_COLOR_UNDERLINE }, + { "index", MT_COLOR_INDEX }, ++ { "sidebar_new", MT_COLOR_NEW }, ++ { "sidebar_flagged", MT_COLOR_FLAGGED }, + { NULL, 0 } + }; + +diff -uNr mutt-1.5.23.nntp.xterm/compose.c mutt-1.5.23.nntp.xterm.sidebar/compose.c +--- mutt-1.5.23.nntp.xterm/compose.c 2014-12-03 02:09:36.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/compose.c 2014-12-03 02:38:03.539176666 +0200 +@@ -1,21 +1,21 @@ + /* + * Copyright (C) 1996-2000,2002,2007 Michael R. Elkins <me@mutt.org> + * Copyright (C) 2004 g10 Code GmbH +- * ++ * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. +- * ++ * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. +- * ++ * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +- */ ++ */ + + #if HAVE_CONFIG_H + # include "config.h" +@@ -83,7 +83,7 @@ + + #define HDR_XOFFSET 14 + #define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */ +-#define W (COLS - HDR_XOFFSET) ++#define W (COLS - HDR_XOFFSET - SidebarWidth) + + static const char * const Prompts[] = + { +@@ -144,7 +144,7 @@ + + static void redraw_crypt_lines (HEADER *msg) + { +- mvprintw (HDR_CRYPT, 0, TITLE_FMT, "Security: "); ++ mvprintw (HDR_CRYPT, SidebarWidth, TITLE_FMT, "Security: "); + + if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0) + { +@@ -176,7 +176,7 @@ + } + + clrtoeol (); +- move (HDR_CRYPTINFO, 0); ++ move (HDR_CRYPTINFO, SidebarWidth); + clrtoeol (); + + if ((WithCrypto & APPLICATION_PGP) +@@ -194,7 +194,7 @@ + && (msg->security & ENCRYPT) + && SmimeCryptAlg + && *SmimeCryptAlg) { +- mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "), ++ mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "), + NONULL(SmimeCryptAlg)); + } + } +@@ -207,7 +207,7 @@ + int c; + char *t; + +- mvprintw (HDR_MIX, 0, TITLE_FMT, "Mix: "); ++ mvprintw (HDR_MIX, SidebarWidth, TITLE_FMT, "Mix: "); + + if (!chain) + { +@@ -215,14 +215,14 @@ + clrtoeol (); + return; + } +- ++ + for (c = 12; chain; chain = chain->next) + { + t = chain->data; + if (t && t[0] == '0' && t[1] == '\0') + t = "<random>"; +- +- if (c + mutt_strlen (t) + 2 >= COLS) ++ ++ if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth) + break; + + addstr (NONULL(t)); +@@ -251,13 +251,13 @@ + pretty, i+1); + return -1; + } +- ++ + if(idx[i]->content->stamp < st.st_mtime) + { + mutt_pretty_mailbox(pretty, sizeof (pretty)); + snprintf(msg, sizeof(msg), _("%s [#%d] modified. Update encoding?"), + pretty, i+1); +- ++ + if((r = mutt_yesorno(msg, M_YES)) == M_YES) + mutt_update_encoding(idx[i]->content); + else if(r == -1) +@@ -274,7 +274,7 @@ + + buf[0] = 0; + rfc822_write_address (buf, sizeof (buf), addr, 1); +- mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]); ++ mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]); + mutt_paddstr (W, buf); + } + +@@ -292,9 +292,9 @@ + } + else + { +- mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]); ++ mvprintw (HDR_TO, SidebarWidth, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]); + mutt_paddstr (W, NONULL (msg->env->newsgroups)); +- mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]); ++ mvprintw (HDR_CC, SidebarWidth, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]); + mutt_paddstr (W, NONULL (msg->env->followup_to)); + if (option (OPTXCOMMENTTO)) + { +@@ -317,7 +317,7 @@ + #endif + + SETCOLOR (MT_COLOR_STATUS); +- mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments")); ++ mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments")); + clrtoeol (); + + NORMAL_COLOR; +@@ -327,7 +327,7 @@ + { + char buf[HUGE_STRING] = ""; /* needs to be large for alias expansion */ + char *err = NULL; +- ++ + mutt_addrlist_to_local (*addr); + rfc822_write_address (buf, sizeof (buf), *addr, 0); + if (mutt_get_field (Prompts[line - 1], buf, sizeof (buf), M_ALIAS) == 0) +@@ -353,9 +353,9 @@ + /* redraw the expanded list so the user can see the result */ + buf[0] = 0; + rfc822_write_address (buf, sizeof (buf), *addr, 1); +- move (line, HDR_XOFFSET); ++ move (line, HDR_XOFFSET+SidebarWidth); + mutt_paddstr (W, buf); +- ++ + return 0; + } + +@@ -390,7 +390,7 @@ + for (; x < *idxlen - 1; x++) + idx[x] = idx[x+1]; + menu->max = --(*idxlen); +- ++ + return (0); + } + +@@ -407,13 +407,13 @@ + } + + +-/* ++/* + * cum_attachs_size: Cumulative Attachments Size + * + * Returns the total number of bytes used by the attachments in the + * attachment list _after_ content-transfer-encodings have been + * applied. +- * ++ * + */ + + static unsigned long cum_attachs_size (MUTTMENU *menu) +@@ -423,7 +423,7 @@ + ATTACHPTR **idx = menu->data; + CONTENT *info; + BODY *b; +- ++ + for (i = 0, s = 0; i < menu->max; i++) + { + b = idx[i]->content; +@@ -452,16 +452,16 @@ + } + + /* prototype for use below */ +-static void compose_status_line (char *buf, size_t buflen, size_t col, MUTTMENU *menu, ++static void compose_status_line (char *buf, size_t buflen, size_t col, MUTTMENU *menu, + const char *p); + + /* + * compose_format_str() + * +- * %a = total number of attachments ++ * %a = total number of attachments + * %h = hostname [option] +- * %l = approx. length of current message (in bytes) +- * %v = Mutt version ++ * %l = approx. length of current message (in bytes) ++ * %v = Mutt version + * + * This function is similar to status_format_str(). Look at that function for + * help when modifying this function. +@@ -518,10 +518,10 @@ + return (src); + } + +-static void compose_status_line (char *buf, size_t buflen, size_t col, MUTTMENU *menu, ++static void compose_status_line (char *buf, size_t buflen, size_t col, MUTTMENU *menu, + const char *p) + { +- mutt_FormatString (buf, buflen, col, p, compose_format_str, ++ mutt_FormatString (buf, buflen, col, p, compose_format_str, + (unsigned long) menu, 0); + } + +@@ -575,7 +575,7 @@ + else + #endif + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp); +- ++ + while (loop) + { + #ifdef USE_NNTP +@@ -614,7 +614,7 @@ + break; + #endif + menu->redraw = edit_address_list (HDR_CC, &msg->env->cc); +- mutt_message_hook (NULL, msg, M_SEND2HOOK); ++ mutt_message_hook (NULL, msg, M_SEND2HOOK); + break; + #ifdef USE_NNTP + case OP_COMPOSE_EDIT_NEWSGROUPS: +@@ -685,7 +685,7 @@ + if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) + { + mutt_str_replace (&msg->env->subject, buf); +- move (HDR_SUBJECT, HDR_XOFFSET); ++ move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth); + if (msg->env->subject) + mutt_paddstr (W, msg->env->subject); + else +@@ -703,7 +703,7 @@ + { + strfcpy (fcc, buf, fcclen); + mutt_pretty_mailbox (fcc, fcclen); +- move (HDR_FCC, HDR_XOFFSET); ++ move (HDR_FCC, HDR_XOFFSET + SidebarWidth); + mutt_paddstr (W, fcc); + fccSet = 1; + } +@@ -764,13 +764,13 @@ + + case OP_COMPOSE_ATTACH_KEY: + if (!(WithCrypto & APPLICATION_PGP)) +- break; ++ break; + if (idxlen == idxmax) + { + safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5)); + menu->data = idx; + } +- ++ + idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR)); + if ((idx[idxlen]->content = crypt_pgp_make_key_attachment(NULL)) != NULL) + { +@@ -787,7 +787,7 @@ + menu->redraw = REDRAW_FULL; + unset_option(OPTNEEDREDRAW); + } +- ++ + mutt_message_hook (NULL, msg, M_SEND2HOOK); + break; + +@@ -830,7 +830,7 @@ + FREE (&idx[idxlen]); + } + } +- ++ + FREE (&files); + if (!error) mutt_clear_error (); + +@@ -915,7 +915,7 @@ + + this = Context; /* remember current folder and sort methods*/ + oldSort = Sort; oldSortAux = SortAux; +- ++ + Context = ctx; + set_option(OPTATTACHMSG); + mutt_message _("Tag the messages you want to attach!"); +@@ -957,7 +957,7 @@ + } + menu->redraw |= REDRAW_FULL; + +- if (close == OP_QUIT) ++ if (close == OP_QUIT) + mx_close_mailbox (Context, NULL); + else + mx_fastclose_mailbox (Context); +@@ -995,9 +995,9 @@ + break; + + #define CURRENT idx[menu->current]->content +- ++ + case OP_COMPOSE_TOGGLE_RECODE: +- { ++ { + CHECK_COUNT; + if (!mutt_is_text_part (CURRENT)) + { +@@ -1049,7 +1049,7 @@ + } + mutt_message_hook (NULL, msg, M_SEND2HOOK); + break; +- ++ + case OP_COMPOSE_TOGGLE_DISPOSITION: + /* toggle the content-disposition between inline/attachment */ + idx[menu->current]->content->disposition = (idx[menu->current]->content->disposition == DISPINLINE) ? DISPATTACH : DISPINLINE; +@@ -1093,19 +1093,19 @@ + /* Note: We don't invoke send2-hook here, since we want to leave + * users an opportunity to change settings from the ":" prompt. + */ +- ++ + if(check_attachments(idx, idxlen) != 0) + { + menu->redraw = REDRAW_FULL; + break; + } + +- ++ + #ifdef MIXMASTER + if (msg->chain && mix_check_message (msg) != 0) + break; + #endif +- ++ + if (!fccSet && *fcc) + { + if ((i = query_quadoption (OPT_COPY, +@@ -1160,7 +1160,7 @@ + + /* No send2hook since this doesn't change the message. */ + break; +- ++ + case OP_COMPOSE_RENAME_FILE: + CHECK_COUNT; + strfcpy (fname, idx[menu->current]->content->filename, sizeof (fname)); +@@ -1177,13 +1177,13 @@ + mutt_expand_path (fname, sizeof (fname)); + if(mutt_rename_file (idx[menu->current]->content->filename, fname)) + break; +- ++ + mutt_str_replace (&idx[menu->current]->content->filename, fname); + menu->redraw = REDRAW_CURRENT; + + if(idx[menu->current]->content->stamp >= st.st_mtime) + mutt_stamp_attachment(idx[menu->current]->content); +- ++ + } + mutt_message_hook (NULL, msg, M_SEND2HOOK); + break; +@@ -1204,7 +1204,7 @@ + + /* Call to lookup_mime_type () ? maybe later */ + type[0] = 0; +- if (mutt_get_field ("Content-Type: ", type, sizeof (type), 0) != 0 ++ if (mutt_get_field ("Content-Type: ", type, sizeof (type), 0) != 0 + || !type[0]) + continue; + +@@ -1253,7 +1253,7 @@ + menu->redraw = REDRAW_FULL; + } + } +- mutt_message_hook (NULL, msg, M_SEND2HOOK); ++ mutt_message_hook (NULL, msg, M_SEND2HOOK); + break; + + case OP_COMPOSE_EDIT_MIME: +@@ -1330,7 +1330,7 @@ + menu->redraw = REDRAW_FULL; + break; + } +- ++ + loop = 0; + r = 1; + break; +@@ -1423,7 +1423,7 @@ + + #ifdef MIXMASTER + case OP_COMPOSE_MIX: +- ++ + mix_make_chain (&msg->chain, &menu->redraw); + mutt_message_hook (NULL, msg, M_SEND2HOOK); + break; +@@ -1432,7 +1432,7 @@ + } + + /* Draw formatted compose status line */ +- if (menu->redraw & REDRAW_STATUS) ++ if (menu->redraw & REDRAW_STATUS) + { + compose_status_line (buf, sizeof (buf), 0, menu, NONULL(ComposeFormat)); + move(option (OPTSTATUSONTOP) ? 0 : LINES-2, 0); +@@ -1461,4 +1461,3 @@ + + return (r); + } +- +diff -uNr mutt-1.5.23.nntp.xterm/curs_main.c mutt-1.5.23.nntp.xterm.sidebar/curs_main.c +--- mutt-1.5.23.nntp.xterm/curs_main.c 2014-12-03 02:10:11.933685529 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/curs_main.c 2014-12-03 02:32:53.218123610 +0200 +@@ -27,7 +27,9 @@ + #include "mailbox.h" + #include "mapping.h" + #include "sort.h" ++#include "buffy.h" + #include "mx.h" ++#include "sidebar.h" + + #ifdef USE_POP + #include "pop.h" +@@ -556,8 +558,12 @@ + menu->redraw |= REDRAW_STATUS; + if (do_buffy_notify) + { +- if (mutt_buffy_notify () && option (OPTBEEPNEW)) +- beep (); ++ if (mutt_buffy_notify ()) ++ { ++ menu->redraw |= REDRAW_FULL; ++ if (option (OPTBEEPNEW)) ++ beep (); ++ } + } + else + do_buffy_notify = 1; +@@ -569,6 +575,7 @@ + if (menu->redraw & REDRAW_FULL) + { + menu_redraw_full (menu); ++ draw_sidebar(menu->menu); + mutt_show_error (); + } + +@@ -591,9 +598,12 @@ + + if (menu->redraw & REDRAW_STATUS) + { ++ DrawFullLine = 1; + menu_status_line (buf, sizeof (buf), menu, NONULL (Status)); ++ DrawFullLine = 0; + move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0); + SETCOLOR (MT_COLOR_STATUS); ++ set_buffystats(Context); + mutt_paddstr (COLS, buf); + NORMAL_COLOR; + menu->redraw &= ~REDRAW_STATUS; +@@ -613,7 +623,7 @@ + menu->oldcurrent = -1; + + if (option (OPTARROWCURSOR)) +- move (menu->current - menu->top + menu->offset, 2); ++ move (menu->current - menu->top + menu->offset, SidebarWidth + 2); + else if (option (OPTBRAILLEFRIENDLY)) + move (menu->current - menu->top + menu->offset, 0); + else +@@ -1294,6 +1304,7 @@ + menu->redraw = REDRAW_FULL; + break; + ++ case OP_SIDEBAR_OPEN: + case OP_MAIN_CHANGE_FOLDER: + case OP_MAIN_NEXT_UNREAD_MAILBOX: + case OP_MAIN_CHANGE_FOLDER_READONLY: +@@ -1348,7 +1359,11 @@ + #endif + mutt_buffy (buf, sizeof (buf)); + +- if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) ++ if ( op == OP_SIDEBAR_OPEN ) { ++ if(!CurBuffy) ++ break; ++ strncpy( buf, CurBuffy->path, sizeof(buf) ); ++ } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) + { + if (menu->menu == MENU_PAGER) + { +@@ -1374,6 +1389,7 @@ + else + #endif + mutt_expand_path (buf, sizeof (buf)); ++ set_curbuffy(buf); + if (mx_get_magic (buf) <= 0) + { + mutt_error (_("%s is not a mailbox."), buf); +@@ -2515,6 +2531,12 @@ + mutt_what_key(); + break; + ++ case OP_SIDEBAR_SCROLL_UP: ++ case OP_SIDEBAR_SCROLL_DOWN: ++ case OP_SIDEBAR_NEXT: ++ case OP_SIDEBAR_PREV: ++ scroll_sidebar(op, menu->menu); ++ break; + default: + if (menu->menu == MENU_MAIN) + km_error_key (MENU_MAIN); +diff -uNr mutt-1.5.23.nntp.xterm/flags.c mutt-1.5.23.nntp.xterm.sidebar/flags.c +--- mutt-1.5.23.nntp.xterm/flags.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/flags.c 2014-12-03 02:32:53.218123610 +0200 +@@ -22,8 +22,10 @@ + + #include "mutt.h" + #include "mutt_curses.h" ++#include "mutt_menu.h" + #include "sort.h" + #include "mx.h" ++#include "sidebar.h" + + void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) + { +@@ -263,6 +265,7 @@ + */ + if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged)) + h->searched = 0; ++ draw_sidebar(0); + } + + void mutt_tag_set_flag (int flag, int bf) +diff -uNr mutt-1.5.23.nntp.xterm/functions.h mutt-1.5.23.nntp.xterm.sidebar/functions.h +--- mutt-1.5.23.nntp.xterm/functions.h 2014-12-03 02:09:36.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/functions.h 2014-12-03 02:32:53.218123610 +0200 +@@ -188,6 +188,11 @@ + { "decrypt-save", OP_DECRYPT_SAVE, NULL }, + + ++ { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, ++ { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, ++ { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, ++ { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, ++ { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, + { NULL, 0, NULL } + }; + +@@ -302,6 +307,11 @@ + + { "what-key", OP_WHAT_KEY, NULL }, + ++ { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, ++ { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, ++ { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, ++ { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, ++ { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, + { NULL, 0, NULL } + }; + +diff -uNr mutt-1.5.23.nntp.xterm/globals.h mutt-1.5.23.nntp.xterm.sidebar/globals.h +--- mutt-1.5.23.nntp.xterm/globals.h 2014-12-03 02:10:11.933685529 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/globals.h 2014-12-03 02:32:53.218123610 +0200 +@@ -128,6 +128,7 @@ + WHERE char *SendCharset; + WHERE char *Sendmail; + WHERE char *Shell; ++WHERE char *SidebarDelim; + WHERE char *Signature; + WHERE char *SimpleSearch; + #if USE_SMTP +@@ -226,6 +227,9 @@ + WHERE short ScoreThresholdRead; + WHERE short ScoreThresholdFlag; + ++WHERE struct buffy_t *CurBuffy INITVAL(0); ++WHERE short DrawFullLine INITVAL(0); ++WHERE short SidebarWidth; + #ifdef USE_IMAP + WHERE short ImapKeepalive; + WHERE short ImapPipelineDepth; +diff -uNr mutt-1.5.23.nntp.xterm/imap/command.c mutt-1.5.23.nntp.xterm.sidebar/imap/command.c +--- mutt-1.5.23.nntp.xterm/imap/command.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/imap/command.c 2014-12-03 02:32:53.218123610 +0200 +@@ -1012,6 +1012,13 @@ + opened */ + status->uidnext = oldun; + ++ /* Added to make the sidebar show the correct numbers */ ++ if (status->messages) ++ { ++ inc->msgcount = status->messages; ++ inc->msg_unread = status->unseen; ++ } ++ + FREE (&value); + return; + } +diff -uNr mutt-1.5.23.nntp.xterm/imap/imap.c mutt-1.5.23.nntp.xterm.sidebar/imap/imap.c +--- mutt-1.5.23.nntp.xterm/imap/imap.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/imap/imap.c 2014-12-03 02:32:53.218123610 +0200 +@@ -1514,7 +1514,7 @@ + + imap_munge_mbox_name (munged, sizeof (munged), name); + snprintf (command, sizeof (command), +- "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged); ++ "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged); + + if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0) + { +diff -uNr mutt-1.5.23.nntp.xterm/init.h mutt-1.5.23.nntp.xterm.sidebar/init.h +--- mutt-1.5.23.nntp.xterm/init.h 2014-12-03 02:12:06.273819281 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/init.h 2014-12-03 02:32:53.218123610 +0200 +@@ -2143,6 +2143,27 @@ + ** not used. + ** (PGP only) + */ ++ {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"}, ++ /* ++ ** .pp ++ ** This specifies the delimiter between the sidebar (if visible) and ++ ** other screens. ++ */ ++ { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 }, ++ /* ++ ** .pp ++ ** This specifies whether or not to show sidebar (left-side list of folders). ++ */ ++ { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 }, ++ /* ++ ** .pp ++ ** This specifies whether or not to sort the sidebar alphabetically. ++ */ ++ { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 }, ++ /* ++ ** .pp ++ ** The width of the sidebar. ++ */ + { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0}, + /* + ** .pp +diff -uNr mutt-1.5.23.nntp.xterm/mailbox.h mutt-1.5.23.nntp.xterm.sidebar/mailbox.h +--- mutt-1.5.23.nntp.xterm/mailbox.h 2014-12-03 02:09:36.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/mailbox.h 2014-12-03 02:32:53.219123620 +0200 +@@ -27,6 +27,7 @@ + #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses + * safe_fopen() for mbox-style folders. + */ ++#define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */ + + /* mx_open_new_message() */ + #define M_ADD_FROM 1 /* add a From_ line */ +diff -uNr mutt-1.5.23.nntp.xterm/Makefile.am mutt-1.5.23.nntp.xterm.sidebar/Makefile.am +--- mutt-1.5.23.nntp.xterm/Makefile.am 2014-12-03 02:09:36.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/Makefile.am 2014-12-03 02:32:53.216123590 +0200 +@@ -32,6 +32,7 @@ + rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \ + score.c send.c sendlib.c signal.c sort.c \ + status.c system.c thread.c charset.c history.c lib.c \ ++ sidebar.c \ + muttlib.c editmsg.c mbyte.c \ + url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c + +diff -uNr mutt-1.5.23.nntp.xterm/mbox.c mutt-1.5.23.nntp.xterm.sidebar/mbox.c +--- mutt-1.5.23.nntp.xterm/mbox.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/mbox.c 2014-12-03 02:32:53.219123620 +0200 +@@ -100,6 +100,7 @@ + mutt_perror (ctx->path); + return (-1); + } ++ ctx->atime = sb.st_atime; + ctx->mtime = sb.st_mtime; + ctx->size = sb.st_size; + +@@ -251,6 +252,7 @@ + + ctx->size = sb.st_size; + ctx->mtime = sb.st_mtime; ++ ctx->atime = sb.st_atime; + + #ifdef NFS_ATTRIBUTE_HACK + if (sb.st_mtime > sb.st_atime) +diff -uNr mutt-1.5.23.nntp.xterm/menu.c mutt-1.5.23.nntp.xterm.sidebar/menu.c +--- mutt-1.5.23.nntp.xterm/menu.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/menu.c 2014-12-03 02:32:53.219123620 +0200 +@@ -24,6 +24,7 @@ + #include "mutt_curses.h" + #include "mutt_menu.h" + #include "mbyte.h" ++#include "sidebar.h" + + extern size_t UngetCount; + +@@ -186,7 +187,7 @@ + { + char *scratch = safe_strdup (s); + int shift = option (OPTARROWCURSOR) ? 3 : 0; +- int cols = COLS - shift; ++ int cols = COLS - shift - SidebarWidth; + + mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1); + s[n - 1] = 0; +@@ -239,6 +240,7 @@ + int do_color; + int attr; + ++ draw_sidebar(1); + for (i = menu->top; i < menu->top + menu->pagelen; i++) + { + if (i < menu->max) +@@ -249,7 +251,7 @@ + menu_pad_string (buf, sizeof (buf)); + + ATTRSET(attr); +- move(i - menu->top + menu->offset, 0); ++ move(i - menu->top + menu->offset, SidebarWidth); + do_color = 1; + + if (i == menu->current) +@@ -272,7 +274,7 @@ + else + { + NORMAL_COLOR; +- CLEARLINE(i - menu->top + menu->offset); ++ CLEARLINE_WIN(i - menu->top + menu->offset); + } + } + NORMAL_COLOR; +@@ -289,7 +291,7 @@ + return; + } + +- move (menu->oldcurrent + menu->offset - menu->top, 0); ++ move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth); + ATTRSET(menu->color (menu->oldcurrent)); + + if (option (OPTARROWCURSOR)) +@@ -301,13 +303,13 @@ + { + menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); + menu_pad_string (buf, sizeof (buf)); +- move (menu->oldcurrent + menu->offset - menu->top, 3); ++ move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3); + print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); + } + + /* now draw it in the new location */ + SETCOLOR(MT_COLOR_INDICATOR); +- mvaddstr(menu->current + menu->offset - menu->top, 0, "->"); ++ mvaddstr(menu->current + menu->offset - menu->top, SidebarWidth, "->"); + } + else + { +@@ -320,7 +322,7 @@ + menu_make_entry (buf, sizeof (buf), menu, menu->current); + menu_pad_string (buf, sizeof (buf)); + SETCOLOR(MT_COLOR_INDICATOR); +- move(menu->current - menu->top + menu->offset, 0); ++ move(menu->current - menu->top + menu->offset, SidebarWidth); + print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); + } + menu->redraw &= REDRAW_STATUS; +@@ -332,7 +334,7 @@ + char buf[LONG_STRING]; + int attr = menu->color (menu->current); + +- move (menu->current + menu->offset - menu->top, 0); ++ move (menu->current + menu->offset - menu->top, SidebarWidth); + menu_make_entry (buf, sizeof (buf), menu, menu->current); + menu_pad_string (buf, sizeof (buf)); + +@@ -872,7 +874,7 @@ + + + if (option (OPTARROWCURSOR)) +- move (menu->current - menu->top + menu->offset, 2); ++ move (menu->current - menu->top + menu->offset, SidebarWidth + 2); + else if (option (OPTBRAILLEFRIENDLY)) + move (menu->current - menu->top + menu->offset, 0); + else +diff -uNr mutt-1.5.23.nntp.xterm/mh.c mutt-1.5.23.nntp.xterm.sidebar/mh.c +--- mutt-1.5.23.nntp.xterm/mh.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/mh.c 2014-12-03 02:32:53.219123620 +0200 +@@ -295,6 +295,28 @@ + mhs_free_sequences (&mhs); + } + ++void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged) ++{ ++ int i; ++ struct mh_sequences mhs; ++ memset (&mhs, 0, sizeof (mhs)); ++ ++ if (mh_read_sequences (&mhs, path) < 0) ++ return; ++ ++ msgcount = 0; ++ msg_unread = 0; ++ msg_flagged = 0; ++ for (i = 0; i <= mhs.max; i++) ++ msgcount++; ++ if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) { ++ msg_unread++; ++ } ++ if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED) ++ msg_flagged++; ++ mhs_free_sequences (&mhs); ++} ++ + static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt) + { + int fd; +diff -uNr mutt-1.5.23.nntp.xterm/mutt_curses.h mutt-1.5.23.nntp.xterm.sidebar/mutt_curses.h +--- mutt-1.5.23.nntp.xterm/mutt_curses.h 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/mutt_curses.h 2014-12-03 02:32:53.219123620 +0200 +@@ -64,6 +64,7 @@ + #undef lines + #endif /* lines */ + ++#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol() + #define CLEARLINE(x) move(x,0), clrtoeol() + #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x) + #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0) +@@ -120,6 +121,8 @@ + MT_COLOR_BOLD, + MT_COLOR_UNDERLINE, + MT_COLOR_INDEX, ++ MT_COLOR_NEW, ++ MT_COLOR_FLAGGED, + MT_COLOR_MAX + }; + +diff -uNr mutt-1.5.23.nntp.xterm/mutt.h mutt-1.5.23.nntp.xterm.sidebar/mutt.h +--- mutt-1.5.23.nntp.xterm/mutt.h 2014-12-03 02:10:11.934685539 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/mutt.h 2014-12-03 02:32:53.219123620 +0200 +@@ -435,6 +435,8 @@ + OPTSAVEEMPTY, + OPTSAVENAME, + OPTSCORE, ++ OPTSIDEBAR, ++ OPTSIDEBARSORT, + OPTSIGDASHES, + OPTSIGONTOP, + OPTSORTRE, +@@ -899,6 +901,7 @@ + { + char *path; + FILE *fp; ++ time_t atime; + time_t mtime; + off_t size; + off_t vsize; +@@ -933,6 +936,7 @@ + unsigned int quiet : 1; /* inhibit status messages? */ + unsigned int collapsed : 1; /* are all threads collapsed? */ + unsigned int closing : 1; /* mailbox is being closed */ ++ unsigned int peekonly : 1; /* just taking a glance, revert atime */ + + /* driver hooks */ + void *data; /* driver specific data */ +diff -uNr mutt-1.5.23.nntp.xterm/muttlib.c mutt-1.5.23.nntp.xterm.sidebar/muttlib.c +--- mutt-1.5.23.nntp.xterm/muttlib.c 2014-12-03 02:09:36.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/muttlib.c 2014-12-03 02:32:53.219123620 +0200 +@@ -1288,6 +1288,8 @@ + pl = pw = 1; + + /* see if there's room to add content, else ignore */ ++ if ( DrawFullLine ) ++ { + if ((col < COLS && wlen < destlen) || soft) + { + int pad; +@@ -1331,6 +1333,52 @@ + col += wid; + src += pl; + } ++ } ++ else ++ { ++ if ((col < COLS-SidebarWidth && wlen < destlen) || soft) ++ { ++ int pad; ++ ++ /* get contents after padding */ ++ mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags); ++ len = mutt_strlen (buf); ++ wid = mutt_strwidth (buf); ++ ++ /* try to consume as many columns as we can, if we don't have ++ * memory for that, use as much memory as possible */ ++ pad = (COLS - SidebarWidth - col - wid) / pw; ++ if (pad > 0 && wlen + (pad * pl) + len > destlen) ++ pad = ((signed)(destlen - wlen - len)) / pl; ++ if (pad > 0) ++ { ++ while (pad--) ++ { ++ memcpy (wptr, src, pl); ++ wptr += pl; ++ wlen += pl; ++ col += pw; ++ } ++ } ++ else if (soft && pad < 0) ++ { ++ /* \0-terminate dest for length computation in mutt_wstr_trunc() */ ++ *wptr = 0; ++ /* make sure right part is at most as wide as display */ ++ len = mutt_wstr_trunc (buf, destlen, COLS, &wid); ++ /* truncate left so that right part fits completely in */ ++ wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col); ++ wptr = dest + wlen; ++ } ++ if (len + wlen > destlen) ++ len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL); ++ memcpy (wptr, buf, len); ++ wptr += len; ++ wlen += len; ++ col += wid; ++ src += pl; ++ } ++ } + break; /* skip rest of input */ + } + else if (ch == '|') +diff -uNr mutt-1.5.23.nntp.xterm/mx.c mutt-1.5.23.nntp.xterm.sidebar/mx.c +--- mutt-1.5.23.nntp.xterm/mx.c 2014-12-03 02:09:36.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/mx.c 2014-12-03 02:32:53.220123630 +0200 +@@ -601,6 +601,7 @@ + * M_APPEND open mailbox for appending + * M_READONLY open mailbox in read-only mode + * M_QUIET only print error messages ++ * M_PEEK revert atime where applicable + * ctx if non-null, context struct to use + */ + CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx) +@@ -623,6 +624,8 @@ + ctx->quiet = 1; + if (flags & M_READONLY) + ctx->readonly = 1; ++ if (flags & M_PEEK) ++ ctx->peekonly = 1; + + if (flags & (M_APPEND|M_NEWFOLDER)) + { +@@ -728,9 +731,21 @@ + void mx_fastclose_mailbox (CONTEXT *ctx) + { + int i; ++#ifndef BUFFY_SIZE ++ struct utimbuf ut; ++#endif + + if(!ctx) + return; ++#ifndef BUFFY_SIZE ++ /* fix up the times so buffy won't get confused */ ++ if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime) ++ { ++ ut.actime = ctx->atime; ++ ut.modtime = ctx->mtime; ++ utime (ctx->path, &ut); ++ } ++#endif + + /* never announce that a mailbox we've just left has new mail. #3290 + * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */ +diff -uNr mutt-1.5.23.nntp.xterm/mx.h mutt-1.5.23.nntp.xterm.sidebar/mx.h +--- mutt-1.5.23.nntp.xterm/mx.h 2014-12-03 02:09:36.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/mx.h 2014-12-03 02:32:53.220123630 +0200 +@@ -60,6 +60,7 @@ + int mh_read_dir (CONTEXT *, const char *); + int mh_sync_mailbox (CONTEXT *, int *); + int mh_check_mailbox (CONTEXT *, int *); ++void mh_buffy_update (const char *, int *, int *, int *); + int mh_check_empty (const char *); + + int maildir_read_dir (CONTEXT *); +diff -uNr mutt-1.5.23.nntp.xterm/OPS mutt-1.5.23.nntp.xterm.sidebar/OPS +--- mutt-1.5.23.nntp.xterm/OPS 2014-12-03 02:09:36.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/OPS 2014-12-03 02:32:53.217123600 +0200 +@@ -198,3 +198,8 @@ + OP_MAIN_SHOW_LIMIT "show currently active limit pattern" + OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread" + OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads" ++OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page" ++OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page" ++OP_SIDEBAR_NEXT "go down to next mailbox" ++OP_SIDEBAR_PREV "go to previous mailbox" ++OP_SIDEBAR_OPEN "open hilighted mailbox" +diff -uNr mutt-1.5.23.nntp.xterm/pager.c mutt-1.5.23.nntp.xterm.sidebar/pager.c +--- mutt-1.5.23.nntp.xterm/pager.c 2014-12-03 02:10:11.934685539 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/pager.c 2014-12-03 02:32:53.220123630 +0200 +@@ -29,6 +29,7 @@ + #include "pager.h" + #include "attach.h" + #include "mbyte.h" ++#include "sidebar.h" + + #include "mutt_crypt.h" + +@@ -1100,6 +1101,7 @@ + wchar_t wc; + mbstate_t mbstate; + int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap); ++ wrap_cols -= SidebarWidth; + + if (check_attachment_marker ((char *)buf) == 0) + wrap_cols = COLS; +@@ -1769,7 +1771,7 @@ + if ((redraw & REDRAW_BODY) || topline != oldtopline) + { + do { +- move (bodyoffset, 0); ++ move (bodyoffset, SidebarWidth); + curline = oldtopline = topline; + lines = 0; + force_redraw = 0; +@@ -1782,6 +1784,7 @@ + &QuoteList, &q_level, &force_redraw, &SearchRE) > 0) + lines++; + curline++; ++ move(lines + bodyoffset, SidebarWidth); + } + last_offset = lineInfo[curline].offset; + } while (force_redraw); +@@ -1794,6 +1797,7 @@ + addch ('~'); + addch ('\n'); + lines++; ++ move(lines + bodyoffset, SidebarWidth); + } + NORMAL_COLOR; + +@@ -1817,22 +1821,22 @@ + strfcpy(pager_progress_str, (topline == 0) ? "all" : "end", sizeof(pager_progress_str)); + + /* print out the pager status bar */ +- move (statusoffset, 0); ++ move (statusoffset, SidebarWidth); + SETCOLOR (MT_COLOR_STATUS); + + if (IsHeader (extra) || IsMsgAttach (extra)) + { +- size_t l1 = COLS * MB_LEN_MAX; ++ size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX; + size_t l2 = sizeof (buffer); + hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr; + mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT); +- mutt_paddstr (COLS, buffer); ++ mutt_paddstr (COLS-SidebarWidth, buffer); + } + else + { + char bn[STRING]; + snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str); +- mutt_paddstr (COLS, bn); ++ mutt_paddstr (COLS-SidebarWidth, bn); + } + NORMAL_COLOR; + if (option(OPTXTERMSETTITLES)) +@@ -1849,16 +1853,21 @@ + /* redraw the pager_index indicator, because the + * flags for this message might have changed. */ + menu_redraw_current (index); ++ draw_sidebar(MENU_PAGER); + + /* print out the index status bar */ + menu_status_line (buffer, sizeof (buffer), index, NONULL(Status)); + +- move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0); ++ move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth); + SETCOLOR (MT_COLOR_STATUS); +- mutt_paddstr (COLS, buffer); ++ mutt_paddstr (COLS-SidebarWidth, buffer); + NORMAL_COLOR; + } + ++ /* if we're not using the index, update every time */ ++ if ( index == 0 ) ++ draw_sidebar(MENU_PAGER); ++ + redraw = 0; + + if (option(OPTBRAILLEFRIENDLY)) { +@@ -2847,6 +2856,13 @@ + mutt_what_key (); + break; + ++ case OP_SIDEBAR_SCROLL_UP: ++ case OP_SIDEBAR_SCROLL_DOWN: ++ case OP_SIDEBAR_NEXT: ++ case OP_SIDEBAR_PREV: ++ scroll_sidebar(ch, MENU_PAGER); ++ break; ++ + default: + ch = -1; + break; +diff -uNr mutt-1.5.23.nntp.xterm/sidebar.c mutt-1.5.23.nntp.xterm.sidebar/sidebar.c +--- mutt-1.5.23.nntp.xterm/sidebar.c 1970-01-01 02:00:00.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/sidebar.c 2014-12-03 02:32:53.220123630 +0200 +@@ -0,0 +1,333 @@ ++/* ++ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> ++ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. ++ */ ++ ++ ++#if HAVE_CONFIG_H ++# include "config.h" ++#endif ++ ++#include "mutt.h" ++#include "mutt_menu.h" ++#include "mutt_curses.h" ++#include "sidebar.h" ++#include "buffy.h" ++#include <libgen.h> ++#include "keymap.h" ++#include <stdbool.h> ++ ++/*BUFFY *CurBuffy = 0;*/ ++static BUFFY *TopBuffy = 0; ++static BUFFY *BottomBuffy = 0; ++static int known_lines = 0; ++ ++static int quick_log10(int n) ++{ ++ char string[32]; ++ sprintf(string, "%d", n); ++ return strlen(string); ++} ++ ++void calc_boundaries (int menu) ++{ ++ BUFFY *tmp = Incoming; ++ ++ if ( known_lines != LINES ) { ++ TopBuffy = BottomBuffy = 0; ++ known_lines = LINES; ++ } ++ for ( ; tmp->next != 0; tmp = tmp->next ) ++ tmp->next->prev = tmp; ++ ++ if ( TopBuffy == 0 && BottomBuffy == 0 ) ++ TopBuffy = Incoming; ++ if ( BottomBuffy == 0 ) { ++ int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); ++ BottomBuffy = TopBuffy; ++ while ( --count && BottomBuffy->next ) ++ BottomBuffy = BottomBuffy->next; ++ } ++ else if ( TopBuffy == CurBuffy->next ) { ++ int count = LINES - 2 - (menu != MENU_PAGER); ++ BottomBuffy = CurBuffy; ++ tmp = BottomBuffy; ++ while ( --count && tmp->prev) ++ tmp = tmp->prev; ++ TopBuffy = tmp; ++ } ++ else if ( BottomBuffy == CurBuffy->prev ) { ++ int count = LINES - 2 - (menu != MENU_PAGER); ++ TopBuffy = CurBuffy; ++ tmp = TopBuffy; ++ while ( --count && tmp->next ) ++ tmp = tmp->next; ++ BottomBuffy = tmp; ++ } ++} ++ ++char *make_sidebar_entry(char *box, int size, int new, int flagged) ++{ ++ static char *entry = 0; ++ char *c; ++ int i = 0; ++ int delim_len = strlen(SidebarDelim); ++ ++ c = realloc(entry, SidebarWidth - delim_len + 2); ++ if ( c ) entry = c; ++ entry[SidebarWidth - delim_len + 1] = 0; ++ for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' ); ++ i = strlen(box); ++ strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) ); ++ ++ if (size == -1) ++ sprintf(entry + SidebarWidth - delim_len - 3, "?"); ++ else if ( new ) { ++ if (flagged > 0) { ++ sprintf( ++ entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged), ++ "% d(%d)[%d]", size, new, flagged); ++ } else { ++ sprintf( ++ entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new), ++ "% d(%d)", size, new); ++ } ++ } else if (flagged > 0) { ++ sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged); ++ } else { ++ sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size); ++ } ++ return entry; ++} ++ ++void set_curbuffy(char buf[LONG_STRING]) ++{ ++ BUFFY* tmp = CurBuffy = Incoming; ++ ++ if (!Incoming) ++ return; ++ ++ while(1) { ++ if(!strcmp(tmp->path, buf)) { ++ CurBuffy = tmp; ++ break; ++ } ++ ++ if(tmp->next) ++ tmp = tmp->next; ++ else ++ break; ++ } ++} ++ ++int draw_sidebar(int menu) { ++ ++ int lines = option(OPTHELP) ? 1 : 0; ++ BUFFY *tmp; ++#ifndef USE_SLANG_CURSES ++ attr_t attrs; ++#endif ++ short delim_len = strlen(SidebarDelim); ++ short color_pair; ++ ++ static bool initialized = false; ++ static int prev_show_value; ++ static short saveSidebarWidth; ++ ++ /* initialize first time */ ++ if(!initialized) { ++ prev_show_value = option(OPTSIDEBAR); ++ saveSidebarWidth = SidebarWidth; ++ if(!option(OPTSIDEBAR)) SidebarWidth = 0; ++ initialized = true; ++ } ++ ++ /* save or restore the value SidebarWidth */ ++ if(prev_show_value != option(OPTSIDEBAR)) { ++ if(prev_show_value && !option(OPTSIDEBAR)) { ++ saveSidebarWidth = SidebarWidth; ++ SidebarWidth = 0; ++ } else if(!prev_show_value && option(OPTSIDEBAR)) { ++ SidebarWidth = saveSidebarWidth; ++ } ++ prev_show_value = option(OPTSIDEBAR); ++ } ++ ++ ++// if ( SidebarWidth == 0 ) return 0; ++ if (SidebarWidth > 0 && option (OPTSIDEBAR) ++ && delim_len >= SidebarWidth) { ++ unset_option (OPTSIDEBAR); ++ /* saveSidebarWidth = SidebarWidth; */ ++ if (saveSidebarWidth > delim_len) { ++ SidebarWidth = saveSidebarWidth; ++ mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar.")); ++ sleep (2); ++ } else { ++ SidebarWidth = 0; ++ mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value.")); ++ sleep (4); /* the advise to set a sane value should be seen long enough */ ++ } ++ saveSidebarWidth = 0; ++ return (0); ++ } ++ ++ if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) { ++ if (SidebarWidth > 0) { ++ saveSidebarWidth = SidebarWidth; ++ SidebarWidth = 0; ++ } ++ unset_option(OPTSIDEBAR); ++ return 0; ++ } ++ ++ /* get attributes for divider */ ++ SETCOLOR(MT_COLOR_STATUS); ++#ifndef USE_SLANG_CURSES ++ attr_get(&attrs, &color_pair, 0); ++#else ++ color_pair = attr_get(); ++#endif ++ SETCOLOR(MT_COLOR_NORMAL); ++ ++ /* draw the divider */ ++ ++ for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { ++ move(lines, SidebarWidth - delim_len); ++ addstr(NONULL(SidebarDelim)); ++#ifndef USE_SLANG_CURSES ++ mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL); ++#endif ++ } ++ ++ if ( Incoming == 0 ) return 0; ++ lines = option(OPTHELP) ? 1 : 0; /* go back to the top */ ++ ++ if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) ++ calc_boundaries(menu); ++ if ( CurBuffy == 0 ) CurBuffy = Incoming; ++ ++ tmp = TopBuffy; ++ ++ SETCOLOR(MT_COLOR_NORMAL); ++ ++ for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) { ++ if ( tmp == CurBuffy ) ++ SETCOLOR(MT_COLOR_INDICATOR); ++ else if ( tmp->msg_unread > 0 ) ++ SETCOLOR(MT_COLOR_NEW); ++ else if ( tmp->msg_flagged > 0 ) ++ SETCOLOR(MT_COLOR_FLAGGED); ++ else ++ SETCOLOR(MT_COLOR_NORMAL); ++ ++ move( lines, 0 ); ++ if ( Context && !strcmp( tmp->path, Context->path ) ) { ++ tmp->msg_unread = Context->unread; ++ tmp->msgcount = Context->msgcount; ++ tmp->msg_flagged = Context->flagged; ++ } ++ // check whether Maildir is a prefix of the current folder's path ++ short maildir_is_prefix = 0; ++ if ( (strlen(tmp->path) > strlen(Maildir)) && ++ (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) ) ++ maildir_is_prefix = 1; ++ // calculate depth of current folder and generate its display name with indented spaces ++ int sidebar_folder_depth = 0; ++ char *sidebar_folder_name; ++ sidebar_folder_name = basename(tmp->path); ++ if ( maildir_is_prefix ) { ++ char *tmp_folder_name; ++ int i; ++ tmp_folder_name = tmp->path + strlen(Maildir); ++ for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) { ++ if (tmp_folder_name[i] == '/') sidebar_folder_depth++; ++ } ++ if (sidebar_folder_depth > 0) { ++ sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1); ++ for (i=0; i < sidebar_folder_depth; i++) ++ sidebar_folder_name[i]=' '; ++ sidebar_folder_name[i]=0; ++ strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth); ++ } ++ } ++ printw( "%.*s", SidebarWidth - delim_len + 1, ++ make_sidebar_entry(sidebar_folder_name, tmp->msgcount, ++ tmp->msg_unread, tmp->msg_flagged)); ++ if (sidebar_folder_depth > 0) ++ free(sidebar_folder_name); ++ lines++; ++ } ++ SETCOLOR(MT_COLOR_NORMAL); ++ for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { ++ int i = 0; ++ move( lines, 0 ); ++ for ( ; i < SidebarWidth - delim_len; i++ ) ++ addch(' '); ++ } ++ return 0; ++} ++ ++ ++void set_buffystats(CONTEXT* Context) ++{ ++ BUFFY *tmp = Incoming; ++ while(tmp) { ++ if(Context && !strcmp(tmp->path, Context->path)) { ++ tmp->msg_unread = Context->unread; ++ tmp->msgcount = Context->msgcount; ++ break; ++ } ++ tmp = tmp->next; ++ } ++} ++ ++void scroll_sidebar(int op, int menu) ++{ ++ if(!SidebarWidth) return; ++ if(!CurBuffy) return; ++ ++ switch (op) { ++ case OP_SIDEBAR_NEXT: ++ if ( CurBuffy->next == NULL ) return; ++ CurBuffy = CurBuffy->next; ++ break; ++ case OP_SIDEBAR_PREV: ++ if ( CurBuffy->prev == NULL ) return; ++ CurBuffy = CurBuffy->prev; ++ break; ++ case OP_SIDEBAR_SCROLL_UP: ++ CurBuffy = TopBuffy; ++ if ( CurBuffy != Incoming ) { ++ calc_boundaries(menu); ++ CurBuffy = CurBuffy->prev; ++ } ++ break; ++ case OP_SIDEBAR_SCROLL_DOWN: ++ CurBuffy = BottomBuffy; ++ if ( CurBuffy->next ) { ++ calc_boundaries(menu); ++ CurBuffy = CurBuffy->next; ++ } ++ break; ++ default: ++ return; ++ } ++ calc_boundaries(menu); ++ draw_sidebar(menu); ++} ++ +diff -uNr mutt-1.5.23.nntp.xterm/sidebar.h mutt-1.5.23.nntp.xterm.sidebar/sidebar.h +--- mutt-1.5.23.nntp.xterm/sidebar.h 1970-01-01 02:00:00.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm.sidebar/sidebar.h 2014-12-03 02:32:53.220123630 +0200 +@@ -0,0 +1,36 @@ ++/* ++ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> ++ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. ++ */ ++ ++#ifndef SIDEBAR_H ++#define SIDEBAR_H ++ ++struct MBOX_LIST { ++ char *path; ++ int msgcount; ++ int new; ++} MBLIST; ++ ++/* parameter is whether or not to go to the status line */ ++/* used for omitting the last | that covers up the status bar in the index */ ++int draw_sidebar(int); ++void scroll_sidebar(int, int); ++void set_curbuffy(char*); ++void set_buffystats(CONTEXT*); ++ ++#endif /* SIDEBAR_H */ Index: SOURCES/mutt-1.5.23-ticket-3716-dev.patch =================================================================== --- SOURCES/mutt-1.5.23-ticket-3716-dev.patch (revision 0) +++ SOURCES/mutt-1.5.23-ticket-3716-dev.patch (working copy) @@ -0,0 +1,41 @@ +# HG changeset patch +# User Kevin McCarthy <kevin@8t8.us> +# Date 1417472349 28800 +# Mon Dec 01 14:19:09 2014 -0800 +# Node ID e8e07f3c08e5e83dbeb83ace6649c05042e5ff9c +# Parent 39d3ddb56d340f66ffd0fe476003645f4cdc30bc +Change EMAIL_WSP to be space and tab (references #3716) + +This patch fixes CVE-2014-9116 in the development branch, by changing +EMAIL_WSP, skip_email_wsp(), and is_email_wsp() to define WSP as space +and tab only. + +Michael reviewed [f251d523ca5a] and the code using these functions, and +believes they all are used for unfolded headers. Furthermore, it makes +sense for WSP to match RFC5322. + +Thanks also to Antonio Radici and Tomas Hoger for their analysis and +patches to mutt, which this patch is based off of. + +diff --git a/lib.h b/lib.h +--- a/lib.h ++++ b/lib.h +@@ -93,17 +93,17 @@ + #define FMT_CENTER -1 + + #define FOREVER while (1) + + /* this macro must check for *c == 0 since isspace(0) has unreliable behavior + on some systems */ + # define SKIPWS(c) while (*(c) && isspace ((unsigned char) *(c))) c++; + +-#define EMAIL_WSP " \t\r\n" ++#define EMAIL_WSP " \t" + + /* skip over WSP as defined by RFC5322. This is used primarily for parsing + * header fields. */ + + static inline char *skip_email_wsp(const char *s) + { + if (s) + return (char *)(s + strspn(s, EMAIL_WSP)); Index: SOURCES/mutt-1.5.23-xterm-title.patch =================================================================== --- SOURCES/mutt-1.5.23-xterm-title.patch (revision 0) +++ SOURCES/mutt-1.5.23-xterm-title.patch (working copy) @@ -0,0 +1,162 @@ +diff -uNr mutt-1.5.23.nntp/curs_main.c mutt-1.5.23.nntp.xterm/curs_main.c +--- mutt-1.5.23.nntp/curs_main.c 2014-12-03 02:09:36.111330033 +0200 ++++ mutt-1.5.23.nntp.xterm/curs_main.c 2014-12-03 02:10:11.933685529 +0200 +@@ -115,6 +115,19 @@ + + extern size_t UngetCount; + ++#define ASCII_CTRL_G 0x07 ++#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b ++ ++void set_xterm_title_bar(char *title) ++{ ++ fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G); ++} ++ ++void set_xterm_icon_name(char *name) ++{ ++ fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G); ++} ++ + void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num) + { + format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX; +@@ -584,6 +597,13 @@ + mutt_paddstr (COLS, buf); + NORMAL_COLOR; + menu->redraw &= ~REDRAW_STATUS; ++ if (option(OPTXTERMSETTITLES)) ++ { ++ menu_status_line (buf, sizeof (buf), menu, NONULL (XtermTitle)); ++ set_xterm_title_bar(buf); ++ menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon)); ++ set_xterm_icon_name(buf); ++ } + } + + menu->redraw = 0; +diff -uNr mutt-1.5.23.nntp/globals.h mutt-1.5.23.nntp.xterm/globals.h +--- mutt-1.5.23.nntp/globals.h 2014-12-03 02:09:36.112330043 +0200 ++++ mutt-1.5.23.nntp.xterm/globals.h 2014-12-03 02:10:11.933685529 +0200 +@@ -152,6 +152,8 @@ + WHERE char *Tochars; + WHERE char *Username; + WHERE char *Visual; ++WHERE char *XtermTitle; ++WHERE char *XtermIcon; + + WHERE char *CurrentFolder; + WHERE char *LastFolder; +diff -uNr mutt-1.5.23.nntp/init.c mutt-1.5.23.nntp.xterm/init.c +--- mutt-1.5.23.nntp/init.c 2014-12-03 02:09:36.113330053 +0200 ++++ mutt-1.5.23.nntp.xterm/init.c 2014-12-03 02:10:11.933685529 +0200 +@@ -1818,6 +1818,26 @@ + toggle_option (MuttVars[idx].data); + else + set_option (MuttVars[idx].data); ++ ++ /* sanity check for xterm */ ++ if ((mutt_strcmp (MuttVars[idx].option, "xterm_set_titles") == 0) ++ && option (OPTXTERMSETTITLES)) ++ { ++ char *ep = getenv ("TERM"); ++ /* Make sure that the terminal can take the control codes */ ++ if (ep == NULL) unset_option (MuttVars[idx].data); ++ else if (mutt_strncasecmp (ep, "xterm", 5) && ++ mutt_strncasecmp (ep, "color-xterm", 11) && ++ mutt_strncasecmp (ep, "eterm", 5) && ++ mutt_strncasecmp (ep, "kterm", 5) && ++ mutt_strncasecmp (ep, "nxterm", 6) && ++ mutt_strncasecmp (ep, "putty", 5) && ++ mutt_strncasecmp (ep, "screen", 6) && ++ mutt_strncasecmp (ep, "cygwin", 6) && ++ mutt_strncasecmp (ep, "rxvt", 4) ) ++ unset_option (MuttVars[idx]. data); ++ ++ } + } + else if (myvar || DTYPE (MuttVars[idx].type) == DT_STR || + DTYPE (MuttVars[idx].type) == DT_PATH || +diff -uNr mutt-1.5.23.nntp/init.h mutt-1.5.23.nntp.xterm/init.h +--- mutt-1.5.23.nntp/init.h 2014-12-03 02:09:36.113330053 +0200 ++++ mutt-1.5.23.nntp.xterm/init.h 2014-12-03 02:12:06.273819281 +0200 +@@ -3629,6 +3629,27 @@ + ** name of original article author) to article that followuped to newsgroup. + */ + #endif ++ {"xterm_icon", DT_STR, R_BOTH, UL &XtermIcon, UL "M%?n?AIL&ail?"}, ++ /* ++ ** .pp ++ ** Controls the format of the icon title, as long as xterm_set_titles ++ ** is enabled. This string is identical in formatting to the one used by ++ ** ``$$status_format''. ++ */ ++ {"xterm_set_titles", DT_BOOL, R_BOTH, OPTXTERMSETTITLES, 0}, ++ /* The default must be off to force in the validity checking. */ ++ /* ++ ** .pp ++ ** Controls whether mutt sets the xterm title bar and icon name ++ ** (as long as you are in an appropriate terminal). ++ */ ++ {"xterm_title", DT_STR, R_BOTH, UL &XtermTitle, UL "Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?"}, ++ /* ++ ** .pp ++ ** Controls the format of the title bar of the xterm provided that ++ ** xterm_set_titles has been set. This string is identical in formatting ++ ** to the one used by ``$$status_format''. ++ */ + /*--*/ + { NULL, 0, 0, 0, 0 } + }; +diff -uNr mutt-1.5.23.nntp/mutt.h mutt-1.5.23.nntp.xterm/mutt.h +--- mutt-1.5.23.nntp/mutt.h 2014-12-03 02:09:36.114330063 +0200 ++++ mutt-1.5.23.nntp.xterm/mutt.h 2014-12-03 02:10:11.934685539 +0200 +@@ -463,6 +463,7 @@ + OPTWRAPSEARCH, + OPTWRITEBCC, /* write out a bcc header? */ + OPTXMAILER, ++ OPTXTERMSETTITLES, + + OPTCRYPTUSEGPGME, + OPTCRYPTUSEPKA, +diff -uNr mutt-1.5.23.nntp/mutt_menu.h mutt-1.5.23.nntp.xterm/mutt_menu.h +--- mutt-1.5.23.nntp/mutt_menu.h 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm/mutt_menu.h 2014-12-03 02:10:11.934685539 +0200 +@@ -103,6 +103,8 @@ + void menu_current_bottom (MUTTMENU *); + void menu_check_recenter (MUTTMENU *); + void menu_status_line (char *, size_t, MUTTMENU *, const char *); ++void set_xterm_title_bar (char *title); ++void set_xterm_icon_name (char *name); + + MUTTMENU *mutt_new_menu (int); + void mutt_menuDestroy (MUTTMENU **); +diff -uNr mutt-1.5.23.nntp/pager.c mutt-1.5.23.nntp.xterm/pager.c +--- mutt-1.5.23.nntp/pager.c 2014-12-03 02:09:36.116330083 +0200 ++++ mutt-1.5.23.nntp.xterm/pager.c 2014-12-03 02:10:11.934685539 +0200 +@@ -1835,6 +1835,13 @@ + mutt_paddstr (COLS, bn); + } + NORMAL_COLOR; ++ if (option(OPTXTERMSETTITLES)) ++ { ++ menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermTitle)); ++ set_xterm_title_bar(buffer); ++ menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermIcon)); ++ set_xterm_icon_name(buffer); ++ } + } + + if ((redraw & REDRAW_INDEX) && index) +diff -uNr mutt-1.5.23.nntp/status.c mutt-1.5.23.nntp.xterm/status.c +--- mutt-1.5.23.nntp/status.c 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23.nntp.xterm/status.c 2014-12-03 02:10:11.934685539 +0200 +@@ -195,6 +195,8 @@ + break; + + case 'P': ++ if (!menu) ++ break; + if (menu->top + menu->pagelen >= menu->max) + cp = menu->top ? "end" : "all"; + else Index: SOURCES/mutt-1.5.23.tar.gz.asc =================================================================== --- SOURCES/mutt-1.5.23.tar.gz.asc (revision 0) +++ SOURCES/mutt-1.5.23.tar.gz.asc (working copy) @@ -0,0 +1,17 @@ +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v2.0.18 (Darwin) + +iQIcBAABAgAGBQJTIIsiAAoJEFHk0k89vdxoVBYP/2S/E6VcqENN3JSk4y9zYdEM +8IejDRjpeASP/83Q3oZCUi6aSL8UeoRGVH7D7pIE76S5mTIyfDpeAQg/cbORc8H/ +dMnevaK6MCt2tK2GelV2t2MXo/hZIBn2EozarEcQaiEeZtuljdE2vJiCdkHkotaN +HjIR2b4fDDkGbTF/ZP+Y/VN/VOIkwUHIPzlznqGrIcvUzKqqnNLPN5w1lkiHMf6V +DZZsp4cMnVgTVaKPLTD0L5ZPXic/Xgotv6V2PjqVSkYpqUELDa+PDZ93zDe1Ezeo +1JbpodFm6WXS5DRxL6EcT+/gZLQos/RCVMqnSwaWlJqvJ59mKewEWPUxoHC0tCCA +S/nwrOhR779ZZ1y0tZHafywxlGw2f7MartK94bHDPjumAjp7Kt+PaXBiv9XohQCN +LioIgUheAg6DHs36YkWP05F29vMHU8fnK0y7RTlpAo4mvgaIlMUK+rLDe4B2xzG1 +T650ZWykUbjjBqUTc+xx1sWHYQbF/EOAG/D2HF3HwD30jjQa4mA/S/r69i9sF1xb +oWcWpbnY+0jsUYUAxorbesw0JHFx+WLxfSbjj91FdGFyPUGLGho4rPQyJnWdI4vn +Ddeuy3aQQU696MxIKzbwDEsx9kVE6ffiucedCe1qYUvYoB+pa0mEOw6opo88ZGmh +ApujO5G9POG0ZUCYXfCn +=PT0u +-----END PGP SIGNATURE----- Index: SOURCES/mutt-1.5.5.1-no-sgid.patch =================================================================== --- SOURCES/mutt-1.5.5.1-no-sgid.patch (revision 800495) +++ SOURCES/mutt-1.5.5.1-no-sgid.patch (working copy) @@ -1,14 +0,0 @@ ---- Makefile.am 2008-05-17 20:04:24.000000000 +0200 -+++ Makefile.am.oden 2008-12-15 16:05:32.000000000 +0100 -@@ -136,11 +136,6 @@ - rm -f $(DESTDIR)$(bindir)/mutt.dotlock ; \ - ln -sf $(DESTDIR)$(bindir)/mutt_dotlock $(DESTDIR)$(bindir)/mutt.dotlock ; \ - fi -- if test -f $(DESTDIR)$(bindir)/mutt_dotlock && test x@DOTLOCK_GROUP@ != x ; then \ -- chgrp @DOTLOCK_GROUP@ $(DESTDIR)$(bindir)/mutt_dotlock && \ -- chmod @DOTLOCK_PERMISSION@ $(DESTDIR)$(bindir)/mutt_dotlock || \ -- { echo "Can't fix mutt_dotlock's permissions!" >&2 ; exit 1 ; } \ -- fi - - install-data-local: - $(srcdir)/mkinstalldirs $(DESTDIR)$(sysconfdir) Index: SOURCES/mutt-1.5.5.1-xterm-title.patch =================================================================== --- SOURCES/mutt-1.5.5.1-xterm-title.patch (revision 800495) +++ SOURCES/mutt-1.5.5.1-xterm-title.patch (working copy) @@ -1,149 +0,0 @@ -diff -Naurp mutt-1.5.18/curs_main.c mutt-1.5.18.oden/curs_main.c ---- mutt-1.5.18/curs_main.c 2008-12-15 16:13:47.000000000 +0100 -+++ mutt-1.5.18.oden/curs_main.c 2008-12-15 16:13:31.000000000 +0100 -@@ -117,6 +117,19 @@ static const char *No_visible = N_("No v - - extern size_t UngetCount; - -+#define ASCII_CTRL_G 0x07 -+#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b -+ -+static void set_xterm_title_bar(char *title) -+{ -+fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G); -+} -+ -+static void set_xterm_icon_name(char *name) -+{ -+fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G); -+} -+ - void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num) - { - format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX; -@@ -598,6 +611,13 @@ int mutt_index_menu (void) - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); - menu->redraw &= ~REDRAW_STATUS; -+ if (option(OPTXTERMSETTITLES)) -+ { -+ menu_status_line (buf, sizeof (buf), menu, NONULL (XtermTitle)); -+ set_xterm_title_bar(buf); -+ menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon)); -+ set_xterm_icon_name(buf); -+ } - } - - menu->redraw = 0; -diff -Naurp mutt-1.5.18/globals.h mutt-1.5.18.oden/globals.h ---- mutt-1.5.18/globals.h 2008-12-15 16:13:47.000000000 +0100 -+++ mutt-1.5.18.oden/globals.h 2008-12-15 16:13:31.000000000 +0100 -@@ -154,6 +154,8 @@ WHERE char *Tempdir; - WHERE char *Tochars; - WHERE char *Username; - WHERE char *Visual; -+WHERE char *XtermTitle; -+WHERE char *XtermIcon; - - WHERE char *CurrentFolder; - WHERE char *LastFolder; -diff -Naurp mutt-1.5.18/init.c mutt-1.5.18.oden/init.c ---- mutt-1.5.18/init.c 2008-12-15 16:13:47.000000000 +0100 -+++ mutt-1.5.18.oden/init.c 2008-12-15 16:13:31.000000000 +0100 -@@ -1811,6 +1811,17 @@ static int parse_set (BUFFER *tmp, BUFFE - toggle_option (MuttVars[idx].data); - else - set_option (MuttVars[idx].data); -+ -+ /* sanity check for xterm */ -+ if ((mutt_strcmp (MuttVars[idx].option, "xterm_set_titles") == 0) && option -+ (OPTXTERMSETTITLES)) -+ { -+ char *ep = getenv ("TERM"); -+ /* Make sure that the terminal can take the control codes */ -+ if (ep == NULL) unset_option (MuttVars[idx].data); -+ else if (mutt_strcasecmp (ep, "xterm") != 0) unset_option (MuttVars[idx]. -+data); -+ } - } - else if (myvar || DTYPE (MuttVars[idx].type) == DT_STR || - DTYPE (MuttVars[idx].type) == DT_PATH || -diff -Naurp mutt-1.5.18/init.h mutt-1.5.18.oden/init.h ---- mutt-1.5.18/init.h 2008-12-15 16:13:47.000000000 +0100 -+++ mutt-1.5.18.oden/init.h 2008-12-15 16:13:31.000000000 +0100 -@@ -3286,6 +3286,27 @@ struct option_t MuttVars[] = { - ** name of original article author) to article that followuped to newsgroup. - */ - #endif -+ {"xterm_icon", DT_STR, R_BOTH, UL &XtermIcon, UL "M%?n?AIL&ail?"}, -+ /* -+ ** .pp -+ ** Controls the format of the icon title, as long as xterm_set_titles -+ ** is enabled. This string is identical in formatting to the one used by -+ ** ``$$status_format''. -+ */ -+ {"xterm_set_titles", DT_BOOL, R_BOTH, OPTXTERMSETTITLES, 0}, -+ /* -+ ** .pp -+ ** Controls whether mutt sets the xterm title bar and icon name -+ ** (as long as you're in an appropriate terminal). The default must -+ ** be off to force in the validity checking. -+ */ -+ {"xterm_title", DT_STR, R_BOTH, UL &XtermTitle, UL "Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?"}, -+ /* -+ ** .pp -+ ** Controls the format of the title bar of the xterm provided that -+ ** xterm_set_titles has been set. This string is identical in formatting -+ ** to the one used by ``$$status_format''. -+ */ - /*--*/ - { NULL } - }; -diff -Naurp mutt-1.5.18/mutt.h mutt-1.5.18.oden/mutt.h ---- mutt-1.5.18/mutt.h 2008-12-15 16:13:47.000000000 +0100 -+++ mutt-1.5.18.oden/mutt.h 2008-12-15 16:13:31.000000000 +0100 -@@ -477,6 +477,7 @@ enum - OPTWRAPSEARCH, - OPTWRITEBCC, /* write out a bcc header? */ - OPTXMAILER, -+ OPTXTERMSETTITLES, - - OPTCRYPTUSEGPGME, - OPTCRYPTUSEPKA, -diff -Naurp mutt-1.5.18/pager.c mutt-1.5.18.oden/pager.c ---- mutt-1.5.18/pager.c 2008-12-15 16:13:47.000000000 +0100 -+++ mutt-1.5.18.oden/pager.c 2008-12-15 16:13:31.000000000 +0100 -@@ -90,6 +90,19 @@ static HEADER *OldHdr = NULL; - break; \ - } - -+#define ASCII_CTRL_G 0x07 -+#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b -+ -+static void set_xterm_title_bar(char *title) -+{ -+ fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G); -+} -+ -+static void set_xterm_icon_name(char *name) -+{ -+ fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G); -+} -+ - struct q_class_t - { - int length; -@@ -1790,6 +1803,13 @@ mutt_pager (const char *banner, const ch - mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner); - BKGDSET (MT_COLOR_NORMAL); - SETCOLOR (MT_COLOR_NORMAL); -+ if (option(OPTXTERMSETTITLES)) -+ { -+ menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermTitle)); -+ set_xterm_title_bar(buffer); -+ menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermIcon)); -+ set_xterm_icon_name(buffer); -+ } - } - - if ((redraw & REDRAW_INDEX) && index) Index: SOURCES/patch-1.5.20.rr.compressed =================================================================== --- SOURCES/patch-1.5.20.rr.compressed (revision 800495) +++ SOURCES/patch-1.5.20.rr.compressed (working copy) @@ -1,1303 +0,0 @@ -diff -udprP mutt-1.5.20.orig/compress.c mutt-1.5.20/compress.c ---- mutt-1.5.20.orig/compress.c 1970-01-01 03:00:00.000000000 +0300 -+++ mutt-1.5.20/compress.c 2009-06-15 20:31:21.000000000 +0300 -@@ -0,0 +1,490 @@ -+/* -+ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#if HAVE_CONFIG_H -+# include "config.h" -+#endif -+ -+#include "mutt.h" -+ -+#ifdef USE_COMPRESSED -+ -+#include "mx.h" -+#include "mailbox.h" -+#include "mutt_curses.h" -+ -+#include <errno.h> -+#include <string.h> -+#include <unistd.h> -+#include <sys/stat.h> -+ -+typedef struct -+{ -+ const char *close; /* close-hook command */ -+ const char *open; /* open-hook command */ -+ const char *append; /* append-hook command */ -+ off_t size; /* size of real folder */ -+} COMPRESS_INFO; -+ -+char echo_cmd[HUGE_STRING]; -+ -+/* parameters: -+ * ctx - context to lock -+ * excl - exclusive lock? -+ * retry - should retry if unable to lock? -+ */ -+int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry) -+{ -+ int r; -+ -+ if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0) -+ ctx->locked = 1; -+ else if (retry && !excl) -+ { -+ ctx->readonly = 1; -+ return 0; -+ } -+ -+ return (r); -+} -+ -+void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp) -+{ -+ if (ctx->locked) -+ { -+ fflush (fp); -+ -+ mx_unlock_file (ctx->realpath, fileno (fp), 1); -+ ctx->locked = 0; -+ } -+} -+ -+static int is_new (const char *path) -+{ -+ return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0; -+} -+ -+static const char* find_compress_hook (int type, const char *path) -+{ -+ const char* c = mutt_find_hook (type, path); -+ return (!c || !*c) ? NULL : c; -+} -+ -+int mutt_can_read_compressed (const char *path) -+{ -+ return find_compress_hook (M_OPENHOOK, path) ? 1 : 0; -+} -+ -+/* if the file is new, we really do not append, but create, and so use -+ * close-hook, and not append-hook -+ */ -+static const char* get_append_command (const char *path, const CONTEXT* ctx) -+{ -+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; -+ return (is_new (path)) ? ci->close : ci->append; -+} -+ -+int mutt_can_append_compressed (const char *path) -+{ -+ int magic; -+ -+ if (is_new (path)) -+ return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0); -+ -+ magic = mx_get_magic (path); -+ -+ if (magic != 0 && magic != M_COMPRESSED) -+ return 0; -+ -+ return (find_compress_hook (M_APPENDHOOK, path) -+ || (find_compress_hook (M_OPENHOOK, path) -+ && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0; -+} -+ -+/* open a compressed mailbox */ -+static COMPRESS_INFO *set_compress_info (CONTEXT *ctx) -+{ -+ COMPRESS_INFO *ci; -+ -+ /* Now lets uncompress this thing */ -+ ci = safe_malloc (sizeof (COMPRESS_INFO)); -+ ctx->compressinfo = (void*) ci; -+ ci->append = find_compress_hook (M_APPENDHOOK, ctx->path); -+ ci->open = find_compress_hook (M_OPENHOOK, ctx->path); -+ ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path); -+ return ci; -+} -+ -+static void set_path (CONTEXT* ctx) -+{ -+ char tmppath[_POSIX_PATH_MAX]; -+ -+ /* Setup the right paths */ -+ ctx->realpath = ctx->path; -+ -+ /* Uncompress to /tmp */ -+ mutt_mktemp (tmppath, sizeof(tmppath)); -+ ctx->path = safe_malloc (strlen (tmppath) + 1); -+ strcpy (ctx->path, tmppath); -+} -+ -+static int get_size (const char* path) -+{ -+ struct stat sb; -+ if (stat (path, &sb) != 0) -+ return 0; -+ return (sb.st_size); -+} -+ -+static void store_size (CONTEXT* ctx) -+{ -+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; -+ ci->size = get_size (ctx->realpath); -+} -+ -+static const char * -+compresshook_format_str (char *dest, size_t destlen, size_t col, char op, -+ const char *src, const char *fmt, const char *ifstring, -+ const char *elsestring, unsigned long data, -+ format_flag flags) -+{ -+ char tmp[SHORT_STRING]; -+ -+ CONTEXT *ctx = (CONTEXT *) data; -+ switch (op) -+ { -+ case 'f': -+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); -+ snprintf (dest, destlen, tmp, ctx->realpath); -+ break; -+ case 't': -+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); -+ snprintf (dest, destlen, tmp, ctx->path); -+ break; -+ } -+ return (src); -+} -+ -+/* check that the command has both %f and %t -+ * 0 means OK, -1 means error -+ */ -+int mutt_test_compress_command (const char* cmd) -+{ -+ return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1; -+} -+ -+static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx) -+{ -+ char expanded[_POSIX_PATH_MAX]; -+ mutt_FormatString (expanded, sizeof (expanded), 0, cmd, compresshook_format_str, -+ (unsigned long) ctx, 0); -+ return safe_strdup (expanded); -+} -+ -+int mutt_check_mailbox_compressed (CONTEXT* ctx) -+{ -+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; -+ if (ci->size != get_size (ctx->realpath)) -+ { -+ FREE (&ctx->compressinfo); -+ FREE (&ctx->realpath); -+ mutt_error _("Mailbox was corrupted!"); -+ return (-1); -+ } -+ return (0); -+} -+ -+int mutt_open_read_compressed (CONTEXT *ctx) -+{ -+ char *cmd; -+ FILE *fp; -+ int rc; -+ -+ COMPRESS_INFO *ci = set_compress_info (ctx); -+ if (!ci->open) { -+ ctx->magic = 0; -+ FREE (ctx->compressinfo); -+ return (-1); -+ } -+ if (!ci->close || access (ctx->path, W_OK) != 0) -+ ctx->readonly = 1; -+ -+ set_path (ctx); -+ store_size (ctx); -+ -+ if (!ctx->quiet) -+ mutt_message (_("Decompressing %s..."), ctx->realpath); -+ -+ cmd = get_compression_cmd (ci->open, ctx); -+ if (cmd == NULL) -+ return (-1); -+ dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd)); -+ -+ if ((fp = fopen (ctx->realpath, "r")) == NULL) -+ { -+ mutt_perror (ctx->realpath); -+ FREE (&cmd); -+ return (-1); -+ } -+ mutt_block_signals (); -+ if (mbox_lock_compressed (ctx, fp, 0, 1) == -1) -+ { -+ fclose (fp); -+ mutt_unblock_signals (); -+ mutt_error _("Unable to lock mailbox!"); -+ FREE (&cmd); -+ return (-1); -+ } -+ -+ endwin (); -+ fflush (stdout); -+ sprintf(echo_cmd,_("echo Decompressing %s..."),ctx->realpath); -+ mutt_system(echo_cmd); -+ rc = mutt_system (cmd); -+ mbox_unlock_compressed (ctx, fp); -+ mutt_unblock_signals (); -+ fclose (fp); -+ -+ if (rc) -+ { -+ mutt_any_key_to_continue (NULL); -+ ctx->magic = 0; -+ FREE (ctx->compressinfo); -+ mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd); -+ } -+ FREE (&cmd); -+ if (rc) -+ return (-1); -+ -+ if (mutt_check_mailbox_compressed (ctx)) -+ return (-1); -+ -+ ctx->magic = mx_get_magic (ctx->path); -+ -+ return (0); -+} -+ -+void restore_path (CONTEXT* ctx) -+{ -+ FREE (&ctx->path); -+ ctx->path = ctx->realpath; -+} -+ -+/* remove the temporary mailbox */ -+void remove_file (CONTEXT* ctx) -+{ -+ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF) -+ remove (ctx->path); -+} -+ -+int mutt_open_append_compressed (CONTEXT *ctx) -+{ -+ FILE *fh; -+ COMPRESS_INFO *ci = set_compress_info (ctx); -+ -+ if (!get_append_command (ctx->path, ctx)) -+ { -+ if (ci->open && ci->close) -+ return (mutt_open_read_compressed (ctx)); -+ -+ ctx->magic = 0; -+ FREE (&ctx->compressinfo); -+ return (-1); -+ } -+ -+ set_path (ctx); -+ -+ ctx->magic = DefaultMagic; -+ -+ if (!is_new (ctx->realpath)) -+ if (ctx->magic == M_MBOX || ctx->magic == M_MMDF) -+ if ((fh = fopen (ctx->path, "w"))) -+ fclose (fh); -+ /* No error checking - the parent function will catch it */ -+ -+ return (0); -+} -+ -+/* close a compressed mailbox */ -+void mutt_fast_close_compressed (CONTEXT *ctx) -+{ -+ dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n", -+ ctx->path)); -+ -+ if (ctx->compressinfo) -+ { -+ if (ctx->fp) -+ fclose (ctx->fp); -+ ctx->fp = NULL; -+ /* if the folder was removed, remove the gzipped folder too */ -+ if (access (ctx->path, F_OK) != 0 && ! option (OPTSAVEEMPTY)) -+ remove (ctx->realpath); -+ else -+ remove_file (ctx); -+ -+ restore_path (ctx); -+ FREE (&ctx->compressinfo); -+ } -+} -+ -+/* return 0 on success, -1 on failure */ -+int mutt_sync_compressed (CONTEXT* ctx) -+{ -+ char *cmd; -+ int rc = 0; -+ FILE *fp; -+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; -+ -+ if (!ctx->quiet) -+ mutt_message (_("Compressing %s..."), ctx->realpath); -+ -+ cmd = get_compression_cmd (ci->close, ctx); -+ if (cmd == NULL) -+ return (-1); -+ -+ if ((fp = fopen (ctx->realpath, "a")) == NULL) -+ { -+ mutt_perror (ctx->realpath); -+ FREE (&cmd); -+ return (-1); -+ } -+ mutt_block_signals (); -+ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) -+ { -+ fclose (fp); -+ mutt_unblock_signals (); -+ mutt_error _("Unable to lock mailbox!"); -+ -+ store_size (ctx); -+ -+ FREE (&cmd); -+ return (-1); -+ } -+ -+ dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd)); -+ -+ endwin (); -+ fflush (stdout); -+ sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath); -+ mutt_system(echo_cmd); -+ if (mutt_system (cmd)) -+ { -+ mutt_any_key_to_continue (NULL); -+ mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path); -+ rc = -1; -+ } -+ -+ mbox_unlock_compressed (ctx, fp); -+ mutt_unblock_signals (); -+ fclose (fp); -+ -+ FREE (&cmd); -+ -+ store_size (ctx); -+ -+ return (rc); -+} -+ -+int mutt_slow_close_compressed (CONTEXT *ctx) -+{ -+ FILE *fp; -+ const char *append; -+ char *cmd; -+ COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; -+ -+ dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n", -+ ctx->path)); -+ -+ if (! (ctx->append -+ && ((append = get_append_command (ctx->realpath, ctx)) -+ || (append = ci->close)))) -+ { /* if we can not or should not append, -+ * we only have to remove the compressed info, because sync was already -+ * called -+ */ -+ mutt_fast_close_compressed (ctx); -+ return (0); -+ } -+ -+ if (ctx->fp) -+ fclose (ctx->fp); -+ ctx->fp = NULL; -+ -+ if (!ctx->quiet) -+ { -+ if (append == ci->close) -+ mutt_message (_("Compressing %s..."), ctx->realpath); -+ else -+ mutt_message (_("Compressed-appending to %s..."), ctx->realpath); -+ } -+ -+ cmd = get_compression_cmd (append, ctx); -+ if (cmd == NULL) -+ return (-1); -+ -+ if ((fp = fopen (ctx->realpath, "a")) == NULL) -+ { -+ mutt_perror (ctx->realpath); -+ FREE (&cmd); -+ return (-1); -+ } -+ mutt_block_signals (); -+ if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) -+ { -+ fclose (fp); -+ mutt_unblock_signals (); -+ mutt_error _("Unable to lock mailbox!"); -+ FREE (&cmd); -+ return (-1); -+ } -+ -+ dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd)); -+ -+ endwin (); -+ fflush (stdout); -+ -+ if (append == ci->close) -+ sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath); -+ else -+ sprintf(echo_cmd,_("echo Compressed-appending to %s..."), ctx->realpath); -+ mutt_system(echo_cmd); -+ -+ if (mutt_system (cmd)) -+ { -+ mutt_any_key_to_continue (NULL); -+ mutt_error (_(" %s: Error compressing mailbox! Uncompressed one kept!\n"), -+ ctx->path); -+ FREE (&cmd); -+ mbox_unlock_compressed (ctx, fp); -+ mutt_unblock_signals (); -+ fclose (fp); -+ return (-1); -+ } -+ -+ mbox_unlock_compressed (ctx, fp); -+ mutt_unblock_signals (); -+ fclose (fp); -+ remove_file (ctx); -+ restore_path (ctx); -+ FREE (&cmd); -+ FREE (&ctx->compressinfo); -+ -+ return (0); -+} -+ -+#endif /* USE_COMPRESSED */ -diff -udprP mutt-1.5.20.orig/compress.h mutt-1.5.20/compress.h ---- mutt-1.5.20.orig/compress.h 1970-01-01 03:00:00.000000000 +0300 -+++ mutt-1.5.20/compress.h 2009-06-15 20:31:21.000000000 +0300 -@@ -0,0 +1,27 @@ -+/* -+ * Copyright (C) 1997 Alain Penders <Alain@Finale-Dev.com> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+int mutt_can_read_compressed (const char *); -+int mutt_can_append_compressed (const char *); -+int mutt_open_read_compressed (CONTEXT *); -+int mutt_open_append_compressed (CONTEXT *); -+int mutt_slow_close_compressed (CONTEXT *); -+int mutt_sync_compressed (CONTEXT *); -+int mutt_test_compress_command (const char *); -+int mutt_check_mailbox_compressed (CONTEXT *); -+void mutt_fast_close_compressed (CONTEXT *); -diff -udprP mutt-1.5.20.orig/config.h.in mutt-1.5.20/config.h.in ---- mutt-1.5.20.orig/config.h.in 2009-06-09 09:51:15.000000000 +0300 -+++ mutt-1.5.20/config.h.in 2009-06-15 20:31:21.000000000 +0300 -@@ -540,6 +540,9 @@ - - /* Define to enable Sun mailtool attachments support. */ - #undef SUN_ATTACHMENT -+ -+/* The compressed mailboxes support */ -+#undef USE_COMPRESSED - - /* Define to use dotlocking for mailboxes. */ - #undef USE_DOTLOCK -diff -udprP mutt-1.5.20.orig/configure mutt-1.5.20/configure ---- mutt-1.5.20.orig/configure 2009-06-09 09:50:42.000000000 +0300 -+++ mutt-1.5.20/configure 2009-06-15 20:31:21.000000000 +0300 -@@ -1434,6 +1434,7 @@ Optional Features: - --disable-warnings Turn off compiler warnings (not recommended) - --enable-nfs-fix Work around an NFS with broken attributes caching - --enable-mailtool Enable Sun mailtool attachments support -+ --enable-compressed Enable compressed folders support - --enable-locales-fix The result of isprint() is unreliable - --enable-exact-address Enable regeneration of email addresses - --enable-hcache Enable header caching -@@ -8650,6 +8651,18 @@ $as_echo "$mutt_cv_regex_broken" >&6; } - fi - fi - -+ -+# Check whether --enable-compressed or --disable-compressed was given. -+if test "${enable_compressed+set}" = set; then -+ enableval="$enable_compressed" -+ if test x$enableval = xyes; then -+ cat >> confdefs.h <<\EOF -+#define USE_COMPRESSED 1 -+EOF -+ -+ fi -+fi -+ - if test $mutt_cv_regex = yes; then - - $as_echo "#define USE_GNU_REGEX 1" >>confdefs.h -diff -udprP mutt-1.5.20.orig/configure.ac mutt-1.5.20/configure.ac ---- mutt-1.5.20.orig/configure.ac 2009-06-09 09:50:33.000000000 +0300 -+++ mutt-1.5.20/configure.ac 2009-06-15 20:31:21.000000000 +0300 -@@ -806,6 +806,11 @@ AC_ARG_ENABLE(mailtool, AC_HELP_STRING([ - AC_DEFINE(SUN_ATTACHMENT,1,[ Define to enable Sun mailtool attachments support. ]) - fi]) - -+AC_ARG_ENABLE(compressed, AC_HELP_STRING([--enable-compressed], [Enable compressed folders support]), -+ [if test x$enableval = xyes; then -+ AC_DEFINE(USE_COMPRESSED,1,[ Define to enable compressed folders support. ]) -+ fi]) -+ - AC_ARG_ENABLE(locales-fix, AC_HELP_STRING([--enable-locales-fix], [The result of isprint() is unreliable]), - [if test x$enableval = xyes; then - AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ]) -diff -udprP mutt-1.5.20.orig/curs_main.c mutt-1.5.20/curs_main.c ---- mutt-1.5.20.orig/curs_main.c 2009-06-14 05:48:36.000000000 +0300 -+++ mutt-1.5.20/curs_main.c 2009-06-15 20:31:21.000000000 +0300 -@@ -1133,6 +1133,11 @@ int mutt_index_menu (void) - { - int check; - -+#ifdef USE_COMPRESSED -+ if (Context->compressinfo && Context->realpath) -+ mutt_str_replace (&LastFolder, Context->realpath); -+ else -+#endif - mutt_str_replace (&LastFolder, Context->path); - oldcount = Context ? Context->msgcount : 0; - -diff -udprP mutt-1.5.20.orig/doc/Makefile.am mutt-1.5.20/doc/Makefile.am ---- mutt-1.5.20.orig/doc/Makefile.am 2009-06-01 05:23:14.000000000 +0300 -+++ mutt-1.5.20/doc/Makefile.am 2009-06-15 20:33:19.000000000 +0300 -@@ -32,7 +32,8 @@ EXTRA_DIST = dotlock.man \ - - CHUNKED_DOCFILES = index.html intro.html gettingstarted.html \ - configuration.html mimesupport.html advancedusage.html \ -- optionalfeatures.html security.html tuning.html reference.html miscellany.html -+ optionalfeatures.html security.html tuning.html reference.html miscellany.html \ -+ compressed-folders.html - - HTML_DOCFILES = manual.html $(CHUNKED_DOCFILES) - -diff -udprP mutt-1.5.20.orig/doc/Makefile.in mutt-1.5.20/doc/Makefile.in ---- mutt-1.5.20.orig/doc/Makefile.in 2009-06-09 09:50:43.000000000 +0300 -+++ mutt-1.5.20/doc/Makefile.in 2009-06-15 20:34:01.000000000 +0300 -@@ -237,7 +237,8 @@ EXTRA_DIST = dotlock.man \ - - CHUNKED_DOCFILES = index.html intro.html gettingstarted.html \ - configuration.html mimesupport.html advancedusage.html \ -- optionalfeatures.html security.html tuning.html reference.html miscellany.html -+ optionalfeatures.html security.html tuning.html reference.html miscellany.html \ -+ compressed-folders.html - - HTML_DOCFILES = manual.html $(CHUNKED_DOCFILES) - BUILT_DISTFILES = stamp-doc-xml stamp-doc-chunked manual.txt $(HTML_DOCFILES) -diff -udprP mutt-1.5.20.orig/doc/manual.xml.head mutt-1.5.20/doc/manual.xml.head ---- mutt-1.5.20.orig/doc/manual.xml.head 2009-05-30 20:20:08.000000000 +0300 -+++ mutt-1.5.20/doc/manual.xml.head 2009-06-15 20:31:21.000000000 +0300 -@@ -5163,6 +5163,24 @@ patterns: - () — logical grouping operator - </para> - </listitem> -+<listitem> -+ -+<para> -+<link linkend="open-hook">open-hook</link> -+</para> -+</listitem> -+<listitem> -+ -+<para> -+<link linkend="close-hook">close-hook</link> -+</para> -+</listitem> -+<listitem> -+ -+<para> -+<link linkend="append-hook">append-hook</link> -+</para> -+</listitem> - - </itemizedlist> - -@@ -6094,6 +6112,254 @@ this selection. Highest priority has the - - </chapter> - -+<chapter id="compressed-folders"> -+<title>Compressed folders Support (OPTIONAL)</title> -+ -+<para> -+If Mutt was compiled with compressed folders support (by running the -+<emphasis>configure</emphasis> script with the -+<emphasis>--enable-compressed</emphasis> flag), Mutt can open folders -+stored in an arbitrary format, provided that the user has a script to -+convert from/to this format to one of the accepted. -+</para> -+ -+<para> -+The most common use is to open compressed archived folders e.g. with -+gzip. -+</para> -+ -+<para> -+In addition, the user can provide a script that gets a folder in an -+accepted format and appends its context to the folder in the -+user-defined format, which may be faster than converting the entire -+folder to the accepted format, appending to it and converting back to -+the user-defined format. -+</para> -+ -+<para> -+There are three hooks defined -+(<link linkend="open-hook">open-hook</link>, -+<link linkend="close-hook">close-hook</link> and -+<link linkend="append-hook">append-hook</link>) which define commands -+to uncompress and compress a folder and to append messages to an -+existing compressed folder respectively. -+</para> -+ -+<para> -+For example: -+ -+<screen> -+open-hook \\.gz$ "gzip -cd %f > %t" -+close-hook \\.gz$ "gzip -c %t > %f" -+append-hook \\.gz$ "gzip -c %t >> %f" -+</screen> -+</para> -+ -+<para> -+You do not have to specify all of the commands. If you omit -+<link linkend="append-hook">append-hook</link>, the folder will be open -+and closed again each time you will add to it. If you omit -+<link linkend="close-hook">close-hook</link> (or give empty command), -+the folder will be open in the mode. If you specify -+<link linkend="append-hook">append-hook</link> though you'll be able to -+append to the folder. -+</para> -+ -+<para> -+Note that Mutt will only try to use hooks if the file is not in one of -+the accepted formats. In particular, if the file is empty, mutt -+supposes it is not compressed. This is important because it allows the -+use of programs that do not have well defined extensions. Just use -+``.'' as a regexp. But this may be surprising if your compressing -+script produces empty files. In this situation, unset -+<link linkend="save-empty">$save_empty</link>, so that -+the compressed file will be removed if you delete all of the messages. -+</para> -+ -+<sect1 id="open-hook"> -+<title>Open a compressed mailbox for reading</title> -+ -+<para> -+Usage: <literal>open-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis> -+</para> -+ -+<para> -+The <emphasis>command</emphasis> is the command that can be used for -+opening the folders whose names match <emphasis>regexp</emphasis>. -+</para> -+ -+<para> -+The <emphasis>command</emphasis> string is the printf-like format -+string, and it should accept two parameters: %f, which is -+replaced with the (compressed) folder name, and %t which is -+replaced with the name of the temporary folder to which to write. -+</para> -+ -+<para> -+%f and %t can be repeated any number of times in the -+command string, and all of the entries are replaced with the -+appropriate folder name. In addition, %% is replaced by -+%, as in printf, and any other %anything is left as is. -+</para> -+ -+<para> -+The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis> -+remove the original compressed file. The <emphasis>command</emphasis> -+should return non-zero exit status if it fails, so mutt knows -+something's wrong. -+</para> -+ -+<para> -+Example: -+ -+<screen> -+open-hook \\.gz$ "gzip -cd %f > %t" -+</screen> -+</para> -+ -+<para> -+If the <emphasis>command</emphasis> is empty, this operation is -+disabled for this file type. -+</para> -+ -+</sect1> -+ -+<sect1 id="close-hook"> -+<title>Write a compressed mailbox</title> -+ -+<para> -+Usage: <literal>close-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis> -+</para> -+ -+<para> -+This is used to close the folder that was open with the -+<link linkend="open-hook">open-hook</link> command after some changes -+were made to it. -+</para> -+ -+<para> -+The <emphasis>command</emphasis> string is the command that can be -+used for closing the folders whose names match <emphasis>regexp</emphasis>. -+It has the same format as in the <link linkend="open-hook">open-hook</link> -+command. Temporary folder in this case is the folder previously -+produced by the <link linkend="open-hook">open-hook</link> command. -+</para> -+ -+<para> -+The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis> -+remove the decompressed file. The <emphasis>command</emphasis> should -+return non-zero exit status if it fails, so mutt knows something's -+wrong. -+</para> -+ -+<para> -+Example: -+ -+<screen> -+close-hook \\.gz$ "gzip -c %t > %f" -+</screen> -+</para> -+ -+<para> -+If the <emphasis>command</emphasis> is empty, this operation is -+disabled for this file type, and the file can only be open in the -+readonly mode. -+</para> -+ -+<para> -+<link linkend="close-hook">close-hook</link> is not called when you -+exit from the folder if the folder was not changed. -+</para> -+ -+</sect1> -+ -+<sect1 id="append-hook"> -+<title>Append a message to a compressed mailbox</title> -+ -+<para> -+Usage: <literal>append-hook</literal> <emphasis>regexp</emphasis> <emphasis>command</emphasis> -+</para> -+ -+<para> -+This command is used for saving to an existing compressed folder. -+The <emphasis>command</emphasis> is the command that can be used for -+appending to the folders whose names match <emphasis>regexp</emphasis>. -+It has the same format as in the <link linkend="open-hook">open-hook</link> -+command. The temporary folder in this case contains the messages that -+are being appended. -+</para> -+ -+<para> -+The <emphasis>command</emphasis> should <emphasis role="bold">not</emphasis> -+remove the decompressed file. The <emphasis>command</emphasis> should -+return non-zero exit status if it fails, so mutt knows something's -+wrong. -+</para> -+ -+<para> -+Example: -+ -+<screen> -+append-hook \\.gz$ "gzip -c %t >> %f" -+</screen> -+</para> -+ -+<para> -+When <link linkend="append-hook">append-hook</link> is used, the folder -+is not opened, which saves time, but this means that we can not find -+out what the folder type is. Thus the default -+(<link linkend="mbox-type">$mbox_type</link>) type is -+always supposed (i.e. this is the format used for the temporary -+folder). -+</para> -+ -+<para> -+If the file does not exist when you save to it, -+<link linkend="close-hook">close-hook</link> is called, and not -+<link linkend="append-hook">append-hook</link>. -+<link linkend="append-hook">append-hook</link> is only for appending -+to existing folders. -+</para> -+ -+<para> -+If the <emphasis>command</emphasis> is empty, this operation is -+disabled for this file type. In this case, the folder will be open and -+closed again (using <link linkend="open-hook">open-hook</link> and -+<link linkend="close-hook">close-hook</link> respectively) each time -+you will add to it. -+</para> -+ -+</sect1> -+ -+<sect1> -+<title>Encrypted folders</title> -+ -+<para> -+The compressed folders support can also be used to handle encrypted -+folders. If you want to encrypt a folder with PGP, you may want to use -+the following hooks: -+ -+<screen> -+open-hook \\.pgp$ "pgp -f < %f > %t" -+close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f" -+</screen> -+</para> -+ -+<para> -+Please note, that PGP does not support appending to an encrypted -+folder, so there is no append-hook defined. -+</para> -+ -+<para> -+<emphasis role="bold">Note:</emphasis> the folder is temporary stored -+decrypted in the /tmp directory, where it can be read by your system -+administrator. So think about the security aspects of this. -+</para> -+ -+</sect1> -+ -+</chapter> -+ - <chapter id="mimesupport"> - <title>Mutt's MIME Support</title> - -@@ -8428,6 +8694,18 @@ The following are the commands understoo - - <listitem> - <cmdsynopsis> -+<command><link linkend="append-hook">append-hook</link></command> -+<arg choice="plain"> -+<replaceable class="parameter">pattern</replaceable> -+</arg> -+<arg choice="plain"> -+<replaceable class="parameter">command</replaceable> -+</arg> -+</cmdsynopsis> -+</listitem> -+ -+<listitem> -+<cmdsynopsis> - <command><link linkend="auto-view">auto_view</link></command> - <arg choice="plain"> - <replaceable>mimetype</replaceable> -@@ -8489,6 +8755,18 @@ The following are the commands understoo - - <listitem> - <cmdsynopsis> -+<command><link linkend="close-hook">close-hook</link></command> -+<arg choice="plain"> -+<replaceable class="parameter">pattern</replaceable> -+</arg> -+<arg choice="plain"> -+<replaceable class="parameter">command</replaceable> -+</arg> -+</cmdsynopsis> -+</listitem> -+ -+<listitem> -+<cmdsynopsis> - <command><link linkend="color">color</link></command> - <arg choice="plain"> - <replaceable class="parameter">object</replaceable> -@@ -8558,6 +8836,18 @@ The following are the commands understoo - - <listitem> - <cmdsynopsis> -+<command><link linkend="open-hook">open-hook</link></command> -+<arg choice="plain"> -+<replaceable class="parameter">pattern</replaceable> -+</arg> -+<arg choice="plain"> -+<replaceable class="parameter">command</replaceable> -+</arg> -+</cmdsynopsis> -+</listitem> -+ -+<listitem> -+<cmdsynopsis> - <command><link linkend="crypt-hook">crypt-hook</link></command> - <arg choice="plain"> - <replaceable class="parameter">pattern</replaceable> -diff -udprP mutt-1.5.20.orig/doc/Muttrc.head mutt-1.5.20/doc/Muttrc.head ---- mutt-1.5.20.orig/doc/Muttrc.head 2008-11-11 21:55:46.000000000 +0200 -+++ mutt-1.5.20/doc/Muttrc.head 2009-06-15 20:31:21.000000000 +0300 -@@ -29,6 +29,11 @@ macro generic,pager <F1> "<shell-escape> - macro index,pager y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list" - bind browser y exit - -+# Use folders which match on \\.gz$ as gzipped folders: -+# open-hook \\.gz$ "gzip -cd %f > %t" -+# close-hook \\.gz$ "gzip -c %t > %f" -+# append-hook \\.gz$ "gzip -c %t >> %f" -+ - # If Mutt is unable to determine your site's domain name correctly, you can - # set the default here. - # -diff -udprP mutt-1.5.20.orig/doc/muttrc.man.head mutt-1.5.20/doc/muttrc.man.head ---- mutt-1.5.20.orig/doc/muttrc.man.head 2009-04-13 19:24:55.000000000 +0300 -+++ mutt-1.5.20/doc/muttrc.man.head 2009-06-15 20:31:21.000000000 +0300 -@@ -346,6 +346,24 @@ specify the ID of the public key to be u - to a certain recipient. The meaning of "key ID" is to be taken - broadly: This can be a different e-mail address, a numerical key ID, - or even just an arbitrary search string. -+.PP -+.nf -+\fBopen-hook\fP \fIregexp\fP "\fIcommand\fP" -+\fBclose-hook\fP \fIregexp\fP "\fIcommand\fP" -+\fBappend-hook\fP \fIregexp\fP "\fIcommand\fP" -+.fi -+.IP -+These commands provide a way to handle compressed folders. The given -+\fBregexp\fP specifies which folders are taken as compressed (e.g. -+"\fI\\\\.gz$\fP"). The commands tell Mutt how to uncompress a folder -+(\fBopen-hook\fP), compress a folder (\fBclose-hook\fP) or append a -+compressed mail to a compressed folder (\fBappend-hook\fP). The -+\fIcommand\fP string is the -+.BR printf (3) -+like format string, and it should accept two parameters: \fB%f\fP, -+which is replaced with the (compressed) folder name, and \fB%t\fP -+which is replaced with the name of the temporary folder to which to -+write. - .TP - \fBpush\fP \fIstring\fP - This command adds the named \fIstring\fP to the keyboard buffer. -diff -udprP mutt-1.5.20.orig/hook.c mutt-1.5.20/hook.c ---- mutt-1.5.20.orig/hook.c 2009-01-13 16:47:49.000000000 +0200 -+++ mutt-1.5.20/hook.c 2009-06-15 20:31:21.000000000 +0300 -@@ -24,6 +24,10 @@ - #include "mailbox.h" - #include "mutt_crypt.h" - -+#ifdef USE_COMPRESSED -+#include "compress.h" -+#endif -+ - #include <limits.h> - #include <string.h> - #include <stdlib.h> -@@ -92,6 +96,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER - memset (&pattern, 0, sizeof (pattern)); - pattern.data = safe_strdup (path); - } -+#ifdef USE_COMPRESSED -+ else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK)) -+ { -+ if (mutt_test_compress_command (command.data)) -+ { -+ strfcpy (err->data, _("bad formatted command string"), err->dsize); -+ return (-1); -+ } -+ } -+#endif - else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ICONVHOOK | M_ACCOUNTHOOK)) - && (!WithCrypto || !(data & M_CRYPTHOOK)) - ) -diff -udprP mutt-1.5.20.orig/init.h mutt-1.5.20/init.h ---- mutt-1.5.20.orig/init.h 2009-06-14 00:35:21.000000000 +0300 -+++ mutt-1.5.20/init.h 2009-06-15 20:31:21.000000000 +0300 -@@ -3486,6 +3486,11 @@ struct command_t Commands[] = { - { "fcc-hook", mutt_parse_hook, M_FCCHOOK }, - { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK }, - { "folder-hook", mutt_parse_hook, M_FOLDERHOOK }, -+#ifdef USE_COMPRESSED -+ { "open-hook", mutt_parse_hook, M_OPENHOOK }, -+ { "close-hook", mutt_parse_hook, M_CLOSEHOOK }, -+ { "append-hook", mutt_parse_hook, M_APPENDHOOK }, -+#endif - { "group", parse_group, M_GROUP }, - { "ungroup", parse_group, M_UNGROUP }, - { "hdr_order", parse_list, UL &HeaderOrderList }, -diff -udprP mutt-1.5.20.orig/main.c mutt-1.5.20/main.c ---- mutt-1.5.20.orig/main.c 2009-06-01 19:29:32.000000000 +0300 -+++ mutt-1.5.20/main.c 2009-06-15 20:31:21.000000000 +0300 -@@ -310,6 +310,12 @@ static void show_version (void) - "-USE_GNU_REGEX " - #endif - -+#ifdef USE_COMPRESSED -+ "+COMPRESSED " -+#else -+ "-COMPRESSED " -+#endif -+ - "\n" - - #ifdef HAVE_COLOR -diff -udprP mutt-1.5.20.orig/Makefile.am mutt-1.5.20/Makefile.am ---- mutt-1.5.20.orig/Makefile.am 2009-01-05 04:11:29.000000000 +0200 -+++ mutt-1.5.20/Makefile.am 2009-06-15 20:31:21.000000000 +0300 -@@ -22,6 +22,7 @@ BUILT_SOURCES = keymap_defs.h patchlist. - bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@ - mutt_SOURCES = \ - addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \ -+ compress.c \ - crypt.c cryptglue.c \ - commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \ - edit.c enter.c flags.c init.c filter.c from.c \ -@@ -62,6 +63,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c - - EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \ - configure account.h \ -+ compress.h \ - attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \ - globals.h hash.h history.h init.h keymap.h mutt_crypt.h \ - mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \ -diff -udprP mutt-1.5.20.orig/Makefile.in mutt-1.5.20/Makefile.in ---- mutt-1.5.20.orig/Makefile.in 2009-06-09 09:50:44.000000000 +0300 -+++ mutt-1.5.20/Makefile.in 2009-06-15 20:31:21.000000000 +0300 -@@ -15,6 +15,10 @@ - - @SET_MAKE@ - -+mutt_SOURCES += compress.c -+EXTRA_DIST += compress.h -+mutt_OBJECTS += compress.o -+ - - VPATH = @srcdir@ - pkgdatadir = $(datadir)/@PACKAGE@ -diff -udprP mutt-1.5.20.orig/mbox.c mutt-1.5.20/mbox.c ---- mutt-1.5.20.orig/mbox.c 2009-06-11 07:29:41.000000000 +0300 -+++ mutt-1.5.20/mbox.c 2009-06-15 20:31:21.000000000 +0300 -@@ -29,6 +29,10 @@ - #include "copy.h" - #include "mutt_curses.h" - -+#ifdef USE_COMPRESSED -+#include "compress.h" -+#endif -+ - #include <sys/stat.h> - #include <dirent.h> - #include <string.h> -@@ -1070,6 +1074,12 @@ bail: /* Come here in case of disaster - int mbox_close_mailbox (CONTEXT *ctx) - { - mx_unlock_file (ctx->path, fileno (ctx->fp), 1); -+ -+#ifdef USE_COMPRESSED -+ if (ctx->compressinfo) -+ mutt_slow_close_compressed (ctx); -+#endif -+ - mutt_unblock_signals (); - mx_fastclose_mailbox (ctx); - return 0; -diff -udprP mutt-1.5.20.orig/mutt.h mutt-1.5.20/mutt.h ---- mutt-1.5.20.orig/mutt.h 2009-06-13 01:15:42.000000000 +0300 -+++ mutt-1.5.20/mutt.h 2009-06-15 20:31:21.000000000 +0300 -@@ -146,6 +146,11 @@ typedef enum - #define M_ACCOUNTHOOK (1<<9) - #define M_REPLYHOOK (1<<10) - #define M_SEND2HOOK (1<<11) -+#ifdef USE_COMPRESSED -+#define M_OPENHOOK (1<<12) -+#define M_APPENDHOOK (1<<13) -+#define M_CLOSEHOOK (1<<14) -+#endif - - /* tree characters for linearize_tree and print_enriched_string */ - #define M_TREE_LLCORNER 1 -@@ -885,6 +890,11 @@ typedef struct _context - - unsigned char rights[(RIGHTSMAX + 7)/8]; /* ACL bits */ - -+#ifdef USE_COMPRESSED -+ void *compressinfo; /* compressed mbox module private data */ -+ char *realpath; /* path to compressed mailbox */ -+#endif /* USE_COMPRESSED */ -+ - unsigned int locked : 1; /* is the mailbox locked? */ - unsigned int changed : 1; /* mailbox has been modified */ - unsigned int readonly : 1; /* don't allow changes to the mailbox */ -diff -udprP mutt-1.5.20.orig/mx.c mutt-1.5.20/mx.c ---- mutt-1.5.20.orig/mx.c 2009-06-11 07:29:41.000000000 +0300 -+++ mutt-1.5.20/mx.c 2009-06-15 20:31:21.000000000 +0300 -@@ -30,6 +30,10 @@ - #include "keymap.h" - #include "url.h" - -+#ifdef USE_COMPRESSED -+#include "compress.h" -+#endif -+ - #ifdef USE_IMAP - #include "imap.h" - #endif -@@ -414,6 +418,11 @@ int mx_get_magic (const char *path) - return (-1); - } - -+#ifdef USE_COMPRESSED -+ if (magic == 0 && mutt_can_read_compressed (path)) -+ return M_COMPRESSED; -+#endif -+ - return (magic); - } - -@@ -453,6 +462,13 @@ static int mx_open_mailbox_append (CONTE - { - struct stat sb; - -+#ifdef USE_COMPRESSED -+ /* special case for appending to compressed folders - -+ * even if we can not open them for reading */ -+ if (mutt_can_append_compressed (ctx->path)) -+ mutt_open_append_compressed (ctx); -+#endif -+ - ctx->append = 1; - - #ifdef USE_IMAP -@@ -617,6 +633,11 @@ CONTEXT *mx_open_mailbox (const char *pa - - ctx->magic = mx_get_magic (path); - -+#ifdef USE_COMPRESSED -+ if (ctx->magic == M_COMPRESSED) -+ mutt_open_read_compressed (ctx); -+#endif -+ - if(ctx->magic == 0) - mutt_error (_("%s is not a mailbox."), path); - -@@ -721,6 +742,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx) - mutt_free_header (&ctx->hdrs[i]); - FREE (&ctx->hdrs); - FREE (&ctx->v2r); -+#ifdef USE_COMPRESSED -+ if (ctx->compressinfo) -+ mutt_fast_close_compressed (ctx); -+#endif - FREE (&ctx->path); - FREE (&ctx->pattern); - if (ctx->limit_pattern) -@@ -773,6 +798,12 @@ static int sync_mailbox (CONTEXT *ctx, i - - if (tmp && tmp->new == 0) - mutt_update_mailbox (tmp); -+ -+#ifdef USE_COMPRESSED -+ if (rc == 0 && ctx->compressinfo) -+ return mutt_sync_compressed (ctx); -+#endif -+ - return rc; - } - -@@ -981,6 +1012,11 @@ int mx_close_mailbox (CONTEXT *ctx, int - !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY)) - mx_unlink_empty (ctx->path); - -+#ifdef USE_COMPRESSED -+ if (ctx->compressinfo && mutt_slow_close_compressed (ctx)) -+ return (-1); -+#endif -+ - mx_fastclose_mailbox (ctx); - - return 0; -@@ -1293,6 +1329,11 @@ int mx_check_mailbox (CONTEXT *ctx, int - { - int rc; - -+#ifdef USE_COMPRESSED -+ if (ctx->compressinfo) -+ return mutt_check_mailbox_compressed (ctx); -+#endif -+ - if (ctx) - { - if (ctx->locked) lock = 0; -diff -udprP mutt-1.5.20.orig/mx.h mutt-1.5.20/mx.h ---- mutt-1.5.20.orig/mx.h 2008-11-11 21:55:47.000000000 +0200 -+++ mutt-1.5.20/mx.h 2009-06-15 20:31:21.000000000 +0300 -@@ -36,6 +36,9 @@ enum - M_MAILDIR, - M_IMAP, - M_POP -+#ifdef USE_COMPRESSED -+ , M_COMPRESSED -+#endif - }; - - WHERE short DefaultMagic INITVAL (M_MBOX); -diff -udprP mutt-1.5.20.orig/PATCHES mutt-1.5.20/PATCHES ---- mutt-1.5.20.orig/PATCHES 2008-11-11 21:55:46.000000000 +0200 -+++ mutt-1.5.20/PATCHES 2009-06-15 20:31:21.000000000 +0300 -@@ -0,0 +1 @@ -+rr.compressed -diff -udprP mutt-1.5.20.orig/po/POTFILES.in mutt-1.5.20/po/POTFILES.in ---- mutt-1.5.20.orig/po/POTFILES.in 2008-11-11 21:55:47.000000000 +0200 -+++ mutt-1.5.20/po/POTFILES.in 2009-06-15 20:31:21.000000000 +0300 -@@ -8,6 +8,7 @@ charset.c - color.c - commands.c - compose.c -+compress.c - crypt-gpgme.c - crypt.c - cryptglue.c -diff -udprP mutt-1.5.20.orig/status.c mutt-1.5.20/status.c ---- mutt-1.5.20.orig/status.c 2009-01-05 01:14:53.000000000 +0200 -+++ mutt-1.5.20/status.c 2009-06-15 20:31:21.000000000 +0300 -@@ -96,6 +96,14 @@ status_format_str (char *buf, size_t buf - - case 'f': - snprintf (fmt, sizeof(fmt), "%%%ss", prefix); -+#ifdef USE_COMPRESSED -+ if (Context && Context->compressinfo && Context->realpath) -+ { -+ strfcpy (tmp, Context->realpath, sizeof (tmp)); -+ mutt_pretty_mailbox (tmp, sizeof (tmp)); -+ } -+ else -+#endif - if (Context && Context->path) - { - strfcpy (tmp, Context->path, sizeof (tmp)); Index: SOURCES/patch-1.5.20.vvv.nntp =================================================================== --- SOURCES/patch-1.5.20.vvv.nntp (revision 800495) +++ SOURCES/patch-1.5.20.vvv.nntp (working copy) @@ -1,7566 +0,0 @@ -WARNING: Run the following script before configure: - -aclocal -I m4 -autoheader -automake --foreign -autoconf - --- -Vsevolod Volkov <vvv@mutt.org.ua> - - -diff -udprP mutt-1.5.20.orig/ChangeLog.nntp mutt-1.5.20/ChangeLog.nntp ---- mutt-1.5.20.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300 -+++ mutt-1.5.20/ChangeLog.nntp 2009-06-15 21:56:06.000000000 +0300 -@@ -0,0 +1,369 @@ -+* Tue Jun 15 2009 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.20 -+ -+* Tue Mar 20 2009 Vsevolod Volkov <vvv@mutt.org.ua> -+- save Date: header of recorded outgoing articles -+ -+* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.19 -+ -+* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.18 -+- fixed SIGSEGV when followup or forward to newsgroup -+ -+* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.17 -+ -+* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua> -+- fixed arguments of nntp_format_str() -+ -+* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua> -+- fixed error selecting news group -+ -+* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.16 -+ -+* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua> -+- fixed posting error if $smtp_url is set -+- added support of print-style sequence %R (x-comment-to) -+ -+* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.15 -+- nntp://... url changed to news://... -+- added indicator of fetching descriptions progress -+ -+* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.14 -+ -+* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.13 -+ -+* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.12 -+- fixed reading empty .newsrc -+ -+* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.11 -+ -+* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.10 -+ -+* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.9 -+ -+* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.8 -+ -+* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.7 -+- function mutt_update_list_file() moved to newsrc.c and changed algorithm -+ -+* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua> -+- fixed error in nntp_logout_all() -+ -+* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua> -+- fixed debug output in mutt_newsrc_update() -+- added optional support of LISTGROUP command -+- fixed typo in nntp_parse_xref() -+ -+* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.6 -+ -+* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua> -+- fixed compose menu -+ -+* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.5.1 -+ -+* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.5 -+- added space after newsgroup name in .newsrc file -+ -+* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua> -+- nntp patch: fixed SIGSEGV when posting article -+ -+* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.4 -+ -+* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.3 -+- replace safe_free calls by the FREE macro -+ -+* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.2 -+- nntp authentication can be passed after any command -+ -+* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.5.1 -+ -+* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.99 -+ -+* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.28 -+- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>, -+ <reconstruct-thread> functions -+- fixed message about nntp reconnect -+- fixed <attach-news-message> function using browser -+- added support of Followup-To: poster -+- added %n (new articles) in group_index_format -+- posting articles without inews by default -+ -+* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.27 -+ -+* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.26 -+ -+* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.25 -+- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>) -+- added default content disposition -+ -+* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.24 -+ -+* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.23.2 -+- fixed segfault if mutt_conn_find() returns null -+ -+* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.23.1 -+- added support of LISTGROUP command -+- added support for servers with broken overview -+- disabled <flag-message> function on news server -+- fixed error storing bad authentication information -+ -+* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.23 -+- fixed typo in buffy.c -+- added substitution of %s parameter in $inews variable -+ -+* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.22.1 -+- update to 1.3.22 -+ -+* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.21 -+ -+* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.20 -+- removed 'server-hook', use 'account-hook' instead -+- fixed error opening NNTP server without newsgroup using -f option -+ -+* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.19 -+ -+* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.18 -+- fixed typo in nntp_attempt_features() -+- changed algorithm of XGTITLE command testing -+- disabled writing of NNTP password in debug file -+- fixed reading and writing of long newsrc lines -+- changed checking of last line while reading lines from server -+- fixed possible buffer overrun in nntp_parse_newsrc_line() -+- removed checking of XHDR command -+- compare NNTP return codes without trailing space -+ -+* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.17 -+- support for 'LIST NEWSGROUPS' command to read descriptions -+ -+* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.16 -+ -+* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.15 -+ -+* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.14 -+- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de> -+ -+* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.13 -+ -+* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua> -+- Fixed problem if last article in group is deleted -+ -+* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua> -+- Fixed checking of XGTITLE command on some servers -+ -+* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua> -+- Added \r in AUTHINFO commands -+ -+* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.12 -+ -+* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.11 -+- fixed error opening newsgroup from mutt started with -g or -G -+ -+* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.10 -+- hotkey 'G' (get-message) replaced with '^G' -+ -+* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.9 -+- changed delay displaying error messages from 1 to 2 seconds -+- fixed error compiling with nntp and without imap -+ -+* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua> -+- fixed catchup in index -+- fixed nntp_open_mailbox() -+ -+* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua> -+- functions <edit> and <delete-entry> disabled -+- format of news mailbox names changed to url form -+- option nntp_attempts removed -+- option reconnect_news renamed to nntp_reconnect -+- default value of nntp_poll changed from 30 to 60 -+- error handling improved -+ -+* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua> -+- update to 1.3.8 -+- new option show_only_unread -+- add newsgroup completion -+ -+* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.3.7 -+ -+* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.3.6 -+ -+* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.3.5 -+- authentication code update -+- fix for changing to newsgroup from mailbox with read messages -+- socket code optimization -+ -+* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.3.4 -+ -+* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- don't substitute current newsgroup with deleted new messages -+ -+* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.3.3 -+- fix for substitution of newsgroup after reconnection -+- fix for loading newsgroups with very long names -+- fix for loading more than 32768 newsgroups -+ -+* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.3.2 -+ -+* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.3.1 -+ -+* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.3 -+ -+* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.2 -+ -+* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.1.14 -+ -+* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.1.12 -+ -+* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- add substitution of newsgroup with new messages by default -+ -+* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- add attach message from newsgroup -+- add one-line help in newsreader mode -+- disable 'change-dir' command in newsgroups browser -+- add -G option -+ -+* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- get default newsserver name from file /etc/nntpserver -+- use case insensitive server names -+- add print-style sequence %s to $newsrc -+- add -g option -+ -+* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- remove 'X-FTN-Origin' header processing -+ -+* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.1.11 -+- update to 1.1.10 -+ -+* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- fix mutt_select_newsserver() -+- remove 'toggle-mode' function -+- add 'change-newsgroup' function -+ -+* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- fix server-hook -+ -+* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- fix error 'bounce' function after 'post' -+- add 'forward to newsgroup' function -+ -+* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- 'forward' function works in newsreader mode -+- add 'post' and 'followup' functions to pager and attachment menu -+- fix active descriptions and allowed flag reload -+ -+* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.1.9 -+- remove deleted newsgroups from list -+ -+* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update .newsrc in browser -+ -+* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- reload .newsrc if externally modified -+- fix active cache update -+ -+* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.1.8 -+ -+* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- patch *.update_list_file is not required -+- count lines when loading descriptions -+- remove cache of unsubscribed newsgroups -+ -+* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- load list of newsgroups from cache faster -+ -+* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.1.7 -+ -+* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- fix unread messages in browser -+- fix newsrc_gen_entries() -+ -+* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- fix mutt_newsgroup_stat() -+- fix nntp_delete_cache() -+- fix nntp_get_status() -+- fix check_children() -+- fix nntp_fetch_headers() -+ -+* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.1.5 -+ -+* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- fix updating new messages in cache -+ -+* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- change default cache filenames -+- fix updating new messages in cache -+ -+* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- fix segmentation fault in news groups browser -+ -+* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.1.4 -+ -+* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.1.3 -+ -+* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- add X-Comment-To editing -+- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers -+- add variables $ask_followup_to and $ask_x_comment_to -+ -+* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> -+- update to 1.1.2 -diff -udprP mutt-1.5.20.orig/OPS mutt-1.5.20/OPS ---- mutt-1.5.20.orig/OPS 2009-05-13 08:01:13.000000000 +0300 -+++ mutt-1.5.20/OPS 2009-06-15 21:05:24.000000000 +0300 -@@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a - OP_BROWSER_NEW_FILE "select a new file in this directory" - OP_BROWSER_VIEW_FILE "view file" - OP_BROWSER_TELL "display the currently selected file's name" --OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)" --OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)" -+OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)" -+OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)" - OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)" - OP_BUFFY_LIST "list mailboxes with new mail" -+OP_CATCHUP "mark all articles in newsgroup as read" - OP_CHANGE_DIRECTORY "change directories" - OP_CHECK_NEW "check mailboxes for new mail" - OP_COMPOSE_ATTACH_FILE "attach file(s) to this message" - OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message" -+OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message" - OP_COMPOSE_EDIT_BCC "edit the BCC list" - OP_COMPOSE_EDIT_CC "edit the CC list" - OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description" -@@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel - OP_COMPOSE_EDIT_HEADERS "edit the message with headers" - OP_COMPOSE_EDIT_MESSAGE "edit the message" - OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry" -+OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list" - OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field" -+OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field" -+OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field" - OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message" - OP_COMPOSE_EDIT_TO "edit the TO list" - OP_CREATE_MAILBOX "create a new mailbox (IMAP only)" -@@ -85,8 +90,13 @@ OP_EXIT "exit this menu" - OP_FILTER "filter attachment through a shell command" - OP_FIRST_ENTRY "move to the first entry" - OP_FLAG_MESSAGE "toggle a message's 'important' flag" -+OP_FOLLOWUP "followup to newsgroup" -+OP_FORWARD_TO_GROUP "forward to newsgroup" - OP_FORWARD_MESSAGE "forward a message with comments" - OP_GENERIC_SELECT_ENTRY "select the current entry" -+OP_GET_CHILDREN "get all children of the current message" -+OP_GET_MESSAGE "get message with Message-Id" -+OP_GET_PARENT "get parent of the current message" - OP_GROUP_REPLY "reply to all recipients" - OP_HALF_DOWN "scroll down 1/2 page" - OP_HALF_UP "scroll up 1/2 page" -@@ -94,11 +104,14 @@ OP_HELP "this screen" - OP_JUMP "jump to an index number" - OP_LAST_ENTRY "move to the last entry" - OP_LIST_REPLY "reply to specified mailing list" -+OP_LOAD_ACTIVE "load active file from NNTP server" - OP_MACRO "execute a macro" - OP_MAIL "compose a new mail message" - OP_MAIN_BREAK_THREAD "break the thread in two" - OP_MAIN_CHANGE_FOLDER "open a different folder" - OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode" -+OP_MAIN_CHANGE_GROUP "open a different newsgroup" -+OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode" - OP_MAIN_CLEAR_FLAG "clear a status flag from a message" - OP_MAIN_DELETE_PATTERN "delete messages matching a pattern" - OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server" -@@ -138,6 +151,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of - OP_PAGER_SKIP_QUOTED "skip beyond quoted text" - OP_PAGER_TOP "jump to the top of the message" - OP_PIPE "pipe message/attachment to a shell command" -+OP_POST "post message to newsgroup" - OP_PREV_ENTRY "move to the previous entry" - OP_PREV_LINE "scroll up one line" - OP_PREV_PAGE "move to the previous page" -@@ -146,6 +160,7 @@ OP_QUERY "query external program for add - OP_QUERY_APPEND "append new query results to current results" - OP_QUIT "save changes to mailbox and quit" - OP_RECALL_MESSAGE "recall a postponed message" -+OP_RECONSTRUCT_THREAD "reconstruct thread containing current message" - OP_REDRAW "clear and redraw the screen" - OP_REFORMAT_WINCH "{internal}" - OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)" -@@ -160,18 +175,22 @@ OP_SEARCH_TOGGLE "toggle search pattern - OP_SHELL_ESCAPE "invoke a command in a subshell" - OP_SORT "sort messages" - OP_SORT_REVERSE "sort messages in reverse order" -+OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern" - OP_TAG "tag the current entry" - OP_TAG_PREFIX "apply next function to tagged messages" - OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages" - OP_TAG_SUBTHREAD "tag the current subthread" - OP_TAG_THREAD "tag the current thread" - OP_TOGGLE_NEW "toggle a message's 'new' flag" -+OP_TOGGLE_READ "toggle view of read messages" - OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten" - OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files" - OP_TOP_PAGE "move to the top of the page" -+OP_UNCATCHUP "mark all articles in newsgroup as unread" - OP_UNDELETE "undelete the current entry" - OP_UNDELETE_THREAD "undelete all messages in thread" - OP_UNDELETE_SUBTHREAD "undelete all messages in subthread" -+OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern" - OP_VERSION "show the Mutt version number and date" - OP_VIEW_ATTACH "view attachment using mailcap entry if necessary" - OP_VIEW_ATTACHMENTS "show MIME attachments" -diff -udprP mutt-1.5.20.orig/PATCHES mutt-1.5.20/PATCHES ---- mutt-1.5.20.orig/PATCHES 2008-11-11 21:55:46.000000000 +0200 -+++ mutt-1.5.20/PATCHES 2009-06-15 21:05:24.000000000 +0300 -@@ -0,0 +1 @@ -+vvv.nntp -diff -udprP mutt-1.5.20.orig/account.c mutt-1.5.20/account.c ---- mutt-1.5.20.orig/account.c 2008-11-11 21:55:46.000000000 +0200 -+++ mutt-1.5.20/account.c 2009-06-15 21:05:24.000000000 +0300 -@@ -51,6 +51,11 @@ int mutt_account_match (const ACCOUNT* a - user = PopUser; - #endif - -+#ifdef USE_NNTP -+ if (a1->type == M_ACCT_TYPE_NNTP && NntpUser) -+ user = NntpUser; -+#endif -+ - if (a1->flags & a2->flags & M_ACCT_USER) - return (!strcmp (a1->user, a2->user)); - if (a1->flags & M_ACCT_USER) -@@ -130,6 +135,16 @@ void mutt_account_tourl (ACCOUNT* accoun - } - #endif - -+#ifdef USE_NNTP -+ if (account->type == M_ACCT_TYPE_NNTP) -+ { -+ if (account->flags & M_ACCT_SSL) -+ url->scheme = U_NNTPS; -+ else -+ url->scheme = U_NNTP; -+ } -+#endif -+ - url->host = account->host; - if (account->flags & M_ACCT_PORT) - url->port = account->port; -@@ -155,6 +170,10 @@ int mutt_account_getuser (ACCOUNT* accou - else if ((account->type == M_ACCT_TYPE_POP) && PopUser) - strfcpy (account->user, PopUser, sizeof (account->user)); - #endif -+#ifdef USE_NNTP -+ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser) -+ strfcpy (account->user, NntpUser, sizeof (account->user)); -+#endif - else if (option (OPTNOCURSES)) - return -1; - /* prompt (defaults to unix username), copy into account->user */ -@@ -215,6 +234,10 @@ int mutt_account_getpass (ACCOUNT* accou - else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass) - strfcpy (account->pass, SmtpPass, sizeof (account->pass)); - #endif -+#ifdef USE_NNTP -+ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass) -+ strfcpy (account->pass, NntpPass, sizeof (account->pass)); -+#endif - else if (option (OPTNOCURSES)) - return -1; - else -diff -udprP mutt-1.5.20.orig/account.h mutt-1.5.20/account.h ---- mutt-1.5.20.orig/account.h 2008-11-11 21:55:46.000000000 +0200 -+++ mutt-1.5.20/account.h 2009-06-15 21:05:24.000000000 +0300 -@@ -29,7 +29,8 @@ enum - M_ACCT_TYPE_NONE = 0, - M_ACCT_TYPE_IMAP, - M_ACCT_TYPE_POP, -- M_ACCT_TYPE_SMTP -+ M_ACCT_TYPE_SMTP, -+ M_ACCT_TYPE_NNTP - }; - - /* account flags */ -diff -udprP mutt-1.5.20.orig/attach.h mutt-1.5.20/attach.h ---- mutt-1.5.20.orig/attach.h 2008-11-11 21:55:46.000000000 +0200 -+++ mutt-1.5.20/attach.h 2009-06-15 21:05:24.000000000 +0300 -@@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f - - void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *); - void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *); --void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *); -+void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int); - void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int); - - #endif /* _ATTACH_H_ */ -diff -udprP mutt-1.5.20.orig/browser.c mutt-1.5.20/browser.c ---- mutt-1.5.20.orig/browser.c 2009-06-11 20:52:54.000000000 +0300 -+++ mutt-1.5.20/browser.c 2009-06-15 21:05:24.000000000 +0300 -@@ -32,6 +32,9 @@ - #ifdef USE_IMAP - #include "imap.h" - #endif -+#ifdef USE_NNTP -+#include "nntp.h" -+#endif - - #include <stdlib.h> - #include <dirent.h> -@@ -49,6 +52,19 @@ static struct mapping_t FolderHelp[] = { - { NULL, 0 } - }; - -+#ifdef USE_NNTP -+static struct mapping_t FolderNewsHelp[] = { -+ { N_("Exit"), OP_EXIT }, -+ { N_("List"), OP_TOGGLE_MAILBOXES }, -+ { N_("Subscribe"), OP_BROWSER_SUBSCRIBE }, -+ { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE }, -+ { N_("Catchup"), OP_CATCHUP }, -+ { N_("Mask"), OP_ENTER_MASK }, -+ { N_("Help"), OP_HELP }, -+ { NULL } -+}; -+#endif -+ - typedef struct folder_t - { - struct folder_file *ff; -@@ -114,9 +130,17 @@ static void browser_sort (struct browser - case SORT_ORDER: - return; - case SORT_DATE: -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ return; -+#endif - f = browser_compare_date; - break; - case SORT_SIZE: -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ return; -+#endif - f = browser_compare_size; - break; - case SORT_SUBJECT: -@@ -307,8 +331,106 @@ folder_format_str (char *dest, size_t de - return (src); - } - -+#ifdef USE_NNTP -+static const char * -+newsgroup_format_str (char *dest, size_t destlen, size_t col, char op, const char *src, -+ const char *fmt, const char *ifstring, const char *elsestring, -+ unsigned long data, format_flag flags) -+{ -+ char fn[SHORT_STRING], tmp[SHORT_STRING]; -+ FOLDER *folder = (FOLDER *) data; -+ -+ switch (op) -+ { -+ case 'C': -+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); -+ snprintf (dest, destlen, tmp, folder->num + 1); -+ break; -+ -+ case 'f': -+ strncpy (fn, folder->ff->name, sizeof(fn) - 1); -+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); -+ snprintf (dest, destlen, tmp, fn); -+ break; -+ -+ case 'N': -+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt); -+ if (folder->ff->nd->subscribed) -+ snprintf (dest, destlen, tmp, ' '); -+ else -+ snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u'); -+ break; -+ -+ case 'M': -+ snprintf (tmp, sizeof (tmp), "%%%sc", fmt); -+ if (folder->ff->nd->deleted) -+ snprintf (dest, destlen, tmp, 'D'); -+ else -+ snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-'); -+ break; -+ -+ case 's': -+ if (flags & M_FORMAT_OPTIONAL) -+ { -+ if (folder->ff->nd->unread != 0) -+ mutt_FormatString (dest, destlen, col, ifstring, newsgroup_format_str, -+ data, flags); -+ else -+ mutt_FormatString (dest, destlen, col, elsestring, newsgroup_format_str, -+ data, flags); -+ } -+ else if (Context && Context->data == folder->ff->nd) -+ { -+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); -+ snprintf (dest, destlen, tmp, Context->unread); -+ } -+ else -+ { -+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); -+ snprintf (dest, destlen, tmp, folder->ff->nd->unread); -+ } -+ break; -+ -+ case 'n': -+ if (Context && Context->data == folder->ff->nd) -+ { -+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); -+ snprintf (dest, destlen, tmp, Context->new); -+ } -+ else if (option (OPTMARKOLD) && -+ folder->ff->nd->lastCached >= folder->ff->nd->firstMessage && -+ folder->ff->nd->lastCached <= folder->ff->nd->lastMessage) -+ { -+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); -+ snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached); -+ } -+ else -+ { -+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); -+ snprintf (dest, destlen, tmp, folder->ff->nd->unread); -+ } -+ break; -+ -+ case 'd': -+ if (folder->ff->nd->desc != NULL) -+ { -+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); -+ snprintf (dest, destlen, tmp, folder->ff->nd->desc); -+ } -+ else -+ { -+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); -+ snprintf (dest, destlen, tmp, ""); -+ } -+ break; -+ } -+ return (src); -+} -+#endif /* USE_NNTP */ -+ - static void add_folder (MUTTMENU *m, struct browser_state *state, -- const char *name, const struct stat *s, int new) -+ const char *name, const struct stat *s, -+ void *data, int new) - { - if (state->entrylen == state->entrymax) - { -@@ -337,6 +459,10 @@ static void add_folder (MUTTMENU *m, str - #ifdef USE_IMAP - (state->entry)[state->entrylen].imap = 0; - #endif -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ (state->entry)[state->entrylen].nd = (NNTP_DATA *) data; -+#endif - (state->entrylen)++; - } - -@@ -352,9 +478,35 @@ static void init_state (struct browser_s - menu->data = state->entry; - } - -+/* get list of all files/newsgroups with mask */ - static int examine_directory (MUTTMENU *menu, struct browser_state *state, - char *d, const char *prefix) - { -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ { -+ LIST *tmp; -+ NNTP_DATA *data; -+ NNTP_SERVER *news = CurrentNewsSrv; -+ -+/* mutt_buffy_check (0); */ -+ init_state (state, menu); -+ -+ for (tmp = news->list; tmp; tmp = tmp->next) -+ { -+ if (!(data = (NNTP_DATA *)tmp->data)) -+ continue; -+ if (prefix && *prefix && strncmp (prefix, data->group, -+ strlen (prefix)) != 0) -+ continue; -+ if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not)) -+ continue; -+ add_folder (menu, state, data->group, NULL, data, data->new); -+ } -+ } -+ else -+#endif /* USE_NNTP */ -+ { - struct stat s; - DIR *dp; - struct dirent *de; -@@ -415,17 +567,40 @@ static int examine_directory (MUTTMENU * - tmp = Incoming; - while (tmp && mutt_strcmp (buffer, tmp->path)) - tmp = tmp->next; -- add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0); -+ add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0); -+ } -+ closedir (dp); - } -- closedir (dp); - browser_sort (state); - return 0; - } - -+/* get list of mailboxes/subscribed newsgroups */ - static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state) - { - struct stat s; - char buffer[LONG_STRING]; -+ -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ { -+ LIST *tmp; -+ NNTP_DATA *data; -+ NNTP_SERVER *news = CurrentNewsSrv; -+ -+/* mutt_buffy_check (0); */ -+ init_state (state, menu); -+ -+ for (tmp = news->list; tmp; tmp = tmp->next) -+ { -+ if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new || -+ (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread)))) -+ add_folder (menu, state, data->group, NULL, data, data->new); -+ } -+ } -+ else -+#endif -+ { - BUFFY *tmp = Incoming; - #ifdef USE_IMAP - struct mailbox_state mbox; -@@ -443,14 +618,21 @@ static int examine_mailboxes (MUTTMENU * - if (mx_is_imap (tmp->path)) - { - imap_mailbox_state (tmp->path, &mbox); -- add_folder (menu, state, tmp->path, NULL, mbox.new); -+ add_folder (menu, state, tmp->path, NULL, NULL, mbox.new); - continue; - } - #endif - #ifdef USE_POP - if (mx_is_pop (tmp->path)) - { -- add_folder (menu, state, tmp->path, NULL, tmp->new); -+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); -+ continue; -+ } -+#endif -+#ifdef USE_NNTP -+ if (mx_is_nntp (tmp->path)) -+ { -+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); - continue; - } - #endif -@@ -479,15 +661,20 @@ static int examine_mailboxes (MUTTMENU * - strfcpy (buffer, NONULL(tmp->path), sizeof (buffer)); - mutt_pretty_mailbox (buffer, sizeof (buffer)); - -- add_folder (menu, state, buffer, &s, tmp->new); -+ add_folder (menu, state, buffer, &s, NULL, tmp->new); - } - while ((tmp = tmp->next)); -+ } - browser_sort (state); - return 0; - } - - static int select_file_search (MUTTMENU *menu, regex_t *re, int n) - { -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0)); -+#endif - return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0)); - } - -@@ -498,6 +685,12 @@ static void folder_entry (char *s, size_ - folder.ff = &((struct folder_file *) menu->data)[num]; - folder.num = num; - -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ mutt_FormatString (s, slen, 0, NONULL(GroupFormat), newsgroup_format_str, -+ (unsigned long) &folder, M_FORMAT_ARROWCURSOR); -+ else -+#endif - mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str, - (unsigned long) &folder, M_FORMAT_ARROWCURSOR); - } -@@ -518,6 +711,17 @@ static void init_menu (struct browser_st - - menu->tagged = 0; - -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ { -+ if (buffy) -+ snprintf (title, titlelen, _("Subscribed newsgroups")); -+ else -+ snprintf (title, titlelen, _("Newsgroups on server [%s]"), -+ CurrentNewsSrv->conn->account.host); -+ } -+ else -+#endif - if (buffy) - snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0)); - else -@@ -573,6 +777,31 @@ void _mutt_select_file (char *f, size_t - if (!folder) - strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup)); - -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ { -+ if (*f) -+ strfcpy (prefix, f, sizeof (prefix)); -+ else -+ { -+ LIST *list; -+ -+ /* default state for news reader mode is browse subscribed newsgroups */ -+ buffy = 0; -+ for (list = CurrentNewsSrv->list; list; list = list->next) -+ { -+ NNTP_DATA *data = (NNTP_DATA *) list->data; -+ -+ if (data && data->subscribed) -+ { -+ buffy = 1; -+ break; -+ } -+ } -+ } -+ } -+ else -+#endif - if (*f) - { - mutt_expand_path (f, flen); -@@ -669,6 +898,9 @@ void _mutt_select_file (char *f, size_t - menu->tag = file_tag; - - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER, -+#ifdef USE_NNTP -+ (option (OPTNEWS)) ? FolderNewsHelp : -+#endif - FolderHelp); - - init_menu (&state, menu, title, sizeof (title), buffy); -@@ -807,7 +1039,11 @@ void _mutt_select_file (char *f, size_t - } - } - -+#ifdef USE_NNTP -+ if (buffy || option (OPTNEWS)) /* news have not path */ -+#else - if (buffy) -+#endif - { - strfcpy (f, state.entry[menu->current].name, flen); - mutt_expand_path (f, flen); -@@ -865,14 +1101,6 @@ void _mutt_select_file (char *f, size_t - break; - - #ifdef USE_IMAP -- case OP_BROWSER_SUBSCRIBE: -- imap_subscribe (state.entry[menu->current].name, 1); -- break; -- -- case OP_BROWSER_UNSUBSCRIBE: -- imap_subscribe (state.entry[menu->current].name, 0); -- break; -- - case OP_BROWSER_TOGGLE_LSUB: - if (option (OPTIMAPLSUB)) - unset_option (OPTIMAPLSUB); -@@ -973,6 +1201,11 @@ void _mutt_select_file (char *f, size_t - - case OP_CHANGE_DIRECTORY: - -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ break; -+#endif -+ - strfcpy (buf, LastDir, sizeof (buf)); - #ifdef USE_IMAP - if (!state.imap_browse) -@@ -1239,6 +1472,190 @@ void _mutt_select_file (char *f, size_t - else - mutt_error _("Error trying to view file"); - } -+ break; -+ -+#ifdef USE_NNTP -+ case OP_CATCHUP: -+ case OP_UNCATCHUP: -+ if (option (OPTNEWS)) -+ { -+ struct folder_file *f = &state.entry[menu->current]; -+ NNTP_DATA *nd; -+ -+ if (i == OP_CATCHUP) -+ nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name); -+ else -+ nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name); -+ -+ if (nd) -+ { -+/* FOLDER folder; -+ struct folder_file ff; -+ char buffer[_POSIX_PATH_MAX + SHORT_STRING]; -+ -+ folder.ff = &ff; -+ folder.ff->name = f->name; -+ folder.ff->st = NULL; -+ folder.ff->is_new = nd->new; -+ folder.ff->nd = nd; -+ FREE (&f->desc); -+ mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat), -+ newsgroup_format_str, (unsigned long) &folder, -+ M_FORMAT_ARROWCURSOR); -+ f->desc = safe_strdup (buffer); */ -+ if (menu->current + 1 < menu->max) -+ menu->current++; -+ menu->redraw = REDRAW_MOTION_RESYNCH; -+ } -+ } -+ break; -+ -+ case OP_LOAD_ACTIVE: -+ if (!option (OPTNEWS)) -+ break; -+ -+ { -+ LIST *tmp; -+ NNTP_DATA *data; -+ -+ for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next) -+ { -+ if ((data = (NNTP_DATA *)tmp->data)) -+ data->deleted = 1; -+ } -+ } -+ nntp_get_active (CurrentNewsSrv); -+ -+ destroy_state (&state); -+ if (buffy) -+ examine_mailboxes (menu, &state); -+ else -+ examine_directory (menu, &state, NULL, NULL); -+ init_menu (&state, menu, title, sizeof (title), buffy); -+ break; -+#endif /* USE_NNTP */ -+ -+#if defined USE_IMAP || defined USE_NNTP -+ case OP_BROWSER_SUBSCRIBE: -+ case OP_BROWSER_UNSUBSCRIBE: -+#endif -+#ifdef USE_NNTP -+ case OP_SUBSCRIBE_PATTERN: -+ case OP_UNSUBSCRIBE_PATTERN: -+ if (option (OPTNEWS)) -+ { -+ regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t)); -+ char *s = buf; -+ int j = menu->current; -+ NNTP_DATA *nd; -+ NNTP_SERVER *news = CurrentNewsSrv; -+ -+ if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN) -+ { -+ char tmp[STRING]; -+ int err; -+ -+ buf[0] = 0; -+ if (i == OP_SUBSCRIBE_PATTERN) -+ snprintf (tmp, sizeof (tmp), _("Subscribe pattern: ")); -+ else -+ snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: ")); -+ if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) -+ { -+ FREE (&rx); -+ break; -+ } -+ -+ if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) -+ { -+ regerror (err, rx, buf, sizeof (buf)); -+ regfree (rx); -+ FREE (&rx); -+ mutt_error ("%s", buf); -+ break; -+ } -+ menu->redraw = REDRAW_FULL; -+ j = 0; -+ } -+ else if (!state.entrylen) -+ { -+ mutt_error _("No newsgroups match the mask"); -+ break; -+ } -+ -+ for ( ; j < state.entrylen; j++) -+ { -+ struct folder_file *f = &state.entry[j]; -+ -+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE || -+ regexec (rx, f->name, 0, NULL, 0) == 0) -+ { -+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN) -+ nd = mutt_newsgroup_subscribe (news, f->name); -+ else -+ nd = mutt_newsgroup_unsubscribe (news, f->name); -+/* if (nd) -+ { -+ FOLDER folder; -+ char buffer[_POSIX_PATH_MAX + SHORT_STRING]; -+ -+ folder.name = f->name; -+ folder.f = NULL; -+ folder.new = nd->new; -+ folder.nd = nd; -+ FREE (&f->desc); -+ mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat), -+ newsgroup_format_str, (unsigned long) &folder, -+ M_FORMAT_ARROWCURSOR); -+ f->desc = safe_strdup (buffer); -+ } */ -+ } -+ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE) -+ { -+ if (menu->current + 1 < menu->max) -+ menu->current++; -+ menu->redraw = REDRAW_MOTION_RESYNCH; -+ break; -+ } -+ } -+ if (i == OP_SUBSCRIBE_PATTERN) -+ { -+ LIST *grouplist = NULL; -+ -+ if (news) -+ grouplist = news->list; -+ for (; grouplist; grouplist = grouplist->next) -+ { -+ nd = (NNTP_DATA *) grouplist->data; -+ if (nd && nd->group && !nd->subscribed) -+ { -+ if (regexec (rx, nd->group, 0, NULL, 0) == 0) -+ { -+ mutt_newsgroup_subscribe (news, nd->group); -+ add_folder (menu, &state, nd->group, NULL, nd, nd->new); -+ } -+ } -+ } -+ init_menu (&state, menu, title, sizeof (title), buffy); -+ } -+ mutt_newsrc_update (news); -+ nntp_clear_cacheindex (news); -+ if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE) -+ regfree (rx); -+ FREE (&rx); -+ } -+#ifdef USE_IMAP -+ else -+#endif /* USE_IMAP && USE_NNTP */ -+#endif /* USE_NNTP */ -+#ifdef USE_IMAP -+ { -+ if (i == OP_BROWSER_SUBSCRIBE) -+ imap_subscribe (state.entry[menu->current].name, 1); -+ else -+ imap_subscribe (state.entry[menu->current].name, 0); -+ } -+#endif /* USE_IMAP */ - } - } - -diff -udprP mutt-1.5.20.orig/browser.h mutt-1.5.20/browser.h ---- mutt-1.5.20.orig/browser.h 2009-01-05 00:34:12.000000000 +0200 -+++ mutt-1.5.20/browser.h 2009-06-15 21:05:24.000000000 +0300 -@@ -19,6 +19,10 @@ - #ifndef _BROWSER_H - #define _BROWSER_H 1 - -+#ifdef USE_NNTP -+#include "nntp.h" -+#endif -+ - struct folder_file - { - mode_t mode; -@@ -37,6 +41,9 @@ struct folder_file - unsigned selectable : 1; - unsigned inferiors : 1; - #endif -+#ifdef USE_NNTP -+ NNTP_DATA *nd; -+#endif - unsigned tagged : 1; - }; - -diff -udprP mutt-1.5.20.orig/buffy.c mutt-1.5.20/buffy.c ---- mutt-1.5.20.orig/buffy.c 2009-06-02 20:16:26.000000000 +0300 -+++ mutt-1.5.20/buffy.c 2009-06-15 21:05:24.000000000 +0300 -@@ -403,6 +403,9 @@ int mutt_buffy_check (int force) - BuffyCount += imap_buffy_check (force); - #endif - -+#ifdef USE_NNTP -+ if (!Context || Context->magic != M_NNTP) -+#endif - /* check device ID and serial number instead of comparing paths */ - if (!Context || Context->magic == M_IMAP || Context->magic == M_POP - || stat (Context->path, &contex_sb) != 0) -@@ -421,6 +424,11 @@ int mutt_buffy_check (int force) - tmp->magic = M_POP; - else - #endif -+#ifdef USE_NNTP -+ if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path)) -+ tmp->magic = M_NNTP; -+ else -+#endif - if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) || - (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0)) - { -@@ -436,7 +444,11 @@ int mutt_buffy_check (int force) - /* check to see if the folder is the currently selected folder - * before polling */ - if (!Context || !Context->path || -- (( tmp->magic == M_IMAP || tmp->magic == M_POP ) -+ (( tmp->magic == M_IMAP || tmp->magic == M_POP -+#ifdef USE_NNTP -+ || tmp->magic == M_NNTP -+#endif -+ ) - ? mutt_strcmp (tmp->path, Context->path) : - (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino))) - { -diff -udprP mutt-1.5.20.orig/complete.c mutt-1.5.20/complete.c ---- mutt-1.5.20.orig/complete.c 2009-01-05 00:38:16.000000000 +0200 -+++ mutt-1.5.20/complete.c 2009-06-15 21:05:24.000000000 +0300 -@@ -25,6 +25,9 @@ - #include "mailbox.h" - #include "imap.h" - #endif -+#ifdef USE_NNTP -+#include "nntp.h" -+#endif - - #include <dirent.h> - #include <string.h> -@@ -48,9 +51,71 @@ int mutt_complete (char *s, size_t slen) - char filepart[_POSIX_PATH_MAX]; - #ifdef USE_IMAP - char imap_path[LONG_STRING]; -+#endif - - dprint (2, (debugfile, "mutt_complete: completing %s\n", s)); - -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ { -+ LIST *l = CurrentNewsSrv->list; -+ -+ strfcpy (filepart, s, sizeof (filepart)); -+ -+ /* -+ * special case to handle when there is no filepart yet. -+ * find the first subscribed newsgroup -+ */ -+ if ((len = mutt_strlen (filepart)) == 0) -+ { -+ for (; l; l = l->next) -+ { -+ NNTP_DATA *data = (NNTP_DATA *)l->data; -+ -+ if (data && data->subscribed) -+ { -+ strfcpy (filepart, data->group, sizeof (filepart)); -+ init++; -+ l = l->next; -+ break; -+ } -+ } -+ } -+ -+ for (; l; l = l->next) -+ { -+ NNTP_DATA *data = (NNTP_DATA *)l->data; -+ -+ if (data && data->subscribed && -+ mutt_strncmp (data->group, filepart, len) == 0) -+ { -+ if (init) -+ { -+ for (i = 0; filepart[i] && data->group[i]; i++) -+ { -+ if (filepart[i] != data->group[i]) -+ { -+ filepart[i] = 0; -+ break; -+ } -+ } -+ filepart[i] = 0; -+ } -+ else -+ { -+ strfcpy (filepart, data->group, sizeof (filepart)); -+ init = 1; -+ } -+ } -+ } -+ -+ strcpy (s, filepart); -+ -+ return (init ? 0 : -1); -+ } -+#endif -+ -+#ifdef USE_IMAP - /* we can use '/' as a delimiter, imap_complete rewrites it */ - if (*s == '=' || *s == '+' || *s == '!') - { -diff -udprP mutt-1.5.20.orig/compose.c mutt-1.5.20/compose.c ---- mutt-1.5.20.orig/compose.c 2009-03-31 09:52:43.000000000 +0300 -+++ mutt-1.5.20/compose.c 2009-06-15 21:05:24.000000000 +0300 -@@ -32,10 +32,15 @@ - #include "mailbox.h" - #include "sort.h" - #include "charset.h" -+#include "mx.h" - - #ifdef MIXMASTER - #include "remailer.h" - #endif -+ -+#ifdef USE_NNTP -+#include "nntp.h" -+#endif - - #include <errno.h> - #include <string.h> -@@ -60,18 +65,21 @@ enum - HDR_REPLYTO, - HDR_FCC, - --#ifdef MIXMASTER -- HDR_MIX, --#endif - - HDR_CRYPT, - HDR_CRYPTINFO, - -+#ifdef USE_NNTP -+ HDR_NEWSGROUPS, -+ HDR_FOLLOWUPTO, -+ HDR_XCOMMENTTO, -+#endif -+ - HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */ - }; - --#define HDR_XOFFSET 10 --#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */ -+#define HDR_XOFFSET 14 -+#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */ - #define W (COLS - HDR_XOFFSET) - - static char *Prompts[] = -@@ -83,6 +91,16 @@ static char *Prompts[] = - "Subject: ", - "Reply-To: ", - "Fcc: " -+#ifdef USE_NNTP -+#ifdef MIXMASTER -+ ,"" -+#endif -+ ,"" -+ ,"" -+ ,"Newsgroups: " -+ ,"Followup-To: " -+ ,"X-Comment-To: " -+#endif - }; - - static struct mapping_t ComposeHelp[] = { -@@ -97,6 +115,19 @@ static struct mapping_t ComposeHelp[] = - { NULL, 0 } - }; - -+#ifdef USE_NNTP -+static struct mapping_t ComposeNewsHelp[] = { -+ { N_("Send"), OP_COMPOSE_SEND_MESSAGE }, -+ { N_("Abort"), OP_EXIT }, -+ { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS }, -+ { "Subj", OP_COMPOSE_EDIT_SUBJECT }, -+ { N_("Attach file"), OP_COMPOSE_ATTACH_FILE }, -+ { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION }, -+ { N_("Help"), OP_HELP }, -+ { NULL } -+}; -+#endif -+ - static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num) - { - mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt, -@@ -252,9 +283,28 @@ static void draw_envelope_addr (int line - static void draw_envelope (HEADER *msg, char *fcc) - { - draw_envelope_addr (HDR_FROM, msg->env->from); -+#ifdef USE_NNTP -+ if (!option (OPTNEWSSEND)) -+ { -+#endif - draw_envelope_addr (HDR_TO, msg->env->to); - draw_envelope_addr (HDR_CC, msg->env->cc); - draw_envelope_addr (HDR_BCC, msg->env->bcc); -+#ifdef USE_NNTP -+ } -+ else -+ { -+ mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]); -+ mutt_paddstr (W, NONULL (msg->env->newsgroups)); -+ mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]); -+ mutt_paddstr (W, NONULL (msg->env->followup_to)); -+ if (option (OPTXCOMMENTTO)) -+ { -+ mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]); -+ mutt_paddstr (W, NONULL (msg->env->x_comment_to)); -+ } -+ } -+#endif - mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); - mutt_paddstr (W, NONULL (msg->env->subject)); - draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); -@@ -507,6 +557,12 @@ int mutt_compose_menu (HEADER *msg, /* - /* Sort, SortAux could be changed in mutt_index_menu() */ - int oldSort, oldSortAux; - struct stat st; -+#ifdef USE_NNTP -+ int news = 0; /* is it a news article ? */ -+ -+ if (option (OPTNEWSSEND)) -+ news++; -+#endif - - mutt_attach_init (msg->content); - idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1); -@@ -517,10 +573,18 @@ int mutt_compose_menu (HEADER *msg, /* - menu->make_entry = snd_entry; - menu->tag = mutt_tag_attach; - menu->data = idx; -+#ifdef USE_NNTP -+ if (news) -+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp); -+ else -+#endif - menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp); - - while (loop) - { -+#ifdef USE_NNTP -+ unset_option (OPTNEWS); /* for any case */ -+#endif - switch (op = mutt_menuLoop (menu)) - { - case OP_REDRAW: -@@ -533,17 +597,87 @@ int mutt_compose_menu (HEADER *msg, /* - mutt_message_hook (NULL, msg, M_SEND2HOOK); - break; - case OP_COMPOSE_EDIT_TO: -+#ifdef USE_NNTP -+ if (news) -+ break; -+#endif - menu->redraw = edit_address_list (HDR_TO, &msg->env->to); - mutt_message_hook (NULL, msg, M_SEND2HOOK); - break; - case OP_COMPOSE_EDIT_BCC: -+#ifdef USE_NNTP -+ if (news) -+ break; -+#endif - menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc); - mutt_message_hook (NULL, msg, M_SEND2HOOK); - break; - case OP_COMPOSE_EDIT_CC: -+#ifdef USE_NNTP -+ if (news) -+ break; -+#endif - menu->redraw = edit_address_list (HDR_CC, &msg->env->cc); - mutt_message_hook (NULL, msg, M_SEND2HOOK); - break; -+#ifdef USE_NNTP -+ case OP_COMPOSE_EDIT_NEWSGROUPS: -+ if (news) -+ { -+ if (msg->env->newsgroups) -+ strfcpy (buf, msg->env->newsgroups, sizeof (buf)); -+ else -+ buf[0] = 0; -+ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0]) -+ { -+ FREE (&msg->env->newsgroups); -+ mutt_remove_trailing_ws (buf); -+ msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf)); -+ move (HDR_TO, HDR_XOFFSET); -+ clrtoeol (); -+ if (msg->env->newsgroups) -+ printw ("%-*.*s", W, W, msg->env->newsgroups); -+ } -+ } -+ break; -+ -+ case OP_COMPOSE_EDIT_FOLLOWUP_TO: -+ if (news) -+ { -+ buf[0] = 0; -+ if (msg->env->followup_to) -+ strfcpy (buf, msg->env->followup_to, sizeof (buf)); -+ if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0]) -+ { -+ FREE (&msg->env->followup_to); -+ mutt_remove_trailing_ws (buf); -+ msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf)); -+ move (HDR_CC, HDR_XOFFSET); -+ clrtoeol(); -+ if (msg->env->followup_to) -+ printw ("%-*.*s", W, W, msg->env->followup_to); -+ } -+ } -+ break; -+ -+ case OP_COMPOSE_EDIT_X_COMMENT_TO: -+ if (news && option (OPTXCOMMENTTO)) -+ { -+ buf[0] = 0; -+ if (msg->env->x_comment_to) -+ strfcpy (buf, msg->env->x_comment_to, sizeof (buf)); -+ if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0]) -+ { -+ FREE (&msg->env->x_comment_to); -+ msg->env->x_comment_to = safe_strdup (buf); -+ move (HDR_BCC, HDR_XOFFSET); -+ clrtoeol(); -+ if (msg->env->x_comment_to) -+ printw ("%-*.*s", W, W, msg->env->x_comment_to); -+ } -+ } -+ break; -+#endif - case OP_COMPOSE_EDIT_SUBJECT: - if (msg->env->subject) - strfcpy (buf, msg->env->subject, sizeof (buf)); -@@ -706,6 +840,9 @@ int mutt_compose_menu (HEADER *msg, /* - break; - - case OP_COMPOSE_ATTACH_MESSAGE: -+#ifdef USE_NNTP -+ case OP_COMPOSE_ATTACH_NEWS_MESSAGE: -+#endif - { - char *prompt; - HEADER *h; -@@ -713,7 +850,22 @@ int mutt_compose_menu (HEADER *msg, /* - fname[0] = 0; - prompt = _("Open mailbox to attach message from"); - -+#ifdef USE_NNTP -+ unset_option (OPTNEWS); -+ if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE) -+ { -+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer))) -+ break; -+ -+ prompt = _("Open newsgroup to attach message from"); -+ set_option (OPTNEWS); -+ } -+#endif -+ - if (Context) -+#ifdef USE_NNTP -+ if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP)) -+#endif - { - strfcpy (fname, NONULL (Context->path), sizeof (fname)); - mutt_pretty_mailbox (fname, sizeof (fname)); -@@ -722,6 +874,11 @@ int mutt_compose_menu (HEADER *msg, /* - if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0]) - break; - -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account); -+ else -+#endif - mutt_expand_path (fname, sizeof (fname)); - #ifdef USE_IMAP - if (!mx_is_imap (fname)) -@@ -729,6 +886,9 @@ int mutt_compose_menu (HEADER *msg, /* - #ifdef USE_POP - if (!mx_is_pop (fname)) - #endif -+#ifdef USE_NNTP -+ if (!mx_is_nntp (fname) && !option (OPTNEWS)) -+#endif - /* check to make sure the file exists and is readable */ - if (access (fname, R_OK) == -1) - { -diff -udprP mutt-1.5.20.orig/config.h.in mutt-1.5.20/config.h.in ---- mutt-1.5.20.orig/config.h.in 2009-06-09 09:51:15.000000000 +0300 -+++ mutt-1.5.20/config.h.in 2009-06-15 21:05:24.000000000 +0300 -@@ -37,6 +37,9 @@ - significant more memory when defined. */ - #undef EXACT_ADDRESS - -+/* Compiling with newsreading support with NNTP */ -+#undef USE_NNTP -+ - /* program to use for shell commands */ - #undef EXECSHELL - -diff -udprP mutt-1.5.20.orig/configure.ac mutt-1.5.20/configure.ac ---- mutt-1.5.20.orig/configure.ac 2009-06-09 09:50:33.000000000 +0300 -+++ mutt-1.5.20/configure.ac 2009-06-15 21:05:24.000000000 +0300 -@@ -599,6 +599,14 @@ if test x"$need_imap" = xyes -o x"$need_ - MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o" - fi - -+AC_ARG_ENABLE(nntp, [ --enable-nntp Enable NNTP support], -+[ if test x$enableval = xyes ; then -+ AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ]) -+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o" -+ need_socket="yes" -+ fi -+]) -+ - dnl -- end socket dependencies -- - - if test "$need_socket" = "yes" -diff -udprP mutt-1.5.20.orig/curs_main.c mutt-1.5.20/curs_main.c ---- mutt-1.5.20.orig/curs_main.c 2009-06-14 05:48:36.000000000 +0300 -+++ mutt-1.5.20/curs_main.c 2009-06-15 21:47:09.000000000 +0300 -@@ -22,6 +22,7 @@ - - #include "mutt.h" - #include "mutt_curses.h" -+#include "mx.h" - #include "mutt_menu.h" - #include "mailbox.h" - #include "mapping.h" -@@ -38,6 +39,10 @@ - - #include "mutt_crypt.h" - -+#ifdef USE_NNTP -+#include "nntp.h" -+#endif -+ - - #include <ctype.h> - #include <stdlib.h> -@@ -413,12 +418,27 @@ static struct mapping_t IndexHelp[] = { - { NULL, 0 } - }; - -+#ifdef USE_NNTP -+struct mapping_t IndexNewsHelp[] = { -+ { N_("Quit"), OP_QUIT }, -+ { N_("Del"), OP_DELETE }, -+ { N_("Undel"), OP_UNDELETE }, -+ { N_("Save"), OP_SAVE }, -+ { N_("Post"), OP_POST }, -+ { N_("Followup"), OP_FOLLOWUP }, -+ { N_("Catchup"), OP_CATCHUP }, -+ { N_("Help"), OP_HELP }, -+ { NULL } -+}; -+#endif -+ - /* This function handles the message index window as well as commands returned - * from the pager (MENU_PAGER). - */ - int mutt_index_menu (void) - { - char buf[LONG_STRING], helpstr[LONG_STRING]; -+ int flags; - int op = OP_NULL; - int done = 0; /* controls when to exit the "event" loop */ - int i = 0, j; -@@ -439,7 +459,11 @@ int mutt_index_menu (void) - menu->make_entry = index_make_entry; - menu->color = index_color; - menu->current = ci_first_message (); -- menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp); -+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, -+#ifdef USE_NNTP -+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : -+#endif -+ IndexHelp); - - if (!attach_msg) - mutt_buffy_check(1); /* force the buffy check after we enter the folder */ -@@ -690,6 +714,9 @@ int mutt_index_menu (void) - imap_disallow_reopen (Context); - #endif - -+#ifdef USE_NNTP -+ unset_option (OPTNEWS); /* for any case */ -+#endif - switch (op) - { - -@@ -740,6 +767,120 @@ int mutt_index_menu (void) - menu_current_bottom (menu); - break; - -+#ifdef USE_NNTP -+ case OP_GET_MESSAGE: -+ case OP_GET_PARENT: -+ CHECK_MSGCOUNT; -+ if (Context->magic == M_NNTP) -+ { -+ HEADER *h; -+ -+ if (op == OP_GET_MESSAGE) -+ { -+ buf[0] = 0; -+ if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0 -+ || !buf[0]) -+ break; -+ } -+ else -+ { -+ LIST *ref = CURHDR->env->references; -+ if (!ref) -+ { -+ mutt_error _("Article has no parent reference!"); -+ break; -+ } -+ strfcpy (buf, ref->data, sizeof (buf)); -+ } -+ if (!Context->id_hash) -+ Context->id_hash = mutt_make_id_hash (Context); -+ if ((h = hash_find (Context->id_hash, buf))) -+ { -+ if (h->virtual != -1) -+ { -+ menu->current = h->virtual; -+ menu->redraw = REDRAW_MOTION_RESYNCH; -+ } -+ else if (h->collapsed) -+ { -+ mutt_uncollapse_thread (Context, h); -+ mutt_set_virtual (Context); -+ menu->current = h->virtual; -+ menu->redraw = REDRAW_MOTION_RESYNCH; -+ } -+ else -+ mutt_error _("Message not visible in limited view."); -+ } -+ else -+ { -+ if (nntp_check_msgid (Context, buf) == 0) -+ { -+ h = Context->hdrs[Context->msgcount-1]; -+ mutt_sort_headers (Context, 0); -+ menu->current = h->virtual; -+ menu->redraw = REDRAW_FULL; -+ } -+ else -+ mutt_error (_("Article %s not found on server"), buf); -+ } -+ } -+ break; -+ -+ case OP_GET_CHILDREN: -+ case OP_RECONSTRUCT_THREAD: -+ CHECK_MSGCOUNT; -+ if (Context->magic == M_NNTP) -+ { -+ HEADER *h; -+ int old = CURHDR->index, i; -+ -+ if (!CURHDR->env->message_id) -+ { -+ mutt_error _("No Message-Id. Unable to perform operation"); -+ break; -+ } -+ -+ if (!Context->id_hash) -+ Context->id_hash = mutt_make_id_hash (Context); -+ strfcpy (buf, CURHDR->env->message_id, sizeof (buf)); -+ -+ if (op == OP_RECONSTRUCT_THREAD) -+ { -+ LIST *ref = CURHDR->env->references; -+ while (ref) -+ { -+ nntp_check_msgid (Context, ref->data); -+ /* the last msgid in References is the root message */ -+ if (!ref->next) -+ strfcpy (buf, ref->data, sizeof (buf)); -+ ref = ref->next; -+ } -+ } -+ mutt_message _("Check for children of message..."); -+ if (nntp_check_children (Context, buf) == 0) -+ { -+ mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD)); -+ h = hash_find (Context->id_hash, buf); -+ /* if the root message was retrieved, move to it */ -+ if (h) -+ menu->current = h->virtual; -+ else /* try to restore old position */ -+ for (i = 0; i < Context->msgcount; i++) -+ if (Context->hdrs[i]->index == old) -+ { -+ menu->current = Context->hdrs[i]->virtual; -+ /* As an added courtesy, recenter the menu -+ * with the current entry at the middle of the screen */ -+ menu_check_recenter (menu); -+ menu_current_middle (menu); -+ } -+ } -+ menu->redraw = REDRAW_FULL; -+ mutt_clear_error (); -+ } -+ break; -+#endif -+ - case OP_JUMP: - - CHECK_MSGCOUNT; -@@ -836,11 +977,33 @@ int mutt_index_menu (void) - break; - - case OP_MAIN_LIMIT: -+ case OP_TOGGLE_READ: - - CHECK_IN_MAILBOX; - menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ? - CURHDR->index : -1; -- if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0) -+ if (op == OP_TOGGLE_READ) -+ { -+ char buf[LONG_STRING]; -+ -+ if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0) -+ { -+ snprintf (buf, sizeof (buf), "!~R!~D~s%s", -+ Context->pattern ? Context->pattern : ".*"); -+ set_option (OPTHIDEREAD); -+ } -+ else -+ { -+ strfcpy (buf, Context->pattern + 8, sizeof(buf)); -+ if (!*buf || strncmp (buf, ".*", 2) == 0) -+ snprintf (buf, sizeof(buf), "~A"); -+ unset_option (OPTHIDEREAD); -+ } -+ FREE (&Context->pattern); -+ Context->pattern = safe_strdup (buf); -+ } -+ if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) || -+ mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0) - { - if (menu->oldcurrent >= 0) - { -@@ -1057,15 +1220,22 @@ int mutt_index_menu (void) - - case OP_MAIN_CHANGE_FOLDER: - case OP_MAIN_NEXT_UNREAD_MAILBOX: -- -- if (attach_msg) -- op = OP_MAIN_CHANGE_FOLDER_READONLY; -- -- /* fallback to the readonly case */ -- - case OP_MAIN_CHANGE_FOLDER_READONLY: -+#ifdef USE_NNTP -+ case OP_MAIN_CHANGE_GROUP: -+ case OP_MAIN_CHANGE_GROUP_READONLY: -+ unset_option (OPTNEWS); -+#endif -+ if (attach_msg || option (OPTREADONLY) || -+#ifdef USE_NNTP -+ op == OP_MAIN_CHANGE_GROUP_READONLY || -+#endif -+ op == OP_MAIN_CHANGE_FOLDER_READONLY) -+ flags = M_READONLY; -+ else -+ flags = 0; - -- if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY)) -+ if (flags) - cp = _("Open mailbox in read-only mode"); - else - cp = _("Open mailbox"); -@@ -1084,6 +1254,21 @@ int mutt_index_menu (void) - } - else - { -+#ifdef USE_NNTP -+ if (op == OP_MAIN_CHANGE_GROUP || -+ op == OP_MAIN_CHANGE_GROUP_READONLY) -+ { -+ set_option (OPTNEWS); -+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer))) -+ break; -+ if (flags) -+ cp = _("Open newsgroup in read-only mode"); -+ else -+ cp = _("Open newsgroup"); -+ nntp_buffy (buf); -+ } -+ else -+#endif - mutt_buffy (buf, sizeof (buf)); - - if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) -@@ -1103,6 +1288,14 @@ int mutt_index_menu (void) - } - } - -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ { -+ unset_option (OPTNEWS); -+ nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account); -+ } -+ else -+#endif - mutt_expand_path (buf, sizeof (buf)); - if (mx_get_magic (buf) <= 0) - { -@@ -1140,15 +1333,18 @@ int mutt_index_menu (void) - CurrentMenu = MENU_MAIN; - mutt_folder_hook (buf); - -- if ((Context = mx_open_mailbox (buf, -- (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ? -- M_READONLY : 0, NULL)) != NULL) -+ if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL) - { - menu->current = ci_first_message (); - } - else - menu->current = 0; - -+#ifdef USE_NNTP -+ /* mutt_buffy_check() must be done with mail-reader mode! */ -+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, -+ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp); -+#endif - mutt_clear_error (); - mutt_buffy_check(1); /* force the buffy check after we have changed - the folder */ -@@ -1519,6 +1715,15 @@ int mutt_index_menu (void) - CHECK_READONLY; - CHECK_ACL(M_ACL_WRITE, _("flag message")); - -+#ifdef USE_NNTP -+ if (Context->magic == M_NNTP) -+ { -+ mutt_flushinp (); -+ mutt_error _("Can't change 'important' flag on NNTP server."); -+ break; -+ } -+#endif -+ - if (tag) - { - for (j = 0; j < Context->vcount; j++) -@@ -1866,6 +2071,17 @@ int mutt_index_menu (void) - } - break; - -+#ifdef USE_NNTP -+ case OP_CATCHUP: -+ if (Context && Context->magic == M_NNTP) -+ { -+ if (mutt_newsgroup_catchup (CurrentNewsSrv, -+ ((NNTP_DATA *)Context->data)->group)) -+ menu->redraw = REDRAW_INDEX | REDRAW_STATUS; -+ } -+ break; -+#endif -+ - case OP_DISPLAY_ADDRESS: - - CHECK_MSGCOUNT; -@@ -1993,6 +2209,15 @@ int mutt_index_menu (void) - menu->redraw = (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS; - } - #endif -+ -+#ifdef USE_NNTP -+ if (Context->magic == M_NNTP) -+ { -+ mutt_flushinp (); -+ mutt_error _("Can't edit message on newsserver."); -+ break; -+ } -+#endif - - MAYBE_REDRAW (menu->redraw); - break; -@@ -2065,6 +2290,41 @@ int mutt_index_menu (void) - menu->redraw = REDRAW_FULL; - break; - -+#ifdef USE_NNTP -+ case OP_FOLLOWUP: -+ case OP_FORWARD_TO_GROUP: -+ -+ CHECK_MSGCOUNT; -+ CHECK_VISIBLE; -+ -+ case OP_POST: -+ -+ CHECK_ATTACH; -+ if (op != OP_FOLLOWUP || !CURHDR->env->followup_to || -+ mutt_strcasecmp (CURHDR->env->followup_to, "poster") || -+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES) -+ { -+ if (Context && Context->magic == M_NNTP && -+ !((NNTP_DATA *)Context->data)->allowed && -+ query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) -+ break; -+ if (op == OP_POST) -+ ci_send_message (SENDNEWS, NULL, NULL, Context, NULL); -+ else -+ { -+ CHECK_MSGCOUNT; -+ if (op == OP_FOLLOWUP) -+ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context, -+ tag ? NULL : CURHDR); -+ else -+ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context, -+ tag ? NULL : CURHDR); -+ } -+ menu->redraw = REDRAW_FULL; -+ break; -+ } -+#endif -+ - case OP_REPLY: - - CHECK_ATTACH; -@@ -2140,6 +2400,12 @@ int mutt_index_menu (void) - CHECK_READONLY; - CHECK_ACL(M_ACL_DELETE, _("undelete message(s)")); - -+#ifdef USE_NNTP -+ /* Close all open NNTP connections */ -+ if (!attach_msg) -+ nntp_logout_all (); -+#endif -+ - rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0, - op == OP_UNDELETE_THREAD ? 0 : 1); - -diff -udprP mutt-1.5.20.orig/doc/manual.xml.head mutt-1.5.20/doc/manual.xml.head ---- mutt-1.5.20.orig/doc/manual.xml.head 2009-05-30 20:20:08.000000000 +0300 -+++ mutt-1.5.20/doc/manual.xml.head 2009-06-15 21:05:24.000000000 +0300 -@@ -1568,6 +1568,22 @@ fo-table</literal> for details. - - </sect2> - -+<sect2> -+<title>Reading news via NNTP</title> -+ -+<para> -+If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can -+read news from newsserver via NNTP. You can open a newsgroup with -+function ``change-newsgroup'' (default: ``i''). Default newsserver -+can be obtained from <emphasis>NNTPSERVER</emphasis> environment -+variable. Like other news readers, info about subscribed newsgroups -+is saved in file by <link linkend="newsrc">$newsrc</link> -+variable. Article headers are cached and can be loaded from file when -+newsgroup entered instead loading from newsserver. -+</para> -+ -+</sect2> -+ - </sect1> - - <sect1 id="forwarding-mail"> -diff -udprP mutt-1.5.20.orig/doc/mutt.man mutt-1.5.20/doc/mutt.man ---- mutt-1.5.20.orig/doc/mutt.man 2009-06-07 03:32:44.000000000 +0300 -+++ mutt-1.5.20/doc/mutt.man 2009-06-15 21:07:47.000000000 +0300 -@@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent - .SH SYNOPSIS - .PP - .B mutt --[\-nRyzZ] --[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-m \fItype\fP] [\-f \fIfile\fP] -+[-GnRyzZ] -+[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-g \fIserver\fP] [\-m \fItype\fP] [\-f \fIfile\fP] - .PP - .B mutt - [\-nx] -@@ -101,6 +101,10 @@ files. - Specify which mailbox to load. - .IP "-F \fImuttrc\fP" - Specify an initialization file to read instead of ~/.muttrc -+.IP "-g \fIserver\fP" -+Start Mutt with a listing of subscribed newsgroups at specified newsserver. -+.IP "-G" -+Start Mutt with a listing of subscribed newsgroups. - .IP "-h" - Display help. - .IP "-H \fIdraft\fP" -diff -udprP mutt-1.5.20.orig/functions.h mutt-1.5.20/functions.h ---- mutt-1.5.20.orig/functions.h 2009-04-30 08:36:17.000000000 +0300 -+++ mutt-1.5.20/functions.h 2009-06-15 21:05:24.000000000 +0300 -@@ -88,6 +88,10 @@ struct binding_t OpMain[] = { /* map: in - { "break-thread", OP_MAIN_BREAK_THREAD, "#" }, - { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" }, - { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" }, -+#ifdef USE_NNTP -+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" }, -+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" }, -+#endif - { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL }, - { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" }, - { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" }, -@@ -101,7 +105,15 @@ struct binding_t OpMain[] = { /* map: in - { "edit", OP_EDIT_MESSAGE, "e" }, - { "edit-type", OP_EDIT_TYPE, "\005" }, - { "forward-message", OP_FORWARD_MESSAGE, "f" }, -- { "flag-message", OP_FLAG_MESSAGE, "F" }, -+#ifdef USE_NNTP -+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" }, -+ { "followup-message", OP_FOLLOWUP, "F" }, -+ { "get-children", OP_GET_CHILDREN, NULL }, -+ { "get-message", OP_GET_MESSAGE, "\007" }, -+ { "get-parent", OP_GET_PARENT, "\033G" }, -+ { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL }, -+#endif -+ { "flag-message", OP_FLAG_MESSAGE, "\033f" }, - { "group-reply", OP_GROUP_REPLY, "g" }, - #ifdef USE_POP - { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" }, -@@ -127,6 +139,9 @@ struct binding_t OpMain[] = { /* map: in - { "sort-mailbox", OP_SORT, "o" }, - { "sort-reverse", OP_SORT_REVERSE, "O" }, - { "print-message", OP_PRINT, "p" }, -+#ifdef USE_NNTP -+ { "post-message", OP_POST, "P" }, -+#endif - { "previous-thread", OP_MAIN_PREV_THREAD, "\020" }, - { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" }, - { "recall-message", OP_RECALL_MESSAGE, "R" }, -@@ -146,6 +161,10 @@ struct binding_t OpMain[] = { /* map: in - { "show-version", OP_VERSION, "V" }, - { "set-flag", OP_MAIN_SET_FLAG, "w" }, - { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" }, -+ { "toggle-read", OP_TOGGLE_READ, "X" }, -+#ifdef USE_NNTP -+ { "catchup", OP_CATCHUP, "y" }, -+#endif - { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S }, - { "buffy-list", OP_BUFFY_LIST, "." }, - { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" }, -@@ -157,7 +176,7 @@ struct binding_t OpMain[] = { /* map: in - { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" }, - { "next-unread", OP_MAIN_NEXT_UNREAD, NULL }, - { "previous-unread", OP_MAIN_PREV_UNREAD, NULL }, -- { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" }, -+ { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL }, - - - { "extract-keys", OP_EXTRACT_KEYS, "\013" }, -@@ -177,6 +196,10 @@ struct binding_t OpPager[] = { /* map: p - { "bounce-message", OP_BOUNCE_MESSAGE, "b" }, - { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" }, - { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" }, -+#ifdef USE_NNTP -+ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" }, -+ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" }, -+#endif - { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL }, - { "copy-message", OP_COPY_MESSAGE, "C" }, - { "decode-copy", OP_DECODE_COPY, "\033C" }, -@@ -187,8 +210,12 @@ struct binding_t OpPager[] = { /* map: p - { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" }, - { "edit", OP_EDIT_MESSAGE, "e" }, - { "edit-type", OP_EDIT_TYPE, "\005" }, -+#ifdef USE_NNTP -+ { "followup-message", OP_FOLLOWUP, "F" }, -+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" }, -+#endif - { "forward-message", OP_FORWARD_MESSAGE, "f" }, -- { "flag-message", OP_FLAG_MESSAGE, "F" }, -+ { "flag-message", OP_FLAG_MESSAGE, "\033f" }, - { "group-reply", OP_GROUP_REPLY, "g" }, - #ifdef USE_IMAP - { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL }, -@@ -207,6 +234,9 @@ struct binding_t OpPager[] = { /* map: p - { "next-thread", OP_MAIN_NEXT_THREAD, "\016" }, - { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" }, - { "print-message", OP_PRINT, "p" }, -+#ifdef USE_NNTP -+ { "post-message", OP_POST, "P" }, -+#endif - { "previous-thread", OP_MAIN_PREV_THREAD, "\020" }, - { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" }, - { "quit", OP_QUIT, "Q" }, -@@ -254,7 +284,7 @@ struct binding_t OpPager[] = { /* map: p - { "half-down", OP_HALF_DOWN, NULL }, - { "previous-line", OP_PREV_LINE, NULL }, - { "bottom", OP_PAGER_BOTTOM, NULL }, -- { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" }, -+ { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL }, - - - -@@ -275,6 +305,10 @@ struct binding_t OpAttach[] = { /* map: - { "bounce-message", OP_BOUNCE_MESSAGE, "b" }, - { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" }, - { "edit-type", OP_EDIT_TYPE, "\005" }, -+#ifdef USE_NNTP -+ { "followup-message", OP_FOLLOWUP, "F" }, -+ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" }, -+#endif - { "print-entry", OP_PRINT, "p" }, - { "save-entry", OP_SAVE, "s" }, - { "pipe-entry", OP_PIPE, "|" }, -@@ -300,6 +334,7 @@ struct binding_t OpAttach[] = { /* map: - struct binding_t OpCompose[] = { /* map: compose */ - { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" }, - { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" }, -+ { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" }, - { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" }, - { "edit-cc", OP_COMPOSE_EDIT_CC, "c" }, - { "copy-file", OP_SAVE, "C" }, -@@ -319,6 +354,11 @@ struct binding_t OpCompose[] = { /* map: - { "print-entry", OP_PRINT, "l" }, - { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" }, - { "new-mime", OP_COMPOSE_NEW_MIME, "n" }, -+#ifdef USE_NNTP -+ { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" }, -+ { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" }, -+ { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" }, -+#endif - { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" }, - { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" }, - { "rename-file", OP_COMPOSE_RENAME_FILE, "R" }, -@@ -370,14 +410,25 @@ struct binding_t OpBrowser[] = { /* map: - { "select-new", OP_BROWSER_NEW_FILE, "N" }, - { "check-new", OP_CHECK_NEW, NULL }, - { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" }, -+#ifdef USE_NNTP -+ { "reload-active", OP_LOAD_ACTIVE, "g" }, -+ { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" }, -+ { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" }, -+ { "catchup", OP_CATCHUP, "y" }, -+ { "uncatchup", OP_UNCATCHUP, "Y" }, -+#endif - { "view-file", OP_BROWSER_VIEW_FILE, " " }, - { "buffy-list", OP_BUFFY_LIST, "." }, - #ifdef USE_IMAP - { "create-mailbox", OP_CREATE_MAILBOX, "C" }, - { "delete-mailbox", OP_DELETE_MAILBOX, "d" }, - { "rename-mailbox", OP_RENAME_MAILBOX, "r" }, -+#endif -+#if defined USE_IMAP || defined USE_NNTP - { "subscribe", OP_BROWSER_SUBSCRIBE, "s" }, - { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" }, -+#endif -+#ifdef USE_IMAP - { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" }, - #endif - { NULL, 0, NULL } -diff -udprP mutt-1.5.20.orig/globals.h mutt-1.5.20/globals.h ---- mutt-1.5.20.orig/globals.h 2009-06-03 23:48:31.000000000 +0300 -+++ mutt-1.5.20/globals.h 2009-06-15 21:05:24.000000000 +0300 -@@ -95,6 +95,15 @@ WHERE char *MixEntryFormat; - #endif - - WHERE char *Muttrc INITVAL (NULL); -+#ifdef USE_NNTP -+WHERE char *NewsCacheDir; -+WHERE char *GroupFormat; -+WHERE char *Inews; -+WHERE char *NewsServer; -+WHERE char *NntpUser; -+WHERE char *NntpPass; -+WHERE char *NewsRc; -+#endif - WHERE char *Outbox; - WHERE char *Pager; - WHERE char *PagerFmt; -@@ -188,6 +197,11 @@ extern unsigned char QuadOptions[]; - - WHERE unsigned short Counter INITVAL (0); - -+#ifdef USE_NNTP -+WHERE short NewsPollTimeout; -+WHERE short NntpContext; -+#endif -+ - WHERE short ConnectTimeout; - WHERE short HistSize; - WHERE short MenuContext; -diff -udprP mutt-1.5.20.orig/hash.c mutt-1.5.20/hash.c ---- mutt-1.5.20.orig/hash.c 2009-03-31 09:52:43.000000000 +0300 -+++ mutt-1.5.20/hash.c 2009-06-15 21:19:59.000000000 +0300 -@@ -57,6 +57,7 @@ HASH *hash_create (int nelem, int lower) - if (nelem == 0) - nelem = 2; - table->nelem = nelem; -+ table->curnelem = 0; - table->table = safe_calloc (nelem, sizeof (struct hash_elem *)); - if (lower) - { -@@ -71,6 +72,29 @@ HASH *hash_create (int nelem, int lower) - return table; - } - -+HASH *hash_resize (HASH *ptr, int nelem, int lower) -+{ -+ HASH *table; -+ struct hash_elem *elem, *tmp; -+ int i; -+ -+ table = hash_create (nelem, lower); -+ -+ for (i = 0; i < ptr->nelem; i++) -+ { -+ for (elem = ptr->table[i]; elem; ) -+ { -+ tmp = elem; -+ elem = elem->next; -+ hash_insert (table, tmp->key, tmp->data, 1); -+ FREE (&tmp); -+ } -+ } -+ FREE (&ptr->table); -+ FREE (&ptr); -+ return table; -+} -+ - /* table hash table to update - * key key to hash on - * data data to associate with `key' -@@ -90,6 +114,7 @@ int hash_insert (HASH * table, const cha - { - ptr->next = table->table[h]; - table->table[h] = ptr; -+ table->curnelem++; - } - else - { -@@ -112,6 +137,7 @@ int hash_insert (HASH * table, const cha - else - table->table[h] = ptr; - ptr->next = tmp; -+ table->curnelem++; - } - return h; - } -@@ -142,6 +168,7 @@ void hash_delete_hash (HASH * table, int - if (destroy) - destroy (ptr->data); - FREE (&ptr); -+ table->curnelem--; - - ptr = *last; - } -diff -udprP mutt-1.5.20.orig/hash.h mutt-1.5.20/hash.h ---- mutt-1.5.20.orig/hash.h 2009-03-31 09:52:43.000000000 +0300 -+++ mutt-1.5.20/hash.h 2009-06-15 21:05:24.000000000 +0300 -@@ -28,7 +28,7 @@ struct hash_elem - - typedef struct - { -- int nelem; -+ int nelem, curnelem; - struct hash_elem **table; - unsigned int (*hash_string)(const unsigned char *, unsigned int); - int (*cmp_string)(const char *, const char *); -@@ -41,6 +41,7 @@ HASH; - - HASH *hash_create (int nelem, int lower); - int hash_insert (HASH * table, const char *key, void *data, int allow_dup); -+HASH *hash_resize (HASH * table, int nelem, int lower); - void *hash_find_hash (const HASH * table, int hash, const char *key); - void hash_delete_hash (HASH * table, int hash, const char *key, const void *data, - void (*destroy) (void *)); -diff -udprP mutt-1.5.20.orig/hdrline.c mutt-1.5.20/hdrline.c ---- mutt-1.5.20.orig/hdrline.c 2009-04-13 19:24:55.000000000 +0300 -+++ mutt-1.5.20/hdrline.c 2009-06-15 21:05:24.000000000 +0300 -@@ -211,6 +211,7 @@ int mutt_user_is_recipient (HEADER *h) - * %E = number of messages in current thread - * %f = entire from line - * %F = like %n, unless from self -+ * %g = newsgroup name (if compiled with nntp support) - * %i = message-id - * %l = number of lines in the message - * %L = like %F, except `lists' are displayed first -@@ -219,12 +220,14 @@ int mutt_user_is_recipient (HEADER *h) - * %N = score - * %O = like %L, except using address instead of name - * %P = progress indicator for builtin pager -+ * %R = `x-comment-to:' field (if present and compiled with nntp support) - * %s = subject - * %S = short message status (e.g., N/O/D/!/r/-) - * %t = `to:' field (recipients) - * %T = $to_chars - * %u = user (login) name of author - * %v = first name of author, unless from self -+ * %W = where user is (organization) - * %X = number of MIME attachments - * %y = `x-label:' field (if present) - * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label) -@@ -457,6 +460,12 @@ hdr_format_str (char *dest, - - break; - -+#ifdef USE_NNTP -+ case 'g': -+ mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : ""); -+ break; -+#endif -+ - case 'i': - mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>"); - break; -@@ -548,6 +557,15 @@ hdr_format_str (char *dest, - strfcpy(dest, NONULL(hfi->pager_progress), destlen); - break; - -+#ifdef USE_NNTP -+ case 'R': -+ if (!optional) -+ mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : ""); -+ else if (!hdr->env->x_comment_to) -+ optional = 0; -+ break; -+#endif -+ - case 's': - - if (flags & M_FORMAT_TREE && !hdr->collapsed) -@@ -637,6 +655,13 @@ hdr_format_str (char *dest, - mutt_format_s (dest, destlen, prefix, buf2); - break; - -+ case 'W': -+ if (!optional) -+ mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : ""); -+ else if (!hdr->env->organization) -+ optional = 0; -+ break; -+ - case 'Z': - - ch = ' '; -diff -udprP mutt-1.5.20.orig/headers.c mutt-1.5.20/headers.c ---- mutt-1.5.20.orig/headers.c 2009-04-30 08:36:17.000000000 +0300 -+++ mutt-1.5.20/headers.c 2009-06-15 21:17:07.000000000 +0300 -@@ -114,6 +114,9 @@ void mutt_edit_headers (const char *edit - $edit_headers set, we remove References: as they're likely invalid; - we can simply compare strings as we don't generate References for - multiple Message-Ids in IRT anyways */ -+#ifdef USE_NNTP -+ if (!option (OPTNEWSSEND)) -+#endif - if (!n->in_reply_to || (msg->env->in_reply_to && - mutt_strcmp (n->in_reply_to->data, - msg->env->in_reply_to->data) != 0)) -diff -udprP mutt-1.5.20.orig/init.c mutt-1.5.20/init.c ---- mutt-1.5.20.orig/init.c 2009-06-01 19:29:32.000000000 +0300 -+++ mutt-1.5.20/init.c 2009-06-15 21:05:24.000000000 +0300 -@@ -2966,6 +2966,28 @@ void mutt_init (int skip_sys_rc, LIST *c - else - Fqdn = safe_strdup(NONULL(Hostname)); - -+#ifdef USE_NNTP -+ { -+ FILE *f; -+ char *i; -+ -+ if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r"))) -+ { -+ buffer[0] = '\0'; -+ fgets (buffer, sizeof (buffer), f); -+ p = &buffer; -+ SKIPWS (p); -+ i = p; -+ while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++; -+ *i = '\0'; -+ NewsServer = safe_strdup (p); -+ fclose (f); -+ } -+ } -+ if ((p = getenv ("NNTPSERVER"))) -+ NewsServer = safe_strdup (p); -+#endif -+ - if ((p = getenv ("MAIL"))) - Spoolfile = safe_strdup (p); - else if ((p = getenv ("MAILDIR"))) -diff -udprP mutt-1.5.20.orig/init.h mutt-1.5.20/init.h ---- mutt-1.5.20.orig/init.h 2009-06-14 00:35:21.000000000 +0300 -+++ mutt-1.5.20/init.h 2009-06-15 21:15:03.000000000 +0300 -@@ -176,6 +176,20 @@ struct option_t MuttVars[] = { - ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before - ** editing the body of an outgoing message. - */ -+#ifdef USE_NNTP -+ { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 }, -+ /* -+ ** .pp -+ ** If set, Mutt will prompt you for follow-up groups before editing -+ ** the body of an outgoing message. -+ */ -+ { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 }, -+ /* -+ ** .pp -+ ** If set, Mutt will prompt you for x-comment-to field before editing -+ ** the body of an outgoing message. -+ */ -+#endif - { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0}, - /* - ** .pp -@@ -322,6 +336,14 @@ struct option_t MuttVars[] = { - ** follow these menus. The option is \fIunset\fP by default because many - ** visual terminals don't permit making the cursor invisible. - */ -+#ifdef USE_NNTP -+ { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES }, -+ /* -+ ** .pp -+ ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup -+ ** as read when you quit the newsgroup (catchup newsgroup). -+ */ -+#endif - #if defined(USE_SSL) - { "certificate_file", DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" }, - /* -@@ -797,6 +819,16 @@ struct option_t MuttVars[] = { - ** sent to both the list and your address, resulting in two copies - ** of the same email for you. - */ -+#ifdef USE_NNTP -+ { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES }, -+ /* -+ ** .pp -+ ** If this variable is \fIset\fP and the keyword "poster" is present in -+ ** \fIFollowup-To\fP header, follow-up to newsgroup function is not -+ ** permitted. The message will be mailed to the submitter of the -+ ** message via mail. -+ */ -+#endif - { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 }, - /* - ** .pp -@@ -879,6 +911,27 @@ struct option_t MuttVars[] = { - ** a regular expression that will match the whole name so mutt will expand - ** ``Franklin'' to ``Franklin, Steve''. - */ -+#ifdef USE_NNTP -+ { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" }, -+ /* -+ ** .pp -+ ** This variable allows you to customize the newsgroup browser display to -+ ** your personal taste. This string is similar to ``$index_format'', but -+ ** has its own set of printf()-like sequences: -+ ** .pp -+ ** .ts -+ ** %C current newsgroup number -+ ** %d description of newsgroup (becomes from server) -+ ** %f newsgroup name -+ ** %M - if newsgroup not allowed for direct post (moderated for example) -+ ** %N N if newsgroup is new, u if unsubscribed, blank otherwise -+ ** %n number of new articles in newsgroup -+ ** %s number of unread articles in newsgroup -+ ** %>X right justify the rest of the string and pad with character "X" -+ ** %|X pad to the end of the line with character "X" -+ ** .te -+ */ -+#endif - { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 }, - /* - */ -@@ -1255,6 +1308,7 @@ struct option_t MuttVars[] = { - ** .dt %E .dd number of messages in current thread - ** .dt %f .dd sender (address + real name), either From: or Return-Path: - ** .dt %F .dd author name, or recipient name if the message is from you -+ ** .dt %g .dd newsgroup name (if compiled with nntp support) - ** .dt %H .dd spam attribute(s) of this message - ** .dt %i .dd message-id of the current message - ** .dt %l .dd number of lines in the message (does not work with maildir, -@@ -1270,12 +1324,14 @@ struct option_t MuttVars[] = { - ** stashed the message: list name or recipient name - ** if not sent to a list - ** .dt %P .dd progress indicator for the built-in pager (how much of the file has been displayed) -+ ** .dt %R .dd `x-comment-to:' field (if present and compiled with nntp support) - ** .dt %s .dd subject of the message - ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as) - ** .dt %t .dd ``To:'' field (recipients) - ** .dt %T .dd the appropriate character from the $$to_chars string - ** .dt %u .dd user (login) name of the author - ** .dt %v .dd first name of the author, or the recipient if the message is from you -+ ** .dt %W .dd name of organization of author (`organization:' field) - ** .dt %X .dd number of attachments - ** (please see the ``$attachments'' section for possible speed effects) - ** .dt %y .dd ``X-Label:'' field, if present -@@ -1310,6 +1366,21 @@ struct option_t MuttVars[] = { - ** Note that these expandos are supported in - ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too. - */ -+#ifdef USE_NNTP -+ { "inews", DT_PATH, R_NONE, UL &Inews, UL "" }, -+ /* -+ ** .pp -+ ** If set, specifies the program and arguments used to deliver news posted -+ ** by Mutt. Otherwise, mutt posts article using current connection to -+ ** news server. The following printf-style sequence is understood: -+ ** .pp -+ ** .ts -+ ** %s newsserver name -+ ** .te -+ ** .pp -+ ** Example: set inews="/usr/local/bin/inews -hS" -+ */ -+#endif - { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL }, - /* - ** .pp -@@ -1533,6 +1604,15 @@ struct option_t MuttVars[] = { - ** menu, attachments which cannot be decoded in a reasonable manner will - ** be attached to the newly composed message if this option is \fIset\fP. - */ -+#ifdef USE_NNTP -+ { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 }, -+ /* -+ ** .pp -+ ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be -+ ** encoded according to RFC2047 to base64. This is useful when message -+ ** is Usenet article, because MIME for news is nonstandard feature. -+ */ -+#endif - #ifdef MIXMASTER - { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" }, - /* -@@ -1580,6 +1660,77 @@ struct option_t MuttVars[] = { - ** See also $$read_inc, $$write_inc and $$net_inc. - */ - #endif -+#ifdef USE_NNTP -+ { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" }, -+ /* -+ ** .pp -+ ** This variable pointing to directory where Mutt will save cached news -+ ** articles headers in. If \fIunset\fP, headers will not be saved at all -+ ** and will be reloaded each time when you enter to newsgroup. -+ */ -+ { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 }, -+ /* -+ ** .pp -+ ** This variable specifies domain name or address of NNTP server. It -+ ** defaults to the newsserver specified in the environment variable -+ ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also -+ ** specify username and an alternative port for each newsserver, ie: -+ ** .pp -+ ** [news[s]://][username[:password]@]newsserver[:port] -+ */ -+ { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" }, -+ /* -+ ** .pp -+ ** The file, containing info about subscribed newsgroups - names and -+ ** indexes of read articles. The following printf-style sequence -+ ** is understood: -+ ** .pp -+ ** .ts -+ ** %s newsserver name -+ ** .te -+ */ -+ { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 }, -+ /* -+ ** .pp -+ ** This variable defines number of articles which will be in index when -+ ** newsgroup entered. If active newsgroup have more articles than this -+ ** number, oldest articles will be ignored. Also controls how many -+ ** articles headers will be saved in cache when you quit newsgroup. -+ */ -+ { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 }, -+ /* -+ ** .pp -+ ** This variable controls whether or not descriptions for each newsgroup -+ ** must be loaded when newsgroup is added to list (first time list -+ ** loading or new newsgroup adding). -+ */ -+ { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" }, -+ /* -+ ** .pp -+ ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires -+ ** authentification, Mutt will prompt you for your account name when you -+ ** connect to newsserver. -+ */ -+ { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" }, -+ /* -+ ** .pp -+ ** Your password for NNTP account. -+ */ -+ { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 }, -+ /* -+ ** .pp -+ ** The time in seconds until any operations on newsgroup except post new -+ ** article will cause recheck for new news. If set to 0, Mutt will -+ ** recheck newsgroup on each operation in index (stepping, read article, -+ ** etc.). -+ */ -+ { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES }, -+ /* -+ ** .pp -+ ** Controls whether or not Mutt will try to reconnect to newsserver when -+ ** connection lost. -+ */ -+#endif - { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" }, - /* - ** .pp -@@ -2079,6 +2230,16 @@ struct option_t MuttVars[] = { - { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 }, - /* - */ -+#ifdef USE_NNTP -+ { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES }, -+ /* -+ ** .pp -+ ** If set to \fIyes\fP, Mutt will post article to newsgroup that have -+ ** not permissions to posting (e.g. moderated). \fBNote:\fP if newsserver -+ ** does not support posting to that newsgroup or totally read-only, that -+ ** posting will not have an effect. -+ */ -+#endif - { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES }, - /* - ** .pp -@@ -2479,6 +2640,28 @@ struct option_t MuttVars[] = { - ** Command to use when spawning a subshell. By default, the user's login - ** shell from \fC/etc/passwd\fP is used. - */ -+#ifdef USE_NNTP -+ { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 }, -+ /* -+ ** .pp -+ ** When \fIset\fP, info about unsubscribed newsgroups will be saved into -+ ** ``newsrc'' file and into cache. -+ */ -+ { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 }, -+ /* -+ ** .pp -+ ** If \fIset\fP, newsserver will be asked for new newsgroups on entering -+ ** the browser. Otherwise, it will be done only once for a newsserver. -+ ** Also controls whether or not number of new articles of subscribed -+ ** newsgroups will be then checked. -+ */ -+ { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 }, -+ /* -+ ** .pp -+ ** If \fIset\fP, only subscribed newsgroups that contain unread articles -+ ** will be displayed in browser. -+ */ -+#endif - { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 }, - /* - ** .pp -@@ -3337,6 +3520,14 @@ struct option_t MuttVars[] = { - ** Also see the $$read_inc, $$net_inc and $$time_inc variables and the - ** ``$tuning'' section of the manual for performance considerations. - */ -+#ifdef USE_NNTP -+ { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 }, -+ /* -+ ** .pp -+ ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full -+ ** name of original article author) to article that followuped to newsgroup. -+ */ -+#endif - /*--*/ - { NULL, 0, 0, 0, 0 } - }; -diff -udprP mutt-1.5.20.orig/keymap.c mutt-1.5.20/keymap.c ---- mutt-1.5.20.orig/keymap.c 2008-11-29 23:09:10.000000000 +0200 -+++ mutt-1.5.20/keymap.c 2009-06-15 21:05:24.000000000 +0300 -@@ -654,7 +654,6 @@ void km_init (void) - km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE); - - km_bindkey ("x", MENU_PAGER, OP_EXIT); -- km_bindkey ("i", MENU_PAGER, OP_EXIT); - km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE); - km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE); - km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE); -diff -udprP mutt-1.5.20.orig/mailbox.h mutt-1.5.20/mailbox.h ---- mutt-1.5.20.orig/mailbox.h 2009-04-30 08:36:17.000000000 +0300 -+++ mutt-1.5.20/mailbox.h 2009-06-15 21:05:24.000000000 +0300 -@@ -74,6 +74,9 @@ int mx_is_imap (const char *); - #ifdef USE_POP - int mx_is_pop (const char *); - #endif -+#ifdef USE_NNTP -+int mx_is_nntp (const char *); -+#endif - - int mx_access (const char*, int); - int mx_check_empty (const char *); -diff -udprP mutt-1.5.20.orig/main.c mutt-1.5.20/main.c ---- mutt-1.5.20.orig/main.c 2009-06-01 19:29:32.000000000 +0300 -+++ mutt-1.5.20/main.c 2009-06-15 21:05:24.000000000 +0300 -@@ -60,6 +60,10 @@ - #include <stringprep.h> - #endif - -+#ifdef USE_NNTP -+#include "nntp.h" -+#endif -+ - static const char *ReachingUs = N_("\ - To contact the developers, please mail to <mutt-dev@mutt.org>.\n\ - To report a bug, please visit http://bugs.mutt.org/.\n"); -@@ -133,6 +137,8 @@ options:\n\ - " -e <command>\tspecify a command to be executed after initialization\n\ - -f <file>\tspecify which mailbox to read\n\ - -F <file>\tspecify an alternate muttrc file\n\ -+ -g <server>\tspecify a newsserver (if compiled with NNTP)\n\ -+ -G\t\tselect a newsgroup (if compiled with NNTP)\n\ - -H <file>\tspecify a draft file to read header and body from\n\ - -i <file>\tspecify a file which Mutt should include in the body\n\ - -m <type>\tspecify a default mailbox type\n\ -@@ -255,6 +261,12 @@ static void show_version (void) - "-USE_POP " - #endif - -+#ifdef USE_NNTP -+ "+USE_NNTP " -+#else -+ "-USE_NNTP " -+#endif -+ - #ifdef USE_IMAP - "+USE_IMAP " - #else -@@ -522,6 +534,9 @@ static void start_curses (void) - #define M_NOSYSRC (1<<2) /* -n */ - #define M_RO (1<<3) /* -R */ - #define M_SELECT (1<<4) /* -y */ -+#ifdef USE_NNTP -+#define M_NEWS (1<<5) /* -g and -G */ -+#endif - - int main (int argc, char **argv) - { -@@ -594,7 +609,11 @@ int main (int argc, char **argv) - argv[nargc++] = argv[optind]; - } - -+#ifdef USE_NNTP -+ if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF) -+#else - if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF) -+#endif - switch (i) - { - case 'A': -@@ -691,6 +710,20 @@ int main (int argc, char **argv) - flags |= M_SELECT; - break; - -+#ifdef USE_NNTP -+ case 'g': /* Specify a newsserver */ -+ { -+ char buf[LONG_STRING]; -+ -+ snprintf (buf, sizeof (buf), "set news_server=%s", optarg); -+ commands = mutt_add_list (commands, buf); -+ } -+ -+ case 'G': /* List of newsgroups */ -+ flags |= M_SELECT | M_NEWS; -+ break; -+#endif -+ - case 'z': - flags |= M_IGNORE; - break; -@@ -978,6 +1011,18 @@ int main (int argc, char **argv) - } - else if (flags & M_SELECT) - { -+#ifdef USE_NNTP -+ if (flags & M_NEWS) -+ { -+ set_option (OPTNEWS); -+ if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer))) -+ { -+ mutt_endwin (Errorbuf); -+ exit (1); -+ } -+ } -+ else -+#endif - if (!Incoming) { - mutt_endwin _("No incoming mailboxes defined."); - exit (1); -@@ -993,6 +1038,15 @@ int main (int argc, char **argv) - - if (!folder[0]) - strfcpy (folder, NONULL(Spoolfile), sizeof (folder)); -+ -+#ifdef USE_NNTP -+ if (option (OPTNEWS)) -+ { -+ unset_option (OPTNEWS); -+ nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account); -+ } -+ else -+#endif - mutt_expand_path (folder, sizeof (folder)); - - mutt_str_replace (&CurrentFolder, folder); -diff -udprP mutt-1.5.20.orig/mutt.h mutt-1.5.20/mutt.h ---- mutt-1.5.20.orig/mutt.h 2009-06-13 01:15:42.000000000 +0300 -+++ mutt-1.5.20/mutt.h 2009-06-15 21:05:24.000000000 +0300 -@@ -229,6 +229,9 @@ enum - M_PGP_KEY, - M_XLABEL, - M_MIMEATTACH, -+#ifdef USE_NNTP -+ M_NEWSGROUPS, -+#endif - - /* Options for Mailcap lookup */ - M_EDIT, -@@ -285,6 +288,12 @@ enum - #endif - OPT_SUBJECT, - OPT_VERIFYSIG, /* verify PGP signatures */ -+#ifdef USE_NNTP -+ OPT_TOMODERATED, -+ OPT_NNTPRECONNECT, -+ OPT_CATCHUP, -+ OPT_FOLLOWUPTOPOSTER, -+#endif /* USE_NNTP */ - - /* THIS MUST BE THE LAST VALUE. */ - OPT_MAX -@@ -300,6 +309,7 @@ enum - #define SENDMAILX (1<<6) - #define SENDKEY (1<<7) - #define SENDRESEND (1<<8) -+#define SENDNEWS (1<<9) - - /* flags to _mutt_select_file() */ - #define M_SEL_BUFFY (1<<0) -@@ -319,6 +329,8 @@ enum - OPTASCIICHARS, - OPTASKBCC, - OPTASKCC, -+ OPTASKFOLLOWUP, -+ OPTASKXCOMMENTTO, - OPTATTACHSPLIT, - OPTAUTOEDIT, - OPTAUTOTAG, -@@ -396,6 +408,9 @@ enum - OPTMETOO, - OPTMHPURGE, - OPTMIMEFORWDECODE, -+#ifdef USE_NNTP -+ OPTMIMESUBJECT, /* encode subject line with RFC2047 */ -+#endif - OPTNARROWTREE, - OPTPAGERSTOP, - OPTPIPEDECODE, -@@ -477,6 +492,16 @@ enum - OPTPGPAUTOINLINE, - OPTPGPREPLYINLINE, - -+ /* news options */ -+ -+#ifdef USE_NNTP -+ OPTSHOWNEWNEWS, -+ OPTSHOWONLYUNREAD, -+ OPTSAVEUNSUB, -+ OPTLOADDESC, -+ OPTXCOMMENTTO, -+#endif /* USE_NNTP */ -+ - /* pseudo options */ - - OPTAUXSORT, /* (pseudo) using auxillary sort function */ -@@ -497,6 +522,7 @@ enum - OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */ - OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */ - OPTATTACHMSG, /* (pseudo) used by attach-message */ -+ OPTHIDEREAD, /* (pseudo) whether or not hide read messages */ - OPTKEEPQUIET, /* (pseudo) shut up the message and refresh - * functions while we are executing an - * external program. -@@ -507,6 +533,12 @@ enum - OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */ - OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */ - -+#ifdef USE_NNTP -+ OPTNEWS, /* (pseudo) used to change reader mode */ -+ OPTNEWSSEND, /* (pseudo) used to change behavior when posting */ -+ OPTNEWSCACHE, /* (pseudo) used to indicate if news cache exist */ -+#endif -+ - OPTMAX - }; - -@@ -585,6 +617,13 @@ typedef struct envelope - char *supersedes; - char *date; - char *x_label; -+ char *organization; -+#ifdef USE_NNTP -+ char *newsgroups; -+ char *xref; -+ char *followup_to; -+ char *x_comment_to; -+#endif - BUFFER *spam; - LIST *references; /* message references (in reverse order) */ - LIST *in_reply_to; /* in-reply-to header content */ -@@ -751,6 +790,9 @@ typedef struct header - ENVELOPE *env; /* envelope information */ - BODY *content; /* list of MIME parts */ - char *path; -+#ifdef USE_NNTP -+ int article_num; -+#endif - - char *tree; /* character string to print thread tree */ - THREAD *thread; -@@ -766,7 +808,7 @@ typedef struct header - int refno; /* message number on server */ - #endif - --#if defined USE_POP || defined USE_IMAP -+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP - void *data; /* driver-specific data */ - #endif - -diff -udprP mutt-1.5.20.orig/muttlib.c mutt-1.5.20/muttlib.c ---- mutt-1.5.20.orig/muttlib.c 2009-05-19 03:11:35.000000000 +0300 -+++ mutt-1.5.20/muttlib.c 2009-06-15 21:05:24.000000000 +0300 -@@ -301,7 +301,7 @@ void mutt_free_header (HEADER **h) - #ifdef MIXMASTER - mutt_free_list (&(*h)->chain); - #endif --#if defined USE_POP || defined USE_IMAP -+#if defined USE_POP || defined USE_IMAP || defined USE_NNTP - FREE (&(*h)->data); - #endif - FREE (h); /* __FREE_CHECKED__ */ -@@ -689,6 +689,13 @@ void mutt_free_envelope (ENVELOPE **p) - FREE (&(*p)->supersedes); - FREE (&(*p)->date); - FREE (&(*p)->x_label); -+ FREE (&(*p)->organization); -+#ifdef USE_NNTP -+ FREE (&(*p)->newsgroups); -+ FREE (&(*p)->xref); -+ FREE (&(*p)->followup_to); -+ FREE (&(*p)->x_comment_to); -+#endif - - mutt_buffer_free (&(*p)->spam); - -@@ -1470,6 +1477,14 @@ int mutt_save_confirm (const char *s, st - } - } - -+#ifdef USE_NNTP -+ if (magic == M_NNTP) -+ { -+ mutt_error _("Can't save message to newsserver."); -+ return 0; -+ } -+#endif -+ - if (stat (s, st) != -1) - { - if (magic == -1) -diff -udprP mutt-1.5.20.orig/mx.c mutt-1.5.20/mx.c ---- mutt-1.5.20.orig/mx.c 2009-06-11 07:29:41.000000000 +0300 -+++ mutt-1.5.20/mx.c 2009-06-15 21:05:24.000000000 +0300 -@@ -343,6 +343,22 @@ int mx_is_pop (const char *p) - } - #endif - -+#ifdef USE_NNTP -+int mx_is_nntp (const char *p) -+{ -+ url_scheme_t scheme; -+ -+ if (!p) -+ return 0; -+ -+ scheme = url_check_scheme (p); -+ if (scheme == U_NNTP || scheme == U_NNTPS) -+ return 1; -+ -+ return 0; -+} -+#endif -+ - int mx_get_magic (const char *path) - { - struct stat st; -@@ -360,6 +376,11 @@ int mx_get_magic (const char *path) - return M_POP; - #endif /* USE_POP */ - -+#ifdef USE_NNTP -+ if (mx_is_nntp (path)) -+ return M_NNTP; -+#endif /* USE_NNTP */ -+ - if (stat (path, &st) == -1) - { - dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n", -@@ -669,6 +690,12 @@ CONTEXT *mx_open_mailbox (const char *pa - break; - #endif /* USE_POP */ - -+#ifdef USE_NNTP -+ case M_NNTP: -+ rc = nntp_open_mailbox (ctx); -+ break; -+#endif /* USE_NNTP */ -+ - default: - rc = -1; - break; -@@ -761,6 +788,12 @@ static int sync_mailbox (CONTEXT *ctx, i - rc = pop_sync_mailbox (ctx, index_hint); - break; - #endif /* USE_POP */ -+ -+#ifdef USE_NNTP -+ case M_NNTP: -+ rc = nntp_sync_mailbox (ctx); -+ break; -+#endif /* USE_NNTP */ - } - - #if 0 -@@ -787,6 +820,16 @@ int mx_close_mailbox (CONTEXT *ctx, int - - ctx->closing = 1; - -+#ifdef USE_NNTP -+ if (ctx->magic == M_NNTP) -+ { -+ int ret; -+ -+ ret = nntp_close_mailbox (ctx); -+ mx_fastclose_mailbox (ctx); -+ return ret; -+ } -+#endif - if (ctx->readonly || ctx->dontwrite) - { - /* mailbox is readonly or we don't want to write */ -@@ -1336,6 +1379,11 @@ int mx_check_mailbox (CONTEXT *ctx, int - case M_POP: - return (pop_check_mailbox (ctx, index_hint)); - #endif /* USE_POP */ -+ -+#ifdef USE_NNTP -+ case M_NNTP: -+ return (nntp_check_mailbox (ctx)); -+#endif /* USE_NNTP */ - } - } - -@@ -1396,6 +1444,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx, - } - #endif /* USE_POP */ - -+#ifdef USE_NNTP -+ case M_NNTP: -+ { -+ if (nntp_fetch_message (msg, ctx, msgno) != 0) -+ FREE (&msg); -+ break; -+ } -+#endif /* USE_NNTP */ -+ - default: - dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic)); - FREE (&msg); -@@ -1517,7 +1517,11 @@ int mx_close_message (MESSAGE **msg) - int r = 0; - - if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR -- || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP) -+ || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP -+#ifdef USE_NNTP -+ || (*msg)->magic == M_NNTP -+#endif -+ ) - { - r = safe_fclose (&(*msg)->fp); - } -diff -udprP mutt-1.5.20.orig/mx.h mutt-1.5.20/mx.h ---- mutt-1.5.20.orig/mx.h 2008-11-11 21:55:47.000000000 +0200 -+++ mutt-1.5.20/mx.h 2009-06-15 21:05:24.000000000 +0300 -@@ -40,6 +40,9 @@ enum - #ifdef USE_POP - , M_POP - #endif -+#ifdef USE_NNTP -+ , M_NNTP -+#endif - }; - - WHERE short DefaultMagic INITVAL (M_MBOX); -diff -udprP mutt-1.5.20.orig/newsrc.c mutt-1.5.20/newsrc.c ---- mutt-1.5.20.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300 -+++ mutt-1.5.20/newsrc.c 2009-06-15 21:05:24.000000000 +0300 -@@ -0,0 +1,1170 @@ -+/* -+ * Copyright (C) 1998 Brandon Long <blong@fiction.net> -+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net> -+ * Copyright (C) 2000-2009 Vsevolod Volkov <vvv@mutt.org.ua> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#if HAVE_CONFIG_H -+# include "config.h" -+#endif -+ -+#include "mutt.h" -+#include "mutt_curses.h" -+#include "sort.h" -+#include "mx.h" -+#include "mime.h" -+#include "mailbox.h" -+#include "nntp.h" -+#include "rfc822.h" -+#include "rfc1524.h" -+#include "rfc2047.h" -+ -+#include <unistd.h> -+#include <string.h> -+#include <ctype.h> -+#include <stdlib.h> -+#include <sys/stat.h> -+ -+void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d) -+{ -+ LIST *l; -+ -+ if (!s || !d) -+ return; -+ -+ l = safe_calloc (1, sizeof (LIST)); -+ if (s->list) -+ s->tail->next = l; -+ else -+ s->list = l; -+ s->tail = l; -+ l->data = (void *) d; -+} -+ -+static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line) -+{ -+ NNTP_DATA *data; -+ char group[LONG_STRING]; -+ int x = 1; -+ char *p = line, *b, *h; -+ size_t len; -+ -+ while (*p) -+ { -+ if (*p++ == ',') -+ x++; -+ } -+ -+ p = line; -+ while (*p && (*p != ':' && *p != '!')) p++; -+ if (!*p) -+ return -1; -+ len = p + 1 - line; -+ if (len > sizeof (group)) -+ len = sizeof (group); -+ strfcpy (group, line, len); -+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL) -+ { -+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1); -+ data->group = (char *) data + sizeof (NNTP_DATA); -+ strcpy (data->group, group); -+ data->nserv = news; -+ data->deleted = 1; -+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2) -+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0); -+ hash_insert (news->newsgroups, data->group, data, 0); -+ nntp_add_to_list (news, data); -+ } -+ else -+ FREE ((void **) &data->entries); -+ -+ data->rc = 1; -+ data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY)); -+ data->max = x*2; -+ -+ if (*p == ':') -+ data->subscribed = 1; -+ else -+ data->subscribed = 0; -+ -+ p++; -+ b = p; -+ x = 0; -+ while (*b) -+ { -+ while (*p && *p != ',' && *p != '\n') p++; -+ if (*p) -+ { -+ *p = '\0'; -+ p++; -+ } -+ if ((h = strchr(b, '-'))) -+ { -+ *h = '\0'; -+ h++; -+ data->entries[x].first = atoi(b); -+ data->entries[x].last = atoi(h); -+ } -+ else -+ { -+ data->entries[x].first = atoi(b); -+ data->entries[x].last = data->entries[x].first; -+ } -+ b = p; -+ if (data->entries[x].last != 0) -+ x++; -+ } -+ if (x && !data->lastMessage) -+ data->lastMessage = data->entries[x-1].last; -+ data->num = x; -+ mutt_newsgroup_stat (data); -+ dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group)); -+ -+ return 0; -+} -+ -+static int slurp_newsrc (NNTP_SERVER *news) -+{ -+ FILE *fp; -+ char *buf; -+ struct stat sb; -+ -+ news->stat = stat (news->newsrc, &sb); -+ news->size = sb.st_size; -+ news->mtime = sb.st_mtime; -+ -+ if ((fp = safe_fopen (news->newsrc, "r")) == NULL) -+ return -1; -+ /* hmm, should we use dotlock? */ -+ if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1)) -+ { -+ fclose (fp); -+ return -1; -+ } -+ -+ buf = safe_malloc (sb.st_size + 1); -+ while (sb.st_size && fgets (buf, sb.st_size + 1, fp)) -+ nntp_parse_newsrc_line (news, buf); -+ FREE (&buf); -+ -+ mx_unlock_file (news->newsrc, fileno (fp), 0); -+ fclose (fp); -+ return 0; -+} -+ -+void nntp_cache_expand (char *dst, const char *src) -+{ -+ snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src); -+ mutt_expand_path (dst, _POSIX_PATH_MAX); -+} -+ -+/* Loads $news_cache_dir/.index into memory, loads newsserver data -+ * and newsgroup cache names */ -+static int nntp_parse_cacheindex (NNTP_SERVER *news) -+{ -+ struct stat st; -+ char buf[HUGE_STRING], *cp; -+ char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX]; -+ FILE *index; -+ NNTP_DATA *data; -+ int l, m, t; -+ -+ /* check is server name defined or not */ -+ if (!news || !news->conn || !news->conn->account.host) -+ return -1; -+ unset_option (OPTNEWSCACHE); -+ if (!NewsCacheDir || !*NewsCacheDir) -+ return 0; -+ -+ strfcpy (dir, NewsCacheDir, sizeof (dir)); -+ mutt_expand_path (dir, sizeof(dir)); -+ -+ if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0) -+ { -+ snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir); -+ if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+ -+ S_IRWXO))) -+ { -+ mutt_error _("Cache directory not created!"); -+ return -1; -+ } -+ mutt_clear_error(); -+ } -+ -+ set_option (OPTNEWSCACHE); -+ -+ FREE (&news->cache); -+ snprintf (buf, sizeof(buf), "%s/.index", dir); -+ if (!(index = safe_fopen (buf, "a+"))) -+ return 0; -+ rewind (index); -+ while (fgets (buf, sizeof(buf), index)) -+ { -+ buf[strlen(buf) - 1] = 0; /* strip ending '\n' */ -+ if (!mutt_strncmp (buf, "#: ", 3) && -+ !mutt_strcasecmp (buf+3, news->conn->account.host)) -+ break; -+ } -+ while (fgets (buf, sizeof(buf), index)) -+ { -+ cp = buf; -+ while (*cp && *cp != ' ') cp++; -+ if (!*cp) continue; -+ cp[0] = 0; -+ if (!mutt_strcmp (buf, "#:")) -+ break; -+ sscanf (cp + 1, "%s %d %d", file, &l, &m); -+ if (!mutt_strcmp (buf, "ALL")) -+ { -+ news->cache = safe_strdup (file); -+ news->newgroups_time = m; -+ } -+ else if (news->newsgroups) -+ { -+ if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL) -+ { -+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1); -+ data->group = (char *) data + sizeof (NNTP_DATA); -+ strcpy(data->group, buf); -+ data->nserv = news; -+ data->deleted = 1; -+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2) -+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0); -+ hash_insert (news->newsgroups, data->group, data, 0); -+ nntp_add_to_list (news, data); -+ } -+ data->cache = safe_strdup (file); -+ t = 0; -+ if (!data->firstMessage || data->lastMessage < m) -+ t = 1; -+ if (!data->firstMessage) -+ data->firstMessage = l; -+ if (data->lastMessage < m) -+ data->lastMessage = m; -+ data->lastCached = m; -+ if (t || !data->unread) -+ mutt_newsgroup_stat (data); -+ } -+ } -+ fclose (index); -+ return 0; -+} -+ -+const char * -+nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src, -+ const char *fmt, const char *ifstring, const char *elsestring, -+ unsigned long data, format_flag flags) -+{ -+ char fn[SHORT_STRING], tmp[SHORT_STRING]; -+ -+ switch (op) -+ { -+ case 's': -+ strncpy (fn, NewsServer, sizeof(fn) - 1); -+ mutt_strlower (fn); -+ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); -+ snprintf (dest, destlen, tmp, fn); -+ break; -+ } -+ return (src); -+} -+ -+/* nntp_parse_url: given an NNPT URL, return host, port, -+ * username, password and newsgroup will recognise. */ -+int nntp_parse_url (const char *server, ACCOUNT *acct, -+ char *group, size_t group_len) -+{ -+ ciss_url_t url; -+ char *c; -+ int ret = -1; -+ -+ /* Defaults */ -+ acct->flags = 0; -+ acct->port = NNTP_PORT; -+ acct->type = M_ACCT_TYPE_NNTP; -+ -+ c = safe_strdup (server); -+ url_parse_ciss (&url, c); -+ -+ if (url.scheme == U_NNTP || url.scheme == U_NNTPS) -+ { -+ if (url.scheme == U_NNTPS) -+ { -+ acct->flags |= M_ACCT_SSL; -+ acct->port = NNTP_SSL_PORT; -+ } -+ -+ *group = '\0'; -+ if (url.path) -+ strfcpy (group, url.path, group_len); -+ -+ ret = mutt_account_fromurl (acct, &url); -+ } -+ -+ FREE (&c); -+ return ret; -+} -+ -+void nntp_expand_path (char *line, size_t len, ACCOUNT *acct) -+{ -+ ciss_url_t url; -+ -+ url.path = safe_strdup (line); -+ mutt_account_tourl (acct, &url); -+ url_ciss_tostring (&url, line, len, 0); -+ FREE (&url.path); -+} -+ -+/* -+ * Automatically loads a newsrc into memory, if necessary. -+ * Checks the size/mtime of a newsrc file, if it doesn't match, load -+ * again. Hmm, if a system has broken mtimes, this might mean the file -+ * is reloaded every time, which we'd have to fix. -+ * -+ * a newsrc file is a line per newsgroup, with the newsgroup, then a -+ * ':' denoting subscribed or '!' denoting unsubscribed, then a -+ * comma separated list of article numbers and ranges. -+ */ -+NNTP_SERVER *mutt_select_newsserver (char *server) -+{ -+ char file[_POSIX_PATH_MAX]; -+ char *buf, *p; -+ LIST *list; -+ ACCOUNT acct; -+ NNTP_SERVER *serv; -+ CONNECTION *conn; -+ -+ if (!server || !*server) -+ { -+ mutt_error _("No newsserver defined!"); -+ return NULL; -+ } -+ -+ buf = p = safe_calloc (strlen (server) + 10, sizeof (char)); -+ if (url_check_scheme (server) == U_UNKNOWN) -+ { -+ strcpy (buf, "news://"); -+ p = strchr (buf, '\0'); -+ } -+ strcpy (p, server); -+ -+ if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file) -+ { -+ FREE (&buf); -+ mutt_error (_("%s is an invalid newsserver specification!"), server); -+ return NULL; -+ } -+ FREE (&buf); -+ -+ conn = mutt_conn_find (NULL, &acct); -+ if (!conn) -+ return NULL; -+ -+ mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), nntp_format_str, 0, 0); -+ mutt_expand_path (file, sizeof (file)); -+ -+ serv = (NNTP_SERVER *)conn->data; -+ if (serv) -+ { -+ struct stat sb; -+ -+ /* externally modified? */ -+ if (serv->stat != stat (file, &sb) || (!serv->stat && -+ (serv->size != sb.st_size || serv->mtime != sb.st_mtime))) -+ { -+ for (list = serv->list; list; list = list->next) -+ { -+ NNTP_DATA *data = (NNTP_DATA *) list->data; -+ -+ if (data) -+ { -+ data->subscribed = 0; -+ data->rc = 0; -+ data->num = 0; -+ } -+ } -+ slurp_newsrc (serv); -+ nntp_clear_cacheindex (serv); -+ } -+ -+ if (serv->status == NNTP_BYE) -+ serv->status = NNTP_NONE; -+ nntp_check_newgroups (serv, 0); -+ return serv; -+ } -+ -+ /* New newsserver */ -+ serv = safe_calloc (1, sizeof (NNTP_SERVER)); -+ serv->conn = conn; -+ serv->newsrc = safe_strdup (file); -+ serv->newsgroups = hash_create (1009, 0); -+ slurp_newsrc (serv); /* load .newsrc */ -+ nntp_parse_cacheindex (serv); /* load .index */ -+ if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0) -+ nntp_check_newgroups (serv, 1); -+ else if (nntp_get_active (serv) < 0) -+ { -+ hash_destroy (&serv->newsgroups, nntp_delete_data); -+ for (list = serv->list; list; list = list->next) -+ list->data = NULL; -+ mutt_free_list (&serv->list); -+ FREE (&serv->newsrc); -+ FREE (&serv->cache); -+ FREE (&serv); -+ return NULL; -+ } -+ nntp_clear_cacheindex (serv); -+ conn->data = (void *)serv; -+ -+ return serv; -+} -+ -+/* -+ * full status flags are not supported by nntp, but we can fake some -+ * of them. This is how: -+ * Read = a read message number is in the .newsrc -+ * New = a message is new since we last read this newsgroup -+ * Old = anything else -+ * So, Read is marked as such in the newsrc, old is anything that is -+ * "skipped" in the newsrc, and new is anything not in the newsrc nor -+ * in the cache. By skipped, I mean before the last unread message -+ */ -+void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article) -+{ -+ NNTP_DATA *data = (NNTP_DATA *) ctx->data; -+ int x; -+ -+ if (group) -+ data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group); -+ -+ if (!data) -+ { -+#ifdef DEBUG -+ if (group) -+ dprint (3, (debugfile, "newsgroup %s not found\n", group)); -+#endif -+ return; -+ } -+ -+ for (x = 0; x < data->num; x++) -+ { -+ if ((article >= data->entries[x].first) && -+ (article <= data->entries[x].last)) -+ { -+ /* we cannot use mutt_set_flag() because mx_update_context() -+ didn't called yet */ -+ h->read = 1; -+ return; -+ } -+ } -+ /* If article was not cached yet, it is new! :) */ -+ if (!data->cache || article > data->lastCached) -+ return; -+ /* Old articles are articles which aren't read but an article after them -+ * has been cached */ -+ if (option (OPTMARKOLD)) -+ h->old = 1; -+} -+ -+void mutt_newsgroup_stat (NNTP_DATA *data) -+{ -+ int i; -+ unsigned int first, last; -+ -+ data->unread = 0; -+ if (data->lastMessage == 0 || data->firstMessage > data->lastMessage) -+ return; -+ -+ data->unread = data->lastMessage - data->firstMessage + 1; -+ for (i = 0; i < data->num; i++) -+ { -+ first = data->entries[i].first; -+ if (first < data->firstMessage) -+ first = data->firstMessage; -+ last = data->entries[i].last; -+ if (last > data->lastMessage) -+ last = data->lastMessage; -+ if (first <= last) -+ data->unread -= last - first + 1; -+ } -+} -+ -+static int puti (char *line, int num) -+{ -+ char *p, s[32]; -+ -+ for (p = s; num; ) -+ { -+ *p++ = '0' + num % 10; -+ num /= 10; -+ } -+ while (p > s) -+ *line++ = *--p, num++; -+ *line = '\0'; -+ return num; -+} -+ -+static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen) -+{ -+ char *line = *pline; -+ size_t len = *buflen - (*pline - *buf); -+ int x, i; -+ -+ if (len < LONG_STRING * 10) -+ { -+ len += *buflen; -+ *buflen *= 2; -+ line = *buf; -+ safe_realloc (buf, *buflen); -+ line = *buf + (*pline - line); -+ } -+ strcpy (line, data->group); -+ len -= strlen (line) + 1; -+ line += strlen (line); -+ *line++ = data->subscribed ? ':' : '!'; -+ *line++ = ' '; -+ *line = '\0'; -+ -+ for (x = 0; x < data->num; x++) -+ { -+ if (len < LONG_STRING) -+ { -+ len += *buflen; -+ *buflen *= 2; -+ *pline = line; -+ line = *buf; -+ safe_realloc (buf, *buflen); -+ line = *buf + (*pline - line); -+ } -+ if (x) -+ { -+ *line++ = ','; -+ len--; -+ } -+ -+#if 0 -+ if (data->entries[x].first == data->entries[x].last) -+ snprintf (line, len, "%d%n", data->entries[x].first, &i); -+ else -+ snprintf (line, len, "%d-%d%n", -+ data->entries[x].first, data->entries[x].last, &i); -+ len -= i; -+ line += i; -+#else -+ i = puti (line, data->entries[x].first); -+ line +=i; len -= i; -+ if (data->entries[x].first != data->entries[x].last) -+ { -+ *line++ = '-'; -+ len--; -+ i = puti (line, data->entries[x].last); -+ line +=i; len -= i; -+ } -+#endif -+ } -+ *line++ = '\n'; -+ *line = '\0'; -+ *pline = line; -+} -+ -+void newsrc_gen_entries (CONTEXT *ctx) -+{ -+ NNTP_DATA *data = (NNTP_DATA *)ctx->data; -+ int series, x; -+ unsigned int last = 0, first = 1; -+ int save_sort = SORT_ORDER; -+ -+ if (Sort != SORT_ORDER) -+ { -+ save_sort = Sort; -+ Sort = SORT_ORDER; -+ mutt_sort_headers (ctx, 0); -+ } -+ -+ if (!data->max) -+ { -+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY)); -+ data->max = 5; -+ } -+ -+ /* -+ * Set up to fake initial sequence from 1 to the article before the -+ * first article in our list -+ */ -+ data->num = 0; -+ series = 1; -+ -+ for (x = 0; x < ctx->msgcount; x++) -+ { -+ if (series) /* search for first unread */ -+ { -+ /* -+ * We don't actually check sequential order, since we mark -+ * "missing" entries as read/deleted -+ */ -+ last = ctx->hdrs[x]->article_num; -+ if (last >= data->firstMessage && !ctx->hdrs[x]->deleted && -+ !ctx->hdrs[x]->read) -+ { -+ if (data->num >= data->max) -+ { -+ data->max = data->max * 2; -+ safe_realloc (&data->entries, -+ data->max * sizeof (NEWSRC_ENTRY)); -+ } -+ data->entries[data->num].first = first; -+ data->entries[data->num].last = last - 1; -+ data->num++; -+ series = 0; -+ } -+ } -+ else /* search for first read */ -+ { -+ if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read) -+ { -+ first = last + 1; -+ series = 1; -+ } -+ last = ctx->hdrs[x]->article_num; -+ } -+ } -+ if (series && first <= data->lastLoaded) -+ { -+ if (data->num >= data->max) -+ { -+ data->max = data->max * 2; -+ safe_realloc (&data->entries, -+ data->max * sizeof (NEWSRC_ENTRY)); -+ } -+ data->entries[data->num].first = first; -+ data->entries[data->num].last = data->lastLoaded; -+ data->num++; -+ } -+ -+ if (save_sort != Sort) -+ { -+ Sort = save_sort; -+ mutt_sort_headers (ctx, 0); -+ } -+} -+ -+static int mutt_update_list_file (char *filename, char *section, -+ char *key, char *line) -+{ -+ FILE *ifp; -+ FILE *ofp; -+ char buf[HUGE_STRING]; -+ char tmpfile[_POSIX_PATH_MAX]; -+ char *c; -+ int ext = 0, done = 0, r = 0; -+ -+ /* if file not exist, create it */ -+ if ((ifp = safe_fopen (filename, "a"))) -+ fclose (ifp); -+ dprint (1, (debugfile, "Opening %s\n", filename)); -+ if (!(ifp = safe_fopen (filename, "r"))) -+ { -+ mutt_error (_("Unable to open %s for reading"), filename); -+ return -1; -+ } -+ if (mx_lock_file (filename, fileno (ifp), 0, 0, 1)) -+ { -+ fclose (ifp); -+ mutt_error (_("Unable to lock %s"), filename); -+ return -1; -+ } -+ snprintf (tmpfile, sizeof(tmpfile), "%s.tmp", filename); -+ dprint (1, (debugfile, "Opening %s\n", tmpfile)); -+ if (!(ofp = fopen (tmpfile, "w"))) -+ { -+ fclose (ifp); -+ mutt_error (_("Unable to open %s for writing"), tmpfile); -+ return -1; -+ } -+ -+ if (section) -+ { -+ while (r != EOF && !done && fgets (buf, sizeof (buf), ifp)) -+ { -+ r = fputs (buf, ofp); -+ c = buf; -+ while (*c && *c != '\n') c++; -+ c[0] = 0; /* strip EOL */ -+ if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section)) -+ done++; -+ } -+ if (r != EOF && !done) -+ { -+ snprintf (buf, sizeof(buf), "#: %s\n", section); -+ r = fputs (buf, ofp); -+ } -+ done = 0; -+ } -+ -+ while (r != EOF && fgets (buf, sizeof (buf), ifp)) -+ { -+ if (ext) -+ { -+ c = buf; -+ while (*c && (*c != '\r') && (*c != '\n')) c++; -+ c--; -+ if (*c != '\\') ext = 0; -+ } -+ else if ((section && !strncmp (buf, "#: ", 3))) -+ { -+ if (!done && line) -+ { -+ fputs (line, ofp); -+ fputc ('\n', ofp); -+ } -+ r = fputs (buf, ofp); -+ done++; -+ break; -+ } -+ else if (key && !strncmp (buf, key, strlen(key)) && -+ (!*key || buf[strlen(key)] == ' ')) -+ { -+ c = buf; -+ ext = 0; -+ while (*c && (*c != '\r') && (*c != '\n')) c++; -+ c--; -+ if (*c == '\\') ext = 1; -+ if (!done && line) -+ { -+ r = fputs (line, ofp); -+ if (*key) -+ r = fputc ('\n', ofp); -+ done++; -+ } -+ } -+ else -+ { -+ r = fputs (buf, ofp); -+ } -+ } -+ -+ while (r != EOF && fgets (buf, sizeof (buf), ifp)) -+ r = fputs (buf, ofp); -+ -+ /* If there wasn't a line to replace, put it on the end of the file */ -+ if (r != EOF && !done && line) -+ { -+ fputs (line, ofp); -+ r = fputc ('\n', ofp); -+ } -+ mx_unlock_file (filename, fileno (ifp), 0); -+ fclose (ofp); -+ fclose (ifp); -+ if (r == EOF) -+ { -+ unlink (tmpfile); -+ mutt_error (_("Can't write %s"), tmpfile); -+ return -1; -+ } -+ if (rename (tmpfile, filename) < 0) -+ { -+ unlink (tmpfile); -+ mutt_error (_("Can't rename %s to %s"), tmpfile, filename); -+ return -1; -+ } -+ return 0; -+} -+ -+int mutt_newsrc_update (NNTP_SERVER *news) -+{ -+ char *buf, *line; -+ NNTP_DATA *data; -+ LIST *tmp; -+ int r = -1; -+ size_t len, llen; -+ -+ if (!news) -+ return -1; -+ llen = len = 10 * LONG_STRING; -+ line = buf = safe_calloc (1, len); -+ /* we will generate full newsrc here */ -+ for (tmp = news->list; tmp; tmp = tmp->next) -+ { -+ data = (NNTP_DATA *) tmp->data; -+ if (!data || !data->rc) -+ continue; -+ nntp_create_newsrc_line (data, &buf, &line, &llen); -+ if (*line) -+ dprint (2, (debugfile, "Added to newsrc: %s\n", line)); -+ line += strlen (line); -+ } -+ /* newrc being fully rewritten */ -+ if (news->newsrc && -+ (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0) -+ { -+ struct stat st; -+ -+ stat (news->newsrc, &st); -+ news->size = st.st_size; -+ news->mtime = st.st_mtime; -+ } -+ FREE (&buf); -+ return r; -+} -+ -+static FILE *mutt_mkname (char *s) -+{ -+ char buf[_POSIX_PATH_MAX], *pc; -+ int fd; -+ FILE *fp; -+ -+ nntp_cache_expand (buf, s); -+ if ((fp = safe_fopen (buf, "w"))) -+ return fp; -+ -+ nntp_cache_expand (buf, "cache-XXXXXX"); -+ pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */ -+ if ((fd = mkstemp (buf)) == -1) -+ return NULL; -+ strcpy (s, pc); /* generated name */ -+ return fdopen (fd, "w"); -+} -+ -+/* Updates info into .index file: ALL or about selected newsgroup */ -+static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data) -+{ -+ char buf[LONG_STRING], *key = "ALL"; -+ char file[_POSIX_PATH_MAX]; -+ -+ if (!serv || !serv->conn || !serv->conn->account.host) -+ return -1; -+ -+ if (data && data->group) -+ { -+ key = data->group; -+ snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache, -+ data->firstMessage, data->lastLoaded); -+ } -+ else -+ { -+ strfcpy (file, serv->cache, sizeof (file)); -+ snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time); -+ } -+ nntp_cache_expand (file, ".index"); -+ return mutt_update_list_file (file, serv->conn->account.host, key, buf); -+} -+ -+/* Remove cache files of unsubscribed newsgroups */ -+void nntp_clear_cacheindex (NNTP_SERVER *news) -+{ -+ NNTP_DATA *data; -+ LIST *tmp; -+ -+ if (option (OPTSAVEUNSUB) || !news) -+ return; -+ -+ for (tmp = news->list; tmp; tmp = tmp->next) -+ { -+ data = (NNTP_DATA *) tmp->data; -+ if (!data || data->subscribed || !data->cache) -+ continue; -+ nntp_delete_cache (data); -+ dprint (2, (debugfile, "Removed from .index: %s\n", data->group)); -+ } -+ return; -+} -+ -+int nntp_save_cache_index (NNTP_SERVER *news) -+{ -+ char buf[HUGE_STRING]; -+ char file[_POSIX_PATH_MAX]; -+ NNTP_DATA *d; -+ FILE *f; -+ LIST *l; -+ -+ if (!news || !news->newsgroups) -+ return -1; -+ if (!option (OPTNEWSCACHE)) -+ return 0; -+ -+ if (news->cache) -+ { -+ nntp_cache_expand (file, news->cache); -+ unlink (file); -+ f = safe_fopen (file, "w"); -+ } -+ else -+ { -+ strfcpy (buf, news->conn->account.host, sizeof(buf)); -+ f = mutt_mkname (buf); -+ news->cache = safe_strdup (buf); -+ nntp_cache_expand (file, buf); -+ } -+ if (!f) -+ return -1; -+ -+ for (l = news->list; l; l = l->next) -+ { -+ if ((d = (NNTP_DATA *)l->data) && !d->deleted) -+ { -+ if (d->desc) -+ snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group, -+ d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n', -+ d->desc); -+ else -+ snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group, -+ d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n'); -+ if (fputs (buf, f) == EOF) -+ { -+ fclose (f); -+ unlink (file); -+ return -1; -+ } -+ } -+ } -+ fclose (f); -+ -+ if (nntp_update_cacheindex (news, NULL)) -+ { -+ unlink (file); -+ return -1; -+ } -+ return 0; -+} -+ -+int nntp_save_cache_group (CONTEXT *ctx) -+{ -+ char buf[HUGE_STRING], addr[STRING]; -+ char file[_POSIX_PATH_MAX]; -+ FILE *f; -+ HEADER *h; -+ struct tm *tm; -+ int i = 0, save = SORT_ORDER; -+ int prev = 0; -+ -+ if (!option (OPTNEWSCACHE)) -+ return 0; -+ if (!ctx || !ctx->data || ctx->magic != M_NNTP) -+ return -1; -+ -+ if (((NNTP_DATA *)ctx->data)->cache) -+ { -+ nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache); -+ unlink (file); -+ f = safe_fopen (file, "w"); -+ } -+ else -+ { -+ snprintf (buf, sizeof(buf), "%s-%s", -+ ((NNTP_DATA *)ctx->data)->nserv->conn->account.host, -+ ((NNTP_DATA *)ctx->data)->group); -+ f = mutt_mkname (buf); -+ ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf); -+ nntp_cache_expand (file, buf); -+ } -+ if (!f) -+ return -1; -+ -+ if (Sort != SORT_ORDER) -+ { -+ save = Sort; -+ Sort = SORT_ORDER; -+ mutt_sort_headers (ctx, 0); -+ } -+ -+ /* Save only $nntp_context messages... */ -+ ((NNTP_DATA *)ctx->data)->lastCached = 0; -+ if (NntpContext && ctx->msgcount > NntpContext) -+ i = ctx->msgcount - NntpContext; -+ for (; i < ctx->msgcount; i++) -+ { -+ if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev) -+ { -+ h = ctx->hdrs[i]; -+ addr[0] = 0; -+ rfc822_write_address (addr, sizeof(addr), h->env->from, 0); -+ tm = gmtime (&h->date_sent); -+ snprintf (buf, sizeof(buf), -+ "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t", -+ h->article_num, h->env->subject, addr, tm->tm_mday, -+ Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min, -+ tm->tm_sec, h->env->message_id); -+ fputs (buf, f); -+ if (h->env->references) -+ mutt_write_references (h->env->references, f, 10); -+ snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", (long int) h->content->length, -+ (int) h->lines, NONULL(h->env->xref)); -+ if (fputs (buf, f) == EOF) -+ { -+ fclose (f); -+ unlink (file); -+ return -1; -+ } -+ } -+ prev = ctx->hdrs[i]->article_num; -+ } -+ -+ if (save != Sort) -+ { -+ Sort = save; -+ mutt_sort_headers (ctx, 0); -+ } -+ fclose (f); -+ -+ if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv, -+ (NNTP_DATA *)ctx->data)) -+ { -+ unlink (file); -+ return -1; -+ } -+ ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded; -+ return 0; -+} -+ -+void nntp_delete_cache (NNTP_DATA *data) -+{ -+ char buf[_POSIX_PATH_MAX]; -+ -+ if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv) -+ return; -+ -+ nntp_cache_expand (buf, data->cache); -+ unlink (buf); -+ FREE (&data->cache); -+ data->lastCached = 0; -+ nntp_cache_expand (buf, ".index"); -+ mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL); -+} -+ -+NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group) -+{ -+ NNTP_DATA *data; -+ -+ if (!news || !news->newsgroups || !group || !*group) -+ return NULL; -+ if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group))) -+ { -+ data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1); -+ data->group = (char *) data + sizeof (NNTP_DATA); -+ strcpy (data->group, group); -+ data->nserv = news; -+ data->deleted = 1; -+ if (news->newsgroups->nelem < news->newsgroups->curnelem * 2) -+ news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2, 0); -+ hash_insert (news->newsgroups, data->group, data, 0); -+ nntp_add_to_list (news, data); -+ } -+ if (!data->subscribed) -+ { -+ data->subscribed = 1; -+ data->rc = 1; -+ } -+ return data; -+} -+ -+NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group) -+{ -+ NNTP_DATA *data; -+ -+ if (!news || !news->newsgroups || !group || !*group || -+ !(data = (NNTP_DATA *)hash_find (news->newsgroups, group))) -+ return NULL; -+ if (data->subscribed) -+ { -+ data->subscribed = 0; -+ if (!option (OPTSAVEUNSUB)) -+ data->rc = 0; -+ } -+ return data; -+} -+ -+NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group) -+{ -+ NNTP_DATA *data; -+ -+ if (!news || !news->newsgroups || !group || !*group || -+ !(data = (NNTP_DATA *)hash_find (news->newsgroups, group))) -+ return NULL; -+ if (!data->max) -+ { -+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY)); -+ data->max = 5; -+ } -+ data->num = 1; -+ data->entries[0].first = 1; -+ data->unread = 0; -+ data->entries[0].last = data->lastMessage; -+ if (Context && Context->data == data) -+ { -+ int x; -+ -+ for (x = 0; x < Context->msgcount; x++) -+ mutt_set_flag (Context, Context->hdrs[x], M_READ, 1); -+ } -+ return data; -+} -+ -+NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group) -+{ -+ NNTP_DATA *data; -+ -+ if (!news || !news->newsgroups || !group || !*group || -+ !(data = (NNTP_DATA *)hash_find (news->newsgroups, group))) -+ return NULL; -+ if (!data->max) -+ { -+ data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY)); -+ data->max = 5; -+ } -+ data->num = 1; -+ data->entries[0].first = 1; -+ data->entries[0].last = data->firstMessage - 1; -+ if (Context && Context->data == data) -+ { -+ int x; -+ -+ data->unread = Context->msgcount; -+ for (x = 0; x < Context->msgcount; x++) -+ mutt_set_flag (Context, Context->hdrs[x], M_READ, 0); -+ } -+ else -+ data->unread = data->lastMessage - data->entries[0].last; -+ return data; -+} -+ -+/* this routine gives the first newsgroup with new messages */ -+void nntp_buffy (char *s) -+{ -+ LIST *list; -+ -+ for (list = CurrentNewsSrv->list; list; list = list->next) -+ { -+ NNTP_DATA *data = (NNTP_DATA *) list->data; -+ -+ if (data && data->subscribed && data->unread) -+ { -+ if (Context && Context->magic == M_NNTP && -+ !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group)) -+ { -+ unsigned int i, unread = 0; -+ -+ for (i = 0; i < Context->msgcount; i++) -+ if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted) -+ unread++; -+ if (!unread) -+ continue; -+ } -+ strcpy (s, data->group); -+ break; -+ } -+ } -+} -diff -udprP mutt-1.5.20.orig/nntp.c mutt-1.5.20/nntp.c ---- mutt-1.5.20.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300 -+++ mutt-1.5.20/nntp.c 2009-06-15 21:05:24.000000000 +0300 -@@ -0,0 +1,1588 @@ -+/* -+ * Copyright (C) 1998 Brandon Long <blong@fiction.net> -+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net> -+ * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#if HAVE_CONFIG_H -+# include "config.h" -+#endif -+ -+#include "mutt.h" -+#include "mutt_curses.h" -+#include "sort.h" -+#include "mx.h" -+#include "mime.h" -+#include "rfc1524.h" -+#include "rfc2047.h" -+#include "mailbox.h" -+#include "nntp.h" -+ -+#ifdef HAVE_PGP -+#include "pgp.h" -+#endif -+ -+#ifdef HAVE_SMIME -+#include "smime.h" -+#endif -+ -+#include <unistd.h> -+#include <string.h> -+#include <ctype.h> -+#include <stdlib.h> -+ -+static unsigned int _checked = 0; -+ -+#ifdef DEBUG -+static void nntp_error (const char *where, const char *msg) -+{ -+ dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg)); -+} -+#endif /* DEBUG */ -+ -+static int nntp_auth (NNTP_SERVER *serv) -+{ -+ CONNECTION *conn = serv->conn; -+ char buf[STRING]; -+ unsigned char flags = conn->account.flags; -+ -+ if (mutt_account_getuser (&conn->account) || !conn->account.user[0] || -+ mutt_account_getpass (&conn->account) || !conn->account.pass[0]) -+ { -+ conn->account.flags = flags; -+ return -2; -+ } -+ -+ mutt_message _("Logging in..."); -+ -+ snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user); -+ mutt_socket_write (conn, buf); -+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) -+ { -+ conn->account.flags = flags; -+ return -1; -+ } -+ -+#ifdef DEBUG -+ /* don't print the password unless we're at the ungodly debugging level */ -+ if (debuglevel < M_SOCK_LOG_FULL) -+ dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n")); -+#endif -+ snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass); -+ mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL); -+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) -+ { -+ conn->account.flags = flags; -+ return -1; -+ } -+ -+ if (mutt_strncmp ("281", buf, 3)) -+ { -+ conn->account.flags = flags; -+ mutt_error _("Login failed."); -+ sleep (2); -+ return -3; -+ } -+ -+ return 0; -+} -+ -+static int nntp_connect_error (NNTP_SERVER *serv) -+{ -+ serv->status = NNTP_NONE; -+ mutt_socket_close (serv->conn); -+ mutt_error _("Server closed connection!"); -+ sleep (2); -+ return -1; -+} -+ -+static int nntp_connect_and_auth (NNTP_SERVER *serv) -+{ -+ CONNECTION *conn = serv->conn; -+ char buf[STRING]; -+ int rc; -+ -+ serv->status = NNTP_NONE; -+ -+ if (mutt_socket_open (conn) < 0) -+ return -1; -+ -+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) -+ return nntp_connect_error (serv); -+ -+ if (!mutt_strncmp ("200", buf, 3)) -+ mutt_message (_("Connected to %s. Posting ok."), conn->account.host); -+ else if (!mutt_strncmp ("201", buf, 3)) -+ mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host); -+ else -+ { -+ mutt_socket_close (conn); -+ mutt_remove_trailing_ws (buf); -+ mutt_error ("%s", buf); -+ sleep (2); -+ return -1; -+ } -+ -+ sleep (1); -+ -+ /* Tell INN to switch to mode reader if it isn't so. Ignore all -+ returned codes and messages. */ -+ mutt_socket_write (conn, "MODE READER\r\n"); -+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) -+ return nntp_connect_error (serv); -+ -+ mutt_socket_write (conn, "STAT\r\n"); -+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) -+ return nntp_connect_error (serv); -+ -+ if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3)) -+ { -+ serv->status = NNTP_OK; -+ return 0; -+ } -+ -+ rc = nntp_auth (serv); -+ if (rc == -1) -+ return nntp_connect_error (serv); -+ if (rc == -2) -+ { -+ mutt_socket_close (conn); -+ serv->status = NNTP_BYE; -+ return -1; -+ } -+ if (rc < 0) -+ { -+ mutt_socket_close (conn); -+ mutt_error _("Login failed."); -+ sleep (2); -+ return -1; -+ } -+ serv->status = NNTP_OK; -+ return 0; -+} -+ -+static int nntp_attempt_features (NNTP_SERVER *serv) -+{ -+ char buf[LONG_STRING]; -+ CONNECTION *conn = serv->conn; -+ -+ mutt_socket_write (conn, "XOVER\r\n"); -+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) -+ return nntp_connect_error (serv); -+ if (mutt_strncmp ("500", buf, 3)) -+ serv->hasXOVER = 1; -+ -+ mutt_socket_write (conn, "XPAT\r\n"); -+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) -+ return nntp_connect_error (serv); -+ if (mutt_strncmp ("500", buf, 3)) -+ serv->hasXPAT = 1; -+ -+ mutt_socket_write (conn, "LISTGROUP\r\n"); -+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) -+ return nntp_connect_error (serv); -+ if (mutt_strncmp ("500", buf, 3)) -+ serv->hasLISTGROUP = 1; -+ -+ mutt_socket_write (conn, "XGTITLE +\r\n"); -+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) -+ return nntp_connect_error (serv); -+ if (mutt_strncmp ("500", buf, 3)) -+ serv->hasXGTITLE = 1; -+ -+ if (!mutt_strncmp ("282", buf, 3)) -+ { -+ do -+ { -+ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) -+ return nntp_connect_error (serv); -+ } while (!(buf[0] == '.' && buf[1] == '\0')); -+ } -+ -+ return 0; -+} -+ -+static int nntp_open_connection (NNTP_SERVER *serv) -+{ -+ if (serv->status == NNTP_OK) -+ return 0; -+ if (serv->status == NNTP_BYE) -+ return -1; -+ if (nntp_connect_and_auth (serv) < 0) -+ return -1; -+ if (nntp_attempt_features (serv) < 0) -+ return -1; -+ return 0; -+} -+ -+static int nntp_reconnect (NNTP_SERVER *serv) -+{ -+ char buf[SHORT_STRING]; -+ -+ mutt_socket_close (serv->conn); -+ -+ FOREVER -+ { -+ if (nntp_connect_and_auth (serv) == 0) -+ return 0; -+ -+ snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"), -+ serv->conn->account.host); -+ if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES) -+ { -+ serv->status = NNTP_BYE; -+ return -1; -+ } -+ } -+} -+ -+/* Send data from line[LONG_STRING] and receive answer to same line */ -+static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen) -+{ -+ char buf[LONG_STRING]; -+ int done = TRUE; -+ -+ if (data->nserv->status == NNTP_BYE) -+ return -1; -+ -+ do -+ { -+ if (*line) -+ { -+ mutt_socket_write (data->nserv->conn, line); -+ } -+ else if (data->group) -+ { -+ snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group); -+ mutt_socket_write (data->nserv->conn, buf); -+ } -+ -+ done = TRUE; -+ if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0) -+ { -+ if (nntp_reconnect (data->nserv) < 0) -+ return -1; -+ -+ if (data->group) -+ { -+ snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group); -+ mutt_socket_write (data->nserv->conn, buf); -+ if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0) -+ return -1; -+ } -+ if (*line) -+ done = FALSE; -+ } -+ else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0) -+ return -1; -+ } while (!done); -+ -+ strfcpy (line, buf, linelen); -+ return 0; -+} -+ -+/* -+ * This function calls funct(*line, *data) for each received line, -+ * funct(NULL, *data) if rewind(*data) needs, exits when fail or done. -+ * Returned codes: -+ * 0 - successful, -+ * 1 - correct but not performed (may be, have to be continued), -+ * -1 - conection lost, -+ * -2 - invalid command or execution error, -+ * -3 - error in funct(*line, *data). -+ */ -+static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg, -+ int (*funct) (char *, void *), void *data, int tagged) -+{ -+ char buf[LONG_STRING]; -+ char *inbuf, *p; -+ int done = FALSE; -+ int chunk, line; -+ size_t lenbuf = 0; -+ int ret; -+ -+ do -+ { -+ strfcpy (buf, query, sizeof (buf)); -+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) -+ return -1; -+ if (buf[0] == '5') -+ return -2; -+ if (buf[0] != '2') -+ return 1; -+ -+ ret = 0; -+ line = 0; -+ inbuf = safe_malloc (sizeof (buf)); -+ -+ FOREVER -+ { -+ chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn, -+ M_SOCK_LOG_HDR); -+ if (chunk < 0) -+ break; -+ -+ p = buf; -+ if (!lenbuf && buf[0] == '.') -+ { -+ if (buf[1] == '\0') -+ { -+ done = TRUE; -+ break; -+ } -+ if (buf[1] == '.') -+ p++; -+ } -+ -+ strfcpy (inbuf + lenbuf, p, sizeof (buf)); -+ -+ if (chunk >= sizeof (buf)) -+ { -+ lenbuf += strlen (p); -+ } -+ else -+ { -+ line++; -+ if (msg && ReadInc && (line % ReadInc == 0)) { -+ if (tagged) -+ mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line); -+ else -+ mutt_message ("%s %d", msg, line); -+ } -+ -+ if (ret == 0 && funct (inbuf, data) < 0) -+ ret = -3; -+ lenbuf = 0; -+ } -+ -+ safe_realloc (&inbuf, lenbuf + sizeof (buf)); -+ } -+ FREE (&inbuf); -+ funct (NULL, data); -+ } -+ while (!done); -+ return ret; -+} -+ -+static int nntp_read_tempfile (char *line, void *file) -+{ -+ FILE *f = (FILE *)file; -+ -+ if (!line) -+ rewind (f); -+ else -+ { -+ fputs (line, f); -+ if (fputc ('\n', f) == EOF) -+ return -1; -+ } -+ return 0; -+} -+ -+static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h) -+{ -+ register char *p, *b; -+ register char *colon = NULL; -+ -+ b = p = xref; -+ while (*p) -+ { -+ /* skip to next word */ -+ b = p; -+ while (*b && ((*b == ' ') || (*b == '\t'))) b++; -+ p = b; -+ colon = NULL; -+ /* skip to end of word */ -+ while (*p && (*p != ' ') && (*p != '\t')) -+ { -+ if (*p == ':') -+ colon = p; -+ p++; -+ } -+ if (*p) -+ { -+ *p = '\0'; -+ p++; -+ } -+ if (colon) -+ { -+ *colon = '\0'; -+ colon++; -+ nntp_get_status (ctx, h, b, atoi(colon)); -+ if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0) -+ h->article_num = atoi(colon); -+ } -+ } -+} -+ -+/* -+ * returns: -+ * 0 on success -+ * 1 if article not found -+ * -1 if read or write error on tempfile or socket -+ */ -+static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num) -+{ -+ NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data); -+ FILE *f; -+ char buf[LONG_STRING]; -+ char tempfile[_POSIX_PATH_MAX]; -+ int ret; -+ HEADER *h = ctx->hdrs[ctx->msgcount]; -+ -+ mutt_mktemp (tempfile, sizeof(tempfile)); -+ if (!(f = safe_fopen (tempfile, "w+"))) -+ return -1; -+ -+ if (!msgid) -+ snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num); -+ else -+ snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid); -+ -+ ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0); -+ if (ret) -+ { -+#ifdef DEBUG -+ if (ret != -1) -+ dprint(1, (debugfile, "nntp_read_header: %s\n", buf)); -+#endif -+ fclose (f); -+ unlink (tempfile); -+ return (ret == -1 ? -1 : 1); -+ } -+ -+ h->article_num = article_num; -+ h->env = mutt_read_rfc822_header (f, h, 0, 0); -+ fclose (f); -+ unlink (tempfile); -+ -+ if (h->env->xref != NULL) -+ nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h); -+ else if (h->article_num == 0 && msgid) -+ { -+ snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid); -+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0) -+ h->article_num = atoi (buf + 4); -+ } -+ -+ return 0; -+} -+ -+static int parse_description (char *line, void *n) -+{ -+#define news ((NNTP_SERVER *) n) -+ register char *d = line; -+ NNTP_DATA *data; -+ -+ if (!line) -+ return 0; -+ while (*d && *d != '\t' && *d != ' ') d++; -+ *d = 0; -+ d++; -+ while (*d && (*d == '\t' || *d == ' ')) d++; -+ dprint (2, (debugfile, "group: %s, desc: %s\n", line, d)); -+ if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL && -+ mutt_strcmp (d, data->desc)) -+ { -+ FREE (&data->desc); -+ data->desc = safe_strdup (d); -+ } -+ return 0; -+#undef news -+} -+ -+static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg) -+{ -+ char buf[STRING]; -+ -+ if (!option (OPTLOADDESC) || !data || !data->nserv) -+ return; -+ -+ /* Get newsgroup description, if we can */ -+ if (data->nserv->hasXGTITLE) -+ snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask); -+ else -+ snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask); -+ if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0) -+ { -+#ifdef DEBUG -+ nntp_error ("nntp_get_desc()", buf); -+#endif -+ } -+} -+ -+/* -+ * XOVER returns a tab separated list of: -+ * id|subject|from|date|Msgid|references|bytes|lines|xref -+ * -+ * This has to duplicate some of the functionality of -+ * mutt_read_rfc822_header(), since it replaces the call to that (albeit with -+ * a limited number of headers which are "parsed" by placement in the list) -+ */ -+static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr) -+{ -+ NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data; -+ char *p, *b; -+ int x, done = 0; -+ -+ hdr->env = mutt_new_envelope(); -+ hdr->env->newsgroups = safe_strdup (nntp_data->group); -+ hdr->content = mutt_new_body(); -+ hdr->content->type = TYPETEXT; -+ hdr->content->subtype = safe_strdup ("plain"); -+ hdr->content->encoding = ENC7BIT; -+ hdr->content->disposition = DISPINLINE; -+ hdr->content->length = -1; -+ b = p = buf; -+ -+ for (x = 0; !done && x < 9; x++) -+ { -+ /* if from file, need to skip newline character */ -+ while (*p && *p != '\n' && *p != '\t') p++; -+ if (!*p) done++; -+ *p = '\0'; -+ p++; -+ switch (x) -+ { -+ case 0: -+ -+ hdr->article_num = atoi (b); -+ nntp_get_status (ctx, hdr, NULL, hdr->article_num); -+ break; -+ case 1: -+ hdr->env->subject = safe_strdup (b); -+ /* Now we need to do the things which would normally be done in -+ * mutt_read_rfc822_header() */ -+ if (hdr->env->subject) -+ { -+ regmatch_t pmatch[1]; -+ -+ rfc2047_decode (&hdr->env->subject); -+ -+ if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0) -+ hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo; -+ else -+ hdr->env->real_subj = hdr->env->subject; -+ } -+ break; -+ case 2: -+ rfc822_free_address (&hdr->env->from); -+ hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b); -+ rfc2047_decode_adrlist (hdr->env->from); -+ break; -+ case 3: -+ hdr->date_sent = mutt_parse_date (b, hdr); -+ hdr->received = hdr->date_sent; -+ break; -+ case 4: -+ FREE (&hdr->env->message_id); -+ hdr->env->message_id = safe_strdup (b); -+ break; -+ case 5: -+ mutt_free_list (&hdr->env->references); -+ hdr->env->references = mutt_parse_references (b, 0); -+ break; -+ case 6: -+ hdr->content->length = atoi (b); -+ break; -+ case 7: -+ hdr->lines = atoi (b); -+ break; -+ case 8: -+ if (!hdr->read) -+ FREE (&hdr->env->xref); -+ b = b + 6; /* skips the "Xref: " */ -+ hdr->env->xref = safe_strdup (b); -+ nntp_parse_xref (ctx, nntp_data->group, b, hdr); -+ } -+ if (!*p) -+ return -1; -+ b = p; -+ } -+ return 0; -+} -+ -+typedef struct -+{ -+ CONTEXT *ctx; -+ unsigned int base; -+ unsigned int first; -+ unsigned int last; -+ unsigned short *messages; -+ char* msg; -+} FETCH_CONTEXT; -+ -+#define fc ((FETCH_CONTEXT *) c) -+static int nntp_fetch_numbers (char *line, void *c) -+{ -+ unsigned int num; -+ -+ if (!line) -+ return 0; -+ num = atoi (line); -+ if (num < fc->base || num > fc->last) -+ return 0; -+ fc->messages[num - fc->base] = 1; -+ return 0; -+} -+ -+static int add_xover_line (char *line, void *c) -+{ -+ unsigned int num, total; -+ CONTEXT *ctx = fc->ctx; -+ NNTP_DATA *data = (NNTP_DATA *)ctx->data; -+ -+ if (!line) -+ return 0; -+ -+ if (ctx->msgcount >= ctx->hdrmax) -+ mx_alloc_memory (ctx); -+ ctx->hdrs[ctx->msgcount] = mutt_new_header (); -+ ctx->hdrs[ctx->msgcount]->index = ctx->msgcount; -+ -+ nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]); -+ num = ctx->hdrs[ctx->msgcount]->article_num; -+ -+ if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base]) -+ { -+ ctx->msgcount++; -+ if (num > data->lastLoaded) -+ data->lastLoaded = num; -+ num = num - fc->first + 1; -+ total = fc->last - fc->first + 1; -+ if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0)) -+ mutt_message ("%s %d/%d", fc->msg, num, total); -+ } -+ else -+ mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */ -+ -+ return 0; -+} -+#undef fc -+ -+static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first, -+ unsigned int last) -+{ -+ char buf[HUGE_STRING]; -+ char *msg = _("Fetching message headers..."); -+ NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data); -+ int ret; -+ int num; -+ int oldmsgcount; -+ unsigned int current; -+ FILE *f; -+ FETCH_CONTEXT fc; -+ -+ /* if empty group or nothing to do */ -+ if (!last || first > last) -+ return 0; -+ -+ /* fetch list of articles */ -+ fc.ctx = ctx; -+ fc.base = first; -+ fc.last = last; -+ fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short)); -+ if (nntp_data->nserv->hasLISTGROUP) -+ { -+ mutt_message _("Fetching list of articles..."); -+ snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group); -+ if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0) -+ { -+ mutt_error (_("LISTGROUP command failed: %s"), buf); -+#ifdef DEBUG -+ nntp_error ("nntp_fetch_headers()", buf); -+#endif -+ FREE (&fc.messages); -+ return -1; -+ } -+ } -+ else -+ { -+ for (num = 0; num < last - first + 1; num++) -+ fc.messages[num] = 1; -+ } -+ -+ /* CACHE: must be loaded xover cache here */ -+ num = nntp_data->lastCached - first + 1; -+ if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0) -+ { -+ nntp_cache_expand (buf, nntp_data->cache); -+ mutt_message _("Fetching headers from cache..."); -+ if ((f = safe_fopen (buf, "r"))) -+ { -+ int r = 0; -+ -+ /* counting number of lines */ -+ while (fgets (buf, sizeof (buf), f) != NULL) -+ r++; -+ rewind (f); -+ while (r > num && fgets (buf, sizeof (buf), f) != NULL) -+ r--; -+ oldmsgcount = ctx->msgcount; -+ fc.first = first; -+ fc.last = first + num - 1; -+ fc.msg = NULL; -+ while (fgets (buf, sizeof (buf), f) != NULL) -+ add_xover_line (buf, &fc); -+ fclose (f); -+ nntp_data->lastLoaded = fc.last; -+ first = fc.last + 1; -+ if (ctx->msgcount > oldmsgcount) -+ mx_update_context (ctx, ctx->msgcount - oldmsgcount); -+ } -+ else -+ nntp_delete_cache (nntp_data); -+ } -+ num = last - first + 1; -+ if (num <= 0) -+ { -+ FREE (&fc.messages); -+ return 0; -+ } -+ -+ /* -+ * Without XOVER, we have to fetch each article header and parse -+ * it. With XOVER, we ask for all of them -+ */ -+ mutt_message (msg); -+ if (nntp_data->nserv->hasXOVER) -+ { -+ oldmsgcount = ctx->msgcount; -+ fc.first = first; -+ fc.last = last; -+ fc.msg = msg; -+ snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last); -+ ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0); -+ if (ctx->msgcount > oldmsgcount) -+ mx_update_context (ctx, ctx->msgcount - oldmsgcount); -+ if (ret != 0) -+ { -+ mutt_error (_("XOVER command failed: %s"), buf); -+#ifdef DEBUG -+ nntp_error ("nntp_fetch_headers()", buf); -+#endif -+ FREE (&fc.messages); -+ return -1; -+ } -+ /* fetched OK */ -+ } -+ else -+ for (current = first; current <= last; current++) -+ { -+ HEADER *h; -+ -+ ret = current - first + 1; -+ mutt_message ("%s %d/%d", msg, ret, num); -+ -+ if (!fc.messages[current - fc.base]) -+ continue; -+ -+ if (ctx->msgcount >= ctx->hdrmax) -+ mx_alloc_memory (ctx); -+ h = ctx->hdrs[ctx->msgcount] = mutt_new_header (); -+ h->index = ctx->msgcount; -+ -+ ret = nntp_read_header (ctx, NULL, current); -+ if (ret == 0) /* Got article. Fetch next header */ -+ { -+ nntp_get_status (ctx, h, NULL, h->article_num); -+ ctx->msgcount++; -+ mx_update_context (ctx, 1); -+ } -+ else -+ mutt_free_header (&h); /* skip it */ -+ if (ret == -1) -+ { -+ FREE (&fc.messages); -+ return -1; -+ } -+ -+ if (current > nntp_data->lastLoaded) -+ nntp_data->lastLoaded = current; -+ } -+ FREE (&fc.messages); -+ nntp_data->lastLoaded = last; -+ mutt_clear_error (); -+ return 0; -+} -+ -+/* -+ * currently, nntp "mailbox" is "newsgroup" -+ */ -+int nntp_open_mailbox (CONTEXT *ctx) -+{ -+ NNTP_DATA *nntp_data; -+ NNTP_SERVER *serv; -+ char buf[HUGE_STRING]; -+ char server[LONG_STRING]; -+ int count = 0; -+ unsigned int first; -+ ACCOUNT acct; -+ -+ if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf) -+ { -+ mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path); -+ mutt_sleep (2); -+ return -1; -+ } -+ -+ server[0] = '\0'; -+ nntp_expand_path (server, sizeof (server), &acct); -+ if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK) -+ return -1; -+ -+ CurrentNewsSrv = serv; -+ -+ /* create NNTP-specific state struct if nof found in list */ -+ if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL) -+ { -+ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1); -+ nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA); -+ strcpy (nntp_data->group, buf); -+ hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0); -+ nntp_add_to_list (serv, nntp_data); -+ } -+ ctx->data = nntp_data; -+ ctx->mx_close = nntp_fastclose_mailbox; -+ nntp_data->nserv = serv; -+ -+ mutt_message (_("Selecting %s..."), nntp_data->group); -+ -+ if (!nntp_data->desc) -+ { -+ nntp_get_desc (nntp_data, nntp_data->group, NULL); -+ if (nntp_data->desc) -+ nntp_save_cache_index (serv); -+ } -+ -+ buf[0] = 0; -+ if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0) -+ { -+#ifdef DEBUG -+ nntp_error ("nntp_open_mailbox()", buf); -+#endif -+ return -1; -+ } -+ -+ if (mutt_strncmp ("211", buf, 3)) -+ { -+ LIST *l = serv->list; -+ -+ /* GROUP command failed */ -+ if (!mutt_strncmp ("411", buf, 3)) -+ { -+ mutt_error (_("Newsgroup %s not found on server %s"), -+ nntp_data->group, serv->conn->account.host); -+ -+ /* CACHE: delete cache and line from .index */ -+ nntp_delete_cache (nntp_data); -+ hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data); -+ while (l && l->data != (void *) nntp_data) l = l->next; -+ if (l) -+ l->data = NULL; -+ -+ sleep (2); -+ } -+ -+ return -1; -+ } -+ -+ sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage, -+ &nntp_data->lastMessage, buf); -+ -+ nntp_data->deleted = 0; -+ -+ time (&serv->check_time); -+ -+ /* -+ * Check for max adding context. If it is greater than $nntp_context, -+ * strip off extra articles -+ */ -+ first = nntp_data->firstMessage; -+ if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext) -+ first = nntp_data->lastMessage - NntpContext + 1; -+ if (first) -+ nntp_data->lastLoaded = first - 1; -+ return nntp_fetch_headers (ctx, first, nntp_data->lastMessage); -+} -+ -+int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno) -+{ -+ char buf[LONG_STRING]; -+ char path[_POSIX_PATH_MAX]; -+ NNTP_CACHE *cache; -+ char *m = _("Fetching message..."); -+ int ret; -+ -+ /* see if we already have the message in our cache */ -+ cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN]; -+ -+ /* if everything is fine, assign msg->fp and return */ -+ if (cache->path && cache->index == ctx->hdrs[msgno]->index && -+ (msg->fp = fopen (cache->path, "r"))) -+ return 0; -+ -+ /* clear the previous entry */ -+ unlink (cache->path); -+ free (cache->path); -+ -+ mutt_message (m); -+ -+ cache->index = ctx->hdrs[msgno]->index; -+ mutt_mktemp (path, sizeof(path)); -+ cache->path = safe_strdup (path); -+ if (!(msg->fp = safe_fopen (path, "w+"))) -+ { -+ FREE (&cache->path); -+ return -1; -+ } -+ -+ if (ctx->hdrs[msgno]->article_num == 0) -+ snprintf (buf, sizeof (buf), "ARTICLE %s\r\n", -+ ctx->hdrs[msgno]->env->message_id); -+ else -+ snprintf (buf, sizeof (buf), "ARTICLE %d\r\n", -+ ctx->hdrs[msgno]->article_num); -+ -+ ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile, -+ msg->fp, ctx->tagged); -+ if (ret == 1) -+ { -+ mutt_error (_("Article %d not found on server"), -+ ctx->hdrs[msgno]->article_num); -+ dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf)); -+ } -+ -+ if (ret) -+ { -+ fclose (msg->fp); -+ unlink (path); -+ FREE (&cache->path); -+ return -1; -+ } -+ -+ mutt_free_envelope (&ctx->hdrs[msgno]->env); -+ ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0); -+ /* fix content length */ -+ fseek(msg->fp, 0, SEEK_END); -+ ctx->hdrs[msgno]->content->length = ftell (msg->fp) - -+ ctx->hdrs[msgno]->content->offset; -+ -+ /* this is called in mutt before the open which fetches the message, -+ * which is probably wrong, but we just call it again here to handle -+ * the problem instead of fixing it. -+ */ -+ mutt_parse_mime_message (ctx, ctx->hdrs[msgno]); -+ -+ /* These would normally be updated in mx_update_context(), but the -+ * full headers aren't parsed with XOVER, so the information wasn't -+ * available then. -+ */ -+#if defined(HAVE_PGP) || defined(HAVE_SMIME) -+ ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content); -+#endif /* HAVE_PGP || HAVE_SMIME */ -+ -+ mutt_clear_error(); -+ rewind (msg->fp); -+ -+ return 0; -+} -+ -+/* Post article */ -+int nntp_post (const char *msg) { -+ char buf[LONG_STRING]; -+ size_t len; -+ FILE *f; -+ NNTP_DATA *nntp_data; -+ -+ if (Context && Context->magic == M_NNTP) -+ nntp_data = (NNTP_DATA *)Context->data; -+ else -+ { -+ if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) || -+ !CurrentNewsSrv->list || !CurrentNewsSrv->list->data) -+ { -+ mutt_error (_("Can't post article. No connection to news server.")); -+ return -1; -+ } -+ nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data; -+ } -+ -+ if (!(f = safe_fopen (msg, "r"))) -+ { -+ mutt_error (_("Can't post article. Unable to open %s"), msg); -+ return -1; -+ } -+ -+ strfcpy (buf, "POST\r\n", sizeof (buf)); -+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) -+ { -+ mutt_error (_("Can't post article. Connection to %s lost."), -+ nntp_data->nserv->conn->account.host); -+ return -1; -+ } -+ if (buf[0] != '3') -+ { -+ mutt_error (_("Can't post article: %s"), buf); -+ return -1; -+ } -+ -+ buf[0] = '.'; -+ buf[1] = '\0'; -+ while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL) -+ { -+ len = strlen (buf); -+ if (buf[len - 1] == '\n') -+ { -+ buf[len - 1] = '\r'; -+ buf[len] = '\n'; -+ len++; -+ buf[len] = '\0'; -+ } -+ if (buf[1] == '.') -+ mutt_socket_write_d (nntp_data->nserv->conn, buf, -1, M_SOCK_LOG_HDR); -+ else -+ mutt_socket_write_d (nntp_data->nserv->conn, buf + 1, -1, M_SOCK_LOG_HDR); -+ } -+ fclose (f); -+ -+ if (buf[strlen (buf) - 1] != '\n') -+ mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR); -+ mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR); -+ if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0) -+ { -+ mutt_error (_("Can't post article. Connection to %s lost."), -+ nntp_data->nserv->conn->account.host); -+ return -1; -+ } -+ if (buf[0] != '2') -+ { -+ mutt_error (_("Can't post article: %s"), buf); -+ return -1; -+ } -+ -+ return 0; -+} -+ -+/* nntp_logout_all: close all open connections. */ -+void nntp_logout_all (void) -+{ -+ char buf[LONG_STRING]; -+ CONNECTION* conn; -+ -+ conn = mutt_socket_head (); -+ -+ while (conn) -+ { -+ CONNECTION *next = conn->next; -+ -+ if (conn->account.type == M_ACCT_TYPE_NNTP) -+ { -+ mutt_message (_("Closing connection to %s..."), conn->account.host); -+ mutt_socket_write (conn, "QUIT\r\n"); -+ mutt_socket_readln (buf, sizeof (buf), conn); -+ mutt_clear_error (); -+ mutt_socket_close (conn); -+ mutt_socket_free (conn); -+ } -+ -+ conn = next; -+ } -+} -+ -+static void nntp_free_acache (NNTP_DATA *data) -+{ -+ int i; -+ -+ for (i = 0; i < NNTP_CACHE_LEN; i++) -+ { -+ if (data->acache[i].path) -+ { -+ unlink (data->acache[i].path); -+ FREE (&data->acache[i].path); -+ } -+ } -+} -+ -+void nntp_delete_data (void *p) -+{ -+ NNTP_DATA *data = (NNTP_DATA *)p; -+ -+ if (!p) -+ return; -+ FREE (&data->entries); -+ FREE (&data->desc); -+ FREE (&data->cache); -+ nntp_free_acache (data); -+ FREE (p); -+} -+ -+int nntp_sync_mailbox (CONTEXT *ctx) -+{ -+ NNTP_DATA *data = ctx->data; -+ -+ /* CACHE: update cache and .index files */ -+ if ((option (OPTSAVEUNSUB) || data->subscribed)) -+ nntp_save_cache_group (ctx); -+ nntp_free_acache (data); -+ -+ data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */ -+ return 0; -+} -+ -+int nntp_fastclose_mailbox (CONTEXT *ctx) -+{ -+ NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp; -+ -+ if (!data) -+ return 0; -+ nntp_free_acache (data); -+ if (!data->nserv || !data->nserv->newsgroups || !data->group) -+ return 0; -+ nntp_save_cache_index (data->nserv); -+ if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL -+ || tmp != data) -+ nntp_delete_data (data); -+ return 0; -+} -+ -+/* commit changes and terminate connection */ -+int nntp_close_mailbox (CONTEXT *ctx) -+{ -+ if (!ctx) -+ return -1; -+ mutt_message _("Quitting newsgroup..."); -+ if (ctx->data) -+ { -+ NNTP_DATA *data = (NNTP_DATA *) ctx->data; -+ int ret; -+ -+ if (data->nserv && data->nserv->conn && ctx->unread) -+ { -+ ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?")); -+ if (ret == M_YES) -+ mutt_newsgroup_catchup (data->nserv, data->group); -+ else if (ret < 0) -+ return -1; -+ } -+ } -+ nntp_sync_mailbox (ctx); -+ if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv) -+ { -+ NNTP_SERVER *news; -+ -+ news = ((NNTP_DATA *)ctx->data)->nserv; -+ newsrc_gen_entries (ctx); -+ ((NNTP_DATA *)ctx->data)->unread = ctx->unread; -+ mutt_newsrc_update (news); -+ } -+ mutt_clear_error(); -+ return 0; -+} -+ -+/* use the GROUP command to poll for new mail */ -+static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data) -+{ -+ char buf[LONG_STRING]; -+ int count = 0; -+ -+ if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL)) -+ return 0; -+ -+ buf[0] = 0; -+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) -+ { -+#ifdef DEBUG -+ nntp_error ("nntp_check_mailbox()", buf); -+#endif -+ return -1; -+ } -+ if (mutt_strncmp ("211", buf, 3)) -+ { -+ buf[0] = 0; -+ if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) -+ { -+#ifdef DEBUG -+ nntp_error ("nntp_check_mailbox()", buf); -+#endif -+ return -1; -+ } -+ } -+ if (!mutt_strncmp ("211", buf, 3)) -+ { -+ int first; -+ int last; -+ -+ sscanf (buf + 4, "%d %d %d", &count, &first, &last); -+ nntp_data->firstMessage = first; -+ nntp_data->lastMessage = last; -+ if (ctx && last > nntp_data->lastLoaded) -+ { -+ nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last); -+ time (&nntp_data->nserv->check_time); -+ return 1; -+ } -+ if (!last || (!nntp_data->rc && !nntp_data->lastCached)) -+ nntp_data->unread = count; -+ else -+ mutt_newsgroup_stat (nntp_data); -+ /* active was renumbered? */ -+ if (last < nntp_data->lastLoaded) -+ { -+ if (!nntp_data->max) -+ { -+ nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY)); -+ nntp_data->max = 5; -+ } -+ nntp_data->lastCached = 0; -+ nntp_data->num = 1; -+ nntp_data->entries[0].first = 1; -+ nntp_data->entries[0].last = 0; -+ } -+ } -+ -+ time (&nntp_data->nserv->check_time); -+ return 0; -+} -+ -+int nntp_check_mailbox (CONTEXT *ctx) -+{ -+ return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data); -+} -+ -+static int add_group (char *buf, void *serv) -+{ -+#define s ((NNTP_SERVER *) serv) -+ char group[LONG_STRING], mod, desc[HUGE_STRING]; -+ int first, last; -+ NNTP_DATA *nntp_data; -+ static int n = 0; -+ -+ _checked = n; /* _checked have N, where N = number of groups */ -+ if (!buf) /* at EOF must be zerouth */ -+ n = 0; -+ -+ if (!s || !buf) -+ return 0; -+ -+ *desc = 0; -+ sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc); -+ if (!group) -+ return 0; -+ if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL) -+ { -+ n++; -+ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1); -+ nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA); -+ strcpy (nntp_data->group, group); -+ nntp_data->nserv = s; -+ if (s->newsgroups->nelem < s->newsgroups->curnelem * 2) -+ s->newsgroups = hash_resize (s->newsgroups, s->newsgroups->nelem * 2, 0); -+ hash_insert (s->newsgroups, nntp_data->group, nntp_data, 0); -+ nntp_add_to_list (s, nntp_data); -+ } -+ nntp_data->deleted = 0; -+ nntp_data->firstMessage = first; -+ nntp_data->lastMessage = last; -+ if (mod == 'y') -+ nntp_data->allowed = 1; -+ else -+ nntp_data->allowed = 0; -+ if (nntp_data->desc) -+ FREE (&nntp_data->desc); -+ if (*desc) -+ nntp_data->desc = safe_strdup (desc); -+ if (nntp_data->rc || nntp_data->lastCached) -+ mutt_newsgroup_stat (nntp_data); -+ else if (nntp_data->lastMessage && -+ nntp_data->firstMessage <= nntp_data->lastMessage) -+ nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1; -+ else -+ nntp_data->unread = 0; -+ -+ return 0; -+#undef s -+} -+ -+int nntp_check_newgroups (NNTP_SERVER *serv, int force) -+{ -+ char buf[LONG_STRING]; -+ char msg[SHORT_STRING]; -+ NNTP_DATA nntp_data; -+ LIST *l; -+ LIST emp; -+ time_t now; -+ struct tm *t; -+ unsigned int count = 0; -+ unsigned int total = 0; -+ -+ if (!serv || !serv->newgroups_time) -+ return -1; -+ -+ if (nntp_open_connection (serv) < 0) -+ return -1; -+ -+ /* check subscribed groups for new news */ -+ if (option (OPTSHOWNEWNEWS)) -+ { -+ mutt_message _("Checking for new messages..."); -+ for (l = serv->list; l; l = l->next) -+ { -+ serv->check_time = 0; /* really check! */ -+ if (l->data && ((NNTP_DATA *) l->data)->subscribed) -+ _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data); -+ } -+ } -+ else if (!force) -+ return 0; -+ -+ mutt_message _("Checking for new newsgroups..."); -+ now = serv->newgroups_time; -+ time (&serv->newgroups_time); -+ t = gmtime (&now); -+ snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n", -+ (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, -+ t->tm_sec); -+ nntp_data.nserv = serv; -+ if (Context && Context->magic == M_NNTP) -+ nntp_data.group = ((NNTP_DATA *)Context->data)->group; -+ else -+ nntp_data.group = NULL; -+ l = serv->tail; -+ if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."), -+ add_group, serv, 0) != 0) -+ { -+#ifdef DEBUG -+ nntp_error ("nntp_check_newgroups()", buf); -+#endif -+ return -1; -+ } -+ -+ strfcpy (msg, _("Loading descriptions..."), sizeof (msg)); -+ mutt_message (msg); -+ if (l) -+ emp.next = l->next; -+ else -+ emp.next = serv->list; -+ l = &emp; -+ while (l->next) -+ { -+ l = l->next; -+ ((NNTP_DATA *) l->data)->new = 1; -+ total++; -+ } -+ l = &emp; -+ while (l->next) -+ { -+ l = l->next; -+ nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL); -+ count++; -+ if (ReadInc && (count % ReadInc == 0)) -+ mutt_message ("%s %d/%d", msg, count, total); -+ } -+ if (emp.next) -+ nntp_save_cache_index (serv); -+ mutt_clear_error (); -+ return _checked; -+} -+ -+/* Load list of all newsgroups from cache ALL */ -+int nntp_get_cache_all (NNTP_SERVER *serv) -+{ -+ char buf[HUGE_STRING]; -+ FILE *f; -+ -+ nntp_cache_expand (buf, serv->cache); -+ if ((f = safe_fopen (buf, "r"))) -+ { -+ int i = 0; -+ -+ while (fgets (buf, sizeof(buf), f) != NULL) -+ { -+ if (ReadInc && (i % ReadInc == 0)) -+ mutt_message (_("Loading list from cache... %d"), i); -+ add_group (buf, serv); -+ i++; -+ } -+ add_group (NULL, NULL); -+ fclose (f); -+ mutt_clear_error (); -+ return 0; -+ } -+ else -+ { -+ FREE (&serv->cache); -+ return -1; -+ } -+} -+ -+/* Load list of all newsgroups from active */ -+int nntp_get_active (NNTP_SERVER *serv) -+{ -+ char msg[SHORT_STRING]; -+ NNTP_DATA nntp_data; -+ LIST *tmp; -+ -+ if (nntp_open_connection (serv) < 0) -+ return -1; -+ -+ snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."), -+ serv->conn->account.host); -+ mutt_message (msg); -+ time (&serv->newgroups_time); -+ nntp_data.nserv = serv; -+ nntp_data.group = NULL; -+ -+ if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0) -+ { -+#ifdef DEBUG -+ nntp_error ("nntp_get_active()", "LIST\r\n"); -+#endif -+ return -1; -+ } -+ -+ strfcpy (msg, _("Loading descriptions..."), sizeof (msg)); -+ mutt_message (msg); -+ nntp_get_desc (&nntp_data, "*", msg); -+ -+ for (tmp = serv->list; tmp; tmp = tmp->next) -+ { -+ NNTP_DATA *data = (NNTP_DATA *)tmp->data; -+ -+ if (data && data->deleted && !data->rc) -+ { -+ nntp_delete_cache (data); -+ hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data); -+ tmp->data = NULL; -+ } -+ } -+ nntp_save_cache_index (serv); -+ -+ mutt_clear_error (); -+ return _checked; -+} -+ -+/* -+ * returns -1 if error ocurred while retrieving header, -+ * number of articles which ones exist in context on success. -+ */ -+int nntp_check_msgid (CONTEXT *ctx, const char *msgid) -+{ -+ int ret; -+ -+ /* if msgid is already in context, don't reload them */ -+ if (hash_find (ctx->id_hash, msgid)) -+ return 1; -+ if (ctx->msgcount == ctx->hdrmax) -+ mx_alloc_memory (ctx); -+ ctx->hdrs[ctx->msgcount] = mutt_new_header (); -+ ctx->hdrs[ctx->msgcount]->index = ctx->msgcount; -+ -+ mutt_message (_("Fetching %s from server..."), msgid); -+ ret = nntp_read_header (ctx, msgid, 0); -+ /* since nntp_read_header() may set read flag, we must reset it */ -+ ctx->hdrs[ctx->msgcount]->read = 0; -+ if (ret != 0) -+ mutt_free_header (&ctx->hdrs[ctx->msgcount]); -+ else -+ { -+ ctx->msgcount++; -+ mx_update_context (ctx, 1); -+ ctx->changed = 1; -+ } -+ return ret; -+} -+ -+typedef struct -+{ -+ CONTEXT *ctx; -+ unsigned int num; -+ unsigned int max; -+ unsigned int *child; -+} CHILD_CONTEXT; -+ -+static int check_children (char *s, void *c) -+{ -+#define cc ((CHILD_CONTEXT *) c) -+ unsigned int i, n; -+ -+ if (!s || (n = atoi (s)) == 0) -+ return 0; -+ for (i = 0; i < cc->ctx->msgcount; i++) -+ if (cc->ctx->hdrs[i]->article_num == n) -+ return 0; -+ if (cc->num >= cc->max) -+ safe_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25)); -+ cc->child[cc->num++] = n; -+ -+ return 0; -+#undef cc -+} -+ -+int nntp_check_children (CONTEXT *ctx, const char *msgid) -+{ -+ NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data; -+ char buf[STRING]; -+ int i, ret = 0, tmp = 0; -+ CHILD_CONTEXT cc; -+ -+ if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn || -+ !nntp_data->nserv->conn->account.host) -+ return -1; -+ if (nntp_data->firstMessage > nntp_data->lastLoaded) -+ return 0; -+ if (!nntp_data->nserv->hasXPAT) -+ { -+ mutt_error (_("Server %s does not support this operation!"), -+ nntp_data->nserv->conn->account.host); -+ return -1; -+ } -+ -+ snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n", -+ nntp_data->firstMessage, nntp_data->lastLoaded, msgid); -+ -+ cc.ctx = ctx; -+ cc.num = 0; -+ cc.max = 25; -+ cc.child = safe_malloc (sizeof (unsigned int) * 25); -+ if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0)) -+ { -+ FREE (&cc.child); -+ return -1; -+ } -+ /* dont try to read the xover cache. check_children() already -+ * made sure that we dont have the article, so we need to visit -+ * the server. Reading the cache at this point is also bad -+ * because it would duplicate messages */ -+ if (option (OPTNEWSCACHE)) -+ { -+ tmp++; -+ unset_option (OPTNEWSCACHE); -+ } -+ for (i = 0; i < cc.num; i++) -+ { -+ if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i]))) -+ break; -+ if (ctx->msgcount && -+ ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i]) -+ ctx->hdrs[ctx->msgcount - 1]->read = 0; -+ } -+ if (tmp) -+ set_option (OPTNEWSCACHE); -+ FREE (&cc.child); -+ return ret; -+} -diff -udprP mutt-1.5.20.orig/nntp.h mutt-1.5.20/nntp.h ---- mutt-1.5.20.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300 -+++ mutt-1.5.20/nntp.h 2009-06-15 21:05:24.000000000 +0300 -@@ -0,0 +1,136 @@ -+/* -+ * Copyright (C) 1998 Brandon Long <blong@fiction.net> -+ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net> -+ * Copyright (C) 2000-2007 Vsevolod Volkov <vvv@mutt.org.ua> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#ifndef _NNTP_H_ -+#define _NNTP_H_ 1 -+ -+#include "mutt_socket.h" -+#include "mailbox.h" -+ -+#include <time.h> -+ -+#define NNTP_PORT 119 -+#define NNTP_SSL_PORT 563 -+ -+/* number of entries in the hash table */ -+#define NNTP_CACHE_LEN 10 -+ -+enum -+{ -+ NNTP_NONE = 0, -+ NNTP_OK, -+ NNTP_BYE -+}; -+ -+typedef struct -+{ -+ int first; -+ int last; -+} NEWSRC_ENTRY; -+ -+typedef struct -+{ -+ unsigned int hasXPAT : 1; -+ unsigned int hasXGTITLE : 1; -+ unsigned int hasXOVER : 1; -+ unsigned int hasLISTGROUP : 1; -+ unsigned int status : 3; -+ char *newsrc; -+ char *cache; -+ int stat; -+ off_t size; -+ time_t mtime; -+ time_t newgroups_time; -+ time_t check_time; -+ HASH *newsgroups; -+ LIST *list; /* list of newsgroups */ -+ LIST *tail; /* last entry of list */ -+ CONNECTION *conn; -+} NNTP_SERVER; -+ -+typedef struct -+{ -+ unsigned int index; -+ char *path; -+} NNTP_CACHE; -+ -+typedef struct -+{ -+ NEWSRC_ENTRY *entries; -+ unsigned int num; /* number of used entries */ -+ unsigned int max; /* number of allocated entries */ -+ unsigned int unread; -+ unsigned int firstMessage; -+ unsigned int lastMessage; -+ unsigned int lastLoaded; -+ unsigned int lastCached; -+ unsigned int subscribed : 1; -+ unsigned int rc : 1; -+ unsigned int new : 1; -+ unsigned int allowed : 1; -+ unsigned int deleted : 1; -+ char *group; -+ char *desc; -+ char *cache; -+ NNTP_SERVER *nserv; -+ NNTP_CACHE acache[NNTP_CACHE_LEN]; -+} NNTP_DATA; -+ -+/* internal functions */ -+int nntp_get_active (NNTP_SERVER *); -+int nntp_get_cache_all (NNTP_SERVER *); -+int nntp_save_cache_index (NNTP_SERVER *); -+int nntp_check_newgroups (NNTP_SERVER *, int); -+int nntp_save_cache_group (CONTEXT *); -+int nntp_parse_url (const char *, ACCOUNT *, char *, size_t); -+void newsrc_gen_entries (CONTEXT *); -+void nntp_get_status (CONTEXT *, HEADER *, char *, int); -+void mutt_newsgroup_stat (NNTP_DATA *); -+void nntp_delete_cache (NNTP_DATA *); -+void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *); -+void nntp_cache_expand (char *, const char *); -+void nntp_delete_data (void *); -+ -+/* exposed interface */ -+NNTP_SERVER *mutt_select_newsserver (char *); -+NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *); -+NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *); -+NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *); -+NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *); -+void nntp_clear_cacheindex (NNTP_SERVER *); -+int mutt_newsrc_update (NNTP_SERVER *); -+int nntp_open_mailbox (CONTEXT *); -+int nntp_sync_mailbox (CONTEXT *); -+int nntp_check_mailbox (CONTEXT *); -+int nntp_close_mailbox (CONTEXT *); -+int nntp_fastclose_mailbox (CONTEXT *); -+int nntp_fetch_message (MESSAGE *, CONTEXT *, int); -+int nntp_post (const char *); -+int nntp_check_msgid (CONTEXT *, const char *); -+int nntp_check_children (CONTEXT *, const char *); -+void nntp_buffy (char *); -+void nntp_expand_path (char *, size_t, ACCOUNT *); -+void nntp_logout_all (); -+const char *nntp_format_str (char *, size_t, size_t, char, const char *, const char *, -+ const char *, const char *, unsigned long, format_flag); -+ -+NNTP_SERVER *CurrentNewsSrv INITVAL (NULL); -+ -+#endif /* _NNTP_H_ */ -diff -udprP mutt-1.5.20.orig/pager.c mutt-1.5.20/pager.c ---- mutt-1.5.20.orig/pager.c 2009-06-03 23:48:31.000000000 +0300 -+++ mutt-1.5.20/pager.c 2009-06-15 21:05:24.000000000 +0300 -@@ -1059,6 +1059,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos, - return b_read; - } - -+#ifdef USE_NNTP -+#include "mx.h" -+#include "nntp.h" -+#endif -+ - - static int format_line (struct line_t **lineInfo, int n, unsigned char *buf, - int flags, ansi_attr *pa, int cnt, -@@ -1512,6 +1517,16 @@ static struct mapping_t PagerHelpExtra[] - { NULL, 0 } - }; - -+#ifdef USE_NNTP -+static struct mapping_t PagerNewsHelpExtra[] = { -+ { N_("Post"), OP_POST }, -+ { N_("Followup"), OP_FOLLOWUP }, -+ { N_("Del"), OP_DELETE }, -+ { N_("Next"), OP_MAIN_NEXT_UNDELETED }, -+ { NULL, 0 } -+}; -+#endif -+ - - - /* This pager is actually not so simple as it once was. It now operates in -@@ -1553,6 +1568,10 @@ mutt_pager (const char *banner, const ch - int old_PagerIndexLines; /* some people want to resize it - * while inside the pager... */ - -+#ifdef USE_NNTP -+ char *followup_to; -+#endif -+ - if (!(flags & M_SHOWCOLOR)) - flags |= M_SHOWFLAT; - -@@ -1592,7 +1611,11 @@ mutt_pager (const char *banner, const ch - if (IsHeader (extra)) - { - strfcpy (tmphelp, helpstr, sizeof (tmphelp)); -- mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra); -+ mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, -+#ifdef USE_NNTP -+ (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra : -+#endif -+ PagerHelpExtra); - snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer); - } - if (!InHelp) -@@ -2465,6 +2488,15 @@ search_next: - CHECK_READONLY; - CHECK_ACL(M_ACL_WRITE, "flag message"); - -+#ifdef USE_NNTP -+ if (Context->magic == M_NNTP) -+ { -+ mutt_flushinp (); -+ mutt_error _("Can't change 'important' flag on NNTP server."); -+ break; -+ } -+#endif -+ - mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged); - redraw = REDRAW_STATUS | REDRAW_INDEX; - if (option (OPTRESOLVE)) -@@ -2498,6 +2530,60 @@ search_next: - redraw = REDRAW_FULL; - break; - -+#ifdef USE_NNTP -+ case OP_POST: -+ CHECK_MODE(IsHeader (extra) && !IsAttach (extra)); -+ CHECK_ATTACH; -+ if (extra->ctx && extra->ctx->magic == M_NNTP && -+ !((NNTP_DATA *)extra->ctx->data)->allowed && -+ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) -+ break; -+ ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL); -+ redraw = REDRAW_FULL; -+ break; -+ -+ case OP_FORWARD_TO_GROUP: -+ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); -+ CHECK_ATTACH; -+ if (extra->ctx && extra->ctx->magic == M_NNTP && -+ !((NNTP_DATA *)extra->ctx->data)->allowed && -+ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) -+ break; -+ if (IsMsgAttach (extra)) -+ mutt_attach_forward (extra->fp, extra->hdr, extra->idx, -+ extra->idxlen, extra->bdy, SENDNEWS); -+ else -+ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); -+ redraw = REDRAW_FULL; -+ break; -+ -+ case OP_FOLLOWUP: -+ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); -+ CHECK_ATTACH; -+ -+ if (IsMsgAttach (extra)) -+ followup_to = extra->bdy->hdr->env->followup_to; -+ else -+ followup_to = extra->hdr->env->followup_to; -+ -+ if (!followup_to || mutt_strcasecmp (followup_to, "poster") || -+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES) -+ { -+ if (extra->ctx && extra->ctx->magic == M_NNTP && -+ !((NNTP_DATA *)extra->ctx->data)->allowed && -+ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) -+ break; -+ if (IsMsgAttach (extra)) -+ mutt_attach_reply (extra->fp, extra->hdr, extra->idx, -+ extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY); -+ else -+ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, -+ extra->ctx, extra->hdr); -+ redraw = REDRAW_FULL; -+ break; -+ } -+#endif -+ - case OP_REPLY: - CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); - CHECK_ATTACH; -@@ -2544,7 +2630,7 @@ search_next: - CHECK_ATTACH; - if (IsMsgAttach (extra)) - mutt_attach_forward (extra->fp, extra->hdr, extra->idx, -- extra->idxlen, extra->bdy); -+ extra->idxlen, extra->bdy, 0); - else - ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); - redraw = REDRAW_FULL; -diff -udprP mutt-1.5.20.orig/parse.c mutt-1.5.20/parse.c ---- mutt-1.5.20.orig/parse.c 2009-06-01 19:29:32.000000000 +0300 -+++ mutt-1.5.20/parse.c 2009-06-15 21:05:24.000000000 +0300 -@@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch - /* not reached */ - } - --static LIST *mutt_parse_references (char *s, int in_reply_to) -+LIST *mutt_parse_references (char *s, int in_reply_to) - { - LIST *t, *lst = NULL; - char *m; -@@ -1067,6 +1067,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e, - e->from = rfc822_parse_adrlist (e->from, p); - matched = 1; - } -+#ifdef USE_NNTP -+ else if (!mutt_strcasecmp (line+1, "ollowup-to")) -+ { -+ if (!e->followup_to) -+ { -+ mutt_remove_trailing_ws (p); -+ e->followup_to = safe_strdup (mutt_skip_whitespace (p)); -+ } -+ matched = 1; -+ } -+#endif - break; - - case 'i': -@@ -1149,6 +1160,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e, - } - break; - -+#ifdef USE_NNTP -+ case 'n': -+ if (!mutt_strcasecmp (line + 1, "ewsgroups")) -+ { -+ FREE (&e->newsgroups); -+ mutt_remove_trailing_ws (p); -+ e->newsgroups = safe_strdup (mutt_skip_whitespace (p)); -+ matched = 1; -+ } -+ break; -+#endif -+ -+ case 'o': -+ /* field `Organization:' saves only for pager! */ -+ if (!mutt_strcasecmp (line + 1, "rganization")) -+ { -+ if (!e->organization && mutt_strcasecmp (p, "unknown")) -+ e->organization = safe_strdup (p); -+ } -+ break; -+ - case 'r': - if (!ascii_strcasecmp (line + 1, "eferences")) - { -@@ -1257,6 +1289,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e, - e->x_label = safe_strdup(p); - matched = 1; - } -+#ifdef USE_NNTP -+ else if (!mutt_strcasecmp (line + 1, "-comment-to")) -+ { -+ if (!e->x_comment_to) -+ e->x_comment_to = safe_strdup (p); -+ matched = 1; -+ } -+ else if (!mutt_strcasecmp (line + 1, "ref")) -+ { -+ if (!e->xref) -+ e->xref = safe_strdup (p); -+ matched = 1; -+ } -+#endif - - default: - break; -diff -udprP mutt-1.5.20.orig/pattern.c mutt-1.5.20/pattern.c ---- mutt-1.5.20.orig/pattern.c 2009-06-03 23:48:31.000000000 +0300 -+++ mutt-1.5.20/pattern.c 2009-06-15 21:05:24.000000000 +0300 -@@ -91,6 +91,9 @@ Flags[] = - { 'U', M_UNREAD, 0, NULL }, - { 'v', M_COLLAPSED, 0, NULL }, - { 'V', M_CRYPT_VERIFIED, 0, NULL }, -+#ifdef USE_NNTP -+ { 'w', M_NEWSGROUPS, 0, eat_regexp }, -+#endif - { 'x', M_REFERENCE, 0, eat_regexp }, - { 'X', M_MIMEATTACH, 0, eat_range }, - { 'y', M_XLABEL, 0, eat_regexp }, -@@ -1204,6 +1207,10 @@ mutt_pattern_exec (struct pattern_t *pat - } - case M_UNREFERENCED: - return (pat->not ^ (h->thread && !h->thread->child)); -+#ifdef USE_NNTP -+ case M_NEWSGROUPS: -+ return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0)); -+#endif - } - mutt_error (_("error: unknown op %d (report this error)."), pat->op); - return (-1); -@@ -1285,6 +1292,7 @@ int mutt_pattern_func (int op, char *pro - progress_t progress; - - strfcpy (buf, NONULL (Context->pattern), sizeof (buf)); -+ if (prompt || op != M_LIMIT) - if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0]) - return (-1); - -diff -udprP mutt-1.5.20.orig/po/POTFILES.in mutt-1.5.20/po/POTFILES.in ---- mutt-1.5.20.orig/po/POTFILES.in 2008-11-11 21:55:47.000000000 +0200 -+++ mutt-1.5.20/po/POTFILES.in 2009-06-15 21:05:24.000000000 +0300 -@@ -46,6 +46,8 @@ mutt_ssl_gnutls.c - mutt_tunnel.c - muttlib.c - mx.c -+newsrc.c -+nntp.c - pager.c - parse.c - pattern.c -diff -udprP mutt-1.5.20.orig/postpone.c mutt-1.5.20/postpone.c ---- mutt-1.5.20.orig/postpone.c 2009-06-14 00:28:37.000000000 +0300 -+++ mutt-1.5.20/postpone.c 2009-06-15 21:05:24.000000000 +0300 -@@ -124,15 +124,26 @@ int mutt_num_postponed (int force) - - if (LastModify < st.st_mtime) - { -+#ifdef USE_NNTP -+ int optnews = option (OPTNEWS); -+#endif - LastModify = st.st_mtime; - - if (access (Postponed, R_OK | F_OK) != 0) - return (PostCount = 0); -+#ifdef USE_NNTP -+ if (optnews) -+ unset_option (OPTNEWS); -+#endif - if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL) - PostCount = 0; - else - PostCount = ctx.msgcount; - mx_fastclose_mailbox (&ctx); -+#ifdef USE_NNTP -+ if (optnews) -+ set_option (OPTNEWS); -+#endif - } - - return (PostCount); -diff -udprP mutt-1.5.20.orig/protos.h mutt-1.5.20/protos.h ---- mutt-1.5.20.orig/protos.h 2009-06-13 02:38:52.000000000 +0300 -+++ mutt-1.5.20/protos.h 2009-06-15 21:05:24.000000000 +0300 -@@ -115,6 +115,7 @@ HASH *mutt_make_id_hash (CONTEXT *); - HASH *mutt_make_subj_hash (CONTEXT *); - - LIST *mutt_make_references(ENVELOPE *e); -+LIST *mutt_parse_references (char *, int); - - char *mutt_read_rfc822_line (FILE *, char *, size_t *); - ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short); -diff -udprP mutt-1.5.20.orig/recvattach.c mutt-1.5.20/recvattach.c ---- mutt-1.5.20.orig/recvattach.c 2009-05-19 03:11:35.000000000 +0300 -+++ mutt-1.5.20/recvattach.c 2009-06-15 21:05:24.000000000 +0300 -@@ -1110,6 +1110,15 @@ void mutt_view_attachments (HEADER *hdr) - } - #endif - -+#ifdef USE_NNTP -+ if (Context->magic == M_NNTP) -+ { -+ mutt_flushinp (); -+ mutt_error _("Can't delete attachment from newsserver."); -+ break; -+ } -+#endif -+ - if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED) - { - mutt_message _( -@@ -1201,10 +1210,33 @@ void mutt_view_attachments (HEADER *hdr) - case OP_FORWARD_MESSAGE: - CHECK_ATTACH; - mutt_attach_forward (fp, hdr, idx, idxlen, -- menu->tagprefix ? NULL : idx[menu->current]->content); -+ menu->tagprefix ? NULL : idx[menu->current]->content, 0); - menu->redraw = REDRAW_FULL; - break; - -+#ifdef USE_NNTP -+ case OP_FORWARD_TO_GROUP: -+ CHECK_ATTACH; -+ mutt_attach_forward (fp, hdr, idx, idxlen, -+ menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS); -+ menu->redraw = REDRAW_FULL; -+ break; -+ -+ case OP_FOLLOWUP: -+ CHECK_ATTACH; -+ -+ if (!idx[menu->current]->content->hdr->env->followup_to || -+ mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") || -+ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES) -+ { -+ mutt_attach_reply (fp, hdr, idx, idxlen, -+ menu->tagprefix ? NULL : idx[menu->current]->content, -+ SENDNEWS|SENDREPLY); -+ menu->redraw = REDRAW_FULL; -+ break; -+ } -+#endif -+ - case OP_REPLY: - case OP_GROUP_REPLY: - case OP_LIST_REPLY: -diff -udprP mutt-1.5.20.orig/recvcmd.c mutt-1.5.20/recvcmd.c ---- mutt-1.5.20.orig/recvcmd.c 2009-06-12 20:24:17.000000000 +0300 -+++ mutt-1.5.20/recvcmd.c 2009-06-15 21:05:24.000000000 +0300 -@@ -401,7 +401,7 @@ static BODY ** copy_problematic_attachme - static void attach_forward_bodies (FILE * fp, HEADER * hdr, - ATTACHPTR ** idx, short idxlen, - BODY * cur, -- short nattach) -+ short nattach, int flags) - { - short i; - short mime_fwd_all = 0; -@@ -547,7 +547,7 @@ _("Can't decode all tagged attachments. - tmpfp = NULL; - - /* now that we have the template, send it. */ -- ci_send_message (0, tmphdr, tmpbody, NULL, parent); -+ ci_send_message (flags, tmphdr, tmpbody, NULL, parent); - return; - - bail: -@@ -574,7 +574,7 @@ _("Can't decode all tagged attachments. - */ - - static void attach_forward_msgs (FILE * fp, HEADER * hdr, -- ATTACHPTR ** idx, short idxlen, BODY * cur) -+ ATTACHPTR ** idx, short idxlen, BODY * cur, int flags) - { - HEADER *curhdr = NULL; - HEADER *tmphdr; -@@ -679,23 +679,23 @@ static void attach_forward_msgs (FILE * - else - mutt_free_header (&tmphdr); - -- ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL, -+ ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL, - NULL, curhdr); - - } - - void mutt_attach_forward (FILE * fp, HEADER * hdr, -- ATTACHPTR ** idx, short idxlen, BODY * cur) -+ ATTACHPTR ** idx, short idxlen, BODY * cur, int flags) - { - short nattach; - - - if (check_all_msg (idx, idxlen, cur, 0) == 0) -- attach_forward_msgs (fp, hdr, idx, idxlen, cur); -+ attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags); - else - { - nattach = count_tagged (idx, idxlen); -- attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach); -+ attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags); - } - } - -@@ -753,28 +753,40 @@ attach_reply_envelope_defaults (ENVELOPE - return -1; - } - -- if (parent) -+#ifdef USE_NNTP -+ if ((flags & SENDNEWS)) - { -- if (mutt_fetch_recips (env, curenv, flags) == -1) -- return -1; -+ /* in case followup set Newsgroups: with Followup-To: if it present */ -+ if (!env->newsgroups && curenv && -+ mutt_strcasecmp (curenv->followup_to, "poster")) -+ env->newsgroups = safe_strdup (curenv->followup_to); - } - else -+#endif - { -- for (i = 0; i < idxlen; i++) -+ if (parent) - { -- if (idx[i]->content->tagged -- && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1) -+ if (mutt_fetch_recips (env, curenv, flags) == -1) - return -1; - } -+ else -+ { -+ for (i = 0; i < idxlen; i++) -+ { -+ if (idx[i]->content->tagged -+ && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1) -+ return -1; -+ } -+ } -+ -+ if ((flags & SENDLISTREPLY) && !env->to) -+ { -+ mutt_error _("No mailing lists found!"); -+ return (-1); -+ } -+ -+ mutt_fix_reply_recipients (env); - } -- -- if ((flags & SENDLISTREPLY) && !env->to) -- { -- mutt_error _("No mailing lists found!"); -- return (-1); -- } -- -- mutt_fix_reply_recipients (env); - mutt_make_misc_reply_headers (env, Context, curhdr, curenv); - - if (parent) -@@ -835,6 +847,13 @@ void mutt_attach_reply (FILE * fp, HEADE - char prefix[SHORT_STRING]; - int rc; - -+#ifdef USE_NNTP -+ if (flags & SENDNEWS) -+ set_option (OPTNEWSSEND); -+ else -+ unset_option (OPTNEWSSEND); -+#endif -+ - if (check_all_msg (idx, idxlen, cur, 0) == -1) - { - nattach = count_tagged (idx, idxlen); -diff -udprP mutt-1.5.20.orig/rfc1524.c mutt-1.5.20/rfc1524.c ---- mutt-1.5.20.orig/rfc1524.c 2009-05-30 20:20:08.000000000 +0300 -+++ mutt-1.5.20/rfc1524.c 2009-06-15 21:05:24.000000000 +0300 -@@ -569,13 +569,13 @@ int rfc1524_expand_filename (char *namet - * safe_fopen(). - */ - --int mutt_rename_file (char *oldfile, char *newfile) -+int _mutt_rename_file (char *oldfile, char *newfile, int overwrite) - { - FILE *ofp, *nfp; - - if (access (oldfile, F_OK) != 0) - return 1; -- if (access (newfile, F_OK) == 0) -+ if (!overwrite && access (newfile, F_OK) == 0) - return 2; - if ((ofp = fopen (oldfile,"r")) == NULL) - return 3; -@@ -590,3 +590,8 @@ int mutt_rename_file (char *oldfile, cha - mutt_unlink (oldfile); - return 0; - } -+ -+int mutt_rename_file (char *oldfile, char *newfile) -+{ -+ return _mutt_rename_file (oldfile, newfile, 0); -+} -diff -udprP mutt-1.5.20.orig/rfc1524.h mutt-1.5.20/rfc1524.h ---- mutt-1.5.20.orig/rfc1524.h 2008-11-11 21:55:47.000000000 +0200 -+++ mutt-1.5.20/rfc1524.h 2009-06-15 21:05:24.000000000 +0300 -@@ -40,5 +40,6 @@ int rfc1524_expand_command (BODY *, char - int rfc1524_expand_filename (char *, char *, char *, size_t); - int rfc1524_mailcap_lookup (BODY *, char *, rfc1524_entry *, int); - int mutt_rename_file (char *, char *); -+int _mutt_rename_file (char *, char *, int); - - #endif /* _RFC1524_H */ -diff -udprP mutt-1.5.20.orig/send.c mutt-1.5.20/send.c ---- mutt-1.5.20.orig/send.c 2009-06-13 02:38:52.000000000 +0300 -+++ mutt-1.5.20/send.c 2009-06-15 21:13:13.000000000 +0300 -@@ -44,6 +44,11 @@ - #include <sys/types.h> - #include <utime.h> - -+#ifdef USE_NNTP -+#include "nntp.h" -+#include "mx.h" -+#endif -+ - #ifdef MIXMASTER - #include "remailer.h" - #endif -@@ -213,17 +218,51 @@ static int edit_address (ADDRESS **a, /* - return 0; - } - --static int edit_envelope (ENVELOPE *en) -+static int edit_envelope (ENVELOPE *en, int flags) - { - char buf[HUGE_STRING]; - LIST *uh = UserHeader; - -- if (edit_address (&en->to, "To: ") == -1 || en->to == NULL) -- return (-1); -- if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1) -- return (-1); -- if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1) -- return (-1); -+#ifdef USE_NNTP -+ if (option (OPTNEWSSEND)) -+ { -+ if (en->newsgroups) -+ strfcpy (buf, en->newsgroups, sizeof (buf)); -+ else -+ buf[0] = 0; -+ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0) -+ return (-1); -+ FREE (&en->newsgroups); -+ en->newsgroups = safe_strdup (buf); -+ -+ if (en->followup_to) -+ strfcpy (buf, en->followup_to, sizeof (buf)); -+ else -+ buf[0] = 0; -+ if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0) -+ return (-1); -+ FREE (&en->followup_to); -+ en->followup_to = safe_strdup (buf); -+ -+ if (en->x_comment_to) -+ strfcpy (buf, en->x_comment_to, sizeof (buf)); -+ else -+ buf[0] = 0; -+ if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0) -+ return (-1); -+ FREE (&en->x_comment_to); -+ en->x_comment_to = safe_strdup (buf); -+ } -+ else -+#endif -+ { -+ if (edit_address (&en->to, "To: ") == -1 || en->to == NULL) -+ return (-1); -+ if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1) -+ return (-1); -+ if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1) -+ return (-1); -+ } - - if (en->subject) - { -@@ -259,6 +298,14 @@ static int edit_envelope (ENVELOPE *en) - return 0; - } - -+#ifdef USE_NNTP -+char *nntp_get_header (const char *s) -+{ -+ SKIPWS (s); -+ return safe_strdup (s); -+} -+#endif -+ - static void process_user_recips (ENVELOPE *env) - { - LIST *uh = UserHeader; -@@ -271,6 +318,14 @@ static void process_user_recips (ENVELOP - env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3); - else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0) - env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4); -+#ifdef USE_NNTP -+ else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0) -+ env->newsgroups = nntp_get_header (uh->data + 11); -+ else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0) -+ env->followup_to = nntp_get_header (uh->data + 12); -+ else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0) -+ env->x_comment_to = nntp_get_header (uh->data + 13); -+#endif - } - } - -@@ -309,6 +364,12 @@ static void process_user_header (ENVELOP - else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 && - ascii_strncasecmp ("cc:", uh->data, 3) != 0 && - ascii_strncasecmp ("bcc:", uh->data, 4) != 0 && -+#ifdef USE_NNTP -+ ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 && -+ ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 && -+ ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 && -+#endif -+ ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 && - ascii_strncasecmp ("subject:", uh->data, 8) != 0 && - ascii_strncasecmp ("return-path:", uh->data, 12) != 0) - { -@@ -657,6 +718,10 @@ void mutt_add_to_reference_headers (ENVE - if (pp) *pp = p; - if (qq) *qq = q; - -+#ifdef USE_NNTP -+ if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from) -+ env->x_comment_to = safe_strdup (mutt_get_name (curenv->from)); -+#endif - } - - static void -@@ -719,6 +784,16 @@ envelope_defaults (ENVELOPE *env, CONTEX - - if (flags & SENDREPLY) - { -+#ifdef USE_NNTP -+ if ((flags & SENDNEWS)) -+ { -+ /* in case followup set Newsgroups: with Followup-To: if it present */ -+ if (!env->newsgroups && curenv && -+ mutt_strcasecmp (curenv->followup_to, "poster")) -+ env->newsgroups = safe_strdup (curenv->followup_to); -+ } -+ else -+#endif - if (tag) - { - HEADER *h; -@@ -865,7 +940,18 @@ void mutt_set_followup_to (ENVELOPE *e) - * it hasn't already been set - */ - -- if (option (OPTFOLLOWUPTO) && !e->mail_followup_to) -+ if (!option (OPTFOLLOWUPTO)) -+ return; -+#ifdef USE_NNTP -+ if (option (OPTNEWSSEND)) -+ { -+ if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ','))) -+ e->followup_to = safe_strdup (e->newsgroups); -+ return; -+ } -+#endif -+ -+ if (!e->mail_followup_to) - { - if (mutt_is_list_cc (0, e->to, e->cc)) - { -@@ -1026,6 +1112,9 @@ static int send_message (HEADER *msg) - #endif - - #if USE_SMTP -+#ifdef USE_NNTP -+ if (!option (OPTNEWSSEND)) -+#endif /* USE_NNTP */ - if (SmtpUrl) - return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc, - msg->env->bcc, tempfile, -@@ -1137,6 +1226,13 @@ ci_send_message (int flags, /* send mod - - int rv = -1; - -+#ifdef USE_NNTP -+ if (flags & SENDNEWS) -+ set_option (OPTNEWSSEND); -+ else -+ unset_option (OPTNEWSSEND); -+#endif -+ - if (!flags && !msg && quadoption (OPT_RECALL) != M_NO && - mutt_num_postponed (1)) - { -@@ -1167,6 +1263,22 @@ ci_send_message (int flags, /* send mod - { - if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0) - goto cleanup; -+#ifdef USE_NNTP -+ /* -+ * If postponed message is a news article, it have -+ * a "Newsgroups:" header line, then set appropriate flag. -+ */ -+ if (msg->env->newsgroups) -+ { -+ flags |= SENDNEWS; -+ set_option (OPTNEWSSEND); -+ } -+ else -+ { -+ flags &= ~SENDNEWS; -+ unset_option (OPTNEWSSEND); -+ } -+#endif - } - - if (flags & (SENDPOSTPONED|SENDRESEND)) -@@ -1278,11 +1390,16 @@ ci_send_message (int flags, /* send mod - if (flags & SENDREPLY) - mutt_fix_reply_recipients (msg->env); - -+#ifdef USE_NNTP -+ if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups) -+ msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group); -+#endif -+ - if (! (flags & (SENDMAILX|SENDBATCH)) && - ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) && - ! ((flags & SENDREPLY) && option (OPTFASTREPLY))) - { -- if (edit_envelope (msg->env) == -1) -+ if (edit_envelope (msg->env, flags) == -1) - goto cleanup; - } - -@@ -1539,6 +1656,11 @@ main_loop: - if (i == -1) - { - /* abort */ -+#ifdef USE_NNTP -+ if (flags & SENDNEWS) -+ mutt_message _("Article not posted."); -+ else -+#endif - mutt_message _("Mail not sent."); - goto cleanup; - } -@@ -1571,6 +1693,9 @@ main_loop: - } - } - -+#ifdef USE_NNTP -+ if (!(flags & SENDNEWS)) -+#endif - if (!has_recips (msg->env->to) && !has_recips (msg->env->cc) && - !has_recips (msg->env->bcc)) - { -@@ -1604,6 +1729,19 @@ main_loop: - mutt_error _("No subject specified."); - goto main_loop; - } -+#ifdef USE_NNTP -+ if ((flags & SENDNEWS) && !msg->env->subject) -+ { -+ mutt_error _("No subject specified."); -+ goto main_loop; -+ } -+ -+ if ((flags & SENDNEWS) && !msg->env->newsgroups) -+ { -+ mutt_error _("No newsgroup specified."); -+ goto main_loop; -+ } -+#endif - - if (msg->content->next) - msg->content = mutt_make_multipart (msg->content); -@@ -1810,7 +1948,12 @@ full_fcc: - } - } - else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX)) -- mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background.")); -+ mutt_message (i != 0 ? _("Sending in background.") : -+#ifdef USE_NNTP -+ (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent.")); -+#else -+ _("Mail sent.")); -+#endif - - if (WithCrypto && (msg->security & ENCRYPT)) - FREE (&pgpkeylist); -diff -udprP mutt-1.5.20.orig/sendlib.c mutt-1.5.20/sendlib.c ---- mutt-1.5.20.orig/sendlib.c 2009-06-14 18:46:11.000000000 +0300 -+++ mutt-1.5.20/sendlib.c 2009-06-15 21:51:17.000000000 +0300 -@@ -46,6 +46,10 @@ - #include <sys/wait.h> - #include <fcntl.h> - -+#ifdef USE_NNTP -+#include "nntp.h" -+#endif -+ - #ifdef HAVE_SYSEXITS_H - #include <sysexits.h> - #else /* Make sure EX_OK is defined <philiph@pobox.com> */ -@@ -1868,6 +1872,9 @@ int mutt_write_rfc822_header (FILE *fp, - mutt_write_address_list (env->to, fp, 4, 0); - } - else if (mode > 0) -+#ifdef USE_NNTP -+ if (!option (OPTNEWSSEND)) -+#endif - fputs ("To: \n", fp); - - if (env->cc) -@@ -1876,6 +1883,9 @@ int mutt_write_rfc822_header (FILE *fp, - mutt_write_address_list (env->cc, fp, 4, 0); - } - else if (mode > 0) -+#ifdef USE_NNTP -+ if (!option (OPTNEWSSEND)) -+#endif - fputs ("Cc: \n", fp); - - if (env->bcc) -@@ -1887,8 +1897,28 @@ int mutt_write_rfc822_header (FILE *fp, - } - } - else if (mode > 0) -+#ifdef USE_NNTP -+ if (!option (OPTNEWSSEND)) -+#endif - fputs ("Bcc: \n", fp); - -+#ifdef USE_NNTP -+ if (env->newsgroups) -+ fprintf (fp, "Newsgroups: %s\n", env->newsgroups); -+ else if (mode == 1 && option (OPTNEWSSEND)) -+ fputs ("Newsgroups: \n", fp); -+ -+ if (env->followup_to) -+ fprintf (fp, "Followup-To: %s\n", env->followup_to); -+ else if (mode == 1 && option (OPTNEWSSEND)) -+ fputs ("Followup-To: \n", fp); -+ -+ if (env->x_comment_to) -+ fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to); -+ else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO)) -+ fputs ("X-Comment-To: \n", fp); -+#endif -+ - if (env->subject) - mutt_write_one_header (fp, "Subject", env->subject, NULL, 0, 0); - else if (mode == 1) -@@ -1907,6 +1937,9 @@ int mutt_write_rfc822_header (FILE *fp, - fputs ("Reply-To: \n", fp); - - if (env->mail_followup_to) -+#ifdef USE_NNTP -+ if (!option (OPTNEWSSEND)) -+#endif - { - fputs ("Mail-Followup-To: ", fp); - mutt_write_address_list (env->mail_followup_to, fp, 18, 0); -@@ -2245,11 +2278,30 @@ mutt_invoke_sendmail (ADDRESS *from, /* - const char *msg, /* file containing message */ - int eightbit) /* message contains 8bit chars */ - { -- char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL; -+ char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL; - char **args = NULL; - size_t argslen = 0, argsmax = 0; - int i; - -+#ifdef USE_NNTP -+ if (option (OPTNEWSSEND)) -+ { -+ char cmd[LONG_STRING]; -+ -+ mutt_FormatString (cmd, sizeof (cmd), 0, NONULL (Inews), nntp_format_str, 0, 0); -+ if (!*cmd) -+ { -+ i = nntp_post (msg); -+ unlink (msg); -+ return i; -+ } -+ -+ s = safe_strdup (cmd); -+ } -+ else -+#endif -+ s = safe_strdup (Sendmail); -+ - ps = s; - i = 0; - while ((ps = strtok (ps, " "))) -@@ -2273,6 +2325,10 @@ mutt_invoke_sendmail (ADDRESS *from, /* - i++; - } - -+#ifdef USE_NNTP -+ if (!option (OPTNEWSSEND)) -+ { -+#endif - if (eightbit && option (OPTUSE8BITMIME)) - args = add_option (args, &argslen, &argsmax, "-B8BITMIME"); - -@@ -2304,6 +2360,9 @@ mutt_invoke_sendmail (ADDRESS *from, /* - args = add_args (args, &argslen, &argsmax, to); - args = add_args (args, &argslen, &argsmax, cc); - args = add_args (args, &argslen, &argsmax, bcc); -+#ifdef USE_NNTP -+ } -+#endif - - if (argslen == argsmax) - safe_realloc (&args, sizeof (char *) * (++argsmax)); -@@ -2384,6 +2443,9 @@ void mutt_prepare_envelope (ENVELOPE *en - rfc2047_encode_string (&env->x_label); - - if (env->subject) -+#ifdef USE_NNTP -+ if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT)) -+#endif - { - rfc2047_encode_string (&env->subject); - } -@@ -2504,6 +2566,10 @@ int mutt_bounce_message (FILE *fp, HEADE - } - rfc822_write_address (resent_from, sizeof (resent_from), from, 0); - -+#ifdef USE_NNTP -+ unset_option (OPTNEWSSEND); -+#endif -+ - ret = _mutt_bounce_message (fp, h, to, resent_from, from); - - rfc822_free_address (&from); -diff -udprP mutt-1.5.20.orig/sort.c mutt-1.5.20/sort.c ---- mutt-1.5.20.orig/sort.c 2008-11-11 21:55:47.000000000 +0200 -+++ mutt-1.5.20/sort.c 2009-06-15 21:05:24.000000000 +0300 -@@ -151,6 +151,15 @@ static int compare_order (const void *a, - HEADER **ha = (HEADER **) a; - HEADER **hb = (HEADER **) b; - -+#ifdef USE_NNTP -+ if ((*ha)->article_num && (*hb)->article_num) -+ { -+ int result = (*ha)->article_num - (*hb)->article_num; -+ AUXSORT(result,a,b); -+ return (SORTCODE (result)); -+ } -+ else -+#endif - /* no need to auxsort because you will never have equality here */ - return (SORTCODE ((*ha)->index - (*hb)->index)); - } -diff -udprP mutt-1.5.20.orig/url.c mutt-1.5.20/url.c ---- mutt-1.5.20.orig/url.c 2009-06-01 19:29:32.000000000 +0300 -+++ mutt-1.5.20/url.c 2009-06-15 21:05:24.000000000 +0300 -@@ -39,6 +39,8 @@ static struct mapping_t UrlMap[] = - { "imaps", U_IMAPS }, - { "pop", U_POP }, - { "pops", U_POPS }, -+ { "news", U_NNTP }, -+ { "newss", U_NNTPS }, - { "mailto", U_MAILTO }, - { "smtp", U_SMTP }, - { "smtps", U_SMTPS }, -diff -udprP mutt-1.5.20.orig/url.h mutt-1.5.20/url.h ---- mutt-1.5.20.orig/url.h 2008-11-11 21:55:47.000000000 +0200 -+++ mutt-1.5.20/url.h 2009-06-15 21:05:24.000000000 +0300 -@@ -8,6 +8,8 @@ typedef enum url_scheme - U_POPS, - U_IMAP, - U_IMAPS, -+ U_NNTP, -+ U_NNTPS, - U_SMTP, - U_SMTPS, - U_MAILTO, -diff -udprP mutt-1.5.20.orig/Makefile.am mutt-1.5.20/Makefile.am ---- mutt-1.5.20.orig/Makefile.am 2009-01-05 04:11:29.000000000 +0200 -+++ mutt-1.5.20/Makefile.am 2009-06-15 21:05:24.000000000 +0300 -@@ -53,6 +53,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c - mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \ - mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \ - pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \ -+ nntp.c newsrc.c \ - smime.c smtp.c utf8.c wcwidth.c \ - bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h - -@@ -64,6 +65,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O - mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \ - mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \ - rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \ -+ nntp.h ChangeLog.nntp \ - _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \ - mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \ - README.SSL smime.h \ -diff -udprP mutt-1.5.20.orig/Makefile.in mutt-1.5.20/Makefile.in ---- mutt-1.5.20.orig/Makefile.in 2009-06-09 09:50:44.000000000 +0300 -+++ mutt-1.5.20/Makefile.in 2009-06-15 21:05:24.000000000 +0300 -@@ -372,6 +372,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c - mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \ - mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \ - pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \ -+ nntp.c newsrc.c \ - smime.c smtp.c utf8.c wcwidth.c \ - bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h - -@@ -383,6 +384,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O - mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \ - mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \ - rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \ -+ nntp.h ChangeLog.nntp \ - _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \ - mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \ - README.SSL smime.h \ -@@ -637,6 +639,8 @@ distclean-compile: - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@ -diff -udprP mutt-1.5.20.orig/configure mutt-1.5.20/configure ---- mutt-1.5.20.orig/configure 2009-06-09 09:50:42.000000000 +0300 -+++ mutt-1.5.20/configure 2009-06-15 21:05:24.000000000 +0300 -@@ -1478,6 +1478,7 @@ Optional Features: - Force use of an external dotlock program - --enable-pop Enable POP3 support - --enable-imap Enable IMAP support -+ --enable-nntp Enable NNTP support - --enable-smtp include internal SMTP relay support - --enable-debug Enable debugging support - --enable-flock Use flock() to lock files -@@ -8523,6 +8524,20 @@ fi - - fi - done -+# Check whether --enable-nntp or --disable-nntp was given. -+if test "${enable_nntp+set}" = set; then -+ enableval="$enable_nntp" -+ if test x$enableval = xyes ; then -+ cat >>confdefs.h <<\_ACEOF -+#define USE_NNTP 1 -+_ACEOF -+ -+ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o" -+ need_socket="yes" -+ fi -+ -+fi; -+ - - - for ac_func in strftime -diff -udprP mutt-1.5.20.orig/doc/Muttrc mutt-1.5.20/doc/Muttrc ---- mutt-1.5.20.orig/doc/Muttrc 2009-06-14 21:53:24.000000000 +0300 -+++ mutt-1.5.20/doc/Muttrc 2009-06-15 21:05:24.000000000 +0300 -@@ -281,6 +281,28 @@ attachments -I message/external-body - # of the value as shown above if included. - # - # -+# set ask_follow_up=no -+# -+# Name: ask_follow_up -+# Type: boolean -+# Default: no -+# -+# -+# If set, Mutt will prompt you for follow-up groups before editing -+# the body of an outgoing message. -+# -+# -+# set ask_x_comment_to=no -+# -+# Name: ask_x_comment_to -+# Type: boolean -+# Default: no -+# -+# -+# If set, Mutt will prompt you for x-comment-to field before editing -+# the body of an outgoing message. -+# -+# - # set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] " - # - # Name: attach_format -@@ -466,6 +488,17 @@ attachments -I message/external-body - # set certificate_file=~/.mutt/certificates - # - # -+# set catchup_newsgroup=ask-yes -+# -+# Name: catchup_newsgroup -+# Type: quadoption -+# Default: ask-yes -+# -+# -+# If this variable is set, Mutt will mark all articles in newsgroup -+# as read when you quit the newsgroup (catchup newsgroup). -+# -+# - # set charset="" - # - # Name: charset -@@ -1121,6 +1154,19 @@ attachments -I message/external-body - # of the same email for you. - # - # -+# set followup_to_poster=ask-yes -+# -+# Name: followup_to_poster -+# Type: quadoption -+# Default: ask-yes -+# -+# -+# If this variable is set and the keyword "poster" is present in -+# Followup-To header, follow-up to newsgroup function is not -+# permitted. The message will be mailed to the submitter of the -+# message via mail. -+# -+# - # set force_name=no - # - # Name: force_name -@@ -1231,6 +1277,28 @@ attachments -I message/external-body - # ``Franklin'' to ``Franklin, Steve''. - # - # -+# set group_index_format="%4C %M%N %5s %-45.45f %d" -+# -+# Name: group_index_format -+# Type: string -+# Default: "%4C %M%N %5s %-45.45f %d" -+# -+# -+# This variable allows you to customize the newsgroup browser display to -+# your personal taste. This string is similar to ``index_format'', but -+# has its own set of printf()-like sequences: -+# -+# %C current newsgroup number -+# %d description of newsgroup (becomes from server) -+# %f newsgroup name -+# %M - if newsgroup not allowed for direct post (moderated for example) -+# %N N if newsgroup is new, u if unsubscribed, blank otherwise -+# %n number of new articles in newsgroup -+# %s number of unread articles in newsgroup -+# %>X right justify the rest of the string and pad with character "X" -+# %|X pad to the end of the line with character "X" -+# -+# - # set hdrs=yes - # - # Name: hdrs -@@ -1779,6 +1847,7 @@ attachments -I message/external-body - # %E number of messages in current thread - # %f sender (address + real name), either From: or Return-Path: - # %F author name, or recipient name if the message is from you -+# %g newsgroup name (if compiled with nntp support) - # %H spam attribute(s) of this message - # %i message-id of the current message - # %l number of lines in the message (does not work with maildir, -@@ -1794,12 +1863,14 @@ attachments -I message/external-body - # stashed the message: list name or recipient name - # if not sent to a list - # %P progress indicator for the built-in pager (how much of the file has been displayed) -+# %R `x-comment-to:' field (if present and compiled with nntp support) - # %s subject of the message - # %S status of the message (``N''/``D''/``d''/``!''/``r''/*) - # %t ``To:'' field (recipients) - # %T the appropriate character from the $to_chars string - # %u user (login) name of the author - # %v first name of the author, or the recipient if the message is from you -+# %W name of organization of author (`organization:' field) - # %X number of attachments - # (please see the ``attachments'' section for possible speed effects) - # %y ``X-Label:'' field, if present -@@ -1835,6 +1906,22 @@ attachments -I message/external-body - # ``save-hook'', ``fcc-hook'' and ``fcc-save-hook'', too. - # - # -+# set inews="" -+# -+# Name: inews -+# Type: path -+# Default: "" -+# -+# -+# If set, specifies the program and arguments used to deliver news posted -+# by Mutt. Otherwise, mutt posts article using current connection to -+# news server. The following printf-style sequence is understood: -+# -+# %s newsserver name -+# -+# Example: set inews="/usr/local/bin/inews -hS" -+# -+# - # set ispell="ispell" - # - # Name: ispell -@@ -2188,6 +2275,18 @@ attachments -I message/external-body - # be attached to the newly composed message if this option is set. - # - # -+# set mime_subject=yes -+# -+# Name: mime_subject -+# Type: boolean -+# Default: yes -+# -+# -+# If unset, 8-bit ``subject:'' line in article header will not be -+# encoded according to RFC2047 to base64. This is useful when message -+# is Usenet article, because MIME for news is nonstandard feature. -+# -+# - # set mix_entry_format="%4n %c %-16s %a" - # - # Name: mix_entry_format -@@ -2254,6 +2353,118 @@ attachments -I message/external-body - # See also $read_inc, $write_inc and $net_inc. - # - # -+# set news_cache_dir="~/.mutt" -+# -+# Name: news_cache_dir -+# Type: path -+# Default: "~/.mutt" -+# -+# -+# This variable pointing to directory where Mutt will save cached news -+# articles headers in. If unset, headers will not be saved at all -+# and will be reloaded each time when you enter to newsgroup. -+# -+# -+# set news_server="" -+# -+# Name: news_server -+# Type: string -+# Default: "" -+# -+# -+# This variable specifies domain name or address of NNTP server. It -+# defaults to the newsserver specified in the environment variable -+# $NNTPSERVER or contained in the file /etc/nntpserver. You can also -+# specify username and an alternative port for each newsserver, ie: -+# -+# [news[s]://][username[:password]@]newsserver[:port] -+# -+# -+# set newsrc="~/.newsrc" -+# -+# Name: newsrc -+# Type: path -+# Default: "~/.newsrc" -+# -+# -+# The file, containing info about subscribed newsgroups - names and -+# indexes of read articles. The following printf-style sequence -+# is understood: -+# -+# %s newsserver name -+# -+# -+# set nntp_context=1000 -+# -+# Name: nntp_context -+# Type: number -+# Default: 1000 -+# -+# -+# This variable defines number of articles which will be in index when -+# newsgroup entered. If active newsgroup have more articles than this -+# number, oldest articles will be ignored. Also controls how many -+# articles headers will be saved in cache when you quit newsgroup. -+# -+# -+# set nntp_load_description=yes -+# -+# Name: nntp_load_description -+# Type: boolean -+# Default: yes -+# -+# -+# This variable controls whether or not descriptions for each newsgroup -+# must be loaded when newsgroup is added to list (first time list -+# loading or new newsgroup adding). -+# -+# -+# set nntp_user="" -+# -+# Name: nntp_user -+# Type: string -+# Default: "" -+# -+# -+# Your login name on the NNTP server. If unset and NNTP server requires -+# authentification, Mutt will prompt you for your account name when you -+# connect to newsserver. -+# -+# -+# set nntp_pass="" -+# -+# Name: nntp_pass -+# Type: string -+# Default: "" -+# -+# -+# Your password for NNTP account. -+# -+# -+# set nntp_poll=60 -+# -+# Name: nntp_poll -+# Type: number -+# Default: 60 -+# -+# -+# The time in seconds until any operations on newsgroup except post new -+# article will cause recheck for new news. If set to 0, Mutt will -+# recheck newsgroup on each operation in index (stepping, read article, -+# etc.). -+# -+# -+# set nntp_reconnect=ask-yes -+# -+# Name: nntp_reconnect -+# Type: quadoption -+# Default: ask-yes -+# -+# -+# Controls whether or not Mutt will try to reconnect to newsserver when -+# connection lost. -+# -+# - # set pager="builtin" - # - # Name: pager -@@ -2969,6 +3180,19 @@ attachments -I message/external-body - # string after the inclusion of a message which is being replied to. - # - # -+# set post_moderated=ask-yes -+# -+# Name: post_moderated -+# Type: quadoption -+# Default: ask-yes -+# -+# -+# If set to yes, Mutt will post article to newsgroup that have -+# not permissions to posting (e.g. moderated). Note: if newsserver -+# does not support posting to that newsgroup or totally read-only, that -+# posting will not have an effect. -+# -+# - # set postpone=ask-yes - # - # Name: postpone -@@ -3543,6 +3767,41 @@ attachments -I message/external-body - # shell from /etc/passwd is used. - # - # -+# set save_unsubscribed=no -+# -+# Name: save_unsubscribed -+# Type: boolean -+# Default: no -+# -+# -+# When set, info about unsubscribed newsgroups will be saved into -+# ``newsrc'' file and into cache. -+# -+# -+# set show_new_news=yes -+# -+# Name: show_new_news -+# Type: boolean -+# Default: yes -+# -+# -+# If set, newsserver will be asked for new newsgroups on entering -+# the browser. Otherwise, it will be done only once for a newsserver. -+# Also controls whether or not number of new articles of subscribed -+# newsgroups will be then checked. -+# -+# -+# set show_only_unread=no -+# -+# Name: show_only_unread -+# Type: boolean -+# Default: no -+# -+# -+# If set, only subscribed newsgroups that contain unread articles -+# will be displayed in browser. -+# -+# - # set sig_dashes=yes - # - # Name: sig_dashes -@@ -4748,3 +5007,14 @@ attachments -I message/external-body - # ``tuning'' section of the manual for performance considerations. - # - # -+# set x_comment_to=no -+# -+# Name: x_comment_to -+# Type: boolean -+# Default: no -+# -+# -+# If set, Mutt will add ``X-Comment-To:'' field (that contains full -+# name of original article author) to article that followuped to newsgroup. -+# -+# Index: SOURCES/patch-1.5.23.vvv.nntp =================================================================== --- SOURCES/patch-1.5.23.vvv.nntp (revision 0) +++ SOURCES/patch-1.5.23.vvv.nntp (working copy) @@ -0,0 +1,8736 @@ +WARNING: Run the following script before configure: + +aclocal -I m4 +autoheader +automake --foreign +autoconf + +-- +Vsevolod Volkov <vvv@mutt.org.ua> + + +diff -udprP mutt-1.5.23.orig/ChangeLog.nntp mutt-1.5.23/ChangeLog.nntp +--- mutt-1.5.23.orig/ChangeLog.nntp 1970-01-01 03:00:00.000000000 +0300 ++++ mutt-1.5.23/ChangeLog.nntp 2014-03-13 12:50:04.000000000 +0200 +@@ -0,0 +1,399 @@ ++* Thu Mar 13 2014 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.23 ++ ++* Tue Oct 29 2013 Vsevolod Volkov <vvv@mutt.org.ua> ++- minor bug fixed while removing new articles ++ ++* Fri Oct 18 2013 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.22 ++ ++* Tue Nov 27 2012 Vsevolod Volkov <vvv@mutt.org.ua> ++- SASL authentication ++- new option nntp_authenticators ++ ++* Fri Nov 16 2012 Vsevolod Volkov <vvv@mutt.org.ua> ++- support of NNTP commands: CAPABILITIES, STARTTLS, LIST NEWSGROUPS, ++ LIST OVERVIEW.FMT, OVER, DATE ++- added bcache support ++- newss URI scheme renamed to snews ++- removed option nntp_reconnect ++ ++* Sun Sep 16 2012 Vsevolod Volkov <vvv@mutt.org.ua> ++- internal header caching replaced with hcache ++- new option newsgroups_charset ++ ++* Wed Sep 16 2010 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.21 ++ ++* Thu Aug 13 2009 Vsevolod Volkov <vvv@mutt.org.ua> ++- fixed writting references in nntp_save_cache_group() ++ ++* Tue Jun 15 2009 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.20 ++ ++* Tue Mar 20 2009 Vsevolod Volkov <vvv@mutt.org.ua> ++- save Date: header of recorded outgoing articles ++ ++* Tue Jan 6 2009 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.19 ++ ++* Mon May 19 2008 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.18 ++- fixed SIGSEGV when followup or forward to newsgroup ++ ++* Sun Nov 4 2007 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.17 ++ ++* Tue Jul 3 2007 Vsevolod Volkov <vvv@mutt.org.ua> ++- fixed arguments of nntp_format_str() ++ ++* Fri Jun 15 2007 Vsevolod Volkov <vvv@mutt.org.ua> ++- fixed error selecting news group ++ ++* Tue Jun 12 2007 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.16 ++ ++* Wed Apr 11 2007 Vsevolod Volkov <vvv@mutt.org.ua> ++- fixed posting error if $smtp_url is set ++- added support of print-style sequence %R (x-comment-to) ++ ++* Sun Apr 8 2007 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.15 ++- nntp://... url changed to news://... ++- added indicator of fetching descriptions progress ++ ++* Tue Feb 28 2007 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.14 ++ ++* Tue Aug 15 2006 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.13 ++ ++* Mon Jul 17 2006 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.12 ++- fixed reading empty .newsrc ++ ++* Sat Sep 17 2005 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.11 ++ ++* Sat Aug 13 2005 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.10 ++ ++* Sun Mar 13 2005 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.9 ++ ++* Sun Feb 13 2005 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.8 ++ ++* Sat Feb 5 2005 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.7 ++- function mutt_update_list_file() moved to newsrc.c and changed algorithm ++ ++* Thu Jul 8 2004 Vsevolod Volkov <vvv@mutt.org.ua> ++- fixed error in nntp_logout_all() ++ ++* Sat Apr 3 2004 Vsevolod Volkov <vvv@mutt.org.ua> ++- fixed debug output in mutt_newsrc_update() ++- added optional support of LISTGROUP command ++- fixed typo in nntp_parse_xref() ++ ++* Tue Feb 3 2004 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.6 ++ ++* Thu Dec 18 2003 Vsevolod Volkov <vvv@mutt.org.ua> ++- fixed compose menu ++ ++* Thu Nov 6 2003 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.5.1 ++ ++* Wed Nov 5 2003 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.5 ++- added space after newsgroup name in .newsrc file ++ ++* Sun May 18 2003 Vsevolod Volkov <vvv@mutt.org.ua> ++- nntp patch: fixed SIGSEGV when posting article ++ ++* Sat Mar 22 2003 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.4 ++ ++* Sat Dec 21 2002 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.3 ++- replace safe_free calls by the FREE macro ++ ++* Fri Dec 6 2002 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.2 ++- nntp authentication can be passed after any command ++ ++* Sat May 4 2002 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.5.1 ++ ++* Thu May 2 2002 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.99 ++ ++* Wed Mar 13 2002 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.28 ++- fixed SIGSEGV in <get-message>, <get-parent>, <get-children>, ++ <reconstruct-thread> functions ++- fixed message about nntp reconnect ++- fixed <attach-news-message> function using browser ++- added support of Followup-To: poster ++- added %n (new articles) in group_index_format ++- posting articles without inews by default ++ ++* Wed Jan 23 2002 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.27 ++ ++* Fri Jan 18 2002 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.26 ++ ++* Thu Jan 3 2002 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.25 ++- accelerated speed of access to news->newsgroups hash (by <gul@gul.kiev.ua>) ++- added default content disposition ++ ++* Mon Dec 3 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.24 ++ ++* Fri Nov 9 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.23.2 ++- fixed segfault if mutt_conn_find() returns null ++ ++* Wed Oct 31 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.23.1 ++- added support of LISTGROUP command ++- added support for servers with broken overview ++- disabled <flag-message> function on news server ++- fixed error storing bad authentication information ++ ++* Wed Oct 10 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.23 ++- fixed typo in buffy.c ++- added substitution of %s parameter in $inews variable ++ ++* Fri Aug 31 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.22.1 ++- update to 1.3.22 ++ ++* Thu Aug 23 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.21 ++ ++* Wed Jul 25 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.20 ++- removed 'server-hook', use 'account-hook' instead ++- fixed error opening NNTP server without newsgroup using -f option ++ ++* Fri Jun 8 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.19 ++ ++* Sat May 5 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.18 ++- fixed typo in nntp_attempt_features() ++- changed algorithm of XGTITLE command testing ++- disabled writing of NNTP password in debug file ++- fixed reading and writing of long newsrc lines ++- changed checking of last line while reading lines from server ++- fixed possible buffer overrun in nntp_parse_newsrc_line() ++- removed checking of XHDR command ++- compare NNTP return codes without trailing space ++ ++* Thu Mar 29 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.17 ++- support for 'LIST NEWSGROUPS' command to read descriptions ++ ++* Fri Mar 2 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.16 ++ ++* Wed Feb 14 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.15 ++ ++* Sun Jan 28 2001 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.14 ++- show number of tagged messages patch from Felix von Leitner <leitner@fefe.de> ++ ++* Sun Dec 31 2000 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.13 ++ ++* Sat Dec 30 2000 Vsevolod Volkov <vvv@mutt.org.ua> ++- Fixed problem if last article in group is deleted ++ ++* Fri Dec 22 2000 Vsevolod Volkov <vvv@mutt.org.ua> ++- Fixed checking of XGTITLE command on some servers ++ ++* Mon Dec 18 2000 Vsevolod Volkov <vvv@mutt.org.ua> ++- Added \r in AUTHINFO commands ++ ++* Mon Nov 27 2000 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.12 ++ ++* Wed Nov 1 2000 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.11 ++- fixed error opening newsgroup from mutt started with -g or -G ++ ++* Thu Oct 12 2000 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.10 ++- hotkey 'G' (get-message) replaced with '^G' ++ ++* Thu Sep 21 2000 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.9 ++- changed delay displaying error messages from 1 to 2 seconds ++- fixed error compiling with nntp and without imap ++ ++* Wed Sep 6 2000 Vsevolod Volkov <vvv@mutt.org.ua> ++- fixed catchup in index ++- fixed nntp_open_mailbox() ++ ++* Sat Sep 2 2000 Vsevolod Volkov <vvv@mutt.org.ua> ++- functions <edit> and <delete-entry> disabled ++- format of news mailbox names changed to url form ++- option nntp_attempts removed ++- option reconnect_news renamed to nntp_reconnect ++- default value of nntp_poll changed from 30 to 60 ++- error handling improved ++ ++* Wed Aug 30 2000 Vsevolod Volkov <vvv@mutt.org.ua> ++- update to 1.3.8 ++- new option show_only_unread ++- add newsgroup completion ++ ++* Fri Aug 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.3.7 ++ ++* Sat Jul 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.3.6 ++ ++* Sun Jul 9 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.3.5 ++- authentication code update ++- fix for changing to newsgroup from mailbox with read messages ++- socket code optimization ++ ++* Wed Jun 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.3.4 ++ ++* Wed Jun 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- don't substitute current newsgroup with deleted new messages ++ ++* Mon Jun 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.3.3 ++- fix for substitution of newsgroup after reconnection ++- fix for loading newsgroups with very long names ++- fix for loading more than 32768 newsgroups ++ ++* Wed May 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.3.2 ++ ++* Sat May 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.3.1 ++ ++* Fri May 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.3 ++ ++* Thu May 11 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.2 ++ ++* Thu May 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.1.14 ++ ++* Sun Apr 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.1.12 ++ ++* Fri Apr 7 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- add substitution of newsgroup with new messages by default ++ ++* Wed Apr 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- add attach message from newsgroup ++- add one-line help in newsreader mode ++- disable 'change-dir' command in newsgroups browser ++- add -G option ++ ++* Tue Apr 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- get default news server name from file /etc/nntpserver ++- use case insensitive server names ++- add print-style sequence %s to $newsrc ++- add -g option ++ ++* Sat Apr 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- remove 'X-FTN-Origin' header processing ++ ++* Thu Mar 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.1.11 ++- update to 1.1.10 ++ ++* Thu Mar 23 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- fix mutt_select_newsserver() ++- remove 'toggle-mode' function ++- add 'change-newsgroup' function ++ ++* Wed Mar 22 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- fix server-hook ++ ++* Tue Mar 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- fix error 'bounce' function after 'post' ++- add 'forward to newsgroup' function ++ ++* Mon Mar 20 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- 'forward' function works in newsreader mode ++- add 'post' and 'followup' functions to pager and attachment menu ++- fix active descriptions and allowed flag reload ++ ++* Tue Mar 14 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.1.9 ++- remove deleted newsgroups from list ++ ++* Mon Mar 13 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update .newsrc in browser ++ ++* Sun Mar 12 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- reload .newsrc if externally modified ++- fix active cache update ++ ++* Sun Mar 5 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.1.8 ++ ++* Sat Mar 4 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- patch *.update_list_file is not required ++- count lines when loading descriptions ++- remove cache of unsubscribed newsgroups ++ ++* Thu Mar 2 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- load list of newsgroups from cache faster ++ ++* Wed Mar 1 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.1.7 ++ ++* Tue Feb 29 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- fix unread messages in browser ++- fix newsrc_gen_entries() ++ ++* Mon Feb 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- fix mutt_newsgroup_stat() ++- fix nntp_delete_cache() ++- fix nntp_get_status() ++- fix check_children() ++- fix nntp_fetch_headers() ++ ++* Fri Feb 25 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.1.5 ++ ++* Thu Feb 24 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- fix updating new messages in cache ++ ++* Mon Feb 21 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- change default cache filenames ++- fix updating new messages in cache ++ ++* Fri Feb 18 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- fix segmentation fault in news groups browser ++ ++* Tue Feb 15 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.1.4 ++ ++* Thu Feb 10 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.1.3 ++ ++* Sun Jan 30 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- add X-Comment-To editing ++- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers ++- add variables $ask_followup_to and $ask_x_comment_to ++ ++* Fri Jan 28 2000 Vsevolod Volkov <vvv@mutt.kiev.ua> ++- update to 1.1.2 +diff -udprP mutt-1.5.23.orig/OPS mutt-1.5.23/OPS +--- mutt-1.5.23.orig/OPS 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/OPS 2014-03-13 12:48:36.000000000 +0200 +@@ -8,14 +8,16 @@ OP_BOUNCE_MESSAGE "remail a message to a + OP_BROWSER_NEW_FILE "select a new file in this directory" + OP_BROWSER_VIEW_FILE "view file" + OP_BROWSER_TELL "display the currently selected file's name" +-OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)" +-OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mailbox (IMAP only)" ++OP_BROWSER_SUBSCRIBE "subscribe to current mbox (IMAP/NNTP only)" ++OP_BROWSER_UNSUBSCRIBE "unsubscribe from current mbox (IMAP/NNTP only)" + OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)" + OP_BUFFY_LIST "list mailboxes with new mail" ++OP_CATCHUP "mark all articles in newsgroup as read" + OP_CHANGE_DIRECTORY "change directories" + OP_CHECK_NEW "check mailboxes for new mail" + OP_COMPOSE_ATTACH_FILE "attach file(s) to this message" + OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message" ++OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach news article(s) to this message" + OP_COMPOSE_EDIT_BCC "edit the BCC list" + OP_COMPOSE_EDIT_CC "edit the CC list" + OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description" +@@ -26,7 +28,10 @@ OP_COMPOSE_EDIT_FROM "edit the from fiel + OP_COMPOSE_EDIT_HEADERS "edit the message with headers" + OP_COMPOSE_EDIT_MESSAGE "edit the message" + OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry" ++OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list" + OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field" ++OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field" ++OP_COMPOSE_EDIT_X_COMMENT_TO "edit the X-Comment-To field" + OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message" + OP_COMPOSE_EDIT_TO "edit the TO list" + OP_CREATE_MAILBOX "create a new mailbox (IMAP only)" +@@ -85,8 +90,13 @@ OP_EXIT "exit this menu" + OP_FILTER "filter attachment through a shell command" + OP_FIRST_ENTRY "move to the first entry" + OP_FLAG_MESSAGE "toggle a message's 'important' flag" ++OP_FOLLOWUP "followup to newsgroup" ++OP_FORWARD_TO_GROUP "forward to newsgroup" + OP_FORWARD_MESSAGE "forward a message with comments" + OP_GENERIC_SELECT_ENTRY "select the current entry" ++OP_GET_CHILDREN "get all children of the current message" ++OP_GET_MESSAGE "get message with Message-Id" ++OP_GET_PARENT "get parent of the current message" + OP_GROUP_REPLY "reply to all recipients" + OP_HALF_DOWN "scroll down 1/2 page" + OP_HALF_UP "scroll up 1/2 page" +@@ -94,11 +104,14 @@ OP_HELP "this screen" + OP_JUMP "jump to an index number" + OP_LAST_ENTRY "move to the last entry" + OP_LIST_REPLY "reply to specified mailing list" ++OP_LOAD_ACTIVE "load list of all newsgroups from NNTP server" + OP_MACRO "execute a macro" + OP_MAIL "compose a new mail message" + OP_MAIN_BREAK_THREAD "break the thread in two" + OP_MAIN_CHANGE_FOLDER "open a different folder" + OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode" ++OP_MAIN_CHANGE_GROUP "open a different newsgroup" ++OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode" + OP_MAIN_CLEAR_FLAG "clear a status flag from a message" + OP_MAIN_DELETE_PATTERN "delete messages matching a pattern" + OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server" +@@ -138,6 +151,7 @@ OP_PAGER_HIDE_QUOTED "toggle display of + OP_PAGER_SKIP_QUOTED "skip beyond quoted text" + OP_PAGER_TOP "jump to the top of the message" + OP_PIPE "pipe message/attachment to a shell command" ++OP_POST "post message to newsgroup" + OP_PREV_ENTRY "move to the previous entry" + OP_PREV_LINE "scroll up one line" + OP_PREV_PAGE "move to the previous page" +@@ -146,6 +160,7 @@ OP_QUERY "query external program for add + OP_QUERY_APPEND "append new query results to current results" + OP_QUIT "save changes to mailbox and quit" + OP_RECALL_MESSAGE "recall a postponed message" ++OP_RECONSTRUCT_THREAD "reconstruct thread containing current message" + OP_REDRAW "clear and redraw the screen" + OP_REFORMAT_WINCH "{internal}" + OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)" +@@ -160,18 +175,22 @@ OP_SEARCH_TOGGLE "toggle search pattern + OP_SHELL_ESCAPE "invoke a command in a subshell" + OP_SORT "sort messages" + OP_SORT_REVERSE "sort messages in reverse order" ++OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern" + OP_TAG "tag the current entry" + OP_TAG_PREFIX "apply next function to tagged messages" + OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages" + OP_TAG_SUBTHREAD "tag the current subthread" + OP_TAG_THREAD "tag the current thread" + OP_TOGGLE_NEW "toggle a message's 'new' flag" ++OP_TOGGLE_READ "toggle view of read messages" + OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten" + OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files" + OP_TOP_PAGE "move to the top of the page" ++OP_UNCATCHUP "mark all articles in newsgroup as unread" + OP_UNDELETE "undelete the current entry" + OP_UNDELETE_THREAD "undelete all messages in thread" + OP_UNDELETE_SUBTHREAD "undelete all messages in subthread" ++OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern" + OP_VERSION "show the Mutt version number and date" + OP_VIEW_ATTACH "view attachment using mailcap entry if necessary" + OP_VIEW_ATTACHMENTS "show MIME attachments" +diff -udprP mutt-1.5.23.orig/PATCHES mutt-1.5.23/PATCHES +--- mutt-1.5.23.orig/PATCHES 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/PATCHES 2014-03-13 12:48:36.000000000 +0200 +@@ -0,0 +1 @@ ++vvv.nntp +diff -udprP mutt-1.5.23.orig/account.c mutt-1.5.23/account.c +--- mutt-1.5.23.orig/account.c 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/account.c 2014-03-13 12:48:36.000000000 +0200 +@@ -51,8 +51,17 @@ int mutt_account_match (const ACCOUNT* a + user = PopUser; + #endif + ++#ifdef USE_NNTP ++ if (a1->type == M_ACCT_TYPE_NNTP && NntpUser) ++ user = NntpUser; ++#endif ++ + if (a1->flags & a2->flags & M_ACCT_USER) + return (!strcmp (a1->user, a2->user)); ++#ifdef USE_NNTP ++ if (a1->type == M_ACCT_TYPE_NNTP) ++ return a1->flags & M_ACCT_USER && a1->user[0] ? 0 : 1; ++#endif + if (a1->flags & M_ACCT_USER) + return (!strcmp (a1->user, user)); + if (a2->flags & M_ACCT_USER) +@@ -130,6 +139,16 @@ void mutt_account_tourl (ACCOUNT* accoun + } + #endif + ++#ifdef USE_NNTP ++ if (account->type == M_ACCT_TYPE_NNTP) ++ { ++ if (account->flags & M_ACCT_SSL) ++ url->scheme = U_NNTPS; ++ else ++ url->scheme = U_NNTP; ++ } ++#endif ++ + url->host = account->host; + if (account->flags & M_ACCT_PORT) + url->port = account->port; +@@ -155,6 +174,10 @@ int mutt_account_getuser (ACCOUNT* accou + else if ((account->type == M_ACCT_TYPE_POP) && PopUser) + strfcpy (account->user, PopUser, sizeof (account->user)); + #endif ++#ifdef USE_NNTP ++ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser) ++ strfcpy (account->user, NntpUser, sizeof (account->user)); ++#endif + else if (option (OPTNOCURSES)) + return -1; + /* prompt (defaults to unix username), copy into account->user */ +@@ -217,6 +240,10 @@ int mutt_account_getpass (ACCOUNT* accou + else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass) + strfcpy (account->pass, SmtpPass, sizeof (account->pass)); + #endif ++#ifdef USE_NNTP ++ else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass) ++ strfcpy (account->pass, NntpPass, sizeof (account->pass)); ++#endif + else if (option (OPTNOCURSES)) + return -1; + else +diff -udprP mutt-1.5.23.orig/account.h mutt-1.5.23/account.h +--- mutt-1.5.23.orig/account.h 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/account.h 2014-03-13 12:48:36.000000000 +0200 +@@ -29,7 +29,8 @@ enum + M_ACCT_TYPE_NONE = 0, + M_ACCT_TYPE_IMAP, + M_ACCT_TYPE_POP, +- M_ACCT_TYPE_SMTP ++ M_ACCT_TYPE_SMTP, ++ M_ACCT_TYPE_NNTP + }; + + /* account flags */ +diff -udprP mutt-1.5.23.orig/attach.h mutt-1.5.23/attach.h +--- mutt-1.5.23.orig/attach.h 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/attach.h 2014-03-13 12:48:36.000000000 +0200 +@@ -50,7 +50,7 @@ void mutt_print_attachment_list (FILE *f + + void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *); + void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *); +-void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *); ++void mutt_attach_forward (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int); + void mutt_attach_reply (FILE *, HEADER *, ATTACHPTR **, short, BODY *, int); + + #endif /* _ATTACH_H_ */ +diff -udprP mutt-1.5.23.orig/browser.c mutt-1.5.23/browser.c +--- mutt-1.5.23.orig/browser.c 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/browser.c 2014-03-13 12:48:36.000000000 +0200 +@@ -32,6 +32,9 @@ + #ifdef USE_IMAP + #include "imap.h" + #endif ++#ifdef USE_NNTP ++#include "nntp.h" ++#endif + + #include <stdlib.h> + #include <dirent.h> +@@ -50,6 +53,19 @@ static const struct mapping_t FolderHelp + { NULL, 0 } + }; + ++#ifdef USE_NNTP ++static struct mapping_t FolderNewsHelp[] = { ++ { N_("Exit"), OP_EXIT }, ++ { N_("List"), OP_TOGGLE_MAILBOXES }, ++ { N_("Subscribe"), OP_BROWSER_SUBSCRIBE }, ++ { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE }, ++ { N_("Catchup"), OP_CATCHUP }, ++ { N_("Mask"), OP_ENTER_MASK }, ++ { N_("Help"), OP_HELP }, ++ { NULL, 0 } ++}; ++#endif ++ + typedef struct folder_t + { + struct folder_file *ff; +@@ -115,9 +131,17 @@ static void browser_sort (struct browser + case SORT_ORDER: + return; + case SORT_DATE: ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ return; ++#endif + f = browser_compare_date; + break; + case SORT_SIZE: ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ return; ++#endif + f = browser_compare_size; + break; + case SORT_SUBJECT: +@@ -324,8 +348,111 @@ folder_format_str (char *dest, size_t de + return (src); + } + ++#ifdef USE_NNTP ++static const char * ++newsgroup_format_str (char *dest, size_t destlen, size_t col, char op, const char *src, ++ const char *fmt, const char *ifstring, const char *elsestring, ++ unsigned long data, format_flag flags) ++{ ++ char fn[SHORT_STRING], tmp[SHORT_STRING]; ++ FOLDER *folder = (FOLDER *) data; ++ ++ switch (op) ++ { ++ case 'C': ++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); ++ snprintf (dest, destlen, tmp, folder->num + 1); ++ break; ++ ++ case 'f': ++ strncpy (fn, folder->ff->name, sizeof(fn) - 1); ++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); ++ snprintf (dest, destlen, tmp, fn); ++ break; ++ ++ case 'N': ++ snprintf (tmp, sizeof (tmp), "%%%sc", fmt); ++ if (folder->ff->nd->subscribed) ++ snprintf (dest, destlen, tmp, ' '); ++ else ++ snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u'); ++ break; ++ ++ case 'M': ++ snprintf (tmp, sizeof (tmp), "%%%sc", fmt); ++ if (folder->ff->nd->deleted) ++ snprintf (dest, destlen, tmp, 'D'); ++ else ++ snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-'); ++ break; ++ ++ case 's': ++ if (flags & M_FORMAT_OPTIONAL) ++ { ++ if (folder->ff->nd->unread != 0) ++ mutt_FormatString (dest, destlen, col, ifstring, newsgroup_format_str, ++ data, flags); ++ else ++ mutt_FormatString (dest, destlen, col, elsestring, newsgroup_format_str, ++ data, flags); ++ } ++ else if (Context && Context->data == folder->ff->nd) ++ { ++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); ++ snprintf (dest, destlen, tmp, Context->unread); ++ } ++ else ++ { ++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); ++ snprintf (dest, destlen, tmp, folder->ff->nd->unread); ++ } ++ break; ++ ++ case 'n': ++ if (Context && Context->data == folder->ff->nd) ++ { ++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); ++ snprintf (dest, destlen, tmp, Context->new); ++ } ++ else if (option (OPTMARKOLD) && ++ folder->ff->nd->lastCached >= folder->ff->nd->firstMessage && ++ folder->ff->nd->lastCached <= folder->ff->nd->lastMessage) ++ { ++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); ++ snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached); ++ } ++ else ++ { ++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt); ++ snprintf (dest, destlen, tmp, folder->ff->nd->unread); ++ } ++ break; ++ ++ case 'd': ++ if (folder->ff->nd->desc != NULL) ++ { ++ char *buf = safe_strdup (folder->ff->nd->desc); ++ if (NewsgroupsCharset && *NewsgroupsCharset) ++ mutt_convert_string (&buf, NewsgroupsCharset, Charset, M_ICONV_HOOK_FROM); ++ mutt_filter_unprintable (&buf); ++ ++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); ++ snprintf (dest, destlen, tmp, buf); ++ } ++ else ++ { ++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); ++ snprintf (dest, destlen, tmp, ""); ++ } ++ break; ++ } ++ return (src); ++} ++#endif /* USE_NNTP */ ++ + static void add_folder (MUTTMENU *m, struct browser_state *state, +- const char *name, const struct stat *s, unsigned int new) ++ const char *name, const struct stat *s, ++ void *data, unsigned int new) + { + if (state->entrylen == state->entrymax) + { +@@ -354,6 +481,10 @@ static void add_folder (MUTTMENU *m, str + #ifdef USE_IMAP + (state->entry)[state->entrylen].imap = 0; + #endif ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ (state->entry)[state->entrylen].nd = (NNTP_DATA *)data; ++#endif + (state->entrylen)++; + } + +@@ -369,9 +500,36 @@ static void init_state (struct browser_s + menu->data = state->entry; + } + ++/* get list of all files/newsgroups with mask */ + static int examine_directory (MUTTMENU *menu, struct browser_state *state, + char *d, const char *prefix) + { ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ { ++ NNTP_SERVER *nserv = CurrentNewsSrv; ++ unsigned int i; ++ ++/* mutt_buffy_check (0); */ ++ init_state (state, menu); ++ ++ for (i = 0; i < nserv->groups_num; i++) ++ { ++ NNTP_DATA *nntp_data = nserv->groups_list[i]; ++ if (!nntp_data) ++ continue; ++ if (prefix && *prefix && ++ strncmp (prefix, nntp_data->group, strlen (prefix))) ++ continue; ++ if (!((regexec (Mask.rx, nntp_data->group, 0, NULL, 0) == 0) ^ Mask.not)) ++ continue; ++ add_folder (menu, state, nntp_data->group, NULL, ++ nntp_data, nntp_data->new); ++ } ++ } ++ else ++#endif /* USE_NNTP */ ++ { + struct stat s; + DIR *dp; + struct dirent *de; +@@ -432,17 +590,41 @@ static int examine_directory (MUTTMENU * + tmp = Incoming; + while (tmp && mutt_strcmp (buffer, tmp->path)) + tmp = tmp->next; +- add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0); ++ add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0); + } + closedir (dp); ++ } + browser_sort (state); + return 0; + } + ++/* get list of mailboxes/subscribed newsgroups */ + static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state) + { + struct stat s; + char buffer[LONG_STRING]; ++ ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ { ++ NNTP_SERVER *nserv = CurrentNewsSrv; ++ unsigned int i; ++ ++/* mutt_buffy_check (0); */ ++ init_state (state, menu); ++ ++ for (i = 0; i < nserv->groups_num; i++) ++ { ++ NNTP_DATA *nntp_data = nserv->groups_list[i]; ++ if (nntp_data && (nntp_data->new || (nntp_data->subscribed && ++ (nntp_data->unread || !option (OPTSHOWONLYUNREAD))))) ++ add_folder (menu, state, nntp_data->group, NULL, ++ nntp_data, nntp_data->new); ++ } ++ } ++ else ++#endif ++ { + BUFFY *tmp = Incoming; + #ifdef USE_IMAP + struct mailbox_state mbox; +@@ -460,14 +642,21 @@ static int examine_mailboxes (MUTTMENU * + if (mx_is_imap (tmp->path)) + { + imap_mailbox_state (tmp->path, &mbox); +- add_folder (menu, state, tmp->path, NULL, mbox.new); ++ add_folder (menu, state, tmp->path, NULL, NULL, mbox.new); + continue; + } + #endif + #ifdef USE_POP + if (mx_is_pop (tmp->path)) + { +- add_folder (menu, state, tmp->path, NULL, tmp->new); ++ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); ++ continue; ++ } ++#endif ++#ifdef USE_NNTP ++ if (mx_is_nntp (tmp->path)) ++ { ++ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); + continue; + } + #endif +@@ -496,15 +685,20 @@ static int examine_mailboxes (MUTTMENU * + strfcpy (buffer, NONULL(tmp->path), sizeof (buffer)); + mutt_pretty_mailbox (buffer, sizeof (buffer)); + +- add_folder (menu, state, buffer, &s, tmp->new); ++ add_folder (menu, state, buffer, &s, NULL, tmp->new); + } + while ((tmp = tmp->next)); ++ } + browser_sort (state); + return 0; + } + + static int select_file_search (MUTTMENU *menu, regex_t *re, int n) + { ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0)); ++#endif + return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0)); + } + +@@ -515,6 +709,12 @@ static void folder_entry (char *s, size_ + folder.ff = &((struct folder_file *) menu->data)[num]; + folder.num = num; + ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ mutt_FormatString (s, slen, 0, NONULL(GroupFormat), newsgroup_format_str, ++ (unsigned long) &folder, M_FORMAT_ARROWCURSOR); ++ else ++#endif + mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str, + (unsigned long) &folder, M_FORMAT_ARROWCURSOR); + } +@@ -535,6 +735,17 @@ static void init_menu (struct browser_st + + menu->tagged = 0; + ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ { ++ if (buffy) ++ snprintf (title, titlelen, _("Subscribed newsgroups")); ++ else ++ snprintf (title, titlelen, _("Newsgroups on server [%s]"), ++ CurrentNewsSrv->conn->account.host); ++ } ++ else ++#endif + if (buffy) + snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0)); + else +@@ -590,6 +801,31 @@ void _mutt_select_file (char *f, size_t + if (!folder) + strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup)); + ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ { ++ if (*f) ++ strfcpy (prefix, f, sizeof (prefix)); ++ else ++ { ++ NNTP_SERVER *nserv = CurrentNewsSrv; ++ unsigned int i; ++ ++ /* default state for news reader mode is browse subscribed newsgroups */ ++ buffy = 0; ++ for (i = 0; i < nserv->groups_num; i++) ++ { ++ NNTP_DATA *nntp_data = nserv->groups_list[i]; ++ if (nntp_data && nntp_data->subscribed) ++ { ++ buffy = 1; ++ break; ++ } ++ } ++ } ++ } ++ else ++#endif + if (*f) + { + mutt_expand_path (f, flen); +@@ -686,6 +922,9 @@ void _mutt_select_file (char *f, size_t + menu->tag = file_tag; + + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER, ++#ifdef USE_NNTP ++ option (OPTNEWS) ? FolderNewsHelp : ++#endif + FolderHelp); + + init_menu (&state, menu, title, sizeof (title), buffy); +@@ -824,7 +1063,11 @@ void _mutt_select_file (char *f, size_t + } + } + ++#ifdef USE_NNTP ++ if (buffy || option (OPTNEWS)) ++#else + if (buffy) ++#endif + { + strfcpy (f, state.entry[menu->current].name, flen); + mutt_expand_path (f, flen); +@@ -882,14 +1125,6 @@ void _mutt_select_file (char *f, size_t + break; + + #ifdef USE_IMAP +- case OP_BROWSER_SUBSCRIBE: +- imap_subscribe (state.entry[menu->current].name, 1); +- break; +- +- case OP_BROWSER_UNSUBSCRIBE: +- imap_subscribe (state.entry[menu->current].name, 0); +- break; +- + case OP_BROWSER_TOGGLE_LSUB: + if (option (OPTIMAPLSUB)) + unset_option (OPTIMAPLSUB); +@@ -990,6 +1225,11 @@ void _mutt_select_file (char *f, size_t + + case OP_CHANGE_DIRECTORY: + ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ break; ++#endif ++ + strfcpy (buf, LastDir, sizeof (buf)); + #ifdef USE_IMAP + if (!state.imap_browse) +@@ -1255,6 +1495,210 @@ void _mutt_select_file (char *f, size_t + else + mutt_error _("Error trying to view file"); + } ++ break; ++ ++#ifdef USE_NNTP ++ case OP_CATCHUP: ++ case OP_UNCATCHUP: ++ if (option (OPTNEWS)) ++ { ++ struct folder_file *f = &state.entry[menu->current]; ++ int rc; ++ NNTP_DATA *nntp_data; ++ ++ rc = nntp_newsrc_parse (CurrentNewsSrv); ++ if (rc < 0) ++ break; ++ ++ if (i == OP_CATCHUP) ++ nntp_data = mutt_newsgroup_catchup (CurrentNewsSrv, f->name); ++ else ++ nntp_data = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name); ++ ++ if (nntp_data) ++ { ++/* FOLDER folder; ++ struct folder_file ff; ++ char buffer[_POSIX_PATH_MAX + SHORT_STRING]; ++ ++ folder.ff = &ff; ++ folder.ff->name = f->name; ++ folder.ff->st = NULL; ++ folder.ff->is_new = nntp_data->new; ++ folder.ff->nntp_data = nntp_data; ++ FREE (&f->desc); ++ mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat), ++ newsgroup_format_str, (unsigned long) &folder, ++ M_FORMAT_ARROWCURSOR); ++ f->desc = safe_strdup (buffer); */ ++ nntp_newsrc_update (CurrentNewsSrv); ++ if (menu->current + 1 < menu->max) ++ menu->current++; ++ menu->redraw = REDRAW_MOTION_RESYNCH; ++ } ++ if (rc) ++ menu->redraw = REDRAW_INDEX; ++ nntp_newsrc_close (CurrentNewsSrv); ++ } ++ break; ++ ++ case OP_LOAD_ACTIVE: ++ if (option (OPTNEWS)) ++ { ++ NNTP_SERVER *nserv = CurrentNewsSrv; ++ unsigned int i; ++ ++ if (nntp_newsrc_parse (nserv) < 0) ++ break; ++ ++ for (i = 0; i < nserv->groups_num; i++) ++ { ++ NNTP_DATA *nntp_data = nserv->groups_list[i]; ++ if (nntp_data) ++ nntp_data->deleted = 1; ++ } ++ nntp_active_fetch (nserv); ++ nntp_newsrc_update (nserv); ++ nntp_newsrc_close (nserv); ++ ++ destroy_state (&state); ++ if (buffy) ++ examine_mailboxes (menu, &state); ++ else ++ examine_directory (menu, &state, NULL, NULL); ++ init_menu (&state, menu, title, sizeof (title), buffy); ++ } ++ break; ++#endif /* USE_NNTP */ ++ ++#if defined USE_IMAP || defined USE_NNTP ++ case OP_BROWSER_SUBSCRIBE: ++ case OP_BROWSER_UNSUBSCRIBE: ++#endif ++#ifdef USE_NNTP ++ case OP_SUBSCRIBE_PATTERN: ++ case OP_UNSUBSCRIBE_PATTERN: ++ if (option (OPTNEWS)) ++ { ++ NNTP_SERVER *nserv = CurrentNewsSrv; ++ NNTP_DATA *nntp_data; ++ regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t)); ++ char *s = buf; ++ int rc, j = menu->current; ++ ++ if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN) ++ { ++ char tmp[STRING]; ++ int err; ++ ++ buf[0] = 0; ++ if (i == OP_SUBSCRIBE_PATTERN) ++ snprintf (tmp, sizeof (tmp), _("Subscribe pattern: ")); ++ else ++ snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: ")); ++ if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) ++ { ++ FREE (&rx); ++ break; ++ } ++ ++ err = REGCOMP (rx, s, REG_NOSUB); ++ if (err) ++ { ++ regerror (err, rx, buf, sizeof (buf)); ++ regfree (rx); ++ FREE (&rx); ++ mutt_error ("%s", buf); ++ break; ++ } ++ menu->redraw = REDRAW_FULL; ++ j = 0; ++ } ++ else if (!state.entrylen) ++ { ++ mutt_error _("No newsgroups match the mask"); ++ break; ++ } ++ ++ rc = nntp_newsrc_parse (nserv); ++ if (rc < 0) ++ break; ++ ++ for ( ; j < state.entrylen; j++) ++ { ++ struct folder_file *f = &state.entry[j]; ++ ++ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE || ++ regexec (rx, f->name, 0, NULL, 0) == 0) ++ { ++ if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN) ++ nntp_data = mutt_newsgroup_subscribe (nserv, f->name); ++ else ++ nntp_data = mutt_newsgroup_unsubscribe (nserv, f->name); ++/* if (nntp_data) ++ { ++ FOLDER folder; ++ char buffer[_POSIX_PATH_MAX + SHORT_STRING]; ++ ++ folder.name = f->name; ++ folder.f = NULL; ++ folder.new = nntp_data->new; ++ folder.nd = nntp_data; ++ FREE (&f->desc); ++ mutt_FormatString (buffer, sizeof (buffer), 0, NONULL(GroupFormat), ++ newsgroup_format_str, (unsigned long) &folder, ++ M_FORMAT_ARROWCURSOR); ++ f->desc = safe_strdup (buffer); ++ } */ ++ } ++ if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE) ++ { ++ if (menu->current + 1 < menu->max) ++ menu->current++; ++ menu->redraw = REDRAW_MOTION_RESYNCH; ++ break; ++ } ++ } ++ if (i == OP_SUBSCRIBE_PATTERN) ++ { ++ unsigned int i; ++ ++ for (i = 0; nserv && i < nserv->groups_num; i++) ++ { ++ nntp_data = nserv->groups_list[i]; ++ if (nntp_data && nntp_data->group && !nntp_data->subscribed) ++ { ++ if (regexec (rx, nntp_data->group, 0, NULL, 0) == 0) ++ { ++ mutt_newsgroup_subscribe (nserv, nntp_data->group); ++ add_folder (menu, &state, nntp_data->group, NULL, ++ nntp_data, nntp_data->new); ++ } ++ } ++ } ++ init_menu (&state, menu, title, sizeof (title), buffy); ++ } ++ if (rc > 0) ++ menu->redraw = REDRAW_FULL; ++ nntp_newsrc_update (nserv); ++ nntp_clear_cache (nserv); ++ nntp_newsrc_close (nserv); ++ if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE) ++ regfree (rx); ++ FREE (&rx); ++ } ++#ifdef USE_IMAP ++ else ++#endif /* USE_IMAP && USE_NNTP */ ++#endif /* USE_NNTP */ ++#ifdef USE_IMAP ++ { ++ if (i == OP_BROWSER_SUBSCRIBE) ++ imap_subscribe (state.entry[menu->current].name, 1); ++ else ++ imap_subscribe (state.entry[menu->current].name, 0); ++ } ++#endif /* USE_IMAP */ + } + } + +diff -udprP mutt-1.5.23.orig/browser.h mutt-1.5.23/browser.h +--- mutt-1.5.23.orig/browser.h 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/browser.h 2014-03-13 12:48:36.000000000 +0200 +@@ -19,6 +19,10 @@ + #ifndef _BROWSER_H + #define _BROWSER_H 1 + ++#ifdef USE_NNTP ++#include "nntp.h" ++#endif ++ + struct folder_file + { + mode_t mode; +@@ -37,6 +41,9 @@ struct folder_file + unsigned selectable : 1; + unsigned inferiors : 1; + #endif ++#ifdef USE_NNTP ++ NNTP_DATA *nd; ++#endif + unsigned tagged : 1; + }; + +diff -udprP mutt-1.5.23.orig/buffy.c mutt-1.5.23/buffy.c +--- mutt-1.5.23.orig/buffy.c 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/buffy.c 2014-03-13 12:48:36.000000000 +0200 +@@ -405,6 +405,9 @@ int mutt_buffy_check (int force) + + /* check device ID and serial number instead of comparing paths */ + if (!Context || Context->magic == M_IMAP || Context->magic == M_POP ++#ifdef USE_NNTP ++ || Context->magic == M_NNTP ++#endif + || stat (Context->path, &contex_sb) != 0) + { + contex_sb.st_dev=0; +@@ -421,6 +424,11 @@ int mutt_buffy_check (int force) + tmp->magic = M_POP; + else + #endif ++#ifdef USE_NNTP ++ if ((tmp->magic == M_NNTP) || mx_is_nntp (tmp->path)) ++ tmp->magic = M_NNTP; ++ else ++#endif + if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) || + (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0)) + { +@@ -436,7 +444,11 @@ int mutt_buffy_check (int force) + /* check to see if the folder is the currently selected folder + * before polling */ + if (!Context || !Context->path || ++#ifdef USE_NNTP ++ (( tmp->magic == M_IMAP || tmp->magic == M_POP || tmp->magic == M_NNTP ) ++#else + (( tmp->magic == M_IMAP || tmp->magic == M_POP ) ++#endif + ? mutt_strcmp (tmp->path, Context->path) : + (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino))) + { +diff -udprP mutt-1.5.23.orig/complete.c mutt-1.5.23/complete.c +--- mutt-1.5.23.orig/complete.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/complete.c 2014-03-13 12:48:36.000000000 +0200 +@@ -25,6 +25,9 @@ + #include "mailbox.h" + #include "imap.h" + #endif ++#ifdef USE_NNTP ++#include "nntp.h" ++#endif + + #include <dirent.h> + #include <string.h> +@@ -48,9 +51,70 @@ int mutt_complete (char *s, size_t slen) + char filepart[_POSIX_PATH_MAX]; + #ifdef USE_IMAP + char imap_path[LONG_STRING]; ++#endif + + dprint (2, (debugfile, "mutt_complete: completing %s\n", s)); + ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ { ++ NNTP_SERVER *nserv = CurrentNewsSrv; ++ unsigned int n = 0; ++ ++ strfcpy (filepart, s, sizeof (filepart)); ++ ++ /* special case to handle when there is no filepart yet ++ * find the first subscribed newsgroup */ ++ len = mutt_strlen (filepart); ++ if (len == 0) ++ { ++ for (; n < nserv->groups_num; n++) ++ { ++ NNTP_DATA *nntp_data = nserv->groups_list[n]; ++ ++ if (nntp_data && nntp_data->subscribed) ++ { ++ strfcpy (filepart, nntp_data->group, sizeof (filepart)); ++ init = 1; ++ n++; ++ break; ++ } ++ } ++ } ++ ++ for (; n < nserv->groups_num; n++) ++ { ++ NNTP_DATA *nntp_data = nserv->groups_list[n]; ++ ++ if (nntp_data && nntp_data->subscribed && ++ mutt_strncmp (nntp_data->group, filepart, len) == 0) ++ { ++ if (init) ++ { ++ for (i = 0; filepart[i] && nntp_data->group[i]; i++) ++ { ++ if (filepart[i] != nntp_data->group[i]) ++ { ++ filepart[i] = 0; ++ break; ++ } ++ } ++ filepart[i] = 0; ++ } ++ else ++ { ++ strfcpy (filepart, nntp_data->group, sizeof (filepart)); ++ init = 1; ++ } ++ } ++ } ++ ++ strcpy (s, filepart); ++ return (init ? 0 : -1); ++ } ++#endif ++ ++#ifdef USE_IMAP + /* we can use '/' as a delimiter, imap_complete rewrites it */ + if (*s == '=' || *s == '+' || *s == '!') + { +diff -udprP mutt-1.5.23.orig/compose.c mutt-1.5.23/compose.c +--- mutt-1.5.23.orig/compose.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/compose.c 2014-03-13 12:48:36.000000000 +0200 +@@ -32,11 +32,16 @@ + #include "mailbox.h" + #include "sort.h" + #include "charset.h" ++#include "mx.h" + + #ifdef MIXMASTER + #include "remailer.h" + #endif + ++#ifdef USE_NNTP ++#include "nntp.h" ++#endif ++ + #include <errno.h> + #include <string.h> + #include <sys/stat.h> +@@ -67,11 +72,17 @@ enum + HDR_CRYPT, + HDR_CRYPTINFO, + ++#ifdef USE_NNTP ++ HDR_NEWSGROUPS, ++ HDR_FOLLOWUPTO, ++ HDR_XCOMMENTTO, ++#endif ++ + HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */ + }; + +-#define HDR_XOFFSET 10 +-#define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */ ++#define HDR_XOFFSET 14 ++#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */ + #define W (COLS - HDR_XOFFSET) + + static const char * const Prompts[] = +@@ -83,6 +94,16 @@ static const char * const Prompts[] = + "Subject: ", + "Reply-To: ", + "Fcc: " ++#ifdef USE_NNTP ++#ifdef MIXMASTER ++ ,"" ++#endif ++ ,"" ++ ,"" ++ ,"Newsgroups: " ++ ,"Followup-To: " ++ ,"X-Comment-To: " ++#endif + }; + + static const struct mapping_t ComposeHelp[] = { +@@ -97,6 +118,19 @@ static const struct mapping_t ComposeHel + { NULL, 0 } + }; + ++#ifdef USE_NNTP ++static struct mapping_t ComposeNewsHelp[] = { ++ { N_("Send"), OP_COMPOSE_SEND_MESSAGE }, ++ { N_("Abort"), OP_EXIT }, ++ { "Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS }, ++ { "Subj", OP_COMPOSE_EDIT_SUBJECT }, ++ { N_("Attach file"), OP_COMPOSE_ATTACH_FILE }, ++ { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION }, ++ { N_("Help"), OP_HELP }, ++ { NULL, 0 } ++}; ++#endif ++ + static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num) + { + mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt, +@@ -110,7 +144,7 @@ static void snd_entry (char *b, size_t b + + static void redraw_crypt_lines (HEADER *msg) + { +- mvaddstr (HDR_CRYPT, 0, "Security: "); ++ mvprintw (HDR_CRYPT, 0, TITLE_FMT, "Security: "); + + if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0) + { +@@ -148,10 +182,11 @@ static void redraw_crypt_lines (HEADER * + if ((WithCrypto & APPLICATION_PGP) + && (msg->security & APPLICATION_PGP) && (msg->security & SIGN)) + printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>")); ++ printw (TITLE_FMT "%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>")); + + if ((WithCrypto & APPLICATION_SMIME) + && (msg->security & APPLICATION_SMIME) && (msg->security & SIGN)) { +- printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>")); ++ printw (TITLE_FMT "%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>")); + } + + if ((WithCrypto & APPLICATION_SMIME) +@@ -172,7 +207,7 @@ static void redraw_mix_line (LIST *chain + int c; + char *t; + +- mvaddstr (HDR_MIX, 0, " Mix: "); ++ mvprintw (HDR_MIX, 0, TITLE_FMT, "Mix: "); + + if (!chain) + { +@@ -246,9 +281,28 @@ static void draw_envelope_addr (int line + static void draw_envelope (HEADER *msg, char *fcc) + { + draw_envelope_addr (HDR_FROM, msg->env->from); ++#ifdef USE_NNTP ++ if (!option (OPTNEWSSEND)) ++ { ++#endif + draw_envelope_addr (HDR_TO, msg->env->to); + draw_envelope_addr (HDR_CC, msg->env->cc); + draw_envelope_addr (HDR_BCC, msg->env->bcc); ++#ifdef USE_NNTP ++ } ++ else ++ { ++ mvprintw (HDR_TO, 0, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]); ++ mutt_paddstr (W, NONULL (msg->env->newsgroups)); ++ mvprintw (HDR_CC, 0, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]); ++ mutt_paddstr (W, NONULL (msg->env->followup_to)); ++ if (option (OPTXCOMMENTTO)) ++ { ++ mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]); ++ mutt_paddstr (W, NONULL (msg->env->x_comment_to)); ++ } ++ } ++#endif + mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); + mutt_paddstr (W, NONULL (msg->env->subject)); + draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); +@@ -499,6 +553,12 @@ int mutt_compose_menu (HEADER *msg, /* + /* Sort, SortAux could be changed in mutt_index_menu() */ + int oldSort, oldSortAux; + struct stat st; ++#ifdef USE_NNTP ++ int news = 0; /* is it a news article ? */ ++ ++ if (option (OPTNEWSSEND)) ++ news++; ++#endif + + mutt_attach_init (msg->content); + idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1); +@@ -509,10 +569,18 @@ int mutt_compose_menu (HEADER *msg, /* + menu->make_entry = snd_entry; + menu->tag = mutt_tag_attach; + menu->data = idx; ++#ifdef USE_NNTP ++ if (news) ++ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp); ++ else ++#endif + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp); + + while (loop) + { ++#ifdef USE_NNTP ++ unset_option (OPTNEWS); /* for any case */ ++#endif + switch (op = mutt_menuLoop (menu)) + { + case OP_REDRAW: +@@ -525,17 +593,90 @@ int mutt_compose_menu (HEADER *msg, /* + mutt_message_hook (NULL, msg, M_SEND2HOOK); + break; + case OP_COMPOSE_EDIT_TO: ++#ifdef USE_NNTP ++ if (news) ++ break; ++#endif + menu->redraw = edit_address_list (HDR_TO, &msg->env->to); + mutt_message_hook (NULL, msg, M_SEND2HOOK); + break; + case OP_COMPOSE_EDIT_BCC: ++#ifdef USE_NNTP ++ if (news) ++ break; ++#endif + menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc); + mutt_message_hook (NULL, msg, M_SEND2HOOK); + break; + case OP_COMPOSE_EDIT_CC: ++#ifdef USE_NNTP ++ if (news) ++ break; ++#endif + menu->redraw = edit_address_list (HDR_CC, &msg->env->cc); + mutt_message_hook (NULL, msg, M_SEND2HOOK); + break; ++#ifdef USE_NNTP ++ case OP_COMPOSE_EDIT_NEWSGROUPS: ++ if (news) ++ { ++ if (msg->env->newsgroups) ++ strfcpy (buf, msg->env->newsgroups, sizeof (buf)); ++ else ++ buf[0] = 0; ++ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && ++ buf[0]) ++ { ++ FREE (&msg->env->newsgroups); ++ mutt_remove_trailing_ws (buf); ++ msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf)); ++ move (HDR_TO, HDR_XOFFSET); ++ clrtoeol (); ++ if (msg->env->newsgroups) ++ printw ("%-*.*s", W, W, msg->env->newsgroups); ++ } ++ } ++ break; ++ ++ case OP_COMPOSE_EDIT_FOLLOWUP_TO: ++ if (news) ++ { ++ buf[0] = 0; ++ if (msg->env->followup_to) ++ strfcpy (buf, msg->env->followup_to, sizeof (buf)); ++ if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && ++ buf[0]) ++ { ++ FREE (&msg->env->followup_to); ++ mutt_remove_trailing_ws (buf); ++ msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf)); ++ move (HDR_CC, HDR_XOFFSET); ++ clrtoeol (); ++ if (msg->env->followup_to) ++ printw ("%-*.*s", W, W, msg->env->followup_to); ++ } ++ } ++ break; ++ ++ case OP_COMPOSE_EDIT_X_COMMENT_TO: ++ if (news && option (OPTXCOMMENTTO)) ++ { ++ buf[0] = 0; ++ if (msg->env->x_comment_to) ++ strfcpy (buf, msg->env->x_comment_to, sizeof (buf)); ++ if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && ++ buf[0]) ++ { ++ FREE (&msg->env->x_comment_to); ++ msg->env->x_comment_to = safe_strdup (buf); ++ move (HDR_BCC, HDR_XOFFSET); ++ clrtoeol (); ++ if (msg->env->x_comment_to) ++ printw ("%-*.*s", W, W, msg->env->x_comment_to); ++ } ++ } ++ break; ++#endif + case OP_COMPOSE_EDIT_SUBJECT: + if (msg->env->subject) + strfcpy (buf, msg->env->subject, sizeof (buf)); +@@ -699,6 +840,9 @@ int mutt_compose_menu (HEADER *msg, /* + break; + + case OP_COMPOSE_ATTACH_MESSAGE: ++#ifdef USE_NNTP ++ case OP_COMPOSE_ATTACH_NEWS_MESSAGE: ++#endif + { + char *prompt; + HEADER *h; +@@ -706,7 +850,22 @@ int mutt_compose_menu (HEADER *msg, /* + fname[0] = 0; + prompt = _("Open mailbox to attach message from"); + ++#ifdef USE_NNTP ++ unset_option (OPTNEWS); ++ if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE) ++ { ++ if (!(CurrentNewsSrv = nntp_select_server (NewsServer, 0))) ++ break; ++ ++ prompt = _("Open newsgroup to attach message from"); ++ set_option (OPTNEWS); ++ } ++#endif ++ + if (Context) ++#ifdef USE_NNTP ++ if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP)) ++#endif + { + strfcpy (fname, NONULL (Context->path), sizeof (fname)); + mutt_pretty_mailbox (fname, sizeof (fname)); +@@ -715,6 +874,11 @@ int mutt_compose_menu (HEADER *msg, /* + if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0]) + break; + ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account); ++ else ++#endif + mutt_expand_path (fname, sizeof (fname)); + #ifdef USE_IMAP + if (!mx_is_imap (fname)) +@@ -722,6 +886,9 @@ int mutt_compose_menu (HEADER *msg, /* + #ifdef USE_POP + if (!mx_is_pop (fname)) + #endif ++#ifdef USE_NNTP ++ if (!mx_is_nntp (fname) && !option (OPTNEWS)) ++#endif + /* check to make sure the file exists and is readable */ + if (access (fname, R_OK) == -1) + { +diff -udprP mutt-1.5.23.orig/config.h.in mutt-1.5.23/config.h.in +--- mutt-1.5.23.orig/config.h.in 2014-03-12 18:27:54.000000000 +0200 ++++ mutt-1.5.23/config.h.in 2014-03-13 12:48:36.000000000 +0200 +@@ -574,6 +574,9 @@ + /* Define if you want support for the IMAP protocol. */ + #undef USE_IMAP + ++/* Define if you want support for the NNTP protocol. */ ++#undef USE_NNTP ++ + /* Define if you want support for the POP3 protocol. */ + #undef USE_POP + +diff -udprP mutt-1.5.23.orig/configure.ac mutt-1.5.23/configure.ac +--- mutt-1.5.23.orig/configure.ac 2014-03-12 18:26:40.000000000 +0200 ++++ mutt-1.5.23/configure.ac 2014-03-13 12:48:36.000000000 +0200 +@@ -592,6 +592,15 @@ AC_ARG_ENABLE(imap, AS_HELP_STRING([--en + ]) + AM_CONDITIONAL(BUILD_IMAP, test x$need_imap = xyes) + ++AC_ARG_ENABLE(nntp, AC_HELP_STRING([--enable-nntp],[Enable NNTP support]), ++[ if test x$enableval = xyes ; then ++ AC_DEFINE(USE_NNTP,1,[ Define if you want support for the NNTP protocol. ]) ++ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o" ++ need_nntp="yes" ++ need_socket="yes" ++ fi ++]) ++ + AC_ARG_ENABLE(smtp, AS_HELP_STRING([--enable-smtp],[include internal SMTP relay support]), + [if test $enableval = yes; then + AC_DEFINE(USE_SMTP, 1, [Include internal SMTP relay support]) +@@ -599,7 +608,7 @@ AC_ARG_ENABLE(smtp, AS_HELP_STRING([--en + need_socket="yes" + fi]) + +-if test x"$need_imap" = xyes -o x"$need_pop" = xyes ; then ++if test x"$need_imap" = xyes -o x"$need_pop" = xyes -o x"$need_nntp" = xyes ; then + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o" + fi + +diff -udprP mutt-1.5.23.orig/curs_main.c mutt-1.5.23/curs_main.c +--- mutt-1.5.23.orig/curs_main.c 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23/curs_main.c 2014-03-13 12:48:36.000000000 +0200 +@@ -22,6 +22,7 @@ + + #include "mutt.h" + #include "mutt_curses.h" ++#include "mx.h" + #include "mutt_menu.h" + #include "mailbox.h" + #include "mapping.h" +@@ -38,6 +39,10 @@ + + #include "mutt_crypt.h" + ++#ifdef USE_NNTP ++#include "nntp.h" ++#endif ++ + + #include <ctype.h> + #include <stdlib.h> +@@ -413,12 +418,27 @@ static const struct mapping_t IndexHelp[ + { NULL, 0 } + }; + ++#ifdef USE_NNTP ++struct mapping_t IndexNewsHelp[] = { ++ { N_("Quit"), OP_QUIT }, ++ { N_("Del"), OP_DELETE }, ++ { N_("Undel"), OP_UNDELETE }, ++ { N_("Save"), OP_SAVE }, ++ { N_("Post"), OP_POST }, ++ { N_("Followup"), OP_FOLLOWUP }, ++ { N_("Catchup"), OP_CATCHUP }, ++ { N_("Help"), OP_HELP }, ++ { NULL, 0 } ++}; ++#endif ++ + /* This function handles the message index window as well as commands returned + * from the pager (MENU_PAGER). + */ + int mutt_index_menu (void) + { + char buf[LONG_STRING], helpstr[LONG_STRING]; ++ int flags; + int op = OP_NULL; + int done = 0; /* controls when to exit the "event" loop */ + int i = 0, j; +@@ -439,7 +459,11 @@ int mutt_index_menu (void) + menu->make_entry = index_make_entry; + menu->color = index_color; + menu->current = ci_first_message (); +- menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp); ++ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, ++#ifdef USE_NNTP ++ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : ++#endif ++ IndexHelp); + + if (!attach_msg) + mutt_buffy_check(1); /* force the buffy check after we enter the folder */ +@@ -680,6 +704,9 @@ int mutt_index_menu (void) + mutt_curs_set (1); /* fallback from the pager */ + } + ++#ifdef USE_NNTP ++ unset_option (OPTNEWS); /* for any case */ ++#endif + switch (op) + { + +@@ -730,6 +757,161 @@ int mutt_index_menu (void) + menu_current_bottom (menu); + break; + ++#ifdef USE_NNTP ++ case OP_GET_PARENT: ++ CHECK_MSGCOUNT; ++ CHECK_VISIBLE; ++ ++ case OP_GET_MESSAGE: ++ CHECK_IN_MAILBOX; ++ CHECK_READONLY; ++ CHECK_ATTACH; ++ if (Context->magic == M_NNTP) ++ { ++ HEADER *hdr; ++ ++ if (op == OP_GET_MESSAGE) ++ { ++ buf[0] = 0; ++ if (mutt_get_field (_("Enter Message-Id: "), ++ buf, sizeof (buf), 0) != 0 || !buf[0]) ++ break; ++ } ++ else ++ { ++ LIST *ref = CURHDR->env->references; ++ if (!ref) ++ { ++ mutt_error _("Article has no parent reference."); ++ break; ++ } ++ strfcpy (buf, ref->data, sizeof (buf)); ++ } ++ if (!Context->id_hash) ++ Context->id_hash = mutt_make_id_hash (Context); ++ hdr = hash_find (Context->id_hash, buf); ++ if (hdr) ++ { ++ if (hdr->virtual != -1) ++ { ++ menu->current = hdr->virtual; ++ menu->redraw = REDRAW_MOTION_RESYNCH; ++ } ++ else if (hdr->collapsed) ++ { ++ mutt_uncollapse_thread (Context, hdr); ++ mutt_set_virtual (Context); ++ menu->current = hdr->virtual; ++ menu->redraw = REDRAW_MOTION_RESYNCH; ++ } ++ else ++ mutt_error _("Message is not visible in limited view."); ++ } ++ else ++ { ++ int rc; ++ ++ mutt_message (_("Fetching %s from server..."), buf); ++ rc = nntp_check_msgid (Context, buf); ++ if (rc == 0) ++ { ++ hdr = Context->hdrs[Context->msgcount - 1]; ++ mutt_sort_headers (Context, 0); ++ menu->current = hdr->virtual; ++ menu->redraw = REDRAW_FULL; ++ } ++ else if (rc > 0) ++ mutt_error (_("Article %s not found on the server."), buf); ++ } ++ } ++ break; ++ ++ case OP_GET_CHILDREN: ++ case OP_RECONSTRUCT_THREAD: ++ CHECK_MSGCOUNT; ++ CHECK_VISIBLE; ++ CHECK_READONLY; ++ CHECK_ATTACH; ++ if (Context->magic == M_NNTP) ++ { ++ int oldmsgcount = Context->msgcount; ++ int oldindex = CURHDR->index; ++ int rc = 0; ++ ++ if (!CURHDR->env->message_id) ++ { ++ mutt_error _("No Message-Id. Unable to perform operation."); ++ break; ++ } ++ ++ mutt_message _("Fetching message headers..."); ++ if (!Context->id_hash) ++ Context->id_hash = mutt_make_id_hash (Context); ++ strfcpy (buf, CURHDR->env->message_id, sizeof (buf)); ++ ++ /* trying to find msgid of the root message */ ++ if (op == OP_RECONSTRUCT_THREAD) ++ { ++ LIST *ref = CURHDR->env->references; ++ while (ref) ++ { ++ if (hash_find (Context->id_hash, ref->data) == NULL) ++ { ++ rc = nntp_check_msgid (Context, ref->data); ++ if (rc < 0) ++ break; ++ } ++ ++ /* the last msgid in References is the root message */ ++ if (!ref->next) ++ strfcpy (buf, ref->data, sizeof (buf)); ++ ref = ref->next; ++ } ++ } ++ ++ /* fetching all child messages */ ++ if (rc >= 0) ++ rc = nntp_check_children (Context, buf); ++ ++ /* at least one message has been loaded */ ++ if (Context->msgcount > oldmsgcount) ++ { ++ HEADER *hdr; ++ int i, quiet = Context->quiet; ++ ++ if (rc < 0) ++ Context->quiet = 1; ++ mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD)); ++ Context->quiet = quiet; ++ ++ /* if the root message was retrieved, move to it */ ++ hdr = hash_find (Context->id_hash, buf); ++ if (hdr) ++ menu->current = hdr->virtual; ++ ++ /* try to restore old position */ ++ else ++ { ++ for (i = 0; i < Context->msgcount; i++) ++ { ++ if (Context->hdrs[i]->index == oldindex) ++ { ++ menu->current = Context->hdrs[i]->virtual; ++ /* as an added courtesy, recenter the menu ++ * with the current entry at the middle of the screen */ ++ menu_check_recenter (menu); ++ menu_current_middle (menu); ++ } ++ } ++ } ++ menu->redraw = REDRAW_FULL; ++ } ++ else if (rc >= 0) ++ mutt_error _("No deleted messages found in the thread."); ++ } ++ break; ++#endif ++ + case OP_JUMP: + + CHECK_MSGCOUNT; +@@ -826,11 +1008,33 @@ int mutt_index_menu (void) + break; + + case OP_MAIN_LIMIT: ++ case OP_TOGGLE_READ: + + CHECK_IN_MAILBOX; + menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ? + CURHDR->index : -1; +- if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0) ++ if (op == OP_TOGGLE_READ) ++ { ++ char buf[LONG_STRING]; ++ ++ if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0) ++ { ++ snprintf (buf, sizeof (buf), "!~R!~D~s%s", ++ Context->pattern ? Context->pattern : ".*"); ++ set_option (OPTHIDEREAD); ++ } ++ else ++ { ++ strfcpy (buf, Context->pattern + 8, sizeof(buf)); ++ if (!*buf || strncmp (buf, ".*", 2) == 0) ++ snprintf (buf, sizeof(buf), "~A"); ++ unset_option (OPTHIDEREAD); ++ } ++ FREE (&Context->pattern); ++ Context->pattern = safe_strdup (buf); ++ } ++ if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) || ++ mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0) + { + if (menu->oldcurrent >= 0) + { +@@ -1072,15 +1276,22 @@ int mutt_index_menu (void) + + case OP_MAIN_CHANGE_FOLDER: + case OP_MAIN_NEXT_UNREAD_MAILBOX: +- +- if (attach_msg) +- op = OP_MAIN_CHANGE_FOLDER_READONLY; +- +- /* fallback to the readonly case */ +- + case OP_MAIN_CHANGE_FOLDER_READONLY: ++#ifdef USE_NNTP ++ case OP_MAIN_CHANGE_GROUP: ++ case OP_MAIN_CHANGE_GROUP_READONLY: ++ unset_option (OPTNEWS); ++#endif ++ if (attach_msg || option (OPTREADONLY) || ++#ifdef USE_NNTP ++ op == OP_MAIN_CHANGE_GROUP_READONLY || ++#endif ++ op == OP_MAIN_CHANGE_FOLDER_READONLY) ++ flags = M_READONLY; ++ else ++ flags = 0; + +- if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY)) ++ if (flags) + cp = _("Open mailbox in read-only mode"); + else + cp = _("Open mailbox"); +@@ -1099,6 +1310,22 @@ int mutt_index_menu (void) + } + else + { ++#ifdef USE_NNTP ++ if (op == OP_MAIN_CHANGE_GROUP || ++ op == OP_MAIN_CHANGE_GROUP_READONLY) ++ { ++ set_option (OPTNEWS); ++ CurrentNewsSrv = nntp_select_server (NewsServer, 0); ++ if (!CurrentNewsSrv) ++ break; ++ if (flags) ++ cp = _("Open newsgroup in read-only mode"); ++ else ++ cp = _("Open newsgroup"); ++ nntp_buffy (buf, sizeof (buf)); ++ } ++ else ++#endif + mutt_buffy (buf, sizeof (buf)); + + if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) +@@ -1118,6 +1345,14 @@ int mutt_index_menu (void) + } + } + ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ { ++ unset_option (OPTNEWS); ++ nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account); ++ } ++ else ++#endif + mutt_expand_path (buf, sizeof (buf)); + if (mx_get_magic (buf) <= 0) + { +@@ -1159,15 +1394,18 @@ int mutt_index_menu (void) + CurrentMenu = MENU_MAIN; + mutt_folder_hook (buf); + +- if ((Context = mx_open_mailbox (buf, +- (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ? +- M_READONLY : 0, NULL)) != NULL) ++ if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL) + { + menu->current = ci_first_message (); + } + else + menu->current = 0; + ++#ifdef USE_NNTP ++ /* mutt_buffy_check() must be done with mail-reader mode! */ ++ menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, ++ (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp); ++#endif + mutt_clear_error (); + mutt_buffy_check(1); /* force the buffy check after we have changed + the folder */ +@@ -1236,6 +1474,7 @@ int mutt_index_menu (void) + CHECK_MSGCOUNT; + CHECK_VISIBLE; + CHECK_READONLY; ++ CHECK_ACL(M_ACL_WRITE, _("break thread")); + + if ((Sort & SORT_MASK) != SORT_THREADS) + mutt_error _("Threading is not enabled."); +@@ -1270,7 +1509,7 @@ int mutt_index_menu (void) + CHECK_MSGCOUNT; + CHECK_VISIBLE; + CHECK_READONLY; +- CHECK_ACL(M_ACL_DELETE, _("link threads")); ++ CHECK_ACL(M_ACL_WRITE, _("link threads")); + + if ((Sort & SORT_MASK) != SORT_THREADS) + mutt_error _("Threading is not enabled."); +@@ -1887,6 +2126,20 @@ int mutt_index_menu (void) + } + break; + ++#ifdef USE_NNTP ++ case OP_CATCHUP: ++ CHECK_MSGCOUNT; ++ CHECK_READONLY; ++ CHECK_ATTACH ++ if (Context && Context->magic == M_NNTP) ++ { ++ NNTP_DATA *nntp_data = Context->data; ++ if (mutt_newsgroup_catchup (nntp_data->nserv, nntp_data->group)) ++ menu->redraw = REDRAW_INDEX | REDRAW_STATUS; ++ } ++ break; ++#endif ++ + case OP_DISPLAY_ADDRESS: + + CHECK_MSGCOUNT; +@@ -2091,6 +2344,39 @@ int mutt_index_menu (void) + menu->redraw = REDRAW_FULL; + break; + ++#ifdef USE_NNTP ++ case OP_FOLLOWUP: ++ case OP_FORWARD_TO_GROUP: ++ ++ CHECK_MSGCOUNT; ++ CHECK_VISIBLE; ++ ++ case OP_POST: ++ ++ CHECK_ATTACH; ++ if (op != OP_FOLLOWUP || !CURHDR->env->followup_to || ++ mutt_strcasecmp (CURHDR->env->followup_to, "poster") || ++ query_quadoption (OPT_FOLLOWUPTOPOSTER, ++ _("Reply by mail as poster prefers?")) != M_YES) ++ { ++ if (Context && Context->magic == M_NNTP && ++ !((NNTP_DATA *)Context->data)->allowed && ++ query_quadoption (OPT_TOMODERATED, ++ _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) ++ break; ++ if (op == OP_POST) ++ ci_send_message (SENDNEWS, NULL, NULL, Context, NULL); ++ else ++ { ++ CHECK_MSGCOUNT; ++ ci_send_message ((op == OP_FOLLOWUP ? SENDREPLY : SENDFORWARD) | ++ SENDNEWS, NULL, NULL, Context, tag ? NULL : CURHDR); ++ } ++ menu->redraw = REDRAW_FULL; ++ break; ++ } ++#endif ++ + case OP_REPLY: + + CHECK_ATTACH; +diff -udprP mutt-1.5.23.orig/doc/manual.xml.head mutt-1.5.23/doc/manual.xml.head +--- mutt-1.5.23.orig/doc/manual.xml.head 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/doc/manual.xml.head 2014-03-13 12:48:36.000000000 +0200 +@@ -1694,6 +1694,26 @@ See also the <link linkend="postpone">$p + + </sect1> + ++<sect1 id="nntp"> ++<title>Reading news via NNTP</title> ++ ++<para> ++If compiled with <emphasis>--enable-nntp</emphasis> option, Mutt can ++read news from news server via NNTP. You can open a newsgroup with ++function ``change-newsgroup'' (default: ``i''). Default news server ++can be obtained from <literal>$NNTPSERVER</literal> environment ++variable or from <literal>/etc/nntpserver</literal> file. Like other ++news readers, info about subscribed newsgroups is saved in file by ++<link linkend="newsrc">$newsrc</link> variable. The variable <link ++linkend="news-cache-dir">$news_cache_dir</link> can be used to point ++to a directory. Mutt will create a hierarchy of subdirectories named ++like the account and newsgroup the cache is for. Also the hierarchy ++is used to store header cache if Mutt was compiled with <link ++linkend="header-caching">header cache</link> support. ++</para> ++ ++</sect1> ++ + </chapter> + + <chapter id="configuration"> +diff -udprP mutt-1.5.23.orig/doc/mutt.man mutt-1.5.23/doc/mutt.man +--- mutt-1.5.23.orig/doc/mutt.man 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/doc/mutt.man 2014-03-13 12:48:36.000000000 +0200 +@@ -23,8 +23,8 @@ mutt \- The Mutt Mail User Agent + .SH SYNOPSIS + .PP + .B mutt +-[\-nRyzZ] +-[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-m \fItype\fP] [\-f \fIfile\fP] ++[\-GnRyzZ] ++[\-e \fIcmd\fP] [\-F \fIfile\fP] [\-g \fIserver\fP] [\-m \fItype\fP] [\-f \fIfile\fP] + .PP + .B mutt + [\-nx] +@@ -101,6 +101,10 @@ files. + Specify which mailbox to load. + .IP "-F \fImuttrc\fP" + Specify an initialization file to read instead of ~/.muttrc ++.IP "-g \fIserver\fP" ++Start Mutt with a listing of subscribed newsgroups at specified news server. ++.IP "-G" ++Start Mutt with a listing of subscribed newsgroups. + .IP "-h" + Display help. + .IP "-H \fIdraft\fP" +diff -udprP mutt-1.5.23.orig/functions.h mutt-1.5.23/functions.h +--- mutt-1.5.23.orig/functions.h 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/functions.h 2014-03-13 12:48:36.000000000 +0200 +@@ -88,6 +88,10 @@ const struct binding_t OpMain[] = { /* m + { "break-thread", OP_MAIN_BREAK_THREAD, "#" }, + { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" }, + { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" }, ++#ifdef USE_NNTP ++ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" }, ++ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" }, ++#endif + { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL }, + { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" }, + { "collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V" }, +@@ -101,7 +105,15 @@ const struct binding_t OpMain[] = { /* m + { "edit", OP_EDIT_MESSAGE, "e" }, + { "edit-type", OP_EDIT_TYPE, "\005" }, + { "forward-message", OP_FORWARD_MESSAGE, "f" }, +- { "flag-message", OP_FLAG_MESSAGE, "F" }, ++#ifdef USE_NNTP ++ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" }, ++ { "followup-message", OP_FOLLOWUP, "F" }, ++ { "get-children", OP_GET_CHILDREN, NULL }, ++ { "get-message", OP_GET_MESSAGE, "\007" }, ++ { "get-parent", OP_GET_PARENT, "\033G" }, ++ { "reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL }, ++#endif ++ { "flag-message", OP_FLAG_MESSAGE, "\033f" }, + { "group-reply", OP_GROUP_REPLY, "g" }, + #ifdef USE_POP + { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" }, +@@ -128,6 +140,9 @@ const struct binding_t OpMain[] = { /* m + { "sort-mailbox", OP_SORT, "o" }, + { "sort-reverse", OP_SORT_REVERSE, "O" }, + { "print-message", OP_PRINT, "p" }, ++#ifdef USE_NNTP ++ { "post-message", OP_POST, "P" }, ++#endif + { "previous-thread", OP_MAIN_PREV_THREAD, "\020" }, + { "previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p" }, + { "recall-message", OP_RECALL_MESSAGE, "R" }, +@@ -147,6 +162,10 @@ const struct binding_t OpMain[] = { /* m + { "show-version", OP_VERSION, "V" }, + { "set-flag", OP_MAIN_SET_FLAG, "w" }, + { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" }, ++ { "toggle-read", OP_TOGGLE_READ, "X" }, ++#ifdef USE_NNTP ++ { "catchup", OP_CATCHUP, "y" }, ++#endif + { "display-message", OP_DISPLAY_MESSAGE, M_ENTER_S }, + { "buffy-list", OP_BUFFY_LIST, "." }, + { "sync-mailbox", OP_MAIN_SYNC_FOLDER, "$" }, +@@ -158,7 +177,7 @@ const struct binding_t OpMain[] = { /* m + { "previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t" }, + { "next-unread", OP_MAIN_NEXT_UNREAD, NULL }, + { "previous-unread", OP_MAIN_PREV_UNREAD, NULL }, +- { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" }, ++ { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL }, + + + { "extract-keys", OP_EXTRACT_KEYS, "\013" }, +@@ -178,6 +197,10 @@ const struct binding_t OpPager[] = { /* + { "bounce-message", OP_BOUNCE_MESSAGE, "b" }, + { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" }, + { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" }, ++#ifdef USE_NNTP ++ { "change-newsgroup", OP_MAIN_CHANGE_GROUP, "i" }, ++ { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" }, ++#endif + { "next-unread-mailbox", OP_MAIN_NEXT_UNREAD_MAILBOX, NULL }, + { "copy-message", OP_COPY_MESSAGE, "C" }, + { "decode-copy", OP_DECODE_COPY, "\033C" }, +@@ -188,8 +211,12 @@ const struct binding_t OpPager[] = { /* + { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" }, + { "edit", OP_EDIT_MESSAGE, "e" }, + { "edit-type", OP_EDIT_TYPE, "\005" }, ++#ifdef USE_NNTP ++ { "followup-message", OP_FOLLOWUP, "F" }, ++ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" }, ++#endif + { "forward-message", OP_FORWARD_MESSAGE, "f" }, +- { "flag-message", OP_FLAG_MESSAGE, "F" }, ++ { "flag-message", OP_FLAG_MESSAGE, "\033f" }, + { "group-reply", OP_GROUP_REPLY, "g" }, + #ifdef USE_IMAP + { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL }, +@@ -211,6 +238,9 @@ const struct binding_t OpPager[] = { /* + { "sort-mailbox", OP_SORT, "o" }, + { "sort-reverse", OP_SORT_REVERSE, "O" }, + { "print-message", OP_PRINT, "p" }, ++#ifdef USE_NNTP ++ { "post-message", OP_POST, "P" }, ++#endif + { "previous-thread", OP_MAIN_PREV_THREAD, "\020" }, + { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" }, + { "quit", OP_QUIT, "Q" }, +@@ -258,7 +288,7 @@ const struct binding_t OpPager[] = { /* + { "half-down", OP_HALF_DOWN, NULL }, + { "previous-line", OP_PREV_LINE, NULL }, + { "bottom", OP_PAGER_BOTTOM, NULL }, +- { "parent-message", OP_MAIN_PARENT_MESSAGE, "P" }, ++ { "parent-message", OP_MAIN_PARENT_MESSAGE, NULL }, + + + +@@ -279,6 +309,10 @@ const struct binding_t OpAttach[] = { /* + { "bounce-message", OP_BOUNCE_MESSAGE, "b" }, + { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" }, + { "edit-type", OP_EDIT_TYPE, "\005" }, ++#ifdef USE_NNTP ++ { "followup-message", OP_FOLLOWUP, "F" }, ++ { "forward-to-group", OP_FORWARD_TO_GROUP, "\033F" }, ++#endif + { "print-entry", OP_PRINT, "p" }, + { "save-entry", OP_SAVE, "s" }, + { "pipe-entry", OP_PIPE, "|" }, +@@ -304,6 +338,7 @@ const struct binding_t OpAttach[] = { /* + const struct binding_t OpCompose[] = { /* map: compose */ + { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" }, + { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" }, ++ { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" }, + { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" }, + { "edit-cc", OP_COMPOSE_EDIT_CC, "c" }, + { "copy-file", OP_SAVE, "C" }, +@@ -323,6 +358,11 @@ const struct binding_t OpCompose[] = { / + { "print-entry", OP_PRINT, "l" }, + { "edit-mime", OP_COMPOSE_EDIT_MIME, "m" }, + { "new-mime", OP_COMPOSE_NEW_MIME, "n" }, ++#ifdef USE_NNTP ++ { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N" }, ++ { "edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o" }, ++ { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO, "x" }, ++#endif + { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" }, + { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" }, + { "rename-file", OP_COMPOSE_RENAME_FILE, "R" }, +@@ -374,14 +414,25 @@ const struct binding_t OpBrowser[] = { / + { "select-new", OP_BROWSER_NEW_FILE, "N" }, + { "check-new", OP_CHECK_NEW, NULL }, + { "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" }, ++#ifdef USE_NNTP ++ { "reload-active", OP_LOAD_ACTIVE, "g" }, ++ { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" }, ++ { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" }, ++ { "catchup", OP_CATCHUP, "y" }, ++ { "uncatchup", OP_UNCATCHUP, "Y" }, ++#endif + { "view-file", OP_BROWSER_VIEW_FILE, " " }, + { "buffy-list", OP_BUFFY_LIST, "." }, + #ifdef USE_IMAP + { "create-mailbox", OP_CREATE_MAILBOX, "C" }, + { "delete-mailbox", OP_DELETE_MAILBOX, "d" }, + { "rename-mailbox", OP_RENAME_MAILBOX, "r" }, ++#endif ++#if defined USE_IMAP || defined USE_NNTP + { "subscribe", OP_BROWSER_SUBSCRIBE, "s" }, + { "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" }, ++#endif ++#ifdef USE_IMAP + { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" }, + #endif + { NULL, 0, NULL } +diff -udprP mutt-1.5.23.orig/globals.h mutt-1.5.23/globals.h +--- mutt-1.5.23.orig/globals.h 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23/globals.h 2014-03-13 12:48:36.000000000 +0200 +@@ -95,6 +95,17 @@ WHERE char *MixEntryFormat; + #endif + + WHERE char *Muttrc INITVAL (NULL); ++#ifdef USE_NNTP ++WHERE char *GroupFormat; ++WHERE char *Inews; ++WHERE char *NewsCacheDir; ++WHERE char *NewsServer; ++WHERE char *NewsgroupsCharset; ++WHERE char *NewsRc; ++WHERE char *NntpAuthenticators; ++WHERE char *NntpUser; ++WHERE char *NntpPass; ++#endif + WHERE char *Outbox; + WHERE char *Pager; + WHERE char *PagerFmt; +@@ -188,6 +199,11 @@ extern unsigned char QuadOptions[]; + + WHERE unsigned short Counter INITVAL (0); + ++#ifdef USE_NNTP ++WHERE short NewsPollTimeout; ++WHERE short NntpContext; ++#endif ++ + WHERE short ConnectTimeout; + WHERE short HistSize; + WHERE short MenuContext; +diff -udprP mutt-1.5.23.orig/hash.c mutt-1.5.23/hash.c +--- mutt-1.5.23.orig/hash.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/hash.c 2014-03-13 12:48:36.000000000 +0200 +@@ -57,6 +57,7 @@ HASH *hash_create (int nelem, int lower) + if (nelem == 0) + nelem = 2; + table->nelem = nelem; ++ table->curnelem = 0; + table->table = safe_calloc (nelem, sizeof (struct hash_elem *)); + if (lower) + { +@@ -71,6 +72,29 @@ HASH *hash_create (int nelem, int lower) + return table; + } + ++HASH *hash_resize (HASH *ptr, int nelem, int lower) ++{ ++ HASH *table; ++ struct hash_elem *elem, *tmp; ++ int i; ++ ++ table = hash_create (nelem, lower); ++ ++ for (i = 0; i < ptr->nelem; i++) ++ { ++ for (elem = ptr->table[i]; elem; ) ++ { ++ tmp = elem; ++ elem = elem->next; ++ hash_insert (table, tmp->key, tmp->data, 1); ++ FREE (&tmp); ++ } ++ } ++ FREE (&ptr->table); ++ FREE (&ptr); ++ return table; ++} ++ + /* table hash table to update + * key key to hash on + * data data to associate with `key' +@@ -90,6 +114,7 @@ int hash_insert (HASH * table, const cha + { + ptr->next = table->table[h]; + table->table[h] = ptr; ++ table->curnelem++; + } + else + { +@@ -112,6 +137,7 @@ int hash_insert (HASH * table, const cha + else + table->table[h] = ptr; + ptr->next = tmp; ++ table->curnelem++; + } + return h; + } +@@ -142,6 +168,7 @@ void hash_delete_hash (HASH * table, int + if (destroy) + destroy (ptr->data); + FREE (&ptr); ++ table->curnelem--; + + ptr = *last; + } +diff -udprP mutt-1.5.23.orig/hash.h mutt-1.5.23/hash.h +--- mutt-1.5.23.orig/hash.h 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/hash.h 2014-03-13 12:48:36.000000000 +0200 +@@ -28,7 +28,7 @@ struct hash_elem + + typedef struct + { +- int nelem; ++ int nelem, curnelem; + struct hash_elem **table; + unsigned int (*hash_string)(const unsigned char *, unsigned int); + int (*cmp_string)(const char *, const char *); +@@ -41,6 +41,7 @@ HASH; + + HASH *hash_create (int nelem, int lower); + int hash_insert (HASH * table, const char *key, void *data, int allow_dup); ++HASH *hash_resize (HASH * table, int nelem, int lower); + void *hash_find_hash (const HASH * table, int hash, const char *key); + void hash_delete_hash (HASH * table, int hash, const char *key, const void *data, + void (*destroy) (void *)); +diff -udprP mutt-1.5.23.orig/hcache.c mutt-1.5.23/hcache.c +--- mutt-1.5.23.orig/hcache.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/hcache.c 2014-03-13 12:48:36.000000000 +0200 +@@ -447,6 +447,12 @@ dump_envelope(ENVELOPE * e, unsigned cha + d = dump_list(e->in_reply_to, d, off, 0); + d = dump_list(e->userhdrs, d, off, convert); + ++#ifdef USE_NNTP ++ d = dump_char(e->xref, d, off, 0); ++ d = dump_char(e->followup_to, d, off, 0); ++ d = dump_char(e->x_comment_to, d, off, convert); ++#endif ++ + return d; + } + +@@ -483,6 +489,12 @@ restore_envelope(ENVELOPE * e, const uns + restore_list(&e->references, d, off, 0); + restore_list(&e->in_reply_to, d, off, 0); + restore_list(&e->userhdrs, d, off, convert); ++ ++#ifdef USE_NNTP ++ restore_char(&e->xref, d, off, 0); ++ restore_char(&e->followup_to, d, off, 0); ++ restore_char(&e->x_comment_to, d, off, convert); ++#endif + } + + static int +diff -udprP mutt-1.5.23.orig/hdrline.c mutt-1.5.23/hdrline.c +--- mutt-1.5.23.orig/hdrline.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/hdrline.c 2014-03-13 12:48:36.000000000 +0200 +@@ -211,6 +211,7 @@ int mutt_user_is_recipient (HEADER *h) + * %E = number of messages in current thread + * %f = entire from line + * %F = like %n, unless from self ++ * %g = newsgroup name (if compiled with NNTP support) + * %i = message-id + * %l = number of lines in the message + * %L = like %F, except `lists' are displayed first +@@ -219,12 +220,14 @@ int mutt_user_is_recipient (HEADER *h) + * %N = score + * %O = like %L, except using address instead of name + * %P = progress indicator for builtin pager ++ * %R = `x-comment-to:' field (if present and compiled with NNTP support) + * %s = subject + * %S = short message status (e.g., N/O/D/!/r/-) + * %t = `to:' field (recipients) + * %T = $to_chars + * %u = user (login) name of author + * %v = first name of author, unless from self ++ * %W = where user is (organization) + * %X = number of MIME attachments + * %y = `x-label:' field (if present) + * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label) +@@ -457,6 +460,12 @@ hdr_format_str (char *dest, + + break; + ++#ifdef USE_NNTP ++ case 'g': ++ mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : ""); ++ break; ++#endif ++ + case 'i': + mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>"); + break; +@@ -548,6 +557,15 @@ hdr_format_str (char *dest, + strfcpy(dest, NONULL(hfi->pager_progress), destlen); + break; + ++#ifdef USE_NNTP ++ case 'R': ++ if (!optional) ++ mutt_format_s (dest, destlen, prefix, hdr->env->x_comment_to ? hdr->env->x_comment_to : ""); ++ else if (!hdr->env->x_comment_to) ++ optional = 0; ++ break; ++#endif ++ + case 's': + + if (flags & M_FORMAT_TREE && !hdr->collapsed) +@@ -637,6 +655,13 @@ hdr_format_str (char *dest, + mutt_format_s (dest, destlen, prefix, buf2); + break; + ++ case 'W': ++ if (!optional) ++ mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : ""); ++ else if (!hdr->env->organization) ++ optional = 0; ++ break; ++ + case 'Z': + + ch = ' '; +diff -udprP mutt-1.5.23.orig/headers.c mutt-1.5.23/headers.c +--- mutt-1.5.23.orig/headers.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/headers.c 2014-03-13 12:48:36.000000000 +0200 +@@ -114,6 +114,9 @@ void mutt_edit_headers (const char *edit + $edit_headers set, we remove References: as they're likely invalid; + we can simply compare strings as we don't generate References for + multiple Message-Ids in IRT anyways */ ++#ifdef USE_NNTP ++ if (!option (OPTNEWSSEND)) ++#endif + if (msg->env->in_reply_to && + (!n->in_reply_to || mutt_strcmp (n->in_reply_to->data, + msg->env->in_reply_to->data) != 0)) +diff -udprP mutt-1.5.23.orig/init.c mutt-1.5.23/init.c +--- mutt-1.5.23.orig/init.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/init.c 2014-03-13 12:48:36.000000000 +0200 +@@ -2980,6 +2980,28 @@ void mutt_init (int skip_sys_rc, LIST *c + else + Fqdn = safe_strdup(NONULL(Hostname)); + ++#ifdef USE_NNTP ++ { ++ FILE *f; ++ char *i; ++ ++ if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r"))) ++ { ++ buffer[0] = '\0'; ++ fgets (buffer, sizeof (buffer), f); ++ p = &buffer; ++ SKIPWS (p); ++ i = p; ++ while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++; ++ *i = '\0'; ++ NewsServer = safe_strdup (p); ++ fclose (f); ++ } ++ } ++ if ((p = getenv ("NNTPSERVER"))) ++ NewsServer = safe_strdup (p); ++#endif ++ + if ((p = getenv ("MAIL"))) + Spoolfile = safe_strdup (p); + else if ((p = getenv ("MAILDIR"))) +diff -udprP mutt-1.5.23.orig/init.h mutt-1.5.23/init.h +--- mutt-1.5.23.orig/init.h 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23/init.h 2014-03-13 12:48:36.000000000 +0200 +@@ -176,6 +176,20 @@ struct option_t MuttVars[] = { + ** If \fIset\fP, Mutt will prompt you for carbon-copy (Cc) recipients before + ** editing the body of an outgoing message. + */ ++#ifdef USE_NNTP ++ { "ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 }, ++ /* ++ ** .pp ++ ** If set, Mutt will prompt you for follow-up groups before editing ++ ** the body of an outgoing message. ++ */ ++ { "ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 }, ++ /* ++ ** .pp ++ ** If set, Mutt will prompt you for x-comment-to field before editing ++ ** the body of an outgoing message. ++ */ ++#endif + { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL 0}, + /* + ** .pp +@@ -322,6 +336,14 @@ struct option_t MuttVars[] = { + ** follow these menus. The option is \fIunset\fP by default because many + ** visual terminals don't permit making the cursor invisible. + */ ++#ifdef USE_NNTP ++ { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES }, ++ /* ++ ** .pp ++ ** If this variable is \fIset\fP, Mutt will mark all articles in newsgroup ++ ** as read when you quit the newsgroup (catchup newsgroup). ++ */ ++#endif + #if defined(USE_SSL) + { "certificate_file", DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" }, + /* +@@ -809,6 +831,16 @@ struct option_t MuttVars[] = { + ** sent to both the list and your address, resulting in two copies + ** of the same email for you. + */ ++#ifdef USE_NNTP ++ { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES }, ++ /* ++ ** .pp ++ ** If this variable is \fIset\fP and the keyword "poster" is present in ++ ** \fIFollowup-To\fP header, follow-up to newsgroup function is not ++ ** permitted. The message will be mailed to the submitter of the ++ ** message via mail. ++ */ ++#endif + { "force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0 }, + /* + ** .pp +@@ -891,6 +923,26 @@ struct option_t MuttVars[] = { + ** a regular expression that will match the whole name so mutt will expand + ** ``Franklin'' to ``Franklin, Steve''. + */ ++#ifdef USE_NNTP ++ { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s %-45.45f %d" }, ++ /* ++ ** .pp ++ ** This variable allows you to customize the newsgroup browser display to ++ ** your personal taste. This string is similar to ``$index_format'', but ++ ** has its own set of printf()-like sequences: ++ ** .dl ++ ** .dt %C .dd current newsgroup number ++ ** .dt %d .dd description of newsgroup (becomes from server) ++ ** .dt %f .dd newsgroup name ++ ** .dt %M .dd - if newsgroup not allowed for direct post (moderated for example) ++ ** .dt %N .dd N if newsgroup is new, u if unsubscribed, blank otherwise ++ ** .dt %n .dd number of new articles in newsgroup ++ ** .dt %s .dd number of unread articles in newsgroup ++ ** .dt %>X .dd right justify the rest of the string and pad with character "X" ++ ** .dt %|X .dd pad to the end of the line with character "X" ++ ** .de ++ */ ++#endif + { "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 }, + /* + */ +@@ -1267,6 +1319,7 @@ struct option_t MuttVars[] = { + ** .dt %E .dd number of messages in current thread + ** .dt %f .dd sender (address + real name), either From: or Return-Path: + ** .dt %F .dd author name, or recipient name if the message is from you ++ ** .dt %g .dd newsgroup name (if compiled with NNTP support) + ** .dt %H .dd spam attribute(s) of this message + ** .dt %i .dd message-id of the current message + ** .dt %l .dd number of lines in the message (does not work with maildir, +@@ -1282,12 +1335,14 @@ struct option_t MuttVars[] = { + ** stashed the message: list name or recipient name + ** if not sent to a list + ** .dt %P .dd progress indicator for the built-in pager (how much of the file has been displayed) ++ ** .dt %R .dd ``X-Comment-To:'' field (if present and compiled with NNTP support) + ** .dt %s .dd subject of the message + ** .dt %S .dd status of the message (``N''/``D''/``d''/``!''/``r''/\(as) + ** .dt %t .dd ``To:'' field (recipients) + ** .dt %T .dd the appropriate character from the $$to_chars string + ** .dt %u .dd user (login) name of the author + ** .dt %v .dd first name of the author, or the recipient if the message is from you ++ ** .dt %W .dd name of organization of author (``Organization:'' field) + ** .dt %X .dd number of attachments + ** (please see the ``$attachments'' section for possible speed effects) + ** .dt %y .dd ``X-Label:'' field, if present +@@ -1322,6 +1377,25 @@ struct option_t MuttVars[] = { + ** Note that these expandos are supported in + ** ``$save-hook'', ``$fcc-hook'' and ``$fcc-save-hook'', too. + */ ++#ifdef USE_NNTP ++ { "inews", DT_PATH, R_NONE, UL &Inews, UL "" }, ++ /* ++ ** .pp ++ ** If set, specifies the program and arguments used to deliver news posted ++ ** by Mutt. Otherwise, mutt posts article using current connection to ++ ** news server. The following printf-style sequence is understood: ++ ** .dl ++ ** .dt %a .dd account url ++ ** .dt %p .dd port ++ ** .dt %P .dd port if specified ++ ** .dt %s .dd news server name ++ ** .dt %S .dd url schema ++ ** .dt %u .dd username ++ ** .de ++ ** .pp ++ ** Example: set inews="/usr/local/bin/inews -hS" ++ */ ++#endif + { "ispell", DT_PATH, R_NONE, UL &Ispell, UL ISPELL }, + /* + ** .pp +@@ -1556,6 +1630,15 @@ struct option_t MuttVars[] = { + ** menu, attachments which cannot be decoded in a reasonable manner will + ** be attached to the newly composed message if this option is \fIset\fP. + */ ++#ifdef USE_NNTP ++ { "mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 }, ++ /* ++ ** .pp ++ ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be ++ ** encoded according to RFC2047 to base64. This is useful when message ++ ** is Usenet article, because MIME for news is nonstandard feature. ++ */ ++#endif + #ifdef MIXMASTER + { "mix_entry_format", DT_STR, R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" }, + /* +@@ -1603,6 +1686,100 @@ struct option_t MuttVars[] = { + ** See also $$read_inc, $$write_inc and $$net_inc. + */ + #endif ++#ifdef USE_NNTP ++ { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" }, ++ /* ++ ** .pp ++ ** This variable pointing to directory where Mutt will save cached news ++ ** articles and headers in. If \fIunset\fP, articles and headers will not be ++ ** saved at all and will be reloaded from the server each time. ++ */ ++ { "news_server", DT_STR, R_NONE, UL &NewsServer, 0 }, ++ /* ++ ** .pp ++ ** This variable specifies domain name or address of NNTP server. It ++ ** defaults to the news server specified in the environment variable ++ ** $$$NNTPSERVER or contained in the file /etc/nntpserver. You can also ++ ** specify username and an alternative port for each news server, ie: ++ ** .pp ++ ** [[s]news://][username[:password]@]server[:port] ++ */ ++ { "newsgroups_charset", DT_STR, R_NONE, UL &NewsgroupsCharset, UL "utf-8" }, ++ /* ++ ** .pp ++ ** Character set of newsgroups descriptions. ++ */ ++ { "newsrc", DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" }, ++ /* ++ ** .pp ++ ** The file, containing info about subscribed newsgroups - names and ++ ** indexes of read articles. The following printf-style sequence ++ ** is understood: ++ ** .dl ++ ** .dt %a .dd account url ++ ** .dt %p .dd port ++ ** .dt %P .dd port if specified ++ ** .dt %s .dd news server name ++ ** .dt %S .dd url schema ++ ** .dt %u .dd username ++ ** .de ++ */ ++ { "nntp_authenticators", DT_STR, R_NONE, UL &NntpAuthenticators, UL 0 }, ++ /* ++ ** .pp ++ ** This is a colon-delimited list of authentication methods mutt may ++ ** attempt to use to log in to a news server, in the order mutt should ++ ** try them. Authentication methods are either ``user'' or any ++ ** SASL mechanism, e.g. ``digest-md5'', ``gssapi'' or ``cram-md5''. ++ ** This option is case-insensitive. If it's \fIunset\fP (the default) ++ ** mutt will try all available methods, in order from most-secure to ++ ** least-secure. ++ ** .pp ++ ** Example: ++ ** .ts ++ ** set nntp_authenticators="digest-md5:user" ++ ** .te ++ ** .pp ++ ** \fBNote:\fP Mutt will only fall back to other authentication methods if ++ ** the previous methods are unavailable. If a method is available but ++ ** authentication fails, mutt will not connect to the IMAP server. ++ */ ++ { "nntp_context", DT_NUM, R_NONE, UL &NntpContext, 1000 }, ++ /* ++ ** .pp ++ ** This variable defines number of articles which will be in index when ++ ** newsgroup entered. If active newsgroup have more articles than this ++ ** number, oldest articles will be ignored. Also controls how many ++ ** articles headers will be saved in cache when you quit newsgroup. ++ */ ++ { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 }, ++ /* ++ ** .pp ++ ** This variable controls whether or not descriptions for each newsgroup ++ ** must be loaded when newsgroup is added to list (first time list ++ ** loading or new newsgroup adding). ++ */ ++ { "nntp_user", DT_STR, R_NONE, UL &NntpUser, UL "" }, ++ /* ++ ** .pp ++ ** Your login name on the NNTP server. If \fIunset\fP and NNTP server requires ++ ** authentification, Mutt will prompt you for your account name when you ++ ** connect to news server. ++ */ ++ { "nntp_pass", DT_STR, R_NONE, UL &NntpPass, UL "" }, ++ /* ++ ** .pp ++ ** Your password for NNTP account. ++ */ ++ { "nntp_poll", DT_NUM, R_NONE, UL &NewsPollTimeout, 60 }, ++ /* ++ ** .pp ++ ** The time in seconds until any operations on newsgroup except post new ++ ** article will cause recheck for new news. If set to 0, Mutt will ++ ** recheck newsgroup on each operation in index (stepping, read article, ++ ** etc.). ++ */ ++#endif + { "pager", DT_PATH, R_NONE, UL &Pager, UL "builtin" }, + /* + ** .pp +@@ -2104,6 +2281,16 @@ struct option_t MuttVars[] = { + { "post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0 }, + /* + */ ++#ifdef USE_NNTP ++ { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES }, ++ /* ++ ** .pp ++ ** If set to \fIyes\fP, Mutt will post article to newsgroup that have ++ ** not permissions to posting (e.g. moderated). \fBNote:\fP if news server ++ ** does not support posting to that newsgroup or totally read-only, that ++ ** posting will not have an effect. ++ */ ++#endif + { "postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES }, + /* + ** .pp +@@ -2528,6 +2715,28 @@ struct option_t MuttVars[] = { + ** Command to use when spawning a subshell. By default, the user's login + ** shell from \fC/etc/passwd\fP is used. + */ ++#ifdef USE_NNTP ++ { "save_unsubscribed", DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 }, ++ /* ++ ** .pp ++ ** When \fIset\fP, info about unsubscribed newsgroups will be saved into ++ ** ``newsrc'' file and into cache. ++ */ ++ { "show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 }, ++ /* ++ ** .pp ++ ** If \fIset\fP, news server will be asked for new newsgroups on entering ++ ** the browser. Otherwise, it will be done only once for a news server. ++ ** Also controls whether or not number of new articles of subscribed ++ ** newsgroups will be then checked. ++ */ ++ { "show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 }, ++ /* ++ ** .pp ++ ** If \fIset\fP, only subscribed newsgroups that contain unread articles ++ ** will be displayed in browser. ++ */ ++#endif + { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 }, + /* + ** .pp +@@ -3412,6 +3621,14 @@ struct option_t MuttVars[] = { + ** Also see the $$read_inc, $$net_inc and $$time_inc variables and the + ** ``$tuning'' section of the manual for performance considerations. + */ ++#ifdef USE_NNTP ++ { "x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 }, ++ /* ++ ** .pp ++ ** If \fIset\fP, Mutt will add ``X-Comment-To:'' field (that contains full ++ ** name of original article author) to article that followuped to newsgroup. ++ */ ++#endif + /*--*/ + { NULL, 0, 0, 0, 0 } + }; +diff -udprP mutt-1.5.23.orig/keymap.c mutt-1.5.23/keymap.c +--- mutt-1.5.23.orig/keymap.c 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/keymap.c 2014-03-13 12:48:36.000000000 +0200 +@@ -784,7 +784,6 @@ void km_init (void) + km_bindkey ("<enter>", MENU_MAIN, OP_DISPLAY_MESSAGE); + + km_bindkey ("x", MENU_PAGER, OP_EXIT); +- km_bindkey ("i", MENU_PAGER, OP_EXIT); + km_bindkey ("<backspace>", MENU_PAGER, OP_PREV_LINE); + km_bindkey ("<pagedown>", MENU_PAGER, OP_NEXT_PAGE); + km_bindkey ("<pageup>", MENU_PAGER, OP_PREV_PAGE); +diff -udprP mutt-1.5.23.orig/mailbox.h mutt-1.5.23/mailbox.h +--- mutt-1.5.23.orig/mailbox.h 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/mailbox.h 2014-03-13 12:48:36.000000000 +0200 +@@ -74,6 +74,9 @@ int mx_is_imap (const char *); + #ifdef USE_POP + int mx_is_pop (const char *); + #endif ++#ifdef USE_NNTP ++int mx_is_nntp (const char *); ++#endif + + int mx_access (const char*, int); + int mx_check_empty (const char *); +diff -udprP mutt-1.5.23.orig/main.c mutt-1.5.23/main.c +--- mutt-1.5.23.orig/main.c 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23/main.c 2014-03-13 12:48:36.000000000 +0200 +@@ -62,6 +62,10 @@ + #include <idn/stringprep.h> + #endif + ++#ifdef USE_NNTP ++#include "nntp.h" ++#endif ++ + static const char *ReachingUs = N_("\ + To contact the developers, please mail to <mutt-dev@mutt.org>.\n\ + To report a bug, please visit http://bugs.mutt.org/.\n"); +@@ -136,6 +140,8 @@ options:\n\ + " -e <command>\tspecify a command to be executed after initialization\n\ + -f <file>\tspecify which mailbox to read\n\ + -F <file>\tspecify an alternate muttrc file\n\ ++ -g <server>\tspecify a news server (if compiled with NNTP)\n\ ++ -G\t\tselect a newsgroup (if compiled with NNTP)\n\ + -H <file>\tspecify a draft file to read header and body from\n\ + -i <file>\tspecify a file which Mutt should include in the body\n\ + -m <type>\tspecify a default mailbox type\n\ +@@ -284,6 +290,12 @@ static void show_version (void) + "-USE_POP " + #endif + ++#ifdef USE_NNTP ++ "+USE_NNTP " ++#else ++ "-USE_NNTP " ++#endif ++ + #ifdef USE_IMAP + "+USE_IMAP " + #else +@@ -552,6 +564,9 @@ init_extended_keys(); + #define M_NOSYSRC (1<<2) /* -n */ + #define M_RO (1<<3) /* -R */ + #define M_SELECT (1<<4) /* -y */ ++#ifdef USE_NNTP ++#define M_NEWS (1<<5) /* -g and -G */ ++#endif + + int main (int argc, char **argv) + { +@@ -624,7 +639,11 @@ int main (int argc, char **argv) + argv[nargc++] = argv[optind]; + } + ++#ifdef USE_NNTP ++ if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF) ++#else + if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF) ++#endif + switch (i) + { + case 'A': +@@ -721,6 +740,20 @@ int main (int argc, char **argv) + flags |= M_SELECT; + break; + ++#ifdef USE_NNTP ++ case 'g': /* Specify a news server */ ++ { ++ char buf[LONG_STRING]; ++ ++ snprintf (buf, sizeof (buf), "set news_server=%s", optarg); ++ commands = mutt_add_list (commands, buf); ++ } ++ ++ case 'G': /* List of newsgroups */ ++ flags |= M_SELECT | M_NEWS; ++ break; ++#endif ++ + case 'z': + flags |= M_IGNORE; + break; +@@ -1008,6 +1041,18 @@ int main (int argc, char **argv) + } + else if (flags & M_SELECT) + { ++#ifdef USE_NNTP ++ if (flags & M_NEWS) ++ { ++ set_option (OPTNEWS); ++ if(!(CurrentNewsSrv = nntp_select_server (NewsServer, 0))) ++ { ++ mutt_endwin (Errorbuf); ++ exit (1); ++ } ++ } ++ else ++#endif + if (!Incoming) { + mutt_endwin _("No incoming mailboxes defined."); + exit (1); +@@ -1023,6 +1068,15 @@ int main (int argc, char **argv) + + if (!folder[0]) + strfcpy (folder, NONULL(Spoolfile), sizeof (folder)); ++ ++#ifdef USE_NNTP ++ if (option (OPTNEWS)) ++ { ++ unset_option (OPTNEWS); ++ nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account); ++ } ++ else ++#endif + mutt_expand_path (folder, sizeof (folder)); + + mutt_str_replace (&CurrentFolder, folder); +diff -udprP mutt-1.5.23.orig/mutt.h mutt-1.5.23/mutt.h +--- mutt-1.5.23.orig/mutt.h 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23/mutt.h 2014-03-13 12:49:30.000000000 +0200 +@@ -227,6 +227,9 @@ enum + M_PGP_KEY, + M_XLABEL, + M_MIMEATTACH, ++#ifdef USE_NNTP ++ M_NEWSGROUPS, ++#endif + + /* Options for Mailcap lookup */ + M_EDIT, +@@ -283,6 +286,11 @@ enum + #endif + OPT_SUBJECT, + OPT_VERIFYSIG, /* verify PGP signatures */ ++#ifdef USE_NNTP ++ OPT_TOMODERATED, ++ OPT_CATCHUP, ++ OPT_FOLLOWUPTOPOSTER, ++#endif + + /* THIS MUST BE THE LAST VALUE. */ + OPT_MAX +@@ -299,6 +307,7 @@ enum + #define SENDKEY (1<<7) + #define SENDRESEND (1<<8) + #define SENDPOSTPONEDFCC (1<<9) /* used by mutt_get_postponed() to signal that the x-mutt-fcc header field was present */ ++#define SENDNEWS (1<<10) + + /* flags to _mutt_select_file() */ + #define M_SEL_BUFFY (1<<0) +@@ -318,6 +327,8 @@ enum + OPTASCIICHARS, + OPTASKBCC, + OPTASKCC, ++ OPTASKFOLLOWUP, ++ OPTASKXCOMMENTTO, + OPTATTACHSPLIT, + OPTAUTOEDIT, + OPTAUTOTAG, +@@ -398,6 +409,9 @@ enum + OPTMETOO, + OPTMHPURGE, + OPTMIMEFORWDECODE, ++#ifdef USE_NNTP ++ OPTMIMESUBJECT, /* encode subject line with RFC2047 */ ++#endif + OPTNARROWTREE, + OPTPAGERSTOP, + OPTPIPEDECODE, +@@ -480,6 +494,16 @@ enum + OPTPGPAUTOINLINE, + OPTPGPREPLYINLINE, + ++ /* news options */ ++ ++#ifdef USE_NNTP ++ OPTSHOWNEWNEWS, ++ OPTSHOWONLYUNREAD, ++ OPTSAVEUNSUB, ++ OPTLOADDESC, ++ OPTXCOMMENTTO, ++#endif ++ + /* pseudo options */ + + OPTAUXSORT, /* (pseudo) using auxiliary sort function */ +@@ -500,6 +524,7 @@ enum + OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */ + OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */ + OPTATTACHMSG, /* (pseudo) used by attach-message */ ++ OPTHIDEREAD, /* (pseudo) whether or not hide read messages */ + OPTKEEPQUIET, /* (pseudo) shut up the message and refresh + * functions while we are executing an + * external program. +@@ -510,6 +535,11 @@ enum + OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */ + OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */ + ++#ifdef USE_NNTP ++ OPTNEWS, /* (pseudo) used to change reader mode */ ++ OPTNEWSSEND, /* (pseudo) used to change behavior when posting */ ++#endif ++ + OPTMAX + }; + +@@ -589,6 +619,13 @@ typedef struct envelope + char *supersedes; + char *date; + char *x_label; ++ char *organization; ++#ifdef USE_NNTP ++ char *newsgroups; ++ char *xref; ++ char *followup_to; ++ char *x_comment_to; ++#endif + BUFFER *spam; + LIST *references; /* message references (in reverse order) */ + LIST *in_reply_to; /* in-reply-to header content */ +@@ -773,7 +810,7 @@ typedef struct header + int refno; /* message number on server */ + #endif + +-#if defined USE_POP || defined USE_IMAP ++#if defined USE_POP || defined USE_IMAP || defined USE_NNTP + void *data; /* driver-specific data */ + #endif + +diff -udprP mutt-1.5.23.orig/mutt_sasl.c mutt-1.5.23/mutt_sasl.c +--- mutt-1.5.23.orig/mutt_sasl.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/mutt_sasl.c 2014-03-13 12:48:37.000000000 +0200 +@@ -188,6 +188,11 @@ int mutt_sasl_client_new (CONNECTION* co + case M_ACCT_TYPE_SMTP: + service = "smtp"; + break; ++#ifdef USE_NNTP ++ case M_ACCT_TYPE_NNTP: ++ service = "nntp"; ++ break; ++#endif + default: + mutt_error (_("Unknown SASL profile")); + return -1; +diff -udprP mutt-1.5.23.orig/muttlib.c mutt-1.5.23/muttlib.c +--- mutt-1.5.23.orig/muttlib.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/muttlib.c 2014-03-13 12:48:37.000000000 +0200 +@@ -337,7 +337,7 @@ void mutt_free_header (HEADER **h) + #ifdef MIXMASTER + mutt_free_list (&(*h)->chain); + #endif +-#if defined USE_POP || defined USE_IMAP ++#if defined USE_POP || defined USE_IMAP || defined USE_NNTP + FREE (&(*h)->data); + #endif + FREE (h); /* __FREE_CHECKED__ */ +@@ -722,6 +722,13 @@ void mutt_free_envelope (ENVELOPE **p) + FREE (&(*p)->supersedes); + FREE (&(*p)->date); + FREE (&(*p)->x_label); ++ FREE (&(*p)->organization); ++#ifdef USE_NNTP ++ FREE (&(*p)->newsgroups); ++ FREE (&(*p)->xref); ++ FREE (&(*p)->followup_to); ++ FREE (&(*p)->x_comment_to); ++#endif + + mutt_buffer_free (&(*p)->spam); + +@@ -1520,6 +1527,14 @@ int mutt_save_confirm (const char *s, st + } + } + ++#ifdef USE_NNTP ++ if (magic == M_NNTP) ++ { ++ mutt_error _("Can't save message to news server."); ++ return 0; ++ } ++#endif ++ + if (stat (s, st) != -1) + { + if (magic == -1) +diff -udprP mutt-1.5.23.orig/mx.c mutt-1.5.23/mx.c +--- mutt-1.5.23.orig/mx.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/mx.c 2014-03-13 12:48:37.000000000 +0200 +@@ -343,6 +343,22 @@ int mx_is_pop (const char *p) + } + #endif + ++#ifdef USE_NNTP ++int mx_is_nntp (const char *p) ++{ ++ url_scheme_t scheme; ++ ++ if (!p) ++ return 0; ++ ++ scheme = url_check_scheme (p); ++ if (scheme == U_NNTP || scheme == U_NNTPS) ++ return 1; ++ ++ return 0; ++} ++#endif ++ + int mx_get_magic (const char *path) + { + struct stat st; +@@ -360,6 +376,11 @@ int mx_get_magic (const char *path) + return M_POP; + #endif /* USE_POP */ + ++#ifdef USE_NNTP ++ if (mx_is_nntp (path)) ++ return M_NNTP; ++#endif /* USE_NNTP */ ++ + if (stat (path, &st) == -1) + { + dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n", +@@ -668,6 +689,12 @@ CONTEXT *mx_open_mailbox (const char *pa + break; + #endif /* USE_POP */ + ++#ifdef USE_NNTP ++ case M_NNTP: ++ rc = nntp_open_mailbox (ctx); ++ break; ++#endif /* USE_NNTP */ ++ + default: + rc = -1; + break; +@@ -764,6 +791,12 @@ static int sync_mailbox (CONTEXT *ctx, i + rc = pop_sync_mailbox (ctx, index_hint); + break; + #endif /* USE_POP */ ++ ++#ifdef USE_NNTP ++ case M_NNTP: ++ rc = nntp_sync_mailbox (ctx); ++ break; ++#endif /* USE_NNTP */ + } + + #if 0 +@@ -807,6 +840,25 @@ int mx_close_mailbox (CONTEXT *ctx, int + return 0; + } + ++#ifdef USE_NNTP ++ if (ctx->unread && ctx->magic == M_NNTP) ++ { ++ NNTP_DATA *nntp_data = ctx->data; ++ ++ if (nntp_data && nntp_data->nserv && nntp_data->group) ++ { ++ int rc = query_quadoption (OPT_CATCHUP, _("Mark all articles read?")); ++ if (rc < 0) ++ { ++ ctx->closing = 0; ++ return -1; ++ } ++ else if (rc == M_YES) ++ mutt_newsgroup_catchup (nntp_data->nserv, nntp_data->group); ++ } ++ } ++#endif ++ + for (i = 0; i < ctx->msgcount; i++) + { + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read +@@ -814,6 +866,12 @@ int mx_close_mailbox (CONTEXT *ctx, int + read_msgs++; + } + ++#ifdef USE_NNTP ++ /* don't need to move articles from newsgroup */ ++ if (ctx->magic == M_NNTP) ++ read_msgs = 0; ++#endif ++ + if (read_msgs && quadoption (OPT_MOVE) != M_NO) + { + char *p; +@@ -1341,6 +1399,11 @@ int mx_check_mailbox (CONTEXT *ctx, int + case M_POP: + return (pop_check_mailbox (ctx, index_hint)); + #endif /* USE_POP */ ++ ++#ifdef USE_NNTP ++ case M_NNTP: ++ return (nntp_check_mailbox (ctx, 0)); ++#endif /* USE_NNTP */ + } + } + +@@ -1401,6 +1464,15 @@ MESSAGE *mx_open_message (CONTEXT *ctx, + } + #endif /* USE_POP */ + ++#ifdef USE_NNTP ++ case M_NNTP: ++ { ++ if (nntp_fetch_message (msg, ctx, msgno) != 0) ++ FREE (&msg); ++ break; ++ } ++#endif /* USE_NNTP */ ++ + default: + dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic)); + FREE (&msg); +@@ -1476,6 +1548,9 @@ int mx_close_message (MESSAGE **msg) + int r = 0; + + if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR ++#ifdef USE_NNTP ++ || (*msg)->magic == M_NNTP ++#endif + || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP) + { + r = safe_fclose (&(*msg)->fp); +diff -udprP mutt-1.5.23.orig/mx.h mutt-1.5.23/mx.h +--- mutt-1.5.23.orig/mx.h 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/mx.h 2014-03-13 12:48:37.000000000 +0200 +@@ -34,6 +34,9 @@ enum + M_MMDF, + M_MH, + M_MAILDIR, ++#ifdef USE_NNTP ++ M_NNTP, ++#endif + M_IMAP, + M_POP + }; +diff -udprP mutt-1.5.23.orig/newsrc.c mutt-1.5.23/newsrc.c +--- mutt-1.5.23.orig/newsrc.c 1970-01-01 03:00:00.000000000 +0300 ++++ mutt-1.5.23/newsrc.c 2014-03-13 12:48:37.000000000 +0200 +@@ -0,0 +1,1260 @@ ++/* ++ * Copyright (C) 1998 Brandon Long <blong@fiction.net> ++ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net> ++ * Copyright (C) 2000-2012 Vsevolod Volkov <vvv@mutt.org.ua> ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++ */ ++ ++#if HAVE_CONFIG_H ++#include "config.h" ++#endif ++ ++#include "mutt.h" ++#include "mutt_curses.h" ++#include "sort.h" ++#include "mx.h" ++#include "mime.h" ++#include "mailbox.h" ++#include "nntp.h" ++#include "rfc822.h" ++#include "rfc1524.h" ++#include "rfc2047.h" ++#include "bcache.h" ++ ++#if USE_HCACHE ++#include "hcache.h" ++#endif ++ ++#include <unistd.h> ++#include <string.h> ++#include <ctype.h> ++#include <stdlib.h> ++#include <sys/stat.h> ++#include <sys/types.h> ++#include <dirent.h> ++#include <errno.h> ++ ++/* Find NNTP_DATA for given newsgroup or add it */ ++static NNTP_DATA *nntp_data_find (NNTP_SERVER *nserv, const char *group) ++{ ++ NNTP_DATA *nntp_data = hash_find (nserv->groups_hash, group); ++ ++ if (!nntp_data) ++ { ++ /* create NNTP_DATA structure and add it to hash */ ++ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1); ++ nntp_data->group = (char *)nntp_data + sizeof (NNTP_DATA); ++ strcpy (nntp_data->group, group); ++ nntp_data->nserv = nserv; ++ nntp_data->deleted = 1; ++ if (nserv->groups_hash->nelem < nserv->groups_hash->curnelem * 2) ++ nserv->groups_hash = hash_resize (nserv->groups_hash, ++ nserv->groups_hash->nelem * 2, 0); ++ hash_insert (nserv->groups_hash, nntp_data->group, nntp_data, 0); ++ ++ /* add NNTP_DATA to list */ ++ if (nserv->groups_num >= nserv->groups_max) ++ { ++ nserv->groups_max *= 2; ++ safe_realloc (&nserv->groups_list, ++ nserv->groups_max * sizeof (nntp_data)); ++ } ++ nserv->groups_list[nserv->groups_num++] = nntp_data; ++ } ++ return nntp_data; ++} ++ ++/* Remove all temporarily cache files */ ++void nntp_acache_free (NNTP_DATA *nntp_data) ++{ ++ int i; ++ ++ for (i = 0; i < NNTP_ACACHE_LEN; i++) ++ { ++ if (nntp_data->acache[i].path) ++ { ++ unlink (nntp_data->acache[i].path); ++ FREE (&nntp_data->acache[i].path); ++ } ++ } ++} ++ ++/* Free NNTP_DATA, used to destroy hash elements */ ++void nntp_data_free (void *data) ++{ ++ NNTP_DATA *nntp_data = data; ++ ++ if (!nntp_data) ++ return; ++ nntp_acache_free (nntp_data); ++ mutt_bcache_close (&nntp_data->bcache); ++ FREE (&nntp_data->newsrc_ent); ++ FREE (&nntp_data->desc); ++ FREE (&data); ++} ++ ++/* Unlock and close .newsrc file */ ++void nntp_newsrc_close (NNTP_SERVER *nserv) ++{ ++ if (!nserv->newsrc_fp) ++ return; ++ ++ dprint (1, (debugfile, "Unlocking %s\n", nserv->newsrc_file)); ++ mx_unlock_file (nserv->newsrc_file, fileno (nserv->newsrc_fp), 0); ++ safe_fclose (&nserv->newsrc_fp); ++} ++ ++/* Parse .newsrc file: ++ * 0 - not changed ++ * 1 - parsed ++ * -1 - error */ ++int nntp_newsrc_parse (NNTP_SERVER *nserv) ++{ ++ unsigned int i; ++ char *line; ++ struct stat sb; ++ ++ /* if file doesn't exist, create it */ ++ nserv->newsrc_fp = safe_fopen (nserv->newsrc_file, "a"); ++ safe_fclose (&nserv->newsrc_fp); ++ ++ /* open .newsrc */ ++ nserv->newsrc_fp = safe_fopen (nserv->newsrc_file, "r"); ++ if (!nserv->newsrc_fp) ++ { ++ mutt_perror (nserv->newsrc_file); ++ mutt_sleep (2); ++ return -1; ++ } ++ ++ /* lock it */ ++ dprint (1, (debugfile, "Locking %s\n", nserv->newsrc_file)); ++ if (mx_lock_file (nserv->newsrc_file, fileno (nserv->newsrc_fp), 0, 0, 1)) ++ { ++ safe_fclose (&nserv->newsrc_fp); ++ return -1; ++ } ++ ++ if (stat (nserv->newsrc_file, &sb)) ++ { ++ mutt_perror (nserv->newsrc_file); ++ nntp_newsrc_close (nserv); ++ mutt_sleep (2); ++ return -1; ++ } ++ ++ if (nserv->size == sb.st_size && nserv->mtime == sb.st_mtime) ++ return 0; ++ ++ nserv->size = sb.st_size; ++ nserv->mtime = sb.st_mtime; ++ nserv->newsrc_modified = 1; ++ dprint (1, (debugfile, "Parsing %s\n", nserv->newsrc_file)); ++ ++ /* .newsrc has been externally modified or hasn't been loaded yet */ ++ for (i = 0; i < nserv->groups_num; i++) ++ { ++ NNTP_DATA *nntp_data = nserv->groups_list[i]; ++ ++ if (!nntp_data) ++ continue; ++ ++ nntp_data->subscribed = 0; ++ nntp_data->newsrc_len = 0; ++ FREE (&nntp_data->newsrc_ent); ++ } ++ ++ line = safe_malloc (sb.st_size + 1); ++ while (sb.st_size && fgets (line, sb.st_size + 1, nserv->newsrc_fp)) ++ { ++ char *b, *h, *p; ++ unsigned int subs = 0, i = 1; ++ NNTP_DATA *nntp_data; ++ ++ /* find end of newsgroup name */ ++ p = strpbrk (line, ":!"); ++ if (!p) ++ continue; ++ ++ /* ":" - subscribed, "!" - unsubscribed */ ++ if (*p == ':') ++ subs++; ++ *p++ = '\0'; ++ ++ /* get newsgroup data */ ++ nntp_data = nntp_data_find (nserv, line); ++ FREE (&nntp_data->newsrc_ent); ++ ++ /* count number of entries */ ++ b = p; ++ while (*b) ++ if (*b++ == ',') ++ i++; ++ nntp_data->newsrc_ent = safe_calloc (i, sizeof (NEWSRC_ENTRY)); ++ nntp_data->subscribed = subs; ++ ++ /* parse entries */ ++ i = 0; ++ while (p) ++ { ++ b = p; ++ ++ /* find end of entry */ ++ p = strchr (p, ','); ++ if (p) ++ *p++ = '\0'; ++ ++ /* first-last or single number */ ++ h = strchr (b, '-'); ++ if (h) ++ *h++ = '\0'; ++ else ++ h = b; ++ ++ if (sscanf (b, ANUM, &nntp_data->newsrc_ent[i].first) == 1 && ++ sscanf (h, ANUM, &nntp_data->newsrc_ent[i].last) == 1) ++ i++; ++ } ++ if (i == 0) ++ { ++ nntp_data->newsrc_ent[i].first = 1; ++ nntp_data->newsrc_ent[i].last = 0; ++ i++; ++ } ++ if (nntp_data->lastMessage == 0) ++ nntp_data->lastMessage = nntp_data->newsrc_ent[i - 1].last; ++ nntp_data->newsrc_len = i; ++ safe_realloc (&nntp_data->newsrc_ent, i * sizeof (NEWSRC_ENTRY)); ++ nntp_group_unread_stat (nntp_data); ++ dprint (2, (debugfile, "nntp_newsrc_parse: %s\n", nntp_data->group)); ++ } ++ FREE (&line); ++ return 1; ++} ++ ++/* Generate array of .newsrc entries */ ++void nntp_newsrc_gen_entries (CONTEXT *ctx) ++{ ++ NNTP_DATA *nntp_data = ctx->data; ++ anum_t last = 0, first = 1; ++ int series, i; ++ int save_sort = SORT_ORDER; ++ unsigned int entries; ++ ++ if (Sort != SORT_ORDER) ++ { ++ save_sort = Sort; ++ Sort = SORT_ORDER; ++ mutt_sort_headers (ctx, 0); ++ } ++ ++ entries = nntp_data->newsrc_len; ++ if (!entries) ++ { ++ entries = 5; ++ nntp_data->newsrc_ent = safe_calloc (entries, sizeof (NEWSRC_ENTRY)); ++ } ++ ++ /* Set up to fake initial sequence from 1 to the article before the ++ * first article in our list */ ++ nntp_data->newsrc_len = 0; ++ series = 1; ++ for (i = 0; i < ctx->msgcount; i++) ++ { ++ /* search for first unread */ ++ if (series) ++ { ++ /* We don't actually check sequential order, since we mark ++ * "missing" entries as read/deleted */ ++ last = NHDR (ctx->hdrs[i])->article_num; ++ if (last >= nntp_data->firstMessage && !ctx->hdrs[i]->deleted && ++ !ctx->hdrs[i]->read) ++ { ++ if (nntp_data->newsrc_len >= entries) ++ { ++ entries *= 2; ++ safe_realloc (&nntp_data->newsrc_ent, entries * sizeof (NEWSRC_ENTRY)); ++ } ++ nntp_data->newsrc_ent[nntp_data->newsrc_len].first = first; ++ nntp_data->newsrc_ent[nntp_data->newsrc_len].last = last - 1; ++ nntp_data->newsrc_len++; ++ series = 0; ++ } ++ } ++ ++ /* search for first read */ ++ else ++ { ++ if (ctx->hdrs[i]->deleted || ctx->hdrs[i]->read) ++ { ++ first = last + 1; ++ series = 1; ++ } ++ last = NHDR (ctx->hdrs[i])->article_num; ++ } ++ } ++ ++ if (series && first <= nntp_data->lastLoaded) ++ { ++ if (nntp_data->newsrc_len >= entries) ++ { ++ entries++; ++ safe_realloc (&nntp_data->newsrc_ent, entries * sizeof (NEWSRC_ENTRY)); ++ } ++ nntp_data->newsrc_ent[nntp_data->newsrc_len].first = first; ++ nntp_data->newsrc_ent[nntp_data->newsrc_len].last = nntp_data->lastLoaded; ++ nntp_data->newsrc_len++; ++ } ++ safe_realloc (&nntp_data->newsrc_ent, ++ nntp_data->newsrc_len * sizeof (NEWSRC_ENTRY)); ++ ++ if (save_sort != Sort) ++ { ++ Sort = save_sort; ++ mutt_sort_headers (ctx, 0); ++ } ++} ++ ++/* Update file with new contents */ ++static int update_file (char *filename, char *buf) ++{ ++ FILE *fp; ++ char tmpfile[_POSIX_PATH_MAX]; ++ int rc = -1; ++ ++ while (1) ++ { ++ snprintf (tmpfile, sizeof (tmpfile), "%s.tmp", filename); ++ fp = fopen (tmpfile, "w"); ++ if (!fp) ++ { ++ mutt_perror (tmpfile); ++ *tmpfile = '\0'; ++ break; ++ } ++ if (fputs (buf, fp) == EOF) ++ { ++ mutt_perror (tmpfile); ++ break; ++ } ++ if (fclose (fp) == EOF) ++ { ++ mutt_perror (tmpfile); ++ fp = NULL; ++ break; ++ } ++ fp = NULL; ++ if (rename (tmpfile, filename) < 0) ++ { ++ mutt_perror (filename); ++ break; ++ } ++ *tmpfile = '\0'; ++ rc = 0; ++ break; ++ } ++ if (fp) ++ fclose (fp); ++ if (*tmpfile) ++ unlink (tmpfile); ++ if (rc) ++ mutt_sleep (2); ++ return rc; ++} ++ ++/* Update .newsrc file */ ++int nntp_newsrc_update (NNTP_SERVER *nserv) ++{ ++ char *buf; ++ size_t buflen, off; ++ unsigned int i; ++ int rc = -1; ++ ++ if (!nserv) ++ return -1; ++ ++ buflen = 10 * LONG_STRING; ++ buf = safe_calloc (1, buflen); ++ off = 0; ++ ++ /* we will generate full newsrc here */ ++ for (i = 0; i < nserv->groups_num; i++) ++ { ++ NNTP_DATA *nntp_data = nserv->groups_list[i]; ++ unsigned int n; ++ ++ if (!nntp_data || !nntp_data->newsrc_ent) ++ continue; ++ ++ /* write newsgroup name */ ++ if (off + strlen (nntp_data->group) + 3 > buflen) ++ { ++ buflen *= 2; ++ safe_realloc (&buf, buflen); ++ } ++ snprintf (buf + off, buflen - off, "%s%c ", nntp_data->group, ++ nntp_data->subscribed ? ':' : '!'); ++ off += strlen (buf + off); ++ ++ /* write entries */ ++ for (n = 0; n < nntp_data->newsrc_len; n++) ++ { ++ if (off + LONG_STRING > buflen) ++ { ++ buflen *= 2; ++ safe_realloc (&buf, buflen); ++ } ++ if (n) ++ buf[off++] = ','; ++ if (nntp_data->newsrc_ent[n].first == nntp_data->newsrc_ent[n].last) ++ snprintf (buf + off, buflen - off, "%d", nntp_data->newsrc_ent[n].first); ++ else if (nntp_data->newsrc_ent[n].first < nntp_data->newsrc_ent[n].last) ++ snprintf (buf + off, buflen - off, "%d-%d", ++ nntp_data->newsrc_ent[n].first, nntp_data->newsrc_ent[n].last); ++ off += strlen (buf + off); ++ } ++ buf[off++] = '\n'; ++ } ++ buf[off] = '\0'; ++ ++ /* newrc being fully rewritten */ ++ dprint (1, (debugfile, "Updating %s\n", nserv->newsrc_file)); ++ if (nserv->newsrc_file && update_file (nserv->newsrc_file, buf) == 0) ++ { ++ struct stat sb; ++ ++ rc = stat (nserv->newsrc_file, &sb); ++ if (rc == 0) ++ { ++ nserv->size = sb.st_size; ++ nserv->mtime = sb.st_mtime; ++ } ++ else ++ { ++ mutt_perror (nserv->newsrc_file); ++ mutt_sleep (2); ++ } ++ } ++ FREE (&buf); ++ return rc; ++} ++ ++/* Make fully qualified cache file name */ ++static void cache_expand (char *dst, size_t dstlen, ACCOUNT *acct, char *src) ++{ ++ char *c; ++ char file[_POSIX_PATH_MAX]; ++ ++ /* server subdirectory */ ++ if (acct) ++ { ++ ciss_url_t url; ++ ++ mutt_account_tourl (acct, &url); ++ url.path = src; ++ url_ciss_tostring (&url, file, sizeof (file), U_PATH); ++ } ++ else ++ strfcpy (file, src ? src : "", sizeof (file)); ++ ++ snprintf (dst, dstlen, "%s/%s", NewsCacheDir, file); ++ ++ /* remove trailing slash */ ++ c = dst + strlen (dst) - 1; ++ if (*c == '/') ++ *c = '\0'; ++ mutt_expand_path (dst, dstlen); ++} ++ ++/* Make fully qualified url from newsgroup name */ ++void nntp_expand_path (char *line, size_t len, ACCOUNT *acct) ++{ ++ ciss_url_t url; ++ ++ url.path = safe_strdup (line); ++ mutt_account_tourl (acct, &url); ++ url_ciss_tostring (&url, line, len, 0); ++ FREE (&url.path); ++} ++ ++/* Parse newsgroup */ ++int nntp_add_group (char *line, void *data) ++{ ++ NNTP_SERVER *nserv = data; ++ NNTP_DATA *nntp_data; ++ char group[LONG_STRING]; ++ char desc[HUGE_STRING] = ""; ++ char mod; ++ anum_t first, last; ++ ++ if (!nserv || !line) ++ return 0; ++ ++ if (sscanf (line, "%s " ANUM " " ANUM " %c %[^\n]", group, ++ &last, &first, &mod, desc) < 4) ++ return 0; ++ ++ nntp_data = nntp_data_find (nserv, group); ++ nntp_data->deleted = 0; ++ nntp_data->firstMessage = first; ++ nntp_data->lastMessage = last; ++ nntp_data->allowed = mod == 'y' || mod == 'm' ? 1 : 0; ++ mutt_str_replace (&nntp_data->desc, desc); ++ if (nntp_data->newsrc_ent || nntp_data->lastCached) ++ nntp_group_unread_stat (nntp_data); ++ else if (nntp_data->lastMessage && ++ nntp_data->firstMessage <= nntp_data->lastMessage) ++ nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1; ++ else ++ nntp_data->unread = 0; ++ return 0; ++} ++ ++/* Load list of all newsgroups from cache */ ++static int active_get_cache (NNTP_SERVER *nserv) ++{ ++ char buf[HUGE_STRING]; ++ char file[_POSIX_PATH_MAX]; ++ time_t t; ++ FILE *fp; ++ ++ cache_expand (file, sizeof (file), &nserv->conn->account, ".active"); ++ dprint (1, (debugfile, "Parsing %s\n", file)); ++ fp = safe_fopen (file, "r"); ++ if (!fp) ++ return -1; ++ ++ if (fgets (buf, sizeof (buf), fp) == NULL || ++ sscanf (buf, "%ld%s", &t, file) != 1 || t == 0) ++ { ++ fclose (fp); ++ return -1; ++ } ++ nserv->newgroups_time = t; ++ ++ mutt_message _("Loading list of groups from cache..."); ++ while (fgets (buf, sizeof (buf), fp)) ++ nntp_add_group (buf, nserv); ++ nntp_add_group (NULL, NULL); ++ fclose (fp); ++ mutt_clear_error (); ++ return 0; ++} ++ ++/* Save list of all newsgroups to cache */ ++int nntp_active_save_cache (NNTP_SERVER *nserv) ++{ ++ char file[_POSIX_PATH_MAX]; ++ char *buf; ++ size_t buflen, off; ++ unsigned int i; ++ int rc; ++ ++ if (!nserv->cacheable) ++ return 0; ++ ++ buflen = 10 * LONG_STRING; ++ buf = safe_calloc (1, buflen); ++ snprintf (buf, buflen, "%lu\n", (unsigned long)nserv->newgroups_time); ++ off = strlen (buf); ++ ++ for (i = 0; i < nserv->groups_num; i++) ++ { ++ NNTP_DATA *nntp_data = nserv->groups_list[i]; ++ ++ if (!nntp_data || nntp_data->deleted) ++ continue; ++ ++ if (off + strlen (nntp_data->group) + ++ (nntp_data->desc ? strlen (nntp_data->desc) : 0) + 50 > buflen) ++ { ++ buflen *= 2; ++ safe_realloc (&buf, buflen); ++ } ++ snprintf (buf + off, buflen - off, "%s %d %d %c%s%s\n", nntp_data->group, ++ nntp_data->lastMessage, nntp_data->firstMessage, ++ nntp_data->allowed ? 'y' : 'n', nntp_data->desc ? " " : "", ++ nntp_data->desc ? nntp_data->desc : ""); ++ off += strlen (buf + off); ++ } ++ ++ cache_expand (file, sizeof (file), &nserv->conn->account, ".active"); ++ dprint (1, (debugfile, "Updating %s\n", file)); ++ rc = update_file (file, buf); ++ FREE (&buf); ++ return rc; ++} ++ ++#ifdef USE_HCACHE ++/* Used by mutt_hcache_open() to compose hcache file name */ ++static int nntp_hcache_namer (const char *path, char *dest, size_t destlen) ++{ ++ return snprintf (dest, destlen, "%s.hcache", path); ++} ++ ++/* Open newsgroup hcache */ ++header_cache_t *nntp_hcache_open (NNTP_DATA *nntp_data) ++{ ++ ciss_url_t url; ++ char file[_POSIX_PATH_MAX]; ++ ++ if (!nntp_data->nserv || !nntp_data->nserv->cacheable || ++ !nntp_data->nserv->conn || !nntp_data->group || ++ !(nntp_data->newsrc_ent || nntp_data->subscribed || ++ option (OPTSAVEUNSUB))) ++ return NULL; ++ ++ mutt_account_tourl (&nntp_data->nserv->conn->account, &url); ++ url.path = nntp_data->group; ++ url_ciss_tostring (&url, file, sizeof (file), U_PATH); ++ return mutt_hcache_open (NewsCacheDir, file, nntp_hcache_namer); ++} ++ ++/* Remove stale cached headers */ ++void nntp_hcache_update (NNTP_DATA *nntp_data, header_cache_t *hc) ++{ ++ char buf[16]; ++ int old = 0; ++ void *hdata; ++ anum_t first, last, current; ++ ++ if (!hc) ++ return; ++ ++ /* fetch previous values of first and last */ ++ hdata = mutt_hcache_fetch_raw (hc, "index", strlen); ++ if (hdata) ++ { ++ dprint (2, (debugfile, ++ "nntp_hcache_update: mutt_hcache_fetch index: %s\n", hdata)); ++ if (sscanf (hdata, ANUM " " ANUM, &first, &last) == 2) ++ { ++ old = 1; ++ nntp_data->lastCached = last; ++ ++ /* clean removed headers from cache */ ++ for (current = first; current <= last; current++) ++ { ++ if (current >= nntp_data->firstMessage && ++ current <= nntp_data->lastMessage) ++ continue; ++ ++ snprintf (buf, sizeof (buf), "%d", current); ++ dprint (2, (debugfile, ++ "nntp_hcache_update: mutt_hcache_delete %s\n", buf)); ++ mutt_hcache_delete (hc, buf, strlen); ++ } ++ } ++ } ++ ++ /* store current values of first and last */ ++ if (!old || nntp_data->firstMessage != first || ++ nntp_data->lastMessage != last) ++ { ++ snprintf (buf, sizeof (buf), "%u %u", nntp_data->firstMessage, ++ nntp_data->lastMessage); ++ dprint (2, (debugfile, ++ "nntp_hcache_update: mutt_hcache_store index: %s\n", buf)); ++ mutt_hcache_store_raw (hc, "index", buf, strlen (buf) + 1, strlen); ++ } ++} ++#endif ++ ++/* Remove bcache file */ ++static int nntp_bcache_delete (const char *id, body_cache_t *bcache, void *data) ++{ ++ NNTP_DATA *nntp_data = data; ++ anum_t anum; ++ char c; ++ ++ if (!nntp_data || sscanf (id, ANUM "%c", &anum, &c) != 1 || ++ anum < nntp_data->firstMessage || anum > nntp_data->lastMessage) ++ { ++ if (nntp_data) ++ dprint (2, (debugfile, "nntp_bcache_delete: mutt_bcache_del %s\n", id)); ++ mutt_bcache_del (bcache, id); ++ } ++ return 0; ++} ++ ++/* Remove stale cached messages */ ++void nntp_bcache_update (NNTP_DATA *nntp_data) ++{ ++ mutt_bcache_list (nntp_data->bcache, nntp_bcache_delete, nntp_data); ++} ++ ++/* Remove hcache and bcache of newsgroup */ ++void nntp_delete_group_cache (NNTP_DATA *nntp_data) ++{ ++ char file[_POSIX_PATH_MAX]; ++ ++ if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->cacheable) ++ return; ++ ++#ifdef USE_HCACHE ++ nntp_hcache_namer (nntp_data->group, file, sizeof (file)); ++ cache_expand (file, sizeof (file), &nntp_data->nserv->conn->account, file); ++ unlink (file); ++ nntp_data->lastCached = 0; ++ dprint (2, (debugfile, "nntp_delete_group_cache: %s\n", file)); ++#endif ++ ++ if (!nntp_data->bcache) ++ nntp_data->bcache = mutt_bcache_open (&nntp_data->nserv->conn->account, ++ nntp_data->group); ++ if (nntp_data->bcache) ++ { ++ dprint (2, (debugfile, "nntp_delete_group_cache: %s/*\n", nntp_data->group)); ++ mutt_bcache_list (nntp_data->bcache, nntp_bcache_delete, NULL); ++ mutt_bcache_close (&nntp_data->bcache); ++ } ++} ++ ++/* Remove hcache and bcache of all unexistent and unsubscribed newsgroups */ ++void nntp_clear_cache (NNTP_SERVER *nserv) ++{ ++ char file[_POSIX_PATH_MAX]; ++ char *fp; ++ struct dirent *entry; ++ DIR *dp; ++ ++ if (!nserv || !nserv->cacheable) ++ return; ++ ++ cache_expand (file, sizeof (file), &nserv->conn->account, NULL); ++ dp = opendir (file); ++ if (dp) ++ { ++ safe_strncat (file, sizeof (file), "/", 1); ++ fp = file + strlen (file); ++ while ((entry = readdir (dp))) ++ { ++ char *group = entry->d_name; ++ struct stat sb; ++ NNTP_DATA *nntp_data; ++ NNTP_DATA nntp_tmp; ++ ++ if (mutt_strcmp (group, ".") == 0 || ++ mutt_strcmp (group, "..") == 0) ++ continue; ++ *fp = '\0'; ++ safe_strncat (file, sizeof (file), group, strlen (group)); ++ if (stat (file, &sb)) ++ continue; ++ ++#ifdef USE_HCACHE ++ if (S_ISREG (sb.st_mode)) ++ { ++ char *ext = group + strlen (group) - 7; ++ if (strlen (group) < 8 || mutt_strcmp (ext, ".hcache")) ++ continue; ++ *ext = '\0'; ++ } ++ else ++#endif ++ if (!S_ISDIR (sb.st_mode)) ++ continue; ++ ++ nntp_data = hash_find (nserv->groups_hash, group); ++ if (!nntp_data) ++ { ++ nntp_data = &nntp_tmp; ++ nntp_data->nserv = nserv; ++ nntp_data->group = group; ++ nntp_data->bcache = NULL; ++ } ++ else if (nntp_data->newsrc_ent || nntp_data->subscribed || ++ option (OPTSAVEUNSUB)) ++ continue; ++ ++ nntp_delete_group_cache (nntp_data); ++ if (S_ISDIR (sb.st_mode)) ++ { ++ rmdir (file); ++ dprint (2, (debugfile, "nntp_clear_cache: %s\n", file)); ++ } ++ } ++ closedir (dp); ++ } ++ return; ++} ++ ++/* %a = account url ++ * %p = port ++ * %P = port if specified ++ * %s = news server name ++ * %S = url schema ++ * %u = username */ ++const char * ++nntp_format_str (char *dest, size_t destlen, size_t col, char op, const char *src, ++ const char *fmt, const char *ifstring, const char *elsestring, ++ unsigned long data, format_flag flags) ++{ ++ NNTP_SERVER *nserv = (NNTP_SERVER *)data; ++ ACCOUNT *acct = &nserv->conn->account; ++ ciss_url_t url; ++ char fn[SHORT_STRING], tmp[SHORT_STRING], *p; ++ ++ switch (op) ++ { ++ case 'a': ++ mutt_account_tourl (acct, &url); ++ url_ciss_tostring (&url, fn, sizeof (fn), U_PATH); ++ p = strchr (fn, '/'); ++ if (p) ++ *p = '\0'; ++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); ++ snprintf (dest, destlen, tmp, fn); ++ break; ++ case 'p': ++ snprintf (tmp, sizeof (tmp), "%%%su", fmt); ++ snprintf (dest, destlen, tmp, acct->port); ++ break; ++ case 'P': ++ *dest = '\0'; ++ if (acct->flags & M_ACCT_PORT) ++ { ++ snprintf (tmp, sizeof (tmp), "%%%su", fmt); ++ snprintf (dest, destlen, tmp, acct->port); ++ } ++ break; ++ case 's': ++ strncpy (fn, acct->host, sizeof (fn) - 1); ++ mutt_strlower (fn); ++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); ++ snprintf (dest, destlen, tmp, fn); ++ break; ++ case 'S': ++ mutt_account_tourl (acct, &url); ++ url_ciss_tostring (&url, fn, sizeof (fn), U_PATH); ++ p = strchr (fn, ':'); ++ if (p) ++ *p = '\0'; ++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); ++ snprintf (dest, destlen, tmp, fn); ++ break; ++ case 'u': ++ snprintf (tmp, sizeof (tmp), "%%%ss", fmt); ++ snprintf (dest, destlen, tmp, acct->user); ++ break; ++ } ++ return (src); ++} ++ ++/* Automatically loads a newsrc into memory, if necessary. ++ * Checks the size/mtime of a newsrc file, if it doesn't match, load ++ * again. Hmm, if a system has broken mtimes, this might mean the file ++ * is reloaded every time, which we'd have to fix. */ ++NNTP_SERVER *nntp_select_server (char *server, int leave_lock) ++{ ++ char file[_POSIX_PATH_MAX]; ++ char *p; ++ int rc; ++ struct stat sb; ++ ACCOUNT acct; ++ NNTP_SERVER *nserv; ++ NNTP_DATA *nntp_data; ++ CONNECTION *conn; ++ ciss_url_t url; ++ ++ if (!server || !*server) ++ { ++ mutt_error _("No news server defined!"); ++ mutt_sleep (2); ++ return NULL; ++ } ++ ++ /* create account from news server url */ ++ acct.flags = 0; ++ acct.port = NNTP_PORT; ++ acct.type = M_ACCT_TYPE_NNTP; ++ snprintf (file, sizeof (file), "%s%s", ++ strstr (server, "://") ? "" : "news://", server); ++ if (url_parse_ciss (&url, file) < 0 || ++ (url.path && *url.path) || ++ !(url.scheme == U_NNTP || url.scheme == U_NNTPS) || ++ mutt_account_fromurl (&acct, &url) < 0) ++ { ++ mutt_error (_("%s is an invalid news server specification!"), server); ++ mutt_sleep (2); ++ return NULL; ++ } ++ if (url.scheme == U_NNTPS) ++ { ++ acct.flags |= M_ACCT_SSL; ++ acct.port = NNTP_SSL_PORT; ++ } ++ ++ /* find connection by account */ ++ conn = mutt_conn_find (NULL, &acct); ++ if (!conn) ++ return NULL; ++ if (!(conn->account.flags & M_ACCT_USER) && acct.flags & M_ACCT_USER) ++ { ++ conn->account.flags |= M_ACCT_USER; ++ conn->account.user[0] = '\0'; ++ } ++ ++ /* news server already exists */ ++ nserv = conn->data; ++ if (nserv) ++ { ++ if (nserv->status == NNTP_BYE) ++ nserv->status = NNTP_NONE; ++ if (nntp_open_connection (nserv) < 0) ++ return NULL; ++ ++ rc = nntp_newsrc_parse (nserv); ++ if (rc < 0) ++ return NULL; ++ ++ /* check for new newsgroups */ ++ if (!leave_lock && nntp_check_new_groups (nserv) < 0) ++ rc = -1; ++ ++ /* .newsrc has been externally modified */ ++ if (rc > 0) ++ nntp_clear_cache (nserv); ++ if (rc < 0 || !leave_lock) ++ nntp_newsrc_close (nserv); ++ return rc < 0 ? NULL : nserv; ++ } ++ ++ /* new news server */ ++ nserv = safe_calloc (1, sizeof (NNTP_SERVER)); ++ nserv->conn = conn; ++ nserv->groups_hash = hash_create (1009, 0); ++ nserv->groups_max = 16; ++ nserv->groups_list = safe_malloc (nserv->groups_max * sizeof (nntp_data)); ++ ++ rc = nntp_open_connection (nserv); ++ ++ /* try to create cache directory and enable caching */ ++ nserv->cacheable = 0; ++ if (rc >= 0 && NewsCacheDir && *NewsCacheDir) ++ { ++ cache_expand (file, sizeof (file), &conn->account, NULL); ++ p = *file == '/' ? file + 1 : file; ++ while (1) ++ { ++ p = strchr (p, '/'); ++ if (p) ++ *p = '\0'; ++ if ((stat (file, &sb) || (sb.st_mode & S_IFDIR) == 0) && ++ mkdir (file, 0700)) ++ { ++ mutt_error (_("Can't create %s: %s."), file, strerror (errno)); ++ mutt_sleep (2); ++ break; ++ } ++ if (!p) ++ { ++ nserv->cacheable = 1; ++ break; ++ } ++ *p++ = '/'; ++ } ++ } ++ ++ /* load .newsrc */ ++ if (rc >= 0) ++ { ++ mutt_FormatString (file, sizeof (file), 0, NONULL (NewsRc), ++ nntp_format_str, (unsigned long)nserv, 0); ++ mutt_expand_path (file, sizeof (file)); ++ nserv->newsrc_file = safe_strdup (file); ++ rc = nntp_newsrc_parse (nserv); ++ } ++ if (rc >= 0) ++ { ++ /* try to load list of newsgroups from cache */ ++ if (nserv->cacheable && active_get_cache (nserv) == 0) ++ rc = nntp_check_new_groups (nserv); ++ ++ /* load list of newsgroups from server */ ++ else ++ rc = nntp_active_fetch (nserv); ++ } ++ ++ if (rc >= 0) ++ nntp_clear_cache (nserv); ++ ++#ifdef USE_HCACHE ++ /* check cache files */ ++ if (rc >= 0 && nserv->cacheable) ++ { ++ struct dirent *entry; ++ DIR *dp = opendir (file); ++ ++ if (dp) ++ { ++ while ((entry = readdir (dp))) ++ { ++ header_cache_t *hc; ++ void *hdata; ++ char *group = entry->d_name; ++ ++ p = group + strlen (group) - 7; ++ if (strlen (group) < 8 || strcmp (p, ".hcache")) ++ continue; ++ *p = '\0'; ++ nntp_data = hash_find (nserv->groups_hash, group); ++ if (!nntp_data) ++ continue; ++ ++ hc = nntp_hcache_open (nntp_data); ++ if (!hc) ++ continue; ++ ++ /* fetch previous values of first and last */ ++ hdata = mutt_hcache_fetch_raw (hc, "index", strlen); ++ if (hdata) ++ { ++ anum_t first, last; ++ ++ if (sscanf (hdata, ANUM " " ANUM, &first, &last) == 2) ++ { ++ if (nntp_data->deleted) ++ { ++ nntp_data->firstMessage = first; ++ nntp_data->lastMessage = last; ++ } ++ if (last >= nntp_data->firstMessage && ++ last <= nntp_data->lastMessage) ++ { ++ nntp_data->lastCached = last; ++ dprint (2, (debugfile, "nntp_select_server: %s lastCached=%u\n", ++ nntp_data->group, last)); ++ } ++ } ++ } ++ mutt_hcache_close (hc); ++ } ++ closedir (dp); ++ } ++ } ++#endif ++ ++ if (rc < 0 || !leave_lock) ++ nntp_newsrc_close (nserv); ++ ++ if (rc < 0) ++ { ++ hash_destroy (&nserv->groups_hash, nntp_data_free); ++ FREE (&nserv->groups_list); ++ FREE (&nserv->newsrc_file); ++ FREE (&nserv->authenticators); ++ FREE (&nserv); ++ mutt_socket_close (conn); ++ mutt_socket_free (conn); ++ return NULL; ++ } ++ ++ conn->data = nserv; ++ return nserv; ++} ++ ++/* Full status flags are not supported by nntp, but we can fake some of them: ++ * Read = a read message number is in the .newsrc ++ * New = not read and not cached ++ * Old = not read but cached */ ++void nntp_article_status (CONTEXT *ctx, HEADER *hdr, char *group, anum_t anum) ++{ ++ NNTP_DATA *nntp_data = ctx->data; ++ unsigned int i; ++ ++ if (group) ++ nntp_data = hash_find (nntp_data->nserv->groups_hash, group); ++ ++ if (!nntp_data) ++ return; ++ ++ for (i = 0; i < nntp_data->newsrc_len; i++) ++ { ++ if ((anum >= nntp_data->newsrc_ent[i].first) && ++ (anum <= nntp_data->newsrc_ent[i].last)) ++ { ++ /* can't use mutt_set_flag() because mx_update_context() ++ didn't called yet */ ++ hdr->read = 1; ++ return; ++ } ++ } ++ ++ /* article was not cached yet, it's new */ ++ if (anum > nntp_data->lastCached) ++ return; ++ ++ /* article isn't read but cached, it's old */ ++ if (option (OPTMARKOLD)) ++ hdr->old = 1; ++} ++ ++/* calculate number of unread articles using .newsrc data */ ++void nntp_group_unread_stat (NNTP_DATA *nntp_data) ++{ ++ unsigned int i; ++ anum_t first, last; ++ ++ nntp_data->unread = 0; ++ if (nntp_data->lastMessage == 0 || ++ nntp_data->firstMessage > nntp_data->lastMessage) ++ return; ++ ++ nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1; ++ for (i = 0; i < nntp_data->newsrc_len; i++) ++ { ++ first = nntp_data->newsrc_ent[i].first; ++ if (first < nntp_data->firstMessage) ++ first = nntp_data->firstMessage; ++ last = nntp_data->newsrc_ent[i].last; ++ if (last > nntp_data->lastMessage) ++ last = nntp_data->lastMessage; ++ if (first <= last) ++ nntp_data->unread -= last - first + 1; ++ } ++} ++ ++/* Subscribe newsgroup */ ++NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *nserv, char *group) ++{ ++ NNTP_DATA *nntp_data; ++ ++ if (!nserv || !nserv->groups_hash || !group || !*group) ++ return NULL; ++ ++ nntp_data = nntp_data_find (nserv, group); ++ nntp_data->subscribed = 1; ++ if (!nntp_data->newsrc_ent) ++ { ++ nntp_data->newsrc_ent = safe_calloc (1, sizeof (NEWSRC_ENTRY)); ++ nntp_data->newsrc_len = 1; ++ nntp_data->newsrc_ent[0].first = 1; ++ nntp_data->newsrc_ent[0].last = 0; ++ } ++ return nntp_data; ++} ++ ++/* Unsubscribe newsgroup */ ++NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *nserv, char *group) ++{ ++ NNTP_DATA *nntp_data; ++ ++ if (!nserv || !nserv->groups_hash || !group || !*group) ++ return NULL; ++ ++ nntp_data = hash_find (nserv->groups_hash, group); ++ if (!nntp_data) ++ return NULL; ++ ++ nntp_data->subscribed = 0; ++ if (!option (OPTSAVEUNSUB)) ++ { ++ nntp_data->newsrc_len = 0; ++ FREE (&nntp_data->newsrc_ent); ++ } ++ return nntp_data; ++} ++ ++/* Catchup newsgroup */ ++NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *nserv, char *group) ++{ ++ NNTP_DATA *nntp_data; ++ ++ if (!nserv || !nserv->groups_hash || !group || !*group) ++ return NULL; ++ ++ nntp_data = hash_find (nserv->groups_hash, group); ++ if (!nntp_data) ++ return NULL; ++ ++ if (nntp_data->newsrc_ent) ++ { ++ safe_realloc (&nntp_data->newsrc_ent, sizeof (NEWSRC_ENTRY)); ++ nntp_data->newsrc_len = 1; ++ nntp_data->newsrc_ent[0].first = 1; ++ nntp_data->newsrc_ent[0].last = nntp_data->lastMessage; ++ } ++ nntp_data->unread = 0; ++ if (Context && Context->data == nntp_data) ++ { ++ unsigned int i; ++ ++ for (i = 0; i < Context->msgcount; i++) ++ mutt_set_flag (Context, Context->hdrs[i], M_READ, 1); ++ } ++ return nntp_data; ++} ++ ++/* Uncatchup newsgroup */ ++NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *nserv, char *group) ++{ ++ NNTP_DATA *nntp_data; ++ ++ if (!nserv || !nserv->groups_hash || !group || !*group) ++ return NULL; ++ ++ nntp_data = hash_find (nserv->groups_hash, group); ++ if (!nntp_data) ++ return NULL; ++ ++ if (nntp_data->newsrc_ent) ++ { ++ safe_realloc (&nntp_data->newsrc_ent, sizeof (NEWSRC_ENTRY)); ++ nntp_data->newsrc_len = 1; ++ nntp_data->newsrc_ent[0].first = 1; ++ nntp_data->newsrc_ent[0].last = nntp_data->firstMessage - 1; ++ } ++ if (Context && Context->data == nntp_data) ++ { ++ unsigned int i; ++ ++ nntp_data->unread = Context->msgcount; ++ for (i = 0; i < Context->msgcount; i++) ++ mutt_set_flag (Context, Context->hdrs[i], M_READ, 0); ++ } ++ else ++ nntp_data->unread = nntp_data->lastMessage - nntp_data->newsrc_ent[0].last; ++ return nntp_data; ++} ++ ++/* Get first newsgroup with new messages */ ++void nntp_buffy (char *buf, size_t len) ++{ ++ unsigned int i; ++ ++ for (i = 0; i < CurrentNewsSrv->groups_num; i++) ++ { ++ NNTP_DATA *nntp_data = CurrentNewsSrv->groups_list[i]; ++ ++ if (!nntp_data || !nntp_data->subscribed || !nntp_data->unread) ++ continue; ++ ++ if (Context && Context->magic == M_NNTP && ++ !mutt_strcmp (nntp_data->group, ((NNTP_DATA *)Context->data)->group)) ++ { ++ unsigned int i, unread = 0; ++ ++ for (i = 0; i < Context->msgcount; i++) ++ if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted) ++ unread++; ++ if (!unread) ++ continue; ++ } ++ strfcpy (buf, nntp_data->group, len); ++ break; ++ } ++} +diff -udprP mutt-1.5.23.orig/nntp.c mutt-1.5.23/nntp.c +--- mutt-1.5.23.orig/nntp.c 1970-01-01 03:00:00.000000000 +0300 ++++ mutt-1.5.23/nntp.c 2014-03-13 12:50:04.000000000 +0200 +@@ -0,0 +1,2404 @@ ++/* ++ * Copyright (C) 1998 Brandon Long <blong@fiction.net> ++ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net> ++ * Copyright (C) 2000-2012 Vsevolod Volkov <vvv@mutt.org.ua> ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++ */ ++ ++#if HAVE_CONFIG_H ++#include "config.h" ++#endif ++ ++#include "mutt.h" ++#include "mutt_curses.h" ++#include "sort.h" ++#include "mx.h" ++#include "mime.h" ++#include "rfc1524.h" ++#include "rfc2047.h" ++#include "mailbox.h" ++#include "mutt_crypt.h" ++#include "nntp.h" ++ ++#if defined(USE_SSL) ++#include "mutt_ssl.h" ++#endif ++ ++#ifdef HAVE_PGP ++#include "pgp.h" ++#endif ++ ++#ifdef HAVE_SMIME ++#include "smime.h" ++#endif ++ ++#if USE_HCACHE ++#include "hcache.h" ++#endif ++ ++#include <unistd.h> ++#include <string.h> ++#include <ctype.h> ++#include <stdlib.h> ++ ++#ifdef USE_SASL ++#include <sasl/sasl.h> ++#include <sasl/saslutil.h> ++ ++#include "mutt_sasl.h" ++#endif ++ ++static int nntp_connect_error (NNTP_SERVER *nserv) ++{ ++ nserv->status = NNTP_NONE; ++ mutt_error _("Server closed connection!"); ++ mutt_sleep (2); ++ return -1; ++} ++ ++/* Get capabilities: ++ * -1 - error, connection is closed ++ * 0 - mode is reader, capabilities setted up ++ * 1 - need to switch to reader mode */ ++static int nntp_capabilities (NNTP_SERVER *nserv) ++{ ++ CONNECTION *conn = nserv->conn; ++ unsigned int mode_reader = 0; ++ char buf[LONG_STRING]; ++ char authinfo[LONG_STRING] = ""; ++ ++ nserv->hasCAPABILITIES = 0; ++ nserv->hasSTARTTLS = 0; ++ nserv->hasDATE = 0; ++ nserv->hasLIST_NEWSGROUPS = 0; ++ nserv->hasLISTGROUP = 0; ++ nserv->hasOVER = 0; ++ FREE (&nserv->authenticators); ++ ++ if (mutt_socket_write (conn, "CAPABILITIES\r\n") < 0 || ++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ ++ /* no capabilities */ ++ if (mutt_strncmp ("101", buf, 3)) ++ return 1; ++ nserv->hasCAPABILITIES = 1; ++ ++ /* parse capabilities */ ++ do ++ { ++ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ if (!mutt_strcmp ("STARTTLS", buf)) ++ nserv->hasSTARTTLS = 1; ++ else if (!mutt_strcmp ("MODE-READER", buf)) ++ mode_reader = 1; ++ else if (!mutt_strcmp ("READER", buf)) ++ { ++ nserv->hasDATE = 1; ++ nserv->hasLISTGROUP = 1; ++ } ++ else if (!mutt_strncmp ("AUTHINFO ", buf, 9)) ++ { ++ safe_strcat (buf, sizeof (buf), " "); ++ strfcpy (authinfo, buf + 8, sizeof (authinfo)); ++ } ++#ifdef USE_SASL ++ else if (!mutt_strncmp ("SASL ", buf, 5)) ++ { ++ char *p = buf + 5; ++ while (*p == ' ') ++ p++; ++ nserv->authenticators = safe_strdup (p); ++ } ++#endif ++ else if (!mutt_strcmp ("OVER", buf)) ++ nserv->hasOVER = 1; ++ else if (!mutt_strncmp ("LIST ", buf, 5)) ++ { ++ char *p = strstr (buf, " NEWSGROUPS"); ++ if (p) ++ { ++ p += 11; ++ if (*p == '\0' || *p == ' ') ++ nserv->hasLIST_NEWSGROUPS = 1; ++ } ++ } ++ } while (mutt_strcmp (".", buf)); ++ *buf = '\0'; ++#ifdef USE_SASL ++ if (nserv->authenticators && strcasestr (authinfo, " SASL ")) ++ strfcpy (buf, nserv->authenticators, sizeof (buf)); ++#endif ++ if (strcasestr (authinfo, " USER ")) ++ { ++ if (*buf) ++ safe_strcat (buf, sizeof (buf), " "); ++ safe_strcat (buf, sizeof (buf), "USER"); ++ } ++ mutt_str_replace (&nserv->authenticators, buf); ++ ++ /* current mode is reader */ ++ if (nserv->hasLISTGROUP) ++ return 0; ++ ++ /* server is mode-switching, need to switch to reader mode */ ++ if (mode_reader) ++ return 1; ++ ++ mutt_socket_close (conn); ++ nserv->status = NNTP_BYE; ++ mutt_error _("Server doesn't support reader mode."); ++ mutt_sleep (2); ++ return -1; ++} ++ ++char *OverviewFmt = ++ "Subject:\0" ++ "From:\0" ++ "Date:\0" ++ "Message-ID:\0" ++ "References:\0" ++ "Content-Length:\0" ++ "Lines:\0" ++ "\0"; ++ ++/* Detect supported commands */ ++static int nntp_attempt_features (NNTP_SERVER *nserv) ++{ ++ CONNECTION *conn = nserv->conn; ++ char buf[LONG_STRING]; ++ ++ /* no CAPABILITIES, trying DATE, LISTGROUP, LIST NEWSGROUPS */ ++ if (!nserv->hasCAPABILITIES) ++ { ++ if (mutt_socket_write (conn, "DATE\r\n") < 0 || ++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ if (mutt_strncmp ("500", buf, 3)) ++ nserv->hasDATE = 1; ++ ++ if (mutt_socket_write (conn, "LISTGROUP\r\n") < 0 || ++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ if (mutt_strncmp ("500", buf, 3)) ++ nserv->hasLISTGROUP = 1; ++ ++ if (mutt_socket_write (conn, "LIST NEWSGROUPS +\r\n") < 0 || ++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ if (mutt_strncmp ("500", buf, 3)) ++ nserv->hasLIST_NEWSGROUPS = 1; ++ if (!mutt_strncmp ("215", buf, 3)) ++ { ++ do ++ { ++ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ } while (mutt_strcmp (".", buf)); ++ } ++ } ++ ++ /* no LIST NEWSGROUPS, trying XGTITLE */ ++ if (!nserv->hasLIST_NEWSGROUPS) ++ { ++ if (mutt_socket_write (conn, "XGTITLE\r\n") < 0 || ++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ if (mutt_strncmp ("500", buf, 3)) ++ nserv->hasXGTITLE = 1; ++ } ++ ++ /* no OVER, trying XOVER */ ++ if (!nserv->hasOVER) ++ { ++ if (mutt_socket_write (conn, "XOVER\r\n") < 0 || ++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ if (mutt_strncmp ("500", buf, 3)) ++ nserv->hasXOVER = 1; ++ } ++ ++ /* trying LIST OVERVIEW.FMT */ ++ if (nserv->hasOVER || nserv->hasXOVER) ++ { ++ if (mutt_socket_write (conn, "LIST OVERVIEW.FMT\r\n") < 0 || ++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ if (mutt_strncmp ("215", buf, 3)) ++ nserv->overview_fmt = OverviewFmt; ++ else ++ { ++ int chunk, cont = 0; ++ size_t buflen = 2 * LONG_STRING, off = 0, b = 0; ++ ++ if (nserv->overview_fmt) ++ FREE (&nserv->overview_fmt); ++ nserv->overview_fmt = safe_malloc (buflen); ++ ++ while (1) ++ { ++ if (buflen - off < LONG_STRING) ++ { ++ buflen *= 2; ++ safe_realloc (&nserv->overview_fmt, buflen); ++ } ++ ++ chunk = mutt_socket_readln (nserv->overview_fmt + off, ++ buflen - off, conn); ++ if (chunk < 0) ++ { ++ FREE (&nserv->overview_fmt); ++ return nntp_connect_error (nserv); ++ } ++ ++ if (!cont && !mutt_strcmp (".", nserv->overview_fmt + off)) ++ break; ++ ++ cont = chunk >= buflen - off ? 1 : 0; ++ off += strlen (nserv->overview_fmt + off); ++ if (!cont) ++ { ++ char *colon; ++ ++ if (nserv->overview_fmt[b] == ':') ++ { ++ memmove (nserv->overview_fmt + b, ++ nserv->overview_fmt + b + 1, off - b - 1); ++ nserv->overview_fmt[off - 1] = ':'; ++ } ++ colon = strchr (nserv->overview_fmt + b, ':'); ++ if (!colon) ++ nserv->overview_fmt[off++] = ':'; ++ else if (strcmp (colon + 1, "full")) ++ off = colon + 1 - nserv->overview_fmt; ++ if (!strcasecmp (nserv->overview_fmt + b, "Bytes:")) ++ { ++ strcpy (nserv->overview_fmt + b, "Content-Length:"); ++ off = b + strlen (nserv->overview_fmt + b); ++ } ++ nserv->overview_fmt[off++] = '\0'; ++ b = off; ++ } ++ } ++ nserv->overview_fmt[off++] = '\0'; ++ safe_realloc (&nserv->overview_fmt, off); ++ } ++ } ++ return 0; ++} ++ ++/* Get login, password and authenticate */ ++static int nntp_auth (NNTP_SERVER *nserv) ++{ ++ CONNECTION *conn = nserv->conn; ++ char buf[LONG_STRING]; ++ char authenticators[LONG_STRING] = "USER"; ++ char *method, *a, *p; ++ unsigned char flags = conn->account.flags; ++ ++ while (1) ++ { ++ /* get login and password */ ++ if (mutt_account_getuser (&conn->account) || !conn->account.user[0] || ++ mutt_account_getpass (&conn->account) || !conn->account.pass[0]) ++ break; ++ ++ /* get list of authenticators */ ++ if (NntpAuthenticators && *NntpAuthenticators) ++ strfcpy (authenticators, NntpAuthenticators, sizeof (authenticators)); ++ else if (nserv->hasCAPABILITIES) ++ { ++ strfcpy (authenticators, NONULL (nserv->authenticators), ++ sizeof (authenticators)); ++ p = authenticators; ++ while (*p) ++ { ++ if (*p == ' ') ++ *p = ':'; ++ p++; ++ } ++ } ++ p = authenticators; ++ while (*p) ++ { ++ *p = ascii_toupper (*p); ++ p++; ++ } ++ ++ dprint (1, (debugfile, ++ "nntp_auth: available methods: %s\n", nserv->authenticators)); ++ a = authenticators; ++ while (1) ++ { ++ if (!a) ++ { ++ mutt_error _("No authenticators available"); ++ mutt_sleep (2); ++ break; ++ } ++ ++ method = a; ++ a = strchr (a, ':'); ++ if (a) ++ *a++ = '\0'; ++ ++ /* check authenticator */ ++ if (nserv->hasCAPABILITIES) ++ { ++ char *m; ++ ++ if (!nserv->authenticators) ++ continue; ++ m = strcasestr (nserv->authenticators, method); ++ if (!m) ++ continue; ++ if (m > nserv->authenticators && *(m - 1) != ' ') ++ continue; ++ m += strlen (method); ++ if (*m != '\0' && *m != ' ') ++ continue; ++ } ++ dprint (1, (debugfile, "nntp_auth: trying method %s\n", method)); ++ ++ /* AUTHINFO USER authentication */ ++ if (!strcmp (method, "USER")) ++ { ++ mutt_message (_("Authenticating (%s)..."), method); ++ snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user); ++ if (mutt_socket_write (conn, buf) < 0 || ++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ break; ++ ++ /* authenticated, password is not required */ ++ if (!mutt_strncmp ("281", buf, 3)) ++ return 0; ++ ++ /* username accepted, sending password */ ++ if (!mutt_strncmp ("381", buf, 3)) ++ { ++#ifdef DEBUG ++ if (debuglevel < M_SOCK_LOG_FULL) ++ dprint (M_SOCK_LOG_CMD, (debugfile, ++ "%d> AUTHINFO PASS *\n", conn->fd)); ++#endif ++ snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", ++ conn->account.pass); ++ if (mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL) < 0 || ++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ break; ++ ++ /* authenticated */ ++ if (!mutt_strncmp ("281", buf, 3)) ++ return 0; ++ } ++ ++ /* server doesn't support AUTHINFO USER, trying next method */ ++ if (*buf == '5') ++ continue; ++ } ++ ++ else ++ { ++#ifdef USE_SASL ++ sasl_conn_t *saslconn; ++ sasl_interact_t *interaction = NULL; ++ int rc; ++ char inbuf[LONG_STRING] = ""; ++ const char *mech; ++ const char *client_out = NULL; ++ unsigned int client_len, len; ++ ++ if (mutt_sasl_client_new (conn, &saslconn) < 0) ++ { ++ dprint (1, (debugfile, ++ "nntp_auth: error allocating SASL connection.\n")); ++ continue; ++ } ++ ++ while (1) ++ { ++ rc = sasl_client_start (saslconn, method, &interaction, ++ &client_out, &client_len, &mech); ++ if (rc != SASL_INTERACT) ++ break; ++ mutt_sasl_interact (interaction); ++ } ++ if (rc != SASL_OK && rc != SASL_CONTINUE) ++ { ++ sasl_dispose (&saslconn); ++ dprint (1, (debugfile, ++ "nntp_auth: error starting SASL authentication exchange.\n")); ++ continue; ++ } ++ ++ mutt_message (_("Authenticating (%s)..."), method); ++ snprintf (buf, sizeof (buf), "AUTHINFO SASL %s", method); ++ ++ /* looping protocol */ ++ while (rc == SASL_CONTINUE || (rc == SASL_OK && client_len)) ++ { ++ /* send out client response */ ++ if (client_len) ++ { ++#ifdef DEBUG ++ if (debuglevel >= M_SOCK_LOG_FULL) ++ { ++ char tmp[LONG_STRING]; ++ memcpy (tmp, client_out, client_len); ++ for (p = tmp; p < tmp + client_len; p++) ++ { ++ if (*p == '\0') ++ *p = '.'; ++ } ++ *p = '\0'; ++ dprint (1, (debugfile, "SASL> %s\n", tmp)); ++ } ++#endif ++ ++ if (*buf) ++ safe_strcat (buf, sizeof (buf), " "); ++ len = strlen (buf); ++ if (sasl_encode64 (client_out, client_len, ++ buf + len, sizeof (buf) - len, &len) != SASL_OK) ++ { ++ dprint (1, (debugfile, ++ "nntp_auth: error base64-encoding client response.\n")); ++ break; ++ } ++ } ++ ++ safe_strcat (buf, sizeof (buf), "\r\n"); ++#ifdef DEBUG ++ if (debuglevel < M_SOCK_LOG_FULL) ++ { ++ if (strchr (buf, ' ')) ++ dprint (M_SOCK_LOG_CMD, (debugfile, "%d> AUTHINFO SASL %s%s\n", ++ conn->fd, method, client_len ? " sasl_data" : "")); ++ else ++ dprint (M_SOCK_LOG_CMD, (debugfile, "%d> sasl_data\n", conn->fd)); ++ } ++#endif ++ client_len = 0; ++ if (mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL) < 0 || ++ mutt_socket_readln_d (inbuf, sizeof (inbuf), conn, M_SOCK_LOG_FULL) < 0) ++ break; ++ if (mutt_strncmp (inbuf, "283 ", 4) && ++ mutt_strncmp (inbuf, "383 ", 4)) ++ { ++#ifdef DEBUG ++ if (debuglevel < M_SOCK_LOG_FULL) ++ dprint (M_SOCK_LOG_CMD, (debugfile, "%d< %s\n", conn->fd, inbuf)); ++#endif ++ break; ++ } ++#ifdef DEBUG ++ if (debuglevel < M_SOCK_LOG_FULL) ++ { ++ inbuf[3] = '\0'; ++ dprint (M_SOCK_LOG_CMD, (debugfile, ++ "%d< %s sasl_data\n", conn->fd, inbuf)); ++ } ++#endif ++ ++ if (!strcmp ("=", inbuf + 4)) ++ len = 0; ++ else if (sasl_decode64 (inbuf + 4, strlen (inbuf + 4), ++ buf, sizeof (buf) - 1, &len) != SASL_OK) ++ { ++ dprint (1, (debugfile, ++ "nntp_auth: error base64-decoding server response.\n")); ++ break; ++ } ++#ifdef DEBUG ++ else if (debuglevel >= M_SOCK_LOG_FULL) ++ { ++ char tmp[LONG_STRING]; ++ memcpy (tmp, buf, len); ++ for (p = tmp; p < tmp + len; p++) ++ { ++ if (*p == '\0') ++ *p = '.'; ++ } ++ *p = '\0'; ++ dprint (1, (debugfile, "SASL< %s\n", tmp)); ++ } ++#endif ++ ++ while (1) ++ { ++ rc = sasl_client_step (saslconn, buf, len, ++ &interaction, &client_out, &client_len); ++ if (rc != SASL_INTERACT) ++ break; ++ mutt_sasl_interact (interaction); ++ } ++ if (*inbuf != '3') ++ break; ++ ++ *buf = '\0'; ++ } /* looping protocol */ ++ ++ if (rc == SASL_OK && client_len == 0 && *inbuf == '2') ++ { ++ mutt_sasl_setup_conn (conn, saslconn); ++ return 0; ++ } ++ ++ /* terminate SASL sessoin */ ++ sasl_dispose (&saslconn); ++ if (conn->fd < 0) ++ break; ++ if (!mutt_strncmp (inbuf, "383 ", 4)) ++ { ++ if (mutt_socket_write (conn, "*\r\n") < 0 || ++ mutt_socket_readln (inbuf, sizeof (inbuf), conn) < 0) ++ break; ++ } ++ ++ /* server doesn't support AUTHINFO SASL, trying next method */ ++ if (*inbuf == '5') ++ continue; ++#else ++ continue; ++#endif /* USE_SASL */ ++ } ++ ++ mutt_error (_("%s authentication failed."), method); ++ mutt_sleep (2); ++ break; ++ } ++ break; ++ } ++ ++ /* error */ ++ nserv->status = NNTP_BYE; ++ conn->account.flags = flags; ++ if (conn->fd < 0) ++ { ++ mutt_error _("Server closed connection!"); ++ mutt_sleep (2); ++ } ++ else ++ mutt_socket_close (conn); ++ return -1; ++} ++ ++/* Connect to server, authenticate and get capabilities */ ++int nntp_open_connection (NNTP_SERVER *nserv) ++{ ++ CONNECTION *conn = nserv->conn; ++ char buf[STRING]; ++ int cap; ++ unsigned int posting = 0, auth = 1; ++ ++ if (nserv->status == NNTP_OK) ++ return 0; ++ if (nserv->status == NNTP_BYE) ++ return -1; ++ nserv->status = NNTP_NONE; ++ ++ if (mutt_socket_open (conn) < 0) ++ return -1; ++ ++ if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ ++ if (!mutt_strncmp ("200", buf, 3)) ++ posting = 1; ++ else if (mutt_strncmp ("201", buf, 3)) ++ { ++ mutt_socket_close (conn); ++ mutt_remove_trailing_ws (buf); ++ mutt_error ("%s", buf); ++ mutt_sleep (2); ++ return -1; ++ } ++ ++ /* get initial capabilities */ ++ cap = nntp_capabilities (nserv); ++ if (cap < 0) ++ return -1; ++ ++ /* tell news server to switch to mode reader if it isn't so */ ++ if (cap > 0) ++ { ++ if (mutt_socket_write (conn, "MODE READER\r\n") < 0 || ++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ ++ if (!mutt_strncmp ("200", buf, 3)) ++ posting = 1; ++ else if (!mutt_strncmp ("201", buf, 3)) ++ posting = 0; ++ /* error if has capabilities, ignore result if no capabilities */ ++ else if (nserv->hasCAPABILITIES) ++ { ++ mutt_socket_close (conn); ++ mutt_error _("Could not switch to reader mode."); ++ mutt_sleep (2); ++ return -1; ++ } ++ ++ /* recheck capabilities after MODE READER */ ++ if (nserv->hasCAPABILITIES) ++ { ++ cap = nntp_capabilities (nserv); ++ if (cap < 0) ++ return -1; ++ } ++ } ++ ++ mutt_message (_("Connected to %s. %s"), conn->account.host, ++ posting ? _("Posting is ok.") : _("Posting is NOT ok.")); ++ mutt_sleep (1); ++ ++#if defined(USE_SSL) ++ /* Attempt STARTTLS if available and desired. */ ++ if (nserv->use_tls != 1 && (nserv->hasSTARTTLS || option (OPTSSLFORCETLS))) ++ { ++ if (nserv->use_tls == 0) ++ nserv->use_tls = option (OPTSSLFORCETLS) || ++ query_quadoption (OPT_SSLSTARTTLS, ++ _("Secure connection with TLS?")) == M_YES ? 2 : 1; ++ if (nserv->use_tls == 2) ++ { ++ if (mutt_socket_write (conn, "STARTTLS\r\n") < 0 || ++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ if (mutt_strncmp ("382", buf, 3)) ++ { ++ nserv->use_tls = 0; ++ mutt_error ("STARTTLS: %s", buf); ++ mutt_sleep (2); ++ } ++ else if (mutt_ssl_starttls (conn)) ++ { ++ nserv->use_tls = 0; ++ nserv->status = NNTP_NONE; ++ mutt_socket_close (nserv->conn); ++ mutt_error _("Could not negotiate TLS connection"); ++ mutt_sleep (2); ++ return -1; ++ } ++ else ++ { ++ /* recheck capabilities after STARTTLS */ ++ cap = nntp_capabilities (nserv); ++ if (cap < 0) ++ return -1; ++ } ++ } ++ } ++#endif ++ ++ /* authentication required? */ ++ if (conn->account.flags & M_ACCT_USER) ++ { ++ if (!conn->account.user[0]) ++ auth = 0; ++ } ++ else ++ { ++ if (mutt_socket_write (conn, "STAT\r\n") < 0 || ++ mutt_socket_readln (buf, sizeof (buf), conn) < 0) ++ return nntp_connect_error (nserv); ++ if (mutt_strncmp ("480", buf, 3)) ++ auth = 0; ++ } ++ ++ /* authenticate */ ++ if (auth && nntp_auth (nserv) < 0) ++ return -1; ++ ++ /* get final capabilities after authentication */ ++ if (nserv->hasCAPABILITIES && (auth || cap > 0)) ++ { ++ cap = nntp_capabilities (nserv); ++ if (cap < 0) ++ return -1; ++ if (cap > 0) ++ { ++ mutt_socket_close (conn); ++ mutt_error _("Could not switch to reader mode."); ++ mutt_sleep (2); ++ return -1; ++ } ++ } ++ ++ /* attempt features */ ++ if (nntp_attempt_features (nserv) < 0) ++ return -1; ++ ++ nserv->status = NNTP_OK; ++ return 0; ++} ++ ++/* Send data from buffer and receive answer to same buffer */ ++static int nntp_query (NNTP_DATA *nntp_data, char *line, size_t linelen) ++{ ++ NNTP_SERVER *nserv = nntp_data->nserv; ++ char buf[LONG_STRING]; ++ ++ if (nserv->status == NNTP_BYE) ++ return -1; ++ ++ while (1) ++ { ++ if (nserv->status == NNTP_OK) ++ { ++ int rc = 0; ++ ++ if (*line) ++ rc = mutt_socket_write (nserv->conn, line); ++ else if (nntp_data->group) ++ { ++ snprintf (buf, sizeof (buf), "GROUP %s\r\n", nntp_data->group); ++ rc = mutt_socket_write (nserv->conn, buf); ++ } ++ if (rc >= 0) ++ rc = mutt_socket_readln (buf, sizeof (buf), nserv->conn); ++ if (rc >= 0) ++ break; ++ } ++ ++ /* reconnect */ ++ while (1) ++ { ++ nserv->status = NNTP_NONE; ++ if (nntp_open_connection (nserv) == 0) ++ break; ++ ++ snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"), ++ nserv->conn->account.host); ++ if (mutt_yesorno (buf, M_YES) != M_YES) ++ { ++ nserv->status = NNTP_BYE; ++ return -1; ++ } ++ } ++ ++ /* select newsgroup after reconnection */ ++ if (nntp_data->group) ++ { ++ snprintf (buf, sizeof (buf), "GROUP %s\r\n", nntp_data->group); ++ if (mutt_socket_write (nserv->conn, buf) < 0 || ++ mutt_socket_readln (buf, sizeof (buf), nserv->conn) < 0) ++ return nntp_connect_error (nserv); ++ } ++ if (!*line) ++ break; ++ } ++ ++ strfcpy (line, buf, linelen); ++ return 0; ++} ++ ++/* This function calls funct(*line, *data) for each received line, ++ * funct(NULL, *data) if rewind(*data) needs, exits when fail or done: ++ * 0 - success ++ * 1 - bad response (answer in query buffer) ++ * -1 - conection lost ++ * -2 - error in funct(*line, *data) */ ++static int nntp_fetch_lines (NNTP_DATA *nntp_data, char *query, size_t qlen, ++ char *msg, int (*funct) (char *, void *), void *data) ++{ ++ int done = FALSE; ++ int rc; ++ ++ while (!done) ++ { ++ char buf[LONG_STRING]; ++ char *line; ++ unsigned int lines = 0; ++ size_t off = 0; ++ progress_t progress; ++ ++ if (msg) ++ mutt_progress_init (&progress, msg, M_PROGRESS_MSG, ReadInc, -1); ++ ++ strfcpy (buf, query, sizeof (buf)); ++ if (nntp_query (nntp_data, buf, sizeof (buf)) < 0) ++ return -1; ++ if (buf[0] != '2') ++ { ++ strfcpy (query, buf, qlen); ++ return 1; ++ } ++ ++ line = safe_malloc (sizeof (buf)); ++ rc = 0; ++ ++ while (1) ++ { ++ char *p; ++ int chunk = mutt_socket_readln_d (buf, sizeof (buf), ++ nntp_data->nserv->conn, M_SOCK_LOG_HDR); ++ if (chunk < 0) ++ { ++ nntp_data->nserv->status = NNTP_NONE; ++ break; ++ } ++ ++ p = buf; ++ if (!off && buf[0] == '.') ++ { ++ if (buf[1] == '\0') ++ { ++ done = TRUE; ++ break; ++ } ++ if (buf[1] == '.') ++ p++; ++ } ++ ++ strfcpy (line + off, p, sizeof (buf)); ++ ++ if (chunk >= sizeof (buf)) ++ off += strlen (p); ++ else ++ { ++ if (msg) ++ mutt_progress_update (&progress, ++lines, -1); ++ ++ if (rc == 0 && funct (line, data) < 0) ++ rc = -2; ++ off = 0; ++ } ++ ++ safe_realloc (&line, off + sizeof (buf)); ++ } ++ FREE (&line); ++ funct (NULL, data); ++ } ++ return rc; ++} ++ ++/* Parse newsgroup description */ ++static int fetch_description (char *line, void *data) ++{ ++ NNTP_SERVER *nserv = data; ++ NNTP_DATA *nntp_data; ++ char *desc; ++ ++ if (!line) ++ return 0; ++ ++ desc = strpbrk (line, " \t"); ++ if (desc) ++ { ++ *desc++ = '\0'; ++ desc += strspn (desc, " \t"); ++ } ++ else ++ desc = strchr (line, '\0'); ++ ++ nntp_data = hash_find (nserv->groups_hash, line); ++ if (nntp_data && mutt_strcmp (desc, nntp_data->desc)) ++ { ++ mutt_str_replace (&nntp_data->desc, desc); ++ dprint (2, (debugfile, "group: %s, desc: %s\n", line, desc)); ++ } ++ return 0; ++} ++ ++/* Fetch newsgroups descriptions. ++ * Returns the same code as nntp_fetch_lines() */ ++static int get_description (NNTP_DATA *nntp_data, char *wildmat, char *msg) ++{ ++ NNTP_SERVER *nserv; ++ char buf[STRING]; ++ char *cmd; ++ int rc; ++ ++ /* get newsgroup description, if possible */ ++ nserv = nntp_data->nserv; ++ if (!wildmat) ++ wildmat = nntp_data->group; ++ if (nserv->hasLIST_NEWSGROUPS) ++ cmd = "LIST NEWSGROUPS"; ++ else if (nserv->hasXGTITLE) ++ cmd = "XGTITLE"; ++ else ++ return 0; ++ ++ snprintf (buf, sizeof (buf), "%s %s\r\n", cmd, wildmat); ++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), msg, ++ fetch_description, nserv); ++ if (rc > 0) ++ { ++ mutt_error ("%s: %s", cmd, buf); ++ mutt_sleep (2); ++ } ++ return rc; ++} ++ ++/* Update read flag and set article number if empty */ ++static void nntp_parse_xref (CONTEXT *ctx, HEADER *hdr) ++{ ++ NNTP_DATA *nntp_data = ctx->data; ++ char *buf, *p; ++ ++ buf = p = safe_strdup (hdr->env->xref); ++ while (p) ++ { ++ char *grp, *colon; ++ anum_t anum; ++ ++ /* skip to next word */ ++ p += strspn (p, " \t"); ++ grp = p; ++ ++ /* skip to end of word */ ++ p = strpbrk (p, " \t"); ++ if (p) ++ *p++ = '\0'; ++ ++ /* find colon */ ++ colon = strchr (grp, ':'); ++ if (!colon) ++ continue; ++ *colon++ = '\0'; ++ if (sscanf (colon, ANUM, &anum) != 1) ++ continue; ++ ++ nntp_article_status (ctx, hdr, grp, anum); ++ if (hdr && !NHDR (hdr)->article_num && !mutt_strcmp (nntp_data->group, grp)) ++ NHDR (hdr)->article_num = anum; ++ } ++ FREE (&buf); ++} ++ ++/* Write line to temporarily file */ ++static int fetch_tempfile (char *line, void *data) ++{ ++ FILE *fp = data; ++ ++ if (!line) ++ rewind (fp); ++ else if (fputs (line, fp) == EOF || fputc ('\n', fp) == EOF) ++ return -1; ++ return 0; ++} ++ ++typedef struct ++{ ++ CONTEXT *ctx; ++ anum_t first; ++ anum_t last; ++ int restore; ++ unsigned char *messages; ++ progress_t progress; ++#ifdef USE_HCACHE ++ header_cache_t *hc; ++#endif ++} FETCH_CTX; ++ ++/* Parse article number */ ++static int fetch_numbers (char *line, void *data) ++{ ++ FETCH_CTX *fc = data; ++ anum_t anum; ++ ++ if (!line) ++ return 0; ++ if (sscanf (line, ANUM, &anum) != 1) ++ return 0; ++ if (anum < fc->first || anum > fc->last) ++ return 0; ++ fc->messages[anum - fc->first] = 1; ++ return 0; ++} ++ ++/* Parse overview line */ ++static int parse_overview_line (char *line, void *data) ++{ ++ FETCH_CTX *fc = data; ++ CONTEXT *ctx = fc->ctx; ++ NNTP_DATA *nntp_data = ctx->data; ++ HEADER *hdr; ++ FILE *fp; ++ char tempfile[_POSIX_PATH_MAX]; ++ char *header, *field; ++ int save = 1; ++ anum_t anum; ++ ++ if (!line) ++ return 0; ++ ++ /* parse article number */ ++ field = strchr (line, '\t'); ++ if (field) ++ *field++ = '\0'; ++ if (sscanf (line, ANUM, &anum) != 1) ++ return 0; ++ dprint (2, (debugfile, "parse_overview_line: " ANUM "\n", anum)); ++ ++ /* out of bounds */ ++ if (anum < fc->first || anum > fc->last) ++ return 0; ++ ++ /* not in LISTGROUP */ ++ if (!fc->messages[anum - fc->first]) ++ { ++ /* progress */ ++ if (!ctx->quiet) ++ mutt_progress_update (&fc->progress, anum - fc->first + 1, -1); ++ return 0; ++ } ++ ++ /* convert overview line to header */ ++ mutt_mktemp (tempfile, sizeof (tempfile)); ++ fp = safe_fopen (tempfile, "w+"); ++ if (!fp) ++ return -1; ++ ++ header = nntp_data->nserv->overview_fmt; ++ while (field) ++ { ++ char *b = field; ++ ++ if (*header) ++ { ++ if (strstr (header, ":full") == NULL && fputs (header, fp) == EOF) ++ { ++ fclose (fp); ++ unlink (tempfile); ++ return -1; ++ } ++ header = strchr (header, '\0') + 1; ++ } ++ ++ field = strchr (field, '\t'); ++ if (field) ++ *field++ = '\0'; ++ if (fputs (b, fp) == EOF || fputc ('\n', fp) == EOF) ++ { ++ fclose (fp); ++ unlink (tempfile); ++ return -1; ++ } ++ } ++ rewind (fp); ++ ++ /* allocate memory for headers */ ++ if (ctx->msgcount >= ctx->hdrmax) ++ mx_alloc_memory (ctx); ++ ++ /* parse header */ ++ hdr = ctx->hdrs[ctx->msgcount] = mutt_new_header (); ++ hdr->env = mutt_read_rfc822_header (fp, hdr, 0, 0); ++ hdr->env->newsgroups = safe_strdup (nntp_data->group); ++ hdr->received = hdr->date_sent; ++ fclose (fp); ++ unlink (tempfile); ++ ++#ifdef USE_HCACHE ++ if (fc->hc) ++ { ++ void *hdata; ++ char buf[16]; ++ ++ /* try to replace with header from cache */ ++ snprintf (buf, sizeof (buf), "%d", anum); ++ hdata = mutt_hcache_fetch (fc->hc, buf, strlen); ++ if (hdata) ++ { ++ dprint (2, (debugfile, ++ "parse_overview_line: mutt_hcache_fetch %s\n", buf)); ++ mutt_free_header (&hdr); ++ ctx->hdrs[ctx->msgcount] = ++ hdr = mutt_hcache_restore (hdata, NULL); ++ hdr->read = 0; ++ hdr->old = 0; ++ ++ /* skip header marked as deleted in cache */ ++ if (hdr->deleted && !fc->restore) ++ { ++ if (nntp_data->bcache) ++ { ++ dprint (2, (debugfile, ++ "parse_overview_line: mutt_bcache_del %s\n", buf)); ++ mutt_bcache_del (nntp_data->bcache, buf); ++ } ++ save = 0; ++ } ++ } ++ ++ /* not chached yet, store header */ ++ else ++ { ++ dprint (2, (debugfile, ++ "parse_overview_line: mutt_hcache_store %s\n", buf)); ++ mutt_hcache_store (fc->hc, buf, hdr, 0, strlen, M_GENERATE_UIDVALIDITY); ++ } ++ } ++#endif ++ ++ if (save) ++ { ++ hdr->index = ctx->msgcount++; ++ hdr->read = 0; ++ hdr->old = 0; ++ hdr->deleted = 0; ++ hdr->data = safe_calloc (1, sizeof (NNTP_HEADER_DATA)); ++ NHDR (hdr)->article_num = anum; ++ if (fc->restore) ++ hdr->changed = 1; ++ else ++ { ++ nntp_article_status (ctx, hdr, NULL, anum); ++ if (!hdr->read) ++ nntp_parse_xref (ctx, hdr); ++ } ++ if (anum > nntp_data->lastLoaded) ++ nntp_data->lastLoaded = anum; ++ } ++ else ++ mutt_free_header (&hdr); ++ ++ /* progress */ ++ if (!ctx->quiet) ++ mutt_progress_update (&fc->progress, anum - fc->first + 1, -1); ++ return 0; ++} ++ ++/* Fetch headers */ ++static int nntp_fetch_headers (CONTEXT *ctx, void *hc, ++ anum_t first, anum_t last, int restore) ++{ ++ NNTP_DATA *nntp_data = ctx->data; ++ FETCH_CTX fc; ++ HEADER *hdr; ++ char buf[HUGE_STRING]; ++ int rc = 0; ++ int oldmsgcount = ctx->msgcount; ++ anum_t current; ++#ifdef USE_HCACHE ++ void *hdata; ++#endif ++ ++ /* if empty group or nothing to do */ ++ if (!last || first > last) ++ return 0; ++ ++ /* init fetch context */ ++ fc.ctx = ctx; ++ fc.first = first; ++ fc.last = last; ++ fc.restore = restore; ++ fc.messages = safe_calloc (last - first + 1, sizeof (unsigned char)); ++#ifdef USE_HCACHE ++ fc.hc = hc; ++#endif ++ ++ /* fetch list of articles */ ++ if (nntp_data->nserv->hasLISTGROUP && !nntp_data->deleted) ++ { ++ if (!ctx->quiet) ++ mutt_message _("Fetching list of articles..."); ++ snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group); ++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL, ++ fetch_numbers, &fc); ++ if (rc > 0) ++ { ++ mutt_error ("LISTGROUP: %s", buf); ++ mutt_sleep (2); ++ } ++ if (rc == 0) ++ { ++ for (current = first; current <= last && rc == 0; current++) ++ { ++ if (fc.messages[current - first]) ++ continue; ++ ++ snprintf (buf, sizeof (buf), "%d", current); ++ if (nntp_data->bcache) ++ { ++ dprint (2, (debugfile, ++ "nntp_fetch_headers: mutt_bcache_del %s\n", buf)); ++ mutt_bcache_del (nntp_data->bcache, buf); ++ } ++ ++#ifdef USE_HCACHE ++ if (fc.hc) ++ { ++ dprint (2, (debugfile, ++ "nntp_fetch_headers: mutt_hcache_delete %s\n", buf)); ++ mutt_hcache_delete (fc.hc, buf, strlen); ++ } ++#endif ++ } ++ } ++ } ++ else ++ for (current = first; current <= last; current++) ++ fc.messages[current - first] = 1; ++ ++ /* fetching header from cache or server, or fallback to fetch overview */ ++ if (!ctx->quiet) ++ mutt_progress_init (&fc.progress, _("Fetching message headers..."), ++ M_PROGRESS_MSG, ReadInc, last - first + 1); ++ for (current = first; current <= last && rc == 0; current++) ++ { ++ if (!ctx->quiet) ++ mutt_progress_update (&fc.progress, current - first + 1, -1); ++ ++#ifdef USE_HCACHE ++ snprintf (buf, sizeof (buf), "%d", current); ++#endif ++ ++ /* delete header from cache that does not exist on server */ ++ if (!fc.messages[current - first]) ++ continue; ++ ++ /* allocate memory for headers */ ++ if (ctx->msgcount >= ctx->hdrmax) ++ mx_alloc_memory (ctx); ++ ++#ifdef USE_HCACHE ++ /* try to fetch header from cache */ ++ hdata = mutt_hcache_fetch (fc.hc, buf, strlen); ++ if (hdata) ++ { ++ dprint (2, (debugfile, ++ "nntp_fetch_headers: mutt_hcache_fetch %s\n", buf)); ++ ctx->hdrs[ctx->msgcount] = ++ hdr = mutt_hcache_restore (hdata, NULL); ++ ++ /* skip header marked as deleted in cache */ ++ if (hdr->deleted && !restore) ++ { ++ mutt_free_header (&hdr); ++ if (nntp_data->bcache) ++ { ++ dprint (2, (debugfile, ++ "nntp_fetch_headers: mutt_bcache_del %s\n", buf)); ++ mutt_bcache_del (nntp_data->bcache, buf); ++ } ++ continue; ++ } ++ ++ hdr->read = 0; ++ hdr->old = 0; ++ } ++ else ++#endif ++ ++ /* don't try to fetch header from removed newsgroup */ ++ if (nntp_data->deleted) ++ continue; ++ ++ /* fallback to fetch overview */ ++ else if (nntp_data->nserv->hasOVER || nntp_data->nserv->hasXOVER) ++ break; ++ ++ /* fetch header from server */ ++ else ++ { ++ FILE *fp; ++ char tempfile[_POSIX_PATH_MAX]; ++ ++ mutt_mktemp (tempfile, sizeof (tempfile)); ++ fp = safe_fopen (tempfile, "w+"); ++ if (!fp) ++ { ++ mutt_perror (tempfile); ++ mutt_sleep (2); ++ unlink (tempfile); ++ rc = -1; ++ break; ++ } ++ ++ snprintf (buf, sizeof (buf), "HEAD %d\r\n", current); ++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL, ++ fetch_tempfile, fp); ++ if (rc) ++ { ++ fclose (fp); ++ unlink (tempfile); ++ if (rc < 0) ++ break; ++ ++ /* invalid response */ ++ if (mutt_strncmp ("423", buf, 3)) ++ { ++ mutt_error ("HEAD: %s", buf); ++ mutt_sleep (2); ++ break; ++ } ++ ++ /* no such article */ ++ if (nntp_data->bcache) ++ { ++ snprintf (buf, sizeof (buf), "%d", current); ++ dprint (2, (debugfile, ++ "nntp_fetch_headers: mutt_bcache_del %s\n", buf)); ++ mutt_bcache_del (nntp_data->bcache, buf); ++ } ++ rc = 0; ++ continue; ++ } ++ ++ /* parse header */ ++ hdr = ctx->hdrs[ctx->msgcount] = mutt_new_header (); ++ hdr->env = mutt_read_rfc822_header (fp, hdr, 0, 0); ++ hdr->received = hdr->date_sent; ++ fclose (fp); ++ unlink (tempfile); ++ } ++ ++ /* save header in context */ ++ hdr->index = ctx->msgcount++; ++ hdr->read = 0; ++ hdr->old = 0; ++ hdr->deleted = 0; ++ hdr->data = safe_calloc (1, sizeof (NNTP_HEADER_DATA)); ++ NHDR (hdr)->article_num = current; ++ if (restore) ++ hdr->changed = 1; ++ else ++ { ++ nntp_article_status (ctx, hdr, NULL, NHDR (hdr)->article_num); ++ if (!hdr->read) ++ nntp_parse_xref (ctx, hdr); ++ } ++ if (current > nntp_data->lastLoaded) ++ nntp_data->lastLoaded = current; ++ } ++ ++ /* fetch overview information */ ++ if (current <= last && rc == 0) { ++ char *cmd = nntp_data->nserv->hasOVER ? "OVER" : "XOVER"; ++ snprintf (buf, sizeof (buf), "%s %d-%d\r\n", cmd, current, last); ++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL, ++ parse_overview_line, &fc); ++ if (rc > 0) ++ { ++ mutt_error ("%s: %s", cmd, buf); ++ mutt_sleep (2); ++ } ++ } ++ ++ if (ctx->msgcount > oldmsgcount) ++ mx_update_context (ctx, ctx->msgcount - oldmsgcount); ++ ++ FREE (&fc.messages); ++ if (rc != 0) ++ return -1; ++ mutt_clear_error (); ++ return 0; ++} ++ ++/* Open newsgroup */ ++int nntp_open_mailbox (CONTEXT *ctx) ++{ ++ NNTP_SERVER *nserv; ++ NNTP_DATA *nntp_data; ++ char buf[HUGE_STRING]; ++ char server[LONG_STRING]; ++ char *group; ++ int rc; ++ void *hc = NULL; ++ anum_t first, last, count = 0; ++ ciss_url_t url; ++ ++ strfcpy (buf, ctx->path, sizeof (buf)); ++ if (url_parse_ciss (&url, buf) < 0 || !url.path || ++ !(url.scheme == U_NNTP || url.scheme == U_NNTPS)) ++ { ++ mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path); ++ mutt_sleep (2); ++ return -1; ++ } ++ ++ group = url.path; ++ url.path = strchr (url.path, '\0'); ++ url_ciss_tostring (&url, server, sizeof (server), 0); ++ nserv = nntp_select_server (server, 1); ++ if (!nserv) ++ return -1; ++ CurrentNewsSrv = nserv; ++ ++ /* find news group data structure */ ++ nntp_data = hash_find (nserv->groups_hash, group); ++ if (!nntp_data) ++ { ++ nntp_newsrc_close (nserv); ++ mutt_error (_("Newsgroup %s not found on the server."), group); ++ mutt_sleep (2); ++ return -1; ++ } ++ ++ mutt_bit_unset (ctx->rights, M_ACL_INSERT); ++ if (!nntp_data->newsrc_ent && !nntp_data->subscribed && ++ !option (OPTSAVEUNSUB)) ++ ctx->readonly = 1; ++ ++ /* select newsgroup */ ++ mutt_message (_("Selecting %s..."), group); ++ buf[0] = '\0'; ++ if (nntp_query (nntp_data, buf, sizeof (buf)) < 0) ++ { ++ nntp_newsrc_close (nserv); ++ return -1; ++ } ++ ++ /* newsgroup not found, remove it */ ++ if (!mutt_strncmp ("411", buf, 3)) ++ { ++ mutt_error (_("Newsgroup %s has been removed from the server."), ++ nntp_data->group); ++ if (!nntp_data->deleted) ++ { ++ nntp_data->deleted = 1; ++ nntp_active_save_cache (nserv); ++ } ++ if (nntp_data->newsrc_ent && !nntp_data->subscribed && ++ !option (OPTSAVEUNSUB)) ++ { ++ FREE (&nntp_data->newsrc_ent); ++ nntp_data->newsrc_len = 0; ++ nntp_delete_group_cache (nntp_data); ++ nntp_newsrc_update (nserv); ++ } ++ mutt_sleep (2); ++ } ++ ++ /* parse newsgroup info */ ++ else { ++ if (sscanf (buf, "211 " ANUM " " ANUM " " ANUM, &count, &first, &last) != 3) ++ { ++ nntp_newsrc_close (nserv); ++ mutt_error ("GROUP: %s", buf); ++ mutt_sleep (2); ++ return -1; ++ } ++ nntp_data->firstMessage = first; ++ nntp_data->lastMessage = last; ++ nntp_data->deleted = 0; ++ ++ /* get description if empty */ ++ if (option (OPTLOADDESC) && !nntp_data->desc) ++ { ++ if (get_description (nntp_data, NULL, NULL) < 0) ++ { ++ nntp_newsrc_close (nserv); ++ return -1; ++ } ++ if (nntp_data->desc) ++ nntp_active_save_cache (nserv); ++ } ++ } ++ ++ time (&nserv->check_time); ++ ctx->data = nntp_data; ++ ctx->mx_close = nntp_fastclose_mailbox; ++ if (!nntp_data->bcache && (nntp_data->newsrc_ent || ++ nntp_data->subscribed || option (OPTSAVEUNSUB))) ++ nntp_data->bcache = mutt_bcache_open (&nserv->conn->account, ++ nntp_data->group); ++ ++ /* strip off extra articles if adding context is greater than $nntp_context */ ++ first = nntp_data->firstMessage; ++ if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext) ++ first = nntp_data->lastMessage - NntpContext + 1; ++ nntp_data->lastLoaded = first ? first - 1 : 0; ++ count = nntp_data->firstMessage; ++ nntp_data->firstMessage = first; ++ nntp_bcache_update (nntp_data); ++ nntp_data->firstMessage = count; ++#ifdef USE_HCACHE ++ hc = nntp_hcache_open (nntp_data); ++ nntp_hcache_update (nntp_data, hc); ++#endif ++ if (!hc) ++ { ++ mutt_bit_unset (ctx->rights, M_ACL_WRITE); ++ mutt_bit_unset (ctx->rights, M_ACL_DELETE); ++ } ++ nntp_newsrc_close (nserv); ++ rc = nntp_fetch_headers (ctx, hc, first, nntp_data->lastMessage, 0); ++#ifdef USE_HCACHE ++ mutt_hcache_close (hc); ++#endif ++ if (rc < 0) ++ return -1; ++ nntp_data->lastLoaded = nntp_data->lastMessage; ++ nserv->newsrc_modified = 0; ++ return 0; ++} ++ ++/* Fetch message */ ++int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno) ++{ ++ NNTP_DATA *nntp_data = ctx->data; ++ NNTP_ACACHE *acache; ++ HEADER *hdr = ctx->hdrs[msgno]; ++ char buf[_POSIX_PATH_MAX]; ++ char article[16]; ++ char *fetch_msg = _("Fetching message..."); ++ int rc; ++ ++ /* try to get article from cache */ ++ acache = &nntp_data->acache[hdr->index % NNTP_ACACHE_LEN]; ++ if (acache->path) ++ { ++ if (acache->index == hdr->index) ++ { ++ msg->fp = fopen (acache->path, "r"); ++ if (msg->fp) ++ return 0; ++ } ++ /* clear previous entry */ ++ else ++ { ++ unlink (acache->path); ++ FREE (&acache->path); ++ } ++ } ++ snprintf (article, sizeof (article), "%d", NHDR (hdr)->article_num); ++ msg->fp = mutt_bcache_get (nntp_data->bcache, article); ++ if (msg->fp) ++ { ++ if (NHDR (hdr)->parsed) ++ return 0; ++ } ++ else ++ { ++ /* don't try to fetch article from removed newsgroup */ ++ if (nntp_data->deleted) ++ return -1; ++ ++ /* create new cache file */ ++ mutt_message (fetch_msg); ++ msg->fp = mutt_bcache_put (nntp_data->bcache, article, 1); ++ if (!msg->fp) ++ { ++ mutt_mktemp (buf, sizeof (buf)); ++ acache->path = safe_strdup (buf); ++ acache->index = hdr->index; ++ msg->fp = safe_fopen (acache->path, "w+"); ++ if (!msg->fp) ++ { ++ mutt_perror (acache->path); ++ unlink (acache->path); ++ FREE (&acache->path); ++ return -1; ++ } ++ } ++ ++ /* fetch message to cache file */ ++ snprintf (buf, sizeof (buf), "ARTICLE %s\r\n", ++ NHDR (hdr)->article_num ? article : hdr->env->message_id); ++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), fetch_msg, ++ fetch_tempfile, msg->fp); ++ if (rc) ++ { ++ safe_fclose (&msg->fp); ++ if (acache->path) ++ { ++ unlink (acache->path); ++ FREE (&acache->path); ++ } ++ if (rc > 0) ++ { ++ if (!mutt_strncmp (NHDR (hdr)->article_num ? "423" : "430", buf, 3)) ++ mutt_error (_("Article %d not found on the server."), ++ NHDR (hdr)->article_num ? article : hdr->env->message_id); ++ else ++ mutt_error ("ARTICLE: %s", buf); ++ } ++ return -1; ++ } ++ ++ if (!acache->path) ++ mutt_bcache_commit (nntp_data->bcache, article); ++ } ++ ++ /* replace envelope with new one ++ * hash elements must be updated because pointers will be changed */ ++ if (ctx->id_hash && hdr->env->message_id) ++ hash_delete (ctx->id_hash, hdr->env->message_id, hdr, NULL); ++ if (ctx->subj_hash && hdr->env->real_subj) ++ hash_delete (ctx->subj_hash, hdr->env->real_subj, hdr, NULL); ++ ++ mutt_free_envelope (&hdr->env); ++ hdr->env = mutt_read_rfc822_header (msg->fp, hdr, 0, 0); ++ ++ if (ctx->id_hash && hdr->env->message_id) ++ hash_insert (ctx->id_hash, hdr->env->message_id, hdr, 0); ++ if (ctx->subj_hash && hdr->env->real_subj) ++ hash_insert (ctx->subj_hash, hdr->env->real_subj, hdr, 1); ++ ++ /* fix content length */ ++ fseek (msg->fp, 0, SEEK_END); ++ hdr->content->length = ftell (msg->fp) - hdr->content->offset; ++ ++ /* this is called in mutt before the open which fetches the message, ++ * which is probably wrong, but we just call it again here to handle ++ * the problem instead of fixing it */ ++ NHDR (hdr)->parsed = 1; ++ mutt_parse_mime_message (ctx, hdr); ++ ++ /* these would normally be updated in mx_update_context(), but the ++ * full headers aren't parsed with overview, so the information wasn't ++ * available then */ ++ if (WithCrypto) ++ hdr->security = crypt_query (hdr->content); ++ ++ rewind (msg->fp); ++ mutt_clear_error(); ++ return 0; ++} ++ ++/* Post article */ ++int nntp_post (const char *msg) { ++ NNTP_DATA *nntp_data, nntp_tmp; ++ FILE *fp; ++ char buf[LONG_STRING]; ++ size_t len; ++ ++ if (Context && Context->magic == M_NNTP) ++ nntp_data = Context->data; ++ else ++ { ++ CurrentNewsSrv = nntp_select_server (NewsServer, 0); ++ if (!CurrentNewsSrv) ++ return -1; ++ ++ nntp_data = &nntp_tmp; ++ nntp_data->nserv = CurrentNewsSrv; ++ nntp_data->group = NULL; ++ } ++ ++ fp = safe_fopen (msg, "r"); ++ if (!fp) ++ { ++ mutt_perror (msg); ++ return -1; ++ } ++ ++ strfcpy (buf, "POST\r\n", sizeof (buf)); ++ if (nntp_query (nntp_data, buf, sizeof (buf)) < 0) ++ return -1; ++ if (buf[0] != '3') ++ { ++ mutt_error (_("Can't post article: %s"), buf); ++ return -1; ++ } ++ ++ buf[0] = '.'; ++ buf[1] = '\0'; ++ while (fgets (buf + 1, sizeof (buf) - 2, fp)) ++ { ++ len = strlen (buf); ++ if (buf[len - 1] == '\n') ++ { ++ buf[len - 1] = '\r'; ++ buf[len] = '\n'; ++ len++; ++ buf[len] = '\0'; ++ } ++ if (mutt_socket_write_d (nntp_data->nserv->conn, ++ buf[1] == '.' ? buf : buf + 1, -1, M_SOCK_LOG_HDR) < 0) ++ return nntp_connect_error (nntp_data->nserv); ++ } ++ fclose (fp); ++ ++ if ((buf[strlen (buf) - 1] != '\n' && ++ mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", -1, M_SOCK_LOG_HDR) < 0) || ++ mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", -1, M_SOCK_LOG_HDR) < 0 || ++ mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0) ++ return nntp_connect_error (nntp_data->nserv); ++ if (buf[0] != '2') ++ { ++ mutt_error (_("Can't post article: %s"), buf); ++ return -1; ++ } ++ return 0; ++} ++ ++/* Save changes to .newsrc and cache */ ++int nntp_sync_mailbox (CONTEXT *ctx) ++{ ++ NNTP_DATA *nntp_data = ctx->data; ++ int rc, i; ++#ifdef USE_HCACHE ++ header_cache_t *hc; ++#endif ++ ++ /* check for new articles */ ++ nntp_data->nserv->check_time = 0; ++ rc = nntp_check_mailbox (ctx, 1); ++ if (rc) ++ return rc; ++ ++#ifdef USE_HCACHE ++ nntp_data->lastCached = 0; ++ hc = nntp_hcache_open (nntp_data); ++#endif ++ ++ nntp_data->unread = ctx->unread; ++ for (i = 0; i < ctx->msgcount; i++) ++ { ++ HEADER *hdr = ctx->hdrs[i]; ++ char buf[16]; ++ ++ snprintf (buf, sizeof (buf), "%d", NHDR (hdr)->article_num); ++ if (nntp_data->bcache && hdr->deleted) ++ { ++ dprint (2, (debugfile, "nntp_sync_mailbox: mutt_bcache_del %s\n", buf)); ++ mutt_bcache_del (nntp_data->bcache, buf); ++ } ++ ++#ifdef USE_HCACHE ++ if (hc && (hdr->changed || hdr->deleted)) ++ { ++ if (hdr->deleted && !hdr->read) ++ nntp_data->unread--; ++ dprint (2, (debugfile, "nntp_sync_mailbox: mutt_hcache_store %s\n", buf)); ++ mutt_hcache_store (hc, buf, hdr, 0, strlen, M_GENERATE_UIDVALIDITY); ++ } ++#endif ++ } ++ ++#ifdef USE_HCACHE ++ if (hc) ++ { ++ mutt_hcache_close (hc); ++ nntp_data->lastCached = nntp_data->lastLoaded; ++ } ++#endif ++ ++ /* save .newsrc entries */ ++ nntp_newsrc_gen_entries (ctx); ++ nntp_newsrc_update (nntp_data->nserv); ++ nntp_newsrc_close (nntp_data->nserv); ++ return 0; ++} ++ ++/* Free up memory associated with the newsgroup context */ ++int nntp_fastclose_mailbox (CONTEXT *ctx) ++{ ++ NNTP_DATA *nntp_data = ctx->data, *nntp_tmp; ++ ++ if (!nntp_data) ++ return 0; ++ ++ nntp_acache_free (nntp_data); ++ if (!nntp_data->nserv || !nntp_data->nserv->groups_hash || !nntp_data->group) ++ return 0; ++ ++ nntp_tmp = hash_find (nntp_data->nserv->groups_hash, nntp_data->group); ++ if (nntp_tmp == NULL || nntp_tmp != nntp_data) ++ nntp_data_free (nntp_data); ++ return 0; ++} ++ ++/* Get date and time from server */ ++int nntp_date (NNTP_SERVER *nserv, time_t *now) ++{ ++ if (nserv->hasDATE) ++ { ++ NNTP_DATA nntp_data; ++ char buf[LONG_STRING]; ++ struct tm tm; ++ ++ nntp_data.nserv = nserv; ++ nntp_data.group = NULL; ++ strfcpy (buf, "DATE\r\n", sizeof (buf)); ++ if (nntp_query (&nntp_data, buf, sizeof (buf)) < 0) ++ return -1; ++ ++ if (sscanf (buf, "111 %4d%2d%2d%2d%2d%2d%*s", &tm.tm_year, &tm.tm_mon, ++ &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) == 6) ++ { ++ tm.tm_year -= 1900; ++ tm.tm_mon--; ++ *now = timegm (&tm); ++ if (*now >= 0) ++ { ++ dprint (1, (debugfile, "nntp_date: server time is %d\n", *now)); ++ return 0; ++ } ++ } ++ } ++ time (now); ++ return 0; ++} ++ ++/* Fetch list of all newsgroups from server */ ++int nntp_active_fetch (NNTP_SERVER *nserv) ++{ ++ NNTP_DATA nntp_data; ++ char msg[SHORT_STRING]; ++ char buf[LONG_STRING]; ++ unsigned int i; ++ int rc; ++ ++ snprintf (msg, sizeof (msg), _("Loading list of groups from server %s..."), ++ nserv->conn->account.host); ++ mutt_message (msg); ++ if (nntp_date (nserv, &nserv->newgroups_time) < 0) ++ return -1; ++ ++ nntp_data.nserv = nserv; ++ nntp_data.group = NULL; ++ strfcpy (buf, "LIST\r\n", sizeof (buf)); ++ rc = nntp_fetch_lines (&nntp_data, buf, sizeof (buf), msg, ++ nntp_add_group, nserv); ++ if (rc) ++ { ++ if (rc > 0) ++ { ++ mutt_error ("LIST: %s", buf); ++ mutt_sleep (2); ++ } ++ return -1; ++ } ++ ++ if (option (OPTLOADDESC) && ++ get_description (&nntp_data, "*", _("Loading descriptions...")) < 0) ++ return -1; ++ ++ for (i = 0; i < nserv->groups_num; i++) ++ { ++ NNTP_DATA *nntp_data = nserv->groups_list[i]; ++ ++ if (nntp_data && nntp_data->deleted && !nntp_data->newsrc_ent) ++ { ++ nntp_delete_group_cache (nntp_data); ++ hash_delete (nserv->groups_hash, nntp_data->group, NULL, nntp_data_free); ++ nserv->groups_list[i] = NULL; ++ } ++ } ++ nntp_active_save_cache (nserv); ++ mutt_clear_error (); ++ return 0; ++} ++ ++/* Check newsgroup for new articles: ++ * 1 - new articles found ++ * 0 - no change ++ * -1 - lost connection */ ++static int nntp_group_poll (NNTP_DATA *nntp_data, int update_stat) ++{ ++ char buf[LONG_STRING] = ""; ++ anum_t count, first, last; ++ ++ /* use GROUP command to poll newsgroup */ ++ if (nntp_query (nntp_data, buf, sizeof (buf)) < 0) ++ return -1; ++ if (sscanf (buf, "211 " ANUM " " ANUM " " ANUM, &count, &first, &last) != 3) ++ return 0; ++ if (first == nntp_data->firstMessage && last == nntp_data->lastMessage) ++ return 0; ++ ++ /* articles have been renumbered */ ++ if (last < nntp_data->lastMessage) ++ { ++ nntp_data->lastCached = 0; ++ if (nntp_data->newsrc_len) ++ { ++ safe_realloc (&nntp_data->newsrc_ent, sizeof (NEWSRC_ENTRY)); ++ nntp_data->newsrc_len = 1; ++ nntp_data->newsrc_ent[0].first = 1; ++ nntp_data->newsrc_ent[0].last = 0; ++ } ++ } ++ nntp_data->firstMessage = first; ++ nntp_data->lastMessage = last; ++ if (!update_stat) ++ return 1; ++ ++ /* update counters */ ++ else if (!last || (!nntp_data->newsrc_ent && !nntp_data->lastCached)) ++ nntp_data->unread = count; ++ else ++ nntp_group_unread_stat (nntp_data); ++ return 1; ++} ++ ++/* Check current newsgroup for new articles: ++ * M_REOPENED - articles have been renumbered or removed from server ++ * M_NEW_MAIL - new articles found ++ * 0 - no change ++ * -1 - lost connection */ ++int nntp_check_mailbox (CONTEXT *ctx, int leave_lock) ++{ ++ NNTP_DATA *nntp_data = ctx->data; ++ NNTP_SERVER *nserv = nntp_data->nserv; ++ time_t now = time (NULL); ++ int i, j; ++ int rc, ret = 0; ++ void *hc = NULL; ++ ++ if (nserv->check_time + NewsPollTimeout > now) ++ return 0; ++ ++ mutt_message _("Checking for new messages..."); ++ if (nntp_newsrc_parse (nserv) < 0) ++ return -1; ++ ++ nserv->check_time = now; ++ rc = nntp_group_poll (nntp_data, 0); ++ if (rc < 0) ++ { ++ nntp_newsrc_close (nserv); ++ return -1; ++ } ++ if (rc) ++ nntp_active_save_cache (nserv); ++ ++ /* articles have been renumbered, remove all headers */ ++ if (nntp_data->lastMessage < nntp_data->lastLoaded) ++ { ++ for (i = 0; i < ctx->msgcount; i++) ++ mutt_free_header (&ctx->hdrs[i]); ++ ctx->msgcount = 0; ++ ctx->tagged = 0; ++ ++ if (nntp_data->lastMessage < nntp_data->lastLoaded) ++ { ++ nntp_data->lastLoaded = nntp_data->firstMessage - 1; ++ if (NntpContext && nntp_data->lastMessage - nntp_data->lastLoaded > ++ NntpContext) ++ nntp_data->lastLoaded = nntp_data->lastMessage - NntpContext; ++ } ++ ret = M_REOPENED; ++ } ++ ++ /* .newsrc has been externally modified */ ++ if (nserv->newsrc_modified) ++ { ++ anum_t anum; ++#ifdef USE_HCACHE ++ unsigned char *messages; ++ char buf[16]; ++ void *hdata; ++ HEADER *hdr; ++ anum_t first = nntp_data->firstMessage; ++ ++ if (NntpContext && nntp_data->lastMessage - first + 1 > NntpContext) ++ first = nntp_data->lastMessage - NntpContext + 1; ++ messages = safe_calloc (nntp_data->lastLoaded - first + 1, ++ sizeof (unsigned char)); ++ hc = nntp_hcache_open (nntp_data); ++ nntp_hcache_update (nntp_data, hc); ++#endif ++ ++ /* update flags according to .newsrc */ ++ for (i = j = 0; i < ctx->msgcount; i++) ++ { ++ int flagged = 0; ++ anum = NHDR (ctx->hdrs[i])->article_num; ++ ++#ifdef USE_HCACHE ++ /* check hcache for flagged and deleted flags */ ++ if (hc) ++ { ++ if (anum >= first && anum <= nntp_data->lastLoaded) ++ messages[anum - first] = 1; ++ ++ snprintf (buf, sizeof (buf), "%d", anum); ++ hdata = mutt_hcache_fetch (hc, buf, strlen); ++ if (hdata) ++ { ++ int deleted; ++ ++ dprint (2, (debugfile, ++ "nntp_check_mailbox: mutt_hcache_fetch %s\n", buf)); ++ hdr = mutt_hcache_restore (hdata, NULL); ++ deleted = hdr->deleted; ++ flagged = hdr->flagged; ++ mutt_free_header (&hdr); ++ ++ /* header marked as deleted, removing from context */ ++ if (deleted) ++ { ++ mutt_set_flag (ctx, ctx->hdrs[i], M_TAG, 0); ++ mutt_free_header (&ctx->hdrs[i]); ++ continue; ++ } ++ } ++ } ++#endif ++ ++ if (!ctx->hdrs[i]->changed) ++ { ++ ctx->hdrs[i]->flagged = flagged; ++ ctx->hdrs[i]->read = 0; ++ ctx->hdrs[i]->old = 0; ++ nntp_article_status (ctx, ctx->hdrs[i], NULL, anum); ++ if (!ctx->hdrs[i]->read) ++ nntp_parse_xref (ctx, ctx->hdrs[i]); ++ } ++ ctx->hdrs[j++] = ctx->hdrs[i]; ++ } ++ ++#ifdef USE_HCACHE ++ ctx->msgcount = j; ++ ++ /* restore headers without "deleted" flag */ ++ for (anum = first; anum <= nntp_data->lastLoaded; anum++) ++ { ++ if (messages[anum - first]) ++ continue; ++ ++ snprintf (buf, sizeof (buf), "%d", anum); ++ hdata = mutt_hcache_fetch (hc, buf, strlen); ++ if (hdata) ++ { ++ dprint (2, (debugfile, ++ "nntp_check_mailbox: mutt_hcache_fetch %s\n", buf)); ++ if (ctx->msgcount >= ctx->hdrmax) ++ mx_alloc_memory (ctx); ++ ++ ctx->hdrs[ctx->msgcount] = ++ hdr = mutt_hcache_restore (hdata, NULL); ++ if (hdr->deleted) ++ { ++ mutt_free_header (&hdr); ++ if (nntp_data->bcache) ++ { ++ dprint (2, (debugfile, ++ "nntp_check_mailbox: mutt_bcache_del %s\n", buf)); ++ mutt_bcache_del (nntp_data->bcache, buf); ++ } ++ continue; ++ } ++ ++ ctx->msgcount++; ++ hdr->read = 0; ++ hdr->old = 0; ++ hdr->data = safe_calloc (1, sizeof (NNTP_HEADER_DATA)); ++ NHDR (hdr)->article_num = anum; ++ nntp_article_status (ctx, hdr, NULL, anum); ++ if (!hdr->read) ++ nntp_parse_xref (ctx, hdr); ++ } ++ } ++ FREE (&messages); ++#endif ++ ++ nserv->newsrc_modified = 0; ++ ret = M_REOPENED; ++ } ++ ++ /* some headers were removed, context must be updated */ ++ if (ret == M_REOPENED) ++ { ++ if (ctx->subj_hash) ++ hash_destroy (&ctx->subj_hash, NULL); ++ if (ctx->id_hash) ++ hash_destroy (&ctx->id_hash, NULL); ++ mutt_clear_threads (ctx); ++ ++ ctx->vcount = 0; ++ ctx->deleted = 0; ++ ctx->new = 0; ++ ctx->unread = 0; ++ ctx->flagged = 0; ++ ctx->changed = 0; ++ ctx->id_hash = NULL; ++ ctx->subj_hash = NULL; ++ mx_update_context (ctx, ctx->msgcount); ++ } ++ ++ /* fetch headers of new articles */ ++ if (nntp_data->lastMessage > nntp_data->lastLoaded) ++ { ++ int oldmsgcount = ctx->msgcount; ++ int quiet = ctx->quiet; ++ ctx->quiet = 1; ++#ifdef USE_HCACHE ++ if (!hc) ++ { ++ hc = nntp_hcache_open (nntp_data); ++ nntp_hcache_update (nntp_data, hc); ++ } ++#endif ++ rc = nntp_fetch_headers (ctx, hc, nntp_data->lastLoaded + 1, ++ nntp_data->lastMessage, 0); ++ ctx->quiet = quiet; ++ if (rc >= 0) ++ nntp_data->lastLoaded = nntp_data->lastMessage; ++ if (ret == 0 && ctx->msgcount > oldmsgcount) ++ ret = M_NEW_MAIL; ++ } ++ ++#ifdef USE_HCACHE ++ mutt_hcache_close (hc); ++#endif ++ if (ret || !leave_lock) ++ nntp_newsrc_close (nserv); ++ mutt_clear_error (); ++ return ret; ++} ++ ++/* Check for new groups and new articles in subscribed groups: ++ * 1 - new groups found ++ * 0 - no new groups ++ * -1 - error */ ++int nntp_check_new_groups (NNTP_SERVER *nserv) ++{ ++ NNTP_DATA nntp_data; ++ time_t now; ++ struct tm *tm; ++ char buf[LONG_STRING]; ++ char *msg = _("Checking for new newsgroups..."); ++ unsigned int i; ++ int rc, update_active = FALSE; ++ ++ if (!nserv || !nserv->newgroups_time) ++ return -1; ++ ++ /* check subscribed newsgroups for new articles */ ++ if (option (OPTSHOWNEWNEWS)) ++ { ++ mutt_message _("Checking for new messages..."); ++ for (i = 0; i < nserv->groups_num; i++) ++ { ++ NNTP_DATA *nntp_data = nserv->groups_list[i]; ++ ++ if (nntp_data && nntp_data->subscribed) ++ { ++ rc = nntp_group_poll (nntp_data, 1); ++ if (rc < 0) ++ return -1; ++ if (rc > 0) ++ update_active = TRUE; ++ } ++ } ++ } ++ else if (nserv->newgroups_time) ++ return 0; ++ ++ /* get list of new groups */ ++ mutt_message (msg); ++ if (nntp_date (nserv, &now) < 0) ++ return -1; ++ nntp_data.nserv = nserv; ++ if (Context && Context->magic == M_NNTP) ++ nntp_data.group = ((NNTP_DATA *)Context->data)->group; ++ else ++ nntp_data.group = NULL; ++ i = nserv->groups_num; ++ tm = gmtime (&nserv->newgroups_time); ++ snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n", ++ tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday, ++ tm->tm_hour, tm->tm_min, tm->tm_sec); ++ rc = nntp_fetch_lines (&nntp_data, buf, sizeof (buf), msg, ++ nntp_add_group, nserv); ++ if (rc) ++ { ++ if (rc > 0) ++ { ++ mutt_error ("NEWGROUPS: %s", buf); ++ mutt_sleep (2); ++ } ++ return -1; ++ } ++ ++ /* new groups found */ ++ rc = 0; ++ if (nserv->groups_num != i) ++ { ++ nserv->newgroups_time = now; ++ ++ /* loading descriptions */ ++ if (option (OPTLOADDESC)) ++ { ++ unsigned int count = 0; ++ progress_t progress; ++ ++ mutt_progress_init (&progress, _("Loading descriptions..."), ++ M_PROGRESS_MSG, ReadInc, nserv->groups_num - i); ++ for (; i < nserv->groups_num; i++) ++ { ++ NNTP_DATA *nntp_data = nserv->groups_list[i]; ++ ++ if (get_description (nntp_data, NULL, NULL) < 0) ++ return -1; ++ mutt_progress_update (&progress, ++count, -1); ++ } ++ } ++ update_active = TRUE; ++ rc = 1; ++ } ++ if (update_active) ++ nntp_active_save_cache (nserv); ++ mutt_clear_error (); ++ return rc; ++} ++ ++/* Fetch article by Message-ID: ++ * 0 - success ++ * 1 - no such article ++ * -1 - error */ ++int nntp_check_msgid (CONTEXT *ctx, const char *msgid) ++{ ++ NNTP_DATA *nntp_data = ctx->data; ++ HEADER *hdr; ++ FILE *fp; ++ char tempfile[_POSIX_PATH_MAX]; ++ char buf[LONG_STRING]; ++ int rc; ++ ++ mutt_mktemp (tempfile, sizeof (tempfile)); ++ fp = safe_fopen (tempfile, "w+"); ++ if (!fp) ++ { ++ mutt_perror (tempfile); ++ unlink (tempfile); ++ return -1; ++ } ++ ++ snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid); ++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL, ++ fetch_tempfile, fp); ++ if (rc) ++ { ++ fclose (fp); ++ unlink (tempfile); ++ if (rc < 0) ++ return -1; ++ if (!mutt_strncmp ("430", buf, 3)) ++ return 1; ++ mutt_error ("HEAD: %s", buf); ++ return -1; ++ } ++ ++ /* parse header */ ++ if (ctx->msgcount == ctx->hdrmax) ++ mx_alloc_memory (ctx); ++ hdr = ctx->hdrs[ctx->msgcount] = mutt_new_header (); ++ hdr->data = safe_calloc (1, sizeof (NNTP_HEADER_DATA)); ++ hdr->env = mutt_read_rfc822_header (fp, hdr, 0, 0); ++ fclose (fp); ++ unlink (tempfile); ++ ++ /* get article number */ ++ if (hdr->env->xref) ++ nntp_parse_xref (ctx, hdr); ++ else ++ { ++ snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid); ++ if (nntp_query (nntp_data, buf, sizeof (buf)) < 0) ++ { ++ mutt_free_header (&hdr); ++ return -1; ++ } ++ sscanf (buf + 4, ANUM, &NHDR (hdr)->article_num); ++ } ++ ++ /* reset flags */ ++ hdr->read = 0; ++ hdr->old = 0; ++ hdr->deleted = 0; ++ hdr->changed = 1; ++ hdr->received = hdr->date_sent; ++ hdr->index = ctx->msgcount++; ++ mx_update_context (ctx, 1); ++ return 0; ++} ++ ++typedef struct ++{ ++ CONTEXT *ctx; ++ unsigned int num; ++ unsigned int max; ++ anum_t *child; ++} CHILD_CTX; ++ ++/* Parse XPAT line */ ++static int fetch_children (char *line, void *data) ++{ ++ CHILD_CTX *cc = data; ++ anum_t anum; ++ unsigned int i; ++ ++ if (!line || sscanf (line, ANUM, &anum) != 1) ++ return 0; ++ for (i = 0; i < cc->ctx->msgcount; i++) ++ if (NHDR (cc->ctx->hdrs[i])->article_num == anum) ++ return 0; ++ if (cc->num >= cc->max) ++ { ++ cc->max *= 2; ++ safe_realloc (&cc->child, sizeof (anum_t) * cc->max); ++ } ++ cc->child[cc->num++] = anum; ++ return 0; ++} ++ ++/* Fetch children of article with the Message-ID */ ++int nntp_check_children (CONTEXT *ctx, const char *msgid) ++{ ++ NNTP_DATA *nntp_data = ctx->data; ++ CHILD_CTX cc; ++ char buf[STRING]; ++ int i, rc, quiet; ++ void *hc = NULL; ++ ++ if (!nntp_data || !nntp_data->nserv) ++ return -1; ++ if (nntp_data->firstMessage > nntp_data->lastLoaded) ++ return 0; ++ ++ /* init context */ ++ cc.ctx = ctx; ++ cc.num = 0; ++ cc.max = 10; ++ cc.child = safe_malloc (sizeof (anum_t) * cc.max); ++ ++ /* fetch numbers of child messages */ ++ snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n", ++ nntp_data->firstMessage, nntp_data->lastLoaded, msgid); ++ rc = nntp_fetch_lines (nntp_data, buf, sizeof (buf), NULL, ++ fetch_children, &cc); ++ if (rc) ++ { ++ FREE (&cc.child); ++ if (rc > 0) { ++ if (mutt_strncmp ("500", buf, 3)) ++ mutt_error ("XPAT: %s", buf); ++ else ++ mutt_error _("Unable to find child articles because server does not support XPAT command."); ++ } ++ return -1; ++ } ++ ++ /* fetch all found messages */ ++ quiet = ctx->quiet; ++ ctx->quiet = 1; ++#ifdef USE_HCACHE ++ hc = nntp_hcache_open (nntp_data); ++#endif ++ for (i = 0; i < cc.num; i++) ++ { ++ rc = nntp_fetch_headers (ctx, hc, cc.child[i], cc.child[i], 1); ++ if (rc < 0) ++ break; ++ } ++#ifdef USE_HCACHE ++ mutt_hcache_close (hc); ++#endif ++ ctx->quiet = quiet; ++ FREE (&cc.child); ++ return rc < 0 ? -1 : 0; ++} +diff -udprP mutt-1.5.23.orig/nntp.h mutt-1.5.23/nntp.h +--- mutt-1.5.23.orig/nntp.h 1970-01-01 03:00:00.000000000 +0300 ++++ mutt-1.5.23/nntp.h 2014-03-13 12:48:37.000000000 +0200 +@@ -0,0 +1,167 @@ ++/* ++ * Copyright (C) 1998 Brandon Long <blong@fiction.net> ++ * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net> ++ * Copyright (C) 2000-2012 Vsevolod Volkov <vvv@mutt.org.ua> ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++ */ ++ ++#ifndef _NNTP_H_ ++#define _NNTP_H_ 1 ++ ++#include "mutt_socket.h" ++#include "mailbox.h" ++#include "bcache.h" ++ ++#if USE_HCACHE ++#include "hcache.h" ++#endif ++ ++#include <time.h> ++#include <sys/types.h> ++#include <stdint.h> ++ ++#define NNTP_PORT 119 ++#define NNTP_SSL_PORT 563 ++ ++/* number of entries in article cache */ ++#define NNTP_ACACHE_LEN 10 ++ ++/* article number type and format */ ++#define anum_t uint32_t ++#define ANUM "%u" ++ ++enum ++{ ++ NNTP_NONE = 0, ++ NNTP_OK, ++ NNTP_BYE ++}; ++ ++typedef struct ++{ ++ unsigned int hasCAPABILITIES : 1; ++ unsigned int hasSTARTTLS : 1; ++ unsigned int hasDATE : 1; ++ unsigned int hasLIST_NEWSGROUPS : 1; ++ unsigned int hasXGTITLE : 1; ++ unsigned int hasLISTGROUP : 1; ++ unsigned int hasOVER : 1; ++ unsigned int hasXOVER : 1; ++ unsigned int use_tls : 3; ++ unsigned int status : 3; ++ unsigned int cacheable : 1; ++ unsigned int newsrc_modified : 1; ++ FILE *newsrc_fp; ++ char *newsrc_file; ++ char *authenticators; ++ char *overview_fmt; ++ off_t size; ++ time_t mtime; ++ time_t newgroups_time; ++ time_t check_time; ++ unsigned int groups_num; ++ unsigned int groups_max; ++ void **groups_list; ++ HASH *groups_hash; ++ CONNECTION *conn; ++} NNTP_SERVER; ++ ++typedef struct ++{ ++ anum_t first; ++ anum_t last; ++} NEWSRC_ENTRY; ++ ++typedef struct ++{ ++ unsigned int index; ++ char *path; ++} NNTP_ACACHE; ++ ++typedef struct ++{ ++ char *group; ++ char *desc; ++ anum_t firstMessage; ++ anum_t lastMessage; ++ anum_t lastLoaded; ++ anum_t lastCached; ++ anum_t unread; ++ unsigned int subscribed : 1; ++ unsigned int new : 1; ++ unsigned int allowed : 1; ++ unsigned int deleted : 1; ++ unsigned int newsrc_len; ++ NEWSRC_ENTRY *newsrc_ent; ++ NNTP_SERVER *nserv; ++ NNTP_ACACHE acache[NNTP_ACACHE_LEN]; ++ body_cache_t *bcache; ++} NNTP_DATA; ++ ++typedef struct ++{ ++ anum_t article_num; ++ unsigned int parsed : 1; ++} NNTP_HEADER_DATA; ++ ++#define NHDR(hdr) ((NNTP_HEADER_DATA*)((hdr)->data)) ++ ++/* internal functions */ ++int nntp_add_group (char *, void *); ++int nntp_active_save_cache (NNTP_SERVER *); ++int nntp_check_new_groups (NNTP_SERVER *); ++int nntp_fastclose_mailbox (CONTEXT *); ++int nntp_open_connection (NNTP_SERVER *); ++void nntp_newsrc_gen_entries (CONTEXT *); ++void nntp_bcache_update (NNTP_DATA *); ++void nntp_article_status (CONTEXT *, HEADER *, char *, anum_t); ++void nntp_group_unread_stat (NNTP_DATA *); ++void nntp_data_free (void *); ++void nntp_acache_free (NNTP_DATA *); ++void nntp_delete_group_cache (NNTP_DATA *); ++ ++/* exposed interface */ ++NNTP_SERVER *nntp_select_server (char *, int); ++NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *); ++NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *); ++NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *); ++NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *); ++int nntp_active_fetch (NNTP_SERVER *); ++int nntp_newsrc_update (NNTP_SERVER *); ++int nntp_open_mailbox (CONTEXT *); ++int nntp_sync_mailbox (CONTEXT *); ++int nntp_check_mailbox (CONTEXT *, int); ++int nntp_fetch_message (MESSAGE *, CONTEXT *, int); ++int nntp_post (const char *); ++int nntp_check_msgid (CONTEXT *, const char *); ++int nntp_check_children (CONTEXT *, const char *); ++int nntp_newsrc_parse (NNTP_SERVER *); ++void nntp_newsrc_close (NNTP_SERVER *); ++void nntp_buffy (char *, size_t); ++void nntp_expand_path (char *, size_t, ACCOUNT *); ++void nntp_clear_cache (NNTP_SERVER *); ++const char *nntp_format_str (char *, size_t, size_t, char, const char *, ++ const char *, const char *, const char *, ++ unsigned long, format_flag); ++ ++NNTP_SERVER *CurrentNewsSrv INITVAL (NULL); ++ ++#ifdef USE_HCACHE ++header_cache_t *nntp_hcache_open (NNTP_DATA *); ++void nntp_hcache_update (NNTP_DATA *, header_cache_t *); ++#endif ++ ++#endif /* _NNTP_H_ */ +diff -udprP mutt-1.5.23.orig/pager.c mutt-1.5.23/pager.c +--- mutt-1.5.23.orig/pager.c 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23/pager.c 2014-03-13 12:48:37.000000000 +0200 +@@ -1084,6 +1084,11 @@ fill_buffer (FILE *f, LOFF_T *last_pos, + return b_read; + } + ++#ifdef USE_NNTP ++#include "mx.h" ++#include "nntp.h" ++#endif ++ + + static int format_line (struct line_t **lineInfo, int n, unsigned char *buf, + int flags, ansi_attr *pa, int cnt, +@@ -1541,6 +1546,16 @@ static const struct mapping_t PagerHelpE + { NULL, 0 } + }; + ++#ifdef USE_NNTP ++static struct mapping_t PagerNewsHelpExtra[] = { ++ { N_("Post"), OP_POST }, ++ { N_("Followup"), OP_FOLLOWUP }, ++ { N_("Del"), OP_DELETE }, ++ { N_("Next"), OP_MAIN_NEXT_UNDELETED }, ++ { NULL, 0 } ++}; ++#endif ++ + + + /* This pager is actually not so simple as it once was. It now operates in +@@ -1582,6 +1597,10 @@ mutt_pager (const char *banner, const ch + int old_PagerIndexLines; /* some people want to resize it + * while inside the pager... */ + ++#ifdef USE_NNTP ++ char *followup_to; ++#endif ++ + if (!(flags & M_SHOWCOLOR)) + flags |= M_SHOWFLAT; + +@@ -1621,7 +1640,11 @@ mutt_pager (const char *banner, const ch + if (IsHeader (extra)) + { + strfcpy (tmphelp, helpstr, sizeof (tmphelp)); +- mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, PagerHelpExtra); ++ mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, ++#ifdef USE_NNTP ++ (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra : ++#endif ++ PagerHelpExtra); + snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer); + } + if (!InHelp) +@@ -2532,6 +2555,60 @@ search_next: + redraw = REDRAW_FULL; + break; + ++#ifdef USE_NNTP ++ case OP_POST: ++ CHECK_MODE(IsHeader (extra) && !IsAttach (extra)); ++ CHECK_ATTACH; ++ if (extra->ctx && extra->ctx->magic == M_NNTP && ++ !((NNTP_DATA *)extra->ctx->data)->allowed && ++ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) ++ break; ++ ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL); ++ redraw = REDRAW_FULL; ++ break; ++ ++ case OP_FORWARD_TO_GROUP: ++ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); ++ CHECK_ATTACH; ++ if (extra->ctx && extra->ctx->magic == M_NNTP && ++ !((NNTP_DATA *)extra->ctx->data)->allowed && ++ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) ++ break; ++ if (IsMsgAttach (extra)) ++ mutt_attach_forward (extra->fp, extra->hdr, extra->idx, ++ extra->idxlen, extra->bdy, SENDNEWS); ++ else ++ ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); ++ redraw = REDRAW_FULL; ++ break; ++ ++ case OP_FOLLOWUP: ++ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); ++ CHECK_ATTACH; ++ ++ if (IsMsgAttach (extra)) ++ followup_to = extra->bdy->hdr->env->followup_to; ++ else ++ followup_to = extra->hdr->env->followup_to; ++ ++ if (!followup_to || mutt_strcasecmp (followup_to, "poster") || ++ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES) ++ { ++ if (extra->ctx && extra->ctx->magic == M_NNTP && ++ !((NNTP_DATA *)extra->ctx->data)->allowed && ++ query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES) ++ break; ++ if (IsMsgAttach (extra)) ++ mutt_attach_reply (extra->fp, extra->hdr, extra->idx, ++ extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY); ++ else ++ ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, ++ extra->ctx, extra->hdr); ++ redraw = REDRAW_FULL; ++ break; ++ } ++#endif ++ + case OP_REPLY: + CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); + CHECK_ATTACH; +@@ -2578,7 +2655,7 @@ search_next: + CHECK_ATTACH; + if (IsMsgAttach (extra)) + mutt_attach_forward (extra->fp, extra->hdr, extra->idx, +- extra->idxlen, extra->bdy); ++ extra->idxlen, extra->bdy, 0); + else + ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); + redraw = REDRAW_FULL; +diff -udprP mutt-1.5.23.orig/parse.c mutt-1.5.23/parse.c +--- mutt-1.5.23.orig/parse.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/parse.c 2014-03-13 12:48:37.000000000 +0200 +@@ -89,7 +89,7 @@ char *mutt_read_rfc822_line (FILE *f, ch + /* not reached */ + } + +-static LIST *mutt_parse_references (char *s, int in_reply_to) ++LIST *mutt_parse_references (char *s, int in_reply_to) + { + LIST *t, *lst = NULL; + char *m; +@@ -1072,6 +1072,17 @@ int mutt_parse_rfc822_line (ENVELOPE *e, + e->from = rfc822_parse_adrlist (e->from, p); + matched = 1; + } ++#ifdef USE_NNTP ++ else if (!mutt_strcasecmp (line+1, "ollowup-to")) ++ { ++ if (!e->followup_to) ++ { ++ mutt_remove_trailing_ws (p); ++ e->followup_to = safe_strdup (mutt_skip_whitespace (p)); ++ } ++ matched = 1; ++ } ++#endif + break; + + case 'i': +@@ -1154,6 +1165,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e, + } + break; + ++#ifdef USE_NNTP ++ case 'n': ++ if (!mutt_strcasecmp (line + 1, "ewsgroups")) ++ { ++ FREE (&e->newsgroups); ++ mutt_remove_trailing_ws (p); ++ e->newsgroups = safe_strdup (mutt_skip_whitespace (p)); ++ matched = 1; ++ } ++ break; ++#endif ++ ++ case 'o': ++ /* field `Organization:' saves only for pager! */ ++ if (!mutt_strcasecmp (line + 1, "rganization")) ++ { ++ if (!e->organization && mutt_strcasecmp (p, "unknown")) ++ e->organization = safe_strdup (p); ++ } ++ break; ++ + case 'r': + if (!ascii_strcasecmp (line + 1, "eferences")) + { +@@ -1266,6 +1298,20 @@ int mutt_parse_rfc822_line (ENVELOPE *e, + e->x_label = safe_strdup(p); + matched = 1; + } ++#ifdef USE_NNTP ++ else if (!mutt_strcasecmp (line + 1, "-comment-to")) ++ { ++ if (!e->x_comment_to) ++ e->x_comment_to = safe_strdup (p); ++ matched = 1; ++ } ++ else if (!mutt_strcasecmp (line + 1, "ref")) ++ { ++ if (!e->xref) ++ e->xref = safe_strdup (p); ++ matched = 1; ++ } ++#endif + + default: + break; +diff -udprP mutt-1.5.23.orig/pattern.c mutt-1.5.23/pattern.c +--- mutt-1.5.23.orig/pattern.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/pattern.c 2014-03-13 12:48:37.000000000 +0200 +@@ -92,6 +92,9 @@ Flags[] = + { 'U', M_UNREAD, 0, NULL }, + { 'v', M_COLLAPSED, 0, NULL }, + { 'V', M_CRYPT_VERIFIED, 0, NULL }, ++#ifdef USE_NNTP ++ { 'w', M_NEWSGROUPS, 0, eat_regexp }, ++#endif + { 'x', M_REFERENCE, 0, eat_regexp }, + { 'X', M_MIMEATTACH, 0, eat_range }, + { 'y', M_XLABEL, 0, eat_regexp }, +@@ -1213,6 +1216,10 @@ mutt_pattern_exec (struct pattern_t *pat + } + case M_UNREFERENCED: + return (pat->not ^ (h->thread && !h->thread->child)); ++#ifdef USE_NNTP ++ case M_NEWSGROUPS: ++ return (pat->not ^ (h->env->newsgroups && patmatch (pat, h->env->newsgroups) == 0)); ++#endif + } + mutt_error (_("error: unknown op %d (report this error)."), pat->op); + return (-1); +@@ -1294,6 +1301,7 @@ int mutt_pattern_func (int op, char *pro + progress_t progress; + + strfcpy (buf, NONULL (Context->pattern), sizeof (buf)); ++ if (prompt || op != M_LIMIT) + if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0]) + return (-1); + +diff -udprP mutt-1.5.23.orig/po/POTFILES.in mutt-1.5.23/po/POTFILES.in +--- mutt-1.5.23.orig/po/POTFILES.in 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/po/POTFILES.in 2014-03-13 12:48:37.000000000 +0200 +@@ -46,6 +46,8 @@ mutt_ssl_gnutls.c + mutt_tunnel.c + muttlib.c + mx.c ++newsrc.c ++nntp.c + pager.c + parse.c + pattern.c +diff -udprP mutt-1.5.23.orig/postpone.c mutt-1.5.23/postpone.c +--- mutt-1.5.23.orig/postpone.c 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23/postpone.c 2014-03-13 12:48:37.000000000 +0200 +@@ -125,15 +125,26 @@ int mutt_num_postponed (int force) + + if (LastModify < st.st_mtime) + { ++#ifdef USE_NNTP ++ int optnews = option (OPTNEWS); ++#endif + LastModify = st.st_mtime; + + if (access (Postponed, R_OK | F_OK) != 0) + return (PostCount = 0); ++#ifdef USE_NNTP ++ if (optnews) ++ unset_option (OPTNEWS); ++#endif + if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL) + PostCount = 0; + else + PostCount = ctx.msgcount; + mx_fastclose_mailbox (&ctx); ++#ifdef USE_NNTP ++ if (optnews) ++ set_option (OPTNEWS); ++#endif + } + + return (PostCount); +diff -udprP mutt-1.5.23.orig/protos.h mutt-1.5.23/protos.h +--- mutt-1.5.23.orig/protos.h 2014-03-12 18:06:17.000000000 +0200 ++++ mutt-1.5.23/protos.h 2014-03-13 12:48:37.000000000 +0200 +@@ -111,6 +111,7 @@ HASH *mutt_make_id_hash (CONTEXT *); + HASH *mutt_make_subj_hash (CONTEXT *); + + LIST *mutt_make_references(ENVELOPE *e); ++LIST *mutt_parse_references (char *, int); + + char *mutt_read_rfc822_line (FILE *, char *, size_t *); + ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short); +diff -udprP mutt-1.5.23.orig/recvattach.c mutt-1.5.23/recvattach.c +--- mutt-1.5.23.orig/recvattach.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/recvattach.c 2014-03-13 12:48:37.000000000 +0200 +@@ -1119,6 +1119,15 @@ void mutt_view_attachments (HEADER *hdr) + } + #endif + ++#ifdef USE_NNTP ++ if (Context->magic == M_NNTP) ++ { ++ mutt_flushinp (); ++ mutt_error _("Can't delete attachment from news server."); ++ break; ++ } ++#endif ++ + if (WithCrypto && hdr->security & ~PGP_TRADITIONAL_CHECKED) + { + mutt_message _( +@@ -1210,10 +1219,33 @@ void mutt_view_attachments (HEADER *hdr) + case OP_FORWARD_MESSAGE: + CHECK_ATTACH; + mutt_attach_forward (fp, hdr, idx, idxlen, +- menu->tagprefix ? NULL : idx[menu->current]->content); ++ menu->tagprefix ? NULL : idx[menu->current]->content, 0); + menu->redraw = REDRAW_FULL; + break; + ++#ifdef USE_NNTP ++ case OP_FORWARD_TO_GROUP: ++ CHECK_ATTACH; ++ mutt_attach_forward (fp, hdr, idx, idxlen, ++ menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS); ++ menu->redraw = REDRAW_FULL; ++ break; ++ ++ case OP_FOLLOWUP: ++ CHECK_ATTACH; ++ ++ if (!idx[menu->current]->content->hdr->env->followup_to || ++ mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") || ++ query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES) ++ { ++ mutt_attach_reply (fp, hdr, idx, idxlen, ++ menu->tagprefix ? NULL : idx[menu->current]->content, ++ SENDNEWS|SENDREPLY); ++ menu->redraw = REDRAW_FULL; ++ break; ++ } ++#endif ++ + case OP_REPLY: + case OP_GROUP_REPLY: + case OP_LIST_REPLY: +diff -udprP mutt-1.5.23.orig/recvcmd.c mutt-1.5.23/recvcmd.c +--- mutt-1.5.23.orig/recvcmd.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/recvcmd.c 2014-03-13 12:48:37.000000000 +0200 +@@ -401,7 +401,7 @@ static BODY ** copy_problematic_attachme + static void attach_forward_bodies (FILE * fp, HEADER * hdr, + ATTACHPTR ** idx, short idxlen, + BODY * cur, +- short nattach) ++ short nattach, int flags) + { + short i; + short mime_fwd_all = 0; +@@ -547,7 +547,7 @@ _("Can't decode all tagged attachments. + tmpfp = NULL; + + /* now that we have the template, send it. */ +- ci_send_message (0, tmphdr, tmpbody, NULL, parent); ++ ci_send_message (flags, tmphdr, tmpbody, NULL, parent); + return; + + bail: +@@ -574,7 +574,7 @@ _("Can't decode all tagged attachments. + */ + + static void attach_forward_msgs (FILE * fp, HEADER * hdr, +- ATTACHPTR ** idx, short idxlen, BODY * cur) ++ ATTACHPTR ** idx, short idxlen, BODY * cur, int flags) + { + HEADER *curhdr = NULL; + HEADER *tmphdr; +@@ -679,23 +679,23 @@ static void attach_forward_msgs (FILE * + else + mutt_free_header (&tmphdr); + +- ci_send_message (0, tmphdr, *tmpbody ? tmpbody : NULL, ++ ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL, + NULL, curhdr); + + } + + void mutt_attach_forward (FILE * fp, HEADER * hdr, +- ATTACHPTR ** idx, short idxlen, BODY * cur) ++ ATTACHPTR ** idx, short idxlen, BODY * cur, int flags) + { + short nattach; + + + if (check_all_msg (idx, idxlen, cur, 0) == 0) +- attach_forward_msgs (fp, hdr, idx, idxlen, cur); ++ attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags); + else + { + nattach = count_tagged (idx, idxlen); +- attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach); ++ attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags); + } + } + +@@ -753,28 +753,40 @@ attach_reply_envelope_defaults (ENVELOPE + return -1; + } + +- if (parent) ++#ifdef USE_NNTP ++ if ((flags & SENDNEWS)) + { +- if (mutt_fetch_recips (env, curenv, flags) == -1) +- return -1; ++ /* in case followup set Newsgroups: with Followup-To: if it present */ ++ if (!env->newsgroups && curenv && ++ mutt_strcasecmp (curenv->followup_to, "poster")) ++ env->newsgroups = safe_strdup (curenv->followup_to); + } + else ++#endif + { +- for (i = 0; i < idxlen; i++) ++ if (parent) + { +- if (idx[i]->content->tagged +- && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1) ++ if (mutt_fetch_recips (env, curenv, flags) == -1) + return -1; + } ++ else ++ { ++ for (i = 0; i < idxlen; i++) ++ { ++ if (idx[i]->content->tagged ++ && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1) ++ return -1; ++ } ++ } ++ ++ if ((flags & SENDLISTREPLY) && !env->to) ++ { ++ mutt_error _("No mailing lists found!"); ++ return (-1); ++ } ++ ++ mutt_fix_reply_recipients (env); + } +- +- if ((flags & SENDLISTREPLY) && !env->to) +- { +- mutt_error _("No mailing lists found!"); +- return (-1); +- } +- +- mutt_fix_reply_recipients (env); + mutt_make_misc_reply_headers (env, Context, curhdr, curenv); + + if (parent) +@@ -835,6 +847,13 @@ void mutt_attach_reply (FILE * fp, HEADE + char prefix[SHORT_STRING]; + int rc; + ++#ifdef USE_NNTP ++ if (flags & SENDNEWS) ++ set_option (OPTNEWSSEND); ++ else ++ unset_option (OPTNEWSSEND); ++#endif ++ + if (check_all_msg (idx, idxlen, cur, 0) == -1) + { + nattach = count_tagged (idx, idxlen); +diff -udprP mutt-1.5.23.orig/send.c mutt-1.5.23/send.c +--- mutt-1.5.23.orig/send.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/send.c 2014-03-13 12:48:37.000000000 +0200 +@@ -44,6 +44,11 @@ + #include <sys/types.h> + #include <utime.h> + ++#ifdef USE_NNTP ++#include "nntp.h" ++#include "mx.h" ++#endif ++ + #ifdef MIXMASTER + #include "remailer.h" + #endif +@@ -213,17 +218,51 @@ static int edit_address (ADDRESS **a, /* + return 0; + } + +-static int edit_envelope (ENVELOPE *en) ++static int edit_envelope (ENVELOPE *en, int flags) + { + char buf[HUGE_STRING]; + LIST *uh = UserHeader; + +- if (edit_address (&en->to, "To: ") == -1 || en->to == NULL) +- return (-1); +- if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1) +- return (-1); +- if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1) +- return (-1); ++#ifdef USE_NNTP ++ if (option (OPTNEWSSEND)) ++ { ++ if (en->newsgroups) ++ strfcpy (buf, en->newsgroups, sizeof (buf)); ++ else ++ buf[0] = 0; ++ if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0) ++ return (-1); ++ FREE (&en->newsgroups); ++ en->newsgroups = safe_strdup (buf); ++ ++ if (en->followup_to) ++ strfcpy (buf, en->followup_to, sizeof (buf)); ++ else ++ buf[0] = 0; ++ if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0) ++ return (-1); ++ FREE (&en->followup_to); ++ en->followup_to = safe_strdup (buf); ++ ++ if (en->x_comment_to) ++ strfcpy (buf, en->x_comment_to, sizeof (buf)); ++ else ++ buf[0] = 0; ++ if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0) ++ return (-1); ++ FREE (&en->x_comment_to); ++ en->x_comment_to = safe_strdup (buf); ++ } ++ else ++#endif ++ { ++ if (edit_address (&en->to, "To: ") == -1 || en->to == NULL) ++ return (-1); ++ if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1) ++ return (-1); ++ if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1) ++ return (-1); ++ } + + if (en->subject) + { +@@ -258,6 +297,14 @@ static int edit_envelope (ENVELOPE *en) + return 0; + } + ++#ifdef USE_NNTP ++char *nntp_get_header (const char *s) ++{ ++ SKIPWS (s); ++ return safe_strdup (s); ++} ++#endif ++ + static void process_user_recips (ENVELOPE *env) + { + LIST *uh = UserHeader; +@@ -270,6 +317,14 @@ static void process_user_recips (ENVELOP + env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3); + else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0) + env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4); ++#ifdef USE_NNTP ++ else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0) ++ env->newsgroups = nntp_get_header (uh->data + 11); ++ else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0) ++ env->followup_to = nntp_get_header (uh->data + 12); ++ else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0) ++ env->x_comment_to = nntp_get_header (uh->data + 13); ++#endif + } + } + +@@ -308,6 +363,12 @@ static void process_user_header (ENVELOP + else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 && + ascii_strncasecmp ("cc:", uh->data, 3) != 0 && + ascii_strncasecmp ("bcc:", uh->data, 4) != 0 && ++#ifdef USE_NNTP ++ ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 && ++ ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 && ++ ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 && ++#endif ++ ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 && + ascii_strncasecmp ("subject:", uh->data, 8) != 0 && + ascii_strncasecmp ("return-path:", uh->data, 12) != 0) + { +@@ -656,6 +717,10 @@ void mutt_add_to_reference_headers (ENVE + if (pp) *pp = p; + if (qq) *qq = q; + ++#ifdef USE_NNTP ++ if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from) ++ env->x_comment_to = safe_strdup (mutt_get_name (curenv->from)); ++#endif + } + + static void +@@ -718,6 +783,16 @@ envelope_defaults (ENVELOPE *env, CONTEX + + if (flags & SENDREPLY) + { ++#ifdef USE_NNTP ++ if ((flags & SENDNEWS)) ++ { ++ /* in case followup set Newsgroups: with Followup-To: if it present */ ++ if (!env->newsgroups && curenv && ++ mutt_strcasecmp (curenv->followup_to, "poster")) ++ env->newsgroups = safe_strdup (curenv->followup_to); ++ } ++ else ++#endif + if (tag) + { + HEADER *h; +@@ -864,7 +939,18 @@ void mutt_set_followup_to (ENVELOPE *e) + * it hasn't already been set + */ + +- if (option (OPTFOLLOWUPTO) && !e->mail_followup_to) ++ if (!option (OPTFOLLOWUPTO)) ++ return; ++#ifdef USE_NNTP ++ if (option (OPTNEWSSEND)) ++ { ++ if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ','))) ++ e->followup_to = safe_strdup (e->newsgroups); ++ return; ++ } ++#endif ++ ++ if (!e->mail_followup_to) + { + if (mutt_is_list_cc (0, e->to, e->cc)) + { +@@ -1026,6 +1112,9 @@ static int send_message (HEADER *msg) + #endif + + #if USE_SMTP ++#ifdef USE_NNTP ++ if (!option (OPTNEWSSEND)) ++#endif + if (SmtpUrl) + return mutt_smtp_send (msg->env->from, msg->env->to, msg->env->cc, + msg->env->bcc, tempfile, +@@ -1137,6 +1226,13 @@ ci_send_message (int flags, /* send mod + + int rv = -1; + ++#ifdef USE_NNTP ++ if (flags & SENDNEWS) ++ set_option (OPTNEWSSEND); ++ else ++ unset_option (OPTNEWSSEND); ++#endif ++ + if (!flags && !msg && quadoption (OPT_RECALL) != M_NO && + mutt_num_postponed (1)) + { +@@ -1167,6 +1263,22 @@ ci_send_message (int flags, /* send mod + { + if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0) + goto cleanup; ++#ifdef USE_NNTP ++ /* ++ * If postponed message is a news article, it have ++ * a "Newsgroups:" header line, then set appropriate flag. ++ */ ++ if (msg->env->newsgroups) ++ { ++ flags |= SENDNEWS; ++ set_option (OPTNEWSSEND); ++ } ++ else ++ { ++ flags &= ~SENDNEWS; ++ unset_option (OPTNEWSSEND); ++ } ++#endif + } + + if (flags & (SENDPOSTPONED|SENDRESEND)) +@@ -1259,11 +1371,16 @@ ci_send_message (int flags, /* send mod + if (flags & SENDREPLY) + mutt_fix_reply_recipients (msg->env); + ++#ifdef USE_NNTP ++ if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups) ++ msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group); ++#endif ++ + if (! (flags & (SENDMAILX|SENDBATCH)) && + ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) && + ! ((flags & SENDREPLY) && option (OPTFASTREPLY))) + { +- if (edit_envelope (msg->env) == -1) ++ if (edit_envelope (msg->env, flags) == -1) + goto cleanup; + } + +@@ -1546,6 +1663,11 @@ main_loop: + if (i == -1) + { + /* abort */ ++#ifdef USE_NNTP ++ if (flags & SENDNEWS) ++ mutt_message _("Article not posted."); ++ else ++#endif + mutt_message _("Mail not sent."); + goto cleanup; + } +@@ -1578,6 +1700,9 @@ main_loop: + } + } + ++#ifdef USE_NNTP ++ if (!(flags & SENDNEWS)) ++#endif + if (!has_recips (msg->env->to) && !has_recips (msg->env->cc) && + !has_recips (msg->env->bcc)) + { +@@ -1611,6 +1736,19 @@ main_loop: + mutt_error _("No subject specified."); + goto main_loop; + } ++#ifdef USE_NNTP ++ if ((flags & SENDNEWS) && !msg->env->subject) ++ { ++ mutt_error _("No subject specified."); ++ goto main_loop; ++ } ++ ++ if ((flags & SENDNEWS) && !msg->env->newsgroups) ++ { ++ mutt_error _("No newsgroup specified."); ++ goto main_loop; ++ } ++#endif + + if (msg->content->next) + msg->content = mutt_make_multipart (msg->content); +@@ -1817,7 +1955,12 @@ full_fcc: + } + } + else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX)) +- mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background.")); ++ mutt_message (i != 0 ? _("Sending in background.") : ++#ifdef USE_NNTP ++ (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent.")); ++#else ++ _("Mail sent.")); ++#endif + + if (WithCrypto && (msg->security & ENCRYPT)) + FREE (&pgpkeylist); +diff -udprP mutt-1.5.23.orig/sendlib.c mutt-1.5.23/sendlib.c +--- mutt-1.5.23.orig/sendlib.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/sendlib.c 2014-03-13 12:48:37.000000000 +0200 +@@ -46,6 +46,10 @@ + #include <sys/wait.h> + #include <fcntl.h> + ++#ifdef USE_NNTP ++#include "nntp.h" ++#endif ++ + #ifdef HAVE_SYSEXITS_H + #include <sysexits.h> + #else /* Make sure EX_OK is defined <philiph@pobox.com> */ +@@ -1543,6 +1547,14 @@ void mutt_write_references (LIST *r, FIL + { + LIST **ref = NULL; + int refcnt = 0, refmax = 0; ++ int multiline = 1; ++ int space = 0; ++ ++ if (trim < 0) ++ { ++ trim = -trim; ++ multiline = 0; ++ } + + for ( ; (trim == 0 || refcnt < trim) && r ; r = r->next) + { +@@ -1553,9 +1565,11 @@ void mutt_write_references (LIST *r, FIL + + while (refcnt-- > 0) + { +- fputc (' ', f); ++ if (multiline || space) ++ fputc (' ', f); ++ space = 1; + fputs (ref[refcnt]->data, f); +- if (refcnt >= 1) ++ if (multiline && refcnt >= 1) + fputc ('\n', f); + } + +@@ -1962,6 +1976,9 @@ int mutt_write_rfc822_header (FILE *fp, + mutt_write_address_list (env->to, fp, 4, 0); + } + else if (mode > 0) ++#ifdef USE_NNTP ++ if (!option (OPTNEWSSEND)) ++#endif + fputs ("To: \n", fp); + + if (env->cc) +@@ -1970,6 +1987,9 @@ int mutt_write_rfc822_header (FILE *fp, + mutt_write_address_list (env->cc, fp, 4, 0); + } + else if (mode > 0) ++#ifdef USE_NNTP ++ if (!option (OPTNEWSSEND)) ++#endif + fputs ("Cc: \n", fp); + + if (env->bcc) +@@ -1981,8 +2001,28 @@ int mutt_write_rfc822_header (FILE *fp, + } + } + else if (mode > 0) ++#ifdef USE_NNTP ++ if (!option (OPTNEWSSEND)) ++#endif + fputs ("Bcc: \n", fp); + ++#ifdef USE_NNTP ++ if (env->newsgroups) ++ fprintf (fp, "Newsgroups: %s\n", env->newsgroups); ++ else if (mode == 1 && option (OPTNEWSSEND)) ++ fputs ("Newsgroups: \n", fp); ++ ++ if (env->followup_to) ++ fprintf (fp, "Followup-To: %s\n", env->followup_to); ++ else if (mode == 1 && option (OPTNEWSSEND)) ++ fputs ("Followup-To: \n", fp); ++ ++ if (env->x_comment_to) ++ fprintf (fp, "X-Comment-To: %s\n", env->x_comment_to); ++ else if (mode == 1 && option (OPTNEWSSEND) && option (OPTXCOMMENTTO)) ++ fputs ("X-Comment-To: \n", fp); ++#endif ++ + if (env->subject) + mutt_write_one_header (fp, "Subject", env->subject, NULL, 0, 0); + else if (mode == 1) +@@ -2001,6 +2041,9 @@ int mutt_write_rfc822_header (FILE *fp, + fputs ("Reply-To: \n", fp); + + if (env->mail_followup_to) ++#ifdef USE_NNTP ++ if (!option (OPTNEWSSEND)) ++#endif + { + fputs ("Mail-Followup-To: ", fp); + mutt_write_address_list (env->mail_followup_to, fp, 18, 0); +@@ -2344,6 +2387,23 @@ mutt_invoke_sendmail (ADDRESS *from, /* + size_t argslen = 0, argsmax = 0; + int i; + ++#ifdef USE_NNTP ++ if (option (OPTNEWSSEND)) ++ { ++ char cmd[LONG_STRING]; ++ ++ mutt_FormatString (cmd, sizeof (cmd), 0, NONULL (Inews), nntp_format_str, 0, 0); ++ if (!*cmd) ++ { ++ i = nntp_post (msg); ++ unlink (msg); ++ return i; ++ } ++ ++ s = safe_strdup (cmd); ++ } ++#endif ++ + /* ensure that $sendmail is set to avoid a crash. http://dev.mutt.org/trac/ticket/3548 */ + if (!s) + { +@@ -2374,6 +2434,10 @@ mutt_invoke_sendmail (ADDRESS *from, /* + i++; + } + ++#ifdef USE_NNTP ++ if (!option (OPTNEWSSEND)) ++ { ++#endif + if (eightbit && option (OPTUSE8BITMIME)) + args = add_option (args, &argslen, &argsmax, "-B8BITMIME"); + +@@ -2405,6 +2469,9 @@ mutt_invoke_sendmail (ADDRESS *from, /* + args = add_args (args, &argslen, &argsmax, to); + args = add_args (args, &argslen, &argsmax, cc); + args = add_args (args, &argslen, &argsmax, bcc); ++#ifdef USE_NNTP ++ } ++#endif + + if (argslen == argsmax) + safe_realloc (&args, sizeof (char *) * (++argsmax)); +@@ -2485,6 +2552,9 @@ void mutt_prepare_envelope (ENVELOPE *en + rfc2047_encode_string (&env->x_label); + + if (env->subject) ++#ifdef USE_NNTP ++ if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT)) ++#endif + { + rfc2047_encode_string (&env->subject); + } +@@ -2605,6 +2675,10 @@ int mutt_bounce_message (FILE *fp, HEADE + } + rfc822_write_address (resent_from, sizeof (resent_from), from, 0); + ++#ifdef USE_NNTP ++ unset_option (OPTNEWSSEND); ++#endif ++ + /* + * prepare recipient list. idna conversion appears to happen before this + * function is called, since the user receives confirmation of the address +diff -udprP mutt-1.5.23.orig/sort.c mutt-1.5.23/sort.c +--- mutt-1.5.23.orig/sort.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/sort.c 2014-03-13 12:48:37.000000000 +0200 +@@ -24,6 +24,11 @@ + #include "sort.h" + #include "mutt_idna.h" + ++#ifdef USE_NNTP ++#include "mx.h" ++#include "nntp.h" ++#endif ++ + #include <stdlib.h> + #include <string.h> + #include <ctype.h> +@@ -151,6 +156,17 @@ static int compare_order (const void *a, + HEADER **ha = (HEADER **) a; + HEADER **hb = (HEADER **) b; + ++#ifdef USE_NNTP ++ if (Context && Context->magic == M_NNTP) ++ { ++ anum_t na = NHDR (*ha)->article_num; ++ anum_t nb = NHDR (*hb)->article_num; ++ int result = na == nb ? 0 : na > nb ? 1 : -1; ++ AUXSORT (result, a, b); ++ return (SORTCODE (result)); ++ } ++ else ++#endif + /* no need to auxsort because you will never have equality here */ + return (SORTCODE ((*ha)->index - (*hb)->index)); + } +diff -udprP mutt-1.5.23.orig/url.c mutt-1.5.23/url.c +--- mutt-1.5.23.orig/url.c 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/url.c 2014-03-13 12:48:37.000000000 +0200 +@@ -39,6 +39,8 @@ static const struct mapping_t UrlMap[] = + { "imaps", U_IMAPS }, + { "pop", U_POP }, + { "pops", U_POPS }, ++ { "news", U_NNTP }, ++ { "snews", U_NNTPS }, + { "mailto", U_MAILTO }, + { "smtp", U_SMTP }, + { "smtps", U_SMTPS }, +@@ -214,7 +216,7 @@ int url_ciss_tostring (ciss_url_t* ciss, + safe_strcat (dest, len, "//"); + len -= (l = strlen (dest)); dest += l; + +- if (ciss->user) ++ if (ciss->user && (ciss->user[0] || !(flags & U_PATH))) + { + char u[STRING]; + url_pct_encode (u, sizeof (u), ciss->user); +diff -udprP mutt-1.5.23.orig/url.h mutt-1.5.23/url.h +--- mutt-1.5.23.orig/url.h 2014-03-12 18:03:45.000000000 +0200 ++++ mutt-1.5.23/url.h 2014-03-13 12:48:37.000000000 +0200 +@@ -8,6 +8,8 @@ typedef enum url_scheme + U_POPS, + U_IMAP, + U_IMAPS, ++ U_NNTP, ++ U_NNTPS, + U_SMTP, + U_SMTPS, + U_MAILTO, +diff -udprP mutt-1.5.23.orig/Makefile.am mutt-1.5.23/Makefile.am +--- mutt-1.5.23.orig/Makefile.am 2014-03-12 18:03:44.000000000 +0200 ++++ mutt-1.5.23/Makefile.am 2014-03-13 12:48:37.000000000 +0200 +@@ -57,6 +57,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c + mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \ + mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \ + pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \ ++ nntp.c newsrc.c \ + smime.c smtp.c utf8.c wcwidth.c \ + bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h + +@@ -68,6 +69,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O + mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \ + mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \ + rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \ ++ nntp.h ChangeLog.nntp \ + _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \ + mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \ + README.SSL smime.h group.h \ +diff -udprP mutt-1.5.23.orig/Makefile.in mutt-1.5.23/Makefile.in +--- mutt-1.5.23.orig/Makefile.in 2014-03-12 18:26:44.000000000 +0200 ++++ mutt-1.5.23/Makefile.in 2014-03-13 12:48:37.000000000 +0200 +@@ -484,6 +484,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c + mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \ + mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \ + pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \ ++ nntp.c newsrc.c \ + smime.c smtp.c utf8.c wcwidth.c \ + bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h + +@@ -495,6 +496,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP O + mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \ + mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \ + rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types VERSION prepare \ ++ nntp.h ChangeLog.nntp \ + _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \ + mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \ + README.SSL smime.h group.h \ +@@ -760,6 +762,8 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutt_tunnel.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muttlib.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mx.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsrc.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pager.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patchlist.Po@am__quote@ +diff -udprP mutt-1.5.23.orig/configure mutt-1.5.23/configure +--- mutt-1.5.23.orig/configure 2014-03-12 18:26:45.000000000 +0200 ++++ mutt-1.5.23/configure 2014-03-13 12:48:37.000000000 +0200 +@@ -796,6 +796,7 @@ with_docdir + with_domain + enable_pop + enable_imap ++enable_nntp + enable_smtp + with_gss + with_ssl +@@ -1464,6 +1465,7 @@ Optional Features: + Force use of an external dotlock program + --enable-pop Enable POP3 support + --enable-imap Enable IMAP support ++ --enable-nntp Enable NNTP support + --enable-smtp include internal SMTP relay support + --enable-debug Enable debugging support + --enable-flock Use flock() to lock files +@@ -9047,6 +9049,20 @@ else + fi + + ++# Check whether --enable-nntp was given. ++if test "${enable_nntp+set}" = set; then : ++ enableval=$enable_nntp; if test x$enableval = xyes ; then ++ ++$as_echo "#define USE_NNTP 1" >>confdefs.h ++ ++ MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS nntp.o newsrc.o" ++ need_nntp="yes" ++ need_socket="yes" ++ fi ++ ++fi ++ ++ + # Check whether --enable-smtp was given. + if test "${enable_smtp+set}" = set; then : + enableval=$enable_smtp; if test $enableval = yes; then +@@ -9059,7 +9075,7 @@ $as_echo "#define USE_SMTP 1" >>confdefs + fi + + +-if test x"$need_imap" = xyes -o x"$need_pop" = xyes ; then ++if test x"$need_imap" = xyes -o x"$need_pop" = xyes -o x"$need_nntp" = xyes ; then + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o" + fi + +diff -udprP mutt-1.5.23.orig/doc/Muttrc mutt-1.5.23/doc/Muttrc +--- mutt-1.5.23.orig/doc/Muttrc 2014-03-12 18:27:11.000000000 +0200 ++++ mutt-1.5.23/doc/Muttrc 2014-03-13 12:48:37.000000000 +0200 +@@ -240,6 +240,28 @@ attachments -I message/external-body + # editing the body of an outgoing message. + # + # ++# set ask_follow_up=no ++# ++# Name: ask_follow_up ++# Type: boolean ++# Default: no ++# ++# ++# If set, Mutt will prompt you for follow-up groups before editing ++# the body of an outgoing message. ++# ++# ++# set ask_x_comment_to=no ++# ++# Name: ask_x_comment_to ++# Type: boolean ++# Default: no ++# ++# ++# If set, Mutt will prompt you for x-comment-to field before editing ++# the body of an outgoing message. ++# ++# + # set assumed_charset="" + # + # Name: assumed_charset +@@ -445,6 +467,17 @@ attachments -I message/external-body + # visual terminals don't permit making the cursor invisible. + # + # ++# set catchup_newsgroup=ask-yes ++# ++# Name: catchup_newsgroup ++# Type: quadoption ++# Default: ask-yes ++# ++# ++# If this variable is set, Mutt will mark all articles in newsgroup ++# as read when you quit the newsgroup (catchup newsgroup). ++# ++# + # set certificate_file="~/.mutt_certificates" + # + # Name: certificate_file +@@ -1131,6 +1164,19 @@ attachments -I message/external-body + # of the same email for you. + # + # ++# set followup_to_poster=ask-yes ++# ++# Name: followup_to_poster ++# Type: quadoption ++# Default: ask-yes ++# ++# ++# If this variable is set and the keyword "poster" is present in ++# Followup-To header, follow-up to newsgroup function is not ++# permitted. The message will be mailed to the submitter of the ++# message via mail. ++# ++# + # set force_name=no + # + # Name: force_name +@@ -1241,6 +1287,27 @@ attachments -I message/external-body + # ``Franklin'' to ``Franklin, Steve''. + # + # ++# set group_index_format="%4C %M%N %5s %-45.45f %d" ++# ++# Name: group_index_format ++# Type: string ++# Default: "%4C %M%N %5s %-45.45f %d" ++# ++# ++# This variable allows you to customize the newsgroup browser display to ++# your personal taste. This string is similar to ``index_format'', but ++# has its own set of printf()-like sequences: ++# %C current newsgroup number ++# %d description of newsgroup (becomes from server) ++# %f newsgroup name ++# %M - if newsgroup not allowed for direct post (moderated for example) ++# %N N if newsgroup is new, u if unsubscribed, blank otherwise ++# %n number of new articles in newsgroup ++# %s number of unread articles in newsgroup ++# %>X right justify the rest of the string and pad with character "X" ++# %|X pad to the end of the line with character "X" ++# ++# + # set hdrs=yes + # + # Name: hdrs +@@ -1789,6 +1856,7 @@ attachments -I message/external-body + # %E number of messages in current thread + # %f sender (address + real name), either From: or Return-Path: + # %F author name, or recipient name if the message is from you ++# %g newsgroup name (if compiled with NNTP support) + # %H spam attribute(s) of this message + # %i message-id of the current message + # %l number of lines in the message (does not work with maildir, +@@ -1804,12 +1872,14 @@ attachments -I message/external-body + # stashed the message: list name or recipient name + # if not sent to a list + # %P progress indicator for the built-in pager (how much of the file has been displayed) ++# %R ``X-Comment-To:'' field (if present and compiled with NNTP support) + # %s subject of the message + # %S status of the message (``N''/``D''/``d''/``!''/``r''/*) + # %t ``To:'' field (recipients) + # %T the appropriate character from the $to_chars string + # %u user (login) name of the author + # %v first name of the author, or the recipient if the message is from you ++# %W name of organization of author (``Organization:'' field) + # %X number of attachments + # (please see the ``attachments'' section for possible speed effects) + # %y ``X-Label:'' field, if present +@@ -1845,6 +1915,27 @@ attachments -I message/external-body + # ``save-hook'', ``fcc-hook'' and ``fcc-save-hook'', too. + # + # ++# set inews="" ++# ++# Name: inews ++# Type: path ++# Default: "" ++# ++# ++# If set, specifies the program and arguments used to deliver news posted ++# by Mutt. Otherwise, mutt posts article using current connection to ++# news server. The following printf-style sequence is understood: ++# %a account url ++# %p port ++# %P port if specified ++# %s news server name ++# %S url schema ++# %u username ++# ++# ++# Example: set inews="/usr/local/bin/inews -hS" ++# ++# + # set ispell="ispell" + # + # Name: ispell +@@ -2214,6 +2305,18 @@ attachments -I message/external-body + # be attached to the newly composed message if this option is set. + # + # ++# set mime_subject=yes ++# ++# Name: mime_subject ++# Type: boolean ++# Default: yes ++# ++# ++# If unset, 8-bit ``subject:'' line in article header will not be ++# encoded according to RFC2047 to base64. This is useful when message ++# is Usenet article, because MIME for news is nonstandard feature. ++# ++# + # set mix_entry_format="%4n %c %-16s %a" + # + # Name: mix_entry_format +@@ -2280,6 +2383,144 @@ attachments -I message/external-body + # See also $read_inc, $write_inc and $net_inc. + # + # ++# set news_cache_dir="~/.mutt" ++# ++# Name: news_cache_dir ++# Type: path ++# Default: "~/.mutt" ++# ++# ++# This variable pointing to directory where Mutt will save cached news ++# articles and headers in. If unset, articles and headers will not be ++# saved at all and will be reloaded from the server each time. ++# ++# ++# set news_server="" ++# ++# Name: news_server ++# Type: string ++# Default: "" ++# ++# ++# This variable specifies domain name or address of NNTP server. It ++# defaults to the news server specified in the environment variable ++# $NNTPSERVER or contained in the file /etc/nntpserver. You can also ++# specify username and an alternative port for each news server, ie: ++# ++# [[s]news://][username[:password]@]server[:port] ++# ++# ++# set newsgroups_charset="utf-8" ++# ++# Name: newsgroups_charset ++# Type: string ++# Default: "utf-8" ++# ++# ++# Character set of newsgroups descriptions. ++# ++# ++# set newsrc="~/.newsrc" ++# ++# Name: newsrc ++# Type: path ++# Default: "~/.newsrc" ++# ++# ++# The file, containing info about subscribed newsgroups - names and ++# indexes of read articles. The following printf-style sequence ++# is understood: ++# %a account url ++# %p port ++# %P port if specified ++# %s news server name ++# %S url schema ++# %u username ++# ++# ++# set nntp_authenticators="" ++# ++# Name: nntp_authenticators ++# Type: string ++# Default: "" ++# ++# ++# This is a colon-delimited list of authentication methods mutt may ++# attempt to use to log in to a news server, in the order mutt should ++# try them. Authentication methods are either ``user'' or any ++# SASL mechanism, e.g. ``digest-md5'', ``gssapi'' or ``cram-md5''. ++# This option is case-insensitive. If it's unset (the default) ++# mutt will try all available methods, in order from most-secure to ++# least-secure. ++# ++# Example: ++# set nntp_authenticators="digest-md5:user" ++# ++# Note: Mutt will only fall back to other authentication methods if ++# the previous methods are unavailable. If a method is available but ++# authentication fails, mutt will not connect to the IMAP server. ++# ++# ++# set nntp_context=1000 ++# ++# Name: nntp_context ++# Type: number ++# Default: 1000 ++# ++# ++# This variable defines number of articles which will be in index when ++# newsgroup entered. If active newsgroup have more articles than this ++# number, oldest articles will be ignored. Also controls how many ++# articles headers will be saved in cache when you quit newsgroup. ++# ++# ++# set nntp_load_description=yes ++# ++# Name: nntp_load_description ++# Type: boolean ++# Default: yes ++# ++# ++# This variable controls whether or not descriptions for each newsgroup ++# must be loaded when newsgroup is added to list (first time list ++# loading or new newsgroup adding). ++# ++# ++# set nntp_user="" ++# ++# Name: nntp_user ++# Type: string ++# Default: "" ++# ++# ++# Your login name on the NNTP server. If unset and NNTP server requires ++# authentification, Mutt will prompt you for your account name when you ++# connect to news server. ++# ++# ++# set nntp_pass="" ++# ++# Name: nntp_pass ++# Type: string ++# Default: "" ++# ++# ++# Your password for NNTP account. ++# ++# ++# set nntp_poll=60 ++# ++# Name: nntp_poll ++# Type: number ++# Default: 60 ++# ++# ++# The time in seconds until any operations on newsgroup except post new ++# article will cause recheck for new news. If set to 0, Mutt will ++# recheck newsgroup on each operation in index (stepping, read article, ++# etc.). ++# ++# + # set pager="builtin" + # + # Name: pager +@@ -2997,6 +3238,19 @@ attachments -I message/external-body + # string after the inclusion of a message which is being replied to. + # + # ++# set post_moderated=ask-yes ++# ++# Name: post_moderated ++# Type: quadoption ++# Default: ask-yes ++# ++# ++# If set to yes, Mutt will post article to newsgroup that have ++# not permissions to posting (e.g. moderated). Note: if news server ++# does not support posting to that newsgroup or totally read-only, that ++# posting will not have an effect. ++# ++# + # set postpone=ask-yes + # + # Name: postpone +@@ -3605,6 +3859,41 @@ attachments -I message/external-body + # shell from /etc/passwd is used. + # + # ++# set save_unsubscribed=no ++# ++# Name: save_unsubscribed ++# Type: boolean ++# Default: no ++# ++# ++# When set, info about unsubscribed newsgroups will be saved into ++# ``newsrc'' file and into cache. ++# ++# ++# set show_new_news=yes ++# ++# Name: show_new_news ++# Type: boolean ++# Default: yes ++# ++# ++# If set, news server will be asked for new newsgroups on entering ++# the browser. Otherwise, it will be done only once for a news server. ++# Also controls whether or not number of new articles of subscribed ++# newsgroups will be then checked. ++# ++# ++# set show_only_unread=no ++# ++# Name: show_only_unread ++# Type: boolean ++# Default: no ++# ++# ++# If set, only subscribed newsgroups that contain unread articles ++# will be displayed in browser. ++# ++# + # set sig_dashes=yes + # + # Name: sig_dashes +@@ -4851,3 +5140,14 @@ attachments -I message/external-body + # ``tuning'' section of the manual for performance considerations. + # + # ++# set x_comment_to=no ++# ++# Name: x_comment_to ++# Type: boolean ++# Default: no ++# ++# ++# If set, Mutt will add ``X-Comment-To:'' field (that contains full ++# name of original article author) to article that followuped to newsgroup. ++# ++# Index: SOURCES/sha1.lst =================================================================== --- SOURCES/sha1.lst (revision 800495) +++ SOURCES/sha1.lst (working copy) @@ -1,2 +1,2 @@ -a8475f2618ce5d5d33bff85c0affdf21ab1d76b9 mutt-1.5.21.tar.gz +8ac821d8b1e25504a31bf5fda9c08d93a4acc862 mutt-1.5.23.tar.gz bd1ee51559088a0922de0fad897ebb452d280ae1 mutt-Muttrc_compressed_folders.foot.bz2 Index: SPECS/mutt.spec =================================================================== --- SPECS/mutt.spec (revision 800495) +++ SPECS/mutt.spec (working copy) @@ -15,8 +15,8 @@ %global __requires_exclude perl\\(timelocal.pl\\) Name: mutt -Version: 1.5.21 -Release: %mkrel 16 +Version: 1.5.23 +Release: %mkrel 1 Epoch: 1 Summary: Text mode mail user agent @@ -45,7 +45,7 @@ Patch2: %{name}-1.5.18-urlview.patch # Allow non root users to install mutt -Patch3: %{name}-1.5.5.1-no-sgid.patch +Patch3: %{name}-1.5.23-no-sgid.patch # Don't include /usr/include/ncurses if not building against normal ncurses Patch4: %{name}-1.5.5.1-ncurses-include.patch @@ -58,7 +58,12 @@ Patch6: mutt-1.5.20-gpg.patch # recognize db5 -Patch7: mutt-1.5.21-db5.patch +Patch7: mutt-1.5.23-db53.patch + +# Fix segmentation fault on corrupt headers +# http://dev.mutt.org/trac/ticket/3716 +Patch8: mutt-1.5.23-ticket-3716-dev.patch + # # Patch 100- : external patches # @@ -65,14 +70,14 @@ # Compressed folder support, http://www.spinnaker.de/mutt/compressed/ # http://www.mutt.org.ua/download/mutt-%{pversion}/patch-%{pversion}.rr.compressed.gz -Patch100: patch-1.5.20.rr.compressed +Patch100: mutt-1.5.23-compressed-mbox.patch # NNTP support # http://www.mutt.org.ua/download/mutt-%{version}/patch-%{version}.vvv.nntp.gz -Patch101: patch-1.5.20.vvv.nntp +Patch101: patch-1.5.23.vvv.nntp # Dynamically set xterm window title / icon name -Patch104: %{name}-1.5.5.1-xterm-title.patch +Patch104: %{name}-1.5.23-xterm-title.patch # Merged upstream #Patch107: mutt-1.5.19-nulcert.diff @@ -79,18 +84,11 @@ # Now maintained at http://www.lunar-linux.org/index.php?option=com_content&task=view&id=44 # Patch adapted from: patch-1.5.20.sidebar.20090619.txt -Patch108: mutt-1.5.20-sidebar.patch +Patch108: mutt-1.5.23-sidebar.patch # Patch adapted from: http://greek0.net/mutt.html -Patch109: mutt-1.5.12-indexcolor-3+cb.diff +Patch109: mutt-1.5.23-indexcolor.patch -#testcert CVE-2011-1429 - http://dev.mutt.org/trac/ticket/3506 -Patch110: mutt-1.5.21-testcert.patch - -Patch111: mutt-1.5.21-automake-1.13.patch -Patch112: mutt-1.5.20-cve-2014-0467.patch -Patch113: mutt-1.5.21-CVE-2014-9116.patch - BuildRequires: bzip2-devel BuildRequires: linuxdoc-tools BuildRequires: pkgconfig(ncurses) @@ -165,6 +163,7 @@ %patch5 -p1 -b .mailcap %patch6 -p0 -b .gpg %patch7 -p0 -b .db +%patch8 -p1 -b .3716 %patch100 -p1 -b .cfp %patch101 -p1 -b .nntp %patch104 -p1 -b .xterm-title @@ -171,10 +170,6 @@ #%patch107 -p0 -b .nulcert %patch108 -p1 %patch109 -p1 -%patch110 -p1 -b .testcert -%patch111 -p1 -%patch112 -p1 -b .CVE-2014-0467 -%patch113 -p1 -b .CVE-2014-9116 # needed by nntp patch autoreconf -fi @@ -228,12 +223,12 @@ perl -pi -e 's/ncurses ncursesw/ncurses # ncursesw/' configure mkdir mutt-normal pushd mutt-normal -build +CPPFLAGS=-DNCURSES_WIDECHAR=0 build popd # build another version enabling wide char support ### ugly. ugly. -perl -pi -e 's/ncurses # ncursesw/ncurses ncursesw/' configure +perl -pi -e 's/ncurses # ncursesw/ncursesw # ncurses/' configure mkdir mutt-utf-8 pushd mutt-utf-8 build
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 14707
: 5676