* Copyright (c) 1980 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)whois.c 5.4 (Berkeley) %G%";
#define NICHOST "sri-nic.arpa"
register FILE *sfi
, *sfo
;
while ((ch
= getopt(argc
, argv
, "h")) != EOF
)
hp
= gethostbyname(host
);
fprintf(stderr
, "whois: %s: host unknown\n", host
);
s
= socket(hp
->h_addrtype
, SOCK_STREAM
, 0, 0);
bzero((caddr_t
)&sin
, sizeof (sin
));
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
)
fprintf(stderr
, "usage: whois [-h host] name\n");