#include <lib-lib/lib-lib.h>
#include <utime.h>
-#include <lib-ui/curses.h>
+#include <lib-ui/lib-ui.h>
#include "mutt.h"
#include "mx.h"
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) {
p_delete(tgt);
close (fd);
unlink (path);
- return (-1);
+ return -1;
}
return 0;
/* 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
struct stat lastchanged;
int ret;
- hc = mutt_hcache_open (HeaderCache, ctx->path);
+ hc = mutt_hcache_open(ctx->path);
#endif
for (p = md, count = 0; p; p = p->next, count++) {
}
static int mh_read_dir (CONTEXT* ctx) {
- return (_mh_read_dir (ctx, NULL));
+ return _mh_read_dir (ctx, NULL);
}
/* read a maildir style mailbox */
* of the main folder path from which to read messages
*/
if (_mh_read_dir (ctx, "new") == -1 || _mh_read_dir (ctx, "cur") == -1)
- return (-1);
+ return -1;
return 0;
}
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) {
p_delete(&msg->path);
close (fd);
unlink (path);
- return (-1);
+ return -1;
}
return 0;
}
+static int maildir_open_message(MESSAGE *msg, CONTEXT *ctx, int msgno)
+{
+ HEADER *cur = ctx->hdrs[msgno];
+ char path[_POSIX_PATH_MAX];
+
+ snprintf (path, sizeof (path), "%s/%s", ctx->path, cur->path);
+ if ((msg->fp = fopen(path, "r")) == NULL
+ && errno == ENOENT && ctx->magic == M_MAILDIR) {
+ msg->fp = maildir_open_find_message (ctx->path, cur->path);
+ }
+
+ if (msg->fp == NULL) {
+ mutt_perror (path);
+ return -1;
+ }
+ return 0;
+}
/*
* Commit a message to a maildir folder.
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) {
if ((dirp = opendir (ctx->path)) == NULL) {
mutt_perror (ctx->path);
- return (-1);
+ return -1;
}
/* figure out what the next message number is */
(h->env && (h->env->refs_changed || h->env->irt_changed))) {
/* when doing attachment deletion/rethreading, fall back to the MH case. */
if (mh_rewrite_message (ctx, msgno) != 0)
- return (-1);
+ return -1;
}
else {
/* we just have to rename the file. */
char *p;
if ((p = strrchr (h->path, '/')) == NULL) {
- return (-1);
+ return -1;
}
p++;
m_strcpy(newpath, sizeof(newpath), p);
if (rename (oldpath, fullpath) != 0) {
mutt_perror ("rename");
- return (-1);
+ return -1;
}
m_strreplace(&h->path, partpath);
}
- return (0);
+ return 0;
}
static int mh_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)), int *index_hint)
int i, j;
#ifdef USE_HCACHE
- void *hc = NULL;
+ hcache_t *hc = NULL;
#endif /* USE_HCACHE */
if (ctx->magic == M_MH)
#ifdef USE_HCACHE
if (ctx->magic == M_MAILDIR)
- hc = mutt_hcache_open (HeaderCache, ctx->path);
+ hc = mutt_hcache_open(ctx->path);
#endif /* USE_HCACHE */
for (i = 0; i < ctx->msgcount; i++) {
#ifdef USE_HCACHE
if (ctx->magic == M_MAILDIR)
- mutt_hcache_close (hc);
+ mutt_hcache_close (&hc);
#endif /* USE_HCACHE */
if (ctx->magic == M_MH)
err:
#ifdef USE_HCACHE
if (ctx->magic == M_MAILDIR)
- mutt_hcache_close (hc);
+ mutt_hcache_close (&hc);
#endif /* USE_HCACHE */
return -1;
}
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) {
access,
maildir_read_dir,
maildir_open_new_message,
+ maildir_open_message,
NULL,
maildir_check_mailbox,
NULL,
access,
mh_read_dir,
mh_open_new_message,
+ maildir_open_message,
NULL,
mh_check_mailbox,
NULL,