diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1998-07-10 15:05:28 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1998-07-10 15:05:28 +0000 |
commit | 88d931f35a731adb533dcf367837ff5949637d86 (patch) | |
tree | 5e01dbc640d99214c193b12c33c9a0aad47bd780 /usr.bin/file/apprentice.c | |
parent | 0ed8ac719d88afe131759970558dcb7530ab0e49 (diff) |
err/warn
Diffstat (limited to 'usr.bin/file/apprentice.c')
-rw-r--r-- | usr.bin/file/apprentice.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/usr.bin/file/apprentice.c b/usr.bin/file/apprentice.c index 8a5ccbec20f..6ec2908cefd 100644 --- a/usr.bin/file/apprentice.c +++ b/usr.bin/file/apprentice.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apprentice.c,v 1.4 1997/02/09 23:58:16 millert Exp $ */ +/* $OpenBSD: apprentice.c,v 1.5 1998/07/10 15:05:13 mickey Exp $ */ /* * apprentice - make one pass through /etc/magic, learning its secrets. @@ -32,10 +32,11 @@ #include <string.h> #include <ctype.h> #include <errno.h> +#include <err.h> #include "file.h" #ifndef lint -static char *moduleid = "$OpenBSD: apprentice.c,v 1.4 1997/02/09 23:58:16 millert Exp $"; +static char *moduleid = "$OpenBSD: apprentice.c,v 1.5 1998/07/10 15:05:13 mickey Exp $"; #endif /* lint */ #define EATAB {while (isascii((unsigned char) *l) && \ @@ -66,7 +67,7 @@ int check; /* non-zero? checking-only run. */ magic = (struct magic *) calloc(sizeof(struct magic), maxmagic); mfn = malloc(strlen(fn)+1); if (magic == NULL || mfn == NULL) { - (void) fprintf(stderr, "%s: Out of memory.\n", progname); + warn("malloc"); if (check) return -1; else @@ -84,8 +85,7 @@ int check; /* non-zero? checking-only run. */ fn = p; } if (errs == -1) - (void) fprintf(stderr, "%s: couldn't find any magic files!\n", - progname); + warnx("couldn't find any magic files!"); if (!check && errs) exit(1); @@ -107,9 +107,7 @@ int check; /* non-zero? checking-only run. */ f = fopen(fn, "r"); if (f==NULL) { if (errno != ENOENT) - (void) fprintf(stderr, - "%s: can't read magic file %s (%s)\n", - progname, fn, strerror(errno)); + warn(fn); return -1; } @@ -165,8 +163,7 @@ uint32 v; case STRING: break; default: - magwarn("can't happen: m->type=%d\n", - m->type); + warnx("can't happen: m->type=%d\n", m->type); return -1; } return v; @@ -190,7 +187,7 @@ int *ndx, check; if ((magic = (struct magic *) realloc(magic, sizeof(struct magic) * maxmagic)) == NULL) { - (void) fprintf(stderr, "%s: Out of memory.\n", progname); + warn("malloc"); if (check) return -1; else @@ -219,7 +216,7 @@ int *ndx, check; /* get offset, then skip over it */ m->offset = (int) strtoul(l,&t,0); if (l == t) - magwarn("offset %s invalid", l); + warnx("offset %s invalid", l); l = t; if (m->flag & INDIR) { @@ -243,7 +240,7 @@ int *ndx, check; m->in.type = BYTE; break; default: - magwarn("indirect offset type %c invalid", *l); + warnx("indirect offset type %c invalid", *l); break; } l++; @@ -257,7 +254,7 @@ int *ndx, check; else t = l; if (*t++ != ')') - magwarn("missing ')' in indirect offset"); + warnx("missing ')' in indirect offset"); l = t; } @@ -318,7 +315,7 @@ int *ndx, check; m->type = LEDATE; l += NLEDATE; } else { - magwarn("type %s invalid", l); + warnx("type %s invalid", l); return -1; } /* New-style anding: "0 byte&0x80 =0x80 dynamically linked" */ @@ -364,7 +361,7 @@ int *ndx, check; /* * TODO finish this macro and start using it! * #define offsetcheck {if (offset > HOWMANY-1) - * magwarn("offset too big"); } + * warnx("offset too big"); } */ /* |