mime: cp1256 and iso-8859-6 character sets
[neatmail.git] / mail.c
blobda90b01d4a88a8c0c2c8b99b61cc34c9ff69774b
1 /*
2 * NEATMAIL MAIL CLIENT
4 * Copyright (C) 2009-2018 Ali Gholami Rudi <ali at rudi dot ir>
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #include <ctype.h>
19 #include <fcntl.h>
20 #include <signal.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <unistd.h>
25 #include <sys/stat.h>
26 #include "mail.h"
28 static int has_mail(char *path)
30 struct stat st;
31 if (stat(path, &st) == -1)
32 return 0;
33 return st.st_mtime > st.st_atime;
36 static int ns(char *argv[])
38 int i;
39 for (i = 0; argv[i]; i++)
40 if (has_mail(argv[i]))
41 printf("%s\n", argv[i]);
42 return 0;
45 static char *usage =
46 "usage: neatmail command [options]\n\n"
47 "commands:\n"
48 " ex \texecute commands on an mbox\n"
49 " mk \tlist the messages in an mbox\n"
50 " pg \tpage a message of an mbox\n"
51 " ns \tcheck mboxes for new mails\n";
53 int main(int argc, char *argv[])
55 signal(SIGPIPE, SIG_IGN);
56 if (!argv[1])
57 printf("%s", usage);
58 if (argv[1] && !strcmp("mk", argv[1]))
59 mk(argv + 2);
60 if (argv[1] && !strcmp("ex", argv[1]))
61 ex(argv + 2);
62 if (argv[1] && !strcmp("pg", argv[1]))
63 pg(argv + 2);
64 if (argv[1] && !strcmp("ns", argv[1]))
65 ns(argv + 2);
66 return 0;