version 1.31, 2005/06/22 10:29:57 |
version 1.32, 2005/06/22 16:50:49 |
|
|
/* $OpenBSD$ */ |
/* $NetBSD: whois.c,v 1.27 2005/06/22 12:17:56 christos Exp $ */ |
|
|
/* |
/* |
* Copyright (c) 1980, 1993 |
* Copyright (c) 1980, 1993 |
|
|
whois(const char *query, const char *server, const char *port, int flags) |
whois(const char *query, const char *server, const char *port, int flags) |
{ |
{ |
FILE *sfi, *sfo; |
FILE *sfi, *sfo; |
char *buf, *p, *nhost, *nbuf = NULL, *nquery; |
char *buf, *p, *nhost, *nbuf = NULL; |
size_t len; |
size_t len; |
int i, s, error; |
int i, s, error; |
const char *reason = NULL; |
const char *reason = NULL, *fmt; |
struct addrinfo hints, *res, *ai; |
struct addrinfo hints, *res, *ai; |
|
|
memset(&hints, 0, sizeof(hints)); |
memset(&hints, 0, sizeof(hints)); |
|
|
return (1); |
return (1); |
} |
} |
|
|
if (!strcmp(server, "whois.denic.de") || |
if (strcmp(server, "whois.denic.de") == 0 || |
!strcmp(server, "de.whois-servers.net")) { |
strcmp(server, "de.whois-servers.net") == 0) |
if (asprintf(&nquery, "-T dn %s", query) == -1) |
fmt = "-T dn %s\r\n"; |
err(1, NULL); |
else |
} else { |
fmt = "%s\r\n"; |
if ((nquery = strdup(query)) == NULL) |
|
err(1, NULL); |
|
} |
|
|
|
sfi = fdopen(s, "r"); |
sfi = fdopen(s, "r"); |
sfo = fdopen(s, "w"); |
sfo = fdopen(s, "w"); |
if (sfi == NULL || sfo == NULL) |
if (sfi == NULL || sfo == NULL) |
err(1, "fdopen"); |
err(1, "fdopen"); |
(void)fprintf(sfo, "%s\r\n", nquery); |
(void)fprintf(sfo, fmt, query); |
(void)fflush(sfo); |
(void)fflush(sfo); |
nhost = NULL; |
nhost = NULL; |
while ((buf = fgetln(sfi, &len)) != NULL) { |
while ((buf = fgetln(sfi, &len)) != NULL) { |
|
|
} |
} |
} |
} |
} |
} |
free(nbuf); |
if (nbuf != NULL) |
free(nquery); |
free(nbuf); |
|
|
if (nhost != NULL) { |
if (nhost != NULL) { |
error = whois(query, nhost, port, 0); |
error = whois(query, nhost, port, 0); |