From: Richard Russon Date: Thu, 30 Aug 2018 15:54:58 +0000 (+0100) Subject: move msgcount X-Git-Tag: 2019-10-25~664^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02fc2d369a1ae8d04eb2a31d42a3c262651ed596;p=neomutt move msgcount --- diff --git a/browser.c b/browser.c index f4989c1b0..90b69893d 100644 --- a/browser.c +++ b/browser.c @@ -887,7 +887,7 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state, if (np && Context && (mutt_str_strcmp(np->b->realpath, Context->mailbox->realpath) == 0)) { - np->b->msg_count = Context->msgcount; + np->b->msg_count = Context->mailbox->msg_count; np->b->msg_unread = Context->unread; } add_folder(menu, state, de->d_name, NULL, &s, np ? np->b : NULL, NULL); @@ -973,7 +973,7 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state) { if (Context && (mutt_str_strcmp(np->b->realpath, Context->mailbox->realpath) == 0)) { - np->b->msg_count = Context->msgcount; + np->b->msg_count = Context->mailbox->msg_count; np->b->msg_unread = Context->unread; } diff --git a/color.c b/color.c index 0ee914570..ed141a1bf 100644 --- a/color.c +++ b/color.c @@ -33,6 +33,7 @@ #include "context.h" #include "globals.h" #include "keymap.h" +#include "mailbox.h" #include "menu.h" #include "mutt_curses.h" #include "options.h" @@ -655,7 +656,7 @@ static int parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long dat { mutt_menu_set_redraw_full(MENU_MAIN); /* force re-caching of index colors */ - for (int i = 0; Context && i < Context->msgcount; i++) + for (int i = 0; Context && i < Context->mailbox->msg_count; i++) Context->hdrs[i]->pair = 0; } return 0; @@ -798,7 +799,7 @@ static int add_pattern(struct ColorLineHead *top, const char *s, bool sensitive, /* force re-caching of index colors */ if (is_index) { - for (int i = 0; Context && i < Context->msgcount; i++) + for (int i = 0; Context && i < Context->mailbox->msg_count; i++) Context->hdrs[i]->pair = 0; } diff --git a/commands.c b/commands.c index 5424eaa87..5c4277c25 100644 --- a/commands.c +++ b/commands.c @@ -302,7 +302,7 @@ void ci_bounce_message(struct Header *h) else if (Context) { msgcount = 0; // count the precise number of messages. - for (rc = 0; rc < Context->msgcount; rc++) + for (rc = 0; rc < Context->mailbox->msg_count; rc++) { if (message_is_tagged(Context, rc) && !Context->hdrs[rc]->env->from) { @@ -479,7 +479,7 @@ static int pipe_message(struct Header *h, char *cmd, bool decode, bool print, /* handle tagged messages */ if ((WithCrypto != 0) && decode) { - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) { if (!message_is_tagged(Context, i)) continue; @@ -496,7 +496,7 @@ static int pipe_message(struct Header *h, char *cmd, bool decode, bool print, if (split) { - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) { if (!message_is_tagged(Context, i)) continue; @@ -530,7 +530,7 @@ static int pipe_message(struct Header *h, char *cmd, bool decode, bool print, return 1; } OptKeepQuiet = true; - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) { if (!message_is_tagged(Context, i)) continue; @@ -585,7 +585,7 @@ void mutt_print_message(struct Header *h) else if (Context) { msgcount = 0; // count the precise number of messages. - for (i = 0; i < Context->msgcount; i++) + for (i = 0; i < Context->mailbox->msg_count; i++) if (message_is_tagged(Context, i)) msgcount++; } @@ -911,7 +911,7 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt) else { /* look for the first tagged message */ - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) { if (message_is_tagged(Context, i)) { @@ -1028,7 +1028,7 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt) if (Context->magic == MUTT_NOTMUCH) nm_longrun_init(Context, true); #endif - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) { if (!message_is_tagged(Context, i)) continue; @@ -1224,7 +1224,7 @@ bool mutt_check_traditional_pgp(struct Header *h, int *redraw) rc = check_traditional_pgp(h, redraw); else { - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) { if (message_is_tagged(Context, i) && !(Context->hdrs[i]->security & PGP_TRADITIONAL_CHECKED)) { diff --git a/compose.c b/compose.c index fd17d8a35..bbe63b0a2 100644 --- a/compose.c +++ b/compose.c @@ -1460,7 +1460,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, break; } - if (!ctx->msgcount) + if (!ctx->mailbox->msg_count) { mx_mbox_close(&ctx, NULL); mutt_error(_("No messages in that folder")); @@ -1488,7 +1488,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, break; } - for (i = 0; i < Context->msgcount; i++) + for (i = 0; i < Context->mailbox->msg_count; i++) { if (!message_is_tagged(Context, i)) continue; diff --git a/context.h b/context.h index 4be460ff4..284c52eb9 100644 --- a/context.h +++ b/context.h @@ -69,7 +69,6 @@ struct Context struct Hash *label_hash; /**< hash table for x-labels */ int *v2r; /**< mapping from virtual to real msgno */ int hdrmax; /**< number of pointers in hdrs */ - int msgcount; /**< number of messages in the mailbox */ int vcount; /**< the number of virtual messages */ int tagged; /**< how many messages are tagged? */ int new; /**< how many new messages? */ diff --git a/curs_lib.c b/curs_lib.c index dd1409dc1..3fe2ae0f9 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -45,6 +45,7 @@ #include "context.h" #include "enter_state.h" #include "globals.h" +#include "mailbox.h" #include "menu.h" #include "mutt_curses.h" #include "mutt_logging.h" @@ -1219,7 +1220,7 @@ int mutt_strwidth(const char *s) */ bool message_is_visible(struct Context *ctx, int index) { - if (!ctx || !ctx->hdrs || (index >= ctx->msgcount)) + if (!ctx || !ctx->hdrs || (index >= ctx->mailbox->msg_count)) return false; return !ctx->pattern || ctx->hdrs[index]->limited; diff --git a/curs_main.c b/curs_main.c index 4b7df8a6d..5cc9507ca 100644 --- a/curs_main.c +++ b/curs_main.c @@ -121,7 +121,7 @@ static const char *NoVisible = N_("No visible messages"); mutt_error(_(No_mailbox_is_open)); \ break; \ } \ - else if (!Context->msgcount) \ + else if (!Context->mailbox->msg_count) \ { \ mutt_flushinp(); \ mutt_error(_(There_are_no_messages)); \ @@ -185,7 +185,7 @@ static void collapse_all(struct Menu *menu, int toggle) struct MuttThread *thread = NULL, *top = NULL; int final; - if (!Context || (Context->msgcount == 0)) + if (!Context || (Context->mailbox->msg_count == 0)) return; /* Figure out what the current message would be after folding / unfolding, @@ -269,7 +269,7 @@ static int ci_previous_undeleted(int msgno) */ static int ci_first_message(void) { - if (!Context || !Context->msgcount) + if (!Context || !Context->mailbox->msg_count) return 0; int old = -1; @@ -379,8 +379,8 @@ static void update_index_threaded(struct Context *ctx, int check, int oldcount) /* save the list of new messages */ if ((check != MUTT_REOPENED) && oldcount && (ctx->pattern || UncollapseNew)) { - save_new = mutt_mem_malloc(sizeof(struct Header *) * (ctx->msgcount - oldcount)); - for (int i = oldcount; i < ctx->msgcount; i++) + save_new = mutt_mem_malloc(sizeof(struct Header *) * (ctx->mailbox->msg_count - oldcount)); + for (int i = oldcount; i < ctx->mailbox->msg_count; i++) save_new[i - oldcount] = ctx->hdrs[i]; } @@ -392,7 +392,7 @@ static void update_index_threaded(struct Context *ctx, int check, int oldcount) if (ctx->pattern) { - for (int i = (check == MUTT_REOPENED) ? 0 : oldcount; i < ctx->msgcount; i++) + for (int i = (check == MUTT_REOPENED) ? 0 : oldcount; i < ctx->mailbox->msg_count; i++) { struct Header *h = NULL; @@ -431,7 +431,7 @@ static void update_index_threaded(struct Context *ctx, int check, int oldcount) } else if (oldcount) { - for (int j = 0; j < (ctx->msgcount - oldcount); j++) + for (int j = 0; j < (ctx->mailbox->msg_count - oldcount); j++) { if (!ctx->pattern || save_new[j]->limited) { @@ -459,7 +459,7 @@ static void update_index_unthreaded(struct Context *ctx, int check, int oldcount if (ctx->pattern) { int padding = mx_msg_padding_size(ctx); - for (int i = (check == MUTT_REOPENED) ? 0 : oldcount; i < ctx->msgcount; i++) + for (int i = (check == MUTT_REOPENED) ? 0 : oldcount; i < ctx->mailbox->msg_count; i++) { if (!i) { @@ -470,7 +470,7 @@ static void update_index_unthreaded(struct Context *ctx, int check, int oldcount if (mutt_pattern_exec(ctx->limit_pattern, MUTT_MATCH_FULL_ADDRESS, ctx, ctx->hdrs[i], NULL)) { - assert(ctx->vcount < ctx->msgcount); + assert(ctx->vcount < ctx->mailbox->msg_count); ctx->hdrs[i]->virtual = ctx->vcount; ctx->v2r[ctx->vcount] = i; ctx->hdrs[i]->limited = true; @@ -577,7 +577,7 @@ static int main_change_folder(struct Menu *menu, int op, char *buf, else #endif new_last_folder = mutt_str_strdup(Context->mailbox->path); - *oldcount = Context ? Context->msgcount : 0; + *oldcount = Context ? Context->mailbox->msg_count : 0; int check = mx_mbox_close(&Context, index_hint); if (check != 0) @@ -1019,13 +1019,13 @@ int mutt_index_menu(void) * any 'op' below could do mutt_enter_command(), either here or * from any new menu launched, and change $sort/$sort_aux */ - if (OptNeedResort && Context && Context->msgcount && menu->current >= 0) + if (OptNeedResort && Context && Context->mailbox->msg_count && menu->current >= 0) resort_index(menu); menu->max = Context ? Context->vcount : 0; - oldcount = Context ? Context->msgcount : 0; + oldcount = Context ? Context->mailbox->msg_count : 0; - if (OptRedrawTree && Context && Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS) + if (OptRedrawTree && Context && Context->mailbox->msg_count && (Sort & SORT_MASK) == SORT_THREADS) { mutt_draw_tree(Context); menu->redraw |= REDRAW_STATUS; @@ -1070,7 +1070,7 @@ int mutt_index_menu(void) } else if (check == MUTT_NEW_MAIL) { - for (i = oldcount; i < Context->msgcount; i++) + for (i = oldcount; i < Context->mailbox->msg_count; i++) { if (!Context->hdrs[i]->read) { @@ -1358,7 +1358,7 @@ int mutt_index_menu(void) rc2 = nntp_check_msgid(Context, buf); if (rc2 == 0) { - hdr = Context->hdrs[Context->msgcount - 1]; + hdr = Context->hdrs[Context->mailbox->msg_count - 1]; mutt_sort_headers(Context, false); menu->current = hdr->virtual; menu->redraw = REDRAW_FULL; @@ -1377,7 +1377,7 @@ int mutt_index_menu(void) CHECK_ATTACH; if (Context->magic == MUTT_NNTP) { - int oldmsgcount = Context->msgcount; + int oldmsgcount = Context->mailbox->msg_count; int oldindex = CURHDR->index; int rc2 = 0; @@ -1416,7 +1416,7 @@ int mutt_index_menu(void) rc2 = nntp_check_children(Context, buf); /* at least one message has been loaded */ - if (Context->msgcount > oldmsgcount) + if (Context->mailbox->msg_count > oldmsgcount) { struct Header *oldcur = CURHDR; struct Header *hdr = NULL; @@ -1445,7 +1445,7 @@ int mutt_index_menu(void) /* try to restore old position */ else { - for (int k = 0; k < Context->msgcount; k++) + for (int k = 0; k < Context->mailbox->msg_count; k++) { if (Context->hdrs[k]->index == oldindex) { @@ -1488,7 +1488,7 @@ int mutt_index_menu(void) } else if (mutt_str_atoi(buf, &i) < 0) mutt_error(_("Argument must be a message number")); - else if ((i < 1) || (i > Context->msgcount)) + else if ((i < 1) || (i > Context->mailbox->msg_count)) mutt_error(_("Invalid message number")); else if (!message_is_visible(Context, i - 1)) mutt_error(_("That message is not visible")); @@ -1634,7 +1634,7 @@ int mutt_index_menu(void) } else menu->current = 0; - if (Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS) + if (Context->mailbox->msg_count && (Sort & SORT_MASK) == SORT_THREADS) mutt_draw_tree(Context); menu->redraw = REDRAW_FULL; } @@ -1655,7 +1655,7 @@ int mutt_index_menu(void) { int check; - oldcount = Context ? Context->msgcount : 0; + oldcount = Context ? Context->mailbox->msg_count : 0; mutt_startup_shutdown_hook(MUTT_SHUTDOWN_HOOK); @@ -1697,7 +1697,7 @@ int mutt_index_menu(void) if (mutt_select_sort((op == OP_SORT_REVERSE)) == 0) { - if (Context && Context->msgcount) + if (Context && Context->mailbox->msg_count) { resort_index(menu); OptSearchInvalid = true; @@ -1717,7 +1717,7 @@ int mutt_index_menu(void) CHECK_VISIBLE; if (tag && !AutoTag) { - for (j = 0; j < Context->msgcount; j++) + for (j = 0; j < Context->mailbox->msg_count; j++) if (message_is_visible(Context, j)) mutt_set_flag(Context, Context->hdrs[j], MUTT_TAG, 0); menu->redraw |= REDRAW_STATUS | REDRAW_INDEX; @@ -1818,14 +1818,14 @@ int mutt_index_menu(void) case OP_MAIN_SYNC_FOLDER: - if (Context && !Context->msgcount) + if (Context && !Context->mailbox->msg_count) break; CHECK_MSGCOUNT; CHECK_READONLY; { int ovc = Context->vcount; - int oc = Context->msgcount; + int oc = Context->mailbox->msg_count; int check; struct Header *newhdr = NULL; @@ -1887,7 +1887,7 @@ int mutt_index_menu(void) CHECK_VISIBLE; if (tag) { - for (j = 0; j < Context->msgcount; j++) + for (j = 0; j < Context->mailbox->msg_count; j++) { if (message_is_tagged(Context, j)) { @@ -1913,13 +1913,13 @@ int mutt_index_menu(void) } CHECK_MSGCOUNT; CHECK_VISIBLE; - int oc = Context->msgcount; + int oc = Context->mailbox->msg_count; if (nm_read_entire_thread(Context, CURHDR) < 0) { mutt_message(_("Failed to read thread, aborting")); break; } - if (oc < Context->msgcount) + if (oc < Context->mailbox->msg_count) { struct Header *oldcur = CURHDR; @@ -1983,7 +1983,7 @@ int mutt_index_menu(void) if (Context->magic == MUTT_NOTMUCH) nm_longrun_init(Context, true); #endif - for (px = 0, j = 0; j < Context->msgcount; j++) + for (px = 0, j = 0; j < Context->mailbox->msg_count; j++) { if (!message_is_tagged(Context, j)) continue; @@ -2285,7 +2285,7 @@ int mutt_index_menu(void) menu->menu = MENU_PAGER; menu->oldcurrent = menu->current; if (Context) - update_index(menu, Context, MUTT_NEW_MAIL, Context->msgcount, hint); + update_index(menu, Context, MUTT_NEW_MAIL, Context->mailbox->msg_count, hint); continue; @@ -2657,7 +2657,7 @@ int mutt_index_menu(void) if (tag) { - for (j = 0; j < Context->msgcount; j++) + for (j = 0; j < Context->mailbox->msg_count; j++) { if (message_is_tagged(Context, j)) { @@ -2698,7 +2698,7 @@ int mutt_index_menu(void) if (tag) { - for (j = 0; j < Context->msgcount; j++) + for (j = 0; j < Context->mailbox->msg_count; j++) { if (!message_is_tagged(Context, j)) continue; @@ -3274,7 +3274,7 @@ int mutt_index_menu(void) if (tag) { - for (j = 0; j < Context->msgcount; j++) + for (j = 0; j < Context->mailbox->msg_count; j++) { if (message_is_tagged(Context, j)) mutt_resend_message(NULL, Context, Context->hdrs[j]); @@ -3531,7 +3531,7 @@ bool mutt_reply_listener(const struct ConfigSet *cs, struct HashElem *he, regmatch_t pmatch[1]; - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) { struct Envelope *e = Context->hdrs[i]->env; if (!e || !e->subject) diff --git a/edit.c b/edit.c index f755456ef..edc2006fd 100644 --- a/edit.c +++ b/edit.c @@ -37,6 +37,7 @@ #include "curs_lib.h" #include "globals.h" #include "hdrline.h" +#include "mailbox.h" #include "mutt_curses.h" #include "mutt_header.h" #include "mutt_window.h" @@ -210,7 +211,7 @@ static char **be_include_messages(char *msg, char **buf, int *bufmax, while ((msg = strtok(msg, " ,"))) { - if (mutt_str_atoi(msg, &n) == 0 && n > 0 && n <= Context->msgcount) + if (mutt_str_atoi(msg, &n) == 0 && n > 0 && n <= Context->mailbox->msg_count) { n--; diff --git a/editmsg.c b/editmsg.c index d5b6df94a..88c07774b 100644 --- a/editmsg.c +++ b/editmsg.c @@ -272,7 +272,7 @@ int edit_or_view_message(bool edit, struct Context *ctx, struct Header *hdr) if (hdr) return edit_or_view_one_message(edit, ctx, hdr); - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { if (!message_is_tagged(ctx, i)) continue; diff --git a/flags.c b/flags.c index f90c1a370..ed360ad38 100644 --- a/flags.c +++ b/flags.c @@ -37,6 +37,7 @@ #include "curs_lib.h" #include "curs_main.h" #include "globals.h" +#include "mailbox.h" #include "menu.h" #include "mutt_curses.h" #include "mutt_window.h" @@ -353,7 +354,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Header *h, int flag, bool */ void mutt_tag_set_flag(int flag, int bf) { - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) if (message_is_tagged(Context, i)) mutt_set_flag(Context, Context->hdrs[i], flag, bf); } diff --git a/hdrline.c b/hdrline.c index d5fbeb7dd..399f3170b 100644 --- a/hdrline.c +++ b/hdrline.c @@ -992,7 +992,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co if (ctx) { snprintf(fmt, sizeof(fmt), "%%%sd", prec); - snprintf(buf, buflen, fmt, ctx->msgcount); + snprintf(buf, buflen, fmt, ctx->mailbox->msg_count); } else mutt_str_strfcpy(buf, "(null)", buflen); diff --git a/imap/browse.c b/imap/browse.c index 37ddeb312..107d25de3 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -124,7 +124,7 @@ static void add_folder(char delim, char *folder, bool noselect, bool noinferiors { if (Context && (mutt_str_strcmp(np->b->realpath, Context->mailbox->realpath) == 0)) { - np->b->msg_count = Context->msgcount; + np->b->msg_count = Context->mailbox->msg_count; np->b->msg_unread = Context->unread; } (state->entry)[state->entrylen].has_mailbox = true; diff --git a/imap/imap.c b/imap/imap.c index 8b51fd3d1..3dfdcd1f0 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -186,7 +186,7 @@ static int make_msg_set(struct ImapData *idata, struct Buffer *buf, int flag, bool started = false; struct Header **hdrs = idata->ctx->hdrs; - for (n = *pos; n < idata->ctx->msgcount && buf->dptr - buf->data < IMAP_MAX_CMDLEN; n++) + for (n = *pos; n < idata->ctx->mailbox->msg_count && buf->dptr - buf->data < IMAP_MAX_CMDLEN; n++) { bool match = false; /* whether current message matches flag condition */ /* don't include pending expunged messages */ @@ -240,12 +240,12 @@ static int make_msg_set(struct ImapData *idata, struct Buffer *buf, int flag, mutt_buffer_printf(buf, ",%u", HEADER_DATA(hdrs[n])->uid); } /* tie up if the last message also matches */ - else if (n == idata->ctx->msgcount - 1) + else if (n == idata->ctx->mailbox->msg_count - 1) mutt_buffer_printf(buf, ":%u", HEADER_DATA(hdrs[n])->uid); } /* End current set if message doesn't match or we've reached the end * of the mailbox via inactive messages following the last match. */ - else if (setstart && (hdrs[n]->active || n == idata->ctx->msgcount - 1)) + else if (setstart && (hdrs[n]->active || n == idata->ctx->mailbox->msg_count - 1)) { if (HEADER_DATA(hdrs[n - 1])->uid > setstart) mutt_buffer_printf(buf, ":%u", HEADER_DATA(hdrs[n - 1])->uid); @@ -843,7 +843,7 @@ void imap_expunge_mailbox(struct ImapData *idata) Sort = SORT_ORDER; mutt_sort_headers(idata->ctx, false); - for (int i = 0; i < idata->ctx->msgcount; i++) + for (int i = 0; i < idata->ctx->mailbox->msg_count; i++) { h = idata->ctx->hdrs[i]; @@ -1202,11 +1202,11 @@ int imap_exec_msgset(struct ImapData *idata, const char *pre, const char *post, if (Sort != SORT_ORDER) { hdrs = idata->ctx->hdrs; - idata->ctx->hdrs = mutt_mem_malloc(idata->ctx->msgcount * sizeof(struct Header *)); - memcpy(idata->ctx->hdrs, hdrs, idata->ctx->msgcount * sizeof(struct Header *)); + idata->ctx->hdrs = mutt_mem_malloc(idata->ctx->mailbox->msg_count * sizeof(struct Header *)); + memcpy(idata->ctx->hdrs, hdrs, idata->ctx->mailbox->msg_count * sizeof(struct Header *)); Sort = SORT_ORDER; - qsort(idata->ctx->hdrs, idata->ctx->msgcount, sizeof(struct Header *), + qsort(idata->ctx->hdrs, idata->ctx->mailbox->msg_count, sizeof(struct Header *), mutt_get_sort_func(SORT_ORDER)); } @@ -1556,7 +1556,7 @@ int imap_status(const char *path, bool queue) * Note that imap_mxcmp() converts NULL to "INBOX", so we need to * make sure the idata really is open to a folder. */ if (idata->ctx && !imap_mxcmp(buf, idata->mailbox)) - return idata->ctx->msgcount; + return idata->ctx->mailbox->msg_count; else if (mutt_bit_isset(idata->capabilities, IMAP4REV1) || mutt_bit_isset(idata->capabilities, STATUS)) { @@ -1684,7 +1684,7 @@ int imap_search(struct Context *ctx, const struct Pattern *pat) { struct Buffer buf; struct ImapData *idata = ctx->data; - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) ctx->hdrs[i]->matched = false; if (do_search(pat, 1) == 0) @@ -1913,7 +1913,7 @@ int imap_fast_trash(struct Context *ctx, char *dest) imap_munge_mbox_name(idata, mmbox, sizeof(mmbox), mbox); sync_cmd = mutt_buffer_new(); - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { if (ctx->hdrs[i]->active && ctx->hdrs[i]->changed && ctx->hdrs[i]->deleted && !ctx->hdrs[i]->purge) @@ -2215,7 +2215,7 @@ static int imap_mbox_open(struct Context *ctx) ctx->hdrmax = count; ctx->hdrs = mutt_mem_calloc(count, sizeof(struct Header *)); ctx->v2r = mutt_mem_calloc(count, sizeof(int)); - ctx->msgcount = 0; + ctx->mailbox->msg_count = 0; if (count && (imap_read_headers(idata, 1, count, true) < 0)) { @@ -2223,7 +2223,7 @@ static int imap_mbox_open(struct Context *ctx) goto fail; } - mutt_debug(2, "msgcount is %d\n", ctx->msgcount); + mutt_debug(2, "mailbox->msg_count is %d\n", ctx->mailbox->msg_count); FREE(&mx.mbox); return 0; @@ -2336,7 +2336,7 @@ static int imap_mbox_close(struct Context *ctx) } /* free IMAP part of headers */ - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { /* mailbox may not have fully loaded */ if (ctx->hdrs[i] && ctx->hdrs[i]->data) @@ -2429,7 +2429,7 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge) { /* mark these messages as unchanged so second pass ignores them. Done * here so BOGUS UW-IMAP 4.7 SILENT FLAGS updates are ignored. */ - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->changed) ctx->hdrs[i]->active = false; mutt_message(ngettext("Marking %d message deleted...", @@ -2443,7 +2443,7 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge) #endif /* save messages with real (non-flag) changes */ - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { h = ctx->hdrs[i]; @@ -2468,8 +2468,8 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge) { /* L10N: The plural is choosen by the last %d, i.e. the total number */ mutt_message(ngettext("Saving changed message... [%d/%d]", - "Saving changed messages... [%d/%d]", ctx->msgcount), - i + 1, ctx->msgcount); + "Saving changed messages... [%d/%d]", ctx->mailbox->msg_count), + i + 1, ctx->mailbox->msg_count); if (!appendctx) appendctx = mx_mbox_open(ctx->mailbox->path, MUTT_APPEND | MUTT_QUIET); if (!appendctx) @@ -2490,11 +2490,11 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge) if (Sort != SORT_ORDER) { hdrs = ctx->hdrs; - ctx->hdrs = mutt_mem_malloc(ctx->msgcount * sizeof(struct Header *)); - memcpy(ctx->hdrs, hdrs, ctx->msgcount * sizeof(struct Header *)); + ctx->hdrs = mutt_mem_malloc(ctx->mailbox->msg_count * sizeof(struct Header *)); + memcpy(ctx->hdrs, hdrs, ctx->mailbox->msg_count * sizeof(struct Header *)); Sort = SORT_ORDER; - qsort(ctx->hdrs, ctx->msgcount, sizeof(struct Header *), mutt_get_sort_func(SORT_ORDER)); + qsort(ctx->hdrs, ctx->mailbox->msg_count, sizeof(struct Header *), mutt_get_sort_func(SORT_ORDER)); } rc = sync_helper(idata, MUTT_ACL_DELETE, MUTT_DELETED, "\\Deleted"); @@ -2539,7 +2539,7 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge) /* Update local record of server state to reflect the synchronization just * completed. imap_read_headers always overwrites hcache-origin flags, so * there is no need to mutate the hcache after flag-only changes. */ - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { HEADER_DATA(ctx->hdrs[i])->deleted = ctx->hdrs[i]->deleted; HEADER_DATA(ctx->hdrs[i])->flagged = ctx->hdrs[i]->flagged; diff --git a/imap/message.c b/imap/message.c index 662fb1bd1..fdb7bc390 100644 --- a/imap/message.c +++ b/imap/message.c @@ -662,7 +662,7 @@ static int read_headers_normal_eval_cache(struct ImapData *idata, char buf[LONG_STRING]; struct Context *ctx = idata->ctx; - int idx = ctx->msgcount; + int idx = ctx->mailbox->msg_count; /* L10N: Comparing the cached data with the IMAP server's data */ @@ -752,7 +752,7 @@ static int read_headers_normal_eval_cache(struct ImapData *idata, STAILQ_INIT(&ctx->hdrs[idx]->tags); driver_tags_replace(&ctx->hdrs[idx]->tags, mutt_str_strdup(h.data->flags_remote)); - ctx->msgcount++; + ctx->mailbox->msg_count++; ctx->size += ctx->hdrs[idx]->content->length; /* If this is the first time we are fetching, we need to @@ -812,13 +812,13 @@ static int read_headers_qresync_eval_cache(struct ImapData *idata, char *uid_seq idata->max_msn = MAX(idata->max_msn, msn); idata->msn_index[msn - 1] = h; - if (ctx->msgcount >= ctx->hdrmax) + if (ctx->mailbox->msg_count >= ctx->hdrmax) mx_alloc_memory(ctx); struct ImapHeaderData *ihd = mutt_mem_calloc(1, sizeof(struct ImapHeaderData)); h->data = ihd; - h->index = ctx->msgcount; + h->index = ctx->mailbox->msg_count; h->active = true; h->changed = false; ihd->read = h->read; @@ -832,7 +832,7 @@ static int read_headers_qresync_eval_cache(struct ImapData *idata, char *uid_seq mutt_hash_int_insert(idata->uid_hash, uid, h); ctx->size += h->content->length; - ctx->hdrs[ctx->msgcount++] = h; + ctx->hdrs[ctx->mailbox->msg_count++] = h; msn++; } @@ -952,7 +952,7 @@ static int read_headers_fetch_new(struct ImapData *idata, unsigned int msn_begin "X-ORIGINAL-TO"; struct Context *ctx = idata->ctx; - int idx = ctx->msgcount; + int idx = ctx->mailbox->msg_count; if (mutt_bit_isset(idata->capabilities, IMAP4REV1)) { @@ -1090,7 +1090,7 @@ static int read_headers_fetch_new(struct ImapData *idata, unsigned int msn_begin imap_hcache_put(idata, ctx->hdrs[idx]); #endif /* USE_HCACHE */ - ctx->msgcount++; + ctx->mailbox->msg_count++; h.data = NULL; idx++; @@ -1174,7 +1174,7 @@ int imap_read_headers(struct ImapData *idata, unsigned int msn_begin, alloc_msn_index(idata, msn_end); imap_alloc_uid_hash(idata, msn_end); - oldmsgcount = ctx->msgcount; + oldmsgcount = ctx->mailbox->msg_count; idata->reopen &= ~(IMAP_REOPEN_ALLOW | IMAP_NEWMAIL_PENDING); idata->new_mail_count = 0; @@ -1306,12 +1306,12 @@ int imap_read_headers(struct ImapData *idata, unsigned int msn_begin, } #endif /* USE_HCACHE */ - if (ctx->msgcount > oldmsgcount) + if (ctx->mailbox->msg_count > oldmsgcount) { /* TODO: it's not clear to me why we are calling mx_alloc_memory * yet again. */ mx_alloc_memory(ctx); - mx_update_context(ctx, ctx->msgcount - oldmsgcount); + mx_update_context(ctx, ctx->mailbox->msg_count - oldmsgcount); } idata->reopen |= IMAP_REOPEN_ALLOW; @@ -1776,7 +1776,7 @@ int imap_copy_messages(struct Context *ctx, struct Header *h, char *dest, bool d /* if any messages have attachments to delete, fall through to FETCH * and APPEND. TODO: Copy what we can with COPY, fall through for the * remainder. */ - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { if (!message_is_tagged(ctx, i)) continue; @@ -1874,7 +1874,7 @@ int imap_copy_messages(struct Context *ctx, struct Header *h, char *dest, bool d { if (!h) { - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { if (!message_is_tagged(ctx, i)) continue; diff --git a/init.c b/init.c index 097aae2a1..c638c5b8a 100644 --- a/init.c +++ b/init.c @@ -132,7 +132,7 @@ static void alternates_clean(void) if (!Context) return; - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) Context->hdrs[i]->recip_valid = false; } @@ -144,7 +144,7 @@ static void attachments_clean(void) if (!Context) return; - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) Context->hdrs[i]->attach_valid = false; } @@ -204,7 +204,7 @@ static void clear_subject_mods(void) if (!Context) return; - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) FREE(&Context->hdrs[i]->env->disp_subj); } diff --git a/mailbox.c b/mailbox.c index 7eece184f..61bc8e871 100644 --- a/mailbox.c +++ b/mailbox.c @@ -373,7 +373,7 @@ static int mailbox_mbox_check(struct Mailbox *mailbox, struct stat *sb, bool che mx_mbox_open(mailbox->path, MUTT_READONLY | MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK); if (ctx) { - mailbox->msg_count = ctx->msgcount; + mailbox->msg_count = ctx->mailbox->msg_count; mailbox->msg_unread = ctx->unread; mailbox->msg_flagged = ctx->flagged; mailbox->stats_last_checked = ctx->mtime; diff --git a/maildir/mh.c b/maildir/mh.c index 07d77c281..d8d8b7eb9 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -587,7 +587,7 @@ static void mh_update_sequences(struct Context *ctx) mutt_file_fclose(&ofp); /* now, update our unseen, flagged, and replied sequences */ - for (l = 0; l < ctx->msgcount; l++) + for (l = 0; l < ctx->mailbox->msg_count; l++) { if (ctx->hdrs[l]->deleted) continue; @@ -1029,7 +1029,7 @@ static int maildir_parse_dir(struct Context *ctx, struct Maildir ***last, */ static bool maildir_add_to_context(struct Context *ctx, struct Maildir *md) { - int oldmsgcount = ctx->msgcount; + int oldmsgcount = ctx->mailbox->msg_count; while (md) { @@ -1040,23 +1040,23 @@ static bool maildir_add_to_context(struct Context *ctx, struct Maildir *md) mutt_debug(2, "Adding header structure. Flags: %s%s%s%s%s\n", md->h->flagged ? "f" : "", md->h->deleted ? "D" : "", md->h->replied ? "r" : "", md->h->old ? "O" : "", md->h->read ? "R" : ""); - if (ctx->msgcount == ctx->hdrmax) + if (ctx->mailbox->msg_count == ctx->hdrmax) mx_alloc_memory(ctx); - ctx->hdrs[ctx->msgcount] = md->h; - ctx->hdrs[ctx->msgcount]->index = ctx->msgcount; + ctx->hdrs[ctx->mailbox->msg_count] = md->h; + ctx->hdrs[ctx->mailbox->msg_count]->index = ctx->mailbox->msg_count; ctx->size += md->h->content->length + md->h->content->offset - md->h->content->hdr_offset; md->h = NULL; - ctx->msgcount++; + ctx->mailbox->msg_count++; } md = md->next; } - if (ctx->msgcount > oldmsgcount) + if (ctx->mailbox->msg_count > oldmsgcount) { - mx_update_context(ctx, ctx->msgcount - oldmsgcount); + mx_update_context(ctx, ctx->mailbox->msg_count - oldmsgcount); return true; } return false; @@ -2289,7 +2289,7 @@ static void maildir_update_tables(struct Context *ctx, int *index_hint) Sort = old_sort; } - const int old_count = ctx->msgcount; + const int old_count = ctx->mailbox->msg_count; for (int i = 0, j = 0; i < old_count; i++) { if (ctx->hdrs[i]->active && index_hint && *index_hint == i) @@ -2391,7 +2391,7 @@ static int maildir_mbox_check(struct Context *ctx, int *index_hint) } /* check for modifications and adjust flags */ - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { ctx->hdrs[i]->active = false; maildir_canon_filename(ctx->hdrs[i]->path, buf, sizeof(buf)); @@ -2568,7 +2568,7 @@ static int mh_mbox_check(struct Context *ctx, int *index_hint) mutt_hash_insert(fnames, p->canon_fname, p); } - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { ctx->hdrs[i]->active = false; @@ -2635,10 +2635,10 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint) if (!ctx->quiet) { snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->mailbox->path); - mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->msgcount); + mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->mailbox->msg_count); } - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { if (!ctx->quiet) mutt_progress_update(&progress, i, -1); @@ -2668,7 +2668,7 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint) if (ctx->deleted) { - for (i = 0, j = 0; i < ctx->msgcount; i++) + for (i = 0, j = 0; i < ctx->mailbox->msg_count; i++) { if (!ctx->hdrs[i]->deleted || (ctx->magic == MUTT_MAILDIR && MaildirTrash)) ctx->hdrs[i]->index = j++; diff --git a/mbox/mbox.c b/mbox/mbox.c index 12e6aa51b..8e8d938a0 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -116,7 +116,7 @@ static int mmdf_parse_mailbox(struct Context *ctx) { char buf[HUGE_STRING]; char return_path[LONG_STRING]; - int count = 0, oldmsgcount = ctx->msgcount; + int count = 0, oldmsgcount = ctx->mailbox->msg_count; int lines; time_t t; LOFF_T loc, tmploc; @@ -160,12 +160,12 @@ static int mmdf_parse_mailbox(struct Context *ctx) if (!ctx->quiet) mutt_progress_update(&progress, count, (int) (loc / (ctx->size / 100 + 1))); - if (ctx->msgcount == ctx->hdrmax) + if (ctx->mailbox->msg_count == ctx->hdrmax) mx_alloc_memory(ctx); hdr = mutt_header_new(); - ctx->hdrs[ctx->msgcount] = hdr; + ctx->hdrs[ctx->mailbox->msg_count] = hdr; hdr->offset = loc; - hdr->index = ctx->msgcount; + hdr->index = ctx->mailbox->msg_count; if (!fgets(buf, sizeof(buf) - 1, ctx->fp)) { @@ -238,7 +238,7 @@ static int mmdf_parse_mailbox(struct Context *ctx) if (!hdr->env->from) hdr->env->from = mutt_addr_copy_list(hdr->env->return_path, false); - ctx->msgcount++; + ctx->mailbox->msg_count++; } else { @@ -248,8 +248,8 @@ static int mmdf_parse_mailbox(struct Context *ctx) } } - if (ctx->msgcount > oldmsgcount) - mx_update_context(ctx, ctx->msgcount - oldmsgcount); + if (ctx->mailbox->msg_count > oldmsgcount) + mx_update_context(ctx, ctx->mailbox->msg_count - oldmsgcount); if (SigInt == 1) { @@ -312,7 +312,7 @@ static int mbox_parse_mailbox(struct Context *ctx) /* Save the Content-Length of the previous message */ if (count > 0) { - struct Header *h = ctx->hdrs[ctx->msgcount - 1]; + struct Header *h = ctx->hdrs[ctx->mailbox->msg_count - 1]; if (h->content->length < 0) { h->content->length = loc - h->content->offset - 1; @@ -331,14 +331,14 @@ static int mbox_parse_mailbox(struct Context *ctx) (int) (ftello(ctx->fp) / (ctx->size / 100 + 1))); } - if (ctx->msgcount == ctx->hdrmax) + if (ctx->mailbox->msg_count == ctx->hdrmax) mx_alloc_memory(ctx); - ctx->hdrs[ctx->msgcount] = mutt_header_new(); - curhdr = ctx->hdrs[ctx->msgcount]; + ctx->hdrs[ctx->mailbox->msg_count] = mutt_header_new(); + curhdr = ctx->hdrs[ctx->mailbox->msg_count]; curhdr->received = t - mutt_date_local_tz(t); curhdr->offset = loc; - curhdr->index = ctx->msgcount; + curhdr->index = ctx->mailbox->msg_count; curhdr->env = mutt_rfc822_read_header(ctx->fp, curhdr, false, false); @@ -411,7 +411,7 @@ static int mbox_parse_mailbox(struct Context *ctx) } } - ctx->msgcount++; + ctx->mailbox->msg_count++; if (!curhdr->env->return_path && return_path[0]) { @@ -437,7 +437,7 @@ static int mbox_parse_mailbox(struct Context *ctx) */ if (count > 0) { - struct Header *h = ctx->hdrs[ctx->msgcount - 1]; + struct Header *h = ctx->hdrs[ctx->mailbox->msg_count - 1]; if (h->content->length < 0) { h->content->length = ftello(ctx->fp) - h->content->offset - 1; @@ -671,20 +671,20 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint) FREE(&ctx->v2r); if (ctx->readonly) { - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) mutt_header_free(&(ctx->hdrs[i])); /* nothing to do! */ FREE(&ctx->hdrs); } else { /* save the old headers */ - old_msgcount = ctx->msgcount; + old_msgcount = ctx->mailbox->msg_count; old_hdrs = ctx->hdrs; ctx->hdrs = NULL; } ctx->hdrmax = 0; /* force allocation of new headers */ - ctx->msgcount = 0; + ctx->mailbox->msg_count = 0; ctx->vcount = 0; ctx->vsize = 0; ctx->tagged = 0; @@ -734,7 +734,7 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint) if (!ctx->readonly) { - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { bool found = false; @@ -935,7 +935,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint) */ static bool mbox_has_new(struct Context *ctx) { - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) if (!ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read && !ctx->hdrs[i]->old) return true; return false; @@ -1056,12 +1056,12 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint) /* find the first deleted/changed message. we save a lot of time by only * rewriting the mailbox from the point where it has actually changed. */ - for (i = 0; (i < ctx->msgcount) && !ctx->hdrs[i]->deleted && + for (i = 0; (i < ctx->mailbox->msg_count) && !ctx->hdrs[i]->deleted && !ctx->hdrs[i]->changed && !ctx->hdrs[i]->attach_del; i++) { } - if (i == ctx->msgcount) + if (i == ctx->mailbox->msg_count) { /* this means ctx->changed or ctx->deleted was set, but no * messages were found to be changed or deleted. This should @@ -1086,16 +1086,16 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint) offset -= (sizeof(MMDF_SEP) - 1); /* allocate space for the new offsets */ - new_offset = mutt_mem_calloc(ctx->msgcount - first, sizeof(struct MUpdate)); - old_offset = mutt_mem_calloc(ctx->msgcount - first, sizeof(struct MUpdate)); + new_offset = mutt_mem_calloc(ctx->mailbox->msg_count - first, sizeof(struct MUpdate)); + old_offset = mutt_mem_calloc(ctx->mailbox->msg_count - first, sizeof(struct MUpdate)); if (!ctx->quiet) { snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->mailbox->path); - mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->msgcount); + mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->mailbox->msg_count); } - for (i = first, j = 0; i < ctx->msgcount; i++) + for (i = first, j = 0; i < ctx->mailbox->msg_count; i++) { if (!ctx->quiet) mutt_progress_update(&progress, i, (int) (ftello(ctx->fp) / (ctx->size / 100 + 1))); @@ -1278,7 +1278,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint) } /* update the offsets of the rewritten messages */ - for (i = first, j = first; i < ctx->msgcount; i++) + for (i = first, j = first; i < ctx->mailbox->msg_count; i++) { if (!ctx->hdrs[i]->deleted) { @@ -1309,7 +1309,7 @@ bail: /* Come here in case of disaster */ /* restore offsets, as far as they are valid */ if (first >= 0 && old_offset) { - for (i = first; (i < ctx->msgcount) && old_offset[i - first].valid; i++) + for (i = first; (i < ctx->mailbox->msg_count) && old_offset[i - first].valid; i++) { ctx->hdrs[i]->offset = old_offset[i - first].hdr; ctx->hdrs[i]->content->hdr_offset = old_offset[i - first].hdr; diff --git a/mutt_header.c b/mutt_header.c index 4ab10c879..af3c31093 100644 --- a/mutt_header.c +++ b/mutt_header.c @@ -35,6 +35,7 @@ #include "curs_lib.h" #include "curs_main.h" #include "globals.h" +#include "mailbox.h" #include "muttlib.h" #include "ncrypt/ncrypt.h" #include "options.h" @@ -150,7 +151,7 @@ int mutt_label_message(struct Header *hdr) } else { - for (int i = 0; i < Context->msgcount; ++i) + for (int i = 0; i < Context->mailbox->msg_count; ++i) { if (!message_is_tagged(Context, i)) continue; diff --git a/mutt_thread.c b/mutt_thread.c index e83012488..841c15eb2 100644 --- a/mutt_thread.c +++ b/mutt_thread.c @@ -33,6 +33,7 @@ #include "mutt_thread.h" #include "context.h" #include "curs_lib.h" +#include "mailbox.h" #include "mx.h" #include "protos.h" #include "sort.h" @@ -117,7 +118,7 @@ bool need_display_subject(struct Context *ctx, struct Header *hdr) static void linearize_tree(struct Context *ctx) { struct MuttThread *tree = ctx->tree; - struct Header **array = ctx->hdrs + ((Sort & SORT_REVERSE) ? ctx->msgcount - 1 : 0); + struct Header **array = ctx->hdrs + ((Sort & SORT_REVERSE) ? ctx->mailbox->msg_count - 1 : 0); while (tree) { @@ -489,9 +490,9 @@ static struct MuttThread *find_subject(struct Context *ctx, struct MuttThread *c */ static struct Hash *make_subj_hash(struct Context *ctx) { - struct Hash *hash = mutt_hash_create(ctx->msgcount * 2, MUTT_HASH_ALLOW_DUPS); + struct Hash *hash = mutt_hash_create(ctx->mailbox->msg_count * 2, MUTT_HASH_ALLOW_DUPS); - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { struct Header *hdr = ctx->hdrs[i]; if (hdr->env->real_subj) @@ -574,7 +575,7 @@ static void pseudo_threads(struct Context *ctx) */ void mutt_clear_threads(struct Context *ctx) { - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { /* mailbox may have been only partially read */ if (ctx->hdrs[i]) @@ -762,7 +763,7 @@ static void check_subjects(struct Context *ctx, bool init) { struct Header *cur = NULL; struct MuttThread *tmp = NULL; - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { cur = ctx->hdrs[i]; if (cur->thread->check_subject) @@ -817,7 +818,7 @@ void mutt_sort_threads(struct Context *ctx, bool init) if (init) { - ctx->thread_hash = mutt_hash_create(ctx->msgcount * 2, MUTT_HASH_ALLOW_DUPS); + ctx->thread_hash = mutt_hash_create(ctx->mailbox->msg_count * 2, MUTT_HASH_ALLOW_DUPS); mutt_hash_set_destructor(ctx->thread_hash, thread_hash_destructor, 0); } @@ -836,7 +837,7 @@ void mutt_sort_threads(struct Context *ctx, bool init) * exists. otherwise, if there is a MuttThread that already has a message, thread * new message as an identical child. if we didn't attach the message to a * MuttThread, make a new one for it. */ - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { cur = ctx->hdrs[i]; @@ -928,7 +929,7 @@ void mutt_sort_threads(struct Context *ctx, bool init) } /* thread by references */ - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { cur = ctx->hdrs[i]; if (cur->threaded) @@ -1156,7 +1157,7 @@ void mutt_set_virtual(struct Context *ctx) ctx->vsize = 0; int padding = mx_msg_padding_size(ctx); - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { cur = ctx->hdrs[i]; if (cur->virtual >= 0) @@ -1377,7 +1378,7 @@ int mutt_messages_in_thread(struct Context *ctx, struct Header *hdr, int flag) rc = threads[0]->message->msgno - (threads[1] ? threads[1]->message->msgno : -1); else { - rc = (threads[1] ? threads[1]->message->msgno : ctx->msgcount) - + rc = (threads[1] ? threads[1]->message->msgno : ctx->mailbox->msg_count) - threads[0]->message->msgno; } @@ -1394,9 +1395,9 @@ int mutt_messages_in_thread(struct Context *ctx, struct Header *hdr, int flag) */ struct Hash *mutt_make_id_hash(struct Context *ctx) { - struct Hash *hash = mutt_hash_create(ctx->msgcount * 2, 0); + struct Hash *hash = mutt_hash_create(ctx->mailbox->msg_count * 2, 0); - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { struct Header *hdr = ctx->hdrs[i]; if (hdr->env->message_id) @@ -1442,7 +1443,7 @@ int mutt_link_threads(struct Header *cur, struct Header *last, struct Context *c if (!last) { - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) if (message_is_tagged(ctx, i)) changed |= link_threads(cur, ctx->hdrs[i], ctx); } diff --git a/mx.c b/mx.c index 5193292c0..daad06996 100644 --- a/mx.c +++ b/mx.c @@ -380,7 +380,7 @@ void mx_fastclose_mailbox(struct Context *ctx) mutt_hash_destroy(&ctx->id_hash); mutt_hash_destroy(&ctx->label_hash); mutt_clear_threads(ctx); - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) mutt_header_free(&ctx->hdrs[i]); FREE(&ctx->hdrs); FREE(&ctx->v2r); @@ -436,7 +436,7 @@ static int trash_append(struct Context *ctx) int delmsgcount = 0; int first_del = -1; - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { if (ctx->hdrs[i]->deleted && (!ctx->hdrs[i]->purge)) { @@ -483,7 +483,7 @@ static int trash_append(struct Context *ctx) if (ctx_trash) { /* continue from initial scan above */ - for (i = first_del; i < ctx->msgcount; i++) + for (i = first_del; i < ctx->mailbox->msg_count; i++) { if (ctx->hdrs[i]->deleted && (!ctx->hdrs[i]->purge)) { @@ -553,7 +553,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) } #endif - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read && !(ctx->hdrs[i]->flagged && KeepFlagged)) { @@ -617,7 +617,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) if (MarkOld) { - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { if (!ctx->hdrs[i]->deleted && !ctx->hdrs[i]->old && !ctx->hdrs[i]->read) mutt_set_flag(ctx, ctx->hdrs[i], MUTT_OLD, 1); @@ -636,7 +636,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) if ((ctx->magic == MUTT_IMAP) && (imap_path_probe(mbox, NULL) == MUTT_IMAP)) { /* tag messages for moving, and clear old tags, if any */ - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { if (ctx->hdrs[i]->read && !ctx->hdrs[i]->deleted && !(ctx->hdrs[i]->flagged && KeepFlagged)) @@ -669,7 +669,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) return -1; } - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { if (ctx->hdrs[i]->read && !ctx->hdrs[i]->deleted && !(ctx->hdrs[i]->flagged && KeepFlagged)) @@ -728,7 +728,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) { if (!purge) { - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { ctx->hdrs[i]->deleted = false; ctx->hdrs[i]->purge = false; @@ -752,13 +752,13 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) if (move_messages) { mutt_message(_("%d kept, %d moved, %d deleted"), - ctx->msgcount - ctx->deleted, read_msgs, ctx->deleted); + ctx->mailbox->msg_count - ctx->deleted, read_msgs, ctx->deleted); } else - mutt_message(_("%d kept, %d deleted"), ctx->msgcount - ctx->deleted, ctx->deleted); + mutt_message(_("%d kept, %d deleted"), ctx->mailbox->msg_count - ctx->deleted, ctx->deleted); } - if (ctx->msgcount == ctx->deleted && (ctx->magic == MUTT_MMDF || ctx->magic == MUTT_MBOX) && + if (ctx->mailbox->msg_count == ctx->deleted && (ctx->magic == MUTT_MMDF || ctx->magic == MUTT_MBOX) && !mutt_is_spool(ctx->mailbox->path) && !SaveEmpty) { mutt_file_unlink_empty(ctx->mailbox->path); @@ -767,18 +767,18 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) #ifdef USE_SIDEBAR if (purge && ctx->deleted) { - int orig_msgcount = ctx->msgcount; + int orig_msgcount = ctx->mailbox->msg_count; - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read) ctx->unread--; if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->flagged) ctx->flagged--; } - ctx->msgcount -= ctx->deleted; + ctx->mailbox->msg_count -= ctx->deleted; mutt_sb_set_mailbox_stats(ctx); - ctx->msgcount = orig_msgcount; + ctx->mailbox->msg_count = orig_msgcount; } #endif @@ -807,7 +807,7 @@ void mx_update_tables(struct Context *ctx, bool committing) ctx->changed = false; ctx->flagged = 0; padding = mx_msg_padding_size(ctx); - for (i = 0, j = 0; i < ctx->msgcount; i++) + for (i = 0, j = 0; i < ctx->mailbox->msg_count; i++) { if (!ctx->hdrs[i]->quasi_deleted && ((committing && (!ctx->hdrs[i]->deleted || (ctx->magic == MUTT_MAILDIR && MaildirTrash))) || @@ -874,7 +874,7 @@ void mx_update_tables(struct Context *ctx, bool committing) mutt_header_free(&ctx->hdrs[i]); } } - ctx->msgcount = j; + ctx->mailbox->msg_count = j; } /** @@ -931,7 +931,7 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint) /* let IMAP servers hold on to D flags */ if (ctx->magic != MUTT_IMAP) { - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { ctx->hdrs[i]->deleted = false; ctx->hdrs[i]->purge = false; @@ -945,7 +945,7 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint) /* really only for IMAP - imap_sync_mailbox results in a call to * mx_update_tables, so ctx->deleted is 0 when it comes back */ - msgcount = ctx->msgcount; + msgcount = ctx->mailbox->msg_count; deleted = ctx->deleted; if (purge && ctx->deleted && (mutt_str_strcmp(ctx->mailbox->path, Trash) != 0)) @@ -977,7 +977,7 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint) mutt_sleep(0); - if (ctx->msgcount == ctx->deleted && (ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF) && + if (ctx->mailbox->msg_count == ctx->deleted && (ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF) && !mutt_is_spool(ctx->mailbox->path) && !SaveEmpty) { unlink(ctx->mailbox->path); @@ -1182,7 +1182,7 @@ void mx_alloc_memory(struct Context *ctx) ctx->hdrs = mutt_mem_calloc((ctx->hdrmax += 25), sizeof(struct Header *)); ctx->v2r = mutt_mem_calloc(ctx->hdrmax, sizeof(int)); } - for (int i = ctx->msgcount; i < ctx->hdrmax; i++) + for (int i = ctx->mailbox->msg_count; i < ctx->hdrmax; i++) { ctx->hdrs[i] = NULL; ctx->v2r[i] = -1; @@ -1200,7 +1200,7 @@ void mx_alloc_memory(struct Context *ctx) void mx_update_context(struct Context *ctx, int new_messages) { struct Header *h = NULL; - for (int msgno = ctx->msgcount - new_messages; msgno < ctx->msgcount; msgno++) + for (int msgno = ctx->mailbox->msg_count - new_messages; msgno < ctx->mailbox->msg_count; msgno++) { h = ctx->hdrs[msgno]; diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index dcc74ff65..92a217515 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -49,6 +49,7 @@ #include "curs_lib.h" #include "globals.h" #include "handler.h" +#include "mailbox.h" #include "mutt_curses.h" #include "mutt_parse.h" #include "muttlib.h" @@ -826,7 +827,7 @@ void crypt_extract_keys_from_messages(struct Header *h) if (!h) { - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) { if (!message_is_tagged(Context, i)) continue; diff --git a/nntp/newsrc.c b/nntp/newsrc.c index e3ea7b72a..1937cfc3b 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -47,6 +47,7 @@ #include "context.h" #include "format_flags.h" #include "globals.h" +#include "mailbox.h" #include "mutt_account.h" #include "mutt_logging.h" #include "mutt_socket.h" @@ -346,7 +347,7 @@ void nntp_newsrc_gen_entries(struct Context *ctx) * first article in our list */ nntp_data->newsrc_len = 0; series = true; - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { /* search for first unread */ if (series) @@ -1325,7 +1326,7 @@ struct NntpData *mutt_newsgroup_catchup(struct NntpServer *nserv, char *group) nntp_data->unread = 0; if (Context && Context->data == nntp_data) { - for (unsigned int i = 0; i < Context->msgcount; i++) + for (unsigned int i = 0; i < Context->mailbox->msg_count; i++) mutt_set_flag(Context, Context->hdrs[i], MUTT_READ, 1); } return nntp_data; @@ -1358,8 +1359,8 @@ struct NntpData *mutt_newsgroup_uncatchup(struct NntpServer *nserv, char *group) } if (Context && Context->data == nntp_data) { - nntp_data->unread = Context->msgcount; - for (unsigned int i = 0; i < Context->msgcount; i++) + nntp_data->unread = Context->mailbox->msg_count; + for (unsigned int i = 0; i < Context->mailbox->msg_count; i++) mutt_set_flag(Context, Context->hdrs[i], MUTT_READ, 0); } else @@ -1390,7 +1391,7 @@ void nntp_mailbox(char *buf, size_t buflen) { unsigned int unread = 0; - for (unsigned int j = 0; j < Context->msgcount; j++) + for (unsigned int j = 0; j < Context->mailbox->msg_count; j++) if (!Context->hdrs[j]->read && !Context->hdrs[j]->deleted) unread++; if (!unread) diff --git a/nntp/nntp.c b/nntp/nntp.c index 6a3f20c8e..dc08e2c53 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -1185,12 +1185,12 @@ static int parse_overview_line(char *line, void *data) rewind(fp); /* allocate memory for headers */ - if (ctx->msgcount >= ctx->hdrmax) + if (ctx->mailbox->msg_count >= ctx->hdrmax) mx_alloc_memory(ctx); /* parse header */ - ctx->hdrs[ctx->msgcount] = mutt_header_new(); - hdr = ctx->hdrs[ctx->msgcount]; + ctx->hdrs[ctx->mailbox->msg_count] = mutt_header_new(); + hdr = ctx->hdrs[ctx->mailbox->msg_count]; hdr->env = mutt_rfc822_read_header(fp, hdr, false, false); hdr->env->newsgroups = mutt_str_strdup(nntp_data->group); hdr->received = hdr->date_sent; @@ -1209,7 +1209,7 @@ static int parse_overview_line(char *line, void *data) mutt_debug(2, "mutt_hcache_fetch %s\n", buf); mutt_header_free(&hdr); hdr = mutt_hcache_restore(hdata); - ctx->hdrs[ctx->msgcount] = hdr; + ctx->hdrs[ctx->mailbox->msg_count] = hdr; mutt_hcache_free(fc->hc, &hdata); hdr->data = NULL; hdr->read = false; @@ -1238,7 +1238,7 @@ static int parse_overview_line(char *line, void *data) if (save) { - hdr->index = ctx->msgcount++; + hdr->index = ctx->mailbox->msg_count++; hdr->read = false; hdr->old = false; hdr->deleted = false; @@ -1282,7 +1282,7 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, struct Header *hdr = NULL; char buf[HUGE_STRING]; int rc = 0; - int oldmsgcount = ctx->msgcount; + int oldmsgcount = ctx->mailbox->msg_count; anum_t current; anum_t first_over = first; #ifdef USE_HCACHE @@ -1369,7 +1369,7 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, continue; /* allocate memory for headers */ - if (ctx->msgcount >= ctx->hdrmax) + if (ctx->mailbox->msg_count >= ctx->hdrmax) mx_alloc_memory(ctx); #ifdef USE_HCACHE @@ -1379,7 +1379,7 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, { mutt_debug(2, "mutt_hcache_fetch %s\n", buf); hdr = mutt_hcache_restore(hdata); - ctx->hdrs[ctx->msgcount] = hdr; + ctx->hdrs[ctx->mailbox->msg_count] = hdr; mutt_hcache_free(fc.hc, &hdata); hdr->data = NULL; @@ -1452,15 +1452,15 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, } /* parse header */ - ctx->hdrs[ctx->msgcount] = mutt_header_new(); - hdr = ctx->hdrs[ctx->msgcount]; + ctx->hdrs[ctx->mailbox->msg_count] = mutt_header_new(); + hdr = ctx->hdrs[ctx->mailbox->msg_count]; hdr->env = mutt_rfc822_read_header(fp, hdr, false, false); hdr->received = hdr->date_sent; mutt_file_fclose(&fp); } /* save header in context */ - hdr->index = ctx->msgcount++; + hdr->index = ctx->mailbox->msg_count++; hdr->read = false; hdr->old = false; hdr->deleted = false; @@ -1494,8 +1494,8 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, } } - if (ctx->msgcount > oldmsgcount) - mx_update_context(ctx, ctx->msgcount - oldmsgcount); + if (ctx->mailbox->msg_count > oldmsgcount) + mx_update_context(ctx, ctx->mailbox->msg_count - oldmsgcount); FREE(&fc.messages); if (rc != 0) @@ -1937,9 +1937,9 @@ static int check_mailbox(struct Context *ctx) /* articles have been renumbered, remove all headers */ if (nntp_data->last_message < nntp_data->last_loaded) { - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) mutt_header_free(&ctx->hdrs[i]); - ctx->msgcount = 0; + ctx->mailbox->msg_count = 0; ctx->tagged = 0; if (nntp_data->last_message < nntp_data->last_loaded) @@ -1971,7 +1971,7 @@ static int check_mailbox(struct Context *ctx) /* update flags according to .newsrc */ int j = 0; anum_t anum; - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { bool flagged = false; anum = NHDR(ctx->hdrs[i])->article_num; @@ -2021,7 +2021,7 @@ static int check_mailbox(struct Context *ctx) } #ifdef USE_HCACHE - ctx->msgcount = j; + ctx->mailbox->msg_count = j; /* restore headers without "deleted" flag */ for (anum = first; anum <= nntp_data->last_loaded; anum++) @@ -2034,11 +2034,11 @@ static int check_mailbox(struct Context *ctx) if (hdata) { mutt_debug(2, "#2 mutt_hcache_fetch %s\n", buf); - if (ctx->msgcount >= ctx->hdrmax) + if (ctx->mailbox->msg_count >= ctx->hdrmax) mx_alloc_memory(ctx); hdr = mutt_hcache_restore(hdata); - ctx->hdrs[ctx->msgcount] = hdr; + ctx->hdrs[ctx->mailbox->msg_count] = hdr; mutt_hcache_free(hc, &hdata); hdr->data = NULL; if (hdr->deleted) @@ -2052,7 +2052,7 @@ static int check_mailbox(struct Context *ctx) continue; } - ctx->msgcount++; + ctx->mailbox->msg_count++; hdr->read = false; hdr->old = false; hdr->data = mutt_mem_calloc(1, sizeof(struct NntpHeaderData)); @@ -2086,13 +2086,13 @@ static int check_mailbox(struct Context *ctx) ctx->changed = false; ctx->id_hash = NULL; ctx->subj_hash = NULL; - mx_update_context(ctx, ctx->msgcount); + mx_update_context(ctx, ctx->mailbox->msg_count); } /* fetch headers of new articles */ if (nntp_data->last_message > nntp_data->last_loaded) { - int oldmsgcount = ctx->msgcount; + int oldmsgcount = ctx->mailbox->msg_count; bool quiet = ctx->quiet; ctx->quiet = true; #ifdef USE_HCACHE @@ -2106,7 +2106,7 @@ static int check_mailbox(struct Context *ctx) ctx->quiet = quiet; if (rc >= 0) nntp_data->last_loaded = nntp_data->last_message; - if (ret == 0 && ctx->msgcount > oldmsgcount) + if (ret == 0 && ctx->mailbox->msg_count > oldmsgcount) ret = MUTT_NEW_MAIL; } @@ -2164,7 +2164,7 @@ static int nntp_mbox_sync(struct Context *ctx, int *index_hint) hc = nntp_hcache_open(nntp_data); #endif - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { struct Header *hdr = ctx->hdrs[i]; char buf[16]; @@ -2475,10 +2475,10 @@ int nntp_check_msgid(struct Context *ctx, const char *msgid) } /* parse header */ - if (ctx->msgcount == ctx->hdrmax) + if (ctx->mailbox->msg_count == ctx->hdrmax) mx_alloc_memory(ctx); - ctx->hdrs[ctx->msgcount] = mutt_header_new(); - struct Header *hdr = ctx->hdrs[ctx->msgcount]; + ctx->hdrs[ctx->mailbox->msg_count] = mutt_header_new(); + struct Header *hdr = ctx->hdrs[ctx->mailbox->msg_count]; hdr->data = mutt_mem_calloc(1, sizeof(struct NntpHeaderData)); hdr->env = mutt_rfc822_read_header(fp, hdr, false, false); mutt_file_fclose(&fp); @@ -2503,7 +2503,7 @@ int nntp_check_msgid(struct Context *ctx, const char *msgid) hdr->deleted = false; hdr->changed = true; hdr->received = hdr->date_sent; - hdr->index = ctx->msgcount++; + hdr->index = ctx->mailbox->msg_count++; mx_update_context(ctx, 1); return 0; } @@ -2532,7 +2532,7 @@ static int fetch_children(char *line, void *data) if (!line || sscanf(line, ANUM, &anum) != 1) return 0; - for (unsigned int i = 0; i < cc->ctx->msgcount; i++) + for (unsigned int i = 0; i < cc->ctx->mailbox->msg_count; i++) if (NHDR(cc->ctx->hdrs[i])->article_num == anum) return 0; if (cc->num >= cc->max) diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index 755feb233..7c01cbdeb 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -1036,7 +1036,7 @@ static void progress_reset(struct Context *ctx) return; memset(&data->progress, 0, sizeof(data->progress)); - data->oldmsgcount = ctx->msgcount; + data->oldmsgcount = ctx->mailbox->msg_count; data->ignmsgcount = 0; data->noprogress = false; data->progress_ready = false; @@ -1076,7 +1076,7 @@ static void progress_update(struct Context *ctx, notmuch_query_t *q) if (data->progress_ready) { mutt_progress_update(&data->progress, - ctx->msgcount + data->ignmsgcount - data->oldmsgcount, -1); + ctx->mailbox->msg_count + data->ignmsgcount - data->oldmsgcount, -1); } } @@ -1150,10 +1150,10 @@ static void append_message(struct Context *ctx, notmuch_query_t *q, if (!path) return; - mutt_debug(2, "nm: appending message, i=%d, id=%s, path=%s\n", ctx->msgcount, + mutt_debug(2, "nm: appending message, i=%d, id=%s, path=%s\n", ctx->mailbox->msg_count, notmuch_message_get_message_id(msg), path); - if (ctx->msgcount >= ctx->hdrmax) + if (ctx->mailbox->msg_count >= ctx->hdrmax) { mutt_debug(2, "nm: allocate mx memory\n"); mx_alloc_memory(ctx); @@ -1192,10 +1192,10 @@ static void append_message(struct Context *ctx, notmuch_query_t *q, } h->active = true; - h->index = ctx->msgcount; + h->index = ctx->mailbox->msg_count; ctx->size += h->content->length + h->content->offset - h->content->hdr_offset; - ctx->hdrs[ctx->msgcount] = h; - ctx->msgcount++; + ctx->hdrs[ctx->mailbox->msg_count] = h; + ctx->mailbox->msg_count++; if (newpath) { @@ -1292,7 +1292,7 @@ static bool read_mesgs_query(struct Context *ctx, notmuch_query_t *q, bool dedup msgs = notmuch_query_search_messages(q); #endif - for (; notmuch_messages_valid(msgs) && ((limit == 0) || (ctx->msgcount < limit)); + for (; notmuch_messages_valid(msgs) && ((limit == 0) || (ctx->mailbox->msg_count < limit)); notmuch_messages_move_to_next(msgs)) { if (SigInt == 1) @@ -1334,7 +1334,7 @@ static bool read_threads_query(struct Context *ctx, notmuch_query_t *q, bool ded threads = notmuch_query_search_threads(q); #endif - for (; notmuch_threads_valid(threads) && ((limit == 0) || (ctx->msgcount < limit)); + for (; notmuch_threads_valid(threads) && ((limit == 0) || (ctx->mailbox->msg_count < limit)); notmuch_threads_move_to_next(threads)) { if (SigInt == 1) @@ -1849,7 +1849,7 @@ int nm_read_entire_thread(struct Context *ctx, struct Header *h) if (!(db = get_db(data, false)) || !(msg = get_nm_message(db, h))) goto done; - mutt_debug(1, "nm: reading entire-thread messages...[current count=%d]\n", ctx->msgcount); + mutt_debug(1, "nm: reading entire-thread messages...[current count=%d]\n", ctx->mailbox->msg_count); progress_reset(ctx); id = notmuch_message_get_thread_id(msg); @@ -1870,20 +1870,20 @@ int nm_read_entire_thread(struct Context *ctx, struct Header *h) ctx->mtime.tv_nsec = 0; rc = 0; - if (ctx->msgcount > data->oldmsgcount) - mx_update_context(ctx, ctx->msgcount - data->oldmsgcount); + if (ctx->mailbox->msg_count > data->oldmsgcount) + mx_update_context(ctx, ctx->mailbox->msg_count - data->oldmsgcount); done: if (q) notmuch_query_destroy(q); if (!is_longrun(data)) release_db(data); - if (ctx->msgcount == data->oldmsgcount) + if (ctx->mailbox->msg_count == data->oldmsgcount) mutt_message(_("No more messages in the thread")); data->oldmsgcount = 0; mutt_debug(1, "nm: reading entire-thread messages... done [rc=%d, count=%d]\n", - rc, ctx->msgcount); + rc, ctx->mailbox->msg_count); return rc; } @@ -2452,7 +2452,7 @@ static int nm_mbox_open(struct Context *ctx) if (!data) return -1; - mutt_debug(1, "nm: reading messages...[current count=%d]\n", ctx->msgcount); + mutt_debug(1, "nm: reading messages...[current count=%d]\n", ctx->mailbox->msg_count); progress_reset(ctx); @@ -2480,10 +2480,10 @@ static int nm_mbox_open(struct Context *ctx) ctx->mtime.tv_sec = time(NULL); ctx->mtime.tv_nsec = 0; - mx_update_context(ctx, ctx->msgcount); + mx_update_context(ctx, ctx->mailbox->msg_count); data->oldmsgcount = 0; - mutt_debug(1, "nm: reading messages... done [rc=%d, count=%d]\n", rc, ctx->msgcount); + mutt_debug(1, "nm: reading messages... done [rc=%d, count=%d]\n", rc, ctx->mailbox->msg_count); return rc; } @@ -2495,7 +2495,7 @@ static int nm_mbox_close(struct Context *ctx) if (!ctx || (ctx->magic != MUTT_NOTMUCH)) return -1; - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { struct Header *h = ctx->hdrs[i]; if (h) @@ -2544,11 +2544,11 @@ static int nm_mbox_check(struct Context *ctx, int *index_hint) if (!q) goto done; - mutt_debug(1, "nm: start checking (count=%d)\n", ctx->msgcount); - data->oldmsgcount = ctx->msgcount; + mutt_debug(1, "nm: start checking (count=%d)\n", ctx->mailbox->msg_count); + data->oldmsgcount = ctx->mailbox->msg_count; data->noprogress = true; - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) ctx->hdrs[i]->active = false; limit = get_limit(data); @@ -2609,7 +2609,7 @@ static int nm_mbox_check(struct Context *ctx, int *index_hint) notmuch_message_destroy(m); } - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { if (!ctx->hdrs[i]->active) { @@ -2618,8 +2618,8 @@ static int nm_mbox_check(struct Context *ctx, int *index_hint) } } - if (ctx->msgcount > data->oldmsgcount) - mx_update_context(ctx, ctx->msgcount - data->oldmsgcount); + if (ctx->mailbox->msg_count > data->oldmsgcount) + mx_update_context(ctx, ctx->mailbox->msg_count - data->oldmsgcount); done: if (q) notmuch_query_destroy(q); @@ -2631,10 +2631,10 @@ done: ctx->mtime.tv_nsec = 0; mutt_debug(1, "nm: ... check done [count=%d, new_flags=%d, occult=%d]\n", - ctx->msgcount, new_flags, occult); + ctx->mailbox->msg_count, new_flags, occult); return occult ? MUTT_REOPENED : - (ctx->msgcount > data->oldmsgcount) ? MUTT_NEW_MAIL : + (ctx->mailbox->msg_count > data->oldmsgcount) ? MUTT_NEW_MAIL : new_flags ? MUTT_FLAGS : 0; } @@ -2659,10 +2659,10 @@ static int nm_mbox_sync(struct Context *ctx, int *index_hint) /* all is in this function so we don't use data->progress here */ char msgbuf[PATH_MAX + 64]; snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->mailbox->path); - mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->msgcount); + mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->mailbox->msg_count); } - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { char old[PATH_MAX], new[PATH_MAX]; struct Header *h = ctx->hdrs[i]; diff --git a/pager.c b/pager.c index 6079782ff..129894edd 100644 --- a/pager.c +++ b/pager.c @@ -2336,7 +2336,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e if (Context && !OptAttachMsg) { - oldcount = Context ? Context->msgcount : 0; + oldcount = Context ? Context->mailbox->msg_count : 0; /* check for new mail */ check = mx_mbox_check(Context, &index_hint); if (check < 0) @@ -2354,7 +2354,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e /* notify user of newly arrived mail */ if (check == MUTT_NEW_MAIL) { - for (i = oldcount; i < Context->msgcount; i++) + for (i = oldcount; i < Context->mailbox->msg_count; i++) { struct Header *h = Context->hdrs[i]; @@ -2373,7 +2373,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e { /* After the mailbox has been updated, * rd.index->current might be invalid */ - rd.index->current = MIN(rd.index->current, (Context->msgcount - 1)); + rd.index->current = MIN(rd.index->current, (Context->mailbox->msg_count - 1)); index_hint = Context->hdrs[Context->v2r[rd.index->current]]->index; bool q = Context->quiet; diff --git a/pattern.c b/pattern.c index 249809fc1..cd2e94a16 100644 --- a/pattern.c +++ b/pattern.c @@ -45,6 +45,7 @@ #include "group.h" #include "handler.h" #include "hdrline.h" +#include "mailbox.h" #include "menu.h" #include "mutt_logging.h" #include "mutt_parse.h" @@ -802,7 +803,7 @@ static int scan_range_slot(struct Buffer *s, regmatch_t pmatch[], int grp, int s if (side == RANGE_S_LEFT) return 1; else if (side == RANGE_S_RIGHT) - return Context->msgcount; + return Context->mailbox->msg_count; } /* We have something, so determine what */ c = (unsigned char) (s->dptr[pmatch[grp].rm_so]); @@ -811,7 +812,7 @@ static int scan_range_slot(struct Buffer *s, regmatch_t pmatch[], int grp, int s case RANGE_CIRCUM: return 1; case RANGE_DOLLAR: - return Context->msgcount; + return Context->mailbox->msg_count; case RANGE_DOT: return CTX_MSGNO(Context); case RANGE_LT: @@ -2184,7 +2185,7 @@ bool mutt_limit_current_thread(struct Header *h) Context->vsize = 0; Context->collapsed = false; - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) { Context->hdrs[i]->virtual = -1; Context->hdrs[i]->limited = false; @@ -2247,7 +2248,7 @@ int mutt_pattern_func(int op, char *prompt) mutt_progress_init(&progress, _("Executing command on matching messages..."), MUTT_PROGRESS_MSG, ReadInc, - (op == MUTT_LIMIT) ? Context->msgcount : Context->vcount); + (op == MUTT_LIMIT) ? Context->mailbox->msg_count : Context->vcount); if (op == MUTT_LIMIT) { @@ -2256,7 +2257,7 @@ int mutt_pattern_func(int op, char *prompt) Context->collapsed = false; padding = mx_msg_padding_size(Context); - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) { mutt_progress_update(&progress, i, -1); /* new limit pattern implicitly uncollapses all threads */ @@ -2311,7 +2312,7 @@ int mutt_pattern_func(int op, char *prompt) if (Context->limit_pattern) mutt_pattern_free(&Context->limit_pattern); - if (Context->msgcount && !Context->vcount) + if (Context->mailbox->msg_count && !Context->vcount) mutt_error(_("No messages matched criteria")); /* record new limit pattern, unless match all */ @@ -2396,7 +2397,7 @@ int mutt_search_command(int cur, int op) if (OptSearchInvalid) { - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) Context->hdrs[i]->searched = false; #ifdef USE_IMAP if (Context->magic == MUTT_IMAP && imap_search(Context, SearchPattern) < 0) diff --git a/pop/pop.c b/pop/pop.c index e1b160e11..925519b38 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -218,18 +218,18 @@ static int fetch_uidl(char *line, void *data) if (strlen(line) == 0) return -1; - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) if (mutt_str_strcmp(line, ctx->hdrs[i]->data) == 0) break; - if (i == ctx->msgcount) + if (i == ctx->mailbox->msg_count) { mutt_debug(1, "new header %d %s\n", index, line); if (i >= ctx->hdrmax) mx_alloc_memory(ctx); - ctx->msgcount++; + ctx->mailbox->msg_count++; ctx->hdrs[i] = mutt_header_new(); ctx->hdrs[i]->data = mutt_str_strdup(line); } @@ -260,7 +260,7 @@ static int msg_cache_check(const char *id, struct BodyCache *bcache, void *data) return 0; #endif - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { /* if the id we get is known for a header: done (i.e. keep in cache) */ if (ctx->hdrs[i]->data && (mutt_str_strcmp(ctx->hdrs[i]->data, id) == 0)) @@ -323,13 +323,13 @@ static int pop_fetch_headers(struct Context *ctx) time(&pop_data->check_time); pop_data->clear_cache = false; - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) ctx->hdrs[i]->refno = -1; - const int old_count = ctx->msgcount; + const int old_count = ctx->mailbox->msg_count; int ret = pop_fetch_data(pop_data, "UIDL\r\n", NULL, fetch_uidl, ctx); - const int new_count = ctx->msgcount; - ctx->msgcount = old_count; + const int new_count = ctx->mailbox->msg_count; + ctx->mailbox->msg_count = old_count; if (pop_data->cmd_uidl == 2) { @@ -445,7 +445,7 @@ static int pop_fetch_headers(struct Context *ctx) ctx->hdrs[i]->read = true; } - ctx->msgcount++; + ctx->mailbox->msg_count++; } if (i > old_count) @@ -458,7 +458,7 @@ static int pop_fetch_headers(struct Context *ctx) if (ret < 0) { - for (int i = ctx->msgcount; i < new_count; i++) + for (int i = ctx->mailbox->msg_count; i < new_count; i++) mutt_header_free(&ctx->hdrs[i]); return ret; } @@ -791,7 +791,7 @@ static int pop_mbox_sync(struct Context *ctx, int *index_hint) hc = pop_hcache_open(pop_data, ctx->mailbox->path); #endif - for (i = 0, j = 0, ret = 0; ret == 0 && i < ctx->msgcount; i++) + for (i = 0, j = 0, ret = 0; ret == 0 && i < ctx->mailbox->msg_count; i++) { if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->refno != -1) { diff --git a/pop/pop_lib.c b/pop/pop_lib.c index 98af61605..cd48067c2 100644 --- a/pop/pop_lib.c +++ b/pop/pop_lib.c @@ -42,6 +42,7 @@ #include "mutt.h" #include "context.h" #include "globals.h" +#include "mailbox.h" #include "mutt_account.h" #include "mutt_logging.h" #include "mutt_socket.h" @@ -586,7 +587,7 @@ static int check_uidl(char *line, void *data) endp++; memmove(line, endp, strlen(endp) + 1); - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { if (mutt_str_strcmp(ctx->hdrs[i]->data, line) == 0) { @@ -624,7 +625,7 @@ int pop_reconnect(struct Context *ctx) mutt_progress_init(&progressbar, _("Verifying message indexes..."), MUTT_PROGRESS_SIZE, NetInc, 0); - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) ctx->hdrs[i]->refno = -1; ret = pop_fetch_data(pop_data, "UIDL\r\n", &progressbar, check_uidl, ctx); diff --git a/postpone.c b/postpone.c index 92d86b932..7fa3ec306 100644 --- a/postpone.c +++ b/postpone.c @@ -166,7 +166,7 @@ int mutt_num_postponed(bool force) if (!ctx) PostCount = 0; else - PostCount = ctx->msgcount; + PostCount = ctx->mailbox->msg_count; mx_fastclose_mailbox(ctx); mutt_context_free(&ctx); #ifdef USE_NNTP @@ -213,7 +213,7 @@ static struct Header *select_msg(void) struct Menu *menu = mutt_menu_new(MENU_POST); menu->make_entry = post_entry; - menu->max = PostContext->msgcount; + menu->max = PostContext->mailbox->msg_count; menu->title = _("Postponed Messages"); menu->data = PostContext; menu->help = mutt_compile_help(helpstr, sizeof(helpstr), MENU_POST, PostponeHelp); @@ -235,7 +235,7 @@ static struct Header *select_msg(void) /* should deleted draft messages be saved in the trash folder? */ mutt_set_flag(PostContext, PostContext->hdrs[menu->current], MUTT_DELETE, (i == OP_DELETE) ? 1 : 0); - PostCount = PostContext->msgcount - PostContext->deleted; + PostCount = PostContext->mailbox->msg_count - PostContext->deleted; if (Resolve && menu->current < menu->max - 1) { menu->oldcurrent = menu->current; @@ -299,7 +299,7 @@ int mutt_get_postponed(struct Context *ctx, struct Header *hdr, return -1; } - if (!PostContext->msgcount) + if (!PostContext->mailbox->msg_count) { PostCount = 0; mx_mbox_close(&PostContext, NULL); @@ -307,7 +307,7 @@ int mutt_get_postponed(struct Context *ctx, struct Header *hdr, return -1; } - if (PostContext->msgcount == 1) + if (PostContext->mailbox->msg_count == 1) { /* only one message, so just use that one. */ h = PostContext->hdrs[0]; @@ -330,7 +330,7 @@ int mutt_get_postponed(struct Context *ctx, struct Header *hdr, mutt_set_flag(PostContext, h, MUTT_PURGE, 1); /* update the count for the status display */ - PostCount = PostContext->msgcount - PostContext->deleted; + PostCount = PostContext->mailbox->msg_count - PostContext->deleted; /* avoid the "purge deleted messages" prompt */ opt_delete = Delete; diff --git a/score.c b/score.c index 87ef1c7f3..99540ed30 100644 --- a/score.c +++ b/score.c @@ -31,6 +31,7 @@ #include "context.h" #include "globals.h" #include "keymap.h" +#include "mailbox.h" #include "menu.h" #include "options.h" #include "pattern.h" @@ -75,7 +76,7 @@ void mutt_check_rescore(struct Context *ctx) mutt_menu_set_redraw_full(MENU_MAIN); mutt_menu_set_redraw_full(MENU_PAGER); - for (int i = 0; ctx && i < ctx->msgcount; i++) + for (int i = 0; ctx && i < ctx->mailbox->msg_count; i++) { mutt_score_message(ctx, ctx->hdrs[i], true); ctx->hdrs[i]->pair = 0; diff --git a/send.c b/send.c index 78f2f3933..e21e204aa 100644 --- a/send.c +++ b/send.c @@ -46,6 +46,7 @@ #include "globals.h" #include "hdrline.h" #include "hook.h" +#include "mailbox.h" #include "mutt_attach.h" #include "mutt_header.h" #include "mutt_logging.h" @@ -907,7 +908,7 @@ static void make_reference_headers(struct Envelope *curenv, if (!curenv) { - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { if (message_is_tagged(ctx, i)) mutt_add_to_reference_headers(env, ctx->hdrs[i]->env); @@ -944,7 +945,7 @@ static int envelope_defaults(struct Envelope *env, struct Context *ctx, if (!cur) { tag = true; - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { if (!message_is_tagged(ctx, i)) continue; @@ -985,7 +986,7 @@ static int envelope_defaults(struct Envelope *env, struct Context *ctx, #endif if (tag) { - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { if (!message_is_tagged(ctx, i)) continue; @@ -1046,7 +1047,7 @@ static int generate_body(FILE *tempfp, struct Header *msg, int flags, mutt_message(_("Including quoted message...")); if (!cur) { - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { if (!message_is_tagged(ctx, i)) continue; @@ -1085,7 +1086,7 @@ static int generate_body(FILE *tempfp, struct Header *msg, int flags, } else { - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { if (!message_is_tagged(ctx, i)) continue; @@ -1110,7 +1111,7 @@ static int generate_body(FILE *tempfp, struct Header *msg, int flags, include_forward(ctx, cur, tempfp); else { - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { if (message_is_tagged(ctx, i)) include_forward(ctx, ctx->hdrs[i], tempfp); @@ -2412,7 +2413,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, mutt_set_flag(ctx, cur, MUTT_REPLIED, is_reply(cur, msg)); else if (!(flags & SEND_POSTPONED) && ctx && ctx->tagged) { - for (i = 0; i < ctx->msgcount; i++) + for (i = 0; i < ctx->mailbox->msg_count; i++) { if (message_is_tagged(ctx, i)) { diff --git a/sendlib.c b/sendlib.c index 185710686..140c6cfc5 100644 --- a/sendlib.c +++ b/sendlib.c @@ -2966,7 +2966,7 @@ static int bounce_message(FILE *fp, struct Header *h, struct Address *to, if (!h) { /* Try to bounce each message out, aborting if we get any failures. */ - for (int i = 0; i < Context->msgcount; i++) + for (int i = 0; i < Context->mailbox->msg_count; i++) if (message_is_tagged(Context, i)) rc |= bounce_message(fp, Context->hdrs[i], to, resent_from, env_from); return rc; diff --git a/sidebar.c b/sidebar.c index 1ed518469..bbe612bc4 100644 --- a/sidebar.c +++ b/sidebar.c @@ -873,7 +873,7 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) #endif { b->msg_unread = Context->unread; - b->msg_count = Context->msgcount; + b->msg_count = Context->mailbox->msg_count; } b->msg_flagged = Context->flagged; } @@ -1080,7 +1080,7 @@ void mutt_sb_set_mailbox_stats(const struct Context *ctx) if (mutt_str_strcmp(np->b->realpath, ctx->mailbox->realpath) == 0) { np->b->msg_unread = ctx->unread; - np->b->msg_count = ctx->msgcount; + np->b->msg_count = ctx->mailbox->msg_count; np->b->msg_flagged = ctx->flagged; break; } diff --git a/sort.c b/sort.c index 139a846e7..452bad34c 100644 --- a/sort.c +++ b/sort.c @@ -30,6 +30,7 @@ #include "alias.h" #include "context.h" #include "globals.h" +#include "mailbox.h" #include "mutt_logging.h" #include "mutt_thread.h" #include "options.h" @@ -359,7 +360,7 @@ void mutt_sort_headers(struct Context *ctx, bool init) if (!ctx) return; - if (!ctx->msgcount) + if (!ctx->mailbox->msg_count) { /* this function gets called by mutt_sync_mailbox(), which may have just * deleted all the messages. the virtual message numbers are not updated @@ -376,7 +377,7 @@ void mutt_sort_headers(struct Context *ctx, bool init) if (OptNeedRescore && Score) { - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) mutt_score_message(ctx, ctx->hdrs[i], true); } OptNeedRescore = false; @@ -412,11 +413,11 @@ void mutt_sort_headers(struct Context *ctx, bool init) return; } else - qsort((void *) ctx->hdrs, ctx->msgcount, sizeof(struct Header *), sortfunc); + qsort((void *) ctx->hdrs, ctx->mailbox->msg_count, sizeof(struct Header *), sortfunc); /* adjust the virtual message numbers */ ctx->vcount = 0; - for (int i = 0; i < ctx->msgcount; i++) + for (int i = 0; i < ctx->mailbox->msg_count; i++) { struct Header *cur = ctx->hdrs[i]; if (cur->virtual != -1 || (cur->collapsed && (!ctx->pattern || cur->limited))) diff --git a/status.c b/status.c index 4f67cd9f7..156b566e2 100644 --- a/status.c +++ b/status.c @@ -190,9 +190,9 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c if (!optional) { snprintf(fmt, sizeof(fmt), "%%%sd", prec); - snprintf(buf, buflen, fmt, Context ? Context->msgcount : 0); + snprintf(buf, buflen, fmt, Context ? Context->mailbox->msg_count : 0); } - else if (!Context || !Context->msgcount) + else if (!Context || !Context->mailbox->msg_count) optional = 0; break; @@ -285,7 +285,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c case 'R': { - int read = Context ? Context->msgcount - Context->unread : 0; + int read = Context ? Context->mailbox->msg_count - Context->unread : 0; if (!optional) {