projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Ignore empty MIME parameter
[mmh]
/
uip
/
whom.c
diff --git
a/uip/whom.c
b/uip/whom.c
index
0451699
..
4b15fbd
100644
(file)
--- a/
uip/whom.c
+++ b/
uip/whom.c
@@
-10,6
+10,8
@@
#include <h/addrsbr.h>
#include <h/fmt_scan.h>
#include <h/utils.h>
#include <h/addrsbr.h>
#include <h/fmt_scan.h>
#include <h/utils.h>
+#include <locale.h>
+#include <sysexits.h>
static struct swit switches[] = {
#define VERSIONSW 0
static struct swit switches[] = {
#define VERSIONSW 0
@@
-85,20
+87,20
@@
main(int argc, char **argv)
switch (smatch(++cp, switches)) {
case AMBIGSW:
ambigsw(cp, switches);
switch (smatch(++cp, switches)) {
case AMBIGSW:
ambigsw(cp, switches);
- done(1);
+ exit(EX_USAGE);
case UNKWNSW:
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);
case HELPSW:
snprintf(buf, sizeof(buf),
"%s [switches] file ...",
invo_name);
print_help(buf, switches, 1);
- done(1);
+ exit(argc == 2 ? EX_OK : EX_USAGE);
case VERSIONSW:
print_version(invo_name);
case VERSIONSW:
print_version(invo_name);
- done(1);
+ exit(argc == 2 ? EX_OK : EX_USAGE);
case TOCCSW:
toccsw = 1;
case TOCCSW:
toccsw = 1;
@@
-123,7
+125,7
@@
main(int argc, char **argv)
}
}
if (filep > NFILES) {
}
}
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;
NFILES);
} else {
files[filep++] = cp;
@@
-131,10
+133,10
@@
main(int argc, char **argv)
}
files[filep] = NULL;
if (!filep) {
}
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) {
}
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]);
}
for (filep=0; files[filep]; filep++) {
process(files[filep]);
@@
-143,7
+145,7
@@
main(int argc, char **argv)
cmd = add("ali -list", NULL);
if ((n=print()) && alisw) {
if (!(in = popen(cmd, "r"))) {
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);
}
while (fgets(buf, sizeof buf, in)) {
fputs(buf, stdout);
@@
-153,14
+155,10
@@
main(int argc, char **argv)
free(cmd);
naddrs += n;
free(cmd);
naddrs += n;
- if (toccsw && bccsw) {
- puts(separator);
- }
-
cmd = add("ali -list", NULL);
if ((n=printbcc()) && alisw) {
if (!(in = popen(cmd, "r"))) {
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);
}
while (fgets(buf, sizeof buf, in)) {
fputs(buf, stdout);
@@
-177,13
+175,13
@@
static int
process(char *file)
{
int state, compnum;
process(char *file)
{
int state, compnum;
- char *cp;
+ char *cp = NULL;
char buf[BUFSIZ], name[NAMESZ];
FILE *in;
if ((in = fopen(file, "r")) == NULL) {
char buf[BUFSIZ], name[NAMESZ];
FILE *in;
if ((in = fopen(file, "r")) == NULL) {
- adios(file, "unable to open");
+ adios(EX_IOERR, file, "unable to open");
}
for (compnum = 1, state = FLD;;) {
}
for (compnum = 1, state = FLD;;) {
@@
-195,7
+193,7
@@
process(char *file)
case FLDPLUS:
compnum++;
case FLDPLUS:
compnum++;
- cp = add(buf, cp);
+ cp = getcpy(buf);
while (state == FLDPLUS) {
state = m_getfld(state, name, buf,
sizeof(buf), in);
while (state == FLDPLUS) {
state = m_getfld(state, name, buf,
sizeof(buf), in);
@@
-211,11
+209,11
@@
process(char *file)
case LENERR:
case FMTERR:
case LENERR:
case FMTERR:
- adios(NULL, "message format error in component #%d",
+ adios(EX_DATAERR, NULL, "message format error in component #%d",
compnum);
default:
compnum);
default:
- adios(NULL, "getfld() returned %d", state);
+ adios(EX_SOFTWARE, NULL, "getfld() returned %d", state);
}
break;
}
}
break;
}
@@
-267,7
+265,7
@@
proc_hdr(char *name, char *val)
while ((cp = getname(val))) {
if (!(mp->m_next = getm(cp, NULL, 0, AD_NAME, NULL))) {
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) {
}
mp = mp->m_next;
if (mp->m_type == BADHOST) {
@@
-314,6
+312,9
@@
printbcc(void)
continue;
}
if (mp->m_type & HBCC) {
continue;
}
if (mp->m_type & HBCC) {
+ if (!naddrs && toccsw) {
+ puts(separator);
+ }
naddrs++;
printone(mp);
}
naddrs++;
printone(mp);
}