aboutsummaryrefslogtreecommitdiffstats
path: root/version_info.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-12-12 18:16:15 -0800
committerGuy Harris <guy@alum.mit.edu>2018-12-13 03:16:13 +0000
commit43dfd45faa8af0b239a671b25ab6a398fa32f5c6 (patch)
tree3ea329a4f3f702e279169382614dcaf553e79431 /version_info.c
parenta34cc98b2ac5a0ad011a1c3a40ce5e59230a9498 (diff)
Move more version-info-related stuff to version_info.c.
Have a ws_init_version_info() routine that, given an application name string: constructs the app-name-and-version-information string, and saves it; adds the initial crash information on platforms that support it, and saves it. Have show_version() use the saved information and take no arguments. Add a show_help_header() routine to print the header for --help command-line options, given a description of the application; it prints the application name and version information, the description, and the "See {wireshark.org URL}" line. Use those routines in various places, including providing the "application name" string in pcapng SHBs. Change-Id: I0042a8fcc91aa919ad5c381a8b8674a007ce66df Reviewed-on: https://code.wireshark.org/review/31029 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'version_info.c')
-rw-r--r--version_info.c81
1 files changed, 66 insertions, 15 deletions
diff --git a/version_info.c b/version_info.c
index 2b1008683e..017135c46f 100644
--- a/version_info.c
+++ b/version_info.c
@@ -37,9 +37,54 @@
#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.
@@ -413,21 +458,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,6 +484,27 @@ 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
*