struct Pattern *limit_pattern; /**< compiled limit pattern */
struct Header *last_tag; /**< last tagged msg. used to link threads */
struct MuttThread *tree; /**< top of thread tree */
- struct Hash *id_hash; /**< hash table by msg id */
- struct Hash *subj_hash; /**< hash table by subject */
struct Hash *thread_hash; /**< hash table for threading */
- struct Hash *label_hash; /**< hash table for x-labels */
int *v2r; /**< mapping from virtual to real msgno */
int vcount; /**< the number of virtual messages */
int tagged; /**< how many messages are tagged? */
mutt_str_strfcpy(buf, STAILQ_FIRST(&CURHDR->env->references)->data,
sizeof(buf));
}
- if (!Context->id_hash)
- Context->id_hash = mutt_make_id_hash(Context);
- hdr = mutt_hash_find(Context->id_hash, buf);
+ if (!Context->mailbox->id_hash)
+ Context->mailbox->id_hash = mutt_make_id_hash(Context);
+ hdr = mutt_hash_find(Context->mailbox->id_hash, buf);
if (hdr)
{
if (hdr->virtual != -1)
}
mutt_message(_("Fetching message headers..."));
- if (!Context->id_hash)
- Context->id_hash = mutt_make_id_hash(Context);
+ if (!Context->mailbox->id_hash)
+ Context->mailbox->id_hash = mutt_make_id_hash(Context);
mutt_str_strfcpy(buf, CURHDR->env->message_id, sizeof(buf));
/* trying to find msgid of the root message */
struct ListNode *ref = NULL;
STAILQ_FOREACH(ref, &CURHDR->env->references, entries)
{
- if (!mutt_hash_find(Context->id_hash, ref->data))
+ if (!mutt_hash_find(Context->mailbox->id_hash, ref->data))
{
rc2 = nntp_check_msgid(Context, ref->data);
if (rc2 < 0)
}
/* if the root message was retrieved, move to it */
- hdr = mutt_hash_find(Context->id_hash, buf);
+ hdr = mutt_hash_find(Context->mailbox->id_hash, buf);
if (hdr)
menu->current = hdr->virtual;
char *pt = buf;
int spaces; /* keep track of the number of leading spaces on the line */
- if (!Context || !Context->label_hash)
+ if (!Context || !Context->mailbox->label_hash)
return 0;
SKIPWS(buf);
mutt_str_strfcpy(UserTyped, buf, sizeof(UserTyped));
memset(Matches, 0, MatchesListsize);
memset(Completed, 0, sizeof(Completed));
- while ((entry = mutt_hash_walk(Context->label_hash, &state)))
+ while ((entry = mutt_hash_walk(Context->mailbox->label_hash, &state)))
candidate(UserTyped, entry->key.strkey, Completed, sizeof(Completed));
matches_ensure_morespace(NumMatched);
qsort(Matches, NumMatched, sizeof(char *), (sort_t *) mutt_str_strcasecmp);
void *compress_info; /**< compressed mbox module private data */
#endif
+ struct Hash *id_hash; /**< hash table by msg id */
+ struct Hash *subj_hash; /**< hash table by subject */
+ struct Hash *label_hash; /**< hash table for x-labels */
+
int flags; /**< e.g. #MB_NORMAL */
};
old_msgcount = 0;
/* simulate a close */
- mutt_hash_destroy(&ctx->id_hash);
- mutt_hash_destroy(&ctx->subj_hash);
- mutt_hash_destroy(&ctx->label_hash);
+ mutt_hash_destroy(&ctx->mailbox->id_hash);
+ mutt_hash_destroy(&ctx->mailbox->subj_hash);
+ mutt_hash_destroy(&ctx->mailbox->label_hash);
mutt_clear_threads(ctx);
FREE(&ctx->v2r);
if (ctx->mailbox->readonly)
ctx->mailbox->msg_unread = 0;
ctx->mailbox->msg_flagged = 0;
ctx->mailbox->changed = false;
- ctx->id_hash = NULL;
- ctx->subj_hash = NULL;
+ ctx->mailbox->id_hash = NULL;
+ ctx->mailbox->subj_hash = NULL;
mutt_make_label_hash(ctx);
switch (ctx->mailbox->magic)
*/
static void label_ref_dec(struct Context *ctx, char *label)
{
- struct HashElem *elem = mutt_hash_find_elem(ctx->label_hash, label);
+ struct HashElem *elem = mutt_hash_find_elem(ctx->mailbox->label_hash, label);
if (!elem)
return;
uintptr_t count = (uintptr_t) elem->data;
if (count <= 1)
{
- mutt_hash_delete(ctx->label_hash, label, NULL);
+ mutt_hash_delete(ctx->mailbox->label_hash, label, NULL);
return;
}
{
uintptr_t count;
- struct HashElem *elem = mutt_hash_find_elem(ctx->label_hash, label);
+ struct HashElem *elem = mutt_hash_find_elem(ctx->mailbox->label_hash, label);
if (!elem)
{
count = 1;
- mutt_hash_insert(ctx->label_hash, label, (void *) count);
+ mutt_hash_insert(ctx->mailbox->label_hash, label, (void *) count);
return;
}
char buf[LONG_STRING], *new = NULL;
int changed;
- if (!Context || !Context->label_hash)
+ if (!Context || !Context->mailbox->label_hash)
return 0;
*buf = '\0';
/* 131 is just a rough prime estimate of how many distinct
* labels someone might have in a mailbox.
*/
- ctx->label_hash = mutt_hash_create(131, MUTT_HASH_STRDUP_KEYS);
+ ctx->mailbox->label_hash = mutt_hash_create(131, MUTT_HASH_STRDUP_KEYS);
}
/**
*/
void mutt_label_hash_add(struct Context *ctx, struct Header *hdr)
{
- if (!ctx || !ctx->label_hash)
+ if (!ctx || !ctx->mailbox->label_hash)
return;
if (hdr->env->x_label)
label_ref_inc(ctx, hdr->env->x_label);
*/
void mutt_label_hash_remove(struct Context *ctx, struct Header *hdr)
{
- if (!ctx || !ctx->label_hash)
+ if (!ctx || !ctx->mailbox->label_hash)
return;
if (hdr->env->x_label)
label_ref_dec(ctx, hdr->env->x_label);
struct ListNode *np = NULL;
STAILQ_FOREACH(np, &subjects, entries)
{
- for (ptr = mutt_hash_find_bucket(ctx->subj_hash, np->data); ptr; ptr = ptr->next)
+ for (ptr = mutt_hash_find_bucket(ctx->mailbox->subj_hash, np->data); ptr; ptr = ptr->next)
{
tmp = ((struct Header *) ptr->data)->thread;
if (tmp != cur && /* don't match the same message */
struct MuttThread *tmp = NULL, *cur = NULL, *parent = NULL, *curchild = NULL,
*nextchild = NULL;
- if (!ctx->subj_hash)
- ctx->subj_hash = make_subj_hash(ctx);
+ if (!ctx->mailbox->subj_hash)
+ ctx->mailbox->subj_hash = make_subj_hash(ctx);
while (tree)
{
if (ctx->mailbox->mx_ops)
ctx->mailbox->mx_ops->mbox_close(ctx);
- mutt_hash_destroy(&ctx->subj_hash);
- mutt_hash_destroy(&ctx->id_hash);
- mutt_hash_destroy(&ctx->label_hash);
+ mutt_hash_destroy(&ctx->mailbox->subj_hash);
+ mutt_hash_destroy(&ctx->mailbox->id_hash);
+ mutt_hash_destroy(&ctx->mailbox->label_hash);
mutt_clear_threads(ctx);
for (int i = 0; i < ctx->mailbox->msg_count; i++)
mutt_header_free(&ctx->mailbox->hdrs[i]);
ctx->mailbox->hdrs[i]->content->hdr_offset);
}
/* remove message from the hash tables */
- if (ctx->subj_hash && ctx->mailbox->hdrs[i]->env->real_subj)
- mutt_hash_delete(ctx->subj_hash, ctx->mailbox->hdrs[i]->env->real_subj,
+ if (ctx->mailbox->subj_hash && ctx->mailbox->hdrs[i]->env->real_subj)
+ mutt_hash_delete(ctx->mailbox->subj_hash, ctx->mailbox->hdrs[i]->env->real_subj,
ctx->mailbox->hdrs[i]);
- if (ctx->id_hash && ctx->mailbox->hdrs[i]->env->message_id)
- mutt_hash_delete(ctx->id_hash, ctx->mailbox->hdrs[i]->env->message_id,
+ if (ctx->mailbox->id_hash && ctx->mailbox->hdrs[i]->env->message_id)
+ mutt_hash_delete(ctx->mailbox->id_hash, ctx->mailbox->hdrs[i]->env->message_id,
ctx->mailbox->hdrs[i]);
mutt_label_hash_remove(ctx, ctx->mailbox->hdrs[i]);
/* The path mx_mbox_check() -> imap_check_mailbox() ->
{
struct Header *h2 = NULL;
- if (!ctx->id_hash)
- ctx->id_hash = mutt_make_id_hash(ctx);
+ if (!ctx->mailbox->id_hash)
+ ctx->mailbox->id_hash = mutt_make_id_hash(ctx);
- h2 = mutt_hash_find(ctx->id_hash, h->env->supersedes);
+ h2 = mutt_hash_find(ctx->mailbox->id_hash, h->env->supersedes);
if (h2)
{
h2->superseded = true;
}
/* add this message to the hash tables */
- if (ctx->id_hash && h->env->message_id)
- mutt_hash_insert(ctx->id_hash, h->env->message_id, h);
- if (ctx->subj_hash && h->env->real_subj)
- mutt_hash_insert(ctx->subj_hash, h->env->real_subj, h);
+ if (ctx->mailbox->id_hash && h->env->message_id)
+ mutt_hash_insert(ctx->mailbox->id_hash, h->env->message_id, h);
+ if (ctx->mailbox->subj_hash && h->env->real_subj)
+ mutt_hash_insert(ctx->mailbox->subj_hash, h->env->real_subj, h);
mutt_label_hash_add(ctx, h);
if (Score)
/* replace envelope with new one
* hash elements must be updated because pointers will be changed */
- if (ctx->id_hash && hdr->env->message_id)
- mutt_hash_delete(ctx->id_hash, hdr->env->message_id, hdr);
- if (ctx->subj_hash && hdr->env->real_subj)
- mutt_hash_delete(ctx->subj_hash, hdr->env->real_subj, hdr);
+ if (ctx->mailbox->id_hash && hdr->env->message_id)
+ mutt_hash_delete(ctx->mailbox->id_hash, hdr->env->message_id, hdr);
+ if (ctx->mailbox->subj_hash && hdr->env->real_subj)
+ mutt_hash_delete(ctx->mailbox->subj_hash, hdr->env->real_subj, hdr);
mutt_env_free(&hdr->env);
hdr->env = mutt_rfc822_read_header(msg->fp, hdr, false, false);
- if (ctx->id_hash && hdr->env->message_id)
- mutt_hash_insert(ctx->id_hash, hdr->env->message_id, hdr);
- if (ctx->subj_hash && hdr->env->real_subj)
- mutt_hash_insert(ctx->subj_hash, hdr->env->real_subj, hdr);
+ if (ctx->mailbox->id_hash && hdr->env->message_id)
+ mutt_hash_insert(ctx->mailbox->id_hash, hdr->env->message_id, hdr);
+ if (ctx->mailbox->subj_hash && hdr->env->real_subj)
+ mutt_hash_insert(ctx->mailbox->subj_hash, hdr->env->real_subj, hdr);
/* fix content length */
fseek(msg->fp, 0, SEEK_END);
/* some headers were removed, context must be updated */
if (ret == MUTT_REOPENED)
{
- if (ctx->subj_hash)
- mutt_hash_destroy(&ctx->subj_hash);
- if (ctx->id_hash)
- mutt_hash_destroy(&ctx->id_hash);
+ if (ctx->mailbox->subj_hash)
+ mutt_hash_destroy(&ctx->mailbox->subj_hash);
+ if (ctx->mailbox->id_hash)
+ mutt_hash_destroy(&ctx->mailbox->id_hash);
mutt_clear_threads(ctx);
ctx->vcount = 0;
ctx->mailbox->msg_unread = 0;
ctx->mailbox->msg_flagged = 0;
ctx->mailbox->changed = false;
- ctx->id_hash = NULL;
- ctx->subj_hash = NULL;
+ ctx->mailbox->id_hash = NULL;
+ ctx->mailbox->subj_hash = NULL;
mx_update_context(ctx, ctx->mailbox->msg_count);
}
mutt_debug(2, "nm: neomutt header, id='%s'\n", id);
- if (!ctx->id_hash)
+ if (!ctx->mailbox->id_hash)
{
mutt_debug(2, "nm: init hash\n");
- ctx->id_hash = mutt_make_id_hash(ctx);
- if (!ctx->id_hash)
+ ctx->mailbox->id_hash = mutt_make_id_hash(ctx);
+ if (!ctx->mailbox->id_hash)
return NULL;
}
mid = nm2mutt_message_id(id);
mutt_debug(2, "nm: neomutt id='%s'\n", mid);
- h = mutt_hash_find(ctx->id_hash, mid);
+ h = mutt_hash_find(ctx->mailbox->id_hash, mid);
FREE(&mid);
return h;
}
uidl = h->data;
/* we replace envelop, key in subj_hash has to be updated as well */
- if (ctx->subj_hash && h->env->real_subj)
- mutt_hash_delete(ctx->subj_hash, h->env->real_subj, h);
+ if (ctx->mailbox->subj_hash && h->env->real_subj)
+ mutt_hash_delete(ctx->mailbox->subj_hash, h->env->real_subj, h);
mutt_label_hash_remove(ctx, h);
mutt_env_free(&h->env);
h->env = mutt_rfc822_read_header(msg->fp, h, false, false);
- if (ctx->subj_hash && h->env->real_subj)
- mutt_hash_insert(ctx->subj_hash, h->env->real_subj, h);
+ if (ctx->mailbox->subj_hash && h->env->real_subj)
+ mutt_hash_insert(ctx->mailbox->subj_hash, h->env->real_subj, h);
mutt_label_hash_add(ctx, h);
h->data = uidl;
/* if a mailbox is currently open, look to see if the original message
the user attempted to reply to is in this mailbox */
p = mutt_str_skip_email_wsp(np->data + 18);
- if (!ctx->id_hash)
- ctx->id_hash = mutt_make_id_hash(ctx);
- *cur = mutt_hash_find(ctx->id_hash, p);
+ if (!ctx->mailbox->id_hash)
+ ctx->mailbox->id_hash = mutt_make_id_hash(ctx);
+ *cur = mutt_hash_find(ctx->mailbox->id_hash, p);
}
if (*cur)
code |= SEND_REPLY;