/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*
* Copyright (c) 2013 Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <ctype.h>
#include <err.h>
#include <limits.h>
#include <netdb.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
static char *choose_server(char *);
static void usage(void);
static void whois(const char *, const char *, int);
int
{
char *qnichost;
flags = use_qnichost = 0;
switch (ch) {
case 'a':
break;
case 'A':
break;
case 'b':
break;
case 'c':
break;
case 'f':
break;
case 'g':
break;
case 'h':
break;
case 'i':
break;
case 'I':
break;
case 'k':
break;
case 'l':
break;
case 'm':
break;
case 'p':
break;
case 'Q':
flags |= WHOIS_QUICK;
break;
case 'r':
break;
case '?':
default:
usage();
/* NOTREACHED */
}
}
usage();
/*
* If no host or country is specified determine the top level domain
* from the query. If the TLD is a number, query ARIN. Otherwise, use
* TLD.whois-server.net. If the domain does not contain '.', fall
* back to NICHOST.
*/
use_qnichost = 1;
if (!(flags & WHOIS_QUICK))
flags |= WHOIS_RECURSE;
}
while (argc-- > 0) {
} else if (use_qnichost)
argv++;
}
return (0);
}
/*
* This function will remove any trailing periods from domain, after which it
* returns a pointer to newly allocated memory containing the whois server to
* be queried, or a NULL if the correct server couldn't be determined. The
* caller must remember to free(3) the allocated memory.
*/
static char *
{
return (retval);
}
*pos = '\0';
if (*domain == '\0')
"-NORID") == 0) {
return (retval);
}
--pos;
return (NULL);
else
return (retval);
}
static struct addrinfo *
{
int error;
if (error) {
if (exit_on_error)
return (NULL);
}
return (res);
}
/*
* Wrapper for asprintf(3) that exits on error.
*/
/* PRINTFLIKE2 */
static void
{
}
}
static void
{
/*
* The variables buf and buflen are static so the buffer for
* getline() is retained across calls.
*/
int i, s;
s = -1;
if (s < 0)
continue;
break;
(void) close(s);
}
} else {
}
if (!ishost(*p)) {
*p = '\0';
break;
}
}
} else if ((host =
if (!ishost(*p)) {
*p = '\0';
break;
}
}
for (c = 0; c <= len; c++)
NULL) {
ip_whois[i]);
break;
}
}
}
}
}
}
}
static void
usage(void)
{
"usage: whois [-aAbfgiIklmQr] [-c country-code | -h hostname] "
"[-p port] name ...\n");
}