X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Frcvstore.c;h=fbddda7faba9d0fc51df3d34e004c157df56513a;hp=ba3cfccd497fad9e3a336427591d156111811337;hb=fede6e42d81ce34fd5c1bbe7fb2757b281c2573a;hpb=a7771fd2e83d64228fb675749fc936151249dbd3 diff --git a/uip/rcvstore.c b/uip/rcvstore.c index ba3cfcc..fbddda7 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -11,29 +11,28 @@ #include #include #include -#include static struct swit switches[] = { #define CRETSW 0 { "create", 0 }, #define NCRETSW 1 - { "nocreate", 0 }, + { "nocreate", 2 }, #define UNSEENSW 2 { "unseen", 0 }, #define NUNSEENSW 3 - { "nounseen", 0 }, + { "nounseen", 2 }, #define PUBSW 4 { "public", 0 }, #define NPUBSW 5 - { "nopublic", 0 }, + { "nopublic", 2 }, #define ZEROSW 6 { "zero", 0 }, #define NZEROSW 7 - { "nozero", 0 }, + { "nozero", 2 }, #define SEQSW 8 { "sequence name", 0 }, #define VERSIONSW 9 - { "version", 0 }, + { "Version", 0 }, #define HELPSW 10 { "help", 0 }, { NULL, 0 } @@ -45,30 +44,28 @@ static struct swit switches[] = { */ static char *tmpfilenam = NULL; -static void unlink_done(int) NORETURN; +static void unlink_done(); int main(int argc, char **argv) { int publicsw = -1, zerosw = 0; int create = 1, unseensw = 1; - int fd, msgnum, seqp = 0; + int fd, msgnum; + size_t seqp = 0; char *cp, *maildir, *folder = NULL, buf[BUFSIZ]; char **argp, **arguments, *seqs[NUMATTRS+1]; struct msgs *mp; struct stat st; - done=unlink_done; + atexit(unlink_done); -#ifdef LOCALE setlocale(LC_ALL, ""); -#endif invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); - mts_init(invo_name); arguments = getarguments(invo_name, argc, argv, 1); argp = arguments; @@ -78,7 +75,7 @@ main(int argc, char **argv) switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(1); + exit(1); case UNKWNSW: adios(NULL, "-%s unknown", cp); @@ -87,10 +84,10 @@ main(int argc, char **argv) "%s [+folder] [switches]", invo_name); print_help(buf, switches, 1); - done(1); + exit(1); case VERSIONSW: print_version(invo_name); - done(1); + exit(1); case SEQSW: if (!(cp = *argp++) || *cp == '-') @@ -189,7 +186,7 @@ main(int argc, char **argv) if (st.st_size == 0) { unlink(tmpfilenam); advise(NULL, "empty file"); - done(0); + exit(0); } /* @@ -204,7 +201,7 @@ main(int argc, char **argv) */ if ((msgnum = folder_addmsg(&mp, tmpfilenam, 0, unseensw, 0, 0, NULL)) == -1) - done(1); + exit(1); /* ** Add the message to any extra sequences @@ -212,7 +209,7 @@ main(int argc, char **argv) */ for (seqp = 0; seqs[seqp]; seqp++) { if (!seq_addmsg(mp, seqs[seqp], msgnum, publicsw, zerosw)) - done(1); + exit(1); } seq_setunseen(mp, 1); /* add new msgs to unseen sequences */ @@ -223,17 +220,16 @@ main(int argc, char **argv) unlink(tmpfilenam); /* remove temporary file */ tmpfilenam = NULL; - done(0); - return 1; + return 0; } /* ** Clean up and exit */ static void -unlink_done(int status) +unlink_done() { - if (tmpfilenam && *tmpfilenam) + if (tmpfilenam && *tmpfilenam) { unlink(tmpfilenam); - exit(status); + } }