* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)whois.c 5.2 (Berkeley) %G%";
#define NICHOST "sri-nic.arpa"
register FILE *sfi
, *sfo
;
if (argc
> 2 && strcmp(*argv
, "-h") == 0) {
fprintf(stderr
, "usage: whois [ -h host ] name\n");
hp
= gethostbyname(host
);
fprintf(stderr
, "whois: %s: host unknown\n", host
);
s
= socket(hp
->h_addrtype
, SOCK_STREAM
, 0, 0);
sin
.sin_family
= hp
->h_addrtype
;
if (bind(s
, &sin
, sizeof (sin
), 0) < 0) {
bcopy(hp
->h_addr
, &sin
.sin_addr
, hp
->h_length
);
sp
= getservbyname("whois", "tcp");
fprintf(stderr
, "whois: whois/tcp: unknown service\n");
sin
.sin_port
= sp
->s_port
;
if (connect(s
, &sin
, sizeof (sin
), 0) < 0) {
perror("whois: connect");
if (sfi
== NULL
|| sfo
== NULL
) {
fprintf(sfo
, "%s\r\n", *argv
);
while ((c
= getc(sfi
)) != EOF
)