diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-01-19 23:10:16 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-01-19 23:10:16 +0000 |
commit | f8c14bbf1fb216d04b076627e2cc0c1d9afce722 (patch) | |
tree | e0ea4d6e1653570b835a9365bf9318173be3ada3 /src/common/compat.c | |
parent | 2c803bff9a62d4fbedd953b442d79e6f82d0ea0b (diff) | |
download | tor-f8c14bbf1fb216d04b076627e2cc0c1d9afce722.tar.gz tor-f8c14bbf1fb216d04b076627e2cc0c1d9afce722.zip |
Detect windows platform correctly
svn:r3377
Diffstat (limited to 'src/common/compat.c')
-rw-r--r-- | src/common/compat.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 69b82f8a41..6a2be5fc09 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -542,8 +542,53 @@ get_uname(void) } else #endif { +#ifdef MS_WINDOWS + OSVERSIONINFO info; + int i; + const char *plat = NULL; + static struct { + int major; int minor; const char *version; + } win_version_table[] = { + { 5, 2, "Windows Server 2003" }, + { 5, 1, "Windows XP" }, + { 5, 0, "Windows 2000" }, + /* { 4, 0, "Windows NT 4.0" }, */ + { 4, 90, "Windows Me" }, + { 4, 10, "Windows 98" }, + /* { 4, 0, "Windows 95" } */ + { 3, 51, "Windows NT 3.51" }, + { -1, -1, NULL } + }; + info.dwOSVersionInfoSize = sizeof(info); + GetVersionEx(&info); + if (info.dwMajorVersion == 4 && info.dwMinorVersion == 0) { + if (info.dwPlatformId == VER_PLATFORM_WIN32_NT) + plat = "Windows NT 4.0"; + else + plat = "Windows 95"; + } else { + for (i=0; win_version_table[i].major>=0; ++i) { + if (win_version_table[i].major == info.dwMajorVersion && + win_version_table[i].minor == info.dwMinorversion) { + plat = win_version_table[i].version; + break; + } + } + } + if (plat) { + strlcpy(uname_result, plat, sizeof(uname_result)); + } else { + if (info.dwMajorVersion > 5 || + (info.dwMajorVersion==5 && info.dwMinorVersion>2)) + tor_snprintf("Very recent version of Windows [major=%d,minor=%d]", + (int)info.dwMajorVersion,(int)info.dwMinorVersion); + else + tor_snprintf("Unrecognized version of Windows [major=%d,minor=%d]", + (int)info.dwMajorVersion,(int)info.dwMinorVersion); + } +#else strlcpy(uname_result, "Unknown platform", sizeof(uname_result)); -/* XXX win32 doesn't have uname, but we can still ifdef windows sprint "windows" */ +#endif } uname_result_is_set = 1; } |