]> granicus.if.org Git - neomutt/commitdiff
move path
authorRichard Russon <rich@flatcap.org>
Wed, 29 Aug 2018 20:37:15 +0000 (21:37 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 4 Sep 2018 00:14:21 +0000 (01:14 +0100)
18 files changed:
compose.c
compress.c
context.h
curs_main.c
editmsg.c
hdrline.c
imap/imap.c
imap/message.c
imap/util.c
mailbox.c
maildir/mh.c
mbox/mbox.c
mx.c
nntp/nntp.c
notmuch/mutt_notmuch.c
pager.c
pop/pop.c
status.c

index 80beeba3a8cda744bcc54887494012970cc37585..fd17d8a35f413f2a83609f3fffc43e30c03fa63a 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -1422,7 +1422,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen,
           if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == MUTT_NNTP))
 #endif
           {
-            mutt_str_strfcpy(fname, Context->path, sizeof(fname));
+            mutt_str_strfcpy(fname, Context->mailbox->path, sizeof(fname));
             mutt_pretty_mailbox(fname, sizeof(fname));
           }
 
@@ -1921,7 +1921,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen,
         fname[0] = '\0';
         if (Context)
         {
-          mutt_str_strfcpy(fname, Context->path, sizeof(fname));
+          mutt_str_strfcpy(fname, Context->mailbox->path, sizeof(fname));
           mutt_pretty_mailbox(fname, sizeof(fname));
         }
         if (actx->idxlen)
index e00446799e3571a01cd3ae07bdcebb32eddf080f..e527f9894744181db2d26d666d741d4ca48fe85c 100644 (file)
@@ -161,14 +161,13 @@ static int setup_paths(struct Context *ctx)
   char tmppath[PATH_MAX];
 
   /* Setup the right paths */
-  FREE(&ctx->mailbox->realpath);
-  mutt_str_strfcpy(ctx->mailbox->realpath, ctx->path, sizeof(ctx->mailbox->realpath));
+  mutt_str_strfcpy(ctx->mailbox->realpath, ctx->mailbox->path, sizeof(ctx->mailbox->realpath));
 
   /* We will uncompress to /tmp */
   mutt_mktemp(tmppath, sizeof(tmppath));
-  ctx->path = mutt_str_strdup(tmppath);
+  mutt_str_strfcpy(ctx->mailbox->path, tmppath, sizeof(ctx->mailbox->path));
 
-  FILE *tmpfp = mutt_file_fopen(ctx->path, "w");
+  FILE *tmpfp = mutt_file_fopen(ctx->mailbox->path, "w");
   if (!tmpfp)
     return -1;
 
@@ -250,19 +249,19 @@ static const char *find_hook(int type, const char *path)
  */
 static struct CompressInfo *set_compress_info(struct Context *ctx)
 {
-  if (!ctx || !ctx->path)
+  if (!ctx || !ctx->mailbox->path)
     return NULL;
 
   if (ctx->compress_info)
     return ctx->compress_info;
 
   /* Open is compulsory */
-  const char *o = find_hook(MUTT_OPEN_HOOK, ctx->path);
+  const char *o = find_hook(MUTT_OPEN_HOOK, ctx->mailbox->path);
   if (!o)
     return NULL;
 
-  const char *c = find_hook(MUTT_CLOSE_HOOK, ctx->path);
-  const char *a = find_hook(MUTT_APPEND_HOOK, ctx->path);
+  const char *c = find_hook(MUTT_CLOSE_HOOK, ctx->mailbox->path);
+  const char *a = find_hook(MUTT_APPEND_HOOK, ctx->mailbox->path);
 
   struct CompressInfo *ci = mutt_mem_calloc(1, sizeof(struct CompressInfo));
   ctx->compress_info = ci;
@@ -362,7 +361,7 @@ static const char *compress_format_str(char *buf, size_t buflen, size_t col, int
       break;
     case 't':
       /* Plaintext, temporary file */
-      snprintf(buf, buflen, "%s", NONULL(escape_path(ctx->path)));
+      snprintf(buf, buflen, "%s", NONULL(escape_path(ctx->mailbox->path)));
       break;
   }
   return src;
@@ -454,7 +453,7 @@ static int comp_mbox_open(struct Context *ctx)
     return -1;
 
   /* If there's no close-hook, or the file isn't writable */
-  if (!ci->close || (access(ctx->path, W_OK) != 0))
+  if (!ci->close || (access(ctx->mailbox->path, W_OK) != 0))
     ctx->readonly = true;
 
   if (setup_paths(ctx) != 0)
@@ -473,7 +472,7 @@ static int comp_mbox_open(struct Context *ctx)
 
   unlock_realpath(ctx);
 
-  ctx->magic = mx_path_probe(ctx->path, NULL);
+  ctx->magic = mx_path_probe(ctx->mailbox->path, NULL);
   if (ctx->magic == MUTT_UNKNOWN)
   {
     mutt_error(_("Can't identify the contents of the compressed file"));
@@ -491,7 +490,7 @@ static int comp_mbox_open(struct Context *ctx)
 
 or_fail:
   /* remove the partial uncompressed file */
-  remove(ctx->path);
+  remove(ctx->mailbox->path);
   free_compress_info(ctx);
   return -1;
 }
@@ -517,7 +516,7 @@ static int comp_mbox_open_append(struct Context *ctx, int flags)
   /* To append we need an append-hook or a close-hook */
   if (!ci->append && !ci->close)
   {
-    mutt_error(_("Cannot append without an append-hook or close-hook : %s"), ctx->path);
+    mutt_error(_("Cannot append without an append-hook or close-hook : %s"), ctx->mailbox->path);
     goto oa_fail1;
   }
 
@@ -541,7 +540,7 @@ static int comp_mbox_open_append(struct Context *ctx, int flags)
       mutt_error(_("Compress command failed: %s"), ci->open);
       goto oa_fail2;
     }
-    ctx->magic = mx_path_probe(ctx->path, NULL);
+    ctx->magic = mx_path_probe(ctx->mailbox->path, NULL);
   }
   else
     ctx->magic = MboxType;
@@ -567,7 +566,7 @@ static int comp_mbox_open_append(struct Context *ctx, int flags)
 
 oa_fail2:
   /* remove the partial uncompressed file */
-  remove(ctx->path);
+  remove(ctx->mailbox->path);
 oa_fail1:
   /* Free the compress_info to prevent close from trying to recompress */
   free_compress_info(ctx);
@@ -603,13 +602,13 @@ static int comp_mbox_close(struct Context *ctx)
   if (!ctx->append)
   {
     /* If the file was removed, remove the compressed folder too */
-    if ((access(ctx->path, F_OK) != 0) && !SaveEmpty)
+    if ((access(ctx->mailbox->path, F_OK) != 0) && !SaveEmpty)
     {
       remove(ctx->mailbox->realpath);
     }
     else
     {
-      remove(ctx->path);
+      remove(ctx->mailbox->path);
     }
   }
   else
@@ -633,10 +632,10 @@ static int comp_mbox_close(struct Context *ctx)
     if (rc == 0)
     {
       mutt_any_key_to_continue(NULL);
-      mutt_error(_("Error. Preserving temporary file: %s"), ctx->path);
+      mutt_error(_("Error. Preserving temporary file: %s"), ctx->mailbox->path);
     }
     else
-      remove(ctx->path);
+      remove(ctx->mailbox->path);
 
     unlock_realpath(ctx);
   }
@@ -799,7 +798,7 @@ bool mutt_comp_can_append(struct Context *ctx)
   if (ci->append || ci->close)
     return true;
 
-  mutt_error(_("Cannot append without an append-hook or close-hook : %s"), ctx->path);
+  mutt_error(_("Cannot append without an append-hook or close-hook : %s"), ctx->mailbox->path);
   return false;
 }
 
index 29a7da7f9c713c8113cd75babb39b6e52e1bac66..4be460ff4775166692d81cede8bbdaf9fee9ff40 100644 (file)
--- a/context.h
+++ b/context.h
@@ -53,7 +53,6 @@ enum AclRights
  */
 struct Context
 {
-  char *path;
   FILE *fp;
   struct timespec atime;
   struct timespec mtime;
index f2ffbd601691fcb3dc12561138e51d42978802c4..4b7df8a6dc20194fbd8c9aca59ef4906f85bfbb3 100644 (file)
@@ -562,7 +562,7 @@ static int main_change_folder(struct Menu *menu, int op, char *buf,
   }
 
   /* keepalive failure in mutt_enter_fname may kill connection. #3028 */
-  if (Context && !Context->path)
+  if (Context && !Context->mailbox->path)
     mutt_context_free(&Context);
 
   if (Context)
@@ -576,7 +576,7 @@ static int main_change_folder(struct Menu *menu, int op, char *buf,
       new_last_folder = mutt_str_strdup(Context->mailbox->realpath);
     else
 #endif
-      new_last_folder = mutt_str_strdup(Context->path);
+      new_last_folder = mutt_str_strdup(Context->mailbox->path);
     *oldcount = Context ? Context->msgcount : 0;
 
     int check = mx_mbox_close(&Context, index_hint);
@@ -1051,7 +1051,7 @@ int mutt_index_menu(void)
       check = mx_mbox_check(Context, &index_hint);
       if (check < 0)
       {
-        if (!Context->path)
+        if (!Context->mailbox->path)
         {
           /* fatal error occurred */
           mutt_context_free(&Context);
@@ -1869,7 +1869,7 @@ int mutt_index_menu(void)
         }
 
         /* check for a fatal error, or all messages deleted */
-        if (!Context->path)
+        if (!Context->mailbox->path)
           mutt_context_free(&Context);
 
         /* if we were in the pager, redisplay the message */
@@ -2141,9 +2141,9 @@ int mutt_index_menu(void)
           cp = _("Open mailbox");
 
         buf[0] = '\0';
-        if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && Context->path)
+        if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && Context->mailbox->path)
         {
-          mutt_str_strfcpy(buf, Context->path, sizeof(buf));
+          mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf));
           mutt_pretty_mailbox(buf, sizeof(buf));
           mutt_mailbox(buf, sizeof(buf));
           if (!buf[0])
@@ -2169,7 +2169,7 @@ int mutt_index_menu(void)
         {
           if (Context && (Context->magic == MUTT_NOTMUCH))
           {
-            mutt_str_strfcpy(buf, Context->path, sizeof(buf));
+            mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf));
             mutt_mailbox_vfolder(buf, sizeof(buf));
           }
           mutt_enter_vfolder(cp, buf, sizeof(buf), 1);
@@ -2182,9 +2182,9 @@ int mutt_index_menu(void)
 #endif
         else
         {
-          if (ChangeFolderNext && Context && Context->path)
+          if (ChangeFolderNext && Context && Context->mailbox->path)
           {
-            mutt_str_strfcpy(buf, Context->path, sizeof(buf));
+            mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf));
             mutt_pretty_mailbox(buf, sizeof(buf));
           }
 #ifdef USE_NNTP
index 97c42ec8c58bd9c97f1e9c7ecd8153380e0772ec..d5b6df94acebd430241a32b55feadd753f4d631c 100644 (file)
--- a/editmsg.c
+++ b/editmsg.c
@@ -43,6 +43,7 @@
 #include "copy.h"
 #include "curs_lib.h"
 #include "globals.h"
+#include "mailbox.h"
 #include "muttlib.h"
 #include "mx.h"
 #include "protos.h"
@@ -185,7 +186,7 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Heade
     goto bail;
   }
 
-  tmpctx = mx_mbox_open(ctx->path, MUTT_APPEND);
+  tmpctx = mx_mbox_open(ctx->mailbox->path, MUTT_APPEND);
   if (!tmpctx)
   {
     rc = -1;
index 11fc137182b47dca81ac09300d2d1586b5a03a3e..d5fbeb7dd1acfa576e31d4808b4aec4a96af9e5b 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -39,6 +39,7 @@
 #include "curs_lib.h"
 #include "format_flags.h"
 #include "globals.h"
+#include "mailbox.h"
 #include "mutt_curses.h"
 #include "mutt_parse.h"
 #include "mutt_thread.h"
@@ -602,11 +603,11 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co
     case 'b':
       if (ctx)
       {
-        p = strrchr(ctx->path, '/');
+        p = strrchr(ctx->mailbox->path, '/');
         if (p)
           mutt_str_strfcpy(buf, p + 1, buflen);
         else
-          mutt_str_strfcpy(buf, ctx->path, buflen);
+          mutt_str_strfcpy(buf, ctx->mailbox->path, buflen);
       }
       else
         mutt_str_strfcpy(buf, "(null)", buflen);
index bc1220bb7fc89f7691b5381bb030fb7d1ffd770f..8b51fd3d1576b99e156c05ecccf4e8fdb94c3a71 100644 (file)
@@ -1903,7 +1903,7 @@ int imap_fast_trash(struct Context *ctx, char *dest)
   /* check that the save-to folder is in the same account */
   if (mutt_account_match(&(idata->conn->account), &(mx.account)) == 0)
   {
-    mutt_debug(3, "%s not same server as %s\n", dest, ctx->path);
+    mutt_debug(3, "%s not same server as %s\n", dest, ctx->mailbox->path);
     return 1;
   }
 
@@ -2002,9 +2002,9 @@ static int imap_mbox_open(struct Context *ctx)
   int rc;
   const char *condstore;
 
-  if (imap_parse_path(ctx->path, &mx))
+  if (imap_parse_path(ctx->mailbox->path, &mx))
   {
-    mutt_error(_("%s is an invalid IMAP path"), ctx->path);
+    mutt_error(_("%s is an invalid IMAP mailbox->path"), ctx->mailbox->path);
     return -1;
   }
 
@@ -2026,9 +2026,8 @@ static int imap_mbox_open(struct Context *ctx)
   idata->mailbox = mutt_str_strdup(buf);
   imap_qualify_path(buf, sizeof(buf), &mx, idata->mailbox);
 
-  FREE(&(ctx->path));
-  ctx->path = mutt_str_strdup(buf);
-  mutt_str_strfcpy(ctx->mailbox->realpath, ctx->path, sizeof(ctx->mailbox->realpath));
+  mutt_str_strfcpy(ctx->mailbox->path, buf, sizeof(ctx->mailbox->path));
+  mutt_str_strfcpy(ctx->mailbox->realpath, ctx->mailbox->path, sizeof(ctx->mailbox->realpath));
 
   idata->ctx = ctx;
 
@@ -2246,7 +2245,7 @@ static int imap_mbox_open_append(struct Context *ctx, int flags)
   struct ImapMbox mx;
   int rc;
 
-  if (imap_parse_path(ctx->path, &mx))
+  if (imap_parse_path(ctx->mailbox->path, &mx))
     return -1;
 
   /* in APPEND mode, we appear to hijack an existing IMAP connection -
@@ -2266,7 +2265,7 @@ static int imap_mbox_open_append(struct Context *ctx, int flags)
     mutt_str_strfcpy(mailbox, "INBOX", sizeof(mailbox));
   FREE(&mx.mbox);
 
-  rc = imap_access(ctx->path);
+  rc = imap_access(ctx->mailbox->path);
   if (rc == 0)
     return 0;
 
@@ -2472,7 +2471,7 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge)
                               "Saving changed messages... [%d/%d]", ctx->msgcount),
                      i + 1, ctx->msgcount);
         if (!appendctx)
-          appendctx = mx_mbox_open(ctx->path, MUTT_APPEND | MUTT_QUIET);
+          appendctx = mx_mbox_open(ctx->mailbox->path, MUTT_APPEND | MUTT_QUIET);
         if (!appendctx)
           mutt_debug(1, "Error opening mailbox in append mode\n");
         else
index 35129ebb635e1a14c948be9a231388f094d92689..662fb1bd1cf35d0c2499b64491ab17c83b50d93e 100644 (file)
@@ -46,6 +46,7 @@
 #include "curs_lib.h"
 #include "globals.h"
 #include "imap/imap.h"
+#include "mailbox.h"
 #include "mutt_account.h"
 #include "mutt_curses.h"
 #include "mutt_logging.h"
@@ -1605,7 +1606,7 @@ int imap_append_message(struct Context *ctx, struct Message *msg)
 
   struct ImapData *idata = ctx->data;
 
-  if (imap_parse_path(ctx->path, &mx))
+  if (imap_parse_path(ctx->mailbox->path, &mx))
     return -1;
 
   imap_fix_path(idata, mx.mbox, mailbox, sizeof(mailbox));
@@ -1748,7 +1749,7 @@ int imap_copy_messages(struct Context *ctx, struct Header *h, char *dest, bool d
   /* check that the save-to folder is in the same account */
   if (mutt_account_match(&(idata->conn->account), &(mx.account)) == 0)
   {
-    mutt_debug(3, "%s not same server as %s\n", dest, ctx->path);
+    mutt_debug(3, "%s not same server as %s\n", dest, ctx->mailbox->path);
     return 1;
   }
 
index ce559e69fea7d8c463db2d9b5f5c08558f53fe20..1205a2e017305f3e49d2f1d89504b6917f4cbbb1 100644 (file)
@@ -51,6 +51,7 @@
 #include "curs_lib.h"
 #include "globals.h"
 #include "imap/imap.h"
+#include "mailbox.h"
 #include "message.h"
 #include "mutt_account.h"
 #include "mx.h"
@@ -297,7 +298,7 @@ header_cache_t *imap_hcache_open(struct ImapData *idata, const char *path)
     imap_cachepath(idata, path, mbox, sizeof(mbox));
   else
   {
-    if (!idata->ctx || imap_parse_path(idata->ctx->path, &mx) < 0)
+    if (!idata->ctx || imap_parse_path(idata->ctx->mailbox->path, &mx) < 0)
       return NULL;
 
     imap_cachepath(idata, mx.mbox, mbox, sizeof(mbox));
index 7478fc8c8f9ee198348e3f14d363635baed8ae11..7eece184f3dc333a4dac9906a383d469f0c21cb8 100644 (file)
--- a/mailbox.c
+++ b/mailbox.c
@@ -438,7 +438,7 @@ static void mailbox_check(struct Mailbox *tmp, struct stat *contex_sb, bool chec
   }
 
   /* check to see if the folder is the currently selected folder before polling */
-  if (!Context || !Context->path ||
+  if (!Context || !Context->mailbox->path ||
       ((tmp->magic == MUTT_IMAP ||
 #ifdef USE_NNTP
         tmp->magic == MUTT_NNTP ||
@@ -447,7 +447,7 @@ static void mailbox_check(struct Mailbox *tmp, struct stat *contex_sb, bool chec
         tmp->magic == MUTT_NOTMUCH ||
 #endif
         tmp->magic == MUTT_POP) ?
-           (mutt_str_strcmp(tmp->path, Context->path) != 0) :
+           (mutt_str_strcmp(tmp->path, Context->mailbox->path) != 0) :
            (sb.st_dev != contex_sb->st_dev || sb.st_ino != contex_sb->st_ino)))
   {
     switch (tmp->magic)
@@ -483,7 +483,7 @@ static void mailbox_check(struct Mailbox *tmp, struct stat *contex_sb, bool chec
       default:; /* do nothing */
     }
   }
-  else if (CheckMboxSize && Context && Context->path)
+  else if (CheckMboxSize && Context && Context->mailbox->path)
     tmp->size = (off_t) sb.st_size; /* update the size of current folder */
 
 #ifdef USE_SIDEBAR
@@ -860,7 +860,7 @@ int mutt_mailbox_check(int force)
 #ifdef USE_NNTP
       || Context->magic == MUTT_NNTP
 #endif
-      || stat(Context->path, &contex_sb) != 0)
+      || stat(Context->mailbox->path, &contex_sb) != 0)
   {
     contex_sb.st_dev = 0;
     contex_sb.st_ino = 0;
index 506f4e512266ca87cfb5a1f9f60d82f07f82d55c..07d77c281e148a71b5b27f29f2ee9d54171edd2c 100644 (file)
@@ -279,9 +279,9 @@ static inline mode_t mh_umask(struct Context *ctx)
   if (data && data->mh_umask)
     return data->mh_umask;
 
-  if (stat(ctx->path, &st))
+  if (stat(ctx->mailbox->path, &st))
   {
-    mutt_debug(1, "stat failed on %s\n", ctx->path);
+    mutt_debug(1, "stat failed on %s\n", ctx->mailbox->path);
     return 077;
   }
 
@@ -448,7 +448,7 @@ static int mh_mkstemp(struct Context *dest, FILE **fp, char **tgt)
   omask = umask(mh_umask(dest));
   while (true)
   {
-    snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, dest->path,
+    snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, dest->mailbox->path,
              NONULL(ShortHostname), (int) getpid(), mutt_rand64());
     fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666);
     if (fd == -1)
@@ -566,7 +566,7 @@ static void mh_update_sequences(struct Context *ctx)
     return;
   }
 
-  snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->path);
+  snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->mailbox->path);
 
   /* first, copy unknown sequences */
   ofp = fopen(sequences, "r");
@@ -676,7 +676,7 @@ static void mh_sequences_add_one(struct Context *ctx, int n, bool unseen,
   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->path);
+  snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->mailbox->path);
   ofp = fopen(sequences, "r");
   if (ofp)
   {
@@ -854,18 +854,18 @@ static void maildir_update_mtime(struct Context *ctx)
 
   if (ctx->magic == MUTT_MAILDIR)
   {
-    snprintf(buf, sizeof(buf), "%s/%s", ctx->path, "cur");
+    snprintf(buf, sizeof(buf), "%s/%s", ctx->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->path, "new");
+    snprintf(buf, sizeof(buf), "%s/%s", ctx->mailbox->path, "new");
   }
   else
   {
-    snprintf(buf, sizeof(buf), "%s/.mh_sequences", ctx->path);
+    snprintf(buf, sizeof(buf), "%s/.mh_sequences", ctx->mailbox->path);
     if (stat(buf, &st) == 0)
       mutt_get_stat_timespec(&data->mtime_cur, &st, MUTT_STAT_MTIME);
 
-    mutt_str_strfcpy(buf, ctx->path, sizeof(buf));
+    mutt_str_strfcpy(buf, ctx->mailbox->path, sizeof(buf));
   }
 
   if (stat(buf, &st) == 0)
@@ -961,11 +961,11 @@ static int maildir_parse_dir(struct Context *ctx, struct Maildir ***last,
 
   if (subdir)
   {
-    snprintf(buf, sizeof(buf), "%s/%s", ctx->path, subdir);
+    snprintf(buf, sizeof(buf), "%s/%s", ctx->mailbox->path, subdir);
     is_old = MarkOld ? (mutt_str_strcmp("cur", subdir) == 0) : false;
   }
   else
-    mutt_str_strfcpy(buf, ctx->path, sizeof(buf));
+    mutt_str_strfcpy(buf, ctx->mailbox->path, sizeof(buf));
 
   dirp = opendir(buf);
   if (!dirp)
@@ -1264,7 +1264,7 @@ static void mh_sort_natural(struct Context *ctx, struct Maildir **md)
 {
   if (!ctx || !md || !*md || ctx->magic != MUTT_MH || Sort != SORT_ORDER)
     return;
-  mutt_debug(4, "maildir: sorting %s into natural order\n", ctx->path);
+  mutt_debug(4, "maildir: sorting %s into natural order\n", ctx->mailbox->path);
   *md = maildir_sort(*md, (size_t) -1, md_cmp_path);
 }
 
@@ -1314,7 +1314,7 @@ static void maildir_delayed_parsing(struct Context *ctx, struct Maildir **md,
 #endif
 
 #ifdef USE_HCACHE
-  header_cache_t *hc = mutt_hcache_open(HeaderCache, ctx->path, NULL);
+  header_cache_t *hc = mutt_hcache_open(HeaderCache, ctx->mailbox->path, NULL);
 #endif
 
   for (p = *md, count = 0; p; p = p->next, count++)
@@ -1330,7 +1330,7 @@ static void maildir_delayed_parsing(struct Context *ctx, struct Maildir **md,
 
     if (!sort)
     {
-      mutt_debug(4, "maildir: need to sort %s by inode\n", ctx->path);
+      mutt_debug(4, "maildir: need to sort %s by inode\n", ctx->mailbox->path);
       p = maildir_sort(p, (size_t) -1, md_cmp_inode);
       if (!last)
         *md = p;
@@ -1338,10 +1338,10 @@ static void maildir_delayed_parsing(struct Context *ctx, struct Maildir **md,
         last->next = p;
       sort = 1;
       p = skip_duplicates(p, &last);
-      snprintf(fn, sizeof(fn), "%s/%s", ctx->path, p->h->path);
+      snprintf(fn, sizeof(fn), "%s/%s", ctx->mailbox->path, p->h->path);
     }
 
-    snprintf(fn, sizeof(fn), "%s/%s", ctx->path, p->h->path);
+    snprintf(fn, sizeof(fn), "%s/%s", ctx->mailbox->path, p->h->path);
 
 #ifdef USE_HCACHE
     if (MaildirHeaderCacheVerify)
@@ -1444,7 +1444,7 @@ static int mh_read_dir(struct Context *ctx, const char *subdir)
 
   if (!ctx->quiet)
   {
-    snprintf(msgbuf, sizeof(msgbuf), _("Scanning %s..."), ctx->path);
+    snprintf(msgbuf, sizeof(msgbuf), _("Scanning %s..."), ctx->mailbox->path);
     mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, ReadInc, 0);
   }
 
@@ -1464,14 +1464,14 @@ static int mh_read_dir(struct Context *ctx, const char *subdir)
 
   if (!ctx->quiet)
   {
-    snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), ctx->path);
+    snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), ctx->mailbox->path);
     mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, ReadInc, count);
   }
   maildir_delayed_parsing(ctx, &md, &progress);
 
   if (ctx->magic == MUTT_MH)
   {
-    if (mh_read_sequences(&mhs, ctx->path) < 0)
+    if (mh_read_sequences(&mhs, ctx->mailbox->path) < 0)
     {
       maildir_free_maildir(&md);
       return -1;
@@ -1526,40 +1526,40 @@ static int maildir_mbox_open_append(struct Context *ctx, int flags)
     return 0;
   }
 
-  if (mkdir(ctx->path, S_IRWXU))
+  if (mkdir(ctx->mailbox->path, S_IRWXU))
   {
-    mutt_perror(ctx->path);
+    mutt_perror(ctx->mailbox->path);
     return -1;
   }
 
   char tmp[PATH_MAX];
-  snprintf(tmp, sizeof(tmp), "%s/cur", ctx->path);
+  snprintf(tmp, sizeof(tmp), "%s/cur", ctx->mailbox->path);
   if (mkdir(tmp, S_IRWXU))
   {
     mutt_perror(tmp);
-    rmdir(ctx->path);
+    rmdir(ctx->mailbox->path);
     return -1;
   }
 
-  snprintf(tmp, sizeof(tmp), "%s/new", ctx->path);
+  snprintf(tmp, sizeof(tmp), "%s/new", ctx->mailbox->path);
   if (mkdir(tmp, S_IRWXU))
   {
     mutt_perror(tmp);
-    snprintf(tmp, sizeof(tmp), "%s/cur", ctx->path);
+    snprintf(tmp, sizeof(tmp), "%s/cur", ctx->mailbox->path);
     rmdir(tmp);
-    rmdir(ctx->path);
+    rmdir(ctx->mailbox->path);
     return -1;
   }
 
-  snprintf(tmp, sizeof(tmp), "%s/tmp", ctx->path);
+  snprintf(tmp, sizeof(tmp), "%s/tmp", ctx->mailbox->path);
   if (mkdir(tmp, S_IRWXU))
   {
     mutt_perror(tmp);
-    snprintf(tmp, sizeof(tmp), "%s/cur", ctx->path);
+    snprintf(tmp, sizeof(tmp), "%s/cur", ctx->mailbox->path);
     rmdir(tmp);
-    snprintf(tmp, sizeof(tmp), "%s/new", ctx->path);
+    snprintf(tmp, sizeof(tmp), "%s/new", ctx->mailbox->path);
     rmdir(tmp);
-    rmdir(ctx->path);
+    rmdir(ctx->mailbox->path);
     return -1;
   }
 
@@ -1584,19 +1584,19 @@ static int mh_mbox_open_append(struct Context *ctx, int flags)
     return 0;
   }
 
-  if (mkdir(ctx->path, S_IRWXU))
+  if (mkdir(ctx->mailbox->path, S_IRWXU))
   {
-    mutt_perror(ctx->path);
+    mutt_perror(ctx->mailbox->path);
     return -1;
   }
 
   char tmp[PATH_MAX];
-  snprintf(tmp, sizeof(tmp), "%s/.mh_sequences", ctx->path);
+  snprintf(tmp, sizeof(tmp), "%s/.mh_sequences", ctx->mailbox->path);
   const int i = creat(tmp, S_IRWXU);
   if (i == -1)
   {
     mutt_perror(tmp);
-    rmdir(ctx->path);
+    rmdir(ctx->mailbox->path);
     return -1;
   }
   close(i);
@@ -1672,11 +1672,11 @@ static int maildir_mh_open_message(struct Context *ctx, struct Message *msg,
   struct Header *cur = ctx->hdrs[msgno];
   char path[PATH_MAX];
 
-  snprintf(path, sizeof(path), "%s/%s", ctx->path, cur->path);
+  snprintf(path, sizeof(path), "%s/%s", ctx->mailbox->path, cur->path);
 
   msg->fp = fopen(path, "r");
   if (!msg->fp && (errno == ENOENT) && is_maildir)
-    msg->fp = maildir_open_find_message(ctx->path, cur->path, NULL);
+    msg->fp = maildir_open_find_message(ctx->mailbox->path, cur->path, NULL);
 
   if (!msg->fp)
   {
@@ -1754,7 +1754,7 @@ static int maildir_msg_open_new(struct Context *ctx, struct Message *msg, struct
   omask = umask(mh_umask(ctx));
   while (true)
   {
-    snprintf(path, sizeof(path), "%s/tmp/%s.%lld.R%" PRIu64 ".%s%s", ctx->path, subdir,
+    snprintf(path, sizeof(path), "%s/tmp/%s.%lld.R%" PRIu64 ".%s%s", ctx->mailbox->path, subdir,
              (long long) time(NULL), mutt_rand64(), NONULL(ShortHostname), suffix);
 
     mutt_debug(2, "Trying %s.\n", path);
@@ -1844,7 +1844,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->path, path);
+    snprintf(full, sizeof(full), "%s/%s", ctx->mailbox->path, path);
 
     mutt_debug(2, "renaming %s to %s.\n", msg->path, full);
 
@@ -1884,7 +1884,7 @@ static int md_commit_message(struct Context *ctx, struct Message *msg, struct He
     }
     else if (errno != EEXIST)
     {
-      mutt_perror(ctx->path);
+      mutt_perror(ctx->mailbox->path);
       return -1;
     }
   }
@@ -1923,10 +1923,10 @@ static int mh_commit_msg(struct Context *ctx, struct Message *msg,
     return -1;
   }
 
-  dirp = opendir(ctx->path);
+  dirp = opendir(ctx->mailbox->path);
   if (!dirp)
   {
-    mutt_perror(ctx->path);
+    mutt_perror(ctx->mailbox->path);
     return -1;
   }
 
@@ -1961,7 +1961,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->path, tmp);
+    snprintf(path, sizeof(path), "%s/%s", ctx->mailbox->path, tmp);
     if (mutt_file_safe_rename(msg->path, path) == 0)
     {
       if (hdr)
@@ -1972,7 +1972,7 @@ static int mh_commit_msg(struct Context *ctx, struct Message *msg,
     }
     else if (errno != EEXIST)
     {
-      mutt_perror(ctx->path);
+      mutt_perror(ctx->mailbox->path);
       return -1;
     }
   }
@@ -2019,7 +2019,7 @@ static int mh_rewrite_message(struct Context *ctx, int msgno)
   {
     char oldpath[PATH_MAX];
     char partpath[PATH_MAX];
-    snprintf(oldpath, sizeof(oldpath), "%s/%s", ctx->path, h->path);
+    snprintf(oldpath, sizeof(oldpath), "%s/%s", ctx->mailbox->path, h->path);
     mutt_str_strfcpy(partpath, h->path, sizeof(partpath));
 
     if (ctx->magic == MUTT_MAILDIR)
@@ -2052,7 +2052,7 @@ static int mh_rewrite_message(struct Context *ctx, int msgno)
     if (ctx->magic == MUTT_MH && rc == 0)
     {
       char newpath[PATH_MAX];
-      snprintf(newpath, sizeof(newpath), "%s/%s", ctx->path, h->path);
+      snprintf(newpath, sizeof(newpath), "%s/%s", ctx->mailbox->path, h->path);
       rc = mutt_file_safe_rename(newpath, oldpath);
       if (rc == 0)
         mutt_str_replace(&h->path, partpath);
@@ -2139,8 +2139,8 @@ static int maildir_sync_message(struct Context *ctx, int msgno)
 
     snprintf(partpath, sizeof(partpath), "%s/%s%s",
              (h->read || h->old) ? "cur" : "new", newpath, suffix);
-    snprintf(fullpath, sizeof(fullpath), "%s/%s", ctx->path, partpath);
-    snprintf(oldpath, sizeof(oldpath), "%s/%s", ctx->path, h->path);
+    snprintf(fullpath, sizeof(fullpath), "%s/%s", ctx->mailbox->path, partpath);
+    snprintf(oldpath, sizeof(oldpath), "%s/%s", ctx->mailbox->path, h->path);
 
     if (mutt_str_strcmp(fullpath, oldpath) == 0)
     {
@@ -2180,7 +2180,7 @@ int mh_sync_mailbox_message(struct Context *ctx, int msgno)
   if (h->deleted && (ctx->magic != MUTT_MAILDIR || !MaildirTrash))
   {
     char path[PATH_MAX];
-    snprintf(path, sizeof(path), "%s/%s", ctx->path, h->path);
+    snprintf(path, sizeof(path), "%s/%s", ctx->mailbox->path, h->path);
     if (ctx->magic == MUTT_MAILDIR || (MhPurge && ctx->magic == MUTT_MH))
     {
 #ifdef USE_HCACHE
@@ -2209,7 +2209,7 @@ int mh_sync_mailbox_message(struct Context *ctx, int msgno)
       if (*h->path != ',')
       {
         char tmp[PATH_MAX];
-        snprintf(tmp, sizeof(tmp), "%s/,%s", ctx->path, h->path);
+        snprintf(tmp, sizeof(tmp), "%s/,%s", ctx->mailbox->path, h->path);
         unlink(tmp);
         rename(path, tmp);
       }
@@ -2334,11 +2334,11 @@ static int maildir_mbox_check(struct Context *ctx, int *index_hint)
   if (!CheckNew)
     return 0;
 
-  snprintf(buf, sizeof(buf), "%s/new", ctx->path);
+  snprintf(buf, sizeof(buf), "%s/new", ctx->mailbox->path);
   if (stat(buf, &st_new) == -1)
     return -1;
 
-  snprintf(buf, sizeof(buf), "%s/cur", ctx->path);
+  snprintf(buf, sizeof(buf), "%s/cur", ctx->mailbox->path);
   if (stat(buf, &st_cur) == -1)
     return -1;
 
@@ -2498,12 +2498,12 @@ static int mh_mbox_check(struct Context *ctx, int *index_hint)
   if (!CheckNew)
     return 0;
 
-  mutt_str_strfcpy(buf, ctx->path, sizeof(buf));
+  mutt_str_strfcpy(buf, ctx->mailbox->path, sizeof(buf));
   if (stat(buf, &st) == -1)
     return -1;
 
   /* create .mh_sequences when there isn't one. */
-  snprintf(buf, sizeof(buf), "%s/.mh_sequences", ctx->path);
+  snprintf(buf, sizeof(buf), "%s/.mh_sequences", ctx->mailbox->path);
   i = stat(buf, &st_cur);
   if ((i == -1) && (errno == ENOENT))
   {
@@ -2553,7 +2553,7 @@ static int mh_mbox_check(struct Context *ctx, int *index_hint)
   maildir_parse_dir(ctx, &last, NULL, &count, NULL);
   maildir_delayed_parsing(ctx, &md, NULL);
 
-  if (mh_read_sequences(&mhs, ctx->path) < 0)
+  if (mh_read_sequences(&mhs, ctx->mailbox->path) < 0)
     return -1;
   mh_update_maildir(md, &mhs);
   mhs_free_sequences(&mhs);
@@ -2629,12 +2629,12 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint)
 
 #ifdef USE_HCACHE
   if (ctx->magic == MUTT_MAILDIR || ctx->magic == MUTT_MH)
-    hc = mutt_hcache_open(HeaderCache, ctx->path, NULL);
+    hc = mutt_hcache_open(HeaderCache, ctx->mailbox->path, NULL);
 #endif
 
   if (!ctx->quiet)
   {
-    snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->path);
+    snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->mailbox->path);
     mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->msgcount);
   }
 
index 574268a8bad4a6754ff7f0d02f00ecef5a0f176e..12e6aa51ba349920c86847761e11ea8c2ba68d6e 100644 (file)
@@ -124,9 +124,9 @@ static int mmdf_parse_mailbox(struct Context *ctx)
   struct stat sb;
   struct Progress progress;
 
-  if (stat(ctx->path, &sb) == -1)
+  if (stat(ctx->mailbox->path, &sb) == -1)
   {
-    mutt_perror(ctx->path);
+    mutt_perror(ctx->mailbox->path);
     return -1;
   }
   mutt_get_stat_timespec(&ctx->atime, &sb, MUTT_STAT_ATIME);
@@ -138,7 +138,7 @@ static int mmdf_parse_mailbox(struct Context *ctx)
   if (!ctx->quiet)
   {
     char msgbuf[STRING];
-    snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), ctx->path);
+    snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), ctx->mailbox->path);
     mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, ReadInc, 0);
   }
 
@@ -284,9 +284,9 @@ static int mbox_parse_mailbox(struct Context *ctx)
   struct Progress progress;
 
   /* Save information about the folder at the time we opened it. */
-  if (stat(ctx->path, &sb) == -1)
+  if (stat(ctx->mailbox->path, &sb) == -1)
   {
-    mutt_perror(ctx->path);
+    mutt_perror(ctx->mailbox->path);
     return -1;
   }
 
@@ -295,12 +295,12 @@ static int mbox_parse_mailbox(struct Context *ctx)
   mutt_get_stat_timespec(&ctx->atime, &sb, MUTT_STAT_ATIME);
 
   if (!ctx->readonly)
-    ctx->readonly = access(ctx->path, W_OK) ? true : false;
+    ctx->readonly = access(ctx->mailbox->path, W_OK) ? true : false;
 
   if (!ctx->quiet)
   {
     char msgbuf[STRING];
-    snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), ctx->path);
+    snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), ctx->mailbox->path);
     mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, ReadInc, 0);
   }
 
@@ -467,10 +467,10 @@ static int mbox_mbox_open(struct Context *ctx)
 {
   int rc;
 
-  ctx->fp = fopen(ctx->path, "r");
+  ctx->fp = fopen(ctx->mailbox->path, "r");
   if (!ctx->fp)
   {
-    mutt_perror(ctx->path);
+    mutt_perror(ctx->mailbox->path);
     return -1;
   }
   mutt_sig_block();
@@ -498,16 +498,16 @@ static int mbox_mbox_open(struct Context *ctx)
  */
 static int mbox_mbox_open_append(struct Context *ctx, int flags)
 {
-  ctx->fp = mutt_file_fopen(ctx->path, (flags & MUTT_NEWFOLDER) ? "w" : "a");
+  ctx->fp = mutt_file_fopen(ctx->mailbox->path, (flags & MUTT_NEWFOLDER) ? "w" : "a");
   if (!ctx->fp)
   {
-    mutt_perror(ctx->path);
+    mutt_perror(ctx->mailbox->path);
     return -1;
   }
 
   if (mbox_lock_mailbox(ctx, 1, 1) != 0)
   {
-    mutt_error(_("Couldn't lock %s"), ctx->path);
+    mutt_error(_("Couldn't lock %s"), ctx->mailbox->path);
     mutt_file_fclose(&ctx->fp);
     return -1;
   }
@@ -703,7 +703,7 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint)
     case MUTT_MMDF:
       cmp_headers = mutt_header_cmp_strict;
       mutt_file_fclose(&ctx->fp);
-      ctx->fp = mutt_file_fopen(ctx->path, "r");
+      ctx->fp = mutt_file_fopen(ctx->mailbox->path, "r");
       if (!ctx->fp)
         rc = -1;
       else
@@ -826,7 +826,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint)
   bool unlock = false;
   bool modified = false;
 
-  if (stat(ctx->path, &st) == 0)
+  if (stat(ctx->mailbox->path, &st) == 0)
   {
     if ((mutt_stat_timespec_compare(&st, MUTT_STAT_MTIME, &ctx->mtime) == 0) &&
         st.st_size == ctx->size)
@@ -956,7 +956,7 @@ void mbox_reset_atime(struct Context *ctx, struct stat *st)
 
   if (!st)
   {
-    if (stat(ctx->path, &st2) < 0)
+    if (stat(ctx->mailbox->path, &st2) < 0)
       return;
     st = &st2;
   }
@@ -972,7 +972,7 @@ void mbox_reset_atime(struct Context *ctx, struct stat *st)
     utimebuf.actime = utimebuf.modtime - 1;
   }
 
-  utime(ctx->path, &utimebuf);
+  utime(ctx->mailbox->path, &utimebuf);
 }
 
 /**
@@ -1008,7 +1008,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
   /* need to open the file for writing in such a way that it does not truncate
    * the file, so use read-write mode.
    */
-  ctx->fp = freopen(ctx->path, "r+", ctx->fp);
+  ctx->fp = freopen(ctx->mailbox->path, "r+", ctx->fp);
   if (!ctx->fp)
   {
     mx_fastclose_mailbox(ctx);
@@ -1091,7 +1091,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
 
   if (!ctx->quiet)
   {
-    snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->path);
+    snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->mailbox->path);
     mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->msgcount);
   }
 
@@ -1178,9 +1178,9 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
   fp = NULL;
 
   /* Save the state of this folder. */
-  if (stat(ctx->path, &statbuf) == -1)
+  if (stat(ctx->mailbox->path, &statbuf) == -1)
   {
-    mutt_perror(ctx->path);
+    mutt_perror(ctx->mailbox->path);
     unlink(tempfile);
     goto bail;
   }
@@ -1265,7 +1265,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
   mbox_reset_atime(ctx, &statbuf);
 
   /* reopen the mailbox in read-only mode */
-  ctx->fp = fopen(ctx->path, "r");
+  ctx->fp = fopen(ctx->mailbox->path, "r");
   if (!ctx->fp)
   {
     unlink(tempfile);
@@ -1295,7 +1295,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
 
   if (CheckMboxSize)
   {
-    tmp = mutt_find_mailbox(ctx->path);
+    tmp = mutt_find_mailbox(ctx->mailbox->path);
     if (tmp && !tmp->new)
       mutt_update_mailbox(tmp);
   }
@@ -1326,7 +1326,7 @@ bail: /* Come here in case of disaster */
   FREE(&new_offset);
   FREE(&old_offset);
 
-  ctx->fp = freopen(ctx->path, "r", ctx->fp);
+  ctx->fp = freopen(ctx->mailbox->path, "r", ctx->fp);
   if (!ctx->fp)
   {
     mutt_error(_("Could not reopen mailbox"));
diff --git a/mx.c b/mx.c
index 17143267373ffe8066f0a6fb8ddff88e7ac1df93..5193292c0c403cfb591280a7d8f98ca3d24e2a1d 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -179,7 +179,7 @@ static int mx_open_mailbox_append(struct Context *ctx, int flags)
   struct stat sb;
 
   ctx->append = true;
-  ctx->magic = mx_path_probe(ctx->path, NULL);
+  ctx->magic = mx_path_probe(ctx->mailbox->path, NULL);
   if (ctx->magic == MUTT_UNKNOWN)
   {
     if (flags & (MUTT_APPEND | MUTT_NEWFOLDER))
@@ -188,14 +188,14 @@ static int mx_open_mailbox_append(struct Context *ctx, int flags)
     }
     else
     {
-      mutt_error(_("%s is not a mailbox"), ctx->path);
+      mutt_error(_("%s is not a mailbox"), ctx->mailbox->path);
       return -1;
     }
   }
 
   if (ctx->magic == MUTT_MAILBOX_ERROR)
   {
-    if (stat(ctx->path, &sb) == -1)
+    if (stat(ctx->mailbox->path, &sb) == -1)
     {
       if (errno == ENOENT)
       {
@@ -209,7 +209,7 @@ static int mx_open_mailbox_append(struct Context *ctx, int flags)
       }
       else
       {
-        mutt_perror(ctx->path);
+        mutt_perror(ctx->mailbox->path);
         return -1;
       }
     }
@@ -247,21 +247,17 @@ struct Context *mx_mbox_open(const char *path, int flags)
 
   struct Context *ctx = mutt_mem_calloc(1, sizeof(*ctx));
 
-  ctx->path = mutt_str_strdup(path);
-  if (!ctx->path)
-  {
-    FREE(&ctx);
-    return NULL;
-  }
-  ctx->mailbox = mutt_find_mailbox(ctx->path);
+  ctx->mailbox = mutt_find_mailbox(ctx->mailbox->path);
   if (!ctx->mailbox)
   {
-    ctx->mailbox = mailbox_new(ctx->path);
+    ctx->mailbox = mailbox_new(ctx->mailbox->path);
     ctx->mailbox->flags = MB_HIDDEN;
   }
 
-  if (!realpath(ctx->path, ctx->mailbox->realpath))
-    mutt_str_strfcpy(ctx->mailbox->realpath, ctx->path, sizeof(ctx->mailbox->realpath));
+  mutt_str_strfcpy(ctx->mailbox->path, path, sizeof(ctx->mailbox->path));
+
+  if (!realpath(ctx->mailbox->path, ctx->mailbox->realpath))
+    mutt_str_strfcpy(ctx->mailbox->realpath, ctx->mailbox->path, sizeof(ctx->mailbox->realpath));
 
   ctx->msgnotreadyet = -1;
   ctx->collapsed = false;
@@ -312,7 +308,7 @@ struct Context *mx_mbox_open(const char *path, int flags)
   OptForceRefresh = true;
 
   if (!ctx->quiet)
-    mutt_message(_("Reading %s..."), ctx->path);
+    mutt_message(_("Reading %s..."), ctx->mailbox->path);
 
   rc = ctx->mx_ops->mbox_open(ctx);
 
@@ -329,7 +325,7 @@ struct Context *mx_mbox_open(const char *path, int flags)
     if (!ctx->quiet)
       mutt_clear_error();
     if (rc == -2)
-      mutt_error(_("Reading from %s interrupted..."), ctx->path);
+      mutt_error(_("Reading from %s interrupted..."), ctx->mailbox->path);
   }
   else
   {
@@ -357,23 +353,23 @@ void mx_fastclose_mailbox(struct Context *ctx)
     return;
 
   /* fix up the times so mailbox won't get confused */
-  if (ctx->peekonly && ctx->path && (mutt_timespec_compare(&ctx->mtime, &ctx->atime) > 0))
+  if (ctx->peekonly && ctx->mailbox->path && (mutt_timespec_compare(&ctx->mtime, &ctx->atime) > 0))
   {
 #ifdef HAVE_UTIMENSAT
     ts[0] = ctx->atime;
     ts[1] = ctx->mtime;
-    utimensat(0, ctx->path, ts, 0);
+    utimensat(0, ctx->mailbox->path, ts, 0);
 #else
     ut.actime = ctx->atime.tv_sec;
     ut.modtime = ctx->mtime.tv_sec;
-    utime(ctx->path, &ut);
+    utime(ctx->mailbox->path, &ut);
 #endif /* HAVE_UTIMENSAT */
   }
 
   /* never announce that a mailbox we've just left has new mail. #3290
    * TODO: really belongs in mx_mbox_close, but this is a nice hook point */
   if (!ctx->peekonly)
-    mutt_mailbox_setnotified(ctx->path);
+    mutt_mailbox_setnotified(ctx->mailbox->path);
 
   if (ctx->mx_ops)
     ctx->mx_ops->mbox_close(ctx);
@@ -388,7 +384,6 @@ void mx_fastclose_mailbox(struct Context *ctx)
     mutt_header_free(&ctx->hdrs[i]);
   FREE(&ctx->hdrs);
   FREE(&ctx->v2r);
-  FREE(&ctx->path);
   FREE(&ctx->pattern);
   if (ctx->limit_pattern)
     mutt_pattern_free(&ctx->limit_pattern);
@@ -411,14 +406,14 @@ static int sync_mailbox(struct Context *ctx, int *index_hint)
   if (!ctx->quiet)
   {
     /* L10N: Displayed before/as a mailbox is being synced */
-    mutt_message(_("Writing %s..."), ctx->path);
+    mutt_message(_("Writing %s..."), ctx->mailbox->path);
   }
 
   int rc = ctx->mx_ops->mbox_sync(ctx, index_hint);
   if ((rc != 0) && !ctx->quiet)
   {
     /* L10N: Displayed if a mailbox sync fails */
-    mutt_error(_("Unable to write %s"), ctx->path);
+    mutt_error(_("Unable to write %s"), ctx->mailbox->path);
   }
 
   return rc;
@@ -470,7 +465,7 @@ static int trash_append(struct Context *ctx)
     return -1;
   }
 
-  if (lstat(ctx->path, &stc) == 0 && stc.st_ino == st.st_ino &&
+  if (lstat(ctx->mailbox->path, &stc) == 0 && stc.st_ino == st.st_ino &&
       stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
   {
     return 0; /* we are in the trash folder: simple sync */
@@ -575,7 +570,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
   if (read_msgs && Move != MUTT_NO)
   {
     int is_spool;
-    char *p = mutt_find_hook(MUTT_MBOX_HOOK, ctx->path);
+    char *p = mutt_find_hook(MUTT_MBOX_HOOK, ctx->mailbox->path);
     if (p)
     {
       is_spool = 1;
@@ -584,7 +579,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
     else
     {
       mutt_str_strfcpy(mbox, Mbox, sizeof(mbox));
-      is_spool = mutt_is_spool(ctx->path) && !mutt_is_spool(mbox);
+      is_spool = mutt_is_spool(ctx->mailbox->path) && !mutt_is_spool(mbox);
     }
 
     if (is_spool && *mbox)
@@ -708,7 +703,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
   }
 
   /* copy mails to the trash before expunging */
-  if (purge && ctx->deleted && (mutt_str_strcmp(ctx->path, Trash) != 0))
+  if (purge && ctx->deleted && (mutt_str_strcmp(ctx->mailbox->path, Trash) != 0))
   {
     if (trash_append(ctx) != 0)
     {
@@ -764,9 +759,9 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
   }
 
   if (ctx->msgcount == ctx->deleted && (ctx->magic == MUTT_MMDF || ctx->magic == MUTT_MBOX) &&
-      !mutt_is_spool(ctx->path) && !SaveEmpty)
+      !mutt_is_spool(ctx->mailbox->path) && !SaveEmpty)
   {
-    mutt_file_unlink_empty(ctx->path);
+    mutt_file_unlink_empty(ctx->mailbox->path);
   }
 
 #ifdef USE_SIDEBAR
@@ -953,7 +948,7 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint)
   msgcount = ctx->msgcount;
   deleted = ctx->deleted;
 
-  if (purge && ctx->deleted && (mutt_str_strcmp(ctx->path, Trash) != 0))
+  if (purge && ctx->deleted && (mutt_str_strcmp(ctx->mailbox->path, Trash) != 0))
   {
     if (trash_append(ctx) != 0)
       return -1;
@@ -983,9 +978,9 @@ 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) &&
-        !mutt_is_spool(ctx->path) && !SaveEmpty)
+        !mutt_is_spool(ctx->mailbox->path) && !SaveEmpty)
     {
-      unlink(ctx->path);
+      unlink(ctx->mailbox->path);
       mx_fastclose_mailbox(ctx);
       return 0;
     }
index 57773f40471f9edad2057b0e8bff46aa3ff5f333..6a3f20c8efa39c1e102ea0ade234da638c4de5b3 100644 (file)
@@ -45,6 +45,7 @@
 #include "context.h"
 #include "curs_lib.h"
 #include "globals.h"
+#include "mailbox.h"
 #include "mutt_account.h"
 #include "mutt_logging.h"
 #include "mutt_parse.h"
@@ -1518,12 +1519,12 @@ static int nntp_mbox_open(struct Context *ctx)
   anum_t first, last, count = 0;
   struct Url url;
 
-  mutt_str_strfcpy(buf, ctx->path, sizeof(buf));
+  mutt_str_strfcpy(buf, ctx->mailbox->path, sizeof(buf));
   if (url_parse(&url, buf) < 0 || !url.host || !url.path ||
       !(url.scheme == U_NNTP || url.scheme == U_NNTPS))
   {
     url_free(&url);
-    mutt_error(_("%s is an invalid newsgroup specification"), ctx->path);
+    mutt_error(_("%s is an invalid newsgroup specification"), ctx->mailbox->path);
     return -1;
   }
 
index c749464c6bb62189c6ff089a929e99118f8f8709..755feb233195399533ec4579f4fc2a7bd3706c68 100644 (file)
@@ -243,7 +243,7 @@ static int init_context(struct Context *ctx)
   if (ctx->data)
     return 0;
 
-  ctx->data = new_ctxdata(ctx->path);
+  ctx->data = new_ctxdata(ctx->mailbox->path);
   if (!ctx->data)
     return -1;
 
@@ -2287,7 +2287,7 @@ char *nm_get_description(struct Context *ctx)
   struct MailboxNode *np = NULL;
   STAILQ_FOREACH(np, &AllMailboxes, entries)
   {
-    if (np->b->desc && (strcmp(np->b->path, ctx->path) == 0))
+    if (np->b->desc && (strcmp(np->b->path, ctx->mailbox->path) == 0))
       return np->b->desc;
   }
 
@@ -2646,7 +2646,7 @@ static int nm_mbox_sync(struct Context *ctx, int *index_hint)
   struct NmCtxData *data = get_ctxdata(ctx);
   int rc = 0;
   struct Progress progress;
-  char *uri = ctx->path;
+  char *uri = ctx->mailbox->path;
   bool changed = false;
 
   if (!data)
@@ -2658,7 +2658,7 @@ 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->path);
+    snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->mailbox->path);
     mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->msgcount);
   }
 
@@ -2683,14 +2683,14 @@ static int nm_mbox_sync(struct Context *ctx, int *index_hint)
     else
       header_get_fullpath(h, old, sizeof(old));
 
-    ctx->path = hd->folder;
+    mutt_str_strfcpy(ctx->mailbox->path, hd->folder, sizeof(ctx->mailbox->path));
     ctx->magic = hd->magic;
 #ifdef USE_HCACHE
     rc = mh_sync_mailbox_message(ctx, i, NULL);
 #else
     rc = mh_sync_mailbox_message(ctx, i);
 #endif
-    ctx->path = uri;
+    mutt_str_strfcpy(ctx->mailbox->path, uri, sizeof(ctx->mailbox->path));
     ctx->magic = MUTT_NOTMUCH;
 
     if (rc)
@@ -2710,7 +2710,7 @@ static int nm_mbox_sync(struct Context *ctx, int *index_hint)
     FREE(&hd->oldpath);
   }
 
-  ctx->path = uri;
+  mutt_str_strfcpy(ctx->mailbox->path, uri, sizeof(ctx->mailbox->path));
   ctx->magic = MUTT_NOTMUCH;
 
   if (!is_longrun(data))
diff --git a/pager.c b/pager.c
index 10e9a971c79d7449de57739d209fcfbfdf51f674..6079782ff2583208e9142f30114c9484d53fe74c 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -2341,7 +2341,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
       check = mx_mbox_check(Context, &index_hint);
       if (check < 0)
       {
-        if (!Context->path)
+        if (!Context->mailbox->path)
         {
           /* fatal error occurred */
           mutt_context_free(&Context);
index a7b9841db07d78f51fb934b81895aa3efa3eeb97..e1b160e1167ab3758fdd5bfe9ee4e58e978ddbc3 100644 (file)
--- a/pop/pop.c
+++ b/pop/pop.c
@@ -317,7 +317,7 @@ static int pop_fetch_headers(struct Context *ctx)
   struct Progress progress;
 
 #ifdef USE_HCACHE
-  header_cache_t *hc = pop_hcache_open(pop_data, ctx->path);
+  header_cache_t *hc = pop_hcache_open(pop_data, ctx->mailbox->path);
 #endif
 
   time(&pop_data->check_time);
@@ -488,9 +488,9 @@ static int pop_mbox_open(struct Context *ctx)
   struct PopData *pop_data = NULL;
   struct Url url;
 
-  if (pop_parse_path(ctx->path, &acct))
+  if (pop_parse_path(ctx->mailbox->path, &acct))
   {
-    mutt_error(_("%s is an invalid POP path"), ctx->path);
+    mutt_error(_("%s is an invalid POP mailbox->path"), ctx->mailbox->path);
     return -1;
   }
 
@@ -501,9 +501,8 @@ static int pop_mbox_open(struct Context *ctx)
   if (!conn)
     return -1;
 
-  FREE(&ctx->path);
-  ctx->path = mutt_str_strdup(buf);
-  mutt_str_strfcpy(ctx->mailbox->realpath, ctx->path, sizeof(ctx->mailbox->realpath));
+  mutt_str_strfcpy(ctx->mailbox->path, buf, sizeof(ctx->mailbox->path));
+  mutt_str_strfcpy(ctx->mailbox->realpath, ctx->mailbox->path, sizeof(ctx->mailbox->realpath));
 
   pop_data = mutt_mem_calloc(1, sizeof(struct PopData));
   pop_data->conn = conn;
@@ -789,7 +788,7 @@ static int pop_mbox_sync(struct Context *ctx, int *index_hint)
                        MUTT_PROGRESS_MSG, WriteInc, ctx->deleted);
 
 #ifdef USE_HCACHE
-    hc = pop_hcache_open(pop_data, ctx->path);
+    hc = pop_hcache_open(pop_data, ctx->mailbox->path);
 #endif
 
     for (i = 0, j = 0, ret = 0; ret == 0 && i < ctx->msgcount; i++)
index 4e0c353d130b171b0d6241c967d09ed05455bfee..4f67cd9f7e85f8ee648689bc9e4a3d652ecbbc24 100644 (file)
--- a/status.c
+++ b/status.c
@@ -137,9 +137,9 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
       }
       else
 #endif
-          if (Context && Context->path)
+          if (Context && Context->mailbox->path)
       {
-        mutt_str_strfcpy(tmp, Context->path, sizeof(tmp));
+        mutt_str_strfcpy(tmp, Context->mailbox->path, sizeof(tmp));
         mutt_pretty_mailbox(tmp, sizeof(tmp));
       }
       else