From 6ddc59dadf33bcbe667a750ba72e867f463eb8ed Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Wed, 10 Nov 2004 14:23:20 +0000 Subject: Replace IsNT with IS_NT(). Return correct timeval in windows_port.c. Squelch gcc warnings: use 'ares_socket_t' in ares_fds.c. Don't cast a 'lvalue' in ares_init.c. --- ares/ares_gethostbyaddr.c | 80 +++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'ares/ares_gethostbyaddr.c') diff --git a/ares/ares_gethostbyaddr.c b/ares/ares_gethostbyaddr.c index 827ccfeda..46144fc8b 100644 --- a/ares/ares_gethostbyaddr.c +++ b/ares/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) @@ -149,19 +149,19 @@ static int file_lookup(struct in_addr *addr, struct hostent **host) #ifdef WIN32 char PATH_HOSTS[MAX_PATH]; - if (IsNT) { - 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); - } + 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); + } } 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); -- cgit v1.2.3