Make --help and --version information a bit more uniform.
authorGuy Harris <guy@alum.mit.edu>
Thu, 3 Jul 2014 08:45:32 +0000 (01:45 -0700)
committerGuy Harris <guy@alum.mit.edu>
Thu, 3 Jul 2014 08:46:01 +0000 (08:46 +0000)
Have --version print the version number, the copyright information, the
"compiled with" information, the "running on/with" information, and the
compiler information.

Have --help print the version number, a one-line summary of what the
program does, a reference to http://www.wireshark.org for more
information, a Usage: line, and a list of command-line options.

This means programs doing that don't need to include version.h; that's
left up to get_ws_vcs_version_info() to do.

Change-Id: Idac641bc10e4dfd04c9914d379b3a3e0cc5ca8cb
Reviewed-on: https://code.wireshark.org/review/2794
Reviewed-by: Guy Harris <guy@alum.mit.edu>
14 files changed:
CMakeLists.txt
Makefile.common
Makefile.nmake
capinfos.c
dumpcap.c
editcap.c
mergecap.c
reordercap.c
text2pcap.c
tfshark.c
tshark.c
ui/gtk/main.c
ui/qt/main.cpp
version_info.c

index b25965a..7f4a366 100644 (file)
@@ -921,7 +921,6 @@ set(SHARK_COMMON_SRC
        capture-pcap-util.c
        cfile.c
        frame_tvbuff.c
-       ${CMAKE_BINARY_DIR}/version.h
        sync_pipe_write.c
        version_info.c
 )
@@ -1221,6 +1220,7 @@ if(BUILD_text2pcap)
        set(text2pcap_CLEAN_FILES
                text2pcap.c
                pcapio.c
+               version_info.c
        )
        set(text2pcap_FILES
                ${text2pcap_CLEAN_FILES}
@@ -1245,7 +1245,7 @@ if(BUILD_mergecap)
        )
        set(mergecap_FILES
                mergecap.c
-               ${CMAKE_BINARY_DIR}/version.h
+               version_info.c
                image/mergecap.rc
        )
        add_executable(mergecap ${mergecap_FILES})
@@ -1264,7 +1264,7 @@ if(BUILD_reordercap)
        )
        set(reordercap_FILES
                reordercap.c
-               ${CMAKE_BINARY_DIR}/version.h
+               version_info.c
                image/reordercap.rc
        )
        add_executable(reordercap ${reordercap_FILES})
@@ -1285,6 +1285,7 @@ if(BUILD_capinfos)
        )
        set(capinfos_FILES
                capinfos.c
+               version_info.c
                image/capinfos.rc
        )
        add_executable(capinfos ${capinfos_FILES})
@@ -1322,6 +1323,7 @@ if(BUILD_editcap)
        )
        set(editcap_FILES
                editcap.c
+               version_info.c
                image/editcap.rc
        )
        add_executable(editcap ${editcap_FILES})
@@ -1347,7 +1349,6 @@ if(BUILD_dumpcap AND PCAP_FOUND)
                ${NL_LIBRARIES}
        )
        set(dumpcap_FILES
-               ${CMAKE_BINARY_DIR}/version.h
                capture_opts.c
                capture-pcap-util.c
                capture_stop_conditions.c
index 5ed647f..00a0031 100644 (file)
@@ -50,7 +50,6 @@ SHARK_COMMON_SRC =    \
 
 # corresponding headers
 SHARK_COMMON_INCLUDES =        \
-       version.h               \
        capture-pcap-util.h     \
        capture-pcap-util-int.h \
        cfile.h                 \
@@ -107,9 +106,10 @@ rawshark_SOURCES = \
 
 # text2pcap specifics
 text2pcap_SOURCES = \
-       pcapio.c \
-       text2pcap.c \
-       text2pcap-scanner.l
+       pcapio.c                \
+       text2pcap.c             \
+       text2pcap-scanner.l     \
+       version_info.c
 
 text2pcap_INCLUDES = \
        pcapio.h \
@@ -117,20 +117,23 @@ text2pcap_INCLUDES = \
 
 # mergecap specifics
 mergecap_SOURCES = \
-       mergecap.c
+       mergecap.c      \
+       version_info.c
 
 # editcap specifics
 editcap_SOURCES = \
-       editcap.c
+       editcap.c       \
+       version_info.c
 
 # reordercap specifics
 reordercap_SOURCES = \
-       reordercap.c \
-       version.h
+       reordercap.c    \
+       version_info.c
 
 # capinfos specifics
 capinfos_SOURCES = \
-       capinfos.c
+       capinfos.c      \
+       version_info.c
 
 # captype specifics
 captype_SOURCES = \
index c64a747..4451ead 100644 (file)
@@ -551,13 +551,6 @@ text2pcap-scanner.c : text2pcap-scanner.l
 text2pcap-scanner.obj : text2pcap-scanner.c
        $(CC) $(GENERATED_CFLAGS) -Fd.\ -c $?
 
-#
-# The following targets will rebuild their respective objs
-# if and when version.h should change.
-#
-text2pcap.obj mergecap.obj capinfos.obj captype.obj editcap.obj reordercap.obj: version.h
-
-
 clean-local:
        rm -f $(wireshark_OBJECTS) $(tshark_OBJECTS) $(tfshark_OBJECTS) $(dumpcap_OBJECTS) $(rawshark_OBJECTS) \
                $(EXECUTABLES) *.pdb *.sbr *.exe.manifest \
index b8e74e9..aec23f9 100644 (file)
 
 #include <glib.h>
 
+#ifdef HAVE_LIBZ
+#include <zlib.h>      /* to get the libz version number */
+#endif
+
 #include <wsutil/privileges.h>
 #include <wsutil/filesystem.h>
+#include <wsutil/crash_info.h>
+#include <wsutil/copyright_info.h>
+#include <wsutil/os_version_info.h>
+#include <wsutil/ws_version_info.h>
 
 #ifdef HAVE_PLUGINS
 #include <wsutil/plugins.h>
@@ -86,7 +94,6 @@
 
 #include "wtap.h"
 #include <wsutil/report_err.h>
-#include <wsutil/privileges.h>
 #include <wsutil/str_util.h>
 #include <wsutil/file_util.h>
 
 #include <wsutil/unicode-utils.h>
 #endif /* _WIN32 */
 
-#include "version.h"
+#include "version_info.h"
 
 /*
  * By default capinfos now continues processing
@@ -996,31 +1003,22 @@ process_cap_file(wtap *wth, const char *filename)
 }
 
 static void
-print_version(FILE *output)
+show_version(GString *comp_info_str, GString *runtime_info_str)
 {
-  fprintf(output, "Capinfos %s"
-#ifdef GITVERSION
-      " (" GITVERSION " from " GITBRANCH ")"
-#endif
-      "\n", VERSION);
+    printf("Capinfos (Wireshark) %s\n"
+           "\n"
+           "%s"
+           "\n"
+           "%s"
+           "\n"
+           "%s",
+           get_ws_vcs_version_info(), get_copyright_info(),
+           comp_info_str->str, runtime_info_str->str);
 }
 
 static void
-usage(gboolean is_error)
+print_usage(FILE *output)
 {
-  FILE *output;
-
-  if (!is_error) {
-    output = stdout;
-    /* XXX - add capinfos header info here */
-  }
-  else {
-    output = stderr;
-  }
-
-  print_version(output);
-  fprintf(output, "Prints various information (infos) about capture files.\n");
-  fprintf(output, "See http://www.wireshark.org for more information.\n");
   fprintf(output, "\n");
   fprintf(output, "Usage: capinfos [options] <infile> ...\n");
   fprintf(output, "\n");
@@ -1107,9 +1105,37 @@ hash_to_str(const unsigned char *hash, size_t length, char *str) {
 }
 #endif /* HAVE_LIBGCRYPT */
 
+static void
+get_capinfos_compiled_info(GString *str)
+{
+  /* LIBZ */
+  g_string_append(str, ", ");
+#ifdef HAVE_LIBZ
+  g_string_append(str, "with libz ");
+#ifdef ZLIB_VERSION
+  g_string_append(str, ZLIB_VERSION);
+#else /* ZLIB_VERSION */
+  g_string_append(str, "(version unknown)");
+#endif /* ZLIB_VERSION */
+#else /* HAVE_LIBZ */
+  g_string_append(str, "without libz");
+#endif /* HAVE_LIBZ */
+}
+
+static void
+get_capinfos_runtime_info(GString *str)
+{
+  /* zlib */
+#if defined(HAVE_LIBZ) && !defined(_WIN32)
+  g_string_append_printf(str, ", with libz %s", zlibVersion());
+#endif
+}
+
 int
 main(int argc, char *argv[])
 {
+  GString *comp_info_str;
+  GString *runtime_info_str;
   wtap  *wth;
   int    err;
   gchar *err_info;
@@ -1132,6 +1158,22 @@ main(int argc, char *argv[])
   size_t hash_bytes;
 #endif
 
+  /* Assemble the compile-time version information string */
+  comp_info_str = g_string_new("Compiled ");
+  get_compiled_version_info(comp_info_str, NULL, get_capinfos_compiled_info);
+
+  /* Assemble the run-time version information string */
+  runtime_info_str = g_string_new("Running ");
+  get_runtime_version_info(runtime_info_str, get_capinfos_runtime_info);
+
+  /* Add it to the information to be reported on a crash. */
+  ws_add_crash_info("Capinfos (Wireshark) %s\n"
+         "\n"
+         "%s"
+         "\n"
+         "%s",
+      get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
+
 #ifdef _WIN32
   arg_list_utf_16to8(argc, argv);
   create_app_running_mutex();
@@ -1363,17 +1405,23 @@ main(int argc, char *argv[])
         break;
 
       case 'h':
-        usage(FALSE);
+        printf("Capinfos (Wireshark) %s\n"
+               "Print various information (infos) about capture files.\n"
+               "See http://www.wireshark.org for more information.\n",
+               get_ws_vcs_version_info());
+        print_usage(stdout);
         exit(0);
         break;
 
       case 'v':
-        print_version(stdout);
+        show_version(comp_info_str, runtime_info_str);
+        g_string_free(comp_info_str, TRUE);
+        g_string_free(runtime_info_str, TRUE);
         exit(0);
         break;
 
       case '?':              /* Bad flag - print usage message */
-        usage(TRUE);
+        print_usage(stderr);
         exit(1);
         break;
     }
@@ -1383,7 +1431,7 @@ main(int argc, char *argv[])
   setlocale(LC_ALL, "");
 
   if ((argc - optind) < 1) {
-    usage(TRUE);
+    print_usage(stderr);
     exit(1);
   }
 
index 100be01..10a782f 100644 (file)
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -556,14 +556,12 @@ print_usage(FILE *output)
 static void
 show_version(GString *comp_info_str, GString *runtime_info_str)
 {
-    printf(
-        "Dumpcap (Wireshark) %s\n"
-        "\n"
-        "%s\n"
-        "%s\n"
-        "%s\n"
-        "See http://www.wireshark.org for more information.\n",
-        get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str, runtime_info_str->str);
+    printf("Dumpcap (Wireshark) %s\n"
+           "\n"
+           "%s\n"
+           "%s\n"
+           "%s",
+           get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str, runtime_info_str->str);
 }
 
 /*
@@ -4156,6 +4154,56 @@ out:
     return ret;
 }
 
+static void
+get_dumpcap_compiled_info(GString *str)
+{
+       /* Libpcap */
+       g_string_append(str, ", ");
+       get_compiled_pcap_version(str);
+
+       /* LIBZ */
+       g_string_append(str, ", ");
+#ifdef HAVE_LIBZ
+       g_string_append(str, "with libz ");
+#ifdef ZLIB_VERSION
+       g_string_append(str, ZLIB_VERSION);
+#else /* ZLIB_VERSION */
+       g_string_append(str, "(version unknown)");
+#endif /* ZLIB_VERSION */
+#else /* HAVE_LIBZ */
+       g_string_append(str, "without libz");
+#endif /* HAVE_LIBZ */
+
+#ifndef _WIN32
+       /* This is UN*X-only. */
+       /* LIBCAP */
+       g_string_append(str, ", ");
+#ifdef HAVE_LIBCAP
+       g_string_append(str, "with POSIX capabilities");
+#ifdef _LINUX_CAPABILITY_VERSION
+       g_string_append(str, " (Linux)");
+#endif /* _LINUX_CAPABILITY_VERSION */
+#else /* HAVE_LIBCAP */
+       g_string_append(str, "without POSIX capabilities");
+#endif /* HAVE_LIBCAP */
+#endif /* _WIN32 */
+
+#ifdef __linux__
+       /* This is a Linux-specific library. */
+       /* LIBNL */
+       g_string_append(str, ", ");
+#if defined(HAVE_LIBNL1)
+       g_string_append(str, "with libnl 1");
+#elif defined(HAVE_LIBNL2)
+       g_string_append(str, "with libnl 2");
+#elif defined(HAVE_LIBNL3)
+       g_string_append(str, "with libnl 3");
+#else /* no libnl */
+       g_string_append(str, "without libnl");
+#endif /* libnl version */
+#endif /* __linux__ */
+}
+
 static void
 get_dumpcap_runtime_info(GString *str)
 {
@@ -4216,7 +4264,7 @@ main(int argc, char *argv[])
 
     /* Assemble the compile-time version information string */
     comp_info_str = g_string_new("Compiled ");
-    get_compiled_version_info(comp_info_str, NULL, NULL);
+    get_compiled_version_info(comp_info_str, NULL, get_dumpcap_compiled_info);
 
     /* Assemble the run-time version information string */
     runtime_info_str = g_string_new("Running ");
index 826f7c6..4432d41 100644 (file)
--- a/editcap.c
+++ b/editcap.c
 #include <sys/time.h>
 #endif
 
+#ifdef HAVE_LIBZ
+#include <zlib.h>      /* to get the libz version number */
+#endif
+
 #include "wtap.h"
 
 #ifndef HAVE_GETOPT
 #include <wsutil/strnatcmp.h>
 #include <wsutil/md5.h>
 #include <wsutil/plugins.h>
+#include <wsutil/crash_info.h>
+#include <wsutil/copyright_info.h>
+#include <wsutil/os_version_info.h>
+#include <wsutil/ws_version_info.h>
 
-#include "version.h"
+#include "version_info.h"
 
 #include "ringbuffer.h" /* For RINGBUFFER_MAX_NUM_FILES */
 
@@ -662,28 +670,22 @@ is_duplicate_rel_time(guint8* fd, guint32 len, const nstime_t *current) {
 }
 
 static void
-print_version(FILE *output)
+show_version(GString *comp_info_str, GString *runtime_info_str)
 {
-  fprintf(output, "Editcap %s"
-#ifdef GITVERSION
-      " (" GITVERSION " from " GITBRANCH ")"
-#endif
-      "\n", VERSION);
+    printf("Editcap (Wireshark) %s\n"
+           "\n"
+           "%s"
+           "\n"
+           "%s"
+           "\n"
+           "%s",
+           get_ws_vcs_version_info(), get_copyright_info(),
+           comp_info_str->str, runtime_info_str->str);
 }
 
 static void
-usage(gboolean is_error)
+print_usage(FILE *output)
 {
-    FILE *output;
-
-    if (!is_error)
-        output = stdout;
-    else
-        output = stderr;
-
-    print_version(output);
-    fprintf(output, "Edit and/or translate the format of capture files.\n");
-    fprintf(output, "See http://www.wireshark.org for more information.\n");
     fprintf(output, "\n");
     fprintf(output, "Usage: editcap [options] ... <infile> <outfile> [ <packet#>[-<packet#>] ... ]\n");
     fprintf(output, "\n");
@@ -839,9 +841,37 @@ failure_message(const char *msg_format _U_, va_list ap _U_)
 }
 #endif
 
+static void
+get_editcap_compiled_info(GString *str)
+{
+  /* LIBZ */
+  g_string_append(str, ", ");
+#ifdef HAVE_LIBZ
+  g_string_append(str, "with libz ");
+#ifdef ZLIB_VERSION
+  g_string_append(str, ZLIB_VERSION);
+#else /* ZLIB_VERSION */
+  g_string_append(str, "(version unknown)");
+#endif /* ZLIB_VERSION */
+#else /* HAVE_LIBZ */
+  g_string_append(str, "without libz");
+#endif /* HAVE_LIBZ */
+}
+
+static void
+get_editcap_runtime_info(GString *str)
+{
+  /* zlib */
+#if defined(HAVE_LIBZ) && !defined(_WIN32)
+  g_string_append_printf(str, ", with libz %s", zlibVersion());
+#endif
+}
+
 int
 main(int argc, char *argv[])
 {
+    GString      *comp_info_str;
+    GString      *runtime_info_str;
     wtap         *wth;
     int           i, j, err;
     gchar        *err_info;
@@ -887,9 +917,25 @@ main(int argc, char *argv[])
     create_app_running_mutex();
 #endif /* _WIN32 */
 
-  /*
-   * Get credential information for later use.
-   */
+    /* Assemble the compile-time version information string */
+    comp_info_str = g_string_new("Compiled ");
+    get_compiled_version_info(comp_info_str, NULL, get_editcap_compiled_info);
+
+    /* Assemble the run-time version information string */
+    runtime_info_str = g_string_new("Running ");
+    get_runtime_version_info(runtime_info_str, get_editcap_runtime_info);
+
+    /* Add it to the information to be reported on a crash. */
+    ws_add_crash_info("Editcap (Wireshark) %s\n"
+         "\n"
+         "%s"
+         "\n"
+         "%s",
+      get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
+
+    /*
+     * Get credential information for later use.
+     */
     init_process_policies();
     init_open_routines();
 
@@ -1045,7 +1091,11 @@ main(int argc, char *argv[])
             break;
 
         case 'h':
-            usage(FALSE);
+            printf("Editcap (Wireshark) %s\n"
+                   "Edit and/or translate the format of capture files.\n"
+                   "See http://www.wireshark.org for more information.\n",
+               get_ws_vcs_version_info());
+            print_usage(stdout);
             exit(0);
             break;
 
@@ -1099,7 +1149,9 @@ main(int argc, char *argv[])
             break;
 
         case 'V':
-            print_version(stdout);
+            show_version(comp_info_str, runtime_info_str);
+            g_string_free(comp_info_str, TRUE);
+            g_string_free(runtime_info_str, TRUE);
             exit(0);
             break;
 
@@ -1119,7 +1171,7 @@ main(int argc, char *argv[])
                 list_encap_types();
                 break;
             default:
-                usage(TRUE);
+                print_usage(stderr);
                 break;
             }
             exit(1);
@@ -1132,7 +1184,7 @@ main(int argc, char *argv[])
 #endif
 
     if ((argc - optind) < 1) {
-        usage(TRUE);
+        print_usage(stderr);
         exit(1);
     }
 
index 44c8c71..49dcfe6 100644 (file)
 #include <sys/time.h>
 #endif
 
+#ifdef HAVE_LIBZ
+#include <zlib.h>      /* to get the libz version number */
+#endif
+
 #include <string.h>
 #include "wtap.h"
 
 
 #include <wsutil/strnatcmp.h>
 #include <wsutil/file_util.h>
+#include <wsutil/crash_info.h>
+#include <wsutil/copyright_info.h>
+#include <wsutil/os_version_info.h>
+#include <wsutil/ws_version_info.h>
 
 #include <wiretap/merge.h>
 
-#include "version.h"
+#include "version_info.h"
 
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
@@ -104,33 +112,25 @@ get_positive_int(const char *string, const char *name)
 }
 
 static void
-print_version(FILE *output)
+show_version(GString *comp_info_str, GString *runtime_info_str)
 {
-  fprintf(output, "Mergecap %s"
-#ifdef GITVERSION
-      " (" GITVERSION " from " GITBRANCH ")"
-#endif
-      "\n", VERSION);
+    printf("Mergecap (Wireshark) %s\n"
+           "\n"
+           "%s"
+           "\n"
+           "%s"
+           "\n"
+           "%s",
+           get_ws_vcs_version_info(), get_copyright_info(),
+           comp_info_str->str, runtime_info_str->str);
 }
 
 /*
  * Show the usage
  */
 static void
-usage(gboolean is_error)
+print_usage(FILE *output)
 {
-  FILE *output;
-
-  if (!is_error) {
-    output = stdout;
-  }
-  else {
-    output = stderr;
-  }
-
-  print_version(output);
-  fprintf(output, "Merge two or more capture files into one.\n");
-  fprintf(output, "See http://www.wireshark.org for more information.\n");
   fprintf(output, "\n");
   fprintf(output, "Usage: mergecap [options] -w <outfile>|- <infile> [<infile> ...]\n");
   fprintf(output, "\n");
@@ -217,9 +217,37 @@ list_encap_types(void) {
   g_free(encaps);
 }
 
+static void
+get_mergecap_compiled_info(GString *str)
+{
+  /* LIBZ */
+  g_string_append(str, ", ");
+#ifdef HAVE_LIBZ
+  g_string_append(str, "with libz ");
+#ifdef ZLIB_VERSION
+  g_string_append(str, ZLIB_VERSION);
+#else /* ZLIB_VERSION */
+  g_string_append(str, "(version unknown)");
+#endif /* ZLIB_VERSION */
+#else /* HAVE_LIBZ */
+  g_string_append(str, "without libz");
+#endif /* HAVE_LIBZ */
+}
+
+static void
+get_mergecap_runtime_info(GString *str)
+{
+  /* zlib */
+#if defined(HAVE_LIBZ) && !defined(_WIN32)
+  g_string_append_printf(str, ", with libz %s", zlibVersion());
+#endif
+}
+
 int
 main(int argc, char *argv[])
 {
+  GString            *comp_info_str;
+  GString            *runtime_info_str;
   int                 opt;
   static const struct option long_options[] = {
       {(char *)"help", no_argument, NULL, 'h'},
@@ -253,6 +281,22 @@ main(int argc, char *argv[])
   create_app_running_mutex();
 #endif /* _WIN32 */
 
+  /* Assemble the compile-time version information string */
+  comp_info_str = g_string_new("Compiled ");
+  get_compiled_version_info(comp_info_str, NULL, get_mergecap_compiled_info);
+
+  /* Assemble the run-time version information string */
+  runtime_info_str = g_string_new("Running ");
+  get_runtime_version_info(runtime_info_str, get_mergecap_runtime_info);
+
+  /* Add it to the information to be reported on a crash. */
+  ws_add_crash_info("Mergecap (Wireshark) %s\n"
+       "\n"
+       "%s"
+       "\n"
+       "%s",
+    get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
+
   /* Process the options first */
   while ((opt = getopt_long(argc, argv, "aF:hs:T:vVw:", long_options, NULL)) != -1) {
 
@@ -272,7 +316,11 @@ main(int argc, char *argv[])
       break;
 
     case 'h':
-      usage(FALSE);
+      printf("Mergecap (Wireshark) %s\n"
+             "Merge two or more capture files into one.\n"
+             "See http://www.wireshark.org for more information.\n",
+             get_ws_vcs_version_info());
+      print_usage(stdout);
       exit(0);
       break;
 
@@ -295,7 +343,9 @@ main(int argc, char *argv[])
       break;
 
     case 'V':
-      print_version(stdout);
+      show_version(comp_info_str, runtime_info_str);
+      g_string_free(comp_info_str, TRUE);
+      g_string_free(runtime_info_str, TRUE);
       exit(0);
       break;
 
@@ -312,7 +362,7 @@ main(int argc, char *argv[])
         list_encap_types();
         break;
       default:
-        usage(TRUE);
+        print_usage(stderr);
       }
       exit(1);
       break;
index 7a9890e..9246974 100644 (file)
 #include <getopt.h>
 #endif
 
+#ifdef HAVE_LIBZ
+#include <zlib.h>      /* to get the libz version number */
+#endif
+
 #include "wtap.h"
 
 #ifndef HAVE_GETOPT
 #include "wsutil/wsgetopt.h"
 #endif
 
-#include "version.h"
+#include <wsutil/strnatcmp.h>
+#include <wsutil/file_util.h>
+#include <wsutil/crash_info.h>
+#include <wsutil/copyright_info.h>
+#include <wsutil/os_version_info.h>
+#include <wsutil/ws_version_info.h>
+
+#include "version_info.h"
 
 static void
-print_version(FILE *output)
+show_version(GString *comp_info_str, GString *runtime_info_str)
 {
-  fprintf(output, "Reordercap %s"
-#ifdef GITVERSION
-      " (" GITVERSION " from " GITBRANCH ")"
-#endif
-      "\n", VERSION);
+    printf("Reordercap (Wireshark) %s\n"
+           "\n"
+           "%s"
+           "\n"
+           "%s"
+           "\n"
+           "%s",
+           get_ws_vcs_version_info(), get_copyright_info(),
+           comp_info_str->str, runtime_info_str->str);
 }
 
 /* Show command-line usage */
 static void
-usage(gboolean is_error)
+print_usage(FILE *output)
 {
-    FILE *output;
-
-    if (!is_error) {
-        output = stdout;
-    }
-    else {
-        output = stderr;
-    }
-
-    print_version(output);
-    fprintf(output, "Reorder timestamps of input file frames into output file.\n");
-    fprintf(output, "See http://www.wireshark.org for more information.\n");
     fprintf(output, "\n");
     fprintf(output, "Usage: reordercap [options] <infile> <outfile>\n");
     fprintf(output, "\n");
@@ -164,6 +167,31 @@ frames_compare(gconstpointer a, gconstpointer b)
     return nstime_cmp(time1, time2);
 }
 
+static void
+get_reordercap_compiled_info(GString *str)
+{
+    /* LIBZ */
+    g_string_append(str, ", ");
+#ifdef HAVE_LIBZ
+    g_string_append(str, "with libz ");
+#ifdef ZLIB_VERSION
+    g_string_append(str, ZLIB_VERSION);
+#else /* ZLIB_VERSION */
+    g_string_append(str, "(version unknown)");
+#endif /* ZLIB_VERSION */
+#else /* HAVE_LIBZ */
+    g_string_append(str, "without libz");
+#endif /* HAVE_LIBZ */
+}
+
+static void
+get_reordercap_runtime_info(GString *str)
+{
+    /* zlib */
+#if defined(HAVE_LIBZ) && !defined(_WIN32)
+    g_string_append_printf(str, ", with libz %s", zlibVersion());
+#endif
+}
 
 /********************************************************************/
 /* Main function.                                                   */
@@ -171,6 +199,8 @@ frames_compare(gconstpointer a, gconstpointer b)
 int
 main(int argc, char *argv[])
 {
+    GString *comp_info_str;
+    GString *runtime_info_str;
     wtap *wth = NULL;
     wtap_dumper *pdh = NULL;
     Buffer buf;
@@ -197,6 +227,22 @@ main(int argc, char *argv[])
     char *infile;
     char *outfile;
 
+    /* Assemble the compile-time version information string */
+    comp_info_str = g_string_new("Compiled ");
+    get_compiled_version_info(comp_info_str, NULL, get_reordercap_compiled_info);
+
+    /* Assemble the run-time version information string */
+    runtime_info_str = g_string_new("Running ");
+    get_runtime_version_info(runtime_info_str, get_reordercap_runtime_info);
+
+    /* Add it to the information to be reported on a crash. */
+    ws_add_crash_info("Reordercap (Wireshark) %s\n"
+         "\n"
+         "%s"
+         "\n"
+         "%s",
+      get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
+
     /* Process the options first */
     while ((opt = getopt_long(argc, argv, "hnv", long_options, NULL)) != -1) {
         switch (opt) {
@@ -204,13 +250,19 @@ main(int argc, char *argv[])
                 write_output_regardless = FALSE;
                 break;
             case 'h':
-                usage(FALSE);
+                printf("Reordercap (Wireshark) %s\n"
+                       "Reorder timestamps of input file frames into output file.\n"
+                       "See http://www.wireshark.org for more information.\n",
+                       get_ws_vcs_version_info());
+                print_usage(stdout);
                 exit(0);
             case 'v':
-                print_version(stdout);
+                show_version(comp_info_str, runtime_info_str);
+                g_string_free(comp_info_str, TRUE);
+                g_string_free(runtime_info_str, TRUE);
                 exit(0);
             case '?':
-                usage(TRUE);
+                print_usage(stderr);
                 exit(1);
         }
     }
@@ -222,7 +274,7 @@ main(int argc, char *argv[])
         outfile = argv[optind+1];
     }
     else {
-        usage(TRUE);
+        print_usage(stderr);
         exit(1);
     }
 
index 2103c86..e308ffc 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <wsutil/file_util.h>
+#include <wsutil/crash_info.h>
+#include <wsutil/copyright_info.h>
+#include <wsutil/os_version_info.h>
+#include <wsutil/ws_version_info.h>
 
 #include <time.h>
 #include <glib.h>
 #include <errno.h>
 #include <assert.h>
 
+#ifdef HAVE_LIBZ
+#include <zlib.h>      /* to get the libz version number */
+#endif
+
 #ifndef HAVE_GETOPT
 #include "wsutil/wsgetopt.h"
 #endif
 
 #include "pcapio.h"
 #include "text2pcap.h"
-#include "version.h"
+#include "version_info.h"
 
 #ifdef _WIN32
 #include <wsutil/unicode-utils.h>
@@ -1425,34 +1433,26 @@ fail_null_str:
 }
 
 static void
-print_version(FILE *output)
+show_version(GString *comp_info_str, GString *runtime_info_str)
 {
-  fprintf(output, "Text2pcap %s"
-#ifdef GITVERSION
-      " (" GITVERSION " from " GITBRANCH ")"
-#endif
-      "\n", VERSION);
+    printf("Text2pcap (Wireshark) %s\n"
+           "\n"
+           "%s"
+           "\n"
+           "%s"
+           "\n"
+           "%s",
+           get_ws_vcs_version_info(), get_copyright_info(),
+           comp_info_str->str, runtime_info_str->str);
 }
 
 /*----------------------------------------------------------------------
  * Print usage string and exit
  */
 static void
-usage (gboolean is_error)
+print_usage (FILE *output)
 {
-    FILE *output;
-
-    if (!is_error) {
-        output = stdout;
-    }
-    else {
-        output = stderr;
-    }
-
-    print_version(output);
     fprintf(output,
-            "Generate a capture file from an ASCII hexdump of packets.\n"
-            "See http://www.wireshark.org for more information.\n"
             "\n"
             "Usage: text2pcap [options] <infile> <outfile>\n"
             "\n"
@@ -1531,8 +1531,32 @@ usage (gboolean is_error)
             "  -n                     use PCAP-NG instead of PCAP as output format.\n"
             "",
             MAX_PACKET);
+}
 
-    exit(is_error ? 1 : 0);
+static void
+get_text2pcap_compiled_info(GString *str)
+{
+    /* LIBZ */
+    g_string_append(str, ", ");
+#ifdef HAVE_LIBZ
+    g_string_append(str, "with libz ");
+#ifdef ZLIB_VERSION
+    g_string_append(str, ZLIB_VERSION);
+#else /* ZLIB_VERSION */
+    g_string_append(str, "(version unknown)");
+#endif /* ZLIB_VERSION */
+#else /* HAVE_LIBZ */
+    g_string_append(str, "without libz");
+#endif /* HAVE_LIBZ */
+}
+
+static void
+get_text2pcap_runtime_info(GString *str)
+{
+    /* zlib */
+#if defined(HAVE_LIBZ) && !defined(_WIN32)
+    g_string_append_printf(str, ", with libz %s", zlibVersion());
+#endif
 }
 
 /*----------------------------------------------------------------------
@@ -1541,6 +1565,8 @@ usage (gboolean is_error)
 static void
 parse_options (int argc, char *argv[])
 {
+    GString *comp_info_str;
+    GString *runtime_info_str;
     int   c;
     char *p;
     static const struct option long_options[] = {
@@ -1554,11 +1580,33 @@ parse_options (int argc, char *argv[])
     create_app_running_mutex();
 #endif /* _WIN32 */
 
+    /* Assemble the compile-time version information string */
+    comp_info_str = g_string_new("Compiled ");
+    get_compiled_version_info(comp_info_str, NULL, get_text2pcap_compiled_info);
+
+    /* Assemble the run-time version information string */
+    runtime_info_str = g_string_new("Running ");
+    get_runtime_version_info(runtime_info_str, get_text2pcap_runtime_info);
+
+    /* Add it to the information to be reported on a crash. */
+    ws_add_crash_info("Text2pcap (Wireshark) %s\n"
+         "\n"
+         "%s"
+         "\n"
+         "%s",
+      get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
+
     /* Scan CLI parameters */
     while ((c = getopt_long(argc, argv, "aDdhqe:i:l:m:no:u:s:S:t:T:v4:6:", long_options, NULL)) != -1) {
         switch (c) {
-        case '?': usage(TRUE); break;
-        case 'h': usage(FALSE); break;
+        case 'h':
+            printf("Text2pcap (Wireshark) %s\n"
+                   "Generate a capture file from an ASCII hexdump of packets.\n"
+                   "See http://www.wireshark.org for more information.\n",
+                   get_ws_vcs_version_info());
+            print_usage(stdout);
+            exit(0);
+            break;
         case 'd': if (!quiet) debug++; break;
         case 'D': has_direction = TRUE; break;
         case 'q': quiet = TRUE; debug = FALSE; break;
@@ -1568,7 +1616,8 @@ parse_options (int argc, char *argv[])
         case 'o':
             if (optarg[0] != 'h' && optarg[0] != 'o' && optarg[0] != 'd') {
                 fprintf(stderr, "Bad argument for '-o': %s\n", optarg);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             switch (optarg[0]) {
             case 'o': offset_base =  8; break;
@@ -1580,7 +1629,8 @@ parse_options (int argc, char *argv[])
             hdr_ethernet = TRUE;
             if (sscanf(optarg, "%x", &hdr_ethernet_proto) < 1) {
                 fprintf(stderr, "Bad argument for '-e': %s\n", optarg);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             break;
 
@@ -1590,7 +1640,8 @@ parse_options (int argc, char *argv[])
             if (p == optarg || *p != '\0' || hdr_ip_proto < 0 ||
                   hdr_ip_proto > 255) {
                 fprintf(stderr, "Bad argument for '-i': %s\n", optarg);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             hdr_ethernet = TRUE;
             hdr_ethernet_proto = 0x800;
@@ -1604,29 +1655,34 @@ parse_options (int argc, char *argv[])
             hdr_sctp_src   = (guint32)strtol(optarg, &p, 10);
             if (p == optarg || (*p != ',' && *p != '\0')) {
                 fprintf(stderr, "Bad src port for '-%c'\n", c);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             if (*p == '\0') {
                 fprintf(stderr, "No dest port specified for '-%c'\n", c);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             p++;
             optarg = p;
             hdr_sctp_dest = (guint32)strtol(optarg, &p, 10);
             if (p == optarg || (*p != ',' && *p != '\0')) {
                 fprintf(stderr, "Bad dest port for '-s'\n");
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             if (*p == '\0') {
                 fprintf(stderr, "No tag specified for '-%c'\n", c);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             p++;
             optarg = p;
             hdr_sctp_tag = (guint32)strtol(optarg, &p, 10);
             if (p == optarg || *p != '\0') {
                 fprintf(stderr, "Bad tag for '-%c'\n", c);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
 
             hdr_ip = TRUE;
@@ -1642,29 +1698,34 @@ parse_options (int argc, char *argv[])
             hdr_sctp_src   = (guint32)strtol(optarg, &p, 10);
             if (p == optarg || (*p != ',' && *p != '\0')) {
                 fprintf(stderr, "Bad src port for '-%c'\n", c);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             if (*p == '\0') {
                 fprintf(stderr, "No dest port specified for '-%c'\n", c);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             p++;
             optarg = p;
             hdr_sctp_dest = (guint32)strtol(optarg, &p, 10);
             if (p == optarg || (*p != ',' && *p != '\0')) {
                 fprintf(stderr, "Bad dest port for '-s'\n");
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             if (*p == '\0') {
                 fprintf(stderr, "No ppi specified for '-%c'\n", c);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             p++;
             optarg = p;
             hdr_data_chunk_ppid = (guint32)strtoul(optarg, &p, 10);
             if (p == optarg || *p != '\0') {
                 fprintf(stderr, "Bad ppi for '-%c'\n", c);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
 
             hdr_ip = TRUE;
@@ -1685,18 +1746,21 @@ parse_options (int argc, char *argv[])
             hdr_src_port = (guint32)strtol(optarg, &p, 10);
             if (p == optarg || (*p != ',' && *p != '\0')) {
                 fprintf(stderr, "Bad src port for '-u'\n");
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             if (*p == '\0') {
                 fprintf(stderr, "No dest port specified for '-u'\n");
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             p++;
             optarg = p;
             hdr_dest_port = (guint32)strtol(optarg, &p, 10);
             if (p == optarg || *p != '\0') {
                 fprintf(stderr, "Bad dest port for '-u'\n");
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             hdr_ip = TRUE;
             hdr_ip_proto = 17;
@@ -1712,18 +1776,21 @@ parse_options (int argc, char *argv[])
             hdr_src_port = (guint32)strtol(optarg, &p, 10);
             if (p == optarg || (*p != ',' && *p != '\0')) {
                 fprintf(stderr, "Bad src port for '-T'\n");
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             if (*p == '\0') {
                 fprintf(stderr, "No dest port specified for '-u'\n");
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             p++;
             optarg = p;
             hdr_dest_port = (guint32)strtol(optarg, &p, 10);
             if (p == optarg || *p != '\0') {
                 fprintf(stderr, "Bad dest port for '-T'\n");
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
             hdr_ip = TRUE;
             hdr_ip_proto = 6;
@@ -1736,7 +1803,9 @@ parse_options (int argc, char *argv[])
             break;
 
         case 'v':
-            print_version(stdout);
+            show_version(comp_info_str, runtime_info_str);
+            g_string_free(comp_info_str, TRUE);
+            g_string_free(runtime_info_str, TRUE);
             exit(0);
             break;
 
@@ -1746,7 +1815,8 @@ parse_options (int argc, char *argv[])
 
             if (!p) {
                 fprintf(stderr, "Bad source param addr for '-%c'\n", c);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
 
             *p = '\0';
@@ -1765,43 +1835,51 @@ parse_options (int argc, char *argv[])
             if (hdr_ipv6 == TRUE) {
                 if (inet_pton( AF_INET6, optarg, hdr_ipv6_src_addr) <= 0) {
                         fprintf(stderr, "Bad src addr -%c '%s'\n", c, p);
-                        usage(TRUE);
+                        print_usage(stderr);
+                        exit(1);
                 }
             } else {
                 if (inet_pton( AF_INET, optarg, &hdr_ip_src_addr) <= 0) {
                         fprintf(stderr, "Bad src addr -%c '%s'\n", c, p);
-                        usage(TRUE);
+                        print_usage(stderr);
+                        exit(1);
                 }
             }
 
             p++;
             if (*p == '\0') {
                 fprintf(stderr, "No dest addr specified for '-%c'\n", c);
-                usage(TRUE);
+                print_usage(stderr);
+                exit(1);
             }
 
             if (hdr_ipv6 == TRUE) {
                 if (inet_pton( AF_INET6, p, hdr_ipv6_dest_addr) <= 0) {
                         fprintf(stderr, "Bad dest addr for -%c '%s'\n", c, p);
-                        usage(TRUE);
+                        print_usage(stderr);
+                        exit(1);
                 }
             } else {
                 if (inet_pton( AF_INET, p, &hdr_ip_dest_addr) <= 0) {
                         fprintf(stderr, "Bad dest addr for -%c '%s'\n", c, p);
-                        usage(TRUE);
+                        print_usage(stderr);
+                        exit(1);
                 }
             }
             break;
 
 
+        case '?':
         default:
-            usage(TRUE);
+            print_usage(stderr);
+            exit(1);
         }
     }
 
     if (optind >= argc || argc-optind < 2) {
         fprintf(stderr, "Must specify input and output filename\n");
-        usage(TRUE);
+        print_usage(stderr);
+        exit(1);
     }
 
     if (strcmp(argv[optind], "-")) {
index 791e55c..e67dbd1 100644 (file)
--- a/tfshark.c
+++ b/tfshark.c
 # include <sys/stat.h>
 #endif
 
+#ifdef HAVE_LIBZ
+#include <zlib.h>      /* to get the libz version number */
+#endif
+
 #ifndef HAVE_GETOPT
 #include "wsutil/wsgetopt.h"
 #endif
@@ -745,6 +749,34 @@ show_version(GString *comp_info_str, GString *runtime_info_str)
          runtime_info_str->str);
 }
 
+static void
+get_tfshark_compiled_version_info(GString *str)
+{
+       /* LIBZ */
+#ifdef HAVE_LIBZ
+       g_string_append(str, "with libz ");
+#ifdef ZLIB_VERSION
+       g_string_append(str, ZLIB_VERSION);
+#else /* ZLIB_VERSION */
+       g_string_append(str, "(version unknown)");
+#endif /* ZLIB_VERSION */
+#else /* HAVE_LIBZ */
+       g_string_append(str, "without libz");
+#endif /* HAVE_LIBZ */
+}
+
+static void
+get_tfshark_runtime_version_info(GString *str)
+{
+    /* zlib */
+#if defined(HAVE_LIBZ) && !defined(_WIN32)
+    g_string_append_printf(str, ", with libz %s", zlibVersion());
+#endif
+
+    /* stuff used by libwireshark */
+    epan_get_runtime_version_info(str);
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -817,11 +849,12 @@ main(int argc, char *argv[])
 
   /* Assemble the compile-time version information string */
   comp_info_str = g_string_new("Compiled ");
-  get_compiled_version_info(comp_info_str, NULL, epan_get_compiled_version_info);
+  get_compiled_version_info(comp_info_str, get_tfshark_compiled_version_info,
+                            epan_get_compiled_version_info);
 
   /* Assemble the run-time version information string */
   runtime_info_str = g_string_new("Running ");
-  get_runtime_version_info(runtime_info_str, NULL);
+  get_runtime_version_info(runtime_info_str, get_tfshark_runtime_version_info);
 
   /* Add it to the information to be reported on a crash. */
   ws_add_crash_info("TFShark (Wireshark) %s\n"
index cbc5a59..cebbd08 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -901,12 +901,67 @@ show_version(GString *comp_info_str, GString *runtime_info_str)
          "%s"
          "\n"
          "%s",
-         get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str,
-         runtime_info_str->str);
+         get_ws_vcs_version_info(), get_copyright_info(),
+         comp_info_str->str, runtime_info_str->str);
 }
 
 static void
-get_tshark_runtime_info(GString *str)
+get_tshark_compiled_version_info(GString *str)
+{
+       /* Libpcap */
+       get_compiled_pcap_version(str);
+
+       /* LIBZ */
+       g_string_append(str, ", ");
+#ifdef HAVE_LIBZ
+       g_string_append(str, "with libz ");
+#ifdef ZLIB_VERSION
+       g_string_append(str, ZLIB_VERSION);
+#else /* ZLIB_VERSION */
+       g_string_append(str, "(version unknown)");
+#endif /* ZLIB_VERSION */
+#else /* HAVE_LIBZ */
+       g_string_append(str, "without libz");
+#endif /* HAVE_LIBZ */
+
+       /*
+        * XXX - these libraries are actually used only by dumpcap,
+        * but we mention them here so that a user reporting a bug
+        * can get information about dumpcap's libraries without
+        * having to run dumpcap.
+        */
+#ifndef _WIN32
+       /* This is UN*X-only. */
+       /* LIBCAP */
+       g_string_append(str, ", ");
+#ifdef HAVE_LIBCAP
+       g_string_append(str, "with POSIX capabilities");
+#ifdef _LINUX_CAPABILITY_VERSION
+       g_string_append(str, " (Linux)");
+#endif /* _LINUX_CAPABILITY_VERSION */
+#else /* HAVE_LIBCAP */
+       g_string_append(str, "without POSIX capabilities");
+#endif /* HAVE_LIBCAP */
+#endif /* _WIN32 */
+
+#ifdef __linux__
+       /* This is a Linux-specific library. */
+       /* LIBNL */
+       g_string_append(str, ", ");
+#if defined(HAVE_LIBNL1)
+       g_string_append(str, "with libnl 1");
+#elif defined(HAVE_LIBNL2)
+       g_string_append(str, "with libnl 2");
+#elif defined(HAVE_LIBNL3)
+       g_string_append(str, "with libnl 3");
+#else /* no libnl */
+       g_string_append(str, "without libnl");
+#endif /* libnl version */
+#endif /* __linux__ */
+}
+
+static void
+get_tshark_runtime_version_info(GString *str)
 {
 #ifdef HAVE_LIBPCAP
     /* Libpcap */
@@ -1031,11 +1086,12 @@ main(int argc, char *argv[])
 
   /* Assemble the compile-time version information string */
   comp_info_str = g_string_new("Compiled ");
-  get_compiled_version_info(comp_info_str, NULL, epan_get_compiled_version_info);
+  get_compiled_version_info(comp_info_str, get_tshark_compiled_version_info,
+                            epan_get_compiled_version_info);
 
   /* Assemble the run-time version information string */
   runtime_info_str = g_string_new("Running ");
-  get_runtime_version_info(runtime_info_str, get_tshark_runtime_info);
+  get_runtime_version_info(runtime_info_str, get_tshark_runtime_version_info);
 
   /* Add it to the information to be reported on a crash. */
   ws_add_crash_info("TShark (Wireshark) %s\n"
index 8d6b6de..77286dd 100644 (file)
@@ -1896,7 +1896,7 @@ main_capture_callback(gint event, capture_session *cap_session, gpointer user_da
 #endif
 
 static void
-get_gtk_compiled_info(GString *str)
+get_wireshark_gtk_compiled_info(GString *str)
 {
     g_string_append(str, "with ");
     g_string_append_printf(str,
@@ -1906,17 +1906,66 @@ get_gtk_compiled_info(GString *str)
 #else
                            "GTK+ (version unknown)");
 #endif
-    g_string_append(str, ", ");
+
     /* Cairo */
-    g_string_append(str, "with Cairo ");
+    g_string_append(str, "with Cairo ");
     g_string_append(str, CAIRO_VERSION_STRING);
-    g_string_append(str, ", ");
 
     /* Pango */
-    g_string_append(str, "with Pango ");
+    g_string_append(str, "with Pango ");
     g_string_append(str, PANGO_VERSION_STRING);
+
+    /* Libpcap */
+    g_string_append(str, ", ");
+    get_compiled_pcap_version(str);
+
+    /* LIBZ */
     g_string_append(str, ", ");
+#ifdef HAVE_LIBZ
+    g_string_append(str, "with libz ");
+#ifdef ZLIB_VERSION
+    g_string_append(str, ZLIB_VERSION);
+#else /* ZLIB_VERSION */
+    g_string_append(str, "(version unknown)");
+#endif /* ZLIB_VERSION */
+#else /* HAVE_LIBZ */
+    g_string_append(str, "without libz");
+#endif /* HAVE_LIBZ */
 
+    /*
+     * XXX - these libraries are actually used only by dumpcap,
+     * but we mention them here so that a user reporting a bug
+     * can get information about dumpcap's libraries without
+     * having to run dumpcap.
+     */
+#ifndef _WIN32
+    /* This is UN*X-only. */
+    /* LIBCAP */
+    g_string_append(str, ", ");
+#ifdef HAVE_LIBCAP
+    g_string_append(str, "with POSIX capabilities");
+#ifdef _LINUX_CAPABILITY_VERSION
+    g_string_append(str, " (Linux)");
+#endif /* _LINUX_CAPABILITY_VERSION */
+#else /* HAVE_LIBCAP */
+    g_string_append(str, "without POSIX capabilities");
+#endif /* HAVE_LIBCAP */
+#endif /* _WIN32 */
+
+#ifdef __linux__
+    /* This is a Linux-specific library. */
+    /* LIBNL */
+    g_string_append(str, ", ");
+#if defined(HAVE_LIBNL1)
+    g_string_append(str, "with libnl 1");
+#elif defined(HAVE_LIBNL2)
+    g_string_append(str, "with libnl 2");
+#elif defined(HAVE_LIBNL3)
+    g_string_append(str, "with libnl 3");
+#else /* no libnl */
+    g_string_append(str, "without libnl");
+#endif /* libnl version */
+#endif /* __linux__ */
 }
 
 static void
@@ -2256,7 +2305,8 @@ main(int argc, char *argv[])
     /* Assemble the compile-time version information string */
     comp_info_str = g_string_new("Compiled ");
 
-    get_compiled_version_info(comp_info_str, get_gtk_compiled_info, get_gui_compiled_info);
+    get_compiled_version_info(comp_info_str, get_wireshark_gtk_compiled_info,
+                              get_gui_compiled_info);
 
     /* Assemble the run-time version information string */
     runtime_info_str = g_string_new("Running ");
index 0569377..e6804ea 100644 (file)
@@ -395,15 +395,67 @@ console_log_handler(const char *log_domain, GLogLevelFlags log_level,
 
 // xxx based from ../gtk/main.c:get_gtk_compiled_info
 static void
-get_qt_compiled_info(GString *str)
+get_wireshark_qt_compiled_info(GString *str)
 {
     g_string_append(str, "with ");
     g_string_append_printf(str,
 #ifdef QT_VERSION
-                    "Qt %s ", QT_VERSION_STR);
+                    "Qt %s", QT_VERSION_STR);
 #else
-                    "Qt (version unknown) ");
+                    "Qt (version unknown)");
 #endif
+
+    /* Libpcap */
+    g_string_append(str, ", ");
+    get_compiled_pcap_version(str);
+
+    /* LIBZ */
+    g_string_append(str, ", ");
+#ifdef HAVE_LIBZ
+    g_string_append(str, "with libz ");
+#ifdef ZLIB_VERSION
+    g_string_append(str, ZLIB_VERSION);
+#else /* ZLIB_VERSION */
+    g_string_append(str, "(version unknown)");
+#endif /* ZLIB_VERSION */
+#else /* HAVE_LIBZ */
+    g_string_append(str, "without libz");
+#endif /* HAVE_LIBZ */
+
+    /*
+     * XXX - these libraries are actually used only by dumpcap,
+     * but we mention them here so that a user reporting a bug
+     * can get information about dumpcap's libraries without
+     * having to run dumpcap.
+     */
+#ifndef _WIN32
+    /* This is UN*X-only. */
+    /* LIBCAP */
+    g_string_append(str, ", ");
+#ifdef HAVE_LIBCAP
+    g_string_append(str, "with POSIX capabilities");
+#ifdef _LINUX_CAPABILITY_VERSION
+    g_string_append(str, " (Linux)");
+#endif /* _LINUX_CAPABILITY_VERSION */
+#else /* HAVE_LIBCAP */
+    g_string_append(str, "without POSIX capabilities");
+#endif /* HAVE_LIBCAP */
+#endif /* _WIN32 */
+
+#ifdef __linux__
+    /* This is a Linux-specific library. */
+    /* LIBNL */
+    g_string_append(str, ", ");
+#if defined(HAVE_LIBNL1)
+    g_string_append(str, "with libnl 1");
+#elif defined(HAVE_LIBNL2)
+    g_string_append(str, "with libnl 2");
+#elif defined(HAVE_LIBNL3)
+    g_string_append(str, "with libnl 3");
+#else /* no libnl */
+    g_string_append(str, "without libnl");
+#endif /* libnl version */
+#endif /* __linux__ */
 }
 
 // xxx copied from ../gtk/main.c
@@ -593,7 +645,8 @@ int main(int argc, char *argv[])
     comp_info_str = g_string_new("Compiled ");
 
     // xxx qtshark
-    get_compiled_version_info(comp_info_str, get_qt_compiled_info, get_gui_compiled_info);
+    get_compiled_version_info(comp_info_str, get_wireshark_qt_compiled_info,
+                              get_gui_compiled_info);
 
     /* Assemble the run-time version information string */
     runtime_info_str = g_string_new("Running ");
index 888d7ea..860fd17 100644 (file)
@@ -90,8 +90,10 @@ get_compiled_version_info(GString *str, void (*prepend_info)(GString *),
        else
                g_string_append(str, "(64-bit) ");
 
-       if (prepend_info)
+       if (prepend_info) {
                (*prepend_info)(str);
+               g_string_append(str, ", ");
+       }
 
        /* GLIB */
        g_string_append(str, "with ");
@@ -103,52 +105,6 @@ get_compiled_version_info(GString *str, void (*prepend_info)(GString *),
            "GLib (version unknown)");
 #endif
 
-       /* Libpcap */
-       g_string_append(str, ", ");
-       get_compiled_pcap_version(str);
-
-       /* LIBZ */
-       g_string_append(str, ", ");
-#ifdef HAVE_LIBZ
-       g_string_append(str, "with libz ");
-#ifdef ZLIB_VERSION
-       g_string_append(str, ZLIB_VERSION);
-#else /* ZLIB_VERSION */
-       g_string_append(str, "(version unknown)");
-#endif /* ZLIB_VERSION */
-#else /* HAVE_LIBZ */
-       g_string_append(str, "without libz");
-#endif /* HAVE_LIBZ */
-
-#ifndef _WIN32
-       /* This is UN*X-only. */
-       /* LIBCAP */
-       g_string_append(str, ", ");
-#ifdef HAVE_LIBCAP
-       g_string_append(str, "with POSIX capabilities");
-#ifdef _LINUX_CAPABILITY_VERSION
-       g_string_append(str, " (Linux)");
-#endif /* _LINUX_CAPABILITY_VERSION */
-#else /* HAVE_LIBCAP */
-       g_string_append(str, "without POSIX capabilities");
-#endif /* HAVE_LIBCAP */
-#endif /* _WIN32 */
-
-#ifdef __linux__
-       /* This is a Linux-specific library. */
-       /* LIBNL */
-       g_string_append(str, ", ");
-#if defined(HAVE_LIBNL1)
-       g_string_append(str, "with libnl 1");
-#elif defined(HAVE_LIBNL2)
-       g_string_append(str, "with libnl 2");
-#elif defined(HAVE_LIBNL3)
-       g_string_append(str, "with libnl 3");
-#else /* no libnl */
-       g_string_append(str, "without libnl");
-#endif /* libnl version */
-#endif /* __linux__ */
-
        /* Additional application-dependent information */
        if (append_info)
                (*append_info)(str);