X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fpackf.c;h=fe1102c66338af9767b58f1bc127998eba2fcc62;hp=763b6e708b9369d9f5c59bde5bbd60d9258f7b18;hb=6e9577f324bef90765a5edc02044eb111ec48072;hpb=ccf4f175ef4c4e7522f9510a4a1149c15d810dd9 diff --git a/uip/packf.c b/uip/packf.c index 763b6e7..fe1102c 100644 --- a/uip/packf.c +++ b/uip/packf.c @@ -11,6 +11,9 @@ #include #include #include +#include +#include +#include static struct swit switches[] = { #define VERSIONSW 0 @@ -20,6 +23,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; int main(int argc, char **argv) @@ -47,23 +51,23 @@ main(int argc, char **argv) switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(1); + exit(EX_USAGE); case UNKWNSW: - adios(NULL, "-%s unknown", cp); + adios(EX_USAGE, NULL, "-%s unknown", cp); case HELPSW: snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help(buf, switches, 1); - done(1); + exit(argc == 2 ? EX_OK : EX_USAGE); case VERSIONSW: print_version(invo_name); - done(1); + exit(argc == 2 ? EX_OK : EX_USAGE); } } if (*cp == '+' || *cp == '@') { if (folder) - adios(NULL, "only one folder at a time!"); - folder = getcpy(expandfol(cp)); + adios(EX_USAGE, NULL, "only one folder at a time!"); + folder = mh_xstrdup(expandfol(cp)); } else app_msgarg(&msgs, cp); } @@ -77,20 +81,20 @@ main(int argc, char **argv) maildir = toabsdir(folder); if (chdir(maildir) == NOTOK) - adios(maildir, "unable to change directory to "); + adios(EX_OSERR, maildir, "unable to change directory to "); /* read folder and create message structure */ if (!(mp = folder_read(folder))) - adios(NULL, "unable to read folder %s", folder); + adios(EX_IOERR, NULL, "unable to read folder %s", folder); /* check for empty folder */ if (mp->nummsg == 0) - adios(NULL, "no messages in %s", folder); + adios(EX_DATAERR, NULL, "no messages in %s", folder); /* parse all the message ranges/sequences and set SELECTED */ for (msgnum = 0; msgnum < msgs.size; msgnum++) if (!m_convert(mp, msgs.msgs[msgnum])) - done(1); + exit(EX_USAGE); seq_setprev(mp); /* set the previous-sequence */ /* copy all the SELECTED messages to stdout */ @@ -102,7 +106,7 @@ main(int argc, char **argv) break; } if (mbox_copy(fileno(stdout), fd) == NOTOK) { - adios(NULL, "error writing to stdout"); + adios(EX_IOERR, NULL, "error writing to stdout"); } close(fd); } @@ -113,6 +117,5 @@ main(int argc, char **argv) seq_save(mp); context_save(); folder_free(mp); - done(0); - return 1; + return 0; }