X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fwhom.c;h=e61dc62327e8f0686d09dfa76362fa5dca3d6957;hp=3d3eb8464ebb937aca6a84ebd15bf03e6efb28ad;hb=cf1205b5cbea2f0cd6ea710ec16c637df85b647c;hpb=2abb9a7cfb0930e27062088734d306e7d78e4cc2 diff --git a/uip/whom.c b/uip/whom.c index 3d3eb84..e61dc62 100644 --- a/uip/whom.c +++ b/uip/whom.c @@ -11,6 +11,7 @@ #include #include #include +#include static struct swit switches[] = { #define VERSIONSW 0 @@ -86,20 +87,20 @@ main(int argc, char **argv) switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - exit(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 [switches] file ...", 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 TOCCSW: toccsw = 1; @@ -124,7 +125,7 @@ main(int argc, char **argv) } } if (filep > NFILES) { - adios(NULL, "too many files (more than %d)", + adios(EX_USAGE, NULL, "too many files (more than %d)", NFILES); } else { files[filep++] = cp; @@ -132,10 +133,10 @@ main(int argc, char **argv) } files[filep] = NULL; if (!filep) { - adios(NULL, "usage: %s [switches] file ...", invo_name); + adios(EX_USAGE, NULL, "usage: %s [switches] file ...", invo_name); } if (!toccsw && !bccsw) { - adios(NULL, "give -tocc or -bcc or both to produce output"); + adios(EX_USAGE, NULL, "give -tocc or -bcc or both to produce output"); } for (filep=0; files[filep]; filep++) { process(files[filep]); @@ -144,7 +145,7 @@ main(int argc, char **argv) cmd = add("ali -list", NULL); if ((n=print()) && alisw) { if (!(in = popen(cmd, "r"))) { - adios("popen", "unable to"); + adios(EX_IOERR, "popen", "unable to"); } while (fgets(buf, sizeof buf, in)) { fputs(buf, stdout); @@ -157,7 +158,7 @@ main(int argc, char **argv) cmd = add("ali -list", NULL); if ((n=printbcc()) && alisw) { if (!(in = popen(cmd, "r"))) { - adios("popen", "unable to"); + adios(EX_IOERR, "popen", "unable to"); } while (fgets(buf, sizeof buf, in)) { fputs(buf, stdout); @@ -180,7 +181,7 @@ process(char *file) if ((in = fopen(file, "r")) == NULL) { - adios(file, "unable to open"); + adios(EX_IOERR, file, "unable to open"); } for (compnum = 1, state = FLD;;) { @@ -208,11 +209,11 @@ process(char *file) case LENERR: case FMTERR: - adios(NULL, "message format error in component #%d", + adios(EX_DATAERR, NULL, "message format error in component #%d", compnum); default: - adios(NULL, "getfld() returned %d", state); + adios(EX_SOFTWARE, NULL, "getfld() returned %d", state); } break; } @@ -264,7 +265,7 @@ proc_hdr(char *name, char *val) while ((cp = getname(val))) { if (!(mp->m_next = getm(cp, NULL, 0, AD_NAME, NULL))) { - adios(NULL, "illegal address: %s", cp); + adios(EX_DATAERR, NULL, "illegal address: %s", cp); } mp = mp->m_next; if (mp->m_type == BADHOST) {