| (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)
{
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);
}
}
{
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*/
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);
else if (WithCrypto
&& (flags & M_CM_DECODE_CRYPT) && (hdr->security & ENCRYPT))
{
- BODY *cur;
+ BODY *cur = NULL;
FILE *fp;
if ((WithCrypto & APPLICATION_PGP)
return (-1);
}
+ if (!cur)
+ {
+ mutt_error (_("No decryption engine available for message"));
+ return -1;
+ }
+
mutt_write_mime_header (cur, fpout);
fputc ('\n', fpout);
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)