---
imap/imap.c | 1 +
imap/imap.h | 1 -
imap/imap_private.h | 1 +
mbox.c | 6 ++++--
mh.c | 6 ++++--
mutt.h | 1 +
mx.c | 39 +++++----------------------------------
mx.h | 5 -----
8 files changed, 16 insertions(+), 44 deletions(-)
diff --git a/imap/imap.c b/imap/imap.c
index 5d59769..6b50350 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -2072,6 +2072,7 @@ struct mx_ops mx_imap_ops = {
.close = imap_close_mailbox,
.open_msg = imap_fetch_message,
.close_msg = imap_close_message,
+ .commit_msg = imap_commit_message,
.open_new_msg = imap_open_new_message,
.check = imap_check_mailbox_reopen,
};
diff --git a/imap/imap.h b/imap/imap.h
index 7c8736f..dbbaf92 100644
--- a/imap/imap.h
+++ b/imap/imap.h
@@ -58,7 +58,6 @@ int imap_mailbox_rename (const char* mailbox);
/* message.c */
int imap_append_message (CONTEXT* ctx, MESSAGE* msg);
int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete);
-int imap_commit_message (CONTEXT *ctx, MESSAGE *msg);
/* socket.c */
void imap_logout_all (void);
diff --git a/imap/imap_private.h b/imap/imap_private.h
index 8cd610a..67fea27 100644
--- a/imap/imap_private.h
+++ b/imap/imap_private.h
@@ -270,6 +270,7 @@ int imap_cache_clean (IMAP_DATA* idata);
int imap_fetch_message (CONTEXT *ctx, MESSAGE *msg, int msgno);
int imap_close_message (CONTEXT *ctx, MESSAGE *msg);
+int imap_commit_message (CONTEXT *ctx, MESSAGE *msg);
/* util.c */
#ifdef USE_HCACHE
diff --git a/mbox.c b/mbox.c
index 3d81e72..a6e4b86 100644
--- a/mbox.c
+++ b/mbox.c
@@ -465,7 +465,7 @@ static int mbox_close_message (CONTEXT *ctx, MESSAGE *msg)
return 0;
}
-int mbox_commit_message (CONTEXT *ctx, MESSAGE *msg)
+static int mbox_commit_message (CONTEXT *ctx, MESSAGE *msg)
{
int r = fputc ('\n', msg->fp);
@@ -475,7 +475,7 @@ int mbox_commit_message (CONTEXT *ctx, MESSAGE *msg)
return 0;
}
-int mmdf_commit_message (CONTEXT *ctx, MESSAGE *msg)
+static int mmdf_commit_message (CONTEXT *ctx, MESSAGE *msg)
{
int r = fputs (MMDF_SEP, msg->fp);
@@ -1314,6 +1314,7 @@ struct mx_ops mx_mbox_ops = {
.close = mbox_close_mailbox,
.open_msg = mbox_open_message,
.close_msg = mbox_close_message,
+ .commit_msg = mbox_commit_message,
.open_new_msg = mbox_open_new_message,
.check = mbox_check_mailbox,
};
@@ -1323,6 +1324,7 @@ struct mx_ops mx_mmdf_ops = {
.close = mbox_close_mailbox,
.open_msg = mbox_open_message,
.close_msg = mbox_close_message,
+ .commit_msg = mmdf_commit_message,
.open_new_msg = mbox_open_new_message,
.check = mbox_check_mailbox,
};
diff --git a/mh.c b/mh.c
index 62c1e38..9f1be15 100644
--- a/mh.c
+++ b/mh.c
@@ -1533,7 +1533,7 @@ static int _maildir_commit_message (CONTEXT * ctx,
MESSAGE * msg, HEADER * hdr)
}
}
-int maildir_commit_message (CONTEXT * ctx, MESSAGE * msg)
+static int maildir_commit_message (CONTEXT * ctx, MESSAGE * msg)
{
return _maildir_commit_message (ctx, msg, NULL);
}
@@ -1619,7 +1619,7 @@ static int _mh_commit_message (CONTEXT * ctx, MESSAGE *
msg, HEADER * hdr,
return 0;
}
-int mh_commit_message (CONTEXT * ctx, MESSAGE * msg)
+static int mh_commit_message (CONTEXT * ctx, MESSAGE * msg)
{
return _mh_commit_message (ctx, msg, NULL, 1);
}
@@ -2450,6 +2450,7 @@ struct mx_ops mx_maildir_ops = {
.close = mh_close_mailbox,
.open_msg = maildir_open_message,
.close_msg = mh_close_message,
+ .commit_msg = maildir_commit_message,
.open_new_msg = maildir_open_new_message,
.check = maildir_check_mailbox,
};
@@ -2459,6 +2460,7 @@ struct mx_ops mx_mh_ops = {
.close = mh_close_mailbox,
.open_msg = mh_open_message,
.close_msg = mh_close_message,
+ .commit_msg = mh_commit_message,
.open_new_msg = mh_open_new_message,
.check = mh_check_mailbox,
};
diff --git a/mutt.h b/mutt.h
index afe7132..ed6ac7d 100644
--- a/mutt.h
+++ b/mutt.h
@@ -895,6 +895,7 @@ struct mx_ops
int (*check) (struct _context *ctx, int *index_hint);
int (*open_msg) (struct _context *, struct _message *, int msgno);
int (*close_msg) (struct _context *, struct _message *);
+ int (*commit_msg) (struct _context *, struct _message *);
int (*open_new_msg) (struct _message *, struct _context *, HEADER *);
};
diff --git a/mx.c b/mx.c
index aaf2c5e..750e754 100644
--- a/mx.c
+++ b/mx.c
@@ -1332,8 +1332,12 @@ MESSAGE *mx_open_message (CONTEXT *ctx, int msgno)
int mx_commit_message (MESSAGE *msg, CONTEXT *ctx)
{
+ struct mx_ops *ops = mx_get_ops (ctx->magic);
int r = 0;
+ if (!ops || !ops->commit_msg)
+ return -1;
+
if (!(msg->write && ctx->append))
{
dprint (1, (debugfile, "mx_commit_message(): msg->write = %d, ctx->append
= %d\n",
@@ -1341,40 +1345,7 @@ int mx_commit_message (MESSAGE *msg, CONTEXT *ctx)
return -1;
}
- switch (ctx->magic)
- {
- case MUTT_MMDF:
- {
- r = mmdf_commit_message (ctx, msg);
- break;
- }
-
- case MUTT_MBOX:
- {
- r = mbox_commit_message (ctx, msg);
- break;
- }
-
-#ifdef USE_IMAP
- case MUTT_IMAP:
- {
- r = imap_commit_message (ctx, msg);
- break;
- }
-#endif
-
- case MUTT_MAILDIR:
- {
- r = maildir_commit_message (ctx, msg);
- break;
- }
-
- case MUTT_MH:
- {
- r = mh_commit_message (ctx, msg);
- break;
- }
- }
+ r = ops->commit_msg (ctx, msg);
if (r == 0 && (ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF)
&& (fflush (msg->fp) == EOF || fsync (fileno (msg->fp)) == -1))
diff --git a/mx.h b/mx.h
index 540715c..743d8d0 100644
--- a/mx.h
+++ b/mx.h
@@ -51,8 +51,6 @@ int mmdf_parse_mailbox (CONTEXT *);
void mbox_unlock_mailbox (CONTEXT *);
int mbox_check_empty (const char *);
void mbox_reset_atime (CONTEXT *, struct stat *);
-int mbox_commit_message (CONTEXT *ctx, MESSAGE *msg);
-int mmdf_commit_message (CONTEXT *ctx, MESSAGE *msg);
int mh_sync_mailbox (CONTEXT *, int *);
#ifdef USE_SIDEBAR
@@ -62,9 +60,6 @@ int mh_check_empty (const char *);
int maildir_check_empty (const char *);
-int maildir_commit_message (CONTEXT *, MESSAGE *);
-int mh_commit_message (CONTEXT *, MESSAGE *);
-
FILE *maildir_open_find_message (const char *, const char *);
int mbox_strict_cmp_headers (const HEADER *, const HEADER *);
--
2.8.3