static int include_reply (CONTEXT *ctx, HEADER *cur, FILE *out) { int cmflags = M_CM_PREFIX | M_CM_DECODE | M_CM_CHARCONV | M_CM_REPLYING; int chflags = CH_DECODE; if (WithCrypto && (cur->security & ENCRYPT)) { /* make sure we have the user's passphrase before proceeding... */ crypt_valid_passphrase (cur->security); } mutt_parse_mime_message (ctx, cur); mutt_message_hook (ctx, cur, M_MESSAGEHOOK); mutt_make_attribution (ctx, cur, out); if (!option (OPTHEADER)) cmflags |= M_CM_NOHEADER; if (option (OPTWEED)) { chflags |= CH_WEED | CH_REORDER; cmflags |= M_CM_WEED; } mutt_copy_message (out, ctx, cur, cmflags, chflags); mutt_make_post_indent (ctx, cur, out); return 0; }
static void attach_include_reply (FILE *fp, FILE *tmpfp, struct header *cur, int flags) { int cmflags = M_CM_PREFIX | M_CM_DECODE | M_CM_CHARCONV; int chflags = CH_DECODE; /* mutt_message_hook (cur, M_MESSAGEHOOK); */ mutt_make_attribution (Context, cur, tmpfp); if (!bit_val(options, OPTHEADER)) cmflags |= M_CM_NOHEADER; if (bit_val(options, OPTWEED)) { chflags |= CH_WEED; cmflags |= M_CM_WEED; } _mutt_copy_message (tmpfp, fp, cur, cur->content, cmflags, chflags); mutt_make_post_indent (Context, cur, tmpfp); }
void mutt_attach_reply (FILE * fp, struct header *hdr, ATTACHPTR ** idx, short idxlen, struct body * cur, int flags) { short mime_reply_any = 0; short nattach = 0; struct header *parent = NULL; struct header *tmphdr = NULL; short i; STATE st; char tmpbody[_POSIX_PATH_MAX]; FILE *tmpfp; char prefix[SHORT_STRING]; int rc; if (check_all_msg (idx, idxlen, cur, 0) == -1) { nattach = count_tagged (idx, idxlen); if ((parent = find_parent (idx, idxlen, cur, nattach)) == NULL) parent = hdr; } if (nattach > 1 && !check_can_decode (idx, idxlen, cur)) { if ((rc = query_quadoption (OPT_MIMEFWDREST, ("Can't decode all tagged attachments. MIME-encapsulate the others?"))) == -1) return; else if (rc == M_YES) mime_reply_any = 1; } else if (nattach == 1) mime_reply_any = 1; tmphdr = mutt_new_header (); tmphdr->env = mutt_new_envelope (); if (attach_reply_envelope_defaults (tmphdr->env, idx, idxlen, parent ? parent : (cur ? cur->hdr : NULL), flags) == -1) { mutt_free_header (&tmphdr); return; } mutt_mktemp (tmpbody, sizeof (tmpbody)); if ((tmpfp = safe_fopen (tmpbody, "w")) == NULL) { mutt_error (("Can't create %s."), tmpbody); mutt_free_header (&tmphdr); return; } if (!parent) { if (cur) attach_include_reply (fp, tmpfp, cur->hdr, flags); else { for (i = 0; i < idxlen; i++) { if (idx[i]->content->tagged) attach_include_reply (fp, tmpfp, idx[i]->content->hdr, flags); } } } else { mutt_make_attribution (Context, parent, tmpfp); memset (&st, 0, sizeof (STATE)); st.fpin = fp; st.fpout = tmpfp; if (!bit_val(options, OPTTEXTFLOWED)) _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context, parent, 0); else strfcpy (prefix, ">", sizeof (prefix)); st.prefix = prefix; st.flags = M_CHARCONV; if (bit_val(options, OPTWEED)) st.flags |= M_WEED; if (bit_val(options, OPTHEADER)) include_header (1, fp, parent, tmpfp, prefix); if (cur) { if (mutt_can_decode (cur)) { mutt_body_handler (cur, &st); state_putc ('\n', &st); } else mutt_copy_body (fp, &tmphdr->content, cur); } else { for (i = 0; i < idxlen; i++) { if (idx[i]->content->tagged && mutt_can_decode (idx[i]->content)) { mutt_body_handler (idx[i]->content, &st); state_putc ('\n', &st); } } } mutt_make_post_indent (Context, parent, tmpfp); if (mime_reply_any && !cur && copy_problematic_attachments (fp, &tmphdr->content, idx, idxlen, 0) == NULL) { mutt_free_header (&tmphdr); safe_fclose (&tmpfp); return; } } safe_fclose (&tmpfp); if (ci_send_message (flags, tmphdr, tmpbody, NULL, parent ? parent : (cur ? cur->hdr : NULL)) == 0) mutt_set_flag (Context, hdr, M_REPLIED, 1); }