]> granicus.if.org Git - neomutt/commitdiff
tidy context usage
authorRichard Russon <rich@flatcap.org>
Sat, 8 Sep 2018 14:59:25 +0000 (15:59 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 9 Sep 2018 15:13:25 +0000 (16:13 +0100)
22 files changed:
compose.c
copy.c
curs_main.c
imap/imap.c
imap/message.c
maildir/mh.c
main.c
mbox/mbox.c
mutt_header.c
mutt_header.h
mutt_thread.c
mutt_thread.h
mx.c
mx.h
nntp/newsrc.c
nntp/nntp.c
nntp/nntp.h
notmuch/mutt_notmuch.c
notmuch/mutt_notmuch.h
pop/pop.c
postpone.c
sendlib.c

index 415d67445ce1c9d65364d11d69734e1e2ee3f52b..adaf87b6c753ea76b45515f680e9af7542fc42c6 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -1408,7 +1408,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen,
         OptNews = false;
         if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
         {
-          CurrentNewsSrv = nntp_select_server(Context, NewsServer, false);
+          CurrentNewsSrv = nntp_select_server(Context->mailbox, NewsServer, false);
           if (!CurrentNewsSrv)
             break;
 
diff --git a/copy.c b/copy.c
index ccba4575c78572dc74e5c2f492ec7c106c90d88f..e42507e21c53f3a37468c2f0531af55d1c7e18f0 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -840,7 +840,7 @@ static int append_message(struct Context *dest, FILE *fpin, struct Context *src,
 #ifdef USE_NOTMUCH
   if (msg->committed_path && dest->mailbox->magic == MUTT_MAILDIR &&
       src->mailbox->magic == MUTT_NOTMUCH)
-    nm_update_filename(src, NULL, msg->committed_path, hdr);
+    nm_update_filename(src->mailbox, NULL, msg->committed_path, hdr);
 #endif
 
   mx_msg_close(dest, &msg);
index 04d82977a9f28c9821720be2c956c7d81369fd55..2026397b22099cf09bac70296bebc3dc812d2e6c 100644 (file)
@@ -1332,7 +1332,7 @@ int mutt_index_menu(void)
                              sizeof(buf));
           }
           if (!Context->mailbox->id_hash)
-            Context->mailbox->id_hash = mutt_make_id_hash(Context);
+            Context->mailbox->id_hash = mutt_make_id_hash(Context->mailbox);
           hdr = mutt_hash_find(Context->mailbox->id_hash, buf);
           if (hdr)
           {
@@ -1390,7 +1390,7 @@ int mutt_index_menu(void)
 
           mutt_message(_("Fetching message headers..."));
           if (!Context->mailbox->id_hash)
-            Context->mailbox->id_hash = mutt_make_id_hash(Context);
+            Context->mailbox->id_hash = mutt_make_id_hash(Context->mailbox);
           mutt_str_strfcpy(buf, CURHDR->env->message_id, sizeof(buf));
 
           /* trying to find msgid of the root message */
@@ -2210,7 +2210,7 @@ int mutt_index_menu(void)
           if (op == OP_MAIN_CHANGE_GROUP || op == OP_MAIN_CHANGE_GROUP_READONLY)
           {
             OptNews = true;
-            CurrentNewsSrv = nntp_select_server(Context, NewsServer, false);
+            CurrentNewsSrv = nntp_select_server(Context->mailbox, NewsServer, false);
             if (!CurrentNewsSrv)
               break;
             if (flags)
index cc0a43a0943480068275217028ac862ecede2592..106912242c083a469ab3de7447b566c5bb53edbd 100644 (file)
@@ -2023,7 +2023,7 @@ static int imap_mbox_open(struct Context *ctx)
   /* once again the context is new */
   ctx->mailbox->data = idata;
 
-  /* Clean up path and replace the one in the ctx */
+  /* Clean up path and replace the one in the mailbox */
   imap_fix_path(idata, mx.mbox, buf, sizeof(buf));
   if (!*buf)
     mutt_str_strfcpy(buf, "INBOX", sizeof(buf));
index 7c855487baf5199005f13f597af284ec70523631..2fce597bfe5c1c111c236790fc1aa99a561b5ef9 100644 (file)
@@ -748,7 +748,7 @@ static int read_headers_normal_eval_cache(struct ImapData *idata,
           h.data->replied = ctx->mailbox->hdrs[idx]->replied;
         }
 
-        /*  ctx->hdrs[msgno]->received is restored from mutt_hcache_restore */
+        /*  mailbox->hdrs[msgno]->received is restored from mutt_hcache_restore */
         ctx->mailbox->hdrs[idx]->data = h.data;
         STAILQ_INIT(&ctx->mailbox->hdrs[idx]->tags);
         driver_tags_replace(&ctx->mailbox->hdrs[idx]->tags,
@@ -815,7 +815,7 @@ static int read_headers_qresync_eval_cache(struct ImapData *idata, char *uid_seq
       idata->msn_index[msn - 1] = h;
 
       if (ctx->mailbox->msg_count >= ctx->mailbox->hdrmax)
-        mx_alloc_memory(ctx);
+        mx_alloc_memory(ctx->mailbox);
 
       struct ImapHeaderData *ihd = mutt_mem_calloc(1, sizeof(struct ImapHeaderData));
       h->data = ihd;
@@ -1118,7 +1118,7 @@ static int read_headers_fetch_new(struct ImapData *idata, unsigned int msn_begin
       msn_begin = idata->max_msn + 1;
       msn_end = idata->new_mail_count;
       while (msn_end > ctx->mailbox->hdrmax)
-        mx_alloc_memory(ctx);
+        mx_alloc_memory(ctx->mailbox);
       alloc_msn_index(idata, msn_end);
       idata->reopen &= ~IMAP_NEWMAIL_PENDING;
       idata->new_mail_count = 0;
@@ -1173,7 +1173,7 @@ int imap_read_headers(struct ImapData *idata, unsigned int msn_begin,
 
   /* make sure context has room to hold the mailbox */
   while (msn_end > ctx->mailbox->hdrmax)
-    mx_alloc_memory(ctx);
+    mx_alloc_memory(ctx->mailbox);
   alloc_msn_index(idata, msn_end);
   imap_alloc_uid_hash(idata, msn_end);
 
@@ -1313,7 +1313,7 @@ int imap_read_headers(struct ImapData *idata, unsigned int msn_begin,
   {
     /* TODO: it's not clear to me why we are calling mx_alloc_memory
      *       yet again. */
-    mx_alloc_memory(ctx);
+    mx_alloc_memory(ctx->mailbox);
     mx_update_context(ctx, ctx->mailbox->msg_count - oldmsgcount);
   }
 
@@ -1999,7 +1999,7 @@ char *imap_set_flags(struct ImapData *idata, struct Header *h, char *s, int *ser
 
   /* YAUH (yet another ugly hack): temporarily set context to
    * read-write even if it's read-only, so *server* updates of
-   * flags can be processed by mutt_set_flag. ctx->changed must
+   * flags can be processed by mutt_set_flag. mailbox->changed must
    * be restored afterwards */
   readonly = ctx->mailbox->readonly;
   ctx->mailbox->readonly = false;
index b70ce60306f367aef15f697a0cb0a3ea8d4ea29b..1a0b6cc2ccdcb2977333a5f7b2f5889a2cc4d024 100644 (file)
@@ -433,22 +433,22 @@ bool mh_mailbox(struct Mailbox *mailbox, bool check_stats)
 
 /**
  * mh_mkstemp - Create a temporary file
- * @param[in]  dest Mailbox to create the file in
- * @param[out] fp   File handle
- * @param[out] tgt  File name
+ * @param[in]  mailbox Mailbox to create the file in
+ * @param[out] fp      File handle
+ * @param[out] tgt     File name
  * @retval  0 Success
  * @retval -1 Failure
  */
-static int mh_mkstemp(struct Context *dest, FILE **fp, char **tgt)
+static int mh_mkstemp(struct Mailbox *mailbox, FILE **fp, char **tgt)
 {
   int fd;
   char path[PATH_MAX];
   mode_t omask;
 
-  omask = umask(mh_umask(dest->mailbox));
+  omask = umask(mh_umask(mailbox));
   while (true)
   {
-    snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, dest->mailbox->path,
+    snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, mailbox->path,
              NONULL(ShortHostname), (int) getpid(), mutt_rand64());
     fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666);
     if (fd == -1)
@@ -529,12 +529,12 @@ static void mhs_write_one_sequence(FILE *fp, struct MhSequences *mhs, short f, c
 
 /**
  * mh_update_sequences - Update sequence numbers
- * @param ctx Mailbox
+ * @param mailbox Mailbox
  *
  * XXX we don't currently remove deleted messages from sequences we don't know.
  * Should we?
  */
-static void mh_update_sequences(struct Context *ctx)
+static void mh_update_sequences(struct Mailbox *mailbox)
 {
   FILE *ofp = NULL, *nfp = NULL;
 
@@ -560,13 +560,13 @@ static void mh_update_sequences(struct Context *ctx)
   snprintf(seq_replied, sizeof(seq_replied), "%s:", NONULL(MhSeqReplied));
   snprintf(seq_flagged, sizeof(seq_flagged), "%s:", NONULL(MhSeqFlagged));
 
-  if (mh_mkstemp(ctx, &nfp, &tmpfname) != 0)
+  if (mh_mkstemp(mailbox, &nfp, &tmpfname) != 0)
   {
     /* error message? */
     return;
   }
 
-  snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->mailbox->path);
+  snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mailbox->path);
 
   /* first, copy unknown sequences */
   ofp = fopen(sequences, "r");
@@ -587,31 +587,31 @@ 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->mailbox->msg_count; l++)
+  for (l = 0; l < mailbox->msg_count; l++)
   {
-    if (ctx->mailbox->hdrs[l]->deleted)
+    if (mailbox->hdrs[l]->deleted)
       continue;
 
-    p = strrchr(ctx->mailbox->hdrs[l]->path, '/');
+    p = strrchr(mailbox->hdrs[l]->path, '/');
     if (p)
       p++;
     else
-      p = ctx->mailbox->hdrs[l]->path;
+      p = mailbox->hdrs[l]->path;
 
     if (mutt_str_atoi(p, &i) < 0)
       continue;
 
-    if (!ctx->mailbox->hdrs[l]->read)
+    if (!mailbox->hdrs[l]->read)
     {
       mhs_set(&mhs, i, MH_SEQ_UNSEEN);
       unseen++;
     }
-    if (ctx->mailbox->hdrs[l]->flagged)
+    if (mailbox->hdrs[l]->flagged)
     {
       mhs_set(&mhs, i, MH_SEQ_FLAGGED);
       flagged++;
     }
-    if (ctx->mailbox->hdrs[l]->replied)
+    if (mailbox->hdrs[l]->replied)
     {
       mhs_set(&mhs, i, MH_SEQ_REPLIED);
       replied++;
@@ -643,13 +643,13 @@ static void mh_update_sequences(struct Context *ctx)
 
 /**
  * mh_sequences_add_one - Update the flags for one sequence
- * @param ctx     Mailbox
+ * @param mailbox Mailbox
  * @param n       Sequence number to update
  * @param unseen  Update the unseen sequence
  * @param flagged Update the flagged sequence
  * @param replied Update the replied sequence
  */
-static void mh_sequences_add_one(struct Context *ctx, int n, bool unseen,
+static void mh_sequences_add_one(struct Mailbox *mailbox, int n, bool unseen,
                                  bool flagged, bool replied)
 {
   short unseen_done = 0;
@@ -669,14 +669,14 @@ static void mh_sequences_add_one(struct Context *ctx, int n, bool unseen,
   int line = 0;
   size_t sz;
 
-  if (mh_mkstemp(ctx, &nfp, &tmpfname) == -1)
+  if (mh_mkstemp(mailbox, &nfp, &tmpfname) == -1)
     return;
 
   snprintf(seq_unseen, sizeof(seq_unseen), "%s:", NONULL(MhSeqUnseen));
   snprintf(seq_replied, sizeof(seq_replied), "%s:", NONULL(MhSeqReplied));
   snprintf(seq_flagged, sizeof(seq_flagged), "%s:", NONULL(MhSeqFlagged));
 
-  snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->mailbox->path);
+  snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mailbox->path);
   ofp = fopen(sequences, "r");
   if (ofp)
   {
@@ -844,32 +844,32 @@ void maildir_parse_flags(struct Header *h, const char *path)
 
 /**
  * maildir_update_mtime - Update our record of the Maildir modification time
- * @param ctx Mailbox
+ * @param mailbox Mailbox
  */
-static void maildir_update_mtime(struct Context *ctx)
+static void maildir_update_mtime(struct Mailbox *mailbox)
 {
   char buf[PATH_MAX];
   struct stat st;
-  struct MhData *data = mh_data(ctx->mailbox);
+  struct MhData *data = mh_data(mailbox);
 
-  if (ctx->mailbox->magic == MUTT_MAILDIR)
+  if (mailbox->magic == MUTT_MAILDIR)
   {
-    snprintf(buf, sizeof(buf), "%s/%s", ctx->mailbox->path, "cur");
+    snprintf(buf, sizeof(buf), "%s/%s", mailbox->path, "cur");
     if (stat(buf, &st) == 0)
       mutt_get_stat_timespec(&data->mtime_cur, &st, MUTT_STAT_MTIME);
-    snprintf(buf, sizeof(buf), "%s/%s", ctx->mailbox->path, "new");
+    snprintf(buf, sizeof(buf), "%s/%s", mailbox->path, "new");
   }
   else
   {
-    snprintf(buf, sizeof(buf), "%s/.mh_sequences", ctx->mailbox->path);
+    snprintf(buf, sizeof(buf), "%s/.mh_sequences", mailbox->path);
     if (stat(buf, &st) == 0)
       mutt_get_stat_timespec(&data->mtime_cur, &st, MUTT_STAT_MTIME);
 
-    mutt_str_strfcpy(buf, ctx->mailbox->path, sizeof(buf));
+    mutt_str_strfcpy(buf, mailbox->path, sizeof(buf));
   }
 
   if (stat(buf, &st) == 0)
-    mutt_get_stat_timespec(&ctx->mailbox->mtime, &st, MUTT_STAT_MTIME);
+    mutt_get_stat_timespec(&mailbox->mtime, &st, MUTT_STAT_MTIME);
 }
 
 /**
@@ -1041,7 +1041,7 @@ static bool maildir_add_to_context(struct Context *ctx, struct Maildir *md)
                  md->h->flagged ? "f" : "", md->h->deleted ? "D" : "",
                  md->h->replied ? "r" : "", md->h->old ? "O" : "", md->h->read ? "R" : "");
       if (ctx->mailbox->msg_count == ctx->mailbox->hdrmax)
-        mx_alloc_memory(ctx);
+        mx_alloc_memory(ctx->mailbox);
 
       ctx->mailbox->hdrs[ctx->mailbox->msg_count] = md->h;
       ctx->mailbox->hdrs[ctx->mailbox->msg_count]->index = ctx->mailbox->msg_count;
@@ -1454,7 +1454,7 @@ static int mh_read_dir(struct Context *ctx, const char *subdir)
   }
   data = mh_data(ctx->mailbox);
 
-  maildir_update_mtime(ctx);
+  maildir_update_mtime(ctx->mailbox);
 
   md = NULL;
   last = &md;
@@ -1609,9 +1609,9 @@ static int mh_mbox_open_append(struct Context *ctx, int flags)
  *
  * Open a new (temporary) message in an MH folder.
  */
-static int mh_msg_open_new(struct Context *ctx, struct Message *msg, struct Header *hdr)
+static int mh_msg_open_new(struct Context *ctx, struct Message *msg, struct Header *hdr) 
 {
-  return mh_mkstemp(ctx, &msg->fp, &msg->path);
+  return mh_mkstemp(ctx->mailbox, &msg->fp, &msg->path);
 }
 
 /**
@@ -1659,24 +1659,24 @@ void maildir_flags(char *dest, size_t destlen, struct Header *hdr)
 
 /**
  * maildir_mh_open_message - Open a Maildir or MH message
- * @param ctx        Mailbox
+ * @param mailbox    Mailbox
  * @param msg        Message to open
  * @param msgno      Index number
  * @param is_maildir true, if a Maildir
  * @retval  0 Success
  * @retval -1 Failure
  */
-static int maildir_mh_open_message(struct Context *ctx, struct Message *msg,
+static int maildir_mh_open_message(struct Mailbox *mailbox, struct Message *msg,
                                    int msgno, int is_maildir)
 {
-  struct Header *cur = ctx->mailbox->hdrs[msgno];
+  struct Header *cur = mailbox->hdrs[msgno];
   char path[PATH_MAX];
 
-  snprintf(path, sizeof(path), "%s/%s", ctx->mailbox->path, cur->path);
+  snprintf(path, sizeof(path), "%s/%s", mailbox->path, cur->path);
 
   msg->fp = fopen(path, "r");
   if (!msg->fp && (errno == ENOENT) && is_maildir)
-    msg->fp = maildir_open_find_message(ctx->mailbox->path, cur->path, NULL);
+    msg->fp = maildir_open_find_message(mailbox->path, cur->path, NULL);
 
   if (!msg->fp)
   {
@@ -1693,7 +1693,7 @@ static int maildir_mh_open_message(struct Context *ctx, struct Message *msg,
  */
 static int maildir_msg_open(struct Context *ctx, struct Message *msg, int msgno)
 {
-  return maildir_mh_open_message(ctx, msg, msgno, 1);
+  return maildir_mh_open_message(ctx->mailbox, msg, msgno, 1);
 }
 
 /**
@@ -1701,7 +1701,7 @@ static int maildir_msg_open(struct Context *ctx, struct Message *msg, int msgno)
  */
 static int mh_msg_open(struct Context *ctx, struct Message *msg, int msgno)
 {
-  return maildir_mh_open_message(ctx, msg, msgno, 0);
+  return maildir_mh_open_message(ctx->mailbox, msg, msgno, 0);
 }
 
 /**
@@ -1793,16 +1793,16 @@ static int maildir_msg_open_new(struct Context *ctx, struct Message *msg, struct
 
 /**
  * md_commit_message - Commit a message to a maildir folder
- * @param ctx Mailbox
- * @param msg Message to commit
- * @param hdr Header of the email
+ * @param mailbox Mailbox
+ * @param msg     Message to commit
+ * @param hdr     Header of the email
  * @retval  0 Success
  * @retval -1 Failure
  *
  * msg->path contains the file name of a file in tmp/. We take the
  * flags from this file's name.
  *
- * ctx is the mail folder we commit to.
+ * mailbox is the mail folder we commit to.
  *
  * hdr is a header structure to which we write the message's new
  * file name.  This is used in the mh and maildir folder synch
@@ -1815,7 +1815,7 @@ static int maildir_msg_open_new(struct Context *ctx, struct Message *msg, struct
  *
  * See also maildir_msg_open_new().
  */
-static int md_commit_message(struct Context *ctx, struct Message *msg, struct Header *hdr)
+static int md_commit_message(struct Mailbox *mailbox, struct Message *msg, struct Header *hdr)
 {
   char subdir[4];
   char suffix[16];
@@ -1845,7 +1845,7 @@ static int md_commit_message(struct Context *ctx, struct Message *msg, struct He
   {
     snprintf(path, sizeof(path), "%s/%lld.R%" PRIu64 ".%s%s", subdir,
              (long long) time(NULL), mutt_rand64(), NONULL(ShortHostname), suffix);
-    snprintf(full, sizeof(full), "%s/%s", ctx->mailbox->path, path);
+    snprintf(full, sizeof(full), "%s/%s", mailbox->path, path);
 
     mutt_debug(2, "renaming %s to %s.\n", msg->path, full);
 
@@ -1870,8 +1870,8 @@ static int md_commit_message(struct Context *ctx, struct Message *msg, struct He
       }
 
 #ifdef USE_NOTMUCH
-      if (ctx->mailbox->magic == MUTT_NOTMUCH)
-        nm_update_filename(ctx, hdr->path, full, hdr);
+      if (mailbox->magic == MUTT_NOTMUCH)
+        nm_update_filename(mailbox, hdr->path, full, hdr);
 #endif
       if (hdr)
         mutt_str_replace(&hdr->path, path);
@@ -1885,7 +1885,7 @@ static int md_commit_message(struct Context *ctx, struct Message *msg, struct He
     }
     else if (errno != EEXIST)
     {
-      mutt_perror(ctx->mailbox->path);
+      mutt_perror(mailbox->path);
       return -1;
     }
   }
@@ -1896,19 +1896,19 @@ static int md_commit_message(struct Context *ctx, struct Message *msg, struct He
  */
 static int maildir_msg_commit(struct Context *ctx, struct Message *msg)
 {
-  return md_commit_message(ctx, msg, NULL);
+  return md_commit_message(ctx->mailbox, msg, NULL);
 }
 
 /**
  * mh_commit_msg - Commit a message to an MH folder
- * @param ctx    Mailbox
- * @param msg    Message to commit
- * @param hdr    Email Header
- * @param updseq If true, update the sequence number
+ * @param mailbox Mailbox
+ * @param msg     Message to commit
+ * @param hdr     Email Header
+ * @param updseq  If true, update the sequence number
  * @retval  0 Success
  * @retval -1 Failure
  */
-static int mh_commit_msg(struct Context *ctx, struct Message *msg,
+static int mh_commit_msg(struct Mailbox *mailbox, struct Message *msg,
                          struct Header *hdr, bool updseq)
 {
   DIR *dirp = NULL;
@@ -1924,10 +1924,10 @@ static int mh_commit_msg(struct Context *ctx, struct Message *msg,
     return -1;
   }
 
-  dirp = opendir(ctx->mailbox->path);
+  dirp = opendir(mailbox->path);
   if (!dirp)
   {
-    mutt_perror(ctx->mailbox->path);
+    mutt_perror(mailbox->path);
     return -1;
   }
 
@@ -1962,7 +1962,7 @@ static int mh_commit_msg(struct Context *ctx, struct Message *msg,
   {
     hi++;
     snprintf(tmp, sizeof(tmp), "%u", hi);
-    snprintf(path, sizeof(path), "%s/%s", ctx->mailbox->path, tmp);
+    snprintf(path, sizeof(path), "%s/%s", mailbox->path, tmp);
     if (mutt_file_safe_rename(msg->path, path) == 0)
     {
       if (hdr)
@@ -1973,13 +1973,13 @@ static int mh_commit_msg(struct Context *ctx, struct Message *msg,
     }
     else if (errno != EEXIST)
     {
-      mutt_perror(ctx->mailbox->path);
+      mutt_perror(mailbox->path);
       return -1;
     }
   }
   if (updseq)
   {
-    mh_sequences_add_one(ctx, hi, !msg->flags.read, msg->flags.flagged,
+    mh_sequences_add_one(mailbox, hi, !msg->flags.read, msg->flags.flagged,
                          msg->flags.replied);
   }
   return 0;
@@ -1990,7 +1990,7 @@ static int mh_commit_msg(struct Context *ctx, struct Message *msg,
  */
 static int mh_msg_commit(struct Context *ctx, struct Message *msg)
 {
-  return mh_commit_msg(ctx, msg, NULL, true);
+  return mh_commit_msg(ctx->mailbox, msg, NULL, true);
 }
 
 /**
@@ -2024,9 +2024,9 @@ static int mh_rewrite_message(struct Context *ctx, int msgno)
     mutt_str_strfcpy(partpath, h->path, sizeof(partpath));
 
     if (ctx->mailbox->magic == MUTT_MAILDIR)
-      rc = md_commit_message(ctx, dest, h);
+      rc = md_commit_message(ctx->mailbox, dest, h);
     else
-      rc = mh_commit_msg(ctx, dest, h, false);
+      rc = mh_commit_msg(ctx->mailbox, dest, h, false);
 
     mx_msg_close(ctx, &dest);
 
@@ -2511,7 +2511,7 @@ static int mh_mbox_check(struct Context *ctx, int *index_hint)
     char *tmp = NULL;
     FILE *fp = NULL;
 
-    if (mh_mkstemp(ctx, &fp, &tmp) == 0)
+    if (mh_mkstemp(ctx->mailbox, &fp, &tmp) == 0)
     {
       mutt_file_fclose(&fp);
       if (mutt_file_safe_rename(tmp, buf) == -1)
@@ -2660,11 +2660,11 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint)
 #endif
 
   if (ctx->mailbox->magic == MUTT_MH)
-    mh_update_sequences(ctx);
+    mh_update_sequences(ctx->mailbox);
 
   /* XXX race condition? */
 
-  maildir_update_mtime(ctx);
+  maildir_update_mtime(ctx->mailbox);
 
   /* adjust indices */
 
diff --git a/main.c b/main.c
index 4482a37c593dd8a67822a3acfee024d6eeb0c3ba..44676b764d9cebffc09d15ddef71c5f4fb0b52de 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1145,7 +1145,7 @@ int main(int argc, char *argv[], char *envp[])
       if (flags & MUTT_NEWS)
       {
         OptNews = true;
-        CurrentNewsSrv = nntp_select_server(Context, NewsServer, false);
+        CurrentNewsSrv = nntp_select_server(Context->mailbox, NewsServer, false);
         if (!CurrentNewsSrv)
           goto main_curses; // TEST38: neomutt -G (unset news_server)
       }
index e954cdc86ef8c2f9ed812ca36c281fcc68dac985..dc2a3e8b11e5412d9fda8c96c19df5b0f0cb868c 100644 (file)
@@ -125,28 +125,28 @@ static int init_mailbox(struct Mailbox *mailbox)
 
 /**
  * get_mboxdata - Get the private data associated with a Mailbox
- * @param ctx Mailbox
+ * @param mailbox Mailbox
  * @retval ptr Private data
  */
-struct MboxData *get_mboxdata(struct Context *ctx)
+struct MboxData *get_mboxdata(struct Mailbox *mailbox)
 {
-  if (ctx && ctx->mailbox && (ctx->mailbox->magic == MUTT_MBOX))
-    return ctx->mailbox->data;
+  if (mailbox && (mailbox->magic == MUTT_MBOX))
+    return mailbox->data;
 
   return NULL;
 }
 
 /**
  * mbox_lock_mailbox - Lock a mailbox
- * @param ctx   Mailbox to lock
+ * @param mailbox   Mailbox to lock
  * @param excl  Exclusive lock?
  * @param retry Should retry if unable to lock?
  * @retval  0 Success
  * @retval -1 Failure
  */
-static int mbox_lock_mailbox(struct Context *ctx, int excl, int retry)
+static int mbox_lock_mailbox(struct Mailbox *mailbox, bool excl, bool retry)
 {
-  struct MboxData *mdata = get_mboxdata(ctx);
+  struct MboxData *mdata = get_mboxdata(mailbox);
   if (!mdata)
     return -1;
 
@@ -155,7 +155,7 @@ static int mbox_lock_mailbox(struct Context *ctx, int excl, int retry)
     mdata->locked = true;
   else if (retry && !excl)
   {
-    ctx->mailbox->readonly = true;
+    mailbox->readonly = true;
     return 0;
   }
 
@@ -164,11 +164,11 @@ static int mbox_lock_mailbox(struct Context *ctx, int excl, int retry)
 
 /**
  * mbox_unlock_mailbox - Unlock a mailbox
- * @param ctx Mailbox to unlock
+ * @param mailbox Mailbox to unlock
  */
-static void mbox_unlock_mailbox(struct Context *ctx)
+static void mbox_unlock_mailbox(struct Mailbox *mailbox)
 {
-  struct MboxData *mdata = get_mboxdata(ctx);
+  struct MboxData *mdata = get_mboxdata(mailbox);
   if (!mdata)
     return;
 
@@ -190,7 +190,7 @@ static void mbox_unlock_mailbox(struct Context *ctx)
  */
 static int mmdf_parse_mailbox(struct Context *ctx)
 {
-  struct MboxData *mdata = get_mboxdata(ctx);
+  struct MboxData *mdata = get_mboxdata(ctx->mailbox);
   if (!mdata)
     return -1;
 
@@ -242,7 +242,7 @@ static int mmdf_parse_mailbox(struct Context *ctx)
                              (int) (loc / (ctx->mailbox->size / 100 + 1)));
 
       if (ctx->mailbox->msg_count == ctx->mailbox->hdrmax)
-        mx_alloc_memory(ctx);
+        mx_alloc_memory(ctx->mailbox);
       hdr = mutt_header_new();
       ctx->mailbox->hdrs[ctx->mailbox->msg_count] = hdr;
       hdr->offset = loc;
@@ -356,7 +356,7 @@ static int mmdf_parse_mailbox(struct Context *ctx)
  */
 static int mbox_parse_mailbox(struct Context *ctx)
 {
-  struct MboxData *mdata = get_mboxdata(ctx);
+  struct MboxData *mdata = get_mboxdata(ctx->mailbox);
   if (!mdata)
     return -1;
 
@@ -417,7 +417,7 @@ static int mbox_parse_mailbox(struct Context *ctx)
       }
 
       if (ctx->mailbox->msg_count == ctx->mailbox->hdrmax)
-        mx_alloc_memory(ctx);
+        mx_alloc_memory(ctx->mailbox);
 
       ctx->mailbox->hdrs[ctx->mailbox->msg_count] = mutt_header_new();
       curhdr = ctx->mailbox->hdrs[ctx->mailbox->msg_count];
@@ -556,7 +556,7 @@ static int mbox_mbox_open(struct Context *ctx)
   if (init_mailbox(mailbox) != 0)
     return -1;
 
-  struct MboxData *mdata = get_mboxdata(ctx);
+  struct MboxData *mdata = get_mboxdata(mailbox);
   if (!mdata)
     return -1;
 
@@ -567,7 +567,7 @@ static int mbox_mbox_open(struct Context *ctx)
     return -1;
   }
   mutt_sig_block();
-  if (mbox_lock_mailbox(ctx, 0, 1) == -1)
+  if (mbox_lock_mailbox(mailbox, false, true) == -1)
   {
     mutt_sig_unblock();
     return -1;
@@ -582,7 +582,7 @@ static int mbox_mbox_open(struct Context *ctx)
     rc = -1;
   mutt_file_touch_atime(fileno(mdata->fp));
 
-  mbox_unlock_mailbox(ctx);
+  mbox_unlock_mailbox(mailbox);
   mutt_sig_unblock();
   return rc;
 }
@@ -597,7 +597,7 @@ static int mbox_mbox_open_append(struct Context *ctx, int flags)
   if (init_mailbox(mailbox) != 0)
     return -1;
 
-  struct MboxData *mdata = get_mboxdata(ctx);
+  struct MboxData *mdata = get_mboxdata(mailbox);
   if (!mdata)
     return -1;
 
@@ -608,7 +608,7 @@ static int mbox_mbox_open_append(struct Context *ctx, int flags)
     return -1;
   }
 
-  if (mbox_lock_mailbox(ctx, 1, 1) != 0)
+  if (mbox_lock_mailbox(mailbox, true, true) != false)
   {
     mutt_error(_("Couldn't lock %s"), mailbox->path);
     mutt_file_fclose(&mdata->fp);
@@ -626,7 +626,7 @@ static int mbox_mbox_open_append(struct Context *ctx, int flags)
  */
 static int mbox_mbox_close(struct Context *ctx)
 {
-  struct MboxData *mdata = get_mboxdata(ctx);
+  struct MboxData *mdata = get_mboxdata(ctx->mailbox);
   if (!mdata)
     return -1;
 
@@ -666,7 +666,7 @@ static int mbox_mbox_close(struct Context *ctx)
  */
 static int mbox_msg_open(struct Context *ctx, struct Message *msg, int msgno)
 {
-  struct MboxData *mdata = get_mboxdata(ctx);
+  struct MboxData *mdata = get_mboxdata(ctx->mailbox);
   if (!mdata)
     return -1;
 
@@ -726,7 +726,7 @@ static int mmdf_msg_commit(struct Context *ctx, struct Message *msg)
  */
 static int mbox_msg_open_new(struct Context *ctx, struct Message *msg, struct Header *hdr)
 {
-  struct MboxData *mdata = get_mboxdata(ctx);
+  struct MboxData *mdata = get_mboxdata(ctx->mailbox);
   if (!mdata)
     return -1;
 
@@ -763,7 +763,7 @@ static int mmdf_msg_padding_size(struct Context *ctx)
  */
 static int reopen_mailbox(struct Context *ctx, int *index_hint)
 {
-  struct MboxData *mdata = get_mboxdata(ctx);
+  struct MboxData *mdata = get_mboxdata(ctx->mailbox);
   if (!mdata)
     return -1;
 
@@ -827,7 +827,7 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint)
   ctx->mailbox->changed = false;
   ctx->mailbox->id_hash = NULL;
   ctx->mailbox->subj_hash = NULL;
-  mutt_make_label_hash(ctx);
+  mutt_make_label_hash(ctx->mailbox);
 
   switch (ctx->mailbox->magic)
   {
@@ -955,7 +955,7 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint)
  */
 static int mbox_mbox_check(struct Context *ctx, int *index_hint)
 {
-  struct MboxData *mdata = get_mboxdata(ctx);
+  struct MboxData *mdata = get_mboxdata(ctx->mailbox);
   if (!mdata)
     return -1;
 
@@ -984,7 +984,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint)
       if (!mdata->locked)
       {
         mutt_sig_block();
-        if (mbox_lock_mailbox(ctx, 0, 0) == -1)
+        if (mbox_lock_mailbox(ctx->mailbox, false, false) == -1)
         {
           mutt_sig_unblock();
           /* we couldn't lock the mailbox, but nothing serious happened:
@@ -1023,7 +1023,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint)
 
           if (unlock)
           {
-            mbox_unlock_mailbox(ctx);
+            mbox_unlock_mailbox(ctx->mailbox);
             mutt_sig_unblock();
           }
 
@@ -1048,7 +1048,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint)
     {
       if (unlock)
       {
-        mbox_unlock_mailbox(ctx);
+        mbox_unlock_mailbox(ctx->mailbox);
         mutt_sig_unblock();
       }
       return MUTT_REOPENED;
@@ -1057,7 +1057,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint)
 
   /* fatal error */
 
-  mbox_unlock_mailbox(ctx);
+  mbox_unlock_mailbox(ctx->mailbox);
   mx_fastclose_mailbox(ctx);
   mutt_sig_unblock();
   mutt_error(_("Mailbox was corrupted"));
@@ -1118,7 +1118,7 @@ void mbox_reset_atime(struct Mailbox *mailbox, struct stat *st)
  */
 static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
 {
-  struct MboxData *mdata = get_mboxdata(ctx);
+  struct MboxData *mdata = get_mboxdata(ctx->mailbox);
   if (!mdata)
     return -1;
 
@@ -1160,7 +1160,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
 
   mutt_sig_block();
 
-  if (mbox_lock_mailbox(ctx, 1, 1) == -1)
+  if (mbox_lock_mailbox(ctx->mailbox, true, true) == -1)
   {
     mutt_sig_unblock();
     mutt_error(_("Unable to lock mailbox"));
@@ -1385,7 +1385,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
 
   mutt_file_fclose(&fp);
   fp = NULL;
-  mbox_unlock_mailbox(ctx);
+  mbox_unlock_mailbox(ctx->mailbox);
 
   if (mutt_file_fclose(&mdata->fp) != 0 || i == -1)
   {
@@ -1466,7 +1466,7 @@ bail: /* Come here in case of disaster */
   }
 
   /* this is ok to call even if we haven't locked anything */
-  mbox_unlock_mailbox(ctx);
+  mbox_unlock_mailbox(ctx->mailbox);
 
   mutt_sig_unblock();
   FREE(&new_offset);
index 25ee723c4b1f98c61df7ac25d98d28273354d354..17134eb9db2e34c4c839f0f28c2ccdef29aab9a9 100644 (file)
 
 /**
  * label_ref_dec - Decrease the refcount of a label
- * @param ctx   Mailbox
+ * @param mailbox   Mailbox
  * @param label Label
  */
-static void label_ref_dec(struct Context *ctx, char *label)
+static void label_ref_dec(struct Mailbox *mailbox, char *label)
 {
-  struct HashElem *elem = mutt_hash_find_elem(ctx->mailbox->label_hash, label);
+  struct HashElem *elem = mutt_hash_find_elem(mailbox->label_hash, label);
   if (!elem)
     return;
 
   uintptr_t count = (uintptr_t) elem->data;
   if (count <= 1)
   {
-    mutt_hash_delete(ctx->mailbox->label_hash, label, NULL);
+    mutt_hash_delete(mailbox->label_hash, label, NULL);
     return;
   }
 
@@ -66,18 +66,18 @@ static void label_ref_dec(struct Context *ctx, char *label)
 
 /**
  * label_ref_inc - Increase the refcount of a label
- * @param ctx   Mailbox
+ * @param mailbox   Mailbox
  * @param label Label
  */
-static void label_ref_inc(struct Context *ctx, char *label)
+static void label_ref_inc(struct Mailbox *mailbox, char *label)
 {
   uintptr_t count;
 
-  struct HashElem *elem = mutt_hash_find_elem(ctx->mailbox->label_hash, label);
+  struct HashElem *elem = mutt_hash_find_elem(mailbox->label_hash, label);
   if (!elem)
   {
     count = 1;
-    mutt_hash_insert(ctx->mailbox->label_hash, label, (void *) count);
+    mutt_hash_insert(mailbox->label_hash, label, (void *) count);
     return;
   }
 
@@ -88,12 +88,12 @@ static void label_ref_inc(struct Context *ctx, char *label)
 
 /**
  * label_message - add an X-Label: field
- * @param[in]  ctx Mailbox
+ * @param[in]  mailbox Mailbox
  * @param[in]  hdr Header of email
  * @param[out] new Set to true if this is a new label
  * @retval true If the label was added
  */
-static bool label_message(struct Context *ctx, struct Header *hdr, char *new)
+static bool label_message(struct Mailbox *mailbox, struct Header *hdr, char *new)
 {
   if (!hdr)
     return false;
@@ -101,10 +101,10 @@ static bool label_message(struct Context *ctx, struct Header *hdr, char *new)
     return false;
 
   if (hdr->env->x_label)
-    label_ref_dec(ctx, hdr->env->x_label);
+    label_ref_dec(mailbox, hdr->env->x_label);
   mutt_str_replace(&hdr->env->x_label, new);
   if (hdr->env->x_label)
-    label_ref_inc(ctx, hdr->env->x_label);
+    label_ref_inc(mailbox, hdr->env->x_label);
 
   hdr->changed = true;
   hdr->xlabel_changed = true;
@@ -143,7 +143,7 @@ int mutt_label_message(struct Header *hdr)
   changed = 0;
   if (hdr)
   {
-    if (label_message(Context, hdr, new))
+    if (label_message(Context->mailbox, hdr, new))
     {
       changed++;
       mutt_set_header_color(Context, hdr);
@@ -157,7 +157,7 @@ int mutt_label_message(struct Header *hdr)
         continue;
 
       struct Header *h = Context->mailbox->hdrs[i];
-      if (label_message(Context, h, new))
+      if (label_message(Context->mailbox, h, new))
       {
         changed++;
         mutt_set_flag(Context, h, MUTT_TAG, 0);
@@ -365,38 +365,38 @@ void mutt_edit_headers(const char *editor, const char *body, struct Header *msg,
 
 /**
  * mutt_make_label_hash - Create a Hash Table to store the labels
- * @param ctx Mailbox
+ * @param mailbox Mailbox
  */
-void mutt_make_label_hash(struct Context *ctx)
+void mutt_make_label_hash(struct Mailbox *mailbox)
 {
   /* 131 is just a rough prime estimate of how many distinct
    * labels someone might have in a mailbox.
    */
-  ctx->mailbox->label_hash = mutt_hash_create(131, MUTT_HASH_STRDUP_KEYS);
+  mailbox->label_hash = mutt_hash_create(131, MUTT_HASH_STRDUP_KEYS);
 }
 
 /**
  * mutt_label_hash_add - Add a message's labels to the Hash Table
- * @param ctx Mailbox
+ * @param mailbox Mailbox
  * @param hdr Header of message
  */
-void mutt_label_hash_add(struct Context *ctx, struct Header *hdr)
+void mutt_label_hash_add(struct Mailbox *mailbox, struct Header *hdr)
 {
-  if (!ctx || !ctx->mailbox->label_hash)
+  if (!mailbox || !mailbox->label_hash)
     return;
   if (hdr->env->x_label)
-    label_ref_inc(ctx, hdr->env->x_label);
+    label_ref_inc(mailbox, hdr->env->x_label);
 }
 
 /**
  * mutt_label_hash_remove - Rmove a message's labels from the Hash Table
- * @param ctx Mailbox
+ * @param mailbox Mailbox
  * @param hdr Header of message
  */
-void mutt_label_hash_remove(struct Context *ctx, struct Header *hdr)
+void mutt_label_hash_remove(struct Mailbox *mailbox, struct Header *hdr)
 {
-  if (!ctx || !ctx->mailbox->label_hash)
+  if (!mailbox || !mailbox->label_hash)
     return;
   if (hdr->env->x_label)
-    label_ref_dec(ctx, hdr->env->x_label);
+    label_ref_dec(mailbox, hdr->env->x_label);
 }
index 07bcb7626d9054264de0258de85b2c325cffeb1a..34356833b2057afece84a91f5053f28e901d4cd6 100644 (file)
@@ -29,9 +29,9 @@ struct Context;
 struct Header;
 
 void mutt_edit_headers(const char *editor, const char *body, struct Header *msg, char *fcc, size_t fcclen);
-void mutt_label_hash_add(struct Context *ctx, struct Header *hdr);
-void mutt_label_hash_remove(struct Context *ctx, struct Header *hdr);
+void mutt_label_hash_add(struct Mailbox *mailbox, struct Header *hdr);
+void mutt_label_hash_remove(struct Mailbox *mailbox, struct Header *hdr);
 int  mutt_label_message(struct Header *hdr);
-void mutt_make_label_hash(struct Context *ctx);
+void mutt_make_label_hash(struct Mailbox *mailbox);
 
 #endif /* MUTT_MUTT_HEADER_H */
index 8def2f0bc82c172f7a48ab1c96fb209252523539..3e3eddbbdfda98ba9ffd3acb3b03451878fe308c 100644 (file)
@@ -1391,16 +1391,16 @@ int mutt_messages_in_thread(struct Context *ctx, struct Header *hdr, int flag)
 
 /**
  * mutt_make_id_hash - Create a Hash Table for message-ids
- * @param ctx Mailbox
+ * @param mailbox Mailbox
  * @retval ptr Newly allocated Hash Table
  */
-struct Hash *mutt_make_id_hash(struct Context *ctx)
+struct Hash *mutt_make_id_hash(struct Mailbox *mailbox)
 {
-  struct Hash *hash = mutt_hash_create(ctx->mailbox->msg_count * 2, 0);
+  struct Hash *hash = mutt_hash_create(mailbox->msg_count * 2, 0);
 
-  for (int i = 0; i < ctx->mailbox->msg_count; i++)
+  for (int i = 0; i < mailbox->msg_count; i++)
   {
-    struct Header *hdr = ctx->mailbox->hdrs[i];
+    struct Header *hdr = mailbox->hdrs[i];
     if (hdr->env->message_id)
       mutt_hash_insert(hash, hdr->env->message_id, hdr);
   }
index 16fb047088168ddb3d576d4130e7737e2874a567..a4d953dd0d495ccfb5444895dd4d0b5263eaa955 100644 (file)
@@ -72,6 +72,6 @@ struct MuttThread *mutt_sort_subthreads(struct MuttThread *thread, bool init);
 void mutt_sort_threads(struct Context *ctx, bool init);
 int mutt_parent_message(struct Context *ctx, struct Header *hdr, bool find_root);
 void mutt_set_virtual(struct Context *ctx);
-struct Hash *mutt_make_id_hash(struct Context *ctx);
+struct Hash *mutt_make_id_hash(struct Mailbox *mailbox);
 
 #endif /* MUTT_MUTT_THREAD_H */
diff --git a/mx.c b/mx.c
index ccc93fac442693f5bbf336b1cc26a891b90aa488..87cf00a3a8c3caa766009347959a9785c6c83219 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -300,7 +300,7 @@ struct Context *mx_mbox_open(const char *path, int flags)
     return NULL;
   }
 
-  mutt_make_label_hash(ctx);
+  mutt_make_label_hash(ctx->mailbox);
 
   /* if the user has a `push' command in their .neomuttrc, or in a folder-hook,
    * it will cause the progress messages not to be displayed because
@@ -850,7 +850,7 @@ void mx_update_tables(struct Context *ctx, bool committing)
       if (ctx->mailbox->id_hash && ctx->mailbox->hdrs[i]->env->message_id)
         mutt_hash_delete(ctx->mailbox->id_hash, ctx->mailbox->hdrs[i]->env->message_id,
                          ctx->mailbox->hdrs[i]);
-      mutt_label_hash_remove(ctx, ctx->mailbox->hdrs[i]);
+      mutt_label_hash_remove(ctx->mailbox, ctx->mailbox->hdrs[i]);
       /* The path mx_mbox_check() -> imap_check_mailbox() ->
        *          imap_expunge_mailbox() -> mx_update_tables()
        * can occur before a call to mx_mbox_sync(), resulting in
@@ -1150,34 +1150,32 @@ int mx_msg_close(struct Context *ctx, struct Message **msg)
 
 /**
  * mx_alloc_memory - Create storage for the emails
- * @param ctx Mailbox
+ * @param mailbox Mailbox
  */
-void mx_alloc_memory(struct Context *ctx)
+void mx_alloc_memory(struct Mailbox *mailbox)
 {
   size_t s = MAX(sizeof(struct Header *), sizeof(int));
 
-  if ((ctx->mailbox->hdrmax + 25) * s < ctx->mailbox->hdrmax * s)
+  if ((mailbox->hdrmax + 25) * s < mailbox->hdrmax * s)
   {
     mutt_error(_("Out of memory"));
     mutt_exit(1);
   }
 
-  if (ctx->mailbox->hdrs)
+  if (mailbox->hdrs)
   {
-    mutt_mem_realloc(&ctx->mailbox->hdrs,
-                     sizeof(struct Header *) * (ctx->mailbox->hdrmax += 25));
-    mutt_mem_realloc(&ctx->mailbox->v2r, sizeof(int) * ctx->mailbox->hdrmax);
+    mutt_mem_realloc(&mailbox->hdrs, sizeof(struct Header *) * (mailbox->hdrmax += 25));
+    mutt_mem_realloc(&mailbox->v2r, sizeof(int) * mailbox->hdrmax);
   }
   else
   {
-    ctx->mailbox->hdrs =
-        mutt_mem_calloc((ctx->mailbox->hdrmax += 25), sizeof(struct Header *));
-    ctx->mailbox->v2r = mutt_mem_calloc(ctx->mailbox->hdrmax, sizeof(int));
+    mailbox->hdrs = mutt_mem_calloc((mailbox->hdrmax += 25), sizeof(struct Header *));
+    mailbox->v2r = mutt_mem_calloc(mailbox->hdrmax, sizeof(int));
   }
-  for (int i = ctx->mailbox->msg_count; i < ctx->mailbox->hdrmax; i++)
+  for (int i = mailbox->msg_count; i < mailbox->hdrmax; i++)
   {
-    ctx->mailbox->hdrs[i] = NULL;
-    ctx->mailbox->v2r[i] = -1;
+    mailbox->hdrs[i] = NULL;
+    mailbox->v2r[i] = -1;
   }
 }
 
@@ -1217,7 +1215,7 @@ void mx_update_context(struct Context *ctx, int new_messages)
       struct Header *h2 = NULL;
 
       if (!ctx->mailbox->id_hash)
-        ctx->mailbox->id_hash = mutt_make_id_hash(ctx);
+        ctx->mailbox->id_hash = mutt_make_id_hash(ctx->mailbox);
 
       h2 = mutt_hash_find(ctx->mailbox->id_hash, h->env->supersedes);
       if (h2)
@@ -1233,7 +1231,7 @@ void mx_update_context(struct Context *ctx, int new_messages)
       mutt_hash_insert(ctx->mailbox->id_hash, h->env->message_id, h);
     if (ctx->mailbox->subj_hash && h->env->real_subj)
       mutt_hash_insert(ctx->mailbox->subj_hash, h->env->real_subj, h);
-    mutt_label_hash_add(ctx, h);
+    mutt_label_hash_add(ctx->mailbox, h);
 
     if (Score)
       mutt_score_message(ctx, h, false);
diff --git a/mx.h b/mx.h
index 861da8cde21cf433a796d11ecaac8a2596c67468..d3fbae7e404341dd699203ed166e21f26a7a2be8 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -251,7 +251,7 @@ int             mx_tags_commit     (struct Context *ctx, struct Header *hdr, cha
 int             mx_tags_edit       (struct Context *ctx, const char *tags, char *buf, size_t buflen);
 
 int                 mx_access(const char *path, int flags);
-void                mx_alloc_memory(struct Context *ctx);
+void                mx_alloc_memory(struct Mailbox *mailbox);
 int                 mx_check_empty(const char *path);
 int                 mx_check_mailbox(struct Context *ctx, int *index_hint);
 void                mx_fastclose_mailbox(struct Context *ctx);
index 86c318081346e9e4060b2c3031332a16c8cc9d0d..5d180735b3a4fbab7220c922f7bd37d6a6a4958a 100644 (file)
@@ -999,7 +999,7 @@ const char *nntp_format_str(char *buf, size_t buflen, size_t col, int cols, char
 
 /**
  * nntp_select_server - Open a connection to an NNTP server
- * @param ctx        Mailbox
+ * @param mailbox    Mailbox
  * @param server     Server URI
  * @param leave_lock Leave the server locked?
  * @retval ptr  NNTP server
@@ -1010,7 +1010,7 @@ const char *nntp_format_str(char *buf, size_t buflen, size_t col, int cols, char
  * system has broken mtimes, this might mean the file is reloaded every time,
  * which we'd have to fix.
  */
-struct NntpServer *nntp_select_server(struct Context *ctx, char *server, bool leave_lock)
+struct NntpServer *nntp_select_server(struct Mailbox *mailbox, char *server, bool leave_lock)
 {
   char file[PATH_MAX];
 #ifdef USE_HCACHE
@@ -1073,7 +1073,7 @@ struct NntpServer *nntp_select_server(struct Context *ctx, char *server, bool le
       return NULL;
 
     /* check for new newsgroups */
-    if (!leave_lock && nntp_check_new_groups(ctx->mailbox, nserv) < 0)
+    if (!leave_lock && nntp_check_new_groups(mailbox, nserv) < 0)
       rc = -1;
 
     /* .newsrc has been externally modified */
@@ -1119,7 +1119,7 @@ struct NntpServer *nntp_select_server(struct Context *ctx, char *server, bool le
   {
     /* try to load list of newsgroups from cache */
     if (nserv->cacheable && active_get_cache(nserv) == 0)
-      rc = nntp_check_new_groups(ctx->mailbox, nserv);
+      rc = nntp_check_new_groups(mailbox, nserv);
 
     /* load list of newsgroups from server */
     else
index 1d6898785b7443d9d664a60333e239877166b2a9..321aa2f044d38202b2aa054dc903dde11a15034f 100644 (file)
@@ -1186,7 +1186,7 @@ static int parse_overview_line(char *line, void *data)
 
   /* allocate memory for headers */
   if (ctx->mailbox->msg_count >= ctx->mailbox->hdrmax)
-    mx_alloc_memory(ctx);
+    mx_alloc_memory(ctx->mailbox);
 
   /* parse header */
   ctx->mailbox->hdrs[ctx->mailbox->msg_count] = mutt_header_new();
@@ -1370,7 +1370,7 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first,
 
     /* allocate memory for headers */
     if (ctx->mailbox->msg_count >= ctx->mailbox->hdrmax)
-      mx_alloc_memory(ctx);
+      mx_alloc_memory(ctx->mailbox);
 
 #ifdef USE_HCACHE
     /* try to fetch header from cache */
@@ -1531,7 +1531,7 @@ static int nntp_mbox_open(struct Context *ctx)
   group = url.path;
   url.path = strchr(url.path, '\0');
   url_tostring(&url, server, sizeof(server), 0);
-  nserv = nntp_select_server(ctx, server, true);
+  nserv = nntp_select_server(ctx->mailbox, server, true);
   url_free(&url);
   if (!nserv)
     return -1;
@@ -1775,22 +1775,22 @@ static int nntp_msg_close(struct Context *ctx, struct Message *msg)
 
 /**
  * nntp_post - Post article
- * @param ctx Mailbox
- * @param msg Message to post
+ * @param mailbox Mailbox
+ * @param msg     Message to post
  * @retval  0 Success
  * @retval -1 Failure
  */
-int nntp_post(struct Context *ctx, const char *msg)
+int nntp_post(struct Mailbox *mailbox, const char *msg)
 {
   struct NntpData *nntp_data = NULL;
   struct NntpData nntp_tmp = { 0 };
   char buf[LONG_STRING];
 
-  if (ctx && (ctx->mailbox->magic == MUTT_NNTP))
-    nntp_data = ctx->mailbox->data;
+  if (mailbox && (mailbox->magic == MUTT_NNTP))
+    nntp_data = mailbox->data;
   else
   {
-    CurrentNewsSrv = nntp_select_server(ctx, NewsServer, false);
+    CurrentNewsSrv = nntp_select_server(mailbox, NewsServer, false);
     if (!CurrentNewsSrv)
       return -1;
 
@@ -2037,7 +2037,7 @@ static int check_mailbox(struct Context *ctx)
       {
         mutt_debug(2, "#2 mutt_hcache_fetch %s\n", buf);
         if (ctx->mailbox->msg_count >= ctx->mailbox->hdrmax)
-          mx_alloc_memory(ctx);
+          mx_alloc_memory(ctx->mailbox);
 
         hdr = mutt_hcache_restore(hdata);
         ctx->mailbox->hdrs[ctx->mailbox->msg_count] = hdr;
@@ -2479,7 +2479,7 @@ int nntp_check_msgid(struct Context *ctx, const char *msgid)
 
   /* parse header */
   if (ctx->mailbox->msg_count == ctx->mailbox->hdrmax)
-    mx_alloc_memory(ctx);
+    mx_alloc_memory(ctx->mailbox);
   ctx->mailbox->hdrs[ctx->mailbox->msg_count] = mutt_header_new();
   struct Header *hdr = ctx->mailbox->hdrs[ctx->mailbox->msg_count];
   hdr->data = mutt_mem_calloc(1, sizeof(struct NntpHeaderData));
index 18f20ea55eed275487b95516145d97d0e990054e..baed3deb8df2e5b6c1a47dcf2296186ed9b1ef2f 100644 (file)
@@ -150,14 +150,14 @@ struct NntpData
   struct BodyCache *bcache;
 };
 
-struct NntpServer *nntp_select_server(struct Context *ctx, char *server, bool leave_lock);
+struct NntpServer *nntp_select_server(struct Mailbox *mailbox, char *server, bool leave_lock);
 struct NntpData *mutt_newsgroup_subscribe(struct NntpServer *nserv, char *group);
 struct NntpData *mutt_newsgroup_unsubscribe(struct NntpServer *nserv, char *group);
 struct NntpData *mutt_newsgroup_catchup(struct Context *ctx, struct NntpServer *nserv, char *group);
 struct NntpData *mutt_newsgroup_uncatchup(struct Context *ctx, struct NntpServer *nserv, char *group);
 int nntp_active_fetch(struct NntpServer *nserv, bool new);
 int nntp_newsrc_update(struct NntpServer *nserv);
-int nntp_post(struct Context *ctx, const char *msg);
+int nntp_post(struct Mailbox *mailbox, const char *msg);
 int nntp_check_msgid(struct Context *ctx, const char *msgid);
 int nntp_check_children(struct Context *ctx, const char *msgid);
 int nntp_newsrc_parse(struct NntpServer *nserv);
index 787fb5539fb0d67490c2a9835334623d580d6616..797891105bcf2c1eb97ace9e372264e6acf81a7a 100644 (file)
@@ -1082,18 +1082,18 @@ static void progress_update(struct Mailbox *mailbox, notmuch_query_t *q)
 
 /**
  * get_mutt_header - Get the Header of a Notmuch message
- * @param ctx Mailbox
+ * @param mailbox Mailbox
  * @param msg Notmuch message
  * @retval ptr  Email Header
  * @retval NULL Error
  */
-static struct Header *get_mutt_header(struct Context *ctx, notmuch_message_t *msg)
+static struct Header *get_mutt_header(struct Mailbox *mailbox, notmuch_message_t *msg)
 {
   char *mid = NULL;
   const char *id = NULL;
   struct Header *h = NULL;
 
-  if (!ctx || !msg)
+  if (!mailbox || !msg)
     return NULL;
 
   id = notmuch_message_get_message_id(msg);
@@ -1102,45 +1102,45 @@ static struct Header *get_mutt_header(struct Context *ctx, notmuch_message_t *ms
 
   mutt_debug(2, "nm: neomutt header, id='%s'\n", id);
 
-  if (!ctx->mailbox->id_hash)
+  if (!mailbox->id_hash)
   {
     mutt_debug(2, "nm: init hash\n");
-    ctx->mailbox->id_hash = mutt_make_id_hash(ctx);
-    if (!ctx->mailbox->id_hash)
+    mailbox->id_hash = mutt_make_id_hash(mailbox);
+    if (!mailbox->id_hash)
       return NULL;
   }
 
   mid = nm2mutt_message_id(id);
   mutt_debug(2, "nm: neomutt id='%s'\n", mid);
 
-  h = mutt_hash_find(ctx->mailbox->id_hash, mid);
+  h = mutt_hash_find(mailbox->id_hash, mid);
   FREE(&mid);
   return h;
 }
 
 /**
  * append_message - Associate a message
- * @param ctx   Mailbox
- * @param q     Notmuch query
- * @param msg   Notmuch message
- * @param dedup De-duplicate results
+ * @param mailbox Mailbox
+ * @param q       Notmuch query
+ * @param msg     Notmuch message
+ * @param dedup   De-duplicate results
  */
-static void append_message(struct Context *ctx, notmuch_query_t *q,
+static void append_message(struct Mailbox *mailbox, notmuch_query_t *q,
                            notmuch_message_t *msg, bool dedup)
 {
   char *newpath = NULL;
   const char *path = NULL;
   struct Header *h = NULL;
 
-  struct NmMboxData *data = get_mboxdata(ctx->mailbox);
+  struct NmMboxData *data = get_mboxdata(mailbox);
   if (!data)
     return;
 
   /* deduplicate */
-  if (dedup && get_mutt_header(ctx, msg))
+  if (dedup && get_mutt_header(mailbox, msg))
   {
     data->ignmsgcount++;
-    progress_update(ctx->mailbox, q);
+    progress_update(mailbox, q);
     mutt_debug(2, "nm: ignore id=%s, already in the mailbox\n",
                notmuch_message_get_message_id(msg));
     return;
@@ -1151,12 +1151,12 @@ static void append_message(struct Context *ctx, notmuch_query_t *q,
     return;
 
   mutt_debug(2, "nm: appending message, i=%d, id=%s, path=%s\n",
-             ctx->mailbox->msg_count, notmuch_message_get_message_id(msg), path);
+             mailbox->msg_count, notmuch_message_get_message_id(msg), path);
 
-  if (ctx->mailbox->msg_count >= ctx->mailbox->hdrmax)
+  if (mailbox->msg_count >= mailbox->hdrmax)
   {
     mutt_debug(2, "nm: allocate mx memory\n");
-    mx_alloc_memory(ctx);
+    mx_alloc_memory(mailbox);
   }
   if (access(path, F_OK) == 0)
     h = maildir_parse_message(MUTT_MAILDIR, path, false, NULL);
@@ -1192,10 +1192,10 @@ static void append_message(struct Context *ctx, notmuch_query_t *q,
   }
 
   h->active = true;
-  h->index = ctx->mailbox->msg_count;
-  ctx->mailbox->size += h->content->length + h->content->offset - h->content->hdr_offset;
-  ctx->mailbox->hdrs[ctx->mailbox->msg_count] = h;
-  ctx->mailbox->msg_count++;
+  h->index = mailbox->msg_count;
+  mailbox->size += h->content->length + h->content->offset - h->content->hdr_offset;
+  mailbox->hdrs[mailbox->msg_count] = h;
+  mailbox->msg_count++;
 
   if (newpath)
   {
@@ -1208,21 +1208,21 @@ static void append_message(struct Context *ctx, notmuch_query_t *q,
       hd->oldpath = mutt_str_strdup(path);
     }
   }
-  progress_update(ctx->mailbox, q);
+  progress_update(mailbox, q);
 done:
   FREE(&newpath);
 }
 
 /**
  * append_replies - add all the replies to a given messages into the display
- * @param ctx   Mailbox
- * @param q     Notmuch query
- * @param top   Notmuch message
- * @param dedup De-duplicate the results
+ * @param mailbox Mailbox
+ * @param q       Notmuch query
+ * @param top     Notmuch message
+ * @param dedup   De-duplicate the results
  *
  * Careful, this calls itself recursively to make sure we get everything.
  */
-static void append_replies(struct Context *ctx, notmuch_query_t *q,
+static void append_replies(struct Mailbox *mailbox, notmuch_query_t *q,
                            notmuch_message_t *top, bool dedup)
 {
   notmuch_messages_t *msgs = NULL;
@@ -1231,24 +1231,24 @@ static void append_replies(struct Context *ctx, notmuch_query_t *q,
        notmuch_messages_move_to_next(msgs))
   {
     notmuch_message_t *m = notmuch_messages_get(msgs);
-    append_message(ctx, q, m, dedup);
+    append_message(mailbox, q, m, dedup);
     /* recurse through all the replies to this message too */
-    append_replies(ctx, q, m, dedup);
+    append_replies(mailbox, q, m, dedup);
     notmuch_message_destroy(m);
   }
 }
 
 /**
  * append_thread - add each top level reply in the thread
- * @param ctx    Mailbox
- * @param q      Notmuch query
- * @param thread Notmuch thread
- * @param dedup  De-duplicate the results
+ * @param mailbox Mailbox
+ * @param q       Notmuch query
+ * @param thread  Notmuch thread
+ * @param dedup   De-duplicate the results
  *
  * add each top level reply in the thread, and then add each reply to the top
  * level replies
  */
-static void append_thread(struct Context *ctx, notmuch_query_t *q,
+static void append_thread(struct Mailbox *mailbox, notmuch_query_t *q,
                           notmuch_thread_t *thread, bool dedup)
 {
   notmuch_messages_t *msgs = NULL;
@@ -1257,23 +1257,23 @@ static void append_thread(struct Context *ctx, notmuch_query_t *q,
        notmuch_messages_valid(msgs); notmuch_messages_move_to_next(msgs))
   {
     notmuch_message_t *m = notmuch_messages_get(msgs);
-    append_message(ctx, q, m, dedup);
-    append_replies(ctx, q, m, dedup);
+    append_message(mailbox, q, m, dedup);
+    append_replies(mailbox, q, m, dedup);
     notmuch_message_destroy(m);
   }
 }
 
 /**
  * read_mesgs_query - Search for matching messages
- * @param ctx   Mailbox
- * @param q     Notmuch query
- * @param dedup De-duplicate the results
+ * @param mailbox Mailbox
+ * @param q       Notmuch query
+ * @param dedup   De-duplicate the results
  * @retval true  Success
  * @retval false Failure
  */
-static bool read_mesgs_query(struct Context *ctx, notmuch_query_t *q, bool dedup)
+static bool read_mesgs_query(struct Mailbox *mailbox, notmuch_query_t *q, bool dedup)
 {
-  struct NmMboxData *data = get_mboxdata(ctx->mailbox);
+  struct NmMboxData *data = get_mboxdata(mailbox);
   int limit;
   notmuch_messages_t *msgs = NULL;
 
@@ -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->mailbox->msg_count < limit));
+  for (; notmuch_messages_valid(msgs) && ((limit == 0) || (mailbox->msg_count < limit));
        notmuch_messages_move_to_next(msgs))
   {
     if (SigInt == 1)
@@ -1301,7 +1301,7 @@ static bool read_mesgs_query(struct Context *ctx, notmuch_query_t *q, bool dedup
       return false;
     }
     notmuch_message_t *m = notmuch_messages_get(msgs);
-    append_message(ctx, q, m, dedup);
+    append_message(mailbox, q, m, dedup);
     notmuch_message_destroy(m);
   }
   return true;
@@ -1309,16 +1309,16 @@ static bool read_mesgs_query(struct Context *ctx, notmuch_query_t *q, bool dedup
 
 /**
  * read_threads_query - Perform a query with threads
- * @param ctx   Mailbox
- * @param q     Query type
- * @param dedup Should the results be de-duped?
- * @param limit Maximum number of results
+ * @param mailbox Mailbox
+ * @param q       Query type
+ * @param dedup   Should the results be de-duped?
+ * @param limit   Maximum number of results
  * @retval true  Success
  * @retval false Failure
  */
-static bool read_threads_query(struct Context *ctx, notmuch_query_t *q, bool dedup, int limit)
+static bool read_threads_query(struct Mailbox *mailbox, notmuch_query_t *q, bool dedup, int limit)
 {
-  struct NmMboxData *data = get_mboxdata(ctx->mailbox);
+  struct NmMboxData *data = get_mboxdata(mailbox);
   notmuch_threads_t *threads = NULL;
 
   if (!data)
@@ -1335,7 +1335,7 @@ static bool read_threads_query(struct Context *ctx, notmuch_query_t *q, bool ded
 #endif
 
   for (; notmuch_threads_valid(threads) &&
-         ((limit == 0) || (ctx->mailbox->msg_count < limit));
+         ((limit == 0) || (mailbox->msg_count < limit));
        notmuch_threads_move_to_next(threads))
   {
     if (SigInt == 1)
@@ -1344,7 +1344,7 @@ static bool read_threads_query(struct Context *ctx, notmuch_query_t *q, bool ded
       return false;
     }
     notmuch_thread_t *thread = notmuch_threads_get(threads);
-    append_thread(ctx, q, thread, dedup);
+    append_thread(mailbox, q, thread, dedup);
     notmuch_thread_destroy(thread);
   }
   return true;
@@ -1867,7 +1867,7 @@ int nm_read_entire_thread(struct Context *ctx, struct Header *h)
   apply_exclude_tags(q);
   notmuch_query_set_sort(q, NOTMUCH_SORT_NEWEST_FIRST);
 
-  read_threads_query(ctx, q, true, 0);
+  read_threads_query(ctx->mailbox, q, true, 0);
   ctx->mailbox->mtime.tv_sec = time(NULL);
   ctx->mailbox->mtime.tv_nsec = 0;
   rc = 0;
@@ -2158,19 +2158,19 @@ bool nm_message_is_still_queried(struct Mailbox *mailbox, struct Header *hdr)
 
 /**
  * nm_update_filename - Change the filename
- * @param ctx Mailbox
+ * @param mailbox Mailbox
  * @param old Old filename
  * @param new New filename
  * @param h   Email Header
  * @retval  0 Success
  * @retval -1 Failure
  */
-int nm_update_filename(struct Context *ctx, const char *old, const char *new,
+int nm_update_filename(struct Mailbox *mailbox, const char *old, const char *new,
                        struct Header *h)
 {
   char buf[PATH_MAX];
   int rc;
-  struct NmMboxData *data = get_mboxdata(ctx->mailbox);
+  struct NmMboxData *data = get_mboxdata(mailbox);
 
   if (!data || !new)
     return -1;
@@ -2185,8 +2185,8 @@ int nm_update_filename(struct Context *ctx, const char *old, const char *new,
 
   if (!is_longrun(data))
     release_db(data);
-  ctx->mailbox->mtime.tv_sec = time(NULL);
-  ctx->mailbox->mtime.tv_nsec = 0;
+  mailbox->mtime.tv_sec = time(NULL);
+  mailbox->mtime.tv_nsec = 0;
   return rc;
 }
 
@@ -2465,11 +2465,11 @@ static int nm_mbox_open(struct Context *ctx)
     switch (data->query_type)
     {
       case NM_QUERY_TYPE_MESGS:
-        if (!read_mesgs_query(ctx, q, false))
+        if (!read_mesgs_query(ctx->mailbox, q, false))
           rc = -2;
         break;
       case NM_QUERY_TYPE_THREADS:
-        if (!read_threads_query(ctx, q, false, get_limit(data)))
+        if (!read_threads_query(ctx->mailbox, q, false, get_limit(data)))
           rc = -2;
         break;
     }
@@ -2524,12 +2524,12 @@ static int nm_mbox_check(struct Context *ctx, int *index_hint)
 
   if (ctx->mailbox->mtime.tv_sec >= mtime)
   {
-    mutt_debug(2, "nm: check unnecessary (db=%lu ctx=%lu)\n", mtime,
+    mutt_debug(2, "nm: check unnecessary (db=%lu mailbox=%lu)\n", mtime,
                ctx->mailbox->mtime);
     return 0;
   }
 
-  mutt_debug(1, "nm: checking (db=%lu ctx=%lu)\n", mtime, ctx->mailbox->mtime);
+  mutt_debug(1, "nm: checking (db=%lu mailbox=%lu)\n", mtime, ctx->mailbox->mtime);
 
   q = get_query(data, false);
   if (!q)
@@ -2561,12 +2561,12 @@ static int nm_mbox_check(struct Context *ctx, int *index_hint)
     const char *new = NULL;
 
     notmuch_message_t *m = notmuch_messages_get(msgs);
-    struct Header *h = get_mutt_header(ctx, m);
+    struct Header *h = get_mutt_header(ctx->mailbox, m);
 
     if (!h)
     {
       /* new email */
-      append_message(ctx, NULL, m, 0);
+      append_message(ctx->mailbox, NULL, m, 0);
       notmuch_message_destroy(m);
       continue;
     }
index bf804e4bd4dc1077d6ff71546ea0aab7d9da739f..8c64edcdaa67cd1f27593fcae5b14b944cd9beac 100644 (file)
@@ -54,7 +54,7 @@ extern char *NmUnreadTag;
 int nm_read_entire_thread(struct Context *ctx, struct Header *h);
 
 char *nm_header_get_folder(struct Header *h);
-int nm_update_filename(struct Context *ctx, const char *old, const char *new, struct Header *h);
+int nm_update_filename(struct Mailbox *mailbox, const char *old, const char *new, struct Header *h);
 bool nm_normalize_uri(const char *uri, char *buf, size_t buflen);
 char *nm_uri_from_query(struct Mailbox *mailbox, char *buf, size_t buflen);
 bool nm_message_is_still_queried(struct Mailbox *mailbox, struct Header *hdr);
index 0e3cac14cd74b14bf1db664fe93210d857c21ebe..0551536b1a1e2e350ad83c7d1aedb2995e4697ce 100644 (file)
--- a/pop/pop.c
+++ b/pop/pop.c
@@ -202,8 +202,8 @@ static int pop_read_header(struct PopData *pop_data, struct Header *h)
 static int fetch_uidl(char *line, void *data)
 {
   int i, index;
-  struct Context *ctx = data;
-  struct PopData *pop_data = ctx->mailbox->data;
+  struct Mailbox *mailbox = data;
+  struct PopData *pop_data = mailbox->data;
   char *endp = NULL;
 
   errno = 0;
@@ -218,26 +218,26 @@ static int fetch_uidl(char *line, void *data)
   if (strlen(line) == 0)
     return -1;
 
-  for (i = 0; i < ctx->mailbox->msg_count; i++)
-    if (mutt_str_strcmp(line, ctx->mailbox->hdrs[i]->data) == 0)
+  for (i = 0; i < mailbox->msg_count; i++)
+    if (mutt_str_strcmp(line, mailbox->hdrs[i]->data) == 0)
       break;
 
-  if (i == ctx->mailbox->msg_count)
+  if (i == mailbox->msg_count)
   {
     mutt_debug(1, "new header %d %s\n", index, line);
 
-    if (i >= ctx->mailbox->hdrmax)
-      mx_alloc_memory(ctx);
+    if (i >= mailbox->hdrmax)
+      mx_alloc_memory(mailbox);
 
-    ctx->mailbox->msg_count++;
-    ctx->mailbox->hdrs[i] = mutt_header_new();
-    ctx->mailbox->hdrs[i]->data = mutt_str_strdup(line);
+    mailbox->msg_count++;
+    mailbox->hdrs[i] = mutt_header_new();
+    mailbox->hdrs[i]->data = mutt_str_strdup(line);
   }
-  else if (ctx->mailbox->hdrs[i]->index != index - 1)
+  else if (mailbox->hdrs[i]->index != index - 1)
     pop_data->clear_cache = true;
 
-  ctx->mailbox->hdrs[i]->refno = index;
-  ctx->mailbox->hdrs[i]->index = index - 1;
+  mailbox->hdrs[i]->refno = index;
+  mailbox->hdrs[i]->index = index - 1;
 
   return 0;
 }
@@ -327,7 +327,7 @@ static int pop_fetch_headers(struct Context *ctx)
     ctx->mailbox->hdrs[i]->refno = -1;
 
   const int old_count = ctx->mailbox->msg_count;
-  int ret = pop_fetch_data(pop_data, "UIDL\r\n", NULL, fetch_uidl, ctx);
+  int ret = pop_fetch_data(pop_data, "UIDL\r\n", NULL, fetch_uidl, ctx->mailbox);
   const int new_count = ctx->mailbox->msg_count;
   ctx->mailbox->msg_count = old_count;
 
@@ -722,12 +722,12 @@ static int pop_msg_open(struct Context *ctx, struct Message *msg, int msgno)
   /* we replace envelop, key in subj_hash has to be updated as well */
   if (ctx->mailbox->subj_hash && h->env->real_subj)
     mutt_hash_delete(ctx->mailbox->subj_hash, h->env->real_subj, h);
-  mutt_label_hash_remove(ctx, h);
+  mutt_label_hash_remove(ctx->mailbox, h);
   mutt_env_free(&h->env);
   h->env = mutt_rfc822_read_header(msg->fp, h, false, false);
   if (ctx->mailbox->subj_hash && h->env->real_subj)
     mutt_hash_insert(ctx->mailbox->subj_hash, h->env->real_subj, h);
-  mutt_label_hash_add(ctx, h);
+  mutt_label_hash_add(ctx->mailbox, h);
 
   h->data = uidl;
   h->lines = 0;
@@ -781,13 +781,20 @@ static int pop_mbox_sync(struct Context *ctx, int *index_hint)
 
   pop_data->check_time = 0;
 
+  int num_deleted = 0;
+  for (i = 0; i < ctx->mailbox->msg_count; i++)
+  {
+    if (ctx->mailbox->hdrs[i]->deleted)
+      num_deleted++;
+  }
+
   while (true)
   {
     if (pop_reconnect(ctx->mailbox) < 0)
       return -1;
 
     mutt_progress_init(&progress, _("Marking messages deleted..."),
-                       MUTT_PROGRESS_MSG, WriteInc, ctx->deleted);
+                       MUTT_PROGRESS_MSG, WriteInc, num_deleted);
 
 #ifdef USE_HCACHE
     hc = pop_hcache_open(pop_data, ctx->mailbox->path);
index 1b90741321d81c3a9f53a8d7dfdb15d6025a035a..1e905a4f02b033410a54d7329518bc3c9d4f89bc 100644 (file)
@@ -349,7 +349,7 @@ int mutt_get_postponed(struct Context *ctx, struct Header *hdr,
            the user attempted to reply to is in this mailbox */
         p = mutt_str_skip_email_wsp(np->data + 18);
         if (!ctx->mailbox->id_hash)
-          ctx->mailbox->id_hash = mutt_make_id_hash(ctx);
+          ctx->mailbox->id_hash = mutt_make_id_hash(ctx->mailbox);
         *cur = mutt_hash_find(ctx->mailbox->id_hash, p);
       }
       if (*cur)
index 27f01f9df8316a9166d1a3e54e605788a133c365..fb3769c4978e7559cde35763eb81628d9530c3fe 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -2716,7 +2716,7 @@ int mutt_invoke_sendmail(struct Address *from, struct Address *to, struct Addres
                         NONULL(Inews), nntp_format_str, 0, 0);
     if (!*cmd)
     {
-      i = nntp_post(Context, msg);
+      i = nntp_post(Context->mailbox, msg);
       unlink(msg);
       return i;
     }