mirror of
https://github.com/rfc1036/whois.git
synced 2026-07-02 07:12:28 +00:00
make is_new_gtld() return the TLD
This commit is contained in:
parent
5120051324
commit
c7769cbfdf
19
whois.c
19
whois.c
@ -392,7 +392,7 @@ char *guess_server(const char *s)
|
||||
{
|
||||
unsigned long ip, as32;
|
||||
unsigned int i;
|
||||
const char *colon;
|
||||
const char *colon, *tld;
|
||||
|
||||
/* IPv6 address */
|
||||
if ((colon = strchr(s, ':'))) {
|
||||
@ -460,16 +460,9 @@ char *guess_server(const char *s)
|
||||
return strdup(tld_serv[i + 1]);
|
||||
|
||||
/* use the default server name for "new" gTLDs */
|
||||
if (is_new_gtld(s)) {
|
||||
char *server;
|
||||
const char *p, *tld = NULL;
|
||||
|
||||
for (p = s; *p; p++) /* look for the TLD */
|
||||
if (*p == '.')
|
||||
tld = p;
|
||||
|
||||
server = malloc(strlen("whois.nic") + strlen(tld) + 1);
|
||||
strcpy(server, "whois.nic");
|
||||
if ((tld = is_new_gtld(s))) {
|
||||
char *server = malloc(strlen("whois.nic.") + strlen(tld) + 1);
|
||||
strcpy(server, "whois.nic.");
|
||||
strcat(server, tld);
|
||||
return(server);
|
||||
}
|
||||
@ -983,13 +976,13 @@ int domcmp(const char *dom, const char *tld)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_new_gtld(const char *s)
|
||||
const char *is_new_gtld(const char *s)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; new_gtlds[i]; i++)
|
||||
if (domcmp(s, new_gtlds[i]))
|
||||
return 1;
|
||||
return new_gtlds[i] + 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
2
whois.h
2
whois.h
@ -29,7 +29,7 @@ unsigned long myinet_aton(const char *);
|
||||
unsigned long asn32_to_long(const char *);
|
||||
int isasciidigit(const char);
|
||||
int domcmp(const char *, const char *);
|
||||
int is_new_gtld(const char *);
|
||||
const char *is_new_gtld(const char *);
|
||||
int domfind(const char *, const char *[]);
|
||||
char *normalize_domain(const char *);
|
||||
char *convert_6to4(const char *);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user