diff options
author | Daniel Stenberg <daniel@haxx.se> | 2004-12-10 21:46:00 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2004-12-10 21:46:00 +0000 |
commit | 994f16d733b6000c2b14acb07aa01721a7be5928 (patch) | |
tree | 4dc176508250098fd8fd8b33878dc9bed791fd8a /ares_gethostbyaddr.c | |
parent | 93538d6a9dab4856b57cf660fa275a26567e967f (diff) | |
download | c-ares-994f16d733b6000c2b14acb07aa01721a7be5928.tar.gz c-ares-994f16d733b6000c2b14acb07aa01721a7be5928.tar.bz2 c-ares-994f16d733b6000c2b14acb07aa01721a7be5928.zip |
untabified
Diffstat (limited to 'ares_gethostbyaddr.c')
-rw-r--r-- | ares_gethostbyaddr.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/ares_gethostbyaddr.c b/ares_gethostbyaddr.c index 46144fc..b33086c 100644 --- a/ares_gethostbyaddr.c +++ b/ares_gethostbyaddr.c @@ -48,13 +48,13 @@ struct addr_query { static void next_lookup(struct addr_query *aquery); static void addr_callback(void *arg, int status, unsigned char *abuf, - int alen); + int alen); static void end_aquery(struct addr_query *aquery, int status, - struct hostent *host); + struct hostent *host); static int file_lookup(struct in_addr *addr, struct hostent **host); void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen, - int family, ares_host_callback callback, void *arg) + int family, ares_host_callback callback, void *arg) { struct addr_query *aquery; @@ -90,27 +90,27 @@ static void next_lookup(struct addr_query *aquery) for (p = aquery->remaining_lookups; *p; p++) { switch (*p) - { - case 'b': - addr = ntohl(aquery->addr.s_addr); - a1 = (int)((addr >> 24) & 0xff); - a2 = (int)((addr >> 16) & 0xff); - a3 = (int)((addr >> 8) & 0xff); - a4 = (int)(addr & 0xff); - sprintf(name, "%d.%d.%d.%d.in-addr.arpa", a4, a3, a2, a1); - aquery->remaining_lookups = p + 1; - ares_query(aquery->channel, name, C_IN, T_PTR, addr_callback, - aquery); - return; - case 'f': - status = file_lookup(&aquery->addr, &host); - if (status != ARES_ENOTFOUND) - { - end_aquery(aquery, status, host); - return; - } - break; - } + { + case 'b': + addr = ntohl(aquery->addr.s_addr); + a1 = (int)((addr >> 24) & 0xff); + a2 = (int)((addr >> 16) & 0xff); + a3 = (int)((addr >> 8) & 0xff); + a4 = (int)(addr & 0xff); + sprintf(name, "%d.%d.%d.%d.in-addr.arpa", a4, a3, a2, a1); + aquery->remaining_lookups = p + 1; + ares_query(aquery->channel, name, C_IN, T_PTR, addr_callback, + aquery); + return; + case 'f': + status = file_lookup(&aquery->addr, &host); + if (status != ARES_ENOTFOUND) + { + end_aquery(aquery, status, host); + return; + } + break; + } } end_aquery(aquery, ARES_ENOTFOUND, NULL); } @@ -123,7 +123,7 @@ static void addr_callback(void *arg, int status, unsigned char *abuf, int alen) if (status == ARES_SUCCESS) { status = ares_parse_ptr_reply(abuf, alen, &aquery->addr, - sizeof(struct in_addr), AF_INET, &host); + sizeof(struct in_addr), AF_INET, &host); end_aquery(aquery, status, host); } else if (status == ARES_EDESTRUCTION) @@ -133,7 +133,7 @@ static void addr_callback(void *arg, int status, unsigned char *abuf, int alen) } static void end_aquery(struct addr_query *aquery, int status, - struct hostent *host) + struct hostent *host) { aquery->callback(aquery->arg, status, host); if (host) @@ -150,18 +150,18 @@ static int file_lookup(struct in_addr *addr, struct hostent **host) char PATH_HOSTS[MAX_PATH]; if (IS_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, tmp, - &dwLength); - ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH); - RegCloseKey(hkeyHosts); - } + 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, tmp, + &dwLength); + ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH); + RegCloseKey(hkeyHosts); + } } else GetWindowsDirectory(PATH_HOSTS, MAX_PATH); @@ -183,7 +183,7 @@ static int file_lookup(struct in_addr *addr, struct hostent **host) while ((status = ares__get_hostent(fp, host)) == ARES_SUCCESS) { if (memcmp((*host)->h_addr, addr, sizeof(struct in_addr)) == 0) - break; + break; ares_free_hostent(*host); } fclose(fp); |