build: find out windows platform using GetVersionEx()
This commit is contained in:
parent
822fd0f877
commit
bd066ab8ef
|
@ -186,7 +186,13 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
|
|||
|
||||
#ifdef WIN32
|
||||
char PATH_HOSTS[MAX_PATH];
|
||||
if (IS_NT()) {
|
||||
win_platform platform;
|
||||
|
||||
PATH_HOSTS[0] = '\0';
|
||||
|
||||
platform = getplatform();
|
||||
|
||||
if (platform == WIN_NT) {
|
||||
char tmp[MAX_PATH];
|
||||
HKEY hkeyHosts;
|
||||
|
||||
|
@ -200,8 +206,10 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
|
|||
RegCloseKey(hkeyHosts);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (platform == WIN_9X)
|
||||
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
|
||||
else
|
||||
return ARES_ENOTFOUND;
|
||||
|
||||
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
|
||||
|
||||
|
|
|
@ -344,7 +344,13 @@ static int file_lookup(const char *name, int family, struct hostent **host)
|
|||
|
||||
#ifdef WIN32
|
||||
char PATH_HOSTS[MAX_PATH];
|
||||
if (IS_NT()) {
|
||||
win_platform platform;
|
||||
|
||||
PATH_HOSTS[0] = '\0';
|
||||
|
||||
platform = getplatform();
|
||||
|
||||
if (platform == WIN_NT) {
|
||||
char tmp[MAX_PATH];
|
||||
HKEY hkeyHosts;
|
||||
|
||||
|
@ -358,8 +364,10 @@ static int file_lookup(const char *name, int family, struct hostent **host)
|
|||
RegCloseKey(hkeyHosts);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (platform == WIN_9X)
|
||||
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
|
||||
else
|
||||
return ARES_ENOTFOUND;
|
||||
|
||||
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
|
||||
|
||||
|
|
|
@ -704,6 +704,7 @@ DhcpNameServer
|
|||
DWORD bytes;
|
||||
DWORD result;
|
||||
char buf[256];
|
||||
win_platform platform;
|
||||
|
||||
if (channel->nservers > -1) /* don't override ARES_OPT_SERVER */
|
||||
return ARES_SUCCESS;
|
||||
|
@ -715,7 +716,9 @@ DhcpNameServer
|
|||
goto okay;
|
||||
}
|
||||
|
||||
if (IS_NT())
|
||||
platform = getplatform();
|
||||
|
||||
if (platform == WIN_NT)
|
||||
{
|
||||
if (RegOpenKeyEx(
|
||||
HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,
|
||||
|
@ -749,7 +752,7 @@ DhcpNameServer
|
|||
RegCloseKey(mykey);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (platform == WIN_9X)
|
||||
{
|
||||
if (RegOpenKeyEx(
|
||||
HKEY_LOCAL_MACHINE, WIN_NS_9X, 0,
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
|
||||
#if defined(WIN32) && !defined(WATT32)
|
||||
|
||||
#define IS_NT() ((int)GetVersion() > 0)
|
||||
#define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP"
|
||||
#define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters"
|
||||
#define NAMESERVER "NameServer"
|
||||
|
@ -345,6 +344,20 @@ long ares__tvdiff(struct timeval t1, struct timeval t2);
|
|||
(c)->sock_state_cb((c)->sock_state_cb_data, (s), (r), (w)); \
|
||||
} while (0)
|
||||
|
||||
#if (defined(WIN32) || defined(WATT32)) && !defined(MSDOS)
|
||||
|
||||
typedef enum {
|
||||
WIN_UNKNOWN,
|
||||
WIN_3X,
|
||||
WIN_9X,
|
||||
WIN_NT,
|
||||
WIN_CE
|
||||
} win_platform;
|
||||
|
||||
win_platform getplatform(void);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CURLDEBUG
|
||||
/* This is low-level hard-hacking memory leak tracking and similar. Using the
|
||||
libcurl lowlevel code from within library is ugly and only works when
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "ares_setup.h"
|
||||
|
||||
#include "ares_private.h"
|
||||
|
||||
/* only do the following on windows
|
||||
*/
|
||||
|
@ -19,4 +20,42 @@ WINAPI DllMain (HINSTANCE hnd, DWORD reason, LPVOID reserved)
|
|||
}
|
||||
#endif
|
||||
|
||||
#define V_PLATFORM_WIN32s 0
|
||||
#define V_PLATFORM_WIN32_WINDOWS 1
|
||||
#define V_PLATFORM_WIN32_NT 2
|
||||
#define V_PLATFORM_WIN32_CE 3
|
||||
|
||||
win_platform getplatform(void)
|
||||
{
|
||||
OSVERSIONINFOEX OsvEx;
|
||||
|
||||
memset(&OsvEx, 0, sizeof(OsvEx));
|
||||
OsvEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
if (!GetVersionEx((void *)&OsvEx))
|
||||
{
|
||||
memset(&OsvEx, 0, sizeof(OsvEx));
|
||||
OsvEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if (!GetVersionEx((void *)&OsvEx))
|
||||
return WIN_UNKNOWN;
|
||||
}
|
||||
|
||||
switch(OsvEx.dwPlatformId)
|
||||
{
|
||||
case V_PLATFORM_WIN32s:
|
||||
return WIN_3X;
|
||||
|
||||
case V_PLATFORM_WIN32_WINDOWS:
|
||||
return WIN_9X;
|
||||
|
||||
case V_PLATFORM_WIN32_NT:
|
||||
return WIN_NT;
|
||||
|
||||
case V_PLATFORM_WIN32_CE:
|
||||
return WIN_CE;
|
||||
|
||||
default:
|
||||
return WIN_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* WIN32 builds only */
|
||||
|
|
Loading…
Reference in New Issue