MH is sooo dead.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
{
char tmp[_POSIX_PATH_MAX];
char buff[STRING];
- int omagic;
int oerrno;
int rc;
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));
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)
{
{ 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 },
};
}
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)
(*((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
** 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
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);
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. */
}
}
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)) {
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);
}
#define MAXLOCKATTEMPT 5
-WHERE short DefaultMagic INITVAL (M_MBOX);
-
/*
* please use the following _ONLY_ when doing "something"
* with folders
/* 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);