X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=copy.c;h=9afdc255ec6548314d75dc3cbd0d08dcbe336d93;hp=2bfcde7fb3f2c42c2f40f4462def85dca523f8bd;hb=c7ceecd31e97891dd5cf48536d4bddf2c1d7d9dd;hpb=6833ce8bdca2d64e14485118f2a4417b7e1cb1b1 diff --git a/copy.c b/copy.c index 2bfcde7..9afdc25 100644 --- a/copy.c +++ b/copy.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include "mutt.h" #include "mailbox.h" #include "mx.h" @@ -95,6 +99,12 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags, (ascii_strncasecmp ("Content-Length:", buf, 15) == 0 || ascii_strncasecmp ("Lines:", buf, 6) == 0)) continue; + if ((flags & CH_UPDATE_REFS) && + ascii_strncasecmp ("References:", buf, 11) == 0) + continue; + if ((flags & CH_UPDATE_IRT) && + ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0) + continue; ignore = 0; } @@ -193,6 +203,12 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags, ascii_strncasecmp ("type:", buf + 8, 5) == 0)) || ascii_strncasecmp ("mime-version:", buf, 13) == 0)) continue; + if ((flags & CH_UPDATE_REFS) && + ascii_strncasecmp ("References:", buf, 11) == 0) + continue; + if ((flags & CH_UPDATE_IRT) && + ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0) + continue; /* Find x -- the array entry where this header is to be saved */ if (flags & CH_REORDER) @@ -326,6 +342,8 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags, CH_XMIT ignore Lines: and Content-Length: CH_WEED do header weeding CH_NOQFROM ignore ">From " line + CH_UPDATE_IRT update the In-Reply-To: header + CH_UPDATE_REFS update the References: header prefix string to use if CH_PREFIX is set @@ -335,6 +353,9 @@ int mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix) { char buffer[SHORT_STRING]; + + flags |= (h->irt_changed ? CH_UPDATE_IRT : 0) + | (h->refs_changed ? CH_UPDATE_REFS : 0); if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) == -1) return (-1); @@ -359,6 +380,49 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix) { if ((flags & CH_NOSTATUS) == 0) { + if (h->irt_changed && h->new_env->in_reply_to) + { + LIST *listp = h->new_env->in_reply_to; + + if (fputs ("In-Reply-To: ", out) == EOF) + return (-1); + + for (; listp; listp = listp->next) + if ((fputs (listp->data, out) == EOF) || (fputc (' ', out) == EOF)) + return (-1); + + if (fputc ('\n', out) == EOF) + return (-1); + } + + if (h->refs_changed && h->new_env->references) + { + LIST *listp = h->new_env->references, *refs = NULL, *t; + + if (fputs ("References: ", out) == EOF) + return (-1); + + /* Mutt stores references in reverse order, thus we create + * a reordered refs list that we can put in the headers */ + for (; listp; listp = listp->next, refs = t) + { + t = (LIST *)safe_malloc (sizeof (LIST)); + t->data = listp->data; + t->next = refs; + } + + for (; refs; refs = refs->next) + if ((fputs (refs->data, out) == EOF) || (fputc (' ', out) == EOF)) + return (-1); + + /* clearing refs from memory */ + for (t = refs; refs; refs = t->next, t = refs) + FREE(&refs); + + if (fputc ('\n', out) == EOF) + return (-1); + } + if (h->old || h->read) { if (fputs ("Status: ", out) == EOF) @@ -586,6 +650,8 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body, s.flags |= M_WEED; if (flags & M_CM_CHARCONV) s.flags |= M_CHARCONV; + if (flags & M_CM_REPLYING) + s.flags |= M_REPLYING; if (WithCrypto && flags & M_CM_VERIFY) s.flags |= M_VERIFY; @@ -906,7 +972,7 @@ static int address_header_decode (char **h) default: return 0; } - if ((a = rfc822_parse_adrlist (a, s + l + 1)) == NULL) + if ((a = rfc822_parse_adrlist (a, s + l)) == NULL) return 0; mutt_addrlist_to_local (a);