[tor-commits] [tor/master] Extract verbatim table in uname.c

nickm at torproject.org nickm at torproject.org
Thu Mar 5 13:25:48 UTC 2020


commit 8a5a1600cdbe678bbd271b4bff29bbe8b70d6b05
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Feb 6 17:02:43 2020 -0500

    Extract verbatim table in uname.c
---
 src/lib/osinfo/uname.c | 61 ++++++++++++++++++++++++++++----------------------
 1 file changed, 34 insertions(+), 27 deletions(-)

diff --git a/src/lib/osinfo/uname.c b/src/lib/osinfo/uname.c
index 66439d133..800acdddb 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)) {





More information about the tor-commits mailing list