}
#endif
- savectx = mx_mbox_open(buf, MUTT_APPEND, NULL);
+ savectx = mx_mbox_open(buf, MUTT_APPEND);
if (savectx)
{
#ifdef USE_COMPRESSED
menu->redraw = REDRAW_FULL;
- ctx = mx_mbox_open(fname, MUTT_READONLY, NULL);
+ ctx = mx_mbox_open(fname, MUTT_READONLY);
if (!ctx)
{
mutt_error(_("Unable to open mailbox %s"), fname);
mutt_folder_hook(buf);
const int flags = (ReadOnly || (op == OP_MAIN_CHANGE_FOLDER_READONLY)) ? MUTT_READONLY : 0;
- Context = mx_mbox_open(buf, flags, NULL);
+ Context = mx_mbox_open(buf, flags);
if (Context)
{
menu->current = ci_first_message();
omagic = MboxType;
MboxType = MUTT_MBOX;
- tmpctx = mx_mbox_open(tmp, MUTT_NEWFOLDER, NULL);
+ tmpctx = mx_mbox_open(tmp, MUTT_NEWFOLDER);
MboxType = omagic;
goto bail;
}
- tmpctx = mx_mbox_open(ctx->path, MUTT_APPEND, NULL);
+ tmpctx = mx_mbox_open(ctx->path, MUTT_APPEND);
if (!tmpctx)
{
rc = -1;
"Saving changed messages... [%d/%d]", ctx->msgcount),
i + 1, ctx->msgcount);
if (!appendctx)
- appendctx = mx_mbox_open(ctx->path, MUTT_APPEND | MUTT_QUIET, NULL);
+ appendctx = mx_mbox_open(ctx->path, MUTT_APPEND | MUTT_QUIET);
if (!appendctx)
mutt_debug(1, "Error opening mailbox in append mode\n");
else
if (check_stats && (mailbox->stats_last_checked < sb->st_mtime))
{
- struct Context *ctx = mx_mbox_open(mailbox->path, MUTT_READONLY | MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK, NULL);
+ struct Context *ctx = mx_mbox_open(mailbox->path, MUTT_READONLY | MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK);
if (ctx)
{
mailbox->msg_count = ctx->msgcount;
mutt_startup_shutdown_hook(MUTT_STARTUP_HOOK);
repeat_error = true;
- Context = mx_mbox_open(folder, ((flags & MUTT_RO) || ReadOnly) ? MUTT_READONLY : 0, NULL);
+ Context = mx_mbox_open(folder, ((flags & MUTT_RO) || ReadOnly) ? MUTT_READONLY : 0);
if (Context || !explicit_folder)
{
#ifdef USE_SIDEBAR
return -1;
if (!fgets(buf, sizeof(buf), fp))
return -1;
- struct Context *ctx = mx_mbox_open(path, MUTT_APPEND | MUTT_QUIET, NULL);
+ struct Context *ctx = mx_mbox_open(path, MUTT_APPEND | MUTT_QUIET);
if (!ctx)
return -1;
msg = mx_msg_open_new(ctx, hn, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM);
* mx_mbox_open - Open a mailbox and parse it
* @param path Path to the mailbox
* @param flags See below
- * @param pctx Reuse this Context (if supplied)
* @retval ptr Mailbox context
* @retval NULL Error
*
* * #MUTT_QUIET only print error messages
* * #MUTT_PEEK revert atime where applicable
*/
-struct Context *mx_mbox_open(const char *path, int flags, struct Context *pctx)
+struct Context *mx_mbox_open(const char *path, int flags)
{
- struct Context *ctx = pctx;
- int rc;
-
if (!path || !path[0])
return NULL;
- if (!ctx)
- ctx = mutt_mem_malloc(sizeof(struct Context));
- memset(ctx, 0, sizeof(struct Context));
+ int rc;
+
+ struct Context *ctx = mutt_mem_calloc(1, sizeof(*ctx));
ctx->path = mutt_str_strdup(path);
if (!ctx->path)
{
- if (!pctx)
- FREE(&ctx);
+ FREE(&ctx);
return NULL;
}
ctx->realpath = realpath(ctx->path, NULL);
if (mx_open_mailbox_append(ctx, flags) != 0)
{
mx_fastclose_mailbox(ctx);
- if (!pctx)
- FREE(&ctx);
+ FREE(&ctx);
return NULL;
}
return ctx;
mutt_error(_("%s is not a mailbox"), path);
mx_fastclose_mailbox(ctx);
- if (!pctx)
- FREE(&ctx);
+ FREE(&ctx);
return NULL;
}
else
{
mx_fastclose_mailbox(ctx);
- if (!pctx)
- FREE(&ctx);
+ FREE(&ctx);
}
OptForceRefresh = false;
}
#endif
- struct Context *ctx_trash = mx_mbox_open(Trash, MUTT_APPEND, NULL);
+ struct Context *ctx_trash = mx_mbox_open(Trash, MUTT_APPEND);
if (ctx_trash)
{
/* continue from initial scan above */
else /* use regular append-copy mode */
#endif
{
- struct Context *f = mx_mbox_open(mbox, MUTT_APPEND, NULL);
+ struct Context *f = mx_mbox_open(mbox, MUTT_APPEND);
if (!f)
{
ctx->closing = false;
/* Wrappers for the Mailbox API, see MxOps */
int mx_mbox_check (struct Context *ctx, int *index_hint);
int mx_mbox_close (struct Context *ctx, int *index_hint);
-struct Context *mx_mbox_open (const char *path, int flags, struct Context *pctx);
+struct Context *mx_mbox_open (const char *path, int flags);
int mx_mbox_sync (struct Context *ctx, int *index_hint);
int mx_msg_close (struct Context *ctx, struct Message **msg);
int mx_msg_commit (struct Context *ctx, struct Message *msg);
goto finish;
}
- struct Context *ctx = mx_mbox_open(Spoolfile, MUTT_APPEND, NULL);
+ struct Context *ctx = mx_mbox_open(Spoolfile, MUTT_APPEND);
if (!ctx)
goto finish;
if (optnews)
OptNews = false;
#endif
- struct Context *ctx = mx_mbox_open(Postponed, MUTT_NOSORT | MUTT_QUIET, NULL);
+ struct Context *ctx = mx_mbox_open(Postponed, MUTT_NOSORT | MUTT_QUIET);
if (!ctx)
PostCount = 0;
else
if (!Postponed)
return -1;
- PostContext = mx_mbox_open(Postponed, MUTT_NOSORT, NULL);
+ PostContext = mx_mbox_open(Postponed, MUTT_NOSORT);
if (!PostContext)
{
PostCount = 0;
#ifdef RECORD_FOLDER_HOOK
mutt_folder_hook(path);
#endif
- struct Context *f = mx_mbox_open(path, MUTT_APPEND | MUTT_QUIET, NULL);
+ struct Context *f = mx_mbox_open(path, MUTT_APPEND | MUTT_QUIET);
if (!f)
{
mutt_debug(1, "unable to open mailbox %s in append-mode, aborting.\n", path);