mirror of
https://frontier.innolan.net/rainlance/c-ares.git
synced 2025-10-05 14:59:30 +00:00
style: make code less than 80 columns wide
This commit is contained in:
@ -190,8 +190,8 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
|
||||
char tmp[MAX_PATH];
|
||||
HKEY hkeyHosts;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts)
|
||||
== ERROR_SUCCESS)
|
||||
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,
|
||||
@ -240,12 +240,14 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
|
||||
}
|
||||
if (addr->family == AF_INET)
|
||||
{
|
||||
if (memcmp((*host)->h_addr, &addr->addrV4, sizeof(addr->addrV4)) == 0)
|
||||
if (memcmp((*host)->h_addr, &addr->addrV4,
|
||||
sizeof(addr->addrV4)) == 0)
|
||||
break;
|
||||
}
|
||||
else if (addr->family == AF_INET6)
|
||||
{
|
||||
if (memcmp((*host)->h_addr, &addr->addrV6, sizeof(addr->addrV6)) == 0)
|
||||
if (memcmp((*host)->h_addr, &addr->addrV6,
|
||||
sizeof(addr->addrV6)) == 0)
|
||||
break;
|
||||
}
|
||||
ares_free_hostent(*host);
|
||||
|
@ -150,8 +150,8 @@ static void next_lookup(struct host_query *hquery, int status_code)
|
||||
}
|
||||
else {
|
||||
hquery->sent_family = AF_INET;
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
|
||||
hquery);
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_A,
|
||||
host_callback, hquery);
|
||||
}
|
||||
return;
|
||||
|
||||
@ -194,9 +194,10 @@ static void host_callback(void *arg, int status, int timeouts,
|
||||
{
|
||||
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
|
||||
if (status == ARES_ENODATA || status == ARES_EBADRESP) {
|
||||
/* The query returned something but either there were no AAAA records (e.g. just CNAME)
|
||||
or the response was malformed. Try looking up A instead.
|
||||
We should possibly limit this attempt-next logic to AF_UNSPEC lookups only. */
|
||||
/* The query returned something but either there were no AAAA
|
||||
records (e.g. just CNAME) or the response was malformed. Try
|
||||
looking up A instead. We should possibly limit this
|
||||
attempt-next logic to AF_UNSPEC lookups only. */
|
||||
hquery->sent_family = AF_INET;
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_A,
|
||||
host_callback, hquery);
|
||||
@ -207,10 +208,12 @@ static void host_callback(void *arg, int status, int timeouts,
|
||||
}
|
||||
end_hquery(hquery, status, host);
|
||||
}
|
||||
else if ((status == ARES_ENODATA || status == ARES_EBADRESP || status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
|
||||
else if ((status == ARES_ENODATA || status == ARES_EBADRESP ||
|
||||
status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
|
||||
{
|
||||
/* The AAAA query yielded no useful result. Now look up an A instead.
|
||||
We should possibly limit this attempt-next logic to AF_UNSPEC lookups only. */
|
||||
/* The AAAA query yielded no useful result. Now look up an A instead.
|
||||
We should possibly limit this attempt-next logic to AF_UNSPEC lookups
|
||||
only. */
|
||||
hquery->sent_family = AF_INET;
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
|
||||
hquery);
|
||||
@ -234,8 +237,8 @@ static void end_hquery(struct host_query *hquery, int status,
|
||||
/* If the name looks like an IP address, fake up a host entry, end the
|
||||
* query immediately, and return true. Otherwise return false.
|
||||
*/
|
||||
static int fake_hostent(const char *name, int family, ares_host_callback callback,
|
||||
void *arg)
|
||||
static int fake_hostent(const char *name, int family,
|
||||
ares_host_callback callback, void *arg)
|
||||
{
|
||||
struct hostent hostent;
|
||||
char *aliases[1] = { NULL };
|
||||
@ -345,8 +348,8 @@ static int file_lookup(const char *name, int family, struct hostent **host)
|
||||
char tmp[MAX_PATH];
|
||||
HKEY hkeyHosts;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts)
|
||||
== ERROR_SUCCESS)
|
||||
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,
|
||||
@ -407,8 +410,8 @@ static int file_lookup(const char *name, int family, struct hostent **host)
|
||||
return status;
|
||||
}
|
||||
|
||||
static void sort_addresses(struct hostent *host, const struct apattern *sortlist,
|
||||
int nsort)
|
||||
static void sort_addresses(struct hostent *host,
|
||||
const struct apattern *sortlist, int nsort)
|
||||
{
|
||||
struct in_addr a1, a2;
|
||||
int i1, i2, ind1, ind2;
|
||||
@ -463,8 +466,8 @@ static int get_address_index(const struct in_addr *addr,
|
||||
return i;
|
||||
}
|
||||
|
||||
static void sort6_addresses(struct hostent *host, const struct apattern *sortlist,
|
||||
int nsort)
|
||||
static void sort6_addresses(struct hostent *host,
|
||||
const struct apattern *sortlist, int nsort)
|
||||
{
|
||||
struct ares_in6_addr a1, a2;
|
||||
int i1, i2, ind1, ind2;
|
||||
|
@ -80,7 +80,8 @@ struct nameinfo_query {
|
||||
(sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"))
|
||||
#endif
|
||||
|
||||
static void nameinfo_callback(void *arg, int status, int timeouts, struct hostent *host);
|
||||
static void nameinfo_callback(void *arg, int status, int timeouts,
|
||||
struct hostent *host);
|
||||
static char *lookup_service(unsigned short port, int flags,
|
||||
char *buf, size_t buflen);
|
||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||
@ -201,7 +202,8 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
||||
}
|
||||
}
|
||||
|
||||
static void nameinfo_callback(void *arg, int status, int timeouts, struct hostent *host)
|
||||
static void nameinfo_callback(void *arg, int status, int timeouts,
|
||||
struct hostent *host)
|
||||
{
|
||||
struct nameinfo_query *niquery = (struct nameinfo_query *) arg;
|
||||
char srvbuf[33];
|
||||
@ -220,8 +222,8 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
|
||||
service = lookup_service(niquery->addr.addr6.sin6_port,
|
||||
niquery->flags, srvbuf, sizeof(srvbuf));
|
||||
}
|
||||
/* NOFQDN means we have to strip off the domain name portion.
|
||||
We do this by determining our own domain name, then searching the string
|
||||
/* NOFQDN means we have to strip off the domain name portion. We do
|
||||
this by determining our own domain name, then searching the string
|
||||
for this domain name and removing it.
|
||||
*/
|
||||
#ifdef HAVE_GETHOSTNAME
|
||||
@ -238,7 +240,8 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
|
||||
}
|
||||
}
|
||||
#endif
|
||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, (char *)(host->h_name),
|
||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts,
|
||||
(char *)(host->h_name),
|
||||
service);
|
||||
return;
|
||||
}
|
||||
@ -247,12 +250,15 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
|
||||
{
|
||||
char ipbuf[IPBUFSIZ];
|
||||
if (niquery->family == AF_INET)
|
||||
ares_inet_ntop(AF_INET, &niquery->addr.addr4.sin_addr, ipbuf, IPBUFSIZ);
|
||||
ares_inet_ntop(AF_INET, &niquery->addr.addr4.sin_addr, ipbuf,
|
||||
IPBUFSIZ);
|
||||
else
|
||||
{
|
||||
ares_inet_ntop(AF_INET6, &niquery->addr.addr6.sin6_addr, ipbuf, IPBUFSIZ);
|
||||
ares_inet_ntop(AF_INET6, &niquery->addr.addr6.sin6_addr, ipbuf,
|
||||
IPBUFSIZ);
|
||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||
append_scopeid(&niquery->addr.addr6, niquery->flags, ipbuf, sizeof(ipbuf));
|
||||
append_scopeid(&niquery->addr.addr6, niquery->flags, ipbuf,
|
||||
sizeof(ipbuf));
|
||||
#endif
|
||||
}
|
||||
/* They want a service too */
|
||||
@ -265,7 +271,8 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
|
||||
service = lookup_service(niquery->addr.addr6.sin6_port,
|
||||
niquery->flags, srvbuf, sizeof(srvbuf));
|
||||
}
|
||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, ipbuf, service);
|
||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, ipbuf,
|
||||
service);
|
||||
return;
|
||||
}
|
||||
niquery->callback(niquery->arg, status, niquery->timeouts, NULL, NULL);
|
||||
@ -300,10 +307,12 @@ static char *lookup_service(unsigned short port, int flags,
|
||||
sep = &se;
|
||||
memset(tmpbuf, 0, sizeof(tmpbuf));
|
||||
#if GETSERVBYPORT_R_ARGS == 6
|
||||
if (getservbyport_r(port, proto, &se, (void *)tmpbuf, sizeof(tmpbuf), &sep) != 0)
|
||||
if (getservbyport_r(port, proto, &se, (void *)tmpbuf,
|
||||
sizeof(tmpbuf), &sep) != 0)
|
||||
sep = NULL;
|
||||
#elif GETSERVBYPORT_R_ARGS == 5
|
||||
sep = getservbyport_r(port, proto, &se, (void *)tmpbuf, sizeof(tmpbuf));
|
||||
sep = getservbyport_r(port, proto, &se, (void *)tmpbuf,
|
||||
sizeof(tmpbuf));
|
||||
#elif GETSERVBYPORT_R_ARGS == 4
|
||||
if (getservbyport_r(port, proto, &se, (void *)tmpbuf) != 0)
|
||||
sep = NULL;
|
||||
@ -349,7 +358,8 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags,
|
||||
char fmt_lu[] = "%lu";
|
||||
char tmpbuf[IF_NAMESIZE + 2];
|
||||
size_t bufl;
|
||||
char *fmt = (sizeof(addr6->sin6_scope_id) > sizeof(unsigned int))?fmt_lu:fmt_u;
|
||||
char *fmt = (sizeof(addr6->sin6_scope_id) > sizeof(unsigned int))?
|
||||
fmt_lu:fmt_u;
|
||||
|
||||
tmpbuf[0] = '%';
|
||||
|
||||
|
Reference in New Issue
Block a user