aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-12-30 19:36:26 -0800
committerGuy Harris <guy@alum.mit.edu>2014-12-31 03:41:02 +0000
commitc1f30471caebea3e7954cc4fbf876b2eae1045e4 (patch)
tree87b10cc473da009eb2b2002059fe0b86c1ec81cd /wsutil
parent4eeb440b70a720dec71317702def6dec9a0914b2 (diff)
Move the version_info.c stuff to wsutil/ws_version_info.c.
Change-Id: I3a5c7e219974bfb924819b43b4d445eaf00e5bde Reviewed-on: https://code.wireshark.org/review/6153 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/ws_version_info.c113
-rw-r--r--wsutil/ws_version_info.h23
2 files changed, 135 insertions, 1 deletions
diff --git a/wsutil/ws_version_info.c b/wsutil/ws_version_info.c
index 49af7acfad..c0e83ae467 100644
--- a/wsutil/ws_version_info.c
+++ b/wsutil/ws_version_info.c
@@ -23,12 +23,123 @@
#include "config.h"
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <glib.h>
-
#include <wsutil/ws_version_info.h>
+
#include <wsutil/copyright_info.h>
+#include <wsutil/glib_version_info.h>
+#include <wsutil/os_version_info.h>
+#include <wsutil/compiler_info.h>
+#include <wsutil/cpu_info.h>
+#include <wsutil/mem_info.h>
+
+/*
+ * If the string doesn't end with a newline, append one.
+ * Then word-wrap it to 80 columns.
+ */
+static void
+end_string(GString *str)
+{
+ size_t point;
+ char *p, *q;
+
+ point = str->len;
+ if (point == 0 || str->str[point - 1] != '\n')
+ g_string_append(str, "\n");
+ p = str->str;
+ while (*p != '\0') {
+ q = strchr(p, '\n');
+ if (q - p > 80) {
+ /*
+ * Break at or before this point.
+ */
+ q = p + 80;
+ while (q > p && *q != ' ')
+ q--;
+ if (q != p)
+ *q = '\n';
+ }
+ p = q + 1;
+ }
+}
+
+/*
+ * Get various library compile-time versions and append them to
+ * the specified GString.
+ *
+ * "additional_info" is called at the end to append any additional
+ * information; this is required in order to, for example, put the
+ * Portaudio information at the end of the string, as we currently
+ * don't use Portaudio in TShark.
+ */
+void
+get_compiled_version_info(GString *str, void (*prepend_info)(GString *),
+ void (*append_info)(GString *))
+{
+ if (sizeof(str) == 4)
+ g_string_append(str, "(32-bit) ");
+ else
+ g_string_append(str, "(64-bit) ");
+
+ if (prepend_info) {
+ (*prepend_info)(str);
+ g_string_append(str, ", ");
+ }
+
+ get_glib_version_info(str);
+
+ /* Additional application-dependent information */
+ if (append_info)
+ (*append_info)(str);
+ g_string_append(str, ".");
+
+ end_string(str);
+}
+
+/*
+ * Get various library run-time versions, and the OS version, and append
+ * them to the specified GString.
+ */
+void
+get_runtime_version_info(GString *str, void (*additional_info)(GString *))
+{
+#ifndef _WIN32
+ gchar *lang;
+#endif
+
+ g_string_append(str, "on ");
+
+ get_os_version_info(str);
+
+#ifndef _WIN32
+ /* Locale */
+ if ((lang = getenv ("LANG")) != NULL)
+ g_string_append_printf(str, ", with locale %s", lang);
+ else
+ g_string_append(str, ", with default locale");
+#endif
+
+ /* Additional application-dependent information */
+ if (additional_info)
+ (*additional_info)(str);
+
+ g_string_append(str, ".");
+
+ /* CPU Info */
+ get_cpu_info(str);
+
+ /* Get info about installed memory Windows only */
+ get_mem_info(str);
+
+ /* Compiler info */
+ get_compiler_info(str);
+
+ end_string(str);
+}
void
show_version(const gchar *prog_name_str, GString *comp_info_str,
diff --git a/wsutil/ws_version_info.h b/wsutil/ws_version_info.h
index 6d573e2105..03f57fc92d 100644
--- a/wsutil/ws_version_info.h
+++ b/wsutil/ws_version_info.h
@@ -30,6 +30,29 @@
extern "C" {
#endif /* __cplusplus */
+/*
+ * Get various library compile-time versions and append them to
+ * the specified GString.
+ *
+ * "prepend_info" is called at the start to prepend any additional
+ * information.
+ *
+ * "append_info" is called at the end to append any additional
+ * information; this is required in order to, for example, put the
+ * Portaudio information at the end of the string, as we currently
+ * don't use Portaudio in TShark.
+ */
+WS_DLL_PUBLIC void get_compiled_version_info(GString *str,
+ void (*prepend_info)(GString *),
+ void (*append_info)(GString *));
+
+/*
+ * Get various library run-time versions, and the OS version, and append
+ * them to the specified GString.
+ */
+WS_DLL_PUBLIC void get_runtime_version_info(GString *str,
+ void (*additional_info)(GString *));
+
WS_DLL_PUBLIC void show_version(const gchar *prog_name, GString *comp_info_str, GString *runtime_info_str);
/*