-/* $OpenBSD: strip.c,v 1.6 1997/01/15 23:43:15 millert Exp $ */
+/* $OpenBSD: strip.c,v 1.7 1997/02/09 16:37:13 mickey Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
#ifndef lint
/*static char sccsid[] = "from: @(#)strip.c 5.8 (Berkeley) 11/6/91";*/
-static char rcsid[] = "$OpenBSD: strip.c,v 1.6 1997/01/15 23:43:15 millert Exp $";
+static char rcsid[] = "$OpenBSD: strip.c,v 1.7 1997/02/09 16:37:13 mickey Exp $";
#endif /* not lint */
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <err.h>
typedef struct exec EXEC;
typedef struct nlist NLIST;
#define strx n_un.n_strx
-void err __P((const char *fmt, ...));
int s_stab __P((const char *, int, EXEC *, struct stat *));
int s_sym __P((const char *, int, EXEC *, struct stat *));
void usage __P((void));
argv += optind;
errors = 0;
-#define ERROR(x) errors |= 1; err("%s: %s", fn, strerror(x)); continue;
+#define ERROR(x) errors |= 1; warn(fn); continue;
while (fn = *argv++) {
if ((fd = open(fn, O_RDWR)) < 0) {
ERROR(errno);
/* Truncate the file. */
if (ftruncate(fd, neweof - (char *)ep)) {
- err("%s: %s", fn, strerror(errno));
+ warn(fn);
return 1;
}
return 0;
if (N_SYMOFF(*ep) >= sp->st_size) {
- err("%s: bad symbol table", fn);
+ warnx("%s: bad symbol table", fn);
return 1;
}
*/
strbase = (char *)ep + N_STROFF(*ep);
if ((nstrbase = malloc((u_int)*(u_long *)strbase)) == NULL) {
- err("%s", strerror(ENOMEM));
+ warnx("%s", strerror(ENOMEM));
return 1;
}
nstr = nstrbase + sizeof(u_long);
/* Truncate to the current length. */
if (ftruncate(fd, (char *)nsym + len - (char *)ep)) {
- err("%s: %s", fn, strerror(errno));
+ warn(fn);
return 1;
}
exit(1);
}
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-void
-#if __STDC__
-err(const char *fmt, ...)
-#else
-err(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- (void)fprintf(stderr, "strip: ");
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- (void)fprintf(stderr, "\n");
-}