summaryrefslogtreecommitdiffstats
path: root/mh.c
diff options
context:
space:
mode:
authorDamien Riegel <damien.riegel@gmail.com>2016-05-12 12:41:25 -0700
committerDamien Riegel <damien.riegel@gmail.com>2016-05-12 12:41:25 -0700
commitd22efaae6e4ec48aad0da1324278a567b5b3326a (patch)
tree0713fd46bb54780c753d34e228e0523cd10036c2 /mh.c
parent740c8600dbb82a03f99370dd293a026ec5d56492 (diff)
Start decoupling mailbox operations.
Introduce a dedicated structure for mailbox operations: struct mx_ops. Move the open and close operations into that structure. Assign this structure to the context in mx_open_mailbox. This is currently based on the "magic" for the mailbox type, but may be refactored in the future. Add a stub mbox_close_mailbox function. This function does nothing, the main purpose is to introduce a mx_ops structure for mbox, so its usage is similar to mh/imap/pop. We reuse the name that was made available by the previous commmit. Note that the actual closing of the descriptor is done in mx.c. To be more consistent with other mailboxes, introduce functions mh_open_mailbox and maildir_open_mailbox, and create a dedicated structure for mmdf.
Diffstat (limited to 'mh.c')
-rw-r--r--mh.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/mh.c b/mh.c
index 33fc712a..c156a10c 100644
--- a/mh.c
+++ b/mh.c
@@ -1168,7 +1168,7 @@ static int mh_close_mailbox (CONTEXT *ctx)
* subdir [IN] NULL for MH mailboxes, otherwise the subdir of the
* maildir mailbox to read from
*/
-int mh_read_dir (CONTEXT * ctx, const char *subdir)
+static int mh_read_dir (CONTEXT * ctx, const char *subdir)
{
struct maildir *md;
struct mh_sequences mhs;
@@ -1188,7 +1188,6 @@ int mh_read_dir (CONTEXT * ctx, const char *subdir)
if (!ctx->data)
{
ctx->data = safe_calloc(sizeof (struct mh_data), 1);
- ctx->mx_close = mh_close_mailbox;
}
data = mh_data (ctx);
@@ -1224,7 +1223,7 @@ int mh_read_dir (CONTEXT * ctx, const char *subdir)
}
/* read a maildir style mailbox */
-int maildir_read_dir (CONTEXT * ctx)
+static int maildir_read_dir (CONTEXT * ctx)
{
/* maildir looks sort of like MH, except that there are two subdirectories
* of the main folder path from which to read messages
@@ -1235,6 +1234,16 @@ int maildir_read_dir (CONTEXT * ctx)
return 0;
}
+static int maildir_open_mailbox (CONTEXT *ctx)
+{
+ return maildir_read_dir (ctx);
+}
+
+static int mh_open_mailbox (CONTEXT *ctx)
+{
+ return mh_read_dir (ctx, NULL);
+}
+
/*
* Open a new (temporary) message in an MH folder.
*/
@@ -2348,3 +2357,13 @@ int mx_is_mh (const char *path)
return 0;
}
+
+struct mx_ops mx_maildir_ops = {
+ .open = maildir_open_mailbox,
+ .close = mh_close_mailbox,
+};
+
+struct mx_ops mx_mh_ops = {
+ .open = mh_open_mailbox,
+ .close = mh_close_mailbox,
+};