iscsi also has a system port (860) registered in addition to the more common
[obnox/wireshark/wip.git] / version_info.c
index e37cfbe75f35ae64dd09afea46ba3ffd2d36a50d..77d961261a7c42d05f4d16e21d068c0be0838fab 100644 (file)
 # include "config.h"
 #endif
 
+#ifdef HAVE_PYTHON
+#include <Python.h> /* to get the Python version number (PY_VERSION) */
+#endif
+
 #include <glib.h>
 
 #include <stdlib.h>
 #include <pcre.h>      /* to get the libpcre version number */
 #endif /* HAVE_LIBPCRE */
 
-#if (defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBGNUTLS)) && defined(_WIN32)
-#include <winposixtype.h>
-#endif
-
 #ifdef HAVE_LIBGCRYPT
 #include <gcrypt.h>
 #endif /* HAVE_LIBGCRYPT */
@@ -92,7 +92,7 @@
 #endif
 
 #ifdef SVNVERSION
-       const char *wireshark_svnversion = " (" SVNVERSION ")";
+       const char *wireshark_svnversion = " (" SVNVERSION " from " SVNPATH ")";
 #else
        const char *wireshark_svnversion = "";
 #endif
@@ -139,6 +139,11 @@ end_string(GString *str)
 void
 get_compiled_version_info(GString *str, void (*additional_info)(GString *))
 {
+       if (sizeof(str) == 4)
+               g_string_append(str, "(32-bit) ");
+       else
+               g_string_append(str, "(64-bit) ");
+
         /* GLIB */
        g_string_append(str, "with ");
        g_string_append_printf(str,
@@ -182,7 +187,7 @@ get_compiled_version_info(GString *str, void (*additional_info)(GString *))
                (*additional_info)(str);
        g_string_append(str, ".");
 
-#ifndef HAVE_LIBPCRE
+#if !defined(HAVE_LIBPCRE) && !GLIB_CHECK_VERSION(2,14,0)
        g_string_append(str,
        "\nNOTE: this build doesn't support the \"matches\" operator for Wireshark filter syntax");
        g_string_append(str, ".");
@@ -248,6 +253,16 @@ get_epan_compiled_version_info(GString *str)
        g_string_append(str, "without Lua");
 #endif /* HAVE_LUA_5_1 */
 
+       g_string_append(str, ", ");
+#ifdef HAVE_PYTHON
+       g_string_append(str, "with Python");
+#ifdef PY_VERSION
+       g_string_append(str, " " PY_VERSION);
+#endif /* PY_VERSION */
+#else
+       g_string_append(str, "without Python");
+#endif /* HAVE_PYTHON */
+
         /* GnuTLS */
        g_string_append(str, ", ");
 #ifdef HAVE_LIBGNUTLS
@@ -297,11 +312,12 @@ get_runtime_version_info(GString *str, void (*additional_info)(GString *))
 {
 #if defined(_WIN32)
        OSVERSIONINFOEX info;
+       SYSTEM_INFO system_info;
 #elif defined(HAVE_SYS_UTSNAME_H)
        struct utsname name;
 #endif
 #if HAVE_OS_X_FRAMEWORKS
-       long macosx_ver, macosx_major_ver, macosx_minor_ver, macosx_bugfix_ver;
+       SInt32 macosx_ver, macosx_major_ver, macosx_minor_ver, macosx_bugfix_ver;
 #endif
 
        g_string_append(str, "on ");
@@ -324,6 +340,8 @@ get_runtime_version_info(GString *str, void (*additional_info)(GString *))
         * not even be able to compile code that *uses* that structure with
         * older versions of the SDK.
         */
+
+       memset(&info, '\0', sizeof info);
        info.dwOSVersionInfoSize = sizeof info;
        if (!GetVersionEx((OSVERSIONINFO *)&info)) {
                /*
@@ -332,6 +350,10 @@ get_runtime_version_info(GString *str, void (*additional_info)(GString *))
                g_string_append(str, "unknown Windows version");
                return;
        }
+
+       memset(&system_info, '\0', sizeof system_info);
+       GetSystemInfo(&system_info);    /* only for W2K or greater .... (which is what we support) */
+
        switch (info.dwPlatformId) {
 
        case VER_PLATFORM_WIN32s:
@@ -396,28 +418,55 @@ get_runtime_version_info(GString *str, void (*additional_info)(GString *))
                                break;
 
                        case 2:
-                               g_string_append_printf(str, "Windows Server 2003");
+                               if ((info.wProductType == VER_NT_WORKSTATION) &&
+                                   (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)) {
+                                       g_string_append_printf(str, "Windows XP Professional x64 Edition");
+                               } else {
+                                       g_string_append_printf(str, "Windows Server 2003");
+                                       if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
+                                               g_string_append_printf(str, " x64 Edition");
+                               }
                                break;
 
                        default:
                                g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
-                                   info.dwMajorVersion, info.dwMinorVersion);
+                                                      info.dwMajorVersion, info.dwMinorVersion);
                                break;
                        }
                        break;
 
-               case 6:
-                       if (info.wProductType == VER_NT_WORKSTATION)
-                               g_string_append_printf(str, "Windows Vista");
-                       else
-                               g_string_append_printf(str, "Windows Server 2008");
-                       break;
+               case 6: {
+                       gboolean is_nt_workstation;
 
+                       if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
+                               g_string_append(str, "64-bit ");
+                       else if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
+                               g_string_append(str, "32-bit ");
+#ifndef VER_NT_WORKSTATION
+#define VER_NT_WORKSTATION 0x01
+                       is_nt_workstation = ((info.wReserved[1] & 0xff) == VER_NT_WORKSTATION);
+#else
+                       is_nt_workstation = (info.wProductType == VER_NT_WORKSTATION);
+#endif
+                       switch (info.dwMinorVersion) {
+                       case 0:
+                               g_string_append_printf(str, is_nt_workstation ? "Windows Vista" : "Windows Server 2008");
+                               break;
+                       case 1:
+                               g_string_append_printf(str, is_nt_workstation ? "Windows 7" : "Windows Server 2008 R2");
+                               break;
+                       default:
+                               g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
+                                                      info.dwMajorVersion, info.dwMinorVersion);
+                               break;
+                       }
+                       break;
+               }  /* case 6 */
                default:
                        g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
                            info.dwMajorVersion, info.dwMinorVersion);
                        break;
-               }
+               } /* info.dwMajorVersion */
                break;
 
        default:
@@ -468,12 +517,12 @@ get_runtime_version_info(GString *str, void (*additional_info)(GString *))
                        Gestalt(gestaltSystemVersionBugFix, &macosx_bugfix_ver);
 
                        g_string_append_printf(str, " (MacOS %ld.%ld.%ld)",
-                                         macosx_major_ver,
-                                         macosx_minor_ver,
-                                         macosx_bugfix_ver);
+                                         (long)macosx_major_ver,
+                                         (long)macosx_minor_ver,
+                                         (long)macosx_bugfix_ver);
                } else {
                        g_string_append_printf(str, " (MacOS X < 10.4 [%lx])",
-                                         macosx_ver);
+                                         (long)macosx_ver);
                        /* See Apple's Gestalt Manager Reference for meanings
                         * of the macosx_ver values. */
                }
@@ -487,6 +536,21 @@ get_runtime_version_info(GString *str, void (*additional_info)(GString *))
        g_string_append(str, ", ");
        get_runtime_pcap_version(str);
 
+        /* zlib */
+#if defined(HAVE_LIBZ) && !defined(_WIN32)
+        g_string_append_printf(str, ", with libz %s", zlibVersion());
+#endif
+
+    /* GnuTLS */
+#ifdef HAVE_LIBGNUTLS
+       g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL));
+#endif /* HAVE_LIBGNUTLS */
+
+        /* Gcrypt */
+#ifdef HAVE_LIBGCRYPT
+       g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL));
+#endif /* HAVE_LIBGCRYPT */
+
        /* Additional application-dependent information */
        if (additional_info)
                (*additional_info)(str);
@@ -568,7 +632,7 @@ const char *
 get_copyright_info(void)
 {
        return
-"Copyright 1998-2008 Gerald Combs <gerald@wireshark.org> and contributors.\n"
+"Copyright 1998-2010 Gerald Combs <gerald@wireshark.org> and contributors.\n"
 "This is free software; see the source for copying conditions. There is NO\n"
 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
 }