diff options
author | Marco d'Itri <md@linux.it> | 2014-09-13 01:21:18 +0200 |
---|---|---|
committer | Marco d'Itri <md@linux.it> | 2014-09-13 02:42:29 +0200 |
commit | c7769cbfdf68a122d5d4ebf587d1273bda060b57 (patch) | |
tree | b2e96a97b4eabdc3f8f3cc6924359834efcd5908 /whois.c | |
parent | 512005132456507e1360d2d24478e75c4d2e6e9f (diff) | |
download | whois-c7769cbfdf68a122d5d4ebf587d1273bda060b57.tar.gz |
make is_new_gtld() return the TLD
Diffstat (limited to 'whois.c')
-rw-r--r-- | whois.c | 19 |
1 files changed, 6 insertions, 13 deletions
@@ -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; } |