diff options
author | Philippe Charnier <charnier@FreeBSD.org> | 1997-08-08 12:20:24 +0000 |
---|---|---|
committer | Philippe Charnier <charnier@FreeBSD.org> | 1997-08-08 12:20:24 +0000 |
commit | 157f1c6c00f74ba3919dbdc0d79ac77cd4a4297b (patch) | |
tree | 70e192e6a07111773f7131aaed88c04111b11fe2 /usr.bin/rwho/rwho.c | |
parent | 3f9b28f9d07251fc69b1b76a1a2d621207a36b6a (diff) | |
download | src-157f1c6c00f74ba3919dbdc0d79ac77cd4a4297b.tar.gz src-157f1c6c00f74ba3919dbdc0d79ac77cd4a4297b.zip |
Use err(3). Add usage() and prototypes. Add Xr to who(1).
Notes
Notes:
svn path=/head/; revision=27978
Diffstat (limited to 'usr.bin/rwho/rwho.c')
-rw-r--r-- | usr.bin/rwho/rwho.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/usr.bin/rwho/rwho.c b/usr.bin/rwho/rwho.c index 557e8fa1548b..b1a4af9a4d96 100644 --- a/usr.bin/rwho/rwho.c +++ b/usr.bin/rwho/rwho.c @@ -32,23 +32,30 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1983, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)rwho.c 8.1 (Berkeley) 6/6/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include <sys/param.h> #include <sys/file.h> #include <protocols/rwhod.h> #include <dirent.h> +#include <err.h> #include <locale.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <time.h> +#include <unistd.h> #include <utmp.h> DIR *dirp; @@ -72,12 +79,14 @@ int nusers; time_t now; int aflg; +static void usage __P((void)); +int utmpcmp __P((struct myutmp *, struct myutmp *)); + +int main(argc, argv) int argc; char **argv; { - extern char *optarg; - extern int optind; int ch; struct dirent *dp; int cc, width; @@ -95,16 +104,13 @@ main(argc, argv) break; case '?': default: - fprintf(stderr, "usage: rwho [-a]\n"); - exit(1); + usage(); } - if (chdir(_PATH_RWHODIR) || (dirp = opendir(".")) == NULL) { - perror(_PATH_RWHODIR); - exit(1); - } + if (chdir(_PATH_RWHODIR) || (dirp = opendir(".")) == NULL) + err(1, "%s", _PATH_RWHODIR); mp = myutmp; (void)time(&now); - while (dp = readdir(dirp)) { + while ((dp = readdir(dirp))) { if (dp->d_ino == 0 || strncmp(dp->d_name, "whod.", 5)) continue; f = open(dp->d_name, O_RDONLY); @@ -126,10 +132,8 @@ main(argc, argv) we++; continue; } - if (nusers >= NUSERS) { - printf("too many users\n"); - exit(1); - } + if (nusers >= NUSERS) + errx(1, "too many users"); mp->myutmp = we->we_utmp; mp->myidle = we->we_idle; (void) strcpy(mp->myhost, w->wd_hostname); nusers++; we++; mp++; @@ -177,6 +181,15 @@ main(argc, argv) exit(0); } + +static void +usage() +{ + fprintf(stderr, "usage: rwho [-a]\n"); + exit(1); +} + +int utmpcmp(u1, u2) struct myutmp *u1, *u2; { |