diff options
author | Michael Mann <mmann78@netscape.net> | 2016-03-02 09:13:08 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-03-03 17:02:10 +0000 |
commit | d7de3515db98a7444fe527c82de43bfaf550b698 (patch) | |
tree | 646ad2af6362088bdad5eb110957294aec0ea779 /mergecap.c | |
parent | 28b76dbb9e3b7f1c4469fcb20d60371888fa7c00 (diff) |
Refactor wiretap option block types into a registration system.
Also required mergecap to look for plugins to initialize wiretap option blocks.
Change-Id: I4208d1028dd0f94f185393801d72025329266cb7
Reviewed-on: https://code.wireshark.org/review/14300
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'mergecap.c')
-rw-r--r-- | mergecap.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/mergecap.c b/mergecap.c index 5c27447c0c..cfcc1a6d73 100644 --- a/mergecap.c +++ b/mergecap.c @@ -49,11 +49,18 @@ #include <wsutil/clopts_common.h> #include <wsutil/cmdarg_err.h> #include <wsutil/crash_info.h> +#include <wsutil/filesystem.h> #include <wsutil/file_util.h> #include <wsutil/strnatcmp.h> #include <wsutil/ws_diag_control.h> #include <wsutil/ws_version_info.h> +#ifdef HAVE_PLUGINS +#include <wsutil/plugins.h> +#endif + +#include <wsutil/report_err.h> + #include <wiretap/merge.h> #include <wiretap/pcap-encap.h> @@ -125,6 +132,19 @@ string_elem_print(gpointer data, gpointer not_used _U_) ((struct string_elem *)data)->lstr); } +#ifdef HAVE_PLUGINS +/* + * Don't report failures to load plugins because most (non-wiretap) plugins + * *should* fail to load (because we're not linked against libwireshark and + * dissector plugins need libwireshark). + */ +static void +failure_message(const char *msg_format _U_, va_list ap _U_) +{ + return; +} +#endif + static void list_capture_types(void) { int i; @@ -279,6 +299,10 @@ main(int argc, char *argv[]) gboolean use_stdout = FALSE; merge_progress_callback_t cb; +#ifdef HAVE_PLUGINS + char *init_progfile_dir_error; +#endif + cmdarg_err_init(mergecap_cmdarg_err, mergecap_cmdarg_err_cont); #ifdef _WIN32 @@ -300,6 +324,25 @@ main(int argc, char *argv[]) "%s", get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str); +#ifdef HAVE_PLUGINS + if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) { + g_warning("captype: init_progfile_dir(): %s", init_progfile_dir_error); + g_free(init_progfile_dir_error); + } else { + /* Register all the plugin types we have. */ + wtap_register_plugin_types(); /* Types known to libwiretap */ + + init_report_err(failure_message,NULL,NULL,NULL); + + /* Scan for plugins. This does *not* call their registration routines; + that's done later. */ + scan_plugins(); + + /* Register all libwiretap plugin modules. */ + register_all_wiretap_modules(); + } +#endif + /* Process the options first */ while ((opt = getopt_long(argc, argv, "aF:hI:s:vVw:", long_options, NULL)) != -1) { |