summaryrefslogtreecommitdiffstats
path: root/usr.bin/whois
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-08-26 11:16:08 +0000
committercharnier <charnier@FreeBSD.org>1997-08-26 11:16:08 +0000
commit19da442f11bbe272dd39ff4fdf3b23e8f2198f0d (patch)
tree73cb27e251687456c15a9e8d21af16fe6ea35ed3 /usr.bin/whois
parenta5eee593ac091b453bd8d7158bf447ab3109b5e8 (diff)
downloadFreeBSD-src-19da442f11bbe272dd39ff4fdf3b23e8f2198f0d.zip
FreeBSD-src-19da442f11bbe272dd39ff4fdf3b23e8f2198f0d.tar.gz
Use err(3).
Diffstat (limited to 'usr.bin/whois')
-rw-r--r--usr.bin/whois/whois.16
-rw-r--r--usr.bin/whois/whois.c35
2 files changed, 22 insertions, 19 deletions
diff --git a/usr.bin/whois/whois.1 b/usr.bin/whois/whois.1
index 6a974b4..01808ea 100644
--- a/usr.bin/whois/whois.1
+++ b/usr.bin/whois/whois.1
@@ -54,10 +54,10 @@ Use the specified host instead of the default NIC (whois.internic.net).
.El
.Pp
The operands specified to
-.Nm whois
+.Nm
are concatenated together (separated by white-space) and presented to
the
-.Nm whois
+.Nm
server.
.Pp
The default action, unless directed otherwise with a special
@@ -75,6 +75,6 @@ the special name
RFC 812: Nicname/Whois
.Sh HISTORY
The
-.Nm whois
+.Nm
command appeared in
.Bx 4.3 .
diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c
index a70301a..7b7be08 100644
--- a/usr.bin/whois/whois.c
+++ b/usr.bin/whois/whois.c
@@ -32,29 +32,37 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1980, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)whois.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <err.h>
#include <netdb.h>
#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
#define NICHOST "whois.internic.net"
+static void usage __P((void));
+
+int
main(argc, argv)
int argc;
char **argv;
{
- extern char *optarg;
- extern int optind;
register FILE *sfi, *sfo;
register int ch;
struct sockaddr_in sin;
@@ -91,27 +99,21 @@ main(argc, argv)
}
host = hp->h_name;
s = socket(hp->h_addrtype, SOCK_STREAM, 0);
- if (s < 0) {
- perror("whois: socket");
- exit(1);
- }
+ if (s < 0)
+ err(1, "socket");
bzero((caddr_t)&sin, sizeof (sin));
sin.sin_family = hp->h_addrtype;
bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length);
sp = getservbyname("whois", "tcp");
- if (sp == NULL) {
- (void)fprintf(stderr, "whois: whois/tcp: unknown service\n");
- exit(1);
- }
+ if (sp == NULL)
+ errx(1, "whois/tcp: unknown service");
sin.sin_port = sp->s_port;
- if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- perror("whois: connect");
- exit(1);
- }
+ if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0)
+ err(1, "connect");
sfi = fdopen(s, "r");
sfo = fdopen(s, "w");
if (sfi == NULL || sfo == NULL) {
- perror("whois: fdopen");
+ warn("fdopen");
(void)close(s);
exit(1);
}
@@ -124,6 +126,7 @@ main(argc, argv)
exit(0);
}
+static void
usage()
{
(void)fprintf(stderr, "usage: whois [-h hostname] name ...\n");
OpenPOWER on IntegriCloud