Alien-cares
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
libcares/ares_getaddrinfo.c view on Meta::CPAN
else
{
port = lookup_service(service, 0);
if (!port)
{
port = (unsigned short)strtoul(service, NULL, 0);
if (!port)
{
callback(arg, ARES_ESERVICE, 0, NULL);
return;
}
}
}
}
if (fake_addrinfo(name, port, hints, callback, arg))
return;
/* Allocate and fill in the host query structure. */
hquery = ares_malloc(sizeof(struct host_query));
if (!hquery)
{
callback(arg, ARES_ENOMEM, 0, NULL);
return;
}
hquery->name = ares_strdup(name);
if (!hquery->name)
{
ares_free(hquery);
callback(arg, ARES_ENOMEM, 0, NULL);
return;
}
hquery->port = port;
hquery->channel = channel;
hquery->hints = *hints;
hquery->sent_family = -1; /* nothing is sent yet */
hquery->callback = callback;
hquery->arg = arg;
hquery->remaining_lookups = channel->lookups;
hquery->timeouts = 0;
hquery->ai = NULL;
hquery->cname = NULL;
/* Start performing lookups according to channel->lookups. */
next_lookup(hquery, ARES_ECONNREFUSED /* initial error code */);
}
static void next_lookup(struct host_query *hquery, int status_code)
{
const char *p;
int status = status_code;
for (p = hquery->remaining_lookups; *p; p++)
{
switch (*p)
{
case 'b':
/* DNS lookup */
hquery->remaining_lookups = p + 1;
if ((hquery->hints.ai_family == AF_INET6) ||
(hquery->hints.ai_family == AF_UNSPEC)) {
/* if inet6 or unspec, start out with AAAA */
hquery->sent_family = AF_INET6;
ares_search(hquery->channel, hquery->name, C_IN, T_AAAA,
host_callback, hquery);
}
else {
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A,
host_callback, hquery);
}
return;
case 'f':
/* Host file lookup */
status = file_lookup(hquery);
/* this status check below previously checked for !ARES_ENOTFOUND,
but we should not assume that this single error code is the one
that can occur, as that is in fact no longer the case */
if (status == ARES_SUCCESS)
{
end_hquery(hquery, status);
return;
}
status = status_code; /* Use original status code */
break;
}
}
end_hquery(hquery, status);
}
static int file_lookup(struct host_query *hquery)
{
FILE *fp;
int error;
int status;
#ifdef WIN32
char PATH_HOSTS[MAX_PATH];
win_platform platform;
PATH_HOSTS[0] = '\0';
platform = ares__getplatform();
if (platform == WIN_NT) {
char tmp[MAX_PATH];
HKEY hkeyHosts;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ,
&hkeyHosts) == ERROR_SUCCESS)
{
DWORD dwLength = MAX_PATH;
RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp,
&dwLength);
ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH);
RegCloseKey(hkeyHosts);
}
}
else if (platform == WIN_9X)
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.288 second using v1.00-cache-2.02-grep-82fe00e-cpan-b63e86051f13 )