summaryrefslogtreecommitdiff
path: root/ares_gethostbyaddr.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-09-26 18:20:58 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-09-26 18:20:58 +0000
commit2bf866b0ce6084e28af061d68bbc351b3be55e84 (patch)
tree7e8ac4d57a5c5e6ad224ad2e764945a3bd5320b6 /ares_gethostbyaddr.c
parentdb2efff373dcffabfd1f94eb689127aee8a733f5 (diff)
downloadc-ares-2bf866b0ce6084e28af061d68bbc351b3be55e84.tar.gz
c-ares-2bf866b0ce6084e28af061d68bbc351b3be55e84.tar.bz2
c-ares-2bf866b0ce6084e28af061d68bbc351b3be55e84.zip
Dominick Meglio host file path discovery patch for windows
Diffstat (limited to 'ares_gethostbyaddr.c')
-rw-r--r--ares_gethostbyaddr.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/ares_gethostbyaddr.c b/ares_gethostbyaddr.c
index f44b3fb..978beba 100644
--- a/ares_gethostbyaddr.c
+++ b/ares_gethostbyaddr.c
@@ -150,12 +150,23 @@ static int file_lookup(struct in_addr *addr, struct hostent **host)
char PATH_HOSTS[MAX_PATH];
if (IsNT) {
- GetSystemDirectory(PATH_HOSTS, MAX_PATH);
- strcat(PATH_HOSTS, PATH_HOSTS_NT);
- } else {
+ 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);
- strcat(PATH_HOSTS, PATH_HOSTS_9X);
- }
+
+ strcat(PATH_HOSTS, WIN_PATH_HOSTS);
#elif defined(WATT32)
extern const char *_w32_GetHostsFile (void);