From f95976eefcbeb5d24df383c29d29ef888b503945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Fri, 1 Apr 2016 01:16:15 +0100 Subject: [PATCH] Move zlib version check to wsutil MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0950f61e90af5bb21c0017204de0c0b509616e5c Reviewed-on: https://code.wireshark.org/review/14747 Petri-Dish: João Valverde Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- capinfos.c | 39 ++------------------------------------- captype.c | 39 ++------------------------------------- dumpcap.c | 22 ---------------------- editcap.c | 39 ++------------------------------------- mergecap.c | 40 ++-------------------------------------- reordercap.c | 39 ++------------------------------------- text2pcap.c | 34 ++-------------------------------- tfshark.c | 28 +--------------------------- tshark.c | 22 ---------------------- ui/gtk/main.c | 22 ---------------------- wireshark-qt.cpp | 22 ---------------------- wsutil/ws_version_info.c | 25 +++++++++++++++++++++++++ 12 files changed, 38 insertions(+), 333 deletions(-) diff --git a/capinfos.c b/capinfos.c index e75e70e1ec..2476a62a18 100644 --- a/capinfos.c +++ b/capinfos.c @@ -69,10 +69,6 @@ #include -#ifdef HAVE_LIBZ -#include /* to get the libz version number */ -#endif - #include #include @@ -1366,37 +1362,6 @@ 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( -#if defined(HAVE_LIBZ) && !defined(_WIN32) - GString *str) -#else - GString *str _U_) -#endif -{ - /* zlib */ -#if defined(HAVE_LIBZ) && !defined(_WIN32) - g_string_append_printf(str, ", with libz %s", zlibVersion()); -#endif -} - int main(int argc, char *argv[]) { @@ -1428,10 +1393,10 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); /* Get the compile-time version information string */ - comp_info_str = get_compiled_version_info(NULL, get_capinfos_compiled_info); + comp_info_str = get_compiled_version_info(NULL, NULL); /* Get the run-time version information string */ - runtime_info_str = get_runtime_version_info(get_capinfos_runtime_info); + runtime_info_str = get_runtime_version_info(NULL); /* Add it to the information to be reported on a crash. */ ws_add_crash_info("Capinfos (Wireshark) %s\n" diff --git a/captype.c b/captype.c index 1390f0ce06..f41f0a22a3 100644 --- a/captype.c +++ b/captype.c @@ -36,10 +36,6 @@ #include #endif -#ifdef HAVE_LIBZ -#include /* to get the libz version number */ -#endif - #include #include @@ -86,37 +82,6 @@ failure_message(const char *msg_format _U_, va_list ap _U_) } #endif -static void -get_captype_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_captype_runtime_info( -#if defined(HAVE_LIBZ) && !defined(_WIN32) - GString *str) -#else - GString *str _U_) -#endif -{ - /* zlib */ -#if defined(HAVE_LIBZ) && !defined(_WIN32) - g_string_append_printf(str, ", with libz %s", zlibVersion()); -#endif -} - int main(int argc, char *argv[]) { @@ -142,10 +107,10 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); /* Get the compile-time version information string */ - comp_info_str = get_compiled_version_info(NULL, get_captype_compiled_info); + comp_info_str = get_compiled_version_info(NULL, NULL); /* Get the run-time version information string */ - runtime_info_str = get_runtime_version_info(get_captype_runtime_info); + runtime_info_str = get_runtime_version_info(NULL); /* Add it to the information to be reported on a crash. */ ws_add_crash_info("Captype (Wireshark) %s\n" diff --git a/dumpcap.c b/dumpcap.c index ccb297ddde..2d2d4d61a9 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -54,10 +54,6 @@ #include #include -#ifdef HAVE_LIBZ -#include /* to get the libz version number */ -#endif - #include #include #include @@ -3706,19 +3702,6 @@ get_dumpcap_compiled_info(GString *str) /* Capture libraries */ g_string_append(str, ", "); get_compiled_caplibs_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 */ } static void @@ -3727,11 +3710,6 @@ get_dumpcap_runtime_info(GString *str) /* Capture libraries */ g_string_append(str, ", "); get_runtime_caplibs_version(str); - - /* zlib */ -#if defined(HAVE_LIBZ) && !defined(_WIN32) - g_string_append_printf(str, ", with libz %s", zlibVersion()); -#endif } /* And now our feature presentation... [ fade to music ] */ diff --git a/editcap.c b/editcap.c index bf2270fb4f..4927e4ecaf 100644 --- a/editcap.c +++ b/editcap.c @@ -54,10 +54,6 @@ #include #endif -#ifdef HAVE_LIBZ -#include /* to get the libz version number */ -#endif - #include #include "epan/etypes.h" @@ -908,37 +904,6 @@ 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( -#if defined(HAVE_LIBZ) && !defined(_WIN32) - GString *str) -#else - GString *str _U_) -#endif -{ - /* zlib */ -#if defined(HAVE_LIBZ) && !defined(_WIN32) - g_string_append_printf(str, ", with libz %s", zlibVersion()); -#endif -} - static wtap_dumper * editcap_dump_open(const char *filename, guint32 snaplen, wtap_optionblock_t shb_hdr, @@ -1017,10 +982,10 @@ main(int argc, char *argv[]) #endif /* _WIN32 */ /* Get the compile-time version information string */ - comp_info_str = get_compiled_version_info(NULL, get_editcap_compiled_info); + comp_info_str = get_compiled_version_info(NULL, NULL); /* Get the run-time version information string */ - runtime_info_str = get_runtime_version_info(get_editcap_runtime_info); + runtime_info_str = get_runtime_version_info(NULL); /* Add it to the information to be reported on a crash. */ ws_add_crash_info("Editcap (Wireshark) %s\n" diff --git a/mergecap.c b/mergecap.c index f6fad775e3..3e93ea592a 100644 --- a/mergecap.c +++ b/mergecap.c @@ -34,10 +34,6 @@ #include #endif -#ifdef HAVE_LIBZ -#include /* to get the libz version number */ -#endif - #include #include @@ -177,38 +173,6 @@ list_idb_merge_modes(void) { } } -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( -#if defined(HAVE_LIBZ) && !defined(_WIN32) - GString *str) -#else - GString *str _U_) -#endif -{ - /* zlib */ -#if defined(HAVE_LIBZ) && !defined(_WIN32) - g_string_append_printf(str, ", with libz %s", zlibVersion()); -#endif -} - - static gboolean merge_callback(merge_event event, int num, const merge_in_file_t in_files[], const guint in_file_count, @@ -317,10 +281,10 @@ main(int argc, char *argv[]) #endif /* _WIN32 */ /* Get the compile-time version information string */ - comp_info_str = get_compiled_version_info(NULL, get_mergecap_compiled_info); + comp_info_str = get_compiled_version_info(NULL, NULL); /* Get the run-time version information string */ - runtime_info_str = get_runtime_version_info(get_mergecap_runtime_info); + runtime_info_str = get_runtime_version_info(NULL); /* Add it to the information to be reported on a crash. */ ws_add_crash_info("Mergecap (Wireshark) %s\n" diff --git a/reordercap.c b/reordercap.c index 4b226e2251..983e13c283 100644 --- a/reordercap.c +++ b/reordercap.c @@ -32,10 +32,6 @@ #include #endif -#ifdef HAVE_LIBZ -#include /* to get the libz version number */ -#endif - #include #ifndef HAVE_GETOPT_LONG @@ -151,37 +147,6 @@ 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( -#if defined(HAVE_LIBZ) && !defined(_WIN32) - GString *str) -#else - GString *str _U_) -#endif -{ - /* zlib */ -#if defined(HAVE_LIBZ) && !defined(_WIN32) - g_string_append_printf(str, ", with libz %s", zlibVersion()); -#endif -} - #ifdef HAVE_PLUGINS /* * Don't report failures to load plugins because most (non-wiretap) plugins @@ -236,10 +201,10 @@ main(int argc, char *argv[]) #endif /* Get the compile-time version information string */ - comp_info_str = get_compiled_version_info(NULL, get_reordercap_compiled_info); + comp_info_str = get_compiled_version_info(NULL, NULL); /* Get the run-time version information string */ - runtime_info_str = get_runtime_version_info(get_reordercap_runtime_info); + runtime_info_str = get_runtime_version_info(NULL); /* Add it to the information to be reported on a crash. */ ws_add_crash_info("Reordercap (Wireshark) %s\n" diff --git a/text2pcap.c b/text2pcap.c index e50dad30b6..fc6b7d4e6b 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -126,10 +126,6 @@ #include #include -#ifdef HAVE_LIBZ -#include /* to get the libz version number */ -#endif - #ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif @@ -1438,32 +1434,6 @@ print_usage (FILE *output) MAX_PACKET); } -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 -} - /*---------------------------------------------------------------------- * Parse CLI options */ @@ -1486,10 +1456,10 @@ parse_options (int argc, char *argv[]) #endif /* _WIN32 */ /* Get the compile-time version information string */ - comp_info_str = get_compiled_version_info(NULL, get_text2pcap_compiled_info); + comp_info_str = get_compiled_version_info(NULL, NULL); /* get the run-time version information string */ - runtime_info_str = get_runtime_version_info(get_text2pcap_runtime_info); + runtime_info_str = get_runtime_version_info(NULL); /* Add it to the information to be reported on a crash. */ ws_add_crash_info("Text2pcap (Wireshark) %s\n" diff --git a/tfshark.c b/tfshark.c index fea110c1e5..595917cf8a 100644 --- a/tfshark.c +++ b/tfshark.c @@ -35,10 +35,6 @@ #include -#ifdef HAVE_LIBZ -#include /* to get the libz version number */ -#endif - #ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif @@ -726,30 +722,9 @@ print_current_user(void) { } } -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); } @@ -844,8 +819,7 @@ main(int argc, char *argv[]) initialize_funnel_ops(); /* Get the compile-time version information string */ - comp_info_str = get_compiled_version_info(get_tfshark_compiled_version_info, - epan_get_compiled_version_info); + comp_info_str = get_compiled_version_info(NULL, epan_get_compiled_version_info); /* Get the run-time version information string */ runtime_info_str = get_runtime_version_info(get_tfshark_runtime_version_info); diff --git a/tshark.c b/tshark.c index df41600762..7407e82ea8 100644 --- a/tshark.c +++ b/tshark.c @@ -40,10 +40,6 @@ #include #endif -#ifdef HAVE_LIBZ -#include /* to get the libz version number */ -#endif - #ifdef HAVE_LIBCAP # include #endif @@ -921,19 +917,6 @@ get_tshark_compiled_version_info(GString *str) { /* Capture libraries */ get_compiled_caplibs_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 */ } static void @@ -945,11 +928,6 @@ get_tshark_runtime_version_info(GString *str) get_runtime_caplibs_version(str); #endif - /* 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); } diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 1a4e53383d..efd56f7748 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -44,10 +44,6 @@ #include "wsutil/wsgetopt.h" #endif -#ifdef HAVE_LIBZ -#include /* to get the libz version number */ -#endif - #ifdef HAVE_EXTCAP #include #endif @@ -1969,19 +1965,6 @@ get_wireshark_gtk_compiled_info(GString *str) /* Capture libraries */ g_string_append(str, ", "); get_compiled_caplibs_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 */ } static void @@ -2018,11 +2001,6 @@ get_wireshark_runtime_info(GString *str) get_runtime_caplibs_version(str); #endif - /* 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); diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp index ec2d74b4f2..5c474a69bc 100644 --- a/wireshark-qt.cpp +++ b/wireshark-qt.cpp @@ -27,10 +27,6 @@ #include #endif -#ifdef HAVE_LIBZ -#include /* to get the libz version number */ -#endif - #ifdef HAVE_GETOPT_H #include #endif @@ -311,19 +307,6 @@ get_wireshark_qt_compiled_info(GString *str) /* Capture libraries */ g_string_append(str, ", "); get_compiled_caplibs_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 copied from ../gtk/main.c @@ -357,11 +340,6 @@ get_wireshark_runtime_info(GString *str) get_runtime_caplibs_version(str); #endif - /* 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); diff --git a/wsutil/ws_version_info.c b/wsutil/ws_version_info.c index 8298e8226e..e479ab1942 100644 --- a/wsutil/ws_version_info.c +++ b/wsutil/ws_version_info.c @@ -33,6 +33,10 @@ #include +#ifdef HAVE_LIBZ +#include +#endif + #include "version.h" #include @@ -71,6 +75,20 @@ end_string(GString *str) } } +static const gchar * +get_zlib_compiled_version_info(void) +{ +#ifdef HAVE_LIBZ +#ifdef ZLIB_VERSION + return "with libz "ZLIB_VERSION; +#else + return "with libz (version unknown)"; +#endif /* ZLIB_VERSION */ +#else + return "without libz"; +#endif /* HAVE_LIBZ */ +} + /* * Get various library compile-time versions, put them in a GString, * and return the GString. @@ -112,6 +130,8 @@ get_compiled_version_info(void (*prepend_info)(GString *), "GLib (version unknown)"); #endif + g_string_append_printf(str, ", %s", get_zlib_compiled_version_info()); + /* Additional application-dependent information */ if (append_info) (*append_info)(str); @@ -334,6 +354,11 @@ get_runtime_version_info(void (*additional_info)(GString *)) if (additional_info) (*additional_info)(str); + /* zlib */ +#if defined(HAVE_LIBZ) && !defined(_WIN32) + g_string_append_printf(str, ", with libz %s", zlibVersion()); +#endif + g_string_append(str, "."); /* CPU Info */