=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/whois/whois.c,v retrieving revision 1.18 retrieving revision 1.19 diff -c -r1.18 -r1.19 *** src/usr.bin/whois/whois.c 2002/12/19 20:37:24 1.18 --- src/usr.bin/whois/whois.c 2002/12/19 21:34:28 1.19 *************** *** 1,4 **** ! /* $OpenBSD: whois.c,v 1.18 2002/12/19 20:37:24 millert Exp $ */ /* * Copyright (c) 1980, 1993 --- 1,4 ---- ! /* $OpenBSD: whois.c,v 1.19 2002/12/19 21:34:28 millert Exp $ */ /* * Copyright (c) 1980, 1993 *************** *** 43,49 **** #if 0 static const char sccsid[] = "@(#)whois.c 8.1 (Berkeley) 6/6/93"; #else ! static const char rcsid[] = "$OpenBSD: whois.c,v 1.18 2002/12/19 20:37:24 millert Exp $"; #endif #endif /* not lint */ --- 43,49 ---- #if 0 static const char sccsid[] = "@(#)whois.c 8.1 (Berkeley) 6/6/93"; #else ! static const char rcsid[] = "$OpenBSD: whois.c,v 1.19 2002/12/19 21:34:28 millert Exp $"; #endif #endif /* not lint */ *************** *** 63,68 **** --- 63,69 ---- #define NICHOST "whois.crsnic.net" #define INICHOST "whois.internic.net" + #define CNICHOST "whois.corenic.net" #define DNICHOST "whois.nic.mil" #define GNICHOST "whois.nic.gov" #define ANICHOST "whois.arin.net" *************** *** 259,280 **** /* * If no 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 (or VNICHOST ! * if name is a handle that starts with a '!'). */ static char * choose_server(const char *name, const char *country) { static char *server; const char *qhead; size_t len; if (country != NULL) qhead = country; ! else if ((qhead = strrchr(name, '.')) == NULL) ! return (*name == '!' ? VNICHOST : NICHOST); ! else if (isdigit(*(++qhead))) return (ANICHOST); len = strlen(qhead) + sizeof(QNICHOST_TAIL); if ((server = realloc(server, len)) == NULL) --- 260,290 ---- /* * If no 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 '.', check to see if it is an NSI handle ! * (starts with '!') or a CORE handle (COCO-[0-9]+ or COHO-[0-9]+). ! * Fall back to NICHOST for the non-handle case. */ static char * choose_server(const char *name, const char *country) { static char *server; const char *qhead; + char *ep; size_t len; if (country != NULL) qhead = country; ! else if ((qhead = strrchr(name, '.')) == NULL) { ! if (*name == '!') ! return (VNICHOST); ! else if ((strncasecmp(name, "COCO-", 5) == 0 || ! strncasecmp(name, "COHO-", 5) == 0) && ! strtol(name + 5, &ep, 10) > 0 && *ep == '\0') ! return (CNICHOST); ! else ! return (NICHOST); ! } else if (isdigit(*(++qhead))) return (ANICHOST); len = strlen(qhead) + sizeof(QNICHOST_TAIL); if ((server = realloc(server, len)) == NULL)