]> granicus.if.org Git - neomutt/commitdiff
move msgcount
authorRichard Russon <rich@flatcap.org>
Thu, 30 Aug 2018 15:54:58 +0000 (16:54 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 4 Sep 2018 00:18:36 +0000 (01:18 +0100)
36 files changed:
browser.c
color.c
commands.c
compose.c
context.h
curs_lib.c
curs_main.c
edit.c
editmsg.c
flags.c
hdrline.c
imap/browse.c
imap/imap.c
imap/message.c
init.c
mailbox.c
maildir/mh.c
mbox/mbox.c
mutt_header.c
mutt_thread.c
mx.c
ncrypt/crypt.c
nntp/newsrc.c
nntp/nntp.c
notmuch/mutt_notmuch.c
pager.c
pattern.c
pop/pop.c
pop/pop_lib.c
postpone.c
score.c
send.c
sendlib.c
sidebar.c
sort.c
status.c

index f4989c1b058948b2f9dc4aaecc22ea2dc325ecae..90b69893ddd98e95e8862750064b0bda85839a4f 100644 (file)
--- 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 0ee9145705a399bb13ca25a64005f7b18d02bb43..ed141a1bfb1f28794d00f764b528f649909280b8 100644 (file)
--- 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;
   }
 
index 5424eaa8798273c67e3b7af849c286612dcdcc03..5c4277c25c098657ad7a2e593e06b7e237f9637a 100644 (file)
@@ -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))
       {
index fd17d8a35f413f2a83609f3fffc43e30c03fa63a..bbe63b0a2267e9340e4b31c07839757c75021054 100644 (file)
--- 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;
index 4be460ff4775166692d81cede8bbdaf9fee9ff40..284c52eb9bc6f24ae44b7e82470b300897a6ce71 100644 (file)
--- 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? */
index dd1409dc1ecf5df3be52c715e9902381595de01d..3fe2ae0f905daf4d4a84a259ada8575e554af67b 100644 (file)
@@ -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;
index 4b7df8a6dc20194fbd8c9aca59ef4906f85bfbb3..5cc9507cad03516a588f8d94d092fa7967bd50b7 100644 (file)
@@ -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 f755456effc9fa808abd3fe594f940df04b1ecb0..edc2006fdd3f7a8341ed630b5f578b3d07993bd0 100644 (file)
--- 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--;
 
index d5b6df94acebd430241a32b55feadd753f4d631c..88c07774beeee8494e52c24d69ba9fd73e503c56 100644 (file)
--- 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 f90c1a370dbbfc97854f6d34fddb18024818b120..ed360ad389005865169d65eb0f409f1a36bb11e6 100644 (file)
--- 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);
 }
index d5fbeb7dd1acfa576e31d4808b4aec4a96af9e5b..399f3170b2859f9e902f81e858a8d569e2ff0595 100644 (file)
--- 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);
index 37ddeb3127621e5efd1d5cfb25b46eb5350d10c0..107d25de3560b24f437888b1928bf20706e983bf 100644 (file)
@@ -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;
index 8b51fd3d1576b99e156c05ecccf4e8fdb94c3a71..3dfdcd1f0d3f8391ab0806decc9b90799300da55 100644 (file)
@@ -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;
index 662fb1bd1cf35d0c2499b64491ab17c83b50d93e..fdb7bc390f05166d78678eb3cf8b359fc45850e0 100644 (file)
@@ -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 097aae2a1eda81629aacd140a16ac589eb205c77..c638c5b8ab6c7ec15911c41f43bafa6330248e03 100644 (file)
--- 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);
 }
 
index 7eece184f3dc333a4dac9906a383d469f0c21cb8..61bc8e8718ae0d7dd6b301f3eb85955bae4fd31f 100644 (file)
--- 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;
index 07d77c281e148a71b5b27f29f2ee9d54171edd2c..d8d8b7eb9ccd50528fa6f9e709c0333bd8aca29e 100644 (file)
@@ -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++;
index 12e6aa51ba349920c86847761e11ea8c2ba68d6e..8e8d938a0c7c3abb5cd72be1722a67c2baf711e5 100644 (file)
@@ -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;
index 4ab10c87955bf01c83059177c6d462b6284d109f..af3c310932f8552a5ad83aea9978b04492006563 100644 (file)
@@ -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;
index e83012488b851e7990ff2df0b93e41a4113d8cdf..841c15eb2679ccc2dfb9c68a1a0cd7804e099fde 100644 (file)
@@ -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 5193292c0c403cfb591280a7d8f98ca3d24e2a1d..daad06996eab270bb4afe7ff964e430a27524fdc 100644 (file)
--- 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];
 
index dcc74ff65fe27b80001e75d7b98e4cc0dfe7bbb2..92a217515b292c0972cbbed9883234159536b382 100644 (file)
@@ -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;
index e3ea7b72aacbbd2b25c2def543373c7a40ccb3b3..1937cfc3bc89828c7b508e675cb7cef8b62579ad 100644 (file)
@@ -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)
index 6a3f20c8efa39c1e102ea0ade234da638c4de5b3..dc08e2c532b2baccebb5efd2a4117f80a453da30 100644 (file)
@@ -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)
index 755feb233195399533ec4579f4fc2a7bd3706c68..7c01cbdebe9612f4de49d269f031f599142929a8 100644 (file)
@@ -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 6079782ff2583208e9142f30114c9484d53fe74c..129894edd7a88ed577b685ab67c1e1f37cafa6c8 100644 (file)
--- 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;
index 249809fc18edccbd39da4c10f6f4f20c6ea02b1b..cd2e94a16d2caaf1f7c8c4a32d2f22980c03e521 100644 (file)
--- 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)
index e1b160e1167ab3758fdd5bfe9ee4e58e978ddbc3..925519b38e09055163244f620bb4fb77ef979067 100644 (file)
--- 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)
       {
index 98af616058b4d6b6b7002fe116c92c15d0f78f03..cd48067c28ca58929d250a1704cc5fd3e720493e 100644 (file)
@@ -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);
index 92d86b93296380ae2cd16aecadf0385dd251aa02..7fa3ec3064155ded6b37801e2620a11c58a53234 100644 (file)
@@ -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 87ef1c7f31072cbe8f288fe0c0f56c356413264e..99540ed303996a1a0850d46ee5152eee9746f954 100644 (file)
--- 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 78f2f393396c6c05b233a15a891dd5567fe31dce..e21e204aaf124748914a6029417f303cd6d5f878 100644 (file)
--- 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))
         {
index 1857106863d5eaba04c859ebbb64f204ed8e4e31..140c6cfc5264d6e1679054772e460dfcad43bce3 100644 (file)
--- 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;
index 1ed5184697e1d4a74b2cbef9b5cb7b5d641d7e6a..bbe612bc451bd1d167fa242ad820a5fb4583e8b3 100644 (file)
--- 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 139a846e76073c3e611c352e9826e84ea02d0fe3..452bad34cdc83ec7e8f93e23e0f4476f35f32410 100644 (file)
--- 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)))
index 4f67cd9f7e85f8ee648689bc9e4a3d652ecbbc24..156b566e2bba6cff55ec6dea3c36117f4f6dabe5 100644 (file)
--- 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)
       {