mbox: include messages added to an mbox before saving it
[neatmail.git] / mail.c
blob136870ddf0ad0226f85bc058243c506615d1c88f
1 /*
2 * neatmail mail client
4 * Copyright (C) 2009-2015 Ali Gholami Rudi <ali at rudi dot ir>
6 * This program is released under the Modified BSD license.
7 */
8 #include <ctype.h>
9 #include <fcntl.h>
10 #include <signal.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <unistd.h>
15 #include <sys/stat.h>
16 #include "mail.h"
18 static int has_mail(char *path)
20 struct stat st;
21 if (stat(path, &st) == -1)
22 return 0;
23 return st.st_mtime > st.st_atime;
26 static int ns(char *argv[])
28 int i;
29 for (i = 0; argv[i]; i++)
30 if (has_mail(argv[i]))
31 printf("%s\n", argv[i]);
32 return 0;
35 static char *usage =
36 "usage: neatmail command [options]\n\n"
37 "commands:\n"
38 " ex \texecute commands on an mbox\n"
39 " mk \tlist the messages in an mbox\n"
40 " pg \tpage a message of an mbox\n"
41 " ns \tcheck mboxes for new mails\n";
43 int main(int argc, char *argv[])
45 signal(SIGPIPE, SIG_IGN);
46 if (!argv[1])
47 printf("%s", usage);
48 if (argv[1] && !strcmp("mk", argv[1]))
49 mk(argv + 2);
50 if (argv[1] && !strcmp("ex", argv[1]))
51 ex(argv + 2);
52 if (argv[1] && !strcmp("pg", argv[1]))
53 pg(argv + 2);
54 if (argv[1] && !strcmp("ns", argv[1]))
55 ns(argv + 2);
56 return 0;