From 1d76b29d79137330c8f42d489fe3f67a23f2390b Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Wed, 28 Nov 2007 17:20:15 +0100 Subject: [PATCH] default magic is useless: only _create_ mboxes and maildirs. MH is sooo dead. Signed-off-by: Pierre Habouzit --- editmsg.c | 8 +---- init.c | 31 ----------------- init.h | 6 ---- lib-mx/compress.c | 4 +-- lib-mx/mx.c | 85 ++++++++++++++++------------------------------- lib-mx/mx.h | 4 --- 6 files changed, 30 insertions(+), 108 deletions(-) diff --git a/editmsg.c b/editmsg.c index 09f358f..41895aa 100644 --- a/editmsg.c +++ b/editmsg.c @@ -28,7 +28,6 @@ static int edit_one_message (CONTEXT * ctx, HEADER * cur) { char tmp[_POSIX_PATH_MAX]; char buff[STRING]; - int omagic; int oerrno; int rc; @@ -48,12 +47,7 @@ static int edit_one_message (CONTEXT * ctx, HEADER * cur) mutt_mktemp (tmp); - omagic = DefaultMagic; - DefaultMagic = M_MBOX; - - rc = (mx_open_mailbox (tmp, M_NEWFOLDER, &tmpctx) == NULL) ? -1 : 0; - - DefaultMagic = omagic; + rc = (mx_open_mailbox(tmp, M_NEWFOLDER, &tmpctx) == NULL) ? -1 : 0; if (rc == -1) { mutt_error (_("could not create temporary folder: %s"), strerror (errno)); diff --git a/init.c b/init.c index 9b9346e..c9442ce 100644 --- a/init.c +++ b/init.c @@ -319,18 +319,6 @@ static int rx_from_string (struct option_t* dst, const char* val, return (1); } -static void magic_to_string (char* dst, ssize_t dstlen, - struct option_t* option) { - const char* s = NULL; - switch (option->data) { - case M_MBOX: s = "mbox"; break; - case M_MH: s = "MH"; break; - case M_MAILDIR: s = "Maildir"; break; - default: s = "unknown"; break; - } - snprintf (dst, dstlen, "%s=%s", option->option, s); -} - static int magic_from_string (struct option_t* dst, const char* val, char *errbuf, ssize_t errlen) { @@ -367,7 +355,6 @@ static struct { { DT_QUAD, quad_to_string, quad_from_string }, { DT_SORT, sort_to_string, sort_from_string }, { DT_RX, rx_to_string, rx_from_string }, - { DT_MAGIC, magic_to_string, magic_from_string }, }; @@ -1099,7 +1086,6 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, } else if (DTYPE (option->type) == DT_STR || DTYPE (option->type) == DT_PATH || - DTYPE (option->type) == DT_MAGIC || DTYPE (option->type) == DT_NUM || DTYPE (option->type) == DT_SORT || DTYPE (option->type) == DT_RX) @@ -1559,23 +1545,6 @@ int mutt_var_value_complete (char *buffer, ssize_t len, int pos) (*((short *)option->data) & SORT_REVERSE) ? "reverse-" : "", (*((short *)option->data) & SORT_LAST) ? "last-" : "", p); } - else if (DTYPE (option->type) == DT_MAGIC) { - const char *p; - switch (DefaultMagic) { - case M_MBOX: - p = "mbox"; - break; - case M_MH: - p = "MH"; - break; - case M_MAILDIR: - p = "Maildir"; - break; - default: - p = "unknown"; - } - m_strcpy(tmp, sizeof(tmp), p); - } else if (DTYPE (option->type) == DT_BOOL) m_strcpy(tmp, sizeof(tmp), option(option->data) ? "yes" : "no"); else diff --git a/init.h b/init.h index feedd18..c5a4b56 100644 --- a/init.h +++ b/init.h @@ -929,12 +929,6 @@ struct option_t MuttVars[] = { ** At which characters this compression is done is controled via the ** $$sidebar_boundary variable. */ - {"mbox_type", DT_MAGIC, UL &DefaultMagic, "mbox" }, - /* - ** .pp - ** The default mailbox type used when creating new folders. May be any of - ** \fTmbox\fP, \fTMH\fP and \fTMaildir\fP. - */ {"metoo", DT_BOOL, OPTMETOO, "no" }, /* ** .pp diff --git a/lib-mx/compress.c b/lib-mx/compress.c index 01e4a07..2b18cbb 100644 --- a/lib-mx/compress.c +++ b/lib-mx/compress.c @@ -307,9 +307,7 @@ int mutt_open_append_compressed (CONTEXT * ctx) m_fclose(&fh); ctx->path = p_dupstr(tmppath, m_strlen(tmppath)); - - ctx->magic = DefaultMagic; - + ctx->magic = M_MBOX; if (is_new (ctx->realpath) || ctx->magic != M_MBOX) unlink(tmppath); diff --git a/lib-mx/mx.c b/lib-mx/mx.c index b41a079..38edb8a 100644 --- a/lib-mx/mx.c +++ b/lib-mx/mx.c @@ -157,23 +157,6 @@ int mx_is_local (int m) { return (mxfmts[m]->local); } -/* - * set DefaultMagic to the given value - */ -int mx_set_magic (const char *s) -{ - if (ascii_strcasecmp (s, "mbox") == 0) - DefaultMagic = M_MBOX; - else if (ascii_strcasecmp (s, "mh") == 0) - DefaultMagic = M_MH; - else if (ascii_strcasecmp (s, "maildir") == 0) - DefaultMagic = M_MAILDIR; - else - return (-1); - - return 0; -} - /* mx_access: Wrapper for access, checks permissions on a given mailbox. * We may be interested in using ACL-style flags at some point, currently * we use the normal access() flags. */ @@ -212,9 +195,8 @@ static int mx_open_mailbox_append (CONTEXT * ctx, int flags) } } else if (errno == ENOENT) { - ctx->magic = DefaultMagic; - - if (ctx->magic == M_MH || ctx->magic == M_MAILDIR) { + int len = m_strlen(ctx->path); + if (len > 0 && ctx->path[len - 1] == '/') { char tmp[_POSIX_PATH_MAX]; if (mkdir (ctx->path, S_IRWXU)) { @@ -222,47 +204,36 @@ static int mx_open_mailbox_append (CONTEXT * ctx, int flags) return (-1); } - if (ctx->magic == M_MAILDIR) { - snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path); - if (mkdir (tmp, S_IRWXU)) { - mutt_perror (tmp); - rmdir (ctx->path); - return (-1); - } - - snprintf (tmp, sizeof (tmp), "%s/new", ctx->path); - if (mkdir (tmp, S_IRWXU)) { - mutt_perror (tmp); - snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path); - rmdir (tmp); - rmdir (ctx->path); - return (-1); - } - snprintf (tmp, sizeof (tmp), "%s/tmp", ctx->path); - if (mkdir (tmp, S_IRWXU)) { - mutt_perror (tmp); - snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path); - rmdir (tmp); - snprintf (tmp, sizeof (tmp), "%s/new", ctx->path); - rmdir (tmp); - rmdir (ctx->path); - return (-1); - } + snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path); + if (mkdir (tmp, S_IRWXU)) { + mutt_perror (tmp); + rmdir (ctx->path); + return (-1); } - else { - int i; - snprintf (tmp, sizeof (tmp), "%s/.mh_sequences", ctx->path); - if ((i = creat (tmp, S_IRWXU)) == -1) { - mutt_perror (tmp); - rmdir (ctx->path); - return (-1); - } - close (i); + snprintf (tmp, sizeof (tmp), "%s/new", ctx->path); + if (mkdir (tmp, S_IRWXU)) { + mutt_perror (tmp); + snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path); + rmdir (tmp); + rmdir (ctx->path); + return (-1); } + snprintf (tmp, sizeof (tmp), "%s/tmp", ctx->path); + if (mkdir (tmp, S_IRWXU)) { + mutt_perror (tmp); + snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path); + rmdir (tmp); + snprintf (tmp, sizeof (tmp), "%s/new", ctx->path); + rmdir (tmp); + rmdir (ctx->path); + return (-1); + } + ctx->magic = M_MAILDIR; + } else { + ctx->magic = M_MBOX; } - } - else { + } else { mutt_perror (ctx->path); return (-1); } diff --git a/lib-mx/mx.h b/lib-mx/mx.h index c40b031..9ccae83 100644 --- a/lib-mx/mx.h +++ b/lib-mx/mx.h @@ -109,8 +109,6 @@ typedef struct mx_t { #define MAXLOCKATTEMPT 5 -WHERE short DefaultMagic INITVAL (M_MBOX); - /* * please use the following _ONLY_ when doing "something" * with folders @@ -130,8 +128,6 @@ int mx_close_message (MESSAGE **); /* determines magic for given folder */ int mx_get_magic (const char*); -/* sets/parses DefaultMagic */ -int mx_set_magic (const char *); /* tests whether given folder magic is (valid and) local */ int mx_is_local (int); -- 2.20.1