From 33ffab8aa4448049956fde308f80fea97512e406 Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 3 May 1998 23:22:37 +0000 Subject: Be picky about the format of the commandline and cleanup a warning related to qsort. PR: 6420 Submitted by: Ruslan Ermilov --- usr.bin/rwho/rwho.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'usr.bin/rwho/rwho.c') diff --git a/usr.bin/rwho/rwho.c b/usr.bin/rwho/rwho.c index b1a4af9..2a6a7ab 100644 --- a/usr.bin/rwho/rwho.c +++ b/usr.bin/rwho/rwho.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)rwho.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id$"; + "$Id: rwho.c,v 1.11 1997/08/08 12:20:24 charnier Exp $"; #endif /* not lint */ #include @@ -80,7 +80,7 @@ time_t now; int aflg; static void usage __P((void)); -int utmpcmp __P((struct myutmp *, struct myutmp *)); +int utmpcmp __P((const void *, const void *)); int main(argc, argv) @@ -106,6 +106,12 @@ main(argc, argv) default: usage(); } + argc -= optind; + argv += optind; + + if (argc != 0) + usage(); + if (chdir(_PATH_RWHODIR) || (dirp = opendir(".")) == NULL) err(1, "%s", _PATH_RWHODIR); mp = myutmp; @@ -189,17 +195,21 @@ usage() exit(1); } +#define MYUTMP(a) ((struct myutmp *)(a)) + int utmpcmp(u1, u2) - struct myutmp *u1, *u2; + const void *u1, *u2; { int rc; - rc = strncmp(u1->myutmp.out_name, u2->myutmp.out_name, sizeof(u2->myutmp.out_name)); + rc = strncmp(MYUTMP(u1)->myutmp.out_name, MYUTMP(u2)->myutmp.out_name, + sizeof(MYUTMP(u2)->myutmp.out_name)); if (rc) return (rc); - rc = strcmp(u1->myhost, u2->myhost); + rc = strcmp(MYUTMP(u1)->myhost, MYUTMP(u2)->myhost); if (rc) return (rc); - return (strncmp(u1->myutmp.out_line, u2->myutmp.out_line, sizeof(u2->myutmp.out_line))); + return (strncmp(MYUTMP(u1)->myutmp.out_line, MYUTMP(u2)->myutmp.out_line, + sizeof(MYUTMP(u2)->myutmp.out_line))); } -- cgit v1.1