From f80921726b70cd11f0caa9827372791aa5550edf Mon Sep 17 00:00:00 2001 From: charnier Date: Wed, 6 Aug 1997 06:49:06 +0000 Subject: Use err(3), cosmetic in usage(). --- usr.bin/rpcinfo/rpcinfo.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) (limited to 'usr.bin/rpcinfo/rpcinfo.c') diff --git a/usr.bin/rpcinfo/rpcinfo.c b/usr.bin/rpcinfo/rpcinfo.c index 4a50531..d5161d0 100644 --- a/usr.bin/rpcinfo/rpcinfo.c +++ b/usr.bin/rpcinfo/rpcinfo.c @@ -1,7 +1,8 @@ #ifndef lint /*static char sccsid[] = "from: @(#)rpcinfo.c 1.22 87/08/12 SMI";*/ /*static char sccsid[] = "from: @(#)rpcinfo.c 2.2 88/08/11 4.0 RPCSRC";*/ -static char rcsid[] = "$Id: rpcinfo.c,v 1.4 1997/02/22 19:56:45 peter Exp $"; +static char rcsid[] = + "$Id: rpcinfo.c,v 1.5 1997/03/29 04:31:57 imp Exp $"; #endif /* @@ -42,6 +43,8 @@ static char rcsid[] = "$Id: rpcinfo.c,v 1.4 1997/02/22 19:56:45 peter Exp $"; * Mountain View, California 94043 */ +#include +#include #include #include #include @@ -49,7 +52,6 @@ static char rcsid[] = "$Id: rpcinfo.c,v 1.4 1997/02/22 19:56:45 peter Exp $"; #include #include #include -#include #define MAXHOSTLEN 256 @@ -591,27 +593,24 @@ deletereg(argc, argv) usage() ; exit(1) ; } - if (getuid()) { /* This command allowed only to root */ - fprintf(stderr, "Sorry. You are not root\n") ; - exit(1) ; - } + if (getuid()) /* This command allowed only to root */ + errx(1, "sorry, you are not root") ; prog_num = getprognum(argv[0]); version_num = getvers(argv[1]); - if ((pmap_unset(prog_num, version_num)) == 0) { - fprintf(stderr, "rpcinfo: Could not delete registration for prog %s version %s\n", + if ((pmap_unset(prog_num, version_num)) == 0) + errx(1, "could not delete registration for prog %s version %s", argv[0], argv[1]) ; - exit(1) ; - } } static void usage() { - fprintf(stderr, "Usage: rpcinfo [ -n portnum ] -u host prognum [ versnum ]\n"); - fprintf(stderr, " rpcinfo [ -n portnum ] -t host prognum [ versnum ]\n"); - fprintf(stderr, " rpcinfo -p [ host ]\n"); - fprintf(stderr, " rpcinfo -b prognum versnum\n"); - fprintf(stderr, " rpcinfo -d prognum versnum\n") ; + fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", + "usage: rpcinfo [-n portnum] -u host prognum [versnum]", + " rpcinfo [-n portnum] -t host prognum [versnum]", + " rpcinfo -p [host]", + " rpcinfo -b prognum versnum", + " rpcinfo -d prognum versnum"); } static u_long @@ -623,11 +622,8 @@ getprognum(arg) if (isalpha(*arg)) { rpc = getrpcbyname(arg); - if (rpc == NULL) { - fprintf(stderr, "rpcinfo: %s is unknown service\n", - arg); - exit(1); - } + if (rpc == NULL) + errx(1, "%s is unknown service", arg); prognum = rpc->r_number; } else { prognum = (u_long) atoi(arg); @@ -656,10 +652,8 @@ get_inet_address(addr, host) bzero((char *)addr, sizeof *addr); addr->sin_addr.s_addr = (u_long) inet_addr(host); if (addr->sin_addr.s_addr == -1 || addr->sin_addr.s_addr == 0) { - if ((hp = gethostbyname(host)) == NULL) { - fprintf(stderr, "rpcinfo: %s is unknown host\n", host); - exit(1); - } + if ((hp = gethostbyname(host)) == NULL) + errx(1, "%s is unknown host", host); bcopy(hp->h_addr, (char *)&addr->sin_addr, hp->h_length); } addr->sin_family = AF_INET; -- cgit v1.1