bcache.c body.c body.h browser.c buffy.c charset.c color.c \
commands.c complete.c compose.c compress.c content.h context.h copy.c \
curs_lib.c curs_main.c edit.c editmsg.c enter.c enter_state.h \
- envelope.h filter.c flags.c format_flags.h from.c getdomain.c group.c \
+ envelope.c envelope.h filter.c flags.c format_flags.h from.c getdomain.c group.c \
handler.c hdrline.c header.h headers.c help.c history.c hook.c \
init.c keymap.c list.h main.c mbox.c mbyte.c mbyte_table.h \
menu.c mh.c muttlib.c mutt_idna.c mutt_sasl_plain.c mutt_socket.c \
#include <utime.h>
#include "buffy.h"
#include "context.h"
+#include "envelope.h"
#include "globals.h"
#include "header.h"
#include "lib/lib.h"
--- /dev/null
+/**
+ * @file
+ * Representation of an email header (envelope)
+ *
+ * @authors
+ * Copyright (C) 2017 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "envelope.h"
+#include <stddef.h>
+#include "lib/buffer.h"
+#include "lib/memory.h"
+#include "queue.h"
+#include "rfc822.h"
+
+struct Envelope *mutt_new_envelope(void)
+{
+ struct Envelope *e = safe_calloc(1, sizeof(struct Envelope));
+ STAILQ_INIT(&e->references);
+ STAILQ_INIT(&e->in_reply_to);
+ STAILQ_INIT(&e->userhdrs);
+ return e;
+}
+
+void mutt_free_envelope(struct Envelope **p)
+{
+ if (!*p)
+ return;
+ rfc822_free_address(&(*p)->return_path);
+ rfc822_free_address(&(*p)->from);
+ rfc822_free_address(&(*p)->to);
+ rfc822_free_address(&(*p)->cc);
+ rfc822_free_address(&(*p)->bcc);
+ rfc822_free_address(&(*p)->sender);
+ rfc822_free_address(&(*p)->reply_to);
+ rfc822_free_address(&(*p)->mail_followup_to);
+
+ FREE(&(*p)->list_post);
+ FREE(&(*p)->subject);
+ /* real_subj is just an offset to subject and shouldn't be freed */
+ FREE(&(*p)->disp_subj);
+ FREE(&(*p)->message_id);
+ FREE(&(*p)->supersedes);
+ FREE(&(*p)->date);
+ FREE(&(*p)->x_label);
+ FREE(&(*p)->organization);
+#ifdef USE_NNTP
+ FREE(&(*p)->newsgroups);
+ FREE(&(*p)->xref);
+ FREE(&(*p)->followup_to);
+ FREE(&(*p)->x_comment_to);
+#endif
+
+ mutt_buffer_free(&(*p)->spam);
+
+ mutt_list_free(&(*p)->references);
+ mutt_list_free(&(*p)->in_reply_to);
+ mutt_list_free(&(*p)->userhdrs);
+ FREE(p);
+}
+
+/**
+ * mutt_merge_envelopes - Merge the headers of two emails
+ *
+ * Move all the headers from extra not present in base into base
+ */
+void mutt_merge_envelopes(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
+ * with dangling pointers. */
+#define MOVE_ELEM(h) \
+ if (!base->h) \
+ { \
+ base->h = (*extra)->h; \
+ (*extra)->h = NULL; \
+ }
+
+#define MOVE_STAILQ(h) \
+ if (STAILQ_EMPTY(&base->h)) \
+ { \
+ STAILQ_SWAP(&base->h, &((*extra))->h, ListNode); \
+ }
+
+ MOVE_ELEM(return_path);
+ MOVE_ELEM(from);
+ MOVE_ELEM(to);
+ MOVE_ELEM(cc);
+ MOVE_ELEM(bcc);
+ MOVE_ELEM(sender);
+ MOVE_ELEM(reply_to);
+ MOVE_ELEM(mail_followup_to);
+ MOVE_ELEM(list_post);
+ MOVE_ELEM(message_id);
+ MOVE_ELEM(supersedes);
+ MOVE_ELEM(date);
+ MOVE_ELEM(x_label);
+ MOVE_ELEM(x_original_to);
+ if (!base->refs_changed)
+ {
+ MOVE_STAILQ(references);
+ }
+ if (!base->irt_changed)
+ {
+ MOVE_STAILQ(in_reply_to);
+ }
+
+ /* real_subj is subordinate to subject */
+ if (!base->subject)
+ {
+ base->subject = (*extra)->subject;
+ base->real_subj = (*extra)->real_subj;
+ base->disp_subj = (*extra)->disp_subj;
+ (*extra)->subject = NULL;
+ (*extra)->real_subj = NULL;
+ (*extra)->disp_subj = NULL;
+ }
+ /* spam and user headers should never be hashed, and the new envelope may
+ * have better values. Use new versions regardless. */
+ mutt_buffer_free(&base->spam);
+ mutt_list_free(&base->userhdrs);
+ MOVE_ELEM(spam);
+ MOVE_STAILQ(userhdrs);
+#undef MOVE_ELEM
+
+ mutt_free_envelope(extra);
+}
+
#define _MUTT_ENVELOPE_H
#include <stdbool.h>
-#include "lib/lib.h"
#include "list.h"
/**
bool refs_changed : 1; /**< References changed to break thread */
};
-static inline struct Envelope *mutt_new_envelope(void)
-{
- struct Envelope *e = safe_calloc(1, sizeof(struct Envelope));
- STAILQ_INIT(&e->references);
- STAILQ_INIT(&e->in_reply_to);
- STAILQ_INIT(&e->userhdrs);
- return e;
-}
+struct Envelope *mutt_new_envelope(void);
+void mutt_free_envelope(struct Envelope **p);
+void mutt_merge_envelopes(struct Envelope *base, struct Envelope **extra);
#endif /* _MUTT_ENVELOPE_H */
return false;
}
-void mutt_free_envelope(struct Envelope **p)
-{
- if (!*p)
- return;
- rfc822_free_address(&(*p)->return_path);
- rfc822_free_address(&(*p)->from);
- rfc822_free_address(&(*p)->to);
- rfc822_free_address(&(*p)->cc);
- rfc822_free_address(&(*p)->bcc);
- rfc822_free_address(&(*p)->sender);
- rfc822_free_address(&(*p)->reply_to);
- rfc822_free_address(&(*p)->mail_followup_to);
-
- FREE(&(*p)->list_post);
- FREE(&(*p)->subject);
- /* real_subj is just an offset to subject and shouldn't be freed */
- FREE(&(*p)->disp_subj);
- FREE(&(*p)->message_id);
- FREE(&(*p)->supersedes);
- FREE(&(*p)->date);
- FREE(&(*p)->x_label);
- FREE(&(*p)->organization);
-#ifdef USE_NNTP
- FREE(&(*p)->newsgroups);
- FREE(&(*p)->xref);
- FREE(&(*p)->followup_to);
- FREE(&(*p)->x_comment_to);
-#endif
-
- mutt_buffer_free(&(*p)->spam);
-
- mutt_list_free(&(*p)->references);
- mutt_list_free(&(*p)->in_reply_to);
- mutt_list_free(&(*p)->userhdrs);
- FREE(p);
-}
-
-/**
- * mutt_merge_envelopes - Merge the headers of two emails
- *
- * Move all the headers from extra not present in base into base
- */
-void mutt_merge_envelopes(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
- * with dangling pointers. */
-#define MOVE_ELEM(h) \
- if (!base->h) \
- { \
- base->h = (*extra)->h; \
- (*extra)->h = NULL; \
- }
-
-#define MOVE_STAILQ(h) \
- if (STAILQ_EMPTY(&base->h)) \
- { \
- STAILQ_SWAP(&base->h, &((*extra))->h, ListNode); \
- }
-
- MOVE_ELEM(return_path);
- MOVE_ELEM(from);
- MOVE_ELEM(to);
- MOVE_ELEM(cc);
- MOVE_ELEM(bcc);
- MOVE_ELEM(sender);
- MOVE_ELEM(reply_to);
- MOVE_ELEM(mail_followup_to);
- MOVE_ELEM(list_post);
- MOVE_ELEM(message_id);
- MOVE_ELEM(supersedes);
- MOVE_ELEM(date);
- MOVE_ELEM(x_label);
- MOVE_ELEM(x_original_to);
- if (!base->refs_changed)
- {
- MOVE_STAILQ(references);
- }
- if (!base->irt_changed)
- {
- MOVE_STAILQ(in_reply_to);
- }
-
- /* real_subj is subordinate to subject */
- if (!base->subject)
- {
- base->subject = (*extra)->subject;
- base->real_subj = (*extra)->real_subj;
- base->disp_subj = (*extra)->disp_subj;
- (*extra)->subject = NULL;
- (*extra)->real_subj = NULL;
- (*extra)->disp_subj = NULL;
- }
- /* spam and user headers should never be hashed, and the new envelope may
- * have better values. Use new versions regardless. */
- mutt_buffer_free(&base->spam);
- mutt_list_free(&base->userhdrs);
- MOVE_ELEM(spam);
- MOVE_STAILQ(userhdrs);
-#undef MOVE_ELEM
-
- mutt_free_envelope(extra);
-}
-
static FILE *frandom;
static void mutt_randbuf(void *out, size_t len)
edit.c
editmsg.c
enter.c
+envelope.c
filter.c
flags.c
from.c
void mutt_free_alias(struct Alias **p);
void mutt_free_color(int fg, int bg);
void mutt_free_enter_state(struct EnterState **esp);
-void mutt_free_envelope(struct Envelope **p);
void mutt_free_header(struct Header **h);
void mutt_free_regexp(struct Regex **pp);
void mutt_help(int menu);
void mutt_make_help(char *d, size_t dlen, const char *txt, int menu, int op);
void mutt_make_misc_reply_headers(struct Envelope *env, struct Context *ctx, struct Header *cur, struct Envelope *curenv);
void mutt_make_post_indent(struct Context *ctx, struct Header *cur, FILE *out);
-void mutt_merge_envelopes(struct Envelope *base, struct Envelope **extra);
void mutt_message_to_7bit(struct Body *a, FILE *fp);
#define mutt_mktemp(a, b) mutt_mktemp_pfx_sfx(a, b, "mutt", NULL)
#define mutt_mktemp_pfx_sfx(a, b, c, d) _mutt_mktemp(a, b, c, d, __FILE__, __LINE__)