enum MailboxType magic = mx_path_probe(buf, NULL);
if ((magic == MUTT_MAILBOX_ERROR) || (magic == MUTT_UNKNOWN))
{
- mutt_error(_("%s is not a mailbox"), buf);
- return -1;
+ // Try and see if the buffer matches a description before we bail. We'll receive a
+ // non-null pointer if there is a corresponding mailbox.
+ m = mutt_find_mailbox_desc(buf);
+ if (m)
+ {
+ magic = m->magic;
+ mutt_str_strfcpy(buf, m->path, buflen);
+ }
+ else
+ {
+ // Bail.
+ mutt_error(_("%s is not a mailbox"), buf);
+ return -1;
+ }
}
/* keepalive failure in mutt_enter_fname may kill connection. #3028 */
*/
int mutt_index_menu(void)
{
- char buf[LONG_STRING], helpstr[LONG_STRING];
+ char buf[PATH_MAX], helpstr[LONG_STRING];
int flags;
int op = OP_NULL;
bool done = false; /* controls when to exit the "event" loop */
return NULL;
}
+/**
+ * mutt_find_mailbox_desc - Find the mailbox with a given description
+ * @param desc Description to match
+ * @retval ptr Matching Mailbox
+ * @retval NULL No matching mailbox found
+ */
+struct Mailbox *mutt_find_mailbox_desc(const char *desc)
+{
+ if (!desc)
+ return NULL;
+
+ struct MailboxNode *np = NULL;
+ STAILQ_FOREACH(np, &AllMailboxes, entries)
+ {
+ if (np->m->desc && mutt_str_strcmp(np->m->desc, desc) == 0)
+ return np->m;
+ }
+
+ return NULL;
+}
+
/**
* mutt_update_mailbox - Get the mailbox's current size
* @param m Mailbox to check
void mutt_context_free(struct Context **ctx);
struct Mailbox *mutt_find_mailbox(const char *path);
+struct Mailbox *mutt_find_mailbox_desc(const char *desc);
void mutt_update_mailbox(struct Mailbox *m);
void mutt_mailbox_cleanup(const char *path, struct stat *st);