X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fburst.c;h=37dc9b17d8871c941027fe1c385685dd51fb797c;hp=21b218ba72e2a151211312227df9fac34d9704b7;hb=cf1205b5cbea2f0cd6ea710ec16c637df85b647c;hpb=d254c5e2ad008f26d5fda43c3f24f0a711c7e851 diff --git a/uip/burst.c b/uip/burst.c index 21b218b..37dc9b1 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -10,6 +10,7 @@ #include #include #include +#include static struct swit switches[] = { #define VERBSW 0 @@ -62,18 +63,17 @@ main(int argc, char **argv) switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - /* sysexits.h EX_USAGE */ - exit(1); + exit(EX_USAGE); case UNKWNSW: - adios(NULL, "-%s unknown\n", cp); + adios(EX_USAGE, NULL, "-%s unknown\n", cp); case HELPSW: snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help(buf, switches, 1); - exit(0); + exit(argc == 2 ? EX_OK : EX_USAGE); case VERSIONSW: print_version(invo_name); - exit(0); + exit(argc == 2 ? EX_OK : EX_USAGE); case VERBSW: verbosw++; @@ -85,7 +85,7 @@ main(int argc, char **argv) } if (*cp == '+' || *cp == '@') { if (folder) - adios(NULL, "only one folder at a time!"); + adios(EX_USAGE, NULL, "only one folder at a time!"); else folder = getcpy(expandfol(cp)); } else { @@ -100,27 +100,26 @@ main(int argc, char **argv) maildir = toabsdir(folder); if (chdir(maildir) == NOTOK) - adios(maildir, "unable to change directory to"); + adios(EX_SOFTWARE, 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 < msgp; msgnum++) if (!m_convert(mp, msgs[msgnum])) - /* sysexits.h EX_USAGE */ - exit(1); + exit(EX_SOFTWARE); seq_setprev(mp); /* set the previous-sequence */ smsgs = (struct smsg *) calloc((size_t) (MAXFOLDER + 2), sizeof(*smsgs)); if (smsgs == NULL) - adios(NULL, "unable to allocate burst storage"); + adios(EX_OSERR, NULL, "unable to allocate burst storage"); hi = mp->hghmsg + 1; @@ -134,7 +133,7 @@ main(int argc, char **argv) } else if (numburst == 0) { admonish(NULL, "message %d not in digest format", msgnum); } else { - adios(NULL, "burst() botch -- you lose big"); + adios(EX_SOFTWARE, NULL, "burst() botch -- you lose big"); } } } @@ -174,7 +173,7 @@ find_delim(int msgnum, struct smsg *smsgs) ld3 = strlen(delim3); if ((in = fopen(msgnam = m_name(msgnum), "r")) == NULL) - adios(msgnam, "unable to read message"); + adios(EX_IOERR, msgnam, "unable to read message"); for (msgp = 0, pos = 0L; msgp <= MAXFOLDER; msgp++) { while (fgets(buffer, sizeof(buffer), in) && buffer[0] == '\n') @@ -227,7 +226,7 @@ burst(struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, struct msgs *mp; if ((in = fopen(msgnam = m_name(msgnum), "r")) == NULL) - adios(msgnam, "unable to read message"); + adios(EX_IOERR, msgnam, "unable to read message"); mode = fstat(fileno(in), &st) != NOTOK ? (int)(st.st_mode & 0777) : m_gmprot(); @@ -239,7 +238,7 @@ burst(struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, */ if ((mp->hghmsg + numburst > mp->hghoff) && !(mp = folder_realloc(mp, mp->lowoff, mp->hghmsg + numburst))) - adios(NULL, "unable to allocate folder storage"); + adios(EX_OSERR, NULL, "unable to allocate folder storage"); *mpp = mp; /* @@ -251,7 +250,7 @@ burst(struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, for (j=1, i=mp->hghmsg+1; j<=numburst; j++, i++) { snprintf(destfil, sizeof destfil, "%s/%d", maildir, i); if (!(out = fopen(destfil, "w"))) { - adios(destfil, "unable to open"); + adios(EX_IOERR, destfil, "unable to open"); } if (verbosw) { printf("message %d of digest %d becomes message %d\n", @@ -331,7 +330,7 @@ cpybrst(FILE *in, FILE *out, char *ifile, char *ofile, int len) } if (ferror(in) && !feof(in)) - adios(ifile, "error reading"); + adios(EX_IOERR, ifile, "error reading"); if (ferror(out)) - adios(ofile, "error writing"); + adios(EX_IOERR, ofile, "error writing"); }