diff options
author | charnier <charnier@FreeBSD.org> | 1997-08-08 12:20:24 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-08-08 12:20:24 +0000 |
commit | feae501bfd9d1b634e4f0ccd3d2197100a679b6d (patch) | |
tree | 6bfc86a4aaab0112841b5a970d39e60019a10e27 /usr.bin/rwho | |
parent | 3fcaa37feecb7f762fef674dd7023ceaf7ab7528 (diff) | |
download | FreeBSD-src-feae501bfd9d1b634e4f0ccd3d2197100a679b6d.zip FreeBSD-src-feae501bfd9d1b634e4f0ccd3d2197100a679b6d.tar.gz |
Use err(3). Add usage() and prototypes. Add Xr to who(1).
Diffstat (limited to 'usr.bin/rwho')
-rw-r--r-- | usr.bin/rwho/rwho.1 | 13 | ||||
-rw-r--r-- | usr.bin/rwho/rwho.c | 41 |
2 files changed, 34 insertions, 20 deletions
diff --git a/usr.bin/rwho/rwho.1 b/usr.bin/rwho/rwho.1 index 898ccc7..1b49b19 100644 --- a/usr.bin/rwho/rwho.1 +++ b/usr.bin/rwho/rwho.1 @@ -38,26 +38,26 @@ .Nm rwho .Nd who is logged in on local machines .Sh SYNOPSIS -.Nm rwho +.Nm .Op Fl a .Sh DESCRIPTION The -.Nm rwho +.Nm command produces output similar to .Xr who , but for all machines on the local network. If no report has been received from a machine for 5 minutes then -.Nm rwho +.Nm assumes the machine is down, and does not report users last known to be logged into that machine. .Pp If a users hasn't typed to the system for a minute or more, then -.Nm rwho +.Nm reports this idle time. If a user hasn't typed to the system for an hour or more, then the user will be omitted from the output of -.Nm rwho +.Nm unless the .Fl a flag is given. @@ -68,10 +68,11 @@ information about other machines .El .Sh SEE ALSO .Xr ruptime 1 , +.Xr who 1 , .Xr rwhod 8 .Sh HISTORY The -.Nm rwho +.Nm command appeared in .Bx 4.3 . diff --git a/usr.bin/rwho/rwho.c b/usr.bin/rwho/rwho.c index 557e8fa..b1a4af9 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; { |