]> granicus.if.org Git - neomutt/commitdiff
tidy mx
authorRichard Russon <rich@flatcap.org>
Sat, 25 Aug 2018 12:52:36 +0000 (13:52 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 26 Aug 2018 21:11:03 +0000 (22:11 +0100)
mx.c
mx.h

diff --git a/mx.c b/mx.c
index d5185336e82e1c103d1d2c6b7af66ef92df41977..f1d43c185a591632d9636fc9b10b035f3f937c87 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -87,6 +87,7 @@
 /* These Config Variables are only used in mx.c */
 unsigned char CatchupNewsgroup; ///< Config: (nntp) Mark all articles as read when leaving a newsgroup
 bool KeepFlagged; ///< Config: Don't move flagged messages from Spoolfile to Mbox
+short MboxType;     ///< Config: Default type for creating new mailboxes
 unsigned char Move; ///< Config: Move emails from Spoolfile to Mbox when read
 char *Trash;        ///< Config: Folder to put deleted emails
 
@@ -142,7 +143,6 @@ static bool mutt_is_spool(const char *str)
 }
 
 #ifdef USE_IMAP
-
 /**
  * mx_is_imap - Is this an IMAP mailbox
  * @param p Mailbox string to test
@@ -164,7 +164,6 @@ bool mx_is_imap(const char *p)
 
   return false;
 }
-
 #endif
 
 #ifdef USE_POP
diff --git a/mx.h b/mx.h
index 7ea7be1c6fdbe273aba79e7c15ad90ea4cd14e3a..cc5fa7668990a1b4eebe7523f84c96171e300fdd 100644 (file)
--- a/mx.h
+++ b/mx.h
 #include <stdbool.h>
 #include <stdio.h>
 #include <time.h>
-#include "where.h"
+#include "config/lib.h"
 #ifdef USE_HCACHE
 #include "hcache/hcache.h"
 #endif
 
 struct Header;
 struct Context;
-struct Message;
 struct stat;
 
 /* These Config Variables are only used in mx.c */
 extern unsigned char CatchupNewsgroup;
 extern bool          KeepFlagged;
+extern short         MboxType;
 extern unsigned char Move;
 extern char *        Trash;
 
+/* flags for mutt_open_mailbox() */
+#define MUTT_NOSORT    (1 << 0) /**< do not sort the mailbox after opening it */
+#define MUTT_APPEND    (1 << 1) /**< open mailbox for appending messages */
+#define MUTT_READONLY  (1 << 2) /**< open in read-only mode */
+#define MUTT_QUIET     (1 << 3) /**< do not print any messages */
+#define MUTT_NEWFOLDER (1 << 4) /**< create a new folder - same as MUTT_APPEND, but uses
+                                 * mutt_file_fopen() with mode "w" for mbox-style folders.
+                                 * This will truncate an existing file. */
+#define MUTT_PEEK      (1 << 5) /**< revert atime back after taking a look (if applicable) */
+#define MUTT_APPENDNEW (1 << 6) /**< set in mx_open_mailbox_append if the mailbox doesn't
+                                 * exist. used by maildir/mh to create the mailbox. */
+
+/* mx_msg_open_new() */
+#define MUTT_ADD_FROM  (1 << 0) /**< add a From_ line */
+#define MUTT_SET_DRAFT (1 << 1) /**< set the message draft flag */
+
+/**
+ * enum MxCheckReturns - Return values from mx_mbox_check()
+ */
+enum MxCheckReturns
+{
+  MUTT_NEW_MAIL = 1, /**< new mail received in mailbox */
+  MUTT_LOCKED,       /**< couldn't lock the mailbox */
+  MUTT_REOPENED,     /**< mailbox was reopened */
+  MUTT_FLAGS         /**< nondestructive flags change (IMAP) */
+};
+
+/**
+ * struct Message - A local copy of an email
+ */
+struct Message
+{
+  FILE *fp;             /**< pointer to the message data */
+  char *path;           /**< path to temp file */
+  char *committed_path; /**< the final path generated by mx_msg_commit() */
+  bool write;           /**< nonzero if message is open for writing */
+  struct
+  {
+    bool read : 1;
+    bool flagged : 1;
+    bool replied : 1;
+    bool draft : 1;
+  } flags;
+  time_t received; /**< the time at which this message was received */
+};
+
 /**
  * struct MxOps - The Mailbox API
  *
@@ -180,101 +226,44 @@ struct MxOps
   int (*path_parent)     (char *buf, size_t buflen);
 };
 
-#ifdef USE_NOTMUCH
-bool mx_is_notmuch(const char *p);
-#endif
-
-bool mx_tags_is_supported(struct Context *ctx);
-
-void mx_alloc_memory(struct Context *ctx);
-void mx_update_context(struct Context *ctx, int new_messages);
-void mx_update_tables(struct Context *ctx, bool committing);
-
-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
-
-/* flags for mutt_open_mailbox() */
-#define MUTT_NOSORT    (1 << 0) /**< do not sort the mailbox after opening it */
-#define MUTT_APPEND    (1 << 1) /**< open mailbox for appending messages */
-#define MUTT_READONLY  (1 << 2) /**< open in read-only mode */
-#define MUTT_QUIET     (1 << 3) /**< do not print any messages */
-#define MUTT_NEWFOLDER (1 << 4) /**< create a new folder - same as MUTT_APPEND, but uses
-                                 * mutt_file_fopen() with mode "w" for mbox-style folders.
-                                 * This will truncate an existing file. */
-#define MUTT_PEEK      (1 << 5) /**< revert atime back after taking a look (if applicable) */
-#define MUTT_APPENDNEW (1 << 6) /**< set in mx_open_mailbox_append if the mailbox doesn't
-                                 * exist. used by maildir/mh to create the mailbox. */
-
-/* mx_msg_open_new() */
-#define MUTT_ADD_FROM  (1 << 0) /**< add a From_ line */
-#define MUTT_SET_DRAFT (1 << 1) /**< set the message draft flag */
-
-/**
- * enum MxCheckReturns - Return values from mx_mbox_check()
- */
-enum MxCheckReturns
-{
-  MUTT_NEW_MAIL = 1, /**< new mail received in mailbox */
-  MUTT_LOCKED,       /**< couldn't lock the mailbox */
-  MUTT_REOPENED,     /**< mailbox was reopened */
-  MUTT_FLAGS         /**< nondestructive flags change (IMAP) */
-};
-
-/**
- * struct Message - A local copy of an email
- */
-struct Message
-{
-  FILE *fp;             /**< pointer to the message data */
-  char *path;           /**< path to temp file */
-  char *committed_path; /**< the final path generated by mx_msg_commit() */
-  bool write;           /**< nonzero if message is open for writing */
-  struct
-  {
-    bool read : 1;
-    bool flagged : 1;
-    bool replied : 1;
-    bool draft : 1;
-  } flags;
-  time_t received; /**< the time at which this message was received */
-};
-
-/* The Mailbox API, see MxOps */
+/* 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);
 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);
 struct Message *mx_msg_open_new(struct Context *ctx, struct Header *hdr, int flags);
 struct Message *mx_msg_open    (struct Context *ctx, int msgno);
-
 int             mx_path_canon  (char *buf, size_t buflen, const char *folder);
 int             mx_path_parent (char *buf, size_t buflen);
 int             mx_path_pretty (char *buf, size_t buflen, const char *folder);
 int             mx_path_probe  (const char *path, const struct stat *st);
-
 int             mx_tags_commit (struct Context *ctx, struct Header *hdr, char *tags);
 int             mx_tags_edit   (struct Context *ctx, const char *tags, char *buf, size_t buflen);
 
-void mx_fastclose_mailbox(struct Context *ctx);
+int                 mx_access(const char *path, int flags);
+void                mx_alloc_memory(struct Context *ctx);
+int                 mx_check_empty(const char *path);
+int                 mx_check_mailbox(struct Context *ctx, int *index_hint);
+void                mx_fastclose_mailbox(struct Context *ctx);
+enum MailboxType    mx_get_magic(const char *path);
+const struct MxOps *mx_get_ops(enum MailboxType magic);
+bool                mx_tags_is_supported(struct Context *ctx);
+void                mx_update_context(struct Context *ctx, int new_messages);
+void                mx_update_tables(struct Context *ctx, bool committing);
 
-enum MailboxType mx_get_magic(const char *path);
-int mx_check_mailbox(struct Context *ctx, int *index_hint);
 #ifdef USE_IMAP
 bool mx_is_imap(const char *p);
 #endif
-#ifdef USE_POP
-bool mx_is_pop(const char *p);
+#ifdef USE_NOTMUCH
+bool mx_is_notmuch(const char *p);
 #endif
 #ifdef USE_NNTP
 bool mx_is_nntp(const char *p);
 #endif
-
-int mx_access(const char *path, int flags);
-int mx_check_empty(const char *path);
+#ifdef USE_POP
+bool mx_is_pop(const char *p);
+#endif
 
 #endif /* _MUTT_MX_H */