Release notes: Bump the next version.
[gd/wireshark/.git] / version_info.c
index 1be759c1fbfb6ba3caeb60b02e86bf7023e8de78..928214a8c0aeab7ac7be84d80068169c8489b9bf 100644 (file)
 #include <wsutil/cpu_info.h>
 #include <wsutil/copyright_info.h>
 #include <wsutil/os_version_info.h>
+#include <wsutil/crash_info.h>
 #include <wsutil/ws_printf.h> /* ws_debug_printf */
 #include <wsutil/plugins.h>
 
+static char *appname_with_version;
+static char *comp_info;
+static char *runtime_info;
+
+void
+ws_init_version_info(const char *appname,
+    void (*prepend_compile_time_info)(GString *),
+    void (*append_compile_time_info)(GString *),
+    void (*additional_run_time_info)(GString *))
+{
+       GString *comp_info_str, *runtime_info_str;
+
+       /*
+        * Combine the supplied application name string with the
+        * version - including the VCS version, for a build from
+        * a checkout.
+        */
+       appname_with_version = g_strdup_printf("%s %s",
+           appname, get_ws_vcs_version_info());
+
+       /* Get the compile-time version information string */
+       comp_info_str = get_compiled_version_info(prepend_compile_time_info,
+           append_compile_time_info);
+
+       /* Get the run-time version information string */
+       runtime_info_str = get_runtime_version_info(additional_run_time_info);
+
+       comp_info = g_string_free(comp_info_str, FALSE);
+       runtime_info = g_string_free(runtime_info_str, FALSE);
+
+       /* Add this information to the information to be reported on a crash. */
+       ws_add_crash_info("%s\n"
+           "\n"
+           "%s\n"
+           "%s",
+           appname_with_version, comp_info, runtime_info);
+}
+
+const char *
+get_appname_and_version(void)
+{
+       return appname_with_version;
+}
+
 /*
  * If the string doesn't end with a newline, append one.
  * Then word-wrap it to 80 columns.
@@ -210,7 +255,7 @@ get_compiler_info(GString *str)
   #define COMPILER_BUILD_NUMBER                 (_MSC_FULL_VER % 100000)
 
        /*
-        * From https://blogs.msdn.microsoft.com/vcblog/2014/11/17/c111417-features-in-vs-2015-preview/
+        * From https://web.archive.org/web/20190125151548/https://blogs.msdn.microsoft.com/vcblog/2014/11/17/c111417-features-in-vs-2015-preview/
          *
         *  Bakersfield: DevDiv's upper management determines the scheduling
         *  of new major versions.  They also decided to increment the product
@@ -226,7 +271,7 @@ get_compiler_info(GString *str)
 
   #if VCPP_MAJOR_VERSION == 14
        /*
-        * From https://blogs.msdn.microsoft.com/vcblog/2017/11/15/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/:
+        * From https://devblogs.microsoft.com/cppblog/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/
         *
         *  We've been delivering improvements to Visual Studio 2017 more
         *  frequently than ever before. Since its first release in March
@@ -243,8 +288,10 @@ get_compiler_info(GString *str)
         */
     #if COMPILER_MINOR_VERSION < 10
       #define VS_VERSION       "2015"
-    #else
+    #elif COMPILER_MINOR_VERSION < 20
       #define VS_VERSION       "2017"
+    #else
+      #define VS_VERSION       "2019"
     #endif
   #else
     /*
@@ -262,7 +309,7 @@ get_compiler_info(GString *str)
         * which I guess is not to be confused with the build number,
         * the _BUILD in the name nonwithstanding.
         */
-       g_string_append_printf(str, "\n\nBuilt using Microsoft Visual Studio " VS_VERSION "(VC++ %d.%d, build %d)",
+       g_string_append_printf(str, "\n\nBuilt using Microsoft Visual Studio " VS_VERSION " (VC++ %d.%d, build %d)",
            VCPP_MAJOR_VERSION, COMPILER_MINOR_VERSION, COMPILER_BUILD_NUMBER);
   #if defined(__clang__)
        /*
@@ -271,7 +318,7 @@ get_compiler_info(GString *str)
        g_string_append_printf(str, " clang/C2 %s and -fno-ms-compatibility.\n",
            __VERSION__);
   #else
-        g_string_append_printf(str, "\n");
+        g_string_append_printf(str, ".\n");
   #endif
 #elif defined(__GNUC__) && defined(__VERSION__)
        /*
@@ -373,7 +420,7 @@ get_runtime_version_info(void (*additional_info)(GString *))
         *
         * On Windows get_locale returns the full language, country
         * name, and code page, e.g. "English_United States.1252":
-        * https://msdn.microsoft.com/en-us/library/x99tb11d.aspx
+        * https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=vs-2019
         */
        if ((lang = get_locale()) != NULL) {
                g_string_append_printf(str, ", with locale %s", lang);
@@ -413,21 +460,6 @@ get_runtime_version_info(void (*additional_info)(GString *))
        return str;
 }
 
-void
-show_version(const gchar *prog_name_str, GString *comp_info_str,
-            GString *runtime_info_str)
-{
-       ws_debug_printf("%s %s\n"
-              "\n"
-              "%s"
-              "\n"
-              "%s"
-              "\n"
-              "%s",
-              prog_name_str, get_ws_vcs_version_info(), get_copyright_info(),
-              comp_info_str->str, runtime_info_str->str);
-}
-
 /*
  * Return a version number string for Wireshark, including, for builds
  * from a tree checked out from Wireshark's version control system,
@@ -454,8 +486,29 @@ get_ws_version_number(int *major, int *minor, int *micro)
                *micro = VERSION_MICRO;
 }
 
+void
+show_version(void)
+{
+       ws_debug_printf("%s\n"
+              "\n"
+              "%s\n"
+              "%s\n"
+              "%s",
+              appname_with_version, get_copyright_info(),
+              comp_info, runtime_info);
+}
+
+void
+show_help_header(const char *description)
+{
+       ws_debug_printf("%s\n"
+               "%s\n"
+               "See https://www.wireshark.org for more information.\n",
+               appname_with_version, description);
+}
+
 /*
- * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
+ * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
  *
  * Local variables:
  * c-basic-offset: 8