diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1998-07-10 15:45:20 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1998-07-10 15:45:20 +0000 |
commit | 40e9d89d04d73ca717a5779ac980382050fcac96 (patch) | |
tree | 9f4dfca9c29cb1cc897c985751db71ae1615c9b2 /usr.bin | |
parent | 88d931f35a731adb533dcf367837ff5949637d86 (diff) |
err/warn
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/finger/finger.c | 29 | ||||
-rw-r--r-- | usr.bin/finger/net.c | 10 | ||||
-rw-r--r-- | usr.bin/finger/sprint.c | 11 | ||||
-rw-r--r-- | usr.bin/finger/util.c | 20 |
4 files changed, 30 insertions, 40 deletions
diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c index 1c42b65938b..487aea33852 100644 --- a/usr.bin/finger/finger.c +++ b/usr.bin/finger/finger.c @@ -1,4 +1,4 @@ -/* $OpenBSD: finger.c,v 1.7 1997/05/30 23:35:51 kstailey Exp $ */ +/* $OpenBSD: finger.c,v 1.8 1998/07/10 15:45:15 mickey Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -54,7 +54,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)finger.c 5.22 (Berkeley) 6/29/90";*/ -static char rcsid[] = "$OpenBSD: finger.c,v 1.7 1997/05/30 23:35:51 kstailey Exp $"; +static char rcsid[] = "$OpenBSD: finger.c,v 1.8 1998/07/10 15:45:15 mickey Exp $"; #endif /* not lint */ /* @@ -77,6 +77,7 @@ static char rcsid[] = "$OpenBSD: finger.c,v 1.7 1997/05/30 23:35:51 kstailey Exp #include <stdlib.h> #include <string.h> #include <time.h> +#include <err.h> #include "finger.h" #include "extern.h" @@ -90,6 +91,7 @@ main(argc, argv) char **argv; { extern int optind; + extern char *__progname; int ch; char domain[256]; @@ -121,7 +123,7 @@ main(argc, argv) case '?': default: (void)fprintf(stderr, - "usage: finger [-lmMpsho] [login ...]\n"); + "usage: %s [-lmMpsho] [login ...]\n", __progname); exit(1); } argc -= optind; @@ -171,10 +173,8 @@ loginlist() struct utmp user; char name[UT_NAMESIZE + 1]; - if (!freopen(_PATH_UTMP, "r", stdin)) { - (void)fprintf(stderr, "finger: can't read %s.\n", _PATH_UTMP); - exit(2); - } + if (!freopen(_PATH_UTMP, "r", stdin)) + err(2, _PATH_UTMP); name[UT_NAMESIZE] = '\0'; while (fread((char *)&user, sizeof(user), 1, stdin) == 1) { if (!user.ut_name[0]) @@ -203,10 +203,8 @@ userlist(argc, argv) struct passwd *pw; int dolocal, *used; - if (!(used = (int *)calloc((u_int)argc, (u_int)sizeof(int)))) { - (void)fprintf(stderr, "finger: out of space.\n"); - exit(1); - } + if (!(used = (int *)calloc((u_int)argc, (u_int)sizeof(int)))) + err(2, "malloc"); /* pull out all network requests */ for (i = 0, dolocal = 0, nettail = &nethead; i < argc; i++) { @@ -247,8 +245,7 @@ userlist(argc, argv) /* list errors */ for (i = 0; i < argc; i++) if (!used[i]) - (void)fprintf(stderr, - "finger: %s: no such user.\n", argv[i]); + warnx("%s: no such user.", argv[i]); /* handle network requests */ net: for (pn = nethead; pn; pn = pn->next) { @@ -264,10 +261,8 @@ net: for (pn = nethead; pn; pn = pn->next) { * Scan thru the list of users currently logged in, saving * appropriate data whenever a match occurs. */ - if (!freopen(_PATH_UTMP, "r", stdin)) { - (void)fprintf( stderr, "finger: can't read %s.\n", _PATH_UTMP); - exit(1); - } + if (!freopen(_PATH_UTMP, "r", stdin)) + err(1, _PATH_UTMP); while (fread((char *)&user, sizeof(user), 1, stdin) == 1) { if (!user.ut_name[0]) continue; diff --git a/usr.bin/finger/net.c b/usr.bin/finger/net.c index ea01e774ca8..a39548ae752 100644 --- a/usr.bin/finger/net.c +++ b/usr.bin/finger/net.c @@ -1,4 +1,4 @@ -/* $OpenBSD: net.c,v 1.5 1997/05/30 23:35:52 kstailey Exp $ */ +/* $OpenBSD: net.c,v 1.6 1998/07/10 15:45:16 mickey Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)net.c 5.5 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$OpenBSD: net.c,v 1.5 1997/05/30 23:35:52 kstailey Exp $"; +static char rcsid[] = "$OpenBSD: net.c,v 1.6 1998/07/10 15:45:16 mickey Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -50,6 +50,7 @@ static char rcsid[] = "$OpenBSD: net.c,v 1.5 1997/05/30 23:35:52 kstailey Exp $" #include <string.h> #include <ctype.h> #include <unistd.h> +#include <err.h> #include "finger.h" #include "extern.h" @@ -72,8 +73,7 @@ netfinger(name) if (inet_aton(host, &sin.sin_addr) == 0) { hp = gethostbyname(host); if (hp == 0) { - (void)fprintf(stderr, - "finger: unknown host: %s\n", host); + warnx("unknown host: %s", host); return; } sin.sin_family = hp->h_addrtype; @@ -82,7 +82,7 @@ netfinger(name) } else sin.sin_family = AF_INET; if (!(sp = getservbyname("finger", "tcp"))) { - (void)fprintf(stderr, "finger: tcp/finger: unknown service\n"); + warnx("tcp/finger: unknown service\n"); return; } sin.sin_port = sp->s_port; diff --git a/usr.bin/finger/sprint.c b/usr.bin/finger/sprint.c index b112a4efa5a..c4005de63e3 100644 --- a/usr.bin/finger/sprint.c +++ b/usr.bin/finger/sprint.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sprint.c,v 1.4 1997/06/02 21:33:27 kstailey Exp $ */ +/* $OpenBSD: sprint.c,v 1.5 1998/07/10 15:45:18 mickey Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)sprint.c 5.8 (Berkeley) 12/4/90";*/ -static char rcsid[] = "$OpenBSD: sprint.c,v 1.4 1997/06/02 21:33:27 kstailey Exp $"; +static char rcsid[] = "$OpenBSD: sprint.c,v 1.5 1998/07/10 15:45:18 mickey Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -46,6 +46,7 @@ static char rcsid[] = "$OpenBSD: sprint.c,v 1.4 1997/06/02 21:33:27 kstailey Exp #include <tzfile.h> #include <stdio.h> #include <stdlib.h> +#include <err.h> #include "finger.h" #include "extern.h" @@ -137,10 +138,8 @@ sort() PERSON *pn, **lp; PERSON **list; - if (!(list = (PERSON **)malloc((u_int)(entries * sizeof(PERSON *))))) { - (void)fprintf(stderr, "finger: out of space.\n"); - exit(1); - } + if (!(list = (PERSON **)malloc((u_int)(entries * sizeof(PERSON *))))) + err(1, "malloc"); for (lp = list, pn = phead; pn != NULL; pn = pn->next) *lp++ = pn; (void)qsort(list, entries, sizeof(PERSON *), psort); diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c index bcb50b75b6e..df7bc600a5b 100644 --- a/usr.bin/finger/util.c +++ b/usr.bin/finger/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.9 1998/01/09 17:17:39 millert Exp $ */ +/* $OpenBSD: util.c,v 1.10 1998/07/10 15:45:19 mickey Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -39,7 +39,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)util.c 5.14 (Berkeley) 1/17/91";*/ -static char rcsid[] = "$OpenBSD: util.c,v 1.9 1998/01/09 17:17:39 millert Exp $"; +static char rcsid[] = "$OpenBSD: util.c,v 1.10 1998/07/10 15:45:19 mickey Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -56,6 +56,7 @@ static char rcsid[] = "$OpenBSD: util.c,v 1.9 1998/01/09 17:17:39 millert Exp $" #include <errno.h> #include <unistd.h> #include <vis.h> +#include <err.h> #include "finger.h" #include "extern.h" @@ -113,8 +114,7 @@ userinfo(pn, pw) pn->mailrecv = -1; /* -1 == not_valid */ if (stat(tbuf, &sb) < 0) { if (errno != ENOENT) { - (void)fprintf(stderr, - "finger: %s: %s\n", tbuf, strerror(errno)); + warn(tbuf); return; } } else if (sb.st_size != 0) { @@ -304,10 +304,8 @@ palloc() { PERSON *p; - if ((p = (PERSON *)malloc((u_int) sizeof(PERSON))) == NULL) { - (void)fprintf(stderr, "finger: out of space.\n"); - exit(1); - } + if ((p = (PERSON *)malloc((u_int) sizeof(PERSON))) == NULL) + err(1, "malloc"); return(p); } @@ -317,10 +315,8 @@ walloc(pn) { WHERE *w; - if ((w = (WHERE *)malloc((u_int) sizeof(WHERE))) == NULL) { - (void)fprintf(stderr, "finger: out of space.\n"); - exit(1); - } + if ((w = (WHERE *)malloc((u_int) sizeof(WHERE))) == NULL) + err(1, "malloc"); if (pn->whead == NULL) pn->whead = pn->wtail = w; else { |