Alien-cares
view release on metacpan or search on metacpan
libcares/ares_init.c view on Meta::CPAN
#endif
}
if (channel->nsort == -1) {
channel->sortlist = NULL;
channel->nsort = 0;
}
if (!channel->lookups) {
channel->lookups = ares_strdup("fb");
if (!channel->lookups)
rc = ARES_ENOMEM;
}
error:
if(rc) {
if(channel->servers) {
ares_free(channel->servers);
channel->servers = NULL;
}
if(channel->domains && channel->domains[0])
ares_free(channel->domains[0]);
if(channel->domains) {
ares_free(channel->domains);
channel->domains = NULL;
}
if(channel->lookups) {
ares_free(channel->lookups);
channel->lookups = NULL;
}
if(channel->resolvconf_path) {
ares_free(channel->resolvconf_path);
channel->resolvconf_path = NULL;
}
}
if(hostname)
ares_free(hostname);
return rc;
}
#if !defined(WIN32) && !defined(WATT32) && \
!defined(ANDROID) && !defined(__ANDROID__) && !defined(CARES_USE_LIBRESOLV)
static int config_domain(ares_channel channel, char *str)
{
char *q;
/* Set a single search domain. */
q = str;
while (*q && !ISSPACE(*q))
q++;
*q = '\0';
return set_search(channel, str);
}
#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 910) && \
defined(__OPTIMIZE__) && defined(__unix__) && defined(__i386__)
/* workaround icc 9.1 optimizer issue */
# define vqualifier volatile
#else
# define vqualifier
#endif
static int config_lookup(ares_channel channel, const char *str,
const char *bindch, const char *altbindch,
const char *filech)
{
char lookups[3], *l;
const char *vqualifier p;
if (altbindch == NULL)
altbindch = bindch;
/* Set the lookup order. Only the first letter of each work
* is relevant, and it has to be "b" for DNS or "f" for the
* host file. Ignore everything else.
*/
l = lookups;
p = str;
while (*p)
{
if ((*p == *bindch || *p == *altbindch || *p == *filech) && l < lookups + 2) {
if (*p == *bindch || *p == *altbindch) *l++ = 'b';
else *l++ = 'f';
}
while (*p && !ISSPACE(*p) && (*p != ','))
p++;
while (*p && (ISSPACE(*p) || (*p == ',')))
p++;
}
*l = '\0';
channel->lookups = ares_strdup(lookups);
return (channel->lookups) ? ARES_SUCCESS : ARES_ENOMEM;
}
#endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ & !CARES_USE_LIBRESOLV */
#ifndef WATT32
/* Validate that the ip address matches the subnet (network base and network
* mask) specified. Addresses are specified in standard Network Byte Order as
* 16 bytes, and the netmask is 0 to 128 (bits).
*/
static int ares_ipv6_subnet_matches(const unsigned char netbase[16],
unsigned char netmask,
const unsigned char ipaddr[16])
{
unsigned char mask[16] = { 0 };
unsigned char i;
/* Misuse */
if (netmask > 128)
return 0;
/* Quickly set whole bytes */
memset(mask, 0xFF, netmask / 8);
/* Set remaining bits */
if(netmask % 8) {
( run in 0.672 second using v1.01-cache-2.11-cpan-39bf76dae61 )