*/
struct CompressInfo
{
- const char *append; /**< append-hook command */
- const char *close; /**< close-hook command */
- const char *open; /**< open-hook command */
- off_t size; /**< size of the compressed file */
- struct MxOps *child_ops; /**< callbacks of de-compressed file */
- int locked; /**< if realpath is locked */
- FILE *lockfp; /**< fp used for locking */
+ const char *append; /**< append-hook command */
+ const char *close; /**< close-hook command */
+ const char *open; /**< open-hook command */
+ off_t size; /**< size of the compressed file */
+ const struct MxOps *child_ops; /**< callbacks of de-compressed file */
+ int locked; /**< if realpath is locked */
+ FILE *lockfp; /**< fp used for locking */
};
/**
if (!ci)
return -1;
- struct MxOps *ops = ci->child_ops;
+ const struct MxOps *ops = ci->child_ops;
if (!ops)
{
free_compress_info(ctx);
if (!ci)
return -1;
- struct MxOps *ops = ci->child_ops;
+ const struct MxOps *ops = ci->child_ops;
if (!ops)
return -1;
if (!ci)
return -1;
- struct MxOps *ops = ci->child_ops;
+ const struct MxOps *ops = ci->child_ops;
if (!ops)
return -1;
if (!ci)
return -1;
- struct MxOps *ops = ci->child_ops;
+ const struct MxOps *ops = ci->child_ops;
if (!ops)
return -1;
if (!ci)
return -1;
- struct MxOps *ops = ci->child_ops;
+ const struct MxOps *ops = ci->child_ops;
if (!ops)
return -1;
if (!ci)
return -1;
- struct MxOps *ops = ci->child_ops;
+ const struct MxOps *ops = ci->child_ops;
if (!ops)
return -1;
return -1;
}
- struct MxOps *ops = ci->child_ops;
+ const struct MxOps *ops = ci->child_ops;
if (!ops)
return -1;
* The message functions are delegated to mbox.
*/
struct MxOps mx_comp_ops = {
+ .magic = MUTT_COMPRESSED,
+ .name = "compressed",
.mbox_open = comp_mbox_open,
.mbox_open_append = comp_mbox_open_append,
.mbox_check = comp_mbox_check,
/* driver hooks */
void *data; /**< driver specific data */
- struct MxOps *mx_ops;
+ const struct MxOps *mx_ops;
};
#endif /* _MUTT_CONTEXT_H */
* struct mx_imap_ops - Mailbox callback functions for IMAP mailboxes
*/
struct MxOps mx_imap_ops = {
+ .magic = MUTT_IMAP,
+ .name = "imap",
.mbox_open = imap_mbox_open,
.mbox_open_append = imap_mbox_open_append,
.mbox_check = imap_mbox_check,
* struct mx_maildir_ops - Mailbox callback functions for Maildir mailboxes
*/
struct MxOps mx_maildir_ops = {
+ .magic = MUTT_MAILDIR,
+ .name = "maildir",
.mbox_open = maildir_mbox_open,
.mbox_open_append = maildir_mbox_open_append,
.mbox_check = maildir_mbox_check,
* struct mx_mh_ops - Mailbox callback functions for MH mailboxes
*/
struct MxOps mx_mh_ops = {
+ .magic = MUTT_MH,
+ .name = "mh",
.mbox_open = mh_mbox_open,
.mbox_open_append = mh_mbox_open_append,
.mbox_check = mh_mbox_check,
* struct mx_mbox_ops - Mailbox callback functions for mbox mailboxes
*/
struct MxOps mx_mbox_ops = {
+ .magic = MUTT_MBOX,
+ .name = "mbox",
.mbox_open = mbox_mbox_open,
.mbox_open_append = mbox_mbox_open_append,
.mbox_check = mbox_mbox_check,
* struct mx_mmdf_ops - Mailbox callback functions for MMDF mailboxes
*/
struct MxOps mx_mmdf_ops = {
+ .magic = MUTT_MMDF,
+ .name = "mmdf",
.mbox_open = mbox_mbox_open,
.mbox_open_append = mbox_mbox_open_append,
.mbox_check = mbox_mbox_check,
char *Trash; ///< Config: Folder to put deleted emails
/**
- * mx_get_ops - Get mailbox operations
- * @param magic Mailbox magic number
- * @retval ptr Mailbox function
- * @retval NULL Error
+ * mx_ops - All the Mailbox backends
*/
-struct MxOps *mx_get_ops(enum MailboxType magic)
-{
- switch (magic)
- {
-#ifdef USE_IMAP
- case MUTT_IMAP:
- return &mx_imap_ops;
-#endif
- case MUTT_MAILDIR:
- return &mx_maildir_ops;
- case MUTT_MBOX:
- return &mx_mbox_ops;
- case MUTT_MH:
- return &mx_mh_ops;
- case MUTT_MMDF:
- return &mx_mmdf_ops;
-#ifdef USE_POP
- case MUTT_POP:
- return &mx_pop_ops;
-#endif
+const struct MxOps *mx_ops[] = {
#ifdef USE_COMPRESSED
- case MUTT_COMPRESSED:
- return &mx_comp_ops;
+ &mx_comp_ops,
+#endif
+#ifdef USE_IMAP
+ &mx_imap_ops,
#endif
+ &mx_maildir_ops,
+ &mx_mbox_ops,
+ &mx_mh_ops,
+ &mx_mmdf_ops,
#ifdef USE_NNTP
- case MUTT_NNTP:
- return &mx_nntp_ops;
+ &mx_nntp_ops,
#endif
#ifdef USE_NOTMUCH
- case MUTT_NOTMUCH:
- return &mx_notmuch_ops;
+ &mx_notmuch_ops,
#endif
- default:
- return NULL;
- }
+#ifdef USE_POP
+ &mx_pop_ops,
+#endif
+ NULL,
+};
+
+/**
+ * mx_get_ops - Get mailbox operations
+ * @param magic Mailbox magic number
+ * @retval ptr Mailbox function
+ * @retval NULL Error
+ */
+const struct MxOps *mx_get_ops(int magic)
+{
+ for (const struct MxOps **ops = mx_ops; *ops; ops++)
+ if ((*ops)->magic == magic)
+ return *ops;
+
+ return NULL;
}
/**
*/
struct MxOps
{
+ const int magic;
+ const char *name;
/**
* mbox_open - Open a mailbox
* @param ctx Mailbox to open
void mx_update_context(struct Context *ctx, int new_messages);
void mx_update_tables(struct Context *ctx, bool committing);
-struct MxOps *mx_get_ops(enum MailboxType magic);
+const struct MxOps *mx_get_ops(enum MailboxType magic);
/* This variable is backing for a config item */
WHERE short MboxType; ///< Config: Default type for creating new mailboxes
* struct mx_nntp_ops - Mailbox callback functions for NNTP mailboxes
*/
struct MxOps mx_nntp_ops = {
+ .magic = MUTT_NNTP,
+ .name = "nntp",
.mbox_open = nntp_mbox_open,
.mbox_open_append = NULL,
.mbox_check = nntp_mbox_check,
* struct mx_notmuch_ops - Mailbox callback functions for Notmuch mailboxes
*/
struct MxOps mx_notmuch_ops = {
+ .magic = MUTT_NOTMUCH,
+ .name = "notmuch",
.mbox_open = nm_mbox_open, /* calls init_context() */
.mbox_open_append = NULL,
.mbox_check = nm_mbox_check,
* mx_pop_ops - Mailbox callback functions for POP mailboxes
*/
struct MxOps mx_pop_ops = {
+ .magic = MUTT_POP,
+ .name = "pop",
.mbox_open = pop_mbox_open,
.mbox_open_append = NULL,
.mbox_check = pop_mbox_check,