* Copyright (c) 1980 Regents of the University of California.
* %sccs.include.redist.c%
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)whois.c 5.10 (Berkeley) %G%";
#define NICHOST "nic.ddn.mil"
register FILE *sfi
, *sfo
;
while ((ch
= getopt(argc
, argv
, "h:")) != EOF
)
hp
= gethostbyname(host
);
(void)fprintf(stderr
, "whois: %s: ", host
);
s
= socket(hp
->h_addrtype
, SOCK_STREAM
, 0);
bzero((caddr_t
)&sin
, sizeof (sin
));
sin
.sin_family
= hp
->h_addrtype
;
if (bind(s
, (struct sockaddr
*)&sin
, sizeof(sin
)) < 0) {
bcopy(hp
->h_addr
, (char *)&sin
.sin_addr
, hp
->h_length
);
sp
= getservbyname("whois", "tcp");
(void)fprintf(stderr
, "whois: whois/tcp: unknown service\n");
sin
.sin_port
= sp
->s_port
;
if (connect(s
, &sin
, sizeof(sin
)) < 0) {
perror("whois: connect");
if (sfi
== NULL
|| sfo
== NULL
) {
(void)fprintf(sfo
, "%s ", *argv
++);
(void)fprintf(sfo
, "%s\r\n", *argv
);
while ((ch
= getc(sfi
)) != EOF
)
(void)fprintf(stderr
, "usage: whois [-h hostname] name ...\n");