Maildir: support winnt/ntfs based systems (currently midipix).

Per the Maildir specification, the info (trailing) part of message
filenames is identified by a <colon><spec_version><comma>; however,
on WINNT/NTFS, a colon may not be part of a filename, therefore use
a <semicolon> instead. Since the default remains to use a <colon>,
all targets (other than those definining the __winnt__ macro)
should remain unaffected by this change.
master
midipix 2 weeks ago committed by Leah Neukirchen
parent d5e202b30f
commit b078f8c19e

@ -8,6 +8,17 @@
#define PATH_MAX 4096
#endif
// maildir filename suffix: use a semicolon on winnt/ntfs, otherwise a colon
#ifdef __winnt__
#define MAILDIR_COLON ';'
#define MAILDIR_COLON_SPEC_VER ";2"
#define MAILDIR_COLON_SPEC_VER_COMMA ";2,"
#else
#define MAILDIR_COLON ':'
#define MAILDIR_COLON_SPEC_VER ":2"
#define MAILDIR_COLON_SPEC_VER_COMMA ":2,"
#endif
struct message;
// blaze822.c

@ -151,7 +151,7 @@ void
magrep(char *file)
{
if (!*header) {
char *flags = strstr(file, ":2,");
char *flags = strstr(file, MAILDIR_COLON_SPEC_VER_COMMA);
if (flags)
match(file, "flags", flags+3);
return;

@ -107,7 +107,7 @@ try_again:
snprintf(tmp, sizeof tmp, "%s/tmp/%s", targetdir, id);
if (try_rename) {
snprintf(dst, sizeof dst, "%s/%s/%s:2,%s",
snprintf(dst, sizeof dst, "%s/%s/%s"MAILDIR_COLON_SPEC_VER_COMMA"%s",
targetdir, cflag ? "cur" : "new", id, Xflag);
if (rename(infilename, dst) == 0)
goto success;
@ -173,7 +173,7 @@ try_again:
if (Mflag && in_header &&
(strncasecmp("status:", line, 7) == 0 ||
strncasecmp("x-status:", line, 9) == 0)) {
char *v = strchr(line, ':');
char *v = strchr(line, MAILDIR_COLON);
if (v) {
if (strchr(v, 'F')) statusflags[0] = 'F';
if (strchr(v, 'A')) statusflags[1] = 'R';
@ -257,7 +257,7 @@ try_again:
#endif
}
snprintf(dst, sizeof dst, "%s/%s/%s:2,%s",
snprintf(dst, sizeof dst, "%s/%s/%s"MAILDIR_COLON_SPEC_VER_COMMA"%s",
targetdir, (cflag || is_old) ? "cur" : "new", id,
Xflag ? Xflag : statusflags);
if (rename(tmp, dst) != 0)
@ -285,7 +285,7 @@ refile(char *file)
file++;
// keep flags
char *flags = strstr(file, ":2,");
char *flags = strstr(file, MAILDIR_COLON_SPEC_VER_COMMA);
if (flags)
Xflag = flags + 3;
else

@ -87,7 +87,7 @@ export(char *file)
if (in_header && line[0] == '\n' && !line[1]) {
if (Sflag) {
char *flags = strstr(file, ":2,");
char *flags = strstr(file, MAILDIR_COLON_SPEC_VER_COMMA);
if (!flags)
flags = "";

@ -47,7 +47,7 @@ flag(char *file)
while (file[indent] == ' ' || file[indent] == '\t')
indent++;
char *f = strstr(file, ":2,");
char *f = strstr(file, MAILDIR_COLON_SPEC_VER_COMMA);
if (!f)
goto skip;

@ -46,7 +46,8 @@ inc(char *dir)
snprintf(src, sizeof src, "%s/new/%s",
dir, d->d_name);
snprintf(dst, sizeof dst, "%s/cur/%s%s",
dir, d->d_name, strstr(d->d_name, ":2,") ? "" : ":2,");
dir, d->d_name,
strstr(d->d_name, MAILDIR_COLON_SPEC_VER_COMMA) ? "" : MAILDIR_COLON_SPEC_VER_COMMA);
if (rename(src, dst) < 0) {
fprintf(stderr, "minc: can't rename '%s' to '%s': %s\n",
src, dst, strerror(errno));

@ -58,14 +58,14 @@ list(char *prefix, char *file)
if (flagset || iflag) {
size_t prefixlen;
f = strstr(file, ":2,");
f = strstr(file, MAILDIR_COLON_SPEC_VER_COMMA);
if (!f &&
prefix &&
(prefixlen = strlen(prefix)) &&
prefixlen >= 4 &&
strcmp(prefix + prefixlen - 4, "/new") == 0)
f = ":2,";
f = MAILDIR_COLON_SPEC_VER_COMMA;
}
if (flagset) {

@ -1290,7 +1290,7 @@ mailfile(struct mailinfo *m, char *file)
cur_idx = m->index;
}
char *f = strstr(fpath, ":2,");
char *f = strstr(fpath, MAILDIR_COLON_SPEC_VER_COMMA);
if (f) {
if (strchr(f, 'P'))
m->flags |= FLAG_PASSED;

@ -322,7 +322,7 @@ oneline(char *file)
}
struct message *msg = blaze822(file);
char *flags = msg ? strstr(file, ":2,") : 0;
char *flags = msg ? strstr(file, MAILDIR_COLON_SPEC_VER_COMMA) : 0;
if (!flags)
flags = "";
else

@ -70,7 +70,7 @@ namescan(char *dir)
snprintf(file, sizeof file, "%s/%s", dir, d->d_name);
char *e;
if ((e = strstr(d->d_name, ":2,")))
if ((e = strstr(d->d_name, MAILDIR_COLON_SPEC_VER_COMMA)))
*e = 0;
struct name *c = malloc(sizeof (struct name));
@ -101,7 +101,7 @@ search(char *file)
if (!namefind(dir))
namescan(dir);
if ((e = strstr(file, ":2,")))
if ((e = strstr(file, MAILDIR_COLON_SPEC_VER_COMMA)))
*e = 0;
return namefind(file);
@ -131,11 +131,11 @@ fix(FILE *out, char *file)
char *e;
char *sep;
if ((e = strstr(file, ":2,"))) {
if ((e = strstr(file, MAILDIR_COLON_SPEC_VER_COMMA))) {
sep = "";
e[3] = 0;
} else {
sep = ":2,";
sep = MAILDIR_COLON_SPEC_VER_COMMA;
}
snprintf(buf, sizeof buf, "%s%s", file, sep);
if (access(buf, F_OK) == 0) goto ok;

@ -219,8 +219,8 @@ unreadorder(const void *a, const void *b)
struct mail *ia = (struct mail *)a;
struct mail *ib = (struct mail *)b;
char *fa = strstr(ia->file, ":2,");
char *fb = strstr(ib->file, ":2,");
char *fa = strstr(ia->file, MAILDIR_COLON_SPEC_VER_COMMA);
char *fb = strstr(ib->file, MAILDIR_COLON_SPEC_VER_COMMA);
int unreada = fa ? !strchr(fa, 'S') : 0;
int unreadb = fb ? !strchr(fb, 'S') : 0;
@ -234,8 +234,8 @@ flaggedorder(const void *a, const void *b)
struct mail *ia = (struct mail *)a;
struct mail *ib = (struct mail *)b;
char *fa = strstr(ia->file, ":2,");
char *fb = strstr(ib->file, ":2,");
char *fa = strstr(ia->file, MAILDIR_COLON_SPEC_VER_COMMA);
char *fb = strstr(ib->file, MAILDIR_COLON_SPEC_VER_COMMA);
int unreada = fa ? !!strchr(fa, 'F') : 0;
int unreadb = fb ? !!strchr(fb, 'F') : 0;

Loading…
Cancel
Save