aboutsummaryrefslogtreecommitdiff
path: root/src/lib/osinfo/uname.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-02-06 17:02:43 -0500
committerNick Mathewson <nickm@torproject.org>2020-02-06 17:06:12 -0500
commit8a5a1600cdbe678bbd271b4bff29bbe8b70d6b05 (patch)
treea4afdc04806a6104a4bb28d8a23841685148623e /src/lib/osinfo/uname.c
parent5fa62fffee1972093798ed356884ef331dcd4ecc (diff)
downloadtor-8a5a1600cdbe678bbd271b4bff29bbe8b70d6b05.tar.gz
tor-8a5a1600cdbe678bbd271b4bff29bbe8b70d6b05.zip
Extract verbatim table in uname.c
Diffstat (limited to 'src/lib/osinfo/uname.c')
-rw-r--r--src/lib/osinfo/uname.c61
1 files changed, 34 insertions, 27 deletions
diff --git a/src/lib/osinfo/uname.c b/src/lib/osinfo/uname.c
index 66439d1336..800acdddb6 100644
--- a/src/lib/osinfo/uname.c
+++ b/src/lib/osinfo/uname.c
@@ -27,6 +27,40 @@ static char uname_result[256];
/** True iff uname_result is set. */
static int uname_result_is_set = 0;
+#ifdef _WIN32
+/** Table to map claimed windows versions into human-readable windows
+ * versions. */
+static struct {
+ unsigned major;
+ unsigned minor;
+ const char *client_version;
+ const char *server_version;
+} win_version_table[] = {
+ /* This table must be sorted in descending order.
+ * Sources:
+ * https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions
+ * https://docs.microsoft.com/en-us/windows/desktop/api/winnt/
+ * ns-winnt-_osversioninfoexa#remarks
+ */
+ /* Windows Server 2019 is indistinguishable from Windows Server 2016
+ * using GetVersionEx().
+ { 10, 0, NULL, "Windows Server 2019" }, */
+ // clang-format off
+ { 10, 0, "Windows 10", "Windows Server 2016" },
+ { 6, 3, "Windows 8.1", "Windows Server 2012 R2" },
+ { 6, 2, "Windows 8", "Windows Server 2012" },
+ { 6, 1, "Windows 7", "Windows Server 2008 R2" },
+ { 6, 0, "Windows Vista", "Windows Server 2008" },
+ { 5, 2, "Windows XP Professional", "Windows Server 2003" },
+ /* Windows XP did not have a server version, but we need something here */
+ { 5, 1, "Windows XP", "Windows XP Server" },
+ { 5, 0, "Windows 2000 Professional", "Windows 2000 Server" },
+ /* Earlier versions are not supported by GetVersionEx(). */
+ { 0, 0, NULL, NULL }
+ // clang-format on
+};
+#endif
+
/** Return a pointer to a description of our platform.
*/
MOCK_IMPL(const char *,
@@ -49,33 +83,6 @@ get_uname,(void))
int is_client = 0;
int is_server = 0;
const char *plat = NULL;
- static struct {
- unsigned major; unsigned minor;
- const char *client_version; const char *server_version;
- } win_version_table[] = {
- /* This table must be sorted in descending order.
- * Sources:
- * https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions
- * https://docs.microsoft.com/en-us/windows/desktop/api/winnt/
- * ns-winnt-_osversioninfoexa#remarks
- */
- /* Windows Server 2019 is indistinguishable from Windows Server 2016
- * using GetVersionEx().
-// clang-format off
- { 10, 0, NULL, "Windows Server 2019" }, */
- { 10, 0, "Windows 10", "Windows Server 2016" },
- { 6, 3, "Windows 8.1", "Windows Server 2012 R2" },
- { 6, 2, "Windows 8", "Windows Server 2012" },
- { 6, 1, "Windows 7", "Windows Server 2008 R2" },
- { 6, 0, "Windows Vista", "Windows Server 2008" },
- { 5, 2, "Windows XP Professional", "Windows Server 2003" },
- /* Windows XP did not have a server version, but we need something here */
- { 5, 1, "Windows XP", "Windows XP Server" },
- { 5, 0, "Windows 2000 Professional", "Windows 2000 Server" },
- /* Earlier versions are not supported by GetVersionEx(). */
- { 0, 0, NULL, NULL }
-// clang-format on
- };
memset(&info, 0, sizeof(info));
info.dwOSVersionInfoSize = sizeof(info);
if (! GetVersionEx((LPOSVERSIONINFO)&info)) {