From d7de3515db98a7444fe527c82de43bfaf550b698 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Wed, 2 Mar 2016 09:13:08 -0500 Subject: 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 Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- mergecap.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'mergecap.c') diff --git a/mergecap.c b/mergecap.c index 5c27447c0c..cfcc1a6d73 100644 --- a/mergecap.c +++ b/mergecap.c @@ -49,11 +49,18 @@ #include #include #include +#include #include #include #include #include +#ifdef HAVE_PLUGINS +#include +#endif + +#include + #include #include @@ -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) { -- cgit v1.2.1