X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/14c29200cb58d3c4a0830265f2433849781858d0..3dba9e5c9fc1d796291f92d6bf08ed88ef540637:/copy.c diff --git a/copy.c b/copy.c index 4cb91d0..fa28320 100644 --- a/copy.c +++ b/copy.c @@ -348,7 +348,7 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix) | (h->env->refs_changed ? CH_UPDATE_REFS : 0); if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) == -1) - return (-1); + return -1; if (flags & CH_TXTPLAIN) { @@ -360,99 +360,47 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix) rfc822_cat(buffer, sizeof(buffer), chsbuf, MimeSpecials); fputs(buffer, out); fputc('\n', out); - - if (ferror (out) != 0 || feof (out) != 0) - return -1; - } - if (flags & CH_UPDATE) + if ((flags & CH_UPDATE_IRT) && h->env->in_reply_to) { - if ((flags & CH_NOSTATUS) == 0) + LIST *listp = h->env->in_reply_to; + fputs ("In-Reply-To:", out); + for (; listp; listp = listp->next) { - if (h->env->irt_changed && h->env->in_reply_to) - { - LIST *listp = h->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->env->refs_changed && h->env->references) - { - LIST *listp = h->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) - return (-1); - - if (h->read) - { - if (fputs ("RO", out) == EOF) - return (-1); - } - else if (h->old) - { - if (fputc ('O', out) == EOF) - return (-1); - } - - if (fputc ('\n', out) == EOF) - return (-1); - } + fputc (' ', out); + fputs (listp->data, out); + } + fputc ('\n', out); + } - if (h->flagged || h->replied) - { - if (fputs ("X-Status: ", out) == EOF) - return (-1); + if ((flags & CH_UPDATE_REFS) && h->env->references) + { + fputs ("References:", out); + mutt_write_references (h->env->references, out, 0); + fputc ('\n', out); + } - if (h->replied) - { - if (fputc ('A', out) == EOF) - return (-1); - } + if ((flags & CH_UPDATE) && (flags & CH_NOSTATUS) == 0) + { + if (h->old || h->read) + { + fputs ("Status: ", out); + if (h->read) + fputs ("RO", out); + else if (h->old) + fputc ('O', out); + fputc ('\n', out); + } - if (h->flagged) - { - if (fputc ('F', out) == EOF) - return (-1); - } - - if (fputc ('\n', out) == EOF) - return (-1); - } + if (h->flagged || h->replied) + { + fputs ("X-Status: ", out); + if (h->replied) + fputc ('A', out); + if (h->flagged) + fputc ('F', out); + fputc ('\n', out); } } @@ -468,14 +416,13 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix) { if (flags & CH_PREFIX) fputs(prefix, out); - if (fputc ('\n', out) == EOF) /* add header terminator */ - return (-1); + fputc ('\n', out); /* add header terminator */ } if (ferror (out) || feof (out)) return -1; - return (0); + return 0; } /* Count the number of lines and bytes to be deleted in this body*/ @@ -572,7 +519,9 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body, if (new_lines <= 0) new_lines = 0; else - fprintf (fpout, "Lines: %d\n\n", new_lines); + fprintf (fpout, "Lines: %d\n", new_lines); + + putc ('\n', fpout); if (ferror (fpout) || feof (fpout)) return -1; new_offset = ftello (fpout); @@ -652,7 +601,7 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body, else if (WithCrypto && (flags & M_CM_DECODE_CRYPT) && (hdr->security & ENCRYPT)) { - BODY *cur; + BODY *cur = NULL; FILE *fp; if ((WithCrypto & APPLICATION_PGP) @@ -672,6 +621,12 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body, return (-1); } + if (!cur) + { + mutt_error (_("No decryption engine available for message")); + return -1; + } + mutt_write_mime_header (cur, fpout); fputc ('\n', fpout); @@ -718,6 +673,8 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body, return rc; } +/* should be made to return -1 on fatal errors, and 1 on non-fatal errors + * like partial decode, where it is worth displaying as much as possible */ int mutt_copy_message (FILE *fpout, CONTEXT *src, HEADER *hdr, int flags, int chflags)