X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-mx%2Fmh.c;h=0d04ea9279551c53be77dd8194fd2497de01e004;hp=c94ef415db6f9ef3e078907f6f40c371a2f67b1a;hb=8db3fe9c19320b6f6e508d6b1aae03980239a930;hpb=e01192eefa02e292a2e9f6e041977f2db03d8db6 diff --git a/lib-mx/mh.c b/lib-mx/mh.c index c94ef41..0d04ea9 100644 --- a/lib-mx/mh.c +++ b/lib-mx/mh.c @@ -163,7 +163,7 @@ static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt) for (;;) { snprintf (path, _POSIX_PATH_MAX, "%s/.mutt-%s-%d-%d", - dest->path, NONULL(MCore.shorthost), (int) getpid (), Counter++); + dest->path, NONULL(mod_core.shorthost), (int) getpid (), Counter++); umask (Umask); if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) { if (errno != EEXIST) { @@ -656,7 +656,7 @@ static int maildir_parse_dir (CONTEXT * ctx, struct maildir ***last, /* FOO - really ignore the return value? */ maildir_parse_entry (ctx, last, subdir, de->d_name, count, is_old, -#if HAVE_DIRENT_D_INO +#ifdef HAVE_DIRENT_D_INO de->d_ino #else 0 @@ -898,7 +898,7 @@ static int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr for (;;) { snprintf (path, _POSIX_PATH_MAX, "%s/tmp/%s.%ld.%u_%d.%s%s", dest->path, subdir, (long) time (NULL), - (unsigned int) getpid (), Counter++, NONULL (MCore.shorthost), suffix); + (unsigned int) getpid (), Counter++, NONULL (mod_core.shorthost), suffix); umask (Umask); if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) { @@ -971,7 +971,7 @@ static int maildir_commit_message (MESSAGE * msg, CONTEXT * ctx, HEADER * hdr) for (;;) { snprintf (path, _POSIX_PATH_MAX, "%s/%ld.%u_%d.%s%s", subdir, (long) time (NULL), (unsigned int) getpid (), Counter++, - NONULL (MCore.shorthost), suffix); + NONULL (mod_core.shorthost), suffix); snprintf (full, _POSIX_PATH_MAX, "%s/%s", ctx->path, path); if (safe_rename (msg->path, full) == 0) { @@ -1762,52 +1762,38 @@ static int mh_check_empty (const char *path) return r; } -static int mh_is_magic (const char* path, struct stat* st) { - char tmp[_POSIX_PATH_MAX]; - - if (S_ISDIR (st->st_mode)) { - snprintf (tmp, sizeof (tmp), "%s/.mh_sequences", path); - if (access (tmp, F_OK) == 0) - return (M_MH); - - snprintf (tmp, sizeof (tmp), "%s/.xmhcache", path); - if (access (tmp, F_OK) == 0) - return (M_MH); - - snprintf (tmp, sizeof (tmp), "%s/.mew_cache", path); - if (access (tmp, F_OK) == 0) - return (M_MH); - - snprintf (tmp, sizeof (tmp), "%s/.mew-cache", path); - if (access (tmp, F_OK) == 0) - return (M_MH); - - snprintf (tmp, sizeof (tmp), "%s/.sylpheed_cache", path); - if (access (tmp, F_OK) == 0) - return (M_MH); - - /* - * ok, this isn't an mh folder, but mh mode can be used to read - * Usenet news from the spool. ;-) - */ +static int mh_is_magic(const char *path, struct stat *st) +{ + static char const * const files[] = { + ".mh_sequences", ".xmhcache", ".mew_cache", + ".mew-cache", ".sylpheed_cache", + }; + + if (S_ISDIR(st->st_mode)) { + for (int i = 0; i < countof(files); i++) { + char tmp[_POSIX_PATH_MAX]; + + snprintf(tmp, sizeof(tmp), "%s/%s", path, files[i]); + if (access(tmp, F_OK) == 0) + return M_MH; + } + } - snprintf (tmp, sizeof (tmp), "%s/.overview", path); - if (access (tmp, F_OK) == 0) - return (M_MH); - } - return (-1); + return -1; } -static int maildir_is_magic (const char* path, struct stat* st) { - struct stat sb; - char tmp[_POSIX_PATH_MAX]; +static int maildir_is_magic (const char *path, struct stat *st) +{ + if (S_ISDIR(st->st_mode)) { + char tmp[_POSIX_PATH_MAX]; + struct stat sb; - if (S_ISDIR (st->st_mode)) { - snprintf (tmp, sizeof (tmp), "%s/cur", path); - if (stat (tmp, &sb) == 0 && S_ISDIR (sb.st_mode)) - return (M_MAILDIR); - } - return (-1); + snprintf(tmp, sizeof(tmp), "%s/cur", path); + if (stat(tmp, &sb) == 0 && S_ISDIR(sb.st_mode)) + return M_MAILDIR; + } + + return -1; } static int mh_commit (MESSAGE* msg, CONTEXT* ctx) {