if (ctx.magic == MUTT_MBOX || ctx.magic == MUTT_MMDF)
chflags = CH_FROM | CH_UPDATE_LEN;
chflags |= (ctx.magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
- if (mutt_copy_message(msg->fp, fp, hn, hn->content, 0, chflags) == 0 &&
+ if (mutt_copy_message_fp(msg->fp, fp, hn, 0, chflags) == 0 &&
mx_commit_message(msg, &ctx) == 0)
r = 0;
else
if (Context->magic == MUTT_NOTMUCH)
chflags |= CH_VIRTUAL;
#endif
- res = mutt_open_copy_message(fpout, Context, cur, cmflags, chflags);
+ res = mutt_copy_message_ctx(fpout, Context, cur, cmflags, chflags);
if ((safe_fclose(&fpout) != 0 && errno != EPIPE) || res < 0)
{
if (decode)
mutt_parse_mime_message(Context, h);
- mutt_open_copy_message(fp, Context, h, cmflags, chflags);
+ mutt_copy_message_ctx(fp, Context, h, cmflags, chflags);
}
/**
}
/**
- * mutt_copy_message - make a copy of a message
+ * mutt_copy_message_fp - make a copy of a message from a FILE pointer
* @param fpout Where to write output
* @param fpin Where to get input
* @param hdr Header of message being copied
* * #MUTT_CM_DECODE_PGP used for decoding PGP messages
* * #MUTT_CM_CHARCONV perform character set conversion
*/
-int mutt_copy_message(FILE *fpout, FILE *fpin, struct Header *hdr,
- struct Body *body, int flags, int chflags)
+int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Header *hdr, int flags,
+ int chflags)
{
+ struct Body *body = hdr->content;
char prefix[SHORT_STRING];
struct State s;
LOFF_T new_offset = -1;
}
/**
- * mutt_open_copy_message - Copy a message
+ * mutt_copy_message_ctx - Copy a message from a Context
*
* 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_open_copy_message(FILE *fpout, struct Context *src, struct Header *hdr,
- int flags, int chflags)
+int mutt_copy_message_ctx(FILE *fpout, struct Context *src, struct Header *hdr,
+ int flags, int chflags)
{
struct Message *msg = NULL;
int r;
msg = mx_open_message(src, hdr->msgno);
if (!msg)
return -1;
- if ((r = mutt_copy_message(fpout, msg->fp, hdr, hdr->content, flags, chflags)) == 0 &&
+ if ((r = mutt_copy_message_fp(fpout, msg->fp, hdr, flags, chflags)) == 0 &&
(ferror(fpout) || feof(fpout)))
{
mutt_debug(1, "mutt_copy_message failed to detect EOF!\n");
* @retval -1 on error
*/
static int append_message(struct Context *dest, FILE *fpin, struct Context *src,
- struct Header *hdr, struct Body *body, int flags, int chflags)
+ struct Header *hdr, int flags, int chflags)
{
char buf[STRING];
struct Message *msg = NULL;
if (dest->magic == MUTT_MBOX || dest->magic == MUTT_MMDF)
chflags |= CH_FROM | CH_FORCE_FROM;
chflags |= (dest->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
- r = mutt_copy_message(msg->fp, fpin, hdr, body, flags, chflags);
+ r = mutt_copy_message_fp(msg->fp, fpin, hdr, flags, chflags);
if (mx_commit_message(msg, dest) != 0)
r = -1;
msg = mx_open_message(src, hdr->msgno);
if (!msg)
return -1;
- r = append_message(dest, msg->fp, src, hdr, hdr->content, cmflags, chflags);
+ r = append_message(dest, msg->fp, src, hdr, cmflags, chflags);
mx_close_message(src, &msg);
return r;
}
int mutt_copy_header(FILE *in, struct Header *h, FILE *out, int flags, const char *prefix);
-int mutt_copy_message(FILE *fpout, FILE *fpin, struct Header *hdr, struct Body *body,
- int flags, int chflags);
-
-int mutt_open_copy_message(FILE *fpout, struct Context *src, struct Header *hdr, int flags, int chflags);
+int mutt_copy_message_fp (FILE *fpout, FILE *fpin, struct Header *hdr, int flags, int chflags);
+int mutt_copy_message_ctx(FILE *fpout, struct Context *src, struct Header *hdr, int flags, int chflags);
int mutt_append_message(struct Context *dest, struct Context *src, struct Header *hdr, int cmflags, int chflags);
*/
newOffset[i - first].hdr = ftello(fp) + offset;
- if (mutt_open_copy_message(fp, ctx, ctx->hdrs[i], MUTT_CM_UPDATE,
+ if (mutt_copy_message_ctx(fp, ctx, ctx->hdrs[i], MUTT_CM_UPDATE,
CH_FROM | CH_UPDATE | CH_UPDATE_LEN) != 0)
{
mutt_perror(tempfile);
if (!dest)
return -1;
- rc = mutt_open_copy_message(dest->fp, ctx, h, MUTT_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN);
+ rc = mutt_copy_message_ctx(dest->fp, ctx, h, MUTT_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN);
if (rc == 0)
{
snprintf(oldpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path);
if ((WithCrypto & APPLICATION_PGP) && (hi->security & APPLICATION_PGP))
{
- mutt_open_copy_message(fpout, Context, hi, MUTT_CM_DECODE | MUTT_CM_CHARCONV, 0);
+ mutt_copy_message_ctx(fpout, Context, hi, MUTT_CM_DECODE | MUTT_CM_CHARCONV, 0);
fflush(fpout);
mutt_endwin(_("Trying to extract PGP keys...\n"));
if ((WithCrypto & APPLICATION_SMIME) && (hi->security & APPLICATION_SMIME))
{
if (hi->security & ENCRYPT)
- mutt_open_copy_message(fpout, Context, hi,
- MUTT_CM_NOHEADER | MUTT_CM_DECODE_CRYPT | MUTT_CM_DECODE_SMIME,
- 0);
+ mutt_copy_message_ctx(fpout, Context, hi,
+ MUTT_CM_NOHEADER | MUTT_CM_DECODE_CRYPT | MUTT_CM_DECODE_SMIME,
+ 0);
else
- mutt_open_copy_message(fpout, Context, hi, 0, 0);
+ mutt_copy_message_ctx(fpout, Context, hi, 0, 0);
fflush(fpout);
if (hi->env->from)
{
if ((WithCrypto & APPLICATION_PGP) && (h->security & APPLICATION_PGP))
{
- mutt_open_copy_message(fpout, Context, h, MUTT_CM_DECODE | MUTT_CM_CHARCONV, 0);
+ mutt_copy_message_ctx(fpout, Context, h, MUTT_CM_DECODE | MUTT_CM_CHARCONV, 0);
fflush(fpout);
mutt_endwin(_("Trying to extract PGP keys...\n"));
crypt_pgp_invoke_import(tempfname);
if ((WithCrypto & APPLICATION_SMIME) && (h->security & APPLICATION_SMIME))
{
if (h->security & ENCRYPT)
- mutt_open_copy_message(fpout, Context, h,
- MUTT_CM_NOHEADER | MUTT_CM_DECODE_CRYPT | MUTT_CM_DECODE_SMIME,
- 0);
+ mutt_copy_message_ctx(fpout, Context, h,
+ MUTT_CM_NOHEADER | MUTT_CM_DECODE_CRYPT | MUTT_CM_DECODE_SMIME,
+ 0);
else
- mutt_open_copy_message(fpout, Context, h, 0, 0);
+ mutt_copy_message_ctx(fpout, Context, h, 0, 0);
fflush(fpout);
if (h->env->from)
}
if (h->security & ENCRYPT)
- mutt_open_copy_message(fpout, Context, h, MUTT_CM_DECODE_CRYPT & MUTT_CM_DECODE_SMIME,
- CH_MIME | CH_WEED | CH_NONEWLINE);
+ mutt_copy_message_ctx(fpout, Context, h, MUTT_CM_DECODE_CRYPT & MUTT_CM_DECODE_SMIME,
+ CH_MIME | CH_WEED | CH_NONEWLINE);
else
- mutt_open_copy_message(fpout, Context, h, 0, 0);
+ mutt_copy_message_ctx(fpout, Context, h, 0, 0);
fflush(fpout);
safe_fclose(&fpout);
if (cur)
{
mutt_forward_intro(Context, cur->hdr, tmpfp);
- mutt_copy_message(tmpfp, fp, cur->hdr, cur->hdr->content, cmflags, chflags);
+ mutt_copy_message_fp(tmpfp, fp, cur->hdr, cmflags, chflags);
mutt_forward_trailer(Context, cur->hdr, tmpfp);
}
else
if (actx->idx[i]->content->tagged)
{
mutt_forward_intro(Context, actx->idx[i]->content->hdr, tmpfp);
- mutt_copy_message(tmpfp, actx->idx[i]->fp, actx->idx[i]->content->hdr,
- actx->idx[i]->content->hdr->content, cmflags, chflags);
+ mutt_copy_message_fp(tmpfp, actx->idx[i]->fp,
+ actx->idx[i]->content->hdr, cmflags, chflags);
mutt_forward_trailer(Context, actx->idx[i]->content->hdr, tmpfp);
}
}
cmflags |= MUTT_CM_WEED;
}
- mutt_copy_message(tmpfp, fp, cur, cur->content, cmflags, chflags);
+ mutt_copy_message_fp(tmpfp, fp, cur, cmflags, chflags);
mutt_make_post_indent(Context, cur, tmpfp);
}
* rather than send action */
chflags |= CH_DISPLAY;
- mutt_open_copy_message(out, ctx, cur, cmflags, chflags);
+ mutt_copy_message_ctx(out, ctx, cur, cmflags, chflags);
mutt_forward_trailer(ctx, cur, out);
return 0;
}
cmflags |= MUTT_CM_WEED;
}
- mutt_open_copy_message(out, ctx, cur, cmflags, chflags);
+ mutt_copy_message_ctx(out, ctx, cur, cmflags, chflags);
mutt_make_post_indent(ctx, cur, out);
}
}
- mutt_open_copy_message(fp, ctx, hdr, cmflags, chflags);
+ mutt_copy_message_ctx(fp, ctx, hdr, cmflags, chflags);
fflush(fp);
rewind(fp);