The "magic" was copied from the context to the message structure to be
able to determine which close function had to be called in
mx_close_message. Now that this function is context aware, there is no
need to store the magic in the MESSAGE structure and it can be safely
removed.
---
mailbox.h | 1 -
mx.c | 10 ++++------
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/mailbox.h b/mailbox.h
index edce294..b8413e2 100644
--- a/mailbox.h
+++ b/mailbox.h
@@ -48,7 +48,6 @@ typedef struct _message
{
FILE *fp; /* pointer to the message data */
char *path; /* path to temp file */
- short magic; /* type of mailbox this message belongs to */
short write; /* nonzero if message is open for writing */
struct {
unsigned read : 1;
diff --git a/mx.c b/mx.c
index a6ce3b6..b2887eb 100644
--- a/mx.c
+++ b/mx.c
@@ -1251,7 +1251,6 @@ MESSAGE *mx_open_new_message (CONTEXT *dest, HEADER *hdr,
int flags)
}
msg = safe_calloc (1, sizeof (MESSAGE));
- msg->magic = dest->magic;
msg->write = 1;
if (hdr)
@@ -1271,7 +1270,7 @@ MESSAGE *mx_open_new_message (CONTEXT *dest, HEADER *hdr,
int flags)
if (dest->magic == MUTT_MMDF)
fputs (MMDF_SEP, msg->fp);
- if ((msg->magic == MUTT_MBOX || msg->magic == MUTT_MMDF) &&
+ if ((dest->magic == MUTT_MBOX || dest->magic == MUTT_MMDF) &&
flags & MUTT_ADD_FROM)
{
if (hdr)
@@ -1322,7 +1321,6 @@ MESSAGE *mx_open_message (CONTEXT *ctx, int msgno)
dprint (1, (debugfile, "mx_open_message(): function not implemented for
mailbox type %d.\n", ctx->magic));
msg = safe_calloc (1, sizeof (MESSAGE));
- msg->magic = ctx->magic;
ret = ops->open_msg (ctx, msg, msgno);
if (ret)
FREE (&msg);
@@ -1343,7 +1341,7 @@ int mx_commit_message (MESSAGE *msg, CONTEXT *ctx)
return -1;
}
- switch (msg->magic)
+ switch (ctx->magic)
{
case MUTT_MMDF:
{
@@ -1396,8 +1394,8 @@ int mx_close_message (CONTEXT *ctx, MESSAGE **msg)
{
int r = 0;
- if ((*msg)->magic == MUTT_MH || (*msg)->magic == MUTT_MAILDIR
- || (*msg)->magic == MUTT_IMAP || (*msg)->magic == MUTT_POP)
+ if (ctx->magic == MUTT_MH || ctx->magic == MUTT_MAILDIR
+ || ctx->magic == MUTT_IMAP || ctx->magic == MUTT_POP)
{
r = safe_fclose (&(*msg)->fp);
}
--
2.8.3