pull/1/merge
Christian Neukirchen 8 years ago
parent 49b88176a0
commit 98456df2cf

@ -1,6 +1,6 @@
CFLAGS=-g -O1 -Wall -Wno-switch -Wextra -fstack-protector-strong -D_FORTIFY_SOURCE=2
ALL = mscan mthread mhdr mshow mlist mseq msort mmime
ALL = mscan mthread mhdr mshow mlist mseq msort mmime minc
all: $(ALL)
@ -12,6 +12,7 @@ mlist: mlist.o
mseq: mseq.o seq.o
msort: msort.o blaze822.o seq.o
mmime: mmime.o
minc: minc.o
clean: FRC
-rm -f $(ALL) *.o

@ -0,0 +1,76 @@
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <search.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "blaze822.h"
static int qflag;
static int status;
void
inc(char *dir)
{
DIR *fd;
struct dirent *d;
char src[PATH_MAX];
char dst[PATH_MAX];
snprintf(src, sizeof src, "%s/new", dir);
fd = opendir(src);
if (!fd) {
fprintf(stderr, "minc: can't open maildir '%s': %s\n",
dir, strerror(errno));
status = 2;
return;
}
while ((d = readdir(fd))) {
if (d->d_type != DT_REG && d->d_type != DT_UNKNOWN)
continue;
if (d->d_name[0] == '.')
continue;
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,");
if (rename(src, dst) < 0) {
fprintf(stderr, "minc: can't rename '%s' to '%s': %s\n",
src, dst, strerror(errno));
status = 3;
continue;
}
if (!qflag)
printf("%s\n", dst);
}
closedir(fd);
}
int
main(int argc, char *argv[])
{
int c, i;
while ((c = getopt(argc, argv, "q")) != -1)
switch(c) {
case 'q': qflag = 1; break;
default:
// XXX usage
exit(1);
}
status = 0;
for (i = optind; i < argc; i++)
inc(argv[i]);
return status;
}
Loading…
Cancel
Save