color.o commands.o complete.o compose.o compress.o \
conststrings.o copy.o curs_lib.o curs_main.o edit.o editmsg.o \
enriched.o enter.o filter.o flags.o from.o group.o handler.o \
- hdrline.o header.o help.o history.o hook.o init.o keymap.o \
- main.o mbox.o menu.o mh.o muttlib.o mutt_account.o mutt_attach.o mutt_body.o \
+ hdrline.o help.o history.o hook.o init.o keymap.o \
+ main.o mbox.o menu.o mh.o muttlib.o mutt_account.o mutt_attach.o mutt_body.o mutt_header.o \
mutt_logging.o mutt_signal.o mutt_socket.o mutt_thread.o mutt_window.o mx.o newsrc.o \
nntp.o pager.o parse.o pattern.o pop.o pop_auth.o pop_lib.o \
postpone.o progress.o query.o recvattach.o recvcmd.o resize.o rfc1524.o \
LIBMUTT= libmutt.a
LIBMUTTOBJS= mutt/address.o mutt/attach.o mutt/base64.o mutt/body.o mutt/buffer.o mutt/charset.o \
mutt/date.o mutt/envelope.o mutt/envlist.o mutt/exit.o mutt/file.o mutt/hash.o \
- mutt/idna.o mutt/list.o mutt/logging.o mutt/mapping.o \
+ mutt/header.o mutt/idna.o mutt/list.o mutt/logging.o mutt/mapping.o \
mutt/mbyte.o mutt/md5.o mutt/memory.o mutt/mime.o \
mutt/parameter.o mutt/regex.o mutt/rfc2047.o mutt/sha1.o \
mutt/signal.o mutt/string.o mutt/tags.o mutt/thread.o
hcache/hcversion.h: $(SRCDIR)/mutt.h $(SRCDIR)/mutt/address.h \
$(SRCDIR)/mutt/list.h $(SRCDIR)/mutt/buffer.h \
$(SRCDIR)/mutt/parameter.h $(SRCDIR)/mutt/body.h \
- $(SRCDIR)/mutt/envelope.h $(SRCDIR)/header.h \
+ $(SRCDIR)/mutt/envelope.h $(SRCDIR)/mutt/header.h \
$(SRCDIR)/hcache/hcachever.sh
$(MKDIR_P) $(PWD)/hcache
( echo '#include "config.h"'; echo '#include "mutt.h"'; \
echo '#include "mutt/address.h"'; echo '#include "mutt/list.h"'; \
echo '#include "mutt/buffer.h"'; echo '#include "mutt/parameter.h"'; \
- echo '#include "header.h"';) | $(CPP) $(CFLAGS) - | \
+ echo '#include "mutt/header.h"';) | $(CPP) $(CFLAGS) - | \
sh $(SRCDIR)/hcache/hcachever.sh hcache/hcversion.h
# clean
#include "buffy.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mutt.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "filter.h"
#include "format_flags.h"
#include "globals.h"
-#include "header.h"
#include "keymap.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "context.h"
#include "format_flags.h"
#include "globals.h"
-#include "header.h"
#include "keymap.h"
#include "mailbox.h"
#include "mutt_attach.h"
#include "context.h"
#include "globals.h"
#include "handler.h"
-#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_window.h"
#include "context.h"
#include "enter_state.h"
#include "globals.h"
-#include "header.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mutt_window.h"
#include "context.h"
#include "format_flags.h"
#include "globals.h"
-#include "header.h"
#include "keymap.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "alias.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "mutt_curses.h"
#include "mutt_window.h"
#include "options.h"
#include "context.h"
#include "copy.h"
#include "globals.h"
-#include "header.h"
#include "mailbox.h"
#include "mx.h"
#include "options.h"
#include "mutt.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mutt_window.h"
#include "globals.h"
#include "hcache.h"
#include "hcache/hcversion.h"
-#include "header.h"
#include "protos.h"
static unsigned int hcachever = 0x0;
#include "context.h"
#include "format_flags.h"
#include "globals.h"
-#include "header.h"
#include "mbtable.h"
#include "mutt_curses.h"
#include "mutt_thread.h"
#include "mutt/mutt.h"
#include "mutt.h"
#include "globals.h"
-#include "header.h"
#include "mailbox.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "buffy.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "imap/imap.h"
#include "mailbox.h"
#include "message.h"
#include "buffy.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "mailbox.h"
#include "message.h"
#include "mutt_account.h"
#include "bcache.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "imap/imap.h"
#include "mailbox.h"
#include "mutt_account.h"
#include "bcache.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "imap/imap.h"
#include "mailbox.h"
#include "message.h"
#include "filter.h"
#include "group.h"
#include "hcache/hcache.h"
-#include "header.h"
#include "history.h"
#include "keymap.h"
#include "mailbox.h"
#include "alias.h"
#include "buffy.h"
#include "globals.h"
-#include "header.h"
#include "keymap.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "context.h"
#include "copy.h"
#include "globals.h"
-#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_thread.h"
return 0;
}
-/**
- * mbox_strict_cmp_headers - Strictly compare message headers
- * @param h1 First Header
- * @param h2 Second Header
- * @retval true Headers are strictly identical
- */
-bool mbox_strict_cmp_headers(const struct Header *h1, const struct Header *h2)
-{
- if (h1 && h2)
- {
- if ((h1->received != h2->received) || (h1->date_sent != h2->date_sent) ||
- (h1->content->length != h2->content->length) ||
- (h1->lines != h2->lines) || (h1->zhours != h2->zhours) ||
- (h1->zminutes != h2->zminutes) || (h1->zoccident != h2->zoccident) ||
- (h1->mime != h2->mime) || !mutt_env_cmp_strict(h1->env, h2->env) ||
- !mutt_body_cmp_strict(h1->content, h2->content))
- {
- return false;
- }
- else
- return true;
- }
- else
- {
- if (!h1 && !h2)
- return true;
- else
- return false;
- }
-}
-
/**
* reopen_mailbox - Close and reopen a mailbox
* @param ctx Mailbox
{
case MUTT_MBOX:
case MUTT_MMDF:
- cmp_headers = mbox_strict_cmp_headers;
+ cmp_headers = mutt_header_cmp_strict;
mutt_file_fclose(&ctx->fp);
ctx->fp = mutt_file_fopen(ctx->path, "r");
if (!ctx->fp)
#include "context.h"
#include "copy.h"
#include "globals.h"
-#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_thread.h"
ctx->hdrs[i]->active = false;
p = mutt_hash_find(fnames, ctx->hdrs[i]->path);
- if (p && p->h && mbox_strict_cmp_headers(ctx->hdrs[i], p->h))
+ if (p && p->h && mutt_header_cmp_strict(ctx->hdrs[i], p->h))
{
ctx->hdrs[i]->active = true;
/* found the right message */
#include <stddef.h>
#include <stdbool.h>
#include <time.h>
-#include "mutt/mutt.h"
+#include "list.h"
+#include "tags.h"
/**
* struct Header - The header/envelope of an email
bool recip_valid : 1; /**< is_recipient is valid */
bool active : 1; /**< message is not to be removed */
bool trash : 1; /**< message is marked as trashed on disk.
- * This flag is used by the maildir_trash
- * option.
- */
+ * This flag is used by the maildir_trash option. */
bool xlabel_changed : 1; /**< editable - used for syncing */
/* timezone of the sender of this message */
char *maildir_flags; /**< unknown maildir flags */
};
+bool mutt_header_cmp_strict(const struct Header *h1, const struct Header *h2);
void mutt_header_free(struct Header **h);
struct Header *mutt_header_new(void);
-bool mbox_strict_cmp_headers(const struct Header *h1, const struct Header *h2);
-
#endif /* _MUTT_HEADER_H */
* | mutt/exit.c | @subpage exit |
* | mutt/file.c | @subpage file |
* | mutt/hash.c | @subpage hash |
+ * | mutt/header.c | @subpage header |
* | mutt/idna.c | @subpage idna |
* | mutt/list.c | @subpage list |
* | mutt/logging.c | @subpage logging |
#include "exit.h"
#include "file.h"
#include "hash.h"
+#include "header.h"
#include "idna2.h"
#include "list.h"
#include "logging.h"
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include "header.h"
+#include "thread.h"
/**
* is_descendant - Is one thread a descendant of another
#include "filter.h"
#include "globals.h"
#include "handler.h"
-#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mx.h"
#include <sys/stat.h>
#include <time.h>
#include "mutt/mutt.h"
-#include "mutt.h"
-#include "header.h"
#include "alias.h"
#include "context.h"
#include "globals.h"
#include "ncrypt/ncrypt.h"
-#include "options.h"
#include "protos.h"
+static void label_ref_dec(struct Context *ctx, char *label)
+{
+ struct HashElem *elem = mutt_hash_find_elem(ctx->label_hash, label);
+ if (!elem)
+ return;
+
+ uintptr_t count = (uintptr_t) elem->data;
+ if (count <= 1)
+ {
+ mutt_hash_delete(ctx->label_hash, label, NULL);
+ return;
+ }
+
+ count--;
+ elem->data = (void *) count;
+}
+
+static void label_ref_inc(struct Context *ctx, char *label)
+{
+ uintptr_t count;
+
+ struct HashElem *elem = mutt_hash_find_elem(ctx->label_hash, label);
+ if (!elem)
+ {
+ count = 1;
+ mutt_hash_insert(ctx->label_hash, label, (void *) count);
+ return;
+ }
+
+ count = (uintptr_t) elem->data;
+ count++;
+ elem->data = (void *) count;
+}
+
+/**
+ * label_message - add an X-Label: field
+ */
+static bool label_message(struct Context *ctx, struct Header *hdr, char *new)
+{
+ if (!hdr)
+ return false;
+ if (mutt_str_strcmp(hdr->env->x_label, new) == 0)
+ return false;
+
+ if (hdr->env->x_label)
+ label_ref_dec(ctx, hdr->env->x_label);
+ mutt_str_replace(&hdr->env->x_label, new);
+ if (hdr->env->x_label)
+ label_ref_inc(ctx, hdr->env->x_label);
+
+ hdr->changed = true;
+ hdr->xlabel_changed = true;
+ return true;
+}
+
+int mutt_label_message(struct Header *hdr)
+{
+ char buf[LONG_STRING], *new = NULL;
+ int changed;
+
+ if (!Context || !Context->label_hash)
+ return 0;
+
+ *buf = '\0';
+ if (hdr != NULL && hdr->env->x_label != NULL)
+ {
+ mutt_str_strfcpy(buf, hdr->env->x_label, sizeof(buf));
+ }
+
+ if (mutt_get_field("Label: ", buf, sizeof(buf), MUTT_LABEL /* | MUTT_CLEAR */) != 0)
+ return 0;
+
+ new = buf;
+ SKIPWS(new);
+ if (*new == '\0')
+ new = NULL;
+
+ changed = 0;
+ if (hdr)
+ {
+ if (label_message(Context, hdr, new))
+ {
+ changed++;
+ mutt_set_header_color(Context, hdr);
+ }
+ }
+ else
+ {
+ for (int i = 0; i < Context->msgcount; ++i)
+ {
+ if (!message_is_tagged(Context, i))
+ continue;
+
+ struct Header *h = Context->hdrs[i];
+ if (label_message(Context, h, new))
+ {
+ changed++;
+ mutt_set_flag(Context, h, MUTT_TAG, 0);
+ /* mutt_set_flag re-evals the header color */
+ }
+ }
+ }
+
+ return changed;
+}
+
void mutt_edit_headers(const char *editor, const char *body, struct Header *msg,
char *fcc, size_t fcclen)
{
}
}
-static void label_ref_dec(struct Context *ctx, char *label)
-{
- struct HashElem *elem = mutt_hash_find_elem(ctx->label_hash, label);
- if (!elem)
- return;
-
- uintptr_t count = (uintptr_t) elem->data;
- if (count <= 1)
- {
- mutt_hash_delete(ctx->label_hash, label, NULL);
- return;
- }
-
- count--;
- elem->data = (void *) count;
-}
-
-static void label_ref_inc(struct Context *ctx, char *label)
-{
- uintptr_t count;
-
- struct HashElem *elem = mutt_hash_find_elem(ctx->label_hash, label);
- if (!elem)
- {
- count = 1;
- mutt_hash_insert(ctx->label_hash, label, (void *) count);
- return;
- }
-
- count = (uintptr_t) elem->data;
- count++;
- elem->data = (void *) count;
-}
-
-/**
- * label_message - add an X-Label: field
- */
-static bool label_message(struct Context *ctx, struct Header *hdr, char *new)
-{
- if (!hdr)
- return false;
- if (mutt_str_strcmp(hdr->env->x_label, new) == 0)
- return false;
-
- if (hdr->env->x_label)
- label_ref_dec(ctx, hdr->env->x_label);
- mutt_str_replace(&hdr->env->x_label, new);
- if (hdr->env->x_label)
- label_ref_inc(ctx, hdr->env->x_label);
-
- hdr->changed = true;
- hdr->xlabel_changed = true;
- return true;
-}
-
-int mutt_label_message(struct Header *hdr)
-{
- char buf[LONG_STRING], *new = NULL;
- int changed;
-
- if (!Context || !Context->label_hash)
- return 0;
-
- *buf = '\0';
- if (hdr != NULL && hdr->env->x_label != NULL)
- {
- mutt_str_strfcpy(buf, hdr->env->x_label, sizeof(buf));
- }
-
- if (mutt_get_field("Label: ", buf, sizeof(buf), MUTT_LABEL /* | MUTT_CLEAR */) != 0)
- return 0;
-
- new = buf;
- SKIPWS(new);
- if (*new == '\0')
- new = NULL;
-
- changed = 0;
- if (hdr)
- {
- if (label_message(Context, hdr, new))
- {
- changed++;
- mutt_set_header_color(Context, hdr);
- }
- }
- else
- {
- for (int i = 0; i < Context->msgcount; ++i)
- {
- if (!message_is_tagged(Context, i))
- continue;
-
- struct Header *h = Context->hdrs[i];
- if (label_message(Context, h, new))
- {
- changed++;
- mutt_set_flag(Context, h, MUTT_TAG, 0);
- /* mutt_set_flag re-evals the header color */
- }
- }
- }
-
- return changed;
-}
-
void mutt_make_label_hash(struct Context *ctx)
{
/* 131 is just a rough prime estimate of how many distinct
if (hdr->env->x_label)
label_ref_dec(ctx, hdr->env->x_label);
}
-
-void mutt_header_free(struct Header **h)
-{
- if (!h || !*h)
- return;
- mutt_env_free(&(*h)->env);
- mutt_body_free(&(*h)->content);
- FREE(&(*h)->maildir_flags);
- FREE(&(*h)->tree);
- FREE(&(*h)->path);
-#ifdef MIXMASTER
- mutt_list_free(&(*h)->chain);
-#endif
- driver_tags_free(&(*h)->tags);
-#if defined(USE_POP) || defined(USE_IMAP) || defined(USE_NNTP) || defined(USE_NOTMUCH)
- if ((*h)->free_cb)
- (*h)->free_cb(*h);
- FREE(&(*h)->data);
-#endif
- FREE(h);
-}
-
-struct Header *mutt_header_new(void)
-{
- struct Header *h = mutt_mem_calloc(1, sizeof(struct Header));
-#ifdef MIXMASTER
- STAILQ_INIT(&h->chain);
-#endif
- STAILQ_INIT(&h->tags);
- return h;
-}
--- /dev/null
+/**
+ * @file
+ * Representation of the email's header
+ *
+ * @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/>.
+ */
+
+#ifndef _MUTT_HEADER_H
+#define _MUTT_HEADER_H
+
+#include <stddef.h>
+#include <stdbool.h>
+#include <time.h>
+
+#endif /* _MUTT_HEADER_H */
#include "buffy.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_thread.h"
#include "mutt_thread.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "options.h"
#include "protos.h"
#include "sort.h"
#include "filter.h"
#include "format_flags.h"
#include "globals.h"
-#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_window.h"
#include "context.h"
#include "copy.h"
#include "globals.h"
-#include "header.h"
#include "keymap.h"
#include "mailbox.h"
#include "mutt_thread.h"
#include "cryptglue.h"
#include "globals.h"
#include "handler.h"
-#include "header.h"
#include "mutt_curses.h"
#include "ncrypt.h"
#include "options.h"
#include "format_flags.h"
#include "globals.h"
#include "handler.h"
-#include "header.h"
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "filter.h"
#include "globals.h"
#include "handler.h"
-#include "header.h"
#include "mutt_curses.h"
#include "ncrypt.h"
#include "options.h"
#include "format_flags.h"
#include "globals.h"
#include "handler.h"
-#include "header.h"
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "context.h"
#include "format_flags.h"
#include "globals.h"
-#include "header.h"
#include "mutt_account.h"
#include "mutt_curses.h"
#include "mutt_socket.h"
#include "bcache.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "mailbox.h"
#include "mutt_account.h"
#include "mutt_curses.h"
#include "context.h"
#include "format_flags.h"
#include "globals.h"
-#include "header.h"
#include "keymap.h"
#include "mailbox.h"
#include "mutt_attach.h"
#include "mutt/mutt.h"
#include "mutt.h"
#include "globals.h"
-#include "header.h"
#include "mailbox.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "globals.h"
#include "group.h"
#include "handler.h"
-#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
hcache/qdbm.c
hcache/tc.c
hdrline.c
-header.c
help.c
history.c
hook.c
mutt/exit.c
mutt/file.c
mutt/hash.c
+mutt/header.c
mutt/idna.c
mutt/list.c
mutt/logging.c
mutt_account.c
mutt_attach.c
mutt_body.c
+mutt_header.c
mutt_logging.c
mutt_lua.c
mutt_notmuch.c
status.c
system.c
terminal.c
-thread.c
url.c
version.c
wcscasecmp.c
#include "bcache.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "mailbox.h"
#include "mutt_account.h"
#include "mutt_curses.h"
#include "mutt.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "mutt_account.h"
#include "mutt_curses.h"
#include "mutt_socket.h"
#include "format_flags.h"
#include "globals.h"
#include "handler.h"
-#include "header.h"
#include "keymap.h"
#include "mailbox.h"
#include "mutt_menu.h"
#include "filter.h"
#include "format_flags.h"
#include "globals.h"
-#include "header.h"
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "format_flags.h"
#include "globals.h"
#include "handler.h"
-#include "header.h"
#include "keymap.h"
#include "mailbox.h"
#include "mutt_attach.h"
#include "copy.h"
#include "globals.h"
#include "handler.h"
-#include "header.h"
#include "mutt_body.h"
#include "mutt_curses.h"
#include "mutt_window.h"
#include "format_flags.h"
#include "globals.h"
#include "handler.h"
-#include "header.h"
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include <unistd.h>
#include "mutt/mutt.h"
#include "globals.h"
-#include "header.h"
#include "mutt_curses.h"
#include "mutt_window.h"
#include "options.h"
#include "mutt.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "keymap.h"
#include "mutt_menu.h"
#include "options.h"
#include "copy.h"
#include "filter.h"
#include "globals.h"
-#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "ncrypt/ncrypt.h"
#include "format_flags.h"
#include "globals.h"
#include "handler.h"
-#include "header.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_window.h"
#include "sort.h"
#include "context.h"
#include "globals.h"
-#include "header.h"
#include "mutt_thread.h"
#include "options.h"
#include "protos.h"