From: Richard Russon Date: Tue, 28 Nov 2017 19:25:12 +0000 (+0000) Subject: standardise the envelope functions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fce7ca2d5223c129d780617566f08554a3c0f231;p=neomutt standardise the envelope functions --- diff --git a/buffy.c b/buffy.c index 9fda5f744..db32d86b6 100644 --- a/buffy.c +++ b/buffy.c @@ -129,7 +129,7 @@ static int test_last_status_new(FILE *f) if (!(hdr->read || hdr->old)) result = 1; - mutt_free_envelope(&tmp_envelope); + mutt_env_free(&tmp_envelope); mutt_free_header(&hdr); return result; diff --git a/envelope.c b/envelope.c index a65f2f38c..6c229128c 100644 --- a/envelope.c +++ b/envelope.c @@ -25,11 +25,11 @@ * * Representation of an email header (envelope) * - * | Function | Description - * | :--------------------------- | :--------------------------------------------------------- - * | mutt_free_envelope | Free an Envelope - * | mutt_merge_envelopes | Merge the headers of two Envelopes - * | mutt_new_envelope | Create a new Envelope + * | Function | Description + * | :--------------- | :--------------------------------- + * | mutt_env_free() | Free an Envelope + * | mutt_env_merge() | Merge the headers of two Envelopes + * | mutt_env_new() | Create a new Envelope */ #include "config.h" @@ -41,10 +41,10 @@ #include "address.h" /** - * mutt_new_envelope - Create a new Envelope + * mutt_env_new - Create a new Envelope * @retval ptr New Envelope */ -struct Envelope *mutt_new_envelope(void) +struct Envelope *mutt_env_new(void) { struct Envelope *e = mutt_mem_calloc(1, sizeof(struct Envelope)); STAILQ_INIT(&e->references); @@ -54,10 +54,10 @@ struct Envelope *mutt_new_envelope(void) } /** - * mutt_free_envelope - Free an Envelope + * mutt_env_free - Free an Envelope * @param p Envelope to free */ -void mutt_free_envelope(struct Envelope **p) +void mutt_env_free(struct Envelope **p) { if (!*p) return; @@ -95,17 +95,17 @@ void mutt_free_envelope(struct Envelope **p) } /** - * mutt_merge_envelopes - Merge the headers of two Envelopes + * mutt_env_merge - Merge the headers of two Envelopes * @param base Envelope destination for all the headers * @param extra Envelope to copy from * * Any fields that are missing from base will be copied from extra. * extra will be freed afterwards. */ -void mutt_merge_envelopes(struct Envelope *base, struct Envelope **extra) +void mutt_env_merge(struct Envelope *base, struct Envelope **extra) { /* copies each existing element if necessary, and sets the element - * to NULL in the source so that mutt_free_envelope doesn't leave us + * to NULL in the source so that mutt_env_free doesn't leave us * with dangling pointers. */ #define MOVE_ELEM(h) \ if (!base->h) \ @@ -161,5 +161,5 @@ void mutt_merge_envelopes(struct Envelope *base, struct Envelope **extra) MOVE_STAILQ(userhdrs); #undef MOVE_ELEM - mutt_free_envelope(extra); + mutt_env_free(extra); } diff --git a/envelope.h b/envelope.h index 245322435..5d7e5f79c 100644 --- a/envelope.h +++ b/envelope.h @@ -64,8 +64,8 @@ struct Envelope bool refs_changed : 1; /**< References changed to break thread */ }; -struct Envelope *mutt_new_envelope(void); -void mutt_free_envelope(struct Envelope **p); -void mutt_merge_envelopes(struct Envelope *base, struct Envelope **extra); +struct Envelope *mutt_env_new(void); +void mutt_env_free(struct Envelope **p); +void mutt_env_merge(struct Envelope *base, struct Envelope **extra); #endif /* _MUTT_ENVELOPE_H */ diff --git a/hcache/hcache.c b/hcache/hcache.c index e24356d18..19d7d3ef6 100644 --- a/hcache/hcache.c +++ b/hcache/hcache.c @@ -705,7 +705,7 @@ struct Header *mutt_hcache_restore(const unsigned char *d) memcpy(h, d + off, sizeof(struct Header)); off += sizeof(struct Header); - h->env = mutt_new_envelope(); + h->env = mutt_env_new(); restore_envelope(h->env, d, &off, convert); h->content = mutt_new_body(); diff --git a/hcache/hcache.h b/hcache/hcache.h index 772d749ab..9a23666dd 100644 --- a/hcache/hcache.h +++ b/hcache/hcache.h @@ -44,7 +44,7 @@ * * mutt_convert_string() * * mutt_encode_path() * * mutt_new_body() - * * mutt_new_envelope() + * * mutt_env_new() * * mutt_sleep() * * mx_lock_file() * * mx_unlock_file() diff --git a/header.c b/header.c index 214fb2727..95dc93e2e 100644 --- a/header.c +++ b/header.c @@ -142,7 +142,7 @@ void mutt_edit_headers(const char *editor, const char *body, struct Header *msg, mutt_list_free(&n->references); STAILQ_SWAP(&n->references, &msg->env->references, ListNode); - mutt_free_envelope(&msg->env); + mutt_env_free(&msg->env); msg->env = n; n = NULL; @@ -360,7 +360,7 @@ void mutt_free_header(struct Header **h) { if (!h || !*h) return; - mutt_free_envelope(&(*h)->env); + mutt_env_free(&(*h)->env); mutt_free_body(&(*h)->content); FREE(&(*h)->maildir_flags); FREE(&(*h)->tree); diff --git a/imap/message.c b/imap/message.c index 4cafe9eb5..b7741328f 100644 --- a/imap/message.c +++ b/imap/message.c @@ -1169,7 +1169,7 @@ parsemsg: * changed). Another possibility: ignore Status on IMAP? */ read = h->read; newenv = mutt_read_rfc822_header(msg->fp, h, 0, 0); - mutt_merge_envelopes(h->env, &newenv); + mutt_env_merge(h->env, &newenv); /* see above. We want the new status in h->read, so we unset it manually * and let mutt_set_flag set it correctly, updating context. */ diff --git a/main.c b/main.c index 6e0c3485e..b6b2d31d9 100644 --- a/main.c +++ b/main.c @@ -302,7 +302,7 @@ int main(int argc, char **argv, char **env) if (!msg) msg = mutt_new_header(); if (!msg->env) - msg->env = mutt_new_envelope(); + msg->env = mutt_env_new(); if (i == 'b') msg->env->bcc = mutt_addr_parse_list(msg->env->bcc, optarg); else @@ -573,7 +573,7 @@ int main(int argc, char **argv, char **env) if (!msg) msg = mutt_new_header(); if (!msg->env) - msg->env = mutt_new_envelope(); + msg->env = mutt_env_new(); for (i = optind; i < argc; i++) { @@ -734,7 +734,7 @@ int main(int argc, char **argv, char **env) if (opts_env->subject) mutt_str_replace(&msg->env->subject, opts_env->subject); - mutt_free_envelope(&opts_env); + mutt_env_free(&opts_env); mutt_free_header(&context_hdr); } /* Editing the includeFile: pass it directly in. diff --git a/muttlib.c b/muttlib.c index 0e20bcc81..6cbf82eab 100644 --- a/muttlib.c +++ b/muttlib.c @@ -257,7 +257,7 @@ char *mutt_expand_path_regex(char *s, size_t slen, int regex) if ((alias = mutt_lookup_alias(s + 1))) { h = mutt_new_header(); - h->env = mutt_new_envelope(); + h->env = mutt_env_new(); h->env->from = h->env->to = alias; mutt_default_save(p, sizeof(p), h); h->env->from = h->env->to = NULL; diff --git a/nntp.c b/nntp.c index d8e67da9c..6bff6fa3e 100644 --- a/nntp.c +++ b/nntp.c @@ -1697,7 +1697,7 @@ static int nntp_open_message(struct Context *ctx, struct Message *msg, int msgno if (ctx->subj_hash && hdr->env->real_subj) mutt_hash_delete(ctx->subj_hash, hdr->env->real_subj, hdr, NULL); - mutt_free_envelope(&hdr->env); + mutt_env_free(&hdr->env); hdr->env = mutt_read_rfc822_header(msg->fp, hdr, 0, 0); if (ctx->id_hash && hdr->env->message_id) diff --git a/parse.c b/parse.c index c0d686dd3..f77195ba2 100644 --- a/parse.c +++ b/parse.c @@ -1149,12 +1149,12 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, * Used for recall-message * @retval ptr Newly allocated envelope structure * - * Caller should free the Envelope using mutt_free_envelope(). + * Caller should free the Envelope using mutt_env_free(). */ struct Envelope *mutt_read_rfc822_header(FILE *f, struct Header *hdr, short user_hdrs, short weed) { - struct Envelope *e = mutt_new_envelope(); + struct Envelope *e = mutt_env_new(); char *line = mutt_mem_malloc(LONG_STRING); char *p = NULL; LOFF_T loc; diff --git a/pop.c b/pop.c index 1d7ba8453..aa4390231 100644 --- a/pop.c +++ b/pop.c @@ -666,7 +666,7 @@ static int pop_fetch_message(struct Context *ctx, struct Message *msg, int msgno if (ctx->subj_hash && h->env->real_subj) mutt_hash_delete(ctx->subj_hash, h->env->real_subj, h, NULL); mutt_label_hash_remove(ctx, h); - mutt_free_envelope(&h->env); + mutt_env_free(&h->env); h->env = mutt_read_rfc822_header(msg->fp, h, 0, 0); if (ctx->subj_hash && h->env->real_subj) mutt_hash_insert(ctx->subj_hash, h->env->real_subj, h); diff --git a/postpone.c b/postpone.c index 685705df8..c0f0432a7 100644 --- a/postpone.c +++ b/postpone.c @@ -587,7 +587,7 @@ int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr, { err: mx_close_message(ctx, &msg); - mutt_free_envelope(&newhdr->env); + mutt_env_free(&newhdr->env); mutt_free_body(&newhdr->content); mutt_error(_("Decryption failed.")); return -1; @@ -741,7 +741,7 @@ bail: if (rc == -1) { - mutt_free_envelope(&newhdr->env); + mutt_env_free(&newhdr->env); mutt_free_body(&newhdr->content); } diff --git a/query.c b/query.c index 7711f896a..f43f50554 100644 --- a/query.c +++ b/query.c @@ -463,7 +463,7 @@ static void query_menu(char *buf, size_t buflen, struct Query *results, int retb /* fallthrough */ case OP_MAIL: msg = mutt_new_header(); - msg->env = mutt_new_envelope(); + msg->env = mutt_env_new(); if (!menu->tagprefix) { msg->env->to = result_to_addr(QueryTable[menu->current].data); diff --git a/recvcmd.c b/recvcmd.c index 8aa5cf1da..ac2aa3259 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -414,7 +414,7 @@ static void attach_forward_bodies(FILE *fp, struct Header *hdr, struct AttachCtx } tmphdr = mutt_new_header(); - tmphdr->env = mutt_new_envelope(); + tmphdr->env = mutt_env_new(); mutt_make_forward_subject(tmphdr->env, Context, parent_hdr); mutt_mktemp(tmpbody, sizeof(tmpbody)); @@ -584,7 +584,7 @@ static void attach_forward_msgs(FILE *fp, struct AttachCtx *actx, struct Body *c } tmphdr = mutt_new_header(); - tmphdr->env = mutt_new_envelope(); + tmphdr->env = mutt_env_new(); mutt_make_forward_subject(tmphdr->env, Context, curhdr); tmpbody[0] = '\0'; @@ -854,7 +854,7 @@ void mutt_attach_reply(FILE *fp, struct Header *hdr, struct AttachCtx *actx, mime_reply_any = true; tmphdr = mutt_new_header(); - tmphdr->env = mutt_new_envelope(); + tmphdr->env = mutt_env_new(); if (attach_reply_envelope_defaults( tmphdr->env, actx, parent_hdr ? parent_hdr : (cur ? cur->hdr : NULL), flags) == -1) diff --git a/send.c b/send.c index ff81269be..22a17d40a 100644 --- a/send.c +++ b/send.c @@ -1213,7 +1213,7 @@ int mutt_compose_to_sender(struct Header *hdr) { struct Header *msg = mutt_new_header(); - msg->env = mutt_new_envelope(); + msg->env = mutt_env_new(); if (!hdr) { for (int i = 0; i < Context->msgcount; i++) @@ -1423,7 +1423,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, } if (!msg->env) - msg->env = mutt_new_envelope(); + msg->env = mutt_env_new(); } /* Parse and use an eventual list-post header */