if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
perror("whois: connect");
exit(1);
}
sfi = fdopen(s, "r");
sfo = fdopen(s, "w");
if (sfi == NULL || sfo == NULL) {
perror("whois: fdopen");
(void)close(s);
exit(1);
}
while (argc-- > 1)
{
(void)fprintf(sfo, "%s ", *argv++);
}
(void)fprintf(sfo, "%s\r\n", *argv);
(void)fflush(sfo);
while ((ch = getc(sfi)) != EOF)
putchar(ch);
exit(0);
}
usage()
{
(void)fprintf(stderr, "Usage1: whois [-h whois_server_hostname] name ...\n\nWhois will look in the file %s%s for a list of TLD and IP whois servers.\n\nThe latest copy of %s can be found at:\n\n http://dns.vrx.net/tech/rootzone/whohosts.txt\n\n", WHOIS_PATH, WHOIS_FILE, WHOIS_FILE);
exit(1);
}
char *nichost (char *name)
{
FILE *hosts;
char hostsfile[SX];
static char inbuf[SX];
char *s;
strcpy (hostsfile, WHOIS_PATH);
strcat (hostsfile, WHOIS_FILE);
hosts = fopen (hostsfile, "r");
if (hosts == (FILE *)NULL)
{
fprintf (stderr, "\nCan't find whois hosts file as %s\nSee http://dns.vrx.net/tech/rootzone/whohosts.txt to get a copy.\n", hostsfile);