/* Remove headers by copying out data to another file, then
* copying the file back */
fseeko(fp, b->offset, SEEK_SET);
- mutt_free_body(&b);
+ mutt_body_free(&b);
mutt_mktemp(tempfile, sizeof(tempfile));
FILE *tfp = mutt_file_fopen(tempfile, "w");
if (!tfp)
actx->fp_len = 0;
for (i = 0; i < actx->body_len; i++)
- mutt_free_body(&actx->body_idx[i]);
+ mutt_body_free(&actx->body_idx[i]);
actx->body_len = 0;
}
#include "header.h"
#include "protos.h"
-struct Body *mutt_new_body(void)
+struct Body *mutt_body_new(void)
{
struct Body *p = mutt_mem_calloc(1, sizeof(struct Body));
}
/**
- * mutt_copy_body - create a send-mode duplicate from a receive-mode body
+ * mutt_body_copy - create a send-mode duplicate from a receive-mode body
*/
-int mutt_copy_body(FILE *fp, struct Body **tgt, struct Body *src)
+int mutt_body_copy(FILE *fp, struct Body **tgt, struct Body *src)
{
if (!tgt || !src)
return -1;
if (mutt_save_attachment(fp, src, tmp, 0, NULL) == -1)
return -1;
- *tgt = mutt_new_body();
+ *tgt = mutt_body_new();
b = *tgt;
memcpy(b, src, sizeof(struct Body));
return 0;
}
-void mutt_free_body(struct Body **p)
+void mutt_body_free(struct Body **p)
{
struct Body *a = *p, *b = NULL;
}
if (b->parts)
- mutt_free_body(&b->parts);
+ mutt_body_free(&b->parts);
FREE(&b);
}
bool noconv : 1; /**< don't do character set conversion */
bool force_charset : 1;
/**< send mode: don't adjust the character
- * set when in send-mode.
- */
+ * set when in send-mode. */
bool is_signed_data : 1; /**< A lot of MUAs don't indicate S/MIME
* signed-data correctly, e.g. they use foo.p7m
* even for the name of signed data. This flag
};
-struct Body *mutt_new_body(void);
-int mutt_copy_body(FILE *fp, struct Body **tgt, struct Body *src);
-void mutt_free_body(struct Body **p);
+int mutt_body_copy(FILE *fp, struct Body **tgt, struct Body *src);
+void mutt_body_free(struct Body **p);
+struct Body *mutt_body_new(void);
#endif /* _MUTT_BODY_H */
if (b)
{
mutt_view_attachment(NULL, b, MUTT_REGULAR, NULL, NULL);
- mutt_free_body(&b);
+ mutt_body_free(&b);
menu->redraw = REDRAW_FULL;
}
else
if (!is_multipart(b) && b->parts)
{
structure_changed = 1;
- mutt_free_body(&b->parts);
+ mutt_body_free(&b->parts);
}
if (!mutt_is_message_type(b->type, b->subtype) && b->hdr)
{
idx[rindex]->content->next = NULL;
idx[rindex]->content->parts = NULL;
- mutt_free_body(&(idx[rindex]->content));
+ mutt_body_free(&(idx[rindex]->content));
FREE(&idx[rindex]->tree);
FREE(&idx[rindex]);
for (; rindex < actx->idxlen - 1; rindex++)
/* avoid freeing other attachments */
actx->idx[i]->content->next = NULL;
actx->idx[i]->content->parts = NULL;
- mutt_free_body(&actx->idx[i]->content);
+ mutt_body_free(&actx->idx[i]->content);
}
}
r = -1;
Context->vsize -= body->length - new_length;
body->length = new_length;
- mutt_free_body(&body->parts);
+ mutt_body_free(&body->parts);
}
return 0;
if (mutt_file_copy_bytes(fp, fpout, cur->length) == -1)
{
mutt_file_fclose(&fp);
- mutt_free_body(&cur);
+ mutt_body_free(&cur);
return -1;
}
- mutt_free_body(&cur);
+ mutt_body_free(&cur);
mutt_file_fclose(&fp);
}
else
if ((flags & MUTT_CM_UPDATE) && (flags & MUTT_CM_NOHEADER) == 0 && new_offset != -1)
{
body->offset = new_offset;
- mutt_free_body(&body->parts);
+ mutt_body_free(&body->parts);
}
return rc;
struct stat st;
mustfree = true;
fstat(fileno(s->fpin), &st);
- b = mutt_new_body();
+ b = mutt_body_new();
b->length = (long) st.st_size;
b->parts = mutt_parse_multipart(
s->fpin, mutt_param_get(&a->parameter, "boundary"), (long) st.st_size,
}
if (mustfree)
- mutt_free_body(&a);
+ mutt_body_free(&a);
return rc;
}
if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE || a->encoding == ENCUUENCODED)
{
fstat(fileno(s->fpin), &st);
- b = mutt_new_body();
+ b = mutt_body_new();
b->length = (LOFF_T) st.st_size;
b->parts = mutt_parse_message_rfc822(s->fpin, b);
}
}
if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE || a->encoding == ENCUUENCODED)
- mutt_free_body(&b);
+ mutt_body_free(&b);
return rc;
}
if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE || a->encoding == ENCUUENCODED)
{
fstat(fileno(s->fpin), &st);
- b = mutt_new_body();
+ b = mutt_body_new();
b->length = (long) st.st_size;
b->parts = mutt_parse_multipart(
s->fpin, mutt_param_get(&a->parameter, "boundary"), (long) st.st_size,
}
if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE || a->encoding == ENCUUENCODED)
- mutt_free_body(&b);
+ mutt_body_free(&b);
/* make failure of a single part non-fatal */
if (rc < 0)
h->env = mutt_env_new();
restore_envelope(h->env, d, &off, convert);
- h->content = mutt_new_body();
+ h->content = mutt_body_new();
restore_body(h->content, d, &off, convert);
restore_char(&h->maildir_flags, d, &off, convert);
if (!h || !*h)
return;
mutt_env_free(&(*h)->env);
- mutt_free_body(&(*h)->content);
+ mutt_body_free(&(*h)->content);
FREE(&(*h)->maildir_flags);
FREE(&(*h)->tree);
FREE(&(*h)->path);
*/
context_hdr = mutt_new_header();
context_hdr->offset = 0;
- context_hdr->content = mutt_new_body();
+ context_hdr->content = mutt_body_new();
if (fstat(fileno(fin), &st) != 0)
{
mutt_perror(draft_file);
* if the user accesses it later.
*/
new_offset[i - first].body = ftello(fp) - ctx->hdrs[i]->content->length + offset;
- mutt_free_body(&ctx->hdrs[i]->content->parts);
+ mutt_body_free(&ctx->hdrs[i]->content->parts);
switch (ctx->magic)
{
h->lines = old_hdr_lines;
}
- mutt_free_body(&h->content->parts);
+ mutt_body_free(&h->content->parts);
return rc;
}
which tmp_smime_pbody->parts after signing. */
tmp_smime_pbody->parts = tmp_smime_pbody->parts->next;
msg->content->next = NULL;
- mutt_free_body(&tmp_smime_pbody);
+ mutt_body_free(&tmp_smime_pbody);
}
pbody = tmp_pbody;
}
/* remove the outer multipart layer */
tmp_pgp_pbody = mutt_remove_multipart(tmp_pgp_pbody);
/* get rid of the signature */
- mutt_free_body(&tmp_pgp_pbody->next);
+ mutt_body_free(&tmp_pgp_pbody->next);
}
return -1;
if (flags != msg->security)
{
tmp_pgp_pbody = mutt_remove_multipart(tmp_pgp_pbody);
- mutt_free_body(&tmp_pgp_pbody->next);
+ mutt_body_free(&tmp_pgp_pbody->next);
}
}
}
return NULL;
}
- t = mutt_new_body();
+ t = mutt_body_new();
t->type = TYPEMULTIPART;
t->subtype = mutt_str_strdup("signed");
t->encoding = ENC7BIT;
t->parts = a;
a = t;
- t->parts->next = mutt_new_body();
+ t->parts->next = mutt_body_new();
t = t->parts->next;
t->type = TYPEAPPLICATION;
if (use_smime)
if (!outfile)
return NULL;
- t = mutt_new_body();
+ t = mutt_body_new();
t->type = TYPEMULTIPART;
t->subtype = mutt_str_strdup("encrypted");
t->encoding = ENC7BIT;
mutt_generate_boundary(&t->parameter);
mutt_param_set(&t->parameter, "protocol", "application/pgp-encrypted");
- t->parts = mutt_new_body();
+ t->parts = mutt_body_new();
t->parts->type = TYPEAPPLICATION;
t->parts->subtype = mutt_str_strdup("pgp-encrypted");
t->parts->encoding = ENC7BIT;
- t->parts->next = mutt_new_body();
+ t->parts->next = mutt_body_new();
t->parts->next->type = TYPEAPPLICATION;
t->parts->next->subtype = mutt_str_strdup("octet-stream");
t->parts->next->encoding = ENC7BIT;
if (!outfile)
return NULL;
- t = mutt_new_body();
+ t = mutt_body_new();
t->type = TYPEAPPLICATION;
t->subtype = mutt_str_strdup("pkcs7-mime");
mutt_param_set(&t->parameter, "name", "smime.p7m");
bb->offset = saved_b_offset;
mutt_file_fclose(&tmpfp);
rewind(*fpout);
- mutt_free_body(cur);
+ mutt_body_free(cur);
*cur = tmp_b;
}
return *cur ? 0 : -1;
s);
}
- mutt_free_body(&tattach);
+ mutt_body_free(&tattach);
mutt_message(_("PGP message successfully decrypted."));
}
else
s);
}
- mutt_free_body(&tattach);
+ mutt_body_free(&tattach);
}
mutt_file_fclose(&fpout);
if (!tempf)
goto bail;
- att = mutt_new_body();
+ att = mutt_body_new();
/* tempf is a newly allocated string, so this is correct: */
att->filename = tempf;
att->unlink = true;
state_attach_puts(_("[-- End of PGP/MIME encrypted data --]\n"), s);
}
- mutt_free_body(&tattach);
+ mutt_body_free(&tattach);
/* clear 'Invoking...' message, since there's no error */
mutt_message(_("PGP message successfully decrypted."));
}
return NULL; /* fatal error while signing */
}
- t = mutt_new_body();
+ t = mutt_body_new();
t->type = TYPEMULTIPART;
t->subtype = mutt_str_strdup("signed");
t->encoding = ENC7BIT;
t->parts = a;
a = t;
- t->parts->next = mutt_new_body();
+ t->parts->next = mutt_body_new();
t = t->parts->next;
t->type = TYPEAPPLICATION;
t->subtype = mutt_str_strdup("pgp-signature");
return NULL;
}
- t = mutt_new_body();
+ t = mutt_body_new();
t->type = TYPEMULTIPART;
t->subtype = mutt_str_strdup("encrypted");
t->encoding = ENC7BIT;
mutt_generate_boundary(&t->parameter);
mutt_param_set(&t->parameter, "protocol", "application/pgp-encrypted");
- t->parts = mutt_new_body();
+ t->parts = mutt_body_new();
t->parts->type = TYPEAPPLICATION;
t->parts->subtype = mutt_str_strdup("pgp-encrypted");
t->parts->encoding = ENC7BIT;
- t->parts->next = mutt_new_body();
+ t->parts->next = mutt_body_new();
t->parts->next->type = TYPEAPPLICATION;
t->parts->next->subtype = mutt_str_strdup("octet-stream");
t->parts->next->encoding = ENC7BIT;
return NULL;
}
- b = mutt_new_body();
+ b = mutt_body_new();
b->encoding = ENC7BIT;
mutt_file_fclose(&tempfp);
mutt_file_fclose(&devnull);
- att = mutt_new_body();
+ att = mutt_body_new();
att->filename = mutt_str_strdup(tempf);
att->unlink = true;
att->use_disp = false;
return NULL;
}
- t = mutt_new_body();
+ t = mutt_body_new();
t->type = TYPEAPPLICATION;
t->subtype = mutt_str_strdup("x-pkcs7-mime");
mutt_param_set(&t->parameter, "name", "smime.p7m");
return NULL; /* fatal error while signing */
}
- t = mutt_new_body();
+ t = mutt_body_new();
t->type = TYPEMULTIPART;
t->subtype = mutt_str_strdup("signed");
t->encoding = ENC7BIT;
t->parts = a;
a = t;
- t->parts->next = mutt_new_body();
+ t->parts->next = mutt_body_new();
t = t->parts->next;
t->type = TYPEAPPLICATION;
t->subtype = mutt_str_strdup("x-pkcs7-signature");
*/
struct Body *mutt_read_mime_header(FILE *fp, int digest)
{
- struct Body *p = mutt_new_body();
+ struct Body *p = mutt_body_new();
char *c = NULL;
char *line = mutt_mem_malloc(LONG_STRING);
size_t linelen = LONG_STRING;
if (new->offset > end_off)
{
- mutt_free_body(&new);
+ mutt_body_free(&new);
break;
}
if (head)
{
if (!hdr->content)
{
- hdr->content = mutt_new_body();
+ hdr->content = mutt_body_new();
/* set the defaults from RFC1521 */
hdr->content->type = TYPETEXT;
hdr->attach_valid = true;
if (!keep_parts)
- mutt_free_body(&hdr->content->parts);
+ mutt_body_free(&hdr->content->parts);
return hdr->attach_total;
}
goto bail;
}
- mutt_free_body(&newhdr->content);
+ mutt_body_free(&newhdr->content);
newhdr->content = b;
mutt_clear_error();
newhdr->security |= APPLICATION_SMIME;
/* destroy the signature */
- mutt_free_body(&newhdr->content->parts->next);
+ mutt_body_free(&newhdr->content->parts->next);
newhdr->content = mutt_remove_multipart(newhdr->content);
}
mutt_stamp_attachment(b);
- mutt_free_body(&b->parts);
+ mutt_body_free(&b->parts);
if (b->hdr)
b->hdr->content = NULL; /* avoid dangling pointer */
}
if (rc == -1)
{
mutt_env_free(&newhdr->env);
- mutt_free_body(&newhdr->content);
+ mutt_body_free(&newhdr->content);
}
return rc;
secured = !crypt_smime_decrypt_mime(outer_fp, &new_fp, outer_new_body, &new_body);
- mutt_free_body(&outer_new_body);
+ mutt_body_free(&outer_new_body);
mutt_file_fclose(&outer_fp);
}
{
if (actx->idx[i]->content->tagged && (force || !mutt_can_decode(actx->idx[i]->content)))
{
- if (mutt_copy_body(actx->idx[i]->fp, last, actx->idx[i]->content) == -1)
+ if (mutt_body_copy(actx->idx[i]->fp, last, actx->idx[i]->content) == -1)
return NULL; /* XXXXX - may lead to crashes */
last = &((*last)->next);
}
}
else
{
- if (mutt_copy_body(fp, last, cur) == -1)
+ if (mutt_body_copy(fp, last, cur) == -1)
goto bail;
}
}
{
last = &tmphdr->content;
if (cur)
- mutt_copy_body(fp, last, cur);
+ mutt_body_copy(fp, last, cur);
else
{
for (short i = 0; i < actx->idxlen; i++)
{
if (actx->idx[i]->content->tagged)
{
- mutt_copy_body(actx->idx[i]->fp, last, actx->idx[i]->content);
+ mutt_body_copy(actx->idx[i]->fp, last, actx->idx[i]->content);
last = &((*last)->next);
}
}
state_putc('\n', &st);
}
else
- mutt_copy_body(fp, &tmphdr->content, cur);
+ mutt_body_copy(fp, &tmphdr->content, cur);
}
else
{
*/
if (!(flags & SENDDRAFTFILE))
{
- pbody = mutt_new_body();
+ pbody = mutt_body_new();
pbody->next = msg->content; /* don't kill command-line attachments */
msg->content = pbody;
/* cleanup the second signature structures */
if (save_content->parts)
{
- mutt_free_body(&save_content->parts->next);
+ mutt_body_free(&save_content->parts->next);
save_content->parts = NULL;
}
- mutt_free_body(&save_content);
+ mutt_body_free(&save_content);
/* restore old signature and attachments */
msg->content->parts->next = save_sig;
else if ((WithCrypto != 0) && save_content)
{
/* destroy the new encrypted body. */
- mutt_free_body(&save_content);
+ mutt_body_free(&save_content);
}
}
else if ((msg->security & ENCRYPT) ||
((msg->security & SIGN) && msg->content->type == TYPEAPPLICATION))
{
- mutt_free_body(&msg->content); /* destroy PGP data */
+ mutt_body_free(&msg->content); /* destroy PGP data */
msg->content = clear_content; /* restore clear text. */
}
else if ((msg->security & SIGN) && msg->content->type == TYPEMULTIPART)
{
- mutt_free_body(&msg->content->parts->next); /* destroy sig */
+ mutt_body_free(&msg->content->parts->next); /* destroy sig */
msg->content = mutt_remove_multipart(msg->content);
}
FREE(&pgpkeylist);
if ((WithCrypto != 0) && free_clear_content)
- mutt_free_body(&clear_content);
+ mutt_body_free(&clear_content);
/* set 'replied' flag only if the user didn't change/remove
In-Reply-To: and References: headers during edit */
return;
}
a->length = sb.st_size;
- mutt_free_body(&a->parts);
+ mutt_body_free(&a->parts);
a->hdr->content = NULL;
}
if (!fp)
return NULL;
- body = mutt_new_body();
+ body = mutt_body_new();
body->type = TYPEMESSAGE;
body->subtype = mutt_str_strdup("rfc822");
body->filename = mutt_str_strdup(buffer);
struct Body *att = NULL;
struct Content *info = NULL;
- att = mutt_new_body();
+ att = mutt_body_new();
att->filename = mutt_str_strdup(path);
if (MimeTypeQueryCommand && *MimeTypeQueryCommand && MimeTypeQueryFirst)
info = mutt_get_content_info(path, att);
if (!info)
{
- mutt_free_body(&att);
+ mutt_body_free(&att);
return NULL;
}
{
struct Body *new = NULL;
- new = mutt_new_body();
+ new = mutt_body_new();
new->type = TYPEMULTIPART;
new->subtype = mutt_str_strdup("mixed");
new->encoding = get_toplevel_encoding(b);
t = b;
b = b->parts;
t->parts = NULL;
- mutt_free_body(&t);
+ mutt_body_free(&t);
}
return b;
}