projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Further pop_mx_ng work
[apps/madmutt.git]
/
lib-mx
/
mh.c
diff --git
a/lib-mx/mh.c
b/lib-mx/mh.c
index
89ae790
..
5e889d6
100644
(file)
--- a/
lib-mx/mh.c
+++ b/
lib-mx/mh.c
@@
-16,7
+16,7
@@
#include <lib-lib/lib-lib.h>
#include <utime.h>
#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"
#include "mutt.h"
#include "mx.h"
@@
-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",
for (;;) {
snprintf (path, _POSIX_PATH_MAX, "%s/.mutt-%s-%d-%d",
- dest->path, NONULL(
MC
ore.shorthost), (int) getpid (), Counter++);
+ dest->path, NONULL(
mod_c
ore.shorthost), (int) getpid (), Counter++);
umask (Umask);
if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) {
if (errno != EEXIST) {
umask (Umask);
if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) {
if (errno != EEXIST) {
@@
-181,7
+181,7
@@
static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
p_delete(tgt);
close (fd);
unlink (path);
p_delete(tgt);
close (fd);
unlink (path);
- return
(-1)
;
+ return
-1
;
}
return 0;
}
return 0;
@@
-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,
/* FOO - really ignore the return value? */
maildir_parse_entry (ctx, last, subdir, de->d_name, count, is_old,
-#if HAVE_DIRENT_D_INO
+#if
def
HAVE_DIRENT_D_INO
de->d_ino
#else
0
de->d_ino
#else
0
@@
-730,7
+730,7
@@
static void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md)
struct stat lastchanged;
int ret;
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++) {
#endif
for (p = md, count = 0; p; p = p->next, count++) {
@@
-803,7
+803,7
@@
static int _mh_read_dir (CONTEXT * ctx, const char *subdir)
}
static int mh_read_dir (CONTEXT* ctx) {
}
static int mh_read_dir (CONTEXT* ctx) {
- return
(_mh_read_dir (ctx, NULL)
);
+ return
_mh_read_dir (ctx, NULL
);
}
/* read a maildir style mailbox */
}
/* read a maildir style mailbox */
@@
-813,7
+813,7
@@
static int maildir_read_dir (CONTEXT * ctx)
* of the main folder path from which to read messages
*/
if (_mh_read_dir (ctx, "new") == -1 || _mh_read_dir (ctx, "cur") == -1)
* 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;
}
return 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),
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 (
MC
ore.shorthost), suffix);
+ (unsigned int) getpid (), Counter++, NONULL (
mod_c
ore.shorthost), suffix);
umask (Umask);
if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) {
umask (Umask);
if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) {
@@
-916,13
+916,30
@@
static int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr
p_delete(&msg->path);
close (fd);
unlink (path);
p_delete(&msg->path);
close (fd);
unlink (path);
- return
(-1)
;
+ return
-1
;
}
return 0;
}
}
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.
/*
* Commit a message to a maildir folder.
@@
-971,7
+988,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++,
for (;;) {
snprintf (path, _POSIX_PATH_MAX, "%s/%ld.%u_%d.%s%s", subdir,
(long) time (NULL), (unsigned int) getpid (), Counter++,
- NONULL (
MC
ore.shorthost), suffix);
+ NONULL (
mod_c
ore.shorthost), suffix);
snprintf (full, _POSIX_PATH_MAX, "%s/%s", ctx->path, path);
if (safe_rename (msg->path, full) == 0) {
snprintf (full, _POSIX_PATH_MAX, "%s/%s", ctx->path, path);
if (safe_rename (msg->path, full) == 0) {
@@
-1027,7
+1044,7
@@
static int _mh_commit_message (MESSAGE * msg, CONTEXT * ctx, HEADER * hdr,
if ((dirp = opendir (ctx->path)) == NULL) {
mutt_perror (ctx->path);
if ((dirp = opendir (ctx->path)) == NULL) {
mutt_perror (ctx->path);
- return
(-1)
;
+ return
-1
;
}
/* figure out what the next message number is */
}
/* figure out what the next message number is */
@@
-1177,7
+1194,7
@@
static int maildir_sync_message (CONTEXT * ctx, int msgno)
(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)
(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. */
}
else {
/* we just have to rename the file. */
@@
-1190,7
+1207,7
@@
static int maildir_sync_message (CONTEXT * ctx, int msgno)
char *p;
if ((p = strrchr (h->path, '/')) == NULL) {
char *p;
if ((p = strrchr (h->path, '/')) == NULL) {
- return
(-1)
;
+ return
-1
;
}
p++;
m_strcpy(newpath, sizeof(newpath), p);
}
p++;
m_strcpy(newpath, sizeof(newpath), p);
@@
-1216,11
+1233,11
@@
static int maildir_sync_message (CONTEXT * ctx, int msgno)
if (rename (oldpath, fullpath) != 0) {
mutt_perror ("rename");
if (rename (oldpath, fullpath) != 0) {
mutt_perror ("rename");
- return
(-1)
;
+ return
-1
;
}
m_strreplace(&h->path, partpath);
}
}
m_strreplace(&h->path, partpath);
}
- return
(0)
;
+ return
0
;
}
static int mh_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)), int *index_hint)
}
static int mh_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)), int *index_hint)
@@
-1229,7
+1246,7
@@
static int mh_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)),
int i, j;
#ifdef USE_HCACHE
int i, j;
#ifdef USE_HCACHE
-
void
*hc = NULL;
+
hcache_t
*hc = NULL;
#endif /* USE_HCACHE */
if (ctx->magic == M_MH)
#endif /* USE_HCACHE */
if (ctx->magic == M_MH)
@@
-1242,7
+1259,7
@@
static int mh_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)),
#ifdef USE_HCACHE
if (ctx->magic == M_MAILDIR)
#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++) {
#endif /* USE_HCACHE */
for (i = 0; i < ctx->msgcount; i++) {
@@
-1286,7
+1303,7
@@
static int mh_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)),
#ifdef USE_HCACHE
if (ctx->magic == M_MAILDIR)
#ifdef USE_HCACHE
if (ctx->magic == M_MAILDIR)
- mutt_hcache_close (hc);
+ mutt_hcache_close (
&
hc);
#endif /* USE_HCACHE */
if (ctx->magic == M_MH)
#endif /* USE_HCACHE */
if (ctx->magic == M_MH)
@@
-1311,7
+1328,7
@@
static int mh_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)),
err:
#ifdef USE_HCACHE
if (ctx->magic == M_MAILDIR)
err:
#ifdef USE_HCACHE
if (ctx->magic == M_MAILDIR)
- mutt_hcache_close (hc);
+ mutt_hcache_close (
&
hc);
#endif /* USE_HCACHE */
return -1;
}
#endif /* USE_HCACHE */
return -1;
}
@@
-1812,6
+1829,7
@@
mx_t const maildir_mx = {
access,
maildir_read_dir,
maildir_open_new_message,
access,
maildir_read_dir,
maildir_open_new_message,
+ maildir_open_message,
NULL,
maildir_check_mailbox,
NULL,
NULL,
maildir_check_mailbox,
NULL,
@@
-1827,6
+1845,7
@@
mx_t const mh_mx = {
access,
mh_read_dir,
mh_open_new_message,
access,
mh_read_dir,
mh_open_new_message,
+ maildir_open_message,
NULL,
mh_check_mailbox,
NULL,
NULL,
mh_check_mailbox,
NULL,