about summary refs log tree commit diff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-06-11 20:51:01 +0000
committerLeah Neukirchen <leah@vuxu.org>2024-06-15 21:51:51 +0200
commitb078f8c19ee4261ca310aa581894dd9a4a441c21 (patch)
treeafd6465de083b381c8c39294de94f86c698589f3
parentd5e202b30f46123d836c73f989587ab2df011fb3 (diff)
downloadmblaze-b078f8c19ee4261ca310aa581894dd9a4a441c21.tar.gz
mblaze-b078f8c19ee4261ca310aa581894dd9a4a441c21.tar.xz
mblaze-b078f8c19ee4261ca310aa581894dd9a4a441c21.zip
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.
-rw-r--r--blaze822.h11
-rw-r--r--magrep.c2
-rw-r--r--mdeliver.c8
-rw-r--r--mexport.c2
-rw-r--r--mflag.c2
-rw-r--r--minc.c3
-rw-r--r--mlist.c4
-rw-r--r--mpick.c2
-rw-r--r--mscan.c2
-rw-r--r--mseq.c8
-rw-r--r--msort.c8
11 files changed, 32 insertions, 20 deletions
diff --git a/blaze822.h b/blaze822.h
index ad5cc76..1346345 100644
--- a/blaze822.h
+++ b/blaze822.h
@@ -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
diff --git a/magrep.c b/magrep.c
index 72ce1bb..608048a 100644
--- a/magrep.c
+++ b/magrep.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;
diff --git a/mdeliver.c b/mdeliver.c
index 5269929..663e8dd 100644
--- a/mdeliver.c
+++ b/mdeliver.c
@@ -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
diff --git a/mexport.c b/mexport.c
index 458f943..0ac490d 100644
--- a/mexport.c
+++ b/mexport.c
@@ -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 = "";
 
diff --git a/mflag.c b/mflag.c
index 9ee8747..ae9a9f2 100644
--- a/mflag.c
+++ b/mflag.c
@@ -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;
 
diff --git a/minc.c b/minc.c
index 2811646..757c65b 100644
--- a/minc.c
+++ b/minc.c
@@ -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));
diff --git a/mlist.c b/mlist.c
index 20061d9..e0ec42c 100644
--- a/mlist.c
+++ b/mlist.c
@@ -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) {
diff --git a/mpick.c b/mpick.c
index 6d80e63..661e472 100644
--- a/mpick.c
+++ b/mpick.c
@@ -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;
diff --git a/mscan.c b/mscan.c
index 4052f1f..bb6cd9e 100644
--- a/mscan.c
+++ b/mscan.c
@@ -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
diff --git a/mseq.c b/mseq.c
index 519284e..ac3aa19 100644
--- a/mseq.c
+++ b/mseq.c
@@ -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;
diff --git a/msort.c b/msort.c
index 02d1e42..55ec6aa 100644
--- a/msort.c
+++ b/msort.c
@@ -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;