From: Pierre Habouzit Date: Sun, 13 May 2007 13:59:10 +0000 (+0200) Subject: remove antiquated cruft: please, who use MMDF's nowadays ?! X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=0ab517261694b001d2eb17f06f167a4cdd2c7c07;p=apps%2Fmadmutt.git remove antiquated cruft: please, who use MMDF's nowadays ?! Signed-off-by: Pierre Habouzit --- diff --git a/OPS b/OPS index d8e4db6..0fda7e6 100644 --- a/OPS +++ b/OPS @@ -113,7 +113,6 @@ OP_MAIN_CHANGE_GROUP "open a different newsgroup" 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" diff --git a/attach.c b/attach.c index 53fac9e..afae486 100644 --- a/attach.c +++ b/attach.c @@ -680,7 +680,7 @@ int mutt_save_attachment (FILE * fp, BODY * m, char *path, int flags, 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 diff --git a/buffy.h b/buffy.h index 1581103..89b6d53 100644 --- a/buffy.h +++ b/buffy.h @@ -18,7 +18,7 @@ typedef struct buffy_t { 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); diff --git a/commands.c b/commands.c index da633cb..147742a 100644 --- a/commands.c +++ b/commands.c @@ -699,7 +699,7 @@ int mutt_save_message (HEADER * h, int delete, } } - need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF); + need_buffy_cleanup = (ctx.magic == M_MBOX); mx_close_mailbox (&ctx, NULL); diff --git a/copy.c b/copy.c index f865d8a..f79a9d5 100644 --- a/copy.c +++ b/copy.c @@ -720,7 +720,7 @@ _mutt_append_message (CONTEXT * dest, FILE * fpin, CONTEXT * src __attribute__ ( 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); diff --git a/editmsg.c b/editmsg.c index c66f5ee..ec458a5 100644 --- a/editmsg.c +++ b/editmsg.c @@ -61,8 +61,7 @@ static int edit_one_message (CONTEXT * ctx, HEADER * cur) } 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); @@ -124,14 +123,14 @@ static int edit_one_message (CONTEXT * ctx, HEADER * cur) } 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 diff --git a/functions.def b/functions.def index 60ca042..7a32260 100644 --- a/functions.def +++ b/functions.def @@ -85,7 +85,6 @@ LIST(OpGeneric) 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) diff --git a/init.c b/init.c index b0f4ac3..48a2024 100644 --- a/init.c +++ b/init.c @@ -328,7 +328,6 @@ static void magic_to_string (char* dst, ssize_t dstlen, 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; @@ -337,15 +336,14 @@ static void magic_to_string (char* dst, ssize_t dstlen, } 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) @@ -1603,12 +1601,9 @@ int mutt_var_value_complete (char *buffer, ssize_t len, int pos) 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; diff --git a/init.h b/init.h index 6d22d36..77b12cb 100644 --- a/init.h +++ b/init.h @@ -1204,7 +1204,7 @@ struct option_t MuttVars[] = { /* ** .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" }, /* @@ -2185,7 +2185,7 @@ struct option_t MuttVars[] = { ** 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" }, diff --git a/lib-mx/compress.c b/lib-mx/compress.c index 6e988ca..93a383d 100644 --- a/lib-mx/compress.c +++ b/lib-mx/compress.c @@ -266,7 +266,7 @@ static void restore_path (CONTEXT * ctx) /* 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); } @@ -296,13 +296,10 @@ int mutt_open_append_compressed (CONTEXT * ctx) 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; } diff --git a/lib-mx/mbox.c b/lib-mx/mbox.c index 60caf04..57f287a 100644 --- a/lib-mx/mbox.c +++ b/lib-mx/mbox.c @@ -7,7 +7,7 @@ * 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 @@ -71,122 +71,6 @@ static void mbox_unlock_mailbox (CONTEXT * ctx) } } -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. * @@ -340,7 +224,7 @@ static int mbox_parse_mailbox (CONTEXT * ctx) #undef PREV -/* open a mbox or mmdf style mailbox */ +/* open a mbox style mailbox */ static int mbox_open_mailbox (CONTEXT * ctx) { int rc; @@ -357,8 +241,6 @@ static int mbox_open_mailbox (CONTEXT * ctx) if (ctx->magic == M_MBOX) rc = mbox_parse_mailbox (ctx); - else if (ctx->magic == M_MMDF) - rc = mmdf_parse_mailbox (ctx); else rc = -1; @@ -416,13 +298,9 @@ static int _mbox_check_mailbox (CONTEXT * ctx, int *index_hint) */ 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 @@ -575,12 +453,6 @@ static int mbox_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)) /* 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); @@ -603,15 +475,6 @@ static int mbox_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)) 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 @@ -637,22 +500,11 @@ static int mbox_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)) 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; } } } @@ -680,11 +532,11 @@ static int mbox_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)) 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 { @@ -867,24 +719,11 @@ static int mbox_reopen_mailbox (CONTEXT * ctx, int *index_hint) 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) { @@ -983,7 +822,8 @@ int mbox_check_empty (const char *path) 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]; @@ -992,11 +832,7 @@ int mbox_is_magic (const char* path, struct stat* st) { 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; @@ -1004,8 +840,6 @@ int mbox_is_magic (const char* path, struct stat* st) { 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, @@ -1025,23 +859,14 @@ int mbox_is_magic (const char* path, struct stat* st) { 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 = { @@ -1059,17 +884,3 @@ 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, -}; diff --git a/lib-mx/mbox.h b/lib-mx/mbox.h index fc9a6fd..1139e4c 100644 --- a/lib-mx/mbox.h +++ b/lib-mx/mbox.h @@ -9,7 +9,7 @@ */ /* - * functions for dealing with mbox/mmdf style mailboxes + * functions for dealing with mbox style mailboxes */ #ifndef _MBOX_H @@ -18,12 +18,9 @@ #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*); diff --git a/lib-mx/mx.c b/lib-mx/mx.c index b58a621..05c9e8a 100644 --- a/lib-mx/mx.c +++ b/lib-mx/mx.c @@ -40,7 +40,6 @@ static mx_t const *mxfmts[] = { &mbox_mx, - &mmdf_mx, &mh_mx, &maildir_mx, &imap_mx, @@ -149,138 +148,138 @@ static int mx_get_idx (const char* path) { 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; } @@ -315,8 +314,6 @@ int mx_set_magic (const char *s) { 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) @@ -422,7 +419,6 @@ static int mx_open_mailbox_append (CONTEXT * ctx, int flags) 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) { @@ -667,7 +663,7 @@ static int _mx_close_mailbox (CONTEXT * ctx, int *index_hint) 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); @@ -820,10 +816,11 @@ static int _mx_close_mailbox (CONTEXT * ctx, int *index_hint) 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); @@ -1004,9 +1001,9 @@ static int _mx_sync_mailbox (CONTEXT * ctx, int *index_hint) 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; @@ -1067,10 +1064,7 @@ MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags) 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; @@ -1113,7 +1107,6 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) msg = p_new(MESSAGE, 1); switch (msg->magic = ctx->magic) { case M_MBOX: - case M_MMDF: msg->fp = ctx->fp; break; @@ -1205,28 +1198,12 @@ int mx_close_message (MESSAGE ** msg) 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 @@ -1309,49 +1286,11 @@ int mx_check_empty (const char *path) 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) diff --git a/lib-mx/mx.h b/lib-mx/mx.h index efc732b..a017576 100644 --- a/lib-mx/mx.h +++ b/lib-mx/mx.h @@ -24,7 +24,6 @@ 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, @@ -159,8 +158,6 @@ void mx_update_tables (CONTEXT *, int); 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 */ diff --git a/lib-ui/curs_main.c b/lib-ui/curs_main.c index 45c5105..b094f23 100644 --- a/lib-ui/curs_main.c +++ b/lib-ui/curs_main.c @@ -2281,10 +2281,6 @@ int mutt_index_menu (void) 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: diff --git a/lib-ui/menu.c b/lib-ui/menu.c index f509ae0..19ab550 100644 --- a/lib-ui/menu.c +++ b/lib-ui/menu.c @@ -984,10 +984,6 @@ int mutt_menuLoop (MUTTMENU * menu) mutt_what_key (); break; - case OP_REBUILD_CACHE: - mx_rebuild_cache (); - break; - case OP_REDRAW: clearok (stdscr, TRUE); menu->redraw = REDRAW_FULL; diff --git a/sendlib.c b/sendlib.c index b79d3c1..5ff0da1 100644 --- a/sendlib.c +++ b/sendlib.c @@ -2109,7 +2109,7 @@ int mutt_write_fcc (const char *path, HEADER * hdr, const char *msgid, /* 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"));