OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
-OP_REBUILD_CACHE "rebuild header caching databases"
OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
OP_MAIN_FETCH_MAIL "retrieve mail from POP server"
mx_close_mailbox (&ctx, NULL);
return -1;
}
- if (ctx.magic == M_MBOX || ctx.magic == M_MMDF)
+ if (ctx.magic == M_MBOX)
chflags = CH_FROM;
chflags |= (ctx.magic == M_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
if (_mutt_copy_message (msg->fp, fp, hn, hn->content, 0, chflags) == 0
int msg_flagged; /* number of flagged messages */
short notified; /* user has been notified */
short magic; /* mailbox type */
- short newly_created; /* mbox or mmdf just popped into existence */
+ short newly_created; /* mbox just popped into existence */
} BUFFY;
DO_INIT(BUFFY, buffy);
}
}
- need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF);
+ need_buffy_cleanup = (ctx.magic == M_MBOX);
mx_close_mailbox (&ctx, NULL);
return (-1);
if ((msg = mx_open_new_message (dest, hdr, is_from (buf, NULL, 0, NULL) ? 0 : M_ADD_FROM)) == NULL)
return (-1);
- if (dest->magic == M_MBOX || dest->magic == M_MMDF)
+ if (dest->magic == M_MBOX)
chflags |= CH_FROM | CH_FORCE_FROM;
chflags |= (dest->magic == M_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
r = _mutt_copy_message (msg->fp, fpin, hdr, body, flags, chflags);
}
rc = mutt_append_message (&tmpctx, ctx, cur, 0, CH_NOLEN |
- ((ctx->magic == M_MBOX
- || ctx->magic == M_MMDF) ? 0 : CH_NOSTATUS));
+ (ctx->magic == M_MBOX ? 0 : CH_NOSTATUS));
oerrno = errno;
mx_close_mailbox (&tmpctx, NULL);
}
of = 0;
- cf = ((tmpctx.magic == M_MBOX || tmpctx.magic == M_MMDF) ? 0 : CH_NOSTATUS);
+ cf = (tmpctx.magic == M_MBOX ? 0 : CH_NOSTATUS);
if (fgets (buff, sizeof (buff), fp) && is_from (buff, NULL, 0, NULL)) {
- if (tmpctx.magic == M_MBOX || tmpctx.magic == M_MMDF)
+ if (tmpctx.magic == M_MBOX)
cf = CH_FROM | CH_FORCE_FROM;
- }
- else
+ } else {
of = M_ADD_FROM;
+ }
/*
* XXX - we have to play games with the message flags to avoid
ITEM("current-middle", OP_CURRENT_MIDDLE, NULL)
ITEM("current-bottom", OP_CURRENT_BOTTOM, NULL)
ITEM("what-key", OP_WHAT_KEY, NULL)
- ITEM("rebuild-cache", OP_REBUILD_CACHE, NULL)
ENDLIST
LIST(OpMain)
const char* s = NULL;
switch (option->data) {
case M_MBOX: s = "mbox"; break;
- case M_MMDF: s = "MMDF"; break;
case M_MH: s = "MH"; break;
case M_MAILDIR: s = "Maildir"; break;
default: s = "unknown"; break;
}
static int magic_from_string (struct option_t* dst, const char* val,
- char* errbuf __attribute__ ((unused)), ssize_t errlen __attribute__ ((unused))) {
+ char *errbuf, ssize_t errlen)
+{
int flag = -1;
if (!dst || m_strisempty(val))
return (0);
if (ascii_strncasecmp (val, "mbox", 4) == 0)
flag = M_MBOX;
- else if (ascii_strncasecmp (val, "mmdf", 4) == 0)
- flag = M_MMDF;
else if (ascii_strncasecmp (val, "mh", 2) == 0)
flag = M_MH;
else if (ascii_strncasecmp (val, "maildir", 7) == 0)
case M_MBOX:
p = "mbox";
break;
- case M_MMDF:
- p = "MMDF";
- break;
case M_MH:
p = "MH";
- break;
+ break;
case M_MAILDIR:
p = "Maildir";
break;
/*
** .pp
** The default mailbox type used when creating new folders. May be any of
- ** \fTmbox\fP, \fTMMDF\fP, \fTMH\fP and \fTMaildir\fP.
+ ** \fTmbox\fP, \fTMH\fP and \fTMaildir\fP.
*/
{"metoo", DT_BOOL, R_NONE, OPTMETOO, "no" },
/*
** when closed (the exception is ``$$spoolfile'' which is never removed).
** If \fIset\fP, mailboxes are never removed.
** .pp
- ** \fBNote:\fP This only applies to mbox and MMDF folders, Madmutt does not
+ ** \fBNote:\fP This only applies to mbox folders, Madmutt does not
** delete MH and Maildir directories.
*/
{"save_name", DT_BOOL, R_NONE, OPTSAVENAME, "no" },
/* remove the temporary mailbox */
static void remove_file (CONTEXT * ctx)
{
- if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
+ if (ctx->magic == M_MBOX)
remove (ctx->path);
}
ctx->magic = DefaultMagic;
- if (is_new (ctx->realpath) ||
- (ctx->magic != M_MBOX &&
- ctx->magic != M_MMDF))
+ if (is_new (ctx->realpath) || ctx->magic != M_MBOX)
unlink(tmppath);
/* No error checking - the parent function will catch it */
-
return 0;
}
* please see the file GPL in the top level source directory.
*/
-/* This file contains code to parse ``mbox'' and ``mmdf'' style mailboxes */
+/* This file contains code to parse ``mbox'' style mailboxes */
#include <lib-lib/lib-lib.h>
}
}
-static int mmdf_parse_mailbox (CONTEXT * ctx)
-{
- char buf[HUGE_STRING];
- char return_path[LONG_STRING];
- int count = 0, oldmsgcount = ctx->msgcount;
- int lines;
- time_t t, tz;
- off_t loc, tmploc;
- HEADER *hdr;
- struct stat sb;
-
- if (stat (ctx->path, &sb) == -1) {
- mutt_perror (ctx->path);
- return (-1);
- }
- ctx->mtime = sb.st_mtime;
- ctx->size = sb.st_size;
-
- /* precompute the local timezone to speed up calculation of the
- received time */
- tz = mutt_local_tz (0);
-
- buf[sizeof (buf) - 1] = 0;
-
- for (;;) {
- if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL)
- break;
-
- if (m_strcmp(buf, MMDF_SEP) == 0) {
- loc = ftello (ctx->fp);
-
- count++;
- if (!ctx->quiet && ReadInc && ((count % ReadInc == 0) || count == 1))
- mutt_message (_("Reading %s... %d (%d%%)"), ctx->path, count,
- (int) (loc / (ctx->size / 100 + 1)));
-
-
- if (ctx->msgcount == ctx->hdrmax)
- mx_alloc_memory (ctx);
- ctx->hdrs[ctx->msgcount] = hdr = header_new();
- hdr->offset = loc;
- hdr->index = ctx->msgcount;
-
- if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL) {
- /* TODO: memory leak??? */
- break;
- }
-
- return_path[0] = 0;
-
- if (!is_from (buf, return_path, sizeof (return_path), &t)) {
- if (fseeko (ctx->fp, loc, SEEK_SET) != 0) {
- mutt_error _("Mailbox is corrupt!");
-
- return (-1);
- }
- }
- else
- hdr->received = t - tz;
-
- hdr->env = mutt_read_rfc822_header (ctx->fp, hdr, 0, 0);
-
- loc = ftello (ctx->fp);
-
- if (hdr->content->length > 0 && hdr->lines > 0) {
- tmploc = loc + hdr->content->length;
-
- if (0 < tmploc && tmploc < ctx->size) {
- if (fseeko (ctx->fp, tmploc, SEEK_SET) != 0 ||
- fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL ||
- m_strcmp(MMDF_SEP, buf) != 0) {
- fseeko (ctx->fp, loc, SEEK_SET);
- hdr->content->length = -1;
- }
- }
- else
- hdr->content->length = -1;
- }
- else
- hdr->content->length = -1;
-
- if (hdr->content->length < 0) {
- lines = -1;
- do {
- loc = ftello (ctx->fp);
- if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL)
- break;
- lines++;
- } while (m_strcmp(buf, MMDF_SEP) != 0);
-
- hdr->lines = lines;
- hdr->content->length = loc - hdr->content->offset;
- }
-
- if (!hdr->env->return_path && return_path[0])
- hdr->env->return_path =
- rfc822_parse_adrlist (hdr->env->return_path, return_path);
-
- if (!hdr->env->from)
- hdr->env->from = address_list_dup (hdr->env->return_path);
-
- ctx->msgcount++;
- }
- else {
- mutt_error _("Mailbox is corrupt!");
-
- return (-1);
- }
- }
-
- if (ctx->msgcount > oldmsgcount)
- mx_update_context (ctx, ctx->msgcount - oldmsgcount);
-
- return (0);
-}
-
/* Note that this function is also called when new mail is appended to the
* currently open folder, and NOT just when the mailbox is initially read.
*
#undef PREV
-/* open a mbox or mmdf style mailbox */
+/* open a mbox style mailbox */
static int mbox_open_mailbox (CONTEXT * ctx)
{
int rc;
if (ctx->magic == M_MBOX)
rc = mbox_parse_mailbox (ctx);
- else if (ctx->magic == M_MMDF)
- rc = mmdf_parse_mailbox (ctx);
else
rc = -1;
*/
fseeko (ctx->fp, ctx->size, SEEK_SET);
if (fgets (buffer, sizeof (buffer), ctx->fp) != NULL) {
- if ((ctx->magic == M_MBOX && m_strncmp("From ", buffer, 5) == 0)
- || (ctx->magic == M_MMDF && m_strcmp(MMDF_SEP, buffer) == 0)) {
+ if (ctx->magic == M_MBOX && m_strncmp("From ", buffer, 5) == 0) {
fseeko (ctx->fp, ctx->size, SEEK_SET);
- if (ctx->magic == M_MBOX)
- mbox_parse_mailbox (ctx);
- else
- mmdf_parse_mailbox (ctx);
+ mbox_parse_mailbox (ctx);
/* Only unlock the folder if it was locked inside of this routine.
* It may have been locked elsewhere, like in
/* where to start overwriting */
offset = ctx->hdrs[i]->offset;
- /* the offset stored in the header does not include the MMDF_SEP, so make
- * sure we seek to the correct location
- */
- if (ctx->magic == M_MMDF)
- offset -= (sizeof MMDF_SEP - 1);
-
/* allocate space for the new offsets */
newOffset = p_new(struct m_update_t, ctx->msgcount - first);
oldOffset = p_new(struct m_update_t, ctx->msgcount - first);
mutt_message (_("Writing messages... %d (%d%%)"), i,
(int) (ftello (ctx->fp) / (ctx->size / 100 + 1)));
- if (ctx->magic == M_MMDF) {
- if (fputs (MMDF_SEP, fp) == EOF) {
- mutt_perror (_("Can't create temporary file"));
- mutt_sleep (5);
- unlink (tempfile);
- goto bail;
- }
- }
-
/* save the new offset for this message. we add `offset' because the
* temporary file only contains saved message which are located after
* `offset' in the real mailbox
ftello (fp) - ctx->hdrs[i]->content->length + offset;
body_list_wipe(&ctx->hdrs[i]->content->parts);
- switch (ctx->magic) {
- case M_MMDF:
- if (fputs (MMDF_SEP, fp) == EOF) {
- mutt_perror (_("Can't create temporary file"));
- mutt_sleep (5);
- unlink (tempfile);
- goto bail;
- }
- break;
- default:
- if (fputs ("\n", fp) == EOF) {
- mutt_perror (_("Can't create temporary file"));
- mutt_sleep (5);
- unlink (tempfile);
- goto bail;
- }
+ if (fputs ("\n", fp) == EOF) {
+ mutt_perror (_("Can't create temporary file"));
+ mutt_sleep (5);
+ unlink (tempfile);
+ goto bail;
}
}
}
return (-1);
}
- if (fseeko (ctx->fp, offset, SEEK_SET) != 0 || /* seek the append location */
+ if (fseeko (ctx->fp, offset, SEEK_SET) != 0 /* seek the append location */
/* do a sanity check to make sure the mailbox looks ok */
- fgets (buf, sizeof (buf), ctx->fp) == NULL ||
- (ctx->magic == M_MBOX && m_strncmp("From ", buf, 5) != 0) ||
- (ctx->magic == M_MMDF && m_strcmp(MMDF_SEP, buf) != 0)) {
+ || fgets (buf, sizeof (buf), ctx->fp) == NULL
+ || (ctx->magic == M_MBOX && m_strncmp("From ", buf, 5) != 0))
+ {
i = -1;
}
else {
ctx->id_hash = NULL;
ctx->subj_hash = NULL;
- switch (ctx->magic) {
- case M_MBOX:
- case M_MMDF:
- if (fseeko (ctx->fp, 0, SEEK_SET) != 0) {
- rc = -1;
- }
- else {
- cmp_headers = mutt_cmp_header;
- if (ctx->magic == M_MBOX)
- rc = mbox_parse_mailbox (ctx);
- else
- rc = mmdf_parse_mailbox (ctx);
- }
- break;
-
- default:
+ if (ctx->magic == M_MBOX && !fseeko(ctx->fp, 0, SEEK_SET)) {
+ cmp_headers = mutt_cmp_header;
+ rc = mbox_parse_mailbox (ctx);
+ } else {
rc = -1;
- break;
}
if (rc == -1) {
return ((st.st_size == 0));
}
-int mbox_is_magic (const char* path, struct stat* st) {
+int mbox_is_magic (const char* path, struct stat* st)
+{
int magic = -1;
FILE* f;
char tmp[_POSIX_PATH_MAX];
return (-1);
if (st->st_size == 0) {
- /* hard to tell what zero-length files are, so assume the default magic */
- if (DefaultMagic == M_MBOX || DefaultMagic == M_MMDF)
- return (DefaultMagic);
- else
- return (M_MBOX);
+ return M_MBOX;
}
else if ((f = fopen (path, "r")) != NULL) {
struct utimbuf times;
fgets (tmp, sizeof (tmp), f);
if (m_strncmp("From ", tmp, 5) == 0)
magic = M_MBOX;
- else if (m_strcmp(MMDF_SEP, tmp) == 0)
- magic = M_MMDF;
m_fclose(&f);
/* need to restore the times here, the file was not really accessed,
return (magic);
}
-static int commit_message (MESSAGE* msg, CONTEXT* ctx __attribute__ ((unused)), int mbox) {
- if ((mbox && fputc ('\n', msg->fp) == EOF) ||
- (!mbox && fputs (MMDF_SEP, msg->fp) == EOF))
- return (-1);
+static int mbox_commit_message (MESSAGE* msg, CONTEXT* ctx) {
+ if (fputc ('\n', msg->fp) == EOF)
+ return -1;
if ((fflush (msg->fp) == EOF || fsync (fileno (msg->fp)) == -1)) {
mutt_perror (_("Can't write message"));
- return (-1);
+ return -1;
}
- return (0);
-}
-
-static int mbox_commit_message (MESSAGE* msg, CONTEXT* ctx) {
- return (commit_message (msg, ctx, 1));
-}
-
-static int mmdf_commit_message (MESSAGE* msg, CONTEXT* ctx) {
- return (commit_message (msg, ctx, 0));
+ return 0;
}
mx_t const mbox_mx = {
mbox_commit_message,
};
-mx_t const mmdf_mx = {
- M_MMDF,
- 1,
- mbox_is_magic,
- mbox_check_empty,
- access,
- mbox_open_mailbox,
- mbox_open_new_message,
- NULL,
- mbox_check_mailbox,
- NULL,
- mbox_sync_mailbox,
- mmdf_commit_message,
-};
*/
/*
- * functions for dealing with mbox/mmdf style mailboxes
+ * functions for dealing with mbox style mailboxes
*/
#ifndef _MBOX_H
#include "mx.h"
extern mx_t const mbox_mx;
-extern mx_t const mmdf_mx;
/* TODO all of these must disappear to achieve good information hiding */
-#define MMDF_SEP "\001\001\001\001\n"
-
int mbox_close_mailbox (CONTEXT *);
int mbox_lock_mailbox (CONTEXT *, int, int);
int mbox_check_empty (const char*);
static mx_t const *mxfmts[] = {
&mbox_mx,
- &mmdf_mx,
&mh_mx,
&maildir_mx,
&imap_mx,
int mx_lock_file (const char *path, int fd, int excl, int dot, int time_out)
{
#if defined (USE_FCNTL) || defined (USE_FLOCK)
- int count;
- int attempt;
- struct stat prev_sb;
+ int count;
+ int attempt;
+ struct stat prev_sb;
#endif
- int r = 0;
+ int r = 0;
#ifdef USE_FCNTL
- struct flock lck;
+ struct flock lck;
- p_clear(&lck, 1);
- lck.l_type = excl ? F_WRLCK : F_RDLCK;
- lck.l_whence = SEEK_SET;
+ p_clear(&lck, 1);
+ lck.l_type = excl ? F_WRLCK : F_RDLCK;
+ lck.l_whence = SEEK_SET;
- count = 0;
- attempt = 0;
- prev_sb.st_size = 0;
- while (fcntl (fd, F_SETLK, &lck) == -1) {
- struct stat sb;
+ count = 0;
+ attempt = 0;
+ prev_sb.st_size = 0;
+ while (fcntl (fd, F_SETLK, &lck) == -1) {
+ struct stat sb;
- if (errno != EAGAIN && errno != EACCES) {
- mutt_perror ("fcntl");
- return (-1);
- }
+ if (errno != EAGAIN && errno != EACCES) {
+ mutt_perror ("fcntl");
+ return (-1);
+ }
- if (fstat (fd, &sb) != 0)
- sb.st_size = 0;
+ if (fstat (fd, &sb) != 0)
+ sb.st_size = 0;
- if (count == 0)
- prev_sb = sb;
+ if (count == 0)
+ prev_sb = sb;
- /* only unlock file if it is unchanged */
- if (prev_sb.st_size == sb.st_size
- && ++count >= (time_out ? MAXLOCKATTEMPT : 0)) {
- if (time_out)
- mutt_error _("Timeout exceeded while attempting fcntl lock!");
+ /* only unlock file if it is unchanged */
+ if (prev_sb.st_size == sb.st_size
+ && ++count >= (time_out ? MAXLOCKATTEMPT : 0)) {
+ if (time_out)
+ mutt_error _("Timeout exceeded while attempting fcntl lock!");
- return (-1);
- }
+ return (-1);
+ }
- prev_sb = sb;
+ prev_sb = sb;
- mutt_message (_("Waiting for fcntl lock... %d"), ++attempt);
- sleep (1);
- }
+ mutt_message (_("Waiting for fcntl lock... %d"), ++attempt);
+ sleep (1);
+ }
#endif /* USE_FCNTL */
#ifdef USE_FLOCK
- count = 0;
- attempt = 0;
- while (flock (fd, (excl ? LOCK_EX : LOCK_SH) | LOCK_NB) == -1) {
- struct stat sb;
-
- if (errno != EWOULDBLOCK) {
- mutt_perror ("flock");
- r = -1;
- break;
- }
+ count = 0;
+ attempt = 0;
+ while (flock (fd, (excl ? LOCK_EX : LOCK_SH) | LOCK_NB) == -1) {
+ struct stat sb;
+
+ if (errno != EWOULDBLOCK) {
+ mutt_perror ("flock");
+ r = -1;
+ break;
+ }
- if (fstat (fd, &sb) != 0)
- sb.st_size = 0;
+ if (fstat (fd, &sb) != 0)
+ sb.st_size = 0;
- if (count == 0)
- prev_sb = sb;
+ if (count == 0)
+ prev_sb = sb;
- /* only unlock file if it is unchanged */
- if (prev_sb.st_size == sb.st_size
- && ++count >= (time_out ? MAXLOCKATTEMPT : 0)) {
- if (time_out)
- mutt_error _("Timeout exceeded while attempting flock lock!");
+ /* only unlock file if it is unchanged */
+ if (prev_sb.st_size == sb.st_size
+ && ++count >= (time_out ? MAXLOCKATTEMPT : 0)) {
+ if (time_out)
+ mutt_error _("Timeout exceeded while attempting flock lock!");
- r = -1;
- break;
- }
+ r = -1;
+ break;
+ }
- prev_sb = sb;
+ prev_sb = sb;
- mutt_message (_("Waiting for flock attempt... %d"), ++attempt);
- sleep (1);
- }
+ mutt_message (_("Waiting for flock attempt... %d"), ++attempt);
+ sleep (1);
+ }
#endif /* USE_FLOCK */
- if (r == 0 && dot)
- r = dotlock_file (path, time_out);
+ if (r == 0 && dot)
+ r = dotlock_file (path, time_out);
- if (r == -1) {
- /* release any other locks obtained in this routine */
+ if (r == -1) {
+ /* release any other locks obtained in this routine */
#ifdef USE_FCNTL
- lck.l_type = F_UNLCK;
- fcntl (fd, F_SETLK, &lck);
+ lck.l_type = F_UNLCK;
+ fcntl (fd, F_SETLK, &lck);
#endif /* USE_FCNTL */
#ifdef USE_FLOCK
- flock (fd, LOCK_UN);
+ flock (fd, LOCK_UN);
#endif /* USE_FLOCK */
- return (-1);
- }
+ return (-1);
+ }
- return 0;
+ return 0;
}
int mx_unlock_file (const char *path, int fd, int dot)
{
#ifdef USE_FCNTL
- struct flock unlockit;
+ struct flock unlockit;
- p_clear(&unlockit, 1);
- unlockit.l_type = F_UNLCK;
- unlockit.l_whence = SEEK_SET;
- fcntl (fd, F_SETLK, &unlockit);
+ p_clear(&unlockit, 1);
+ unlockit.l_type = F_UNLCK;
+ unlockit.l_whence = SEEK_SET;
+ fcntl (fd, F_SETLK, &unlockit);
#endif
#ifdef USE_FLOCK
- flock (fd, LOCK_UN);
+ flock (fd, LOCK_UN);
#endif
- if (dot)
- undotlock_file (path);
+ if (dot)
+ undotlock_file (path);
- return 0;
+ return 0;
}
static void mx_unlink_empty (const char *path)
{
- int fd;
+ int fd;
- if ((fd = open (path, O_RDWR)) == -1)
- return;
+ if ((fd = open (path, O_RDWR)) == -1)
+ return;
- if (mx_lock_file (path, fd, 1, 0, 1) == -1) {
+ if (mx_lock_file (path, fd, 1, 0, 1) == -1) {
close (fd);
return;
}
{
if (ascii_strcasecmp (s, "mbox") == 0)
DefaultMagic = M_MBOX;
- else if (ascii_strcasecmp (s, "mmdf") == 0)
- DefaultMagic = M_MMDF;
else if (ascii_strcasecmp (s, "mh") == 0)
DefaultMagic = M_MH;
else if (ascii_strcasecmp (s, "maildir") == 0)
switch (ctx->magic) {
case M_MBOX:
- case M_MMDF:
if ((ctx->fp =
safe_fopen (ctx->path, flags & M_NEWFOLDER ? "w" : "a")) == NULL
|| mbox_lock_mailbox (ctx, 1, 1) != 0) {
if (ctx->append) {
/* mailbox was opened in write-mode */
- if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
+ if (ctx->magic == M_MBOX)
mbox_close_mailbox (ctx);
else
mx_fastclose_mailbox (ctx);
mutt_message (_("%d kept, %d deleted."),
ctx->msgcount - ctx->deleted, ctx->deleted);
- if (ctx->msgcount == ctx->deleted &&
- (ctx->magic == M_MMDF || ctx->magic == M_MBOX) &&
- !mutt_is_spool (ctx->path) && !option (OPTSAVEEMPTY))
+ if (ctx->msgcount == ctx->deleted && ctx->magic == M_MBOX
+ && !mutt_is_spool (ctx->path) && !option (OPTSAVEEMPTY))
+ {
mx_unlink_empty (ctx->path);
+ }
if (ctx->cinfo && mutt_slow_close_compressed (ctx))
return (-1);
mutt_sleep (0);
- if (ctx->msgcount == ctx->deleted &&
- (ctx->magic == M_MBOX || ctx->magic == M_MMDF) &&
- !mutt_is_spool (ctx->path) && !option (OPTSAVEEMPTY)) {
+ if (ctx->msgcount == ctx->deleted && ctx->magic == M_MBOX
+ && !mutt_is_spool (ctx->path) && !option (OPTSAVEEMPTY))
+ {
unlink (ctx->path);
mx_fastclose_mailbox (ctx);
return 0;
time (&msg->received);
if (mxfmts[dest->magic-1]->mx_open_new_message(msg, dest, hdr) == 0) {
- if (dest->magic == M_MMDF)
- fputs (MMDF_SEP, msg->fp);
-
- if ((msg->magic == M_MBOX || msg->magic == M_MMDF) && flags & M_ADD_FROM) {
+ if (msg->magic == M_MBOX && flags & M_ADD_FROM) {
if (hdr) {
if (hdr->env->return_path)
p = hdr->env->return_path;
msg = p_new(MESSAGE, 1);
switch (msg->magic = ctx->magic) {
case M_MBOX:
- case M_MMDF:
msg->fp = ctx->fp;
break;
void mx_alloc_memory (CONTEXT * ctx)
{
- int i;
- size_t s = MAX (sizeof (HEADER *), sizeof (int));
+ ctx->hdrmax += 25;
- if ((ctx->hdrmax + 25) * s < ctx->hdrmax * s) {
- mutt_error _("Integer overflow -- can't allocate memory.");
-
- sleep (1);
- mutt_exit (1);
- }
-
- if (ctx->hdrs) {
- p_realloc(&ctx->hdrs, ctx->hdrmax += 25);
+ p_realloc(&ctx->hdrs, ctx->hdrmax);
p_realloc(&ctx->v2r, ctx->hdrmax);
- }
- else {
- ctx->hdrs = p_new(HEADER *, (ctx->hdrmax += 25));
- ctx->v2r = p_new(int, ctx->hdrmax);
- }
- for (i = ctx->msgcount; i < ctx->hdrmax; i++) {
- ctx->hdrs[i] = NULL;
- ctx->v2r[i] = -1;
- }
+ p_clear(ctx->hdrs + ctx->msgcount, ctx->hdrmax - ctx->msgcount);
+ p_clear(ctx->v2r + ctx->msgcount, ctx->hdrmax - ctx->msgcount);
}
/* this routine is called to update the counts in the context structure for
return (-1);
}
-int mx_acl_check (CONTEXT* ctx, int flag) {
- if (!ctx || !MX_IDX(ctx->magic-1))
- return (0);
- /* if no acl_check defined for module, assume permission is granted */
- if (!mxfmts[ctx->magic-1]->mx_acl_check)
- return (1);
- return (mxfmts[ctx->magic-1]->mx_acl_check(ctx,flag));
-}
-
-int mx_rebuild_cache (void) {
-#ifndef USE_HCACHE
- mutt_error (_("Support for header caching was not build in."));
- return (1);
-#else
- int i = 0, magic = 0;
- CONTEXT* ctx = NULL;
- BUFFY* b = NULL;
-
- if (!Incoming.len) {
- mutt_error (_("No mailboxes defined."));
- return (1);
- }
-
- for (i = 0; i < Incoming.len; i++) {
- b = Incoming.arr[i];
- magic = mx_get_magic (b->path);
- if (magic != M_MAILDIR && magic != M_MH && magic != M_IMAP)
- continue;
- sidebar_set_current (b->path);
- sidebar_draw ();
- if ((ctx = mx_open_mailbox (b->path,
- M_READONLY | M_NOSORT | M_COUNT,
- NULL)) != NULL)
- mx_close_mailbox (ctx, 0);
- }
- mutt_clear_error ();
-
- if (Context && Context->path)
- sidebar_set_current (Context->path);
- sidebar_draw ();
-
- return (0);
-#endif
+int mx_acl_check(CONTEXT *ctx, int flag)
+{
+ if (!mxfmts[ctx->magic-1]->mx_acl_check)
+ return 1;
+ return mxfmts[ctx->magic-1]->mx_acl_check(ctx,flag);
}
void mutt_parse_mime_message (CONTEXT * ctx, HEADER * cur)
XXX: has to be in the same order than mxfmts in mx.c */
enum {
M_MBOX = 1,
- M_MMDF,
M_MH,
M_MAILDIR,
M_IMAP,
int mx_lock_file (const char *, int, int, int, int);
int mx_unlock_file (const char *path, int fd, int dot);
-
-int mx_rebuild_cache (void);
void mutt_parse_mime_message (CONTEXT * ctx, HEADER *);
#endif /* !_MX_H */
mutt_what_key ();
break;
- case OP_REBUILD_CACHE:
- mx_rebuild_cache ();
- break;
-
case OP_SIDEBAR_SCROLL_UP:
case OP_SIDEBAR_SCROLL_DOWN:
case OP_SIDEBAR_NEXT:
mutt_what_key ();
break;
- case OP_REBUILD_CACHE:
- mx_rebuild_cache ();
- break;
-
case OP_REDRAW:
clearok (stdscr, TRUE);
menu->redraw = REDRAW_FULL;
/* We need to add a Content-Length field to avoid problems where a line in
* the message body begins with "From "
*/
- if (f.magic == M_MMDF || f.magic == M_MBOX) {
+ if (f.magic == M_MBOX) {
tempfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL);
if (!tempfp) {
mutt_error(_("Could not create temporary file"));