diff options
author | Lars Roland <Lars.Roland@gmx.net> | 2005-03-05 06:28:10 +0000 |
---|---|---|
committer | Lars Roland <Lars.Roland@gmx.net> | 2005-03-05 06:28:10 +0000 |
commit | 00273300e721999ac67a4ce66dab80fed6a1314f (patch) | |
tree | ac2c8b87fdd4dc989c3ef1d3b646f7700ba7626c /epan/plugins.c | |
parent | 1a7b3ec1439203e3bea3381dfb31b4357758b4c3 (diff) | |
download | wireshark-00273300e721999ac67a4ce66dab80fed6a1314f.tar.gz |
Preparations for dropping the old plugin api.
Introduce a new init routine for plugins,
which does not take the plugin api table as an
argument and allows etheral to distinguish
between plugins using the old and the new api.
Update README.plugins accordingly
Change all g_warnings() in epan/plugins.c to report_failue().
On windows we do not have a log console open while
loading the plugins, because a log console cannot be opened before the prefs have been read. Thus g_warnings()
does not work for reporting problems with plugins.
svn path=/trunk/; revision=13596
Diffstat (limited to 'epan/plugins.c')
-rw-r--r-- | epan/plugins.c | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/epan/plugins.c b/epan/plugins.c index 72e05fc305..96f56911e5 100644 --- a/epan/plugins.c +++ b/epan/plugins.c @@ -171,6 +171,7 @@ plugins_scan_dir(const char *dirname) gchar *version; gpointer gp; void (*init)(void *); + void (*newinit)(void) = NULL; void (*reg_handoff)(void); void (*register_tap_listener)(void); gchar *dot; @@ -232,29 +233,49 @@ plugins_scan_dir(const char *dirname) #endif if ((handle = g_module_open(filename, 0)) == NULL) { - g_warning("Couldn't load module %s: %s", filename, + report_failure("Couldn't load module %s: %s", filename, g_module_error()); continue; } if (!g_module_symbol(handle, "version", &gp)) { - g_warning("The plugin %s has no version symbol", name); + report_failure("The plugin %s has no version symbol", name); g_module_close(handle); continue; } version = gp; - + /* * We require the plugin to have a "plugin_init()" routine. */ - if (!g_module_symbol(handle, "plugin_init", &gp)) + if (g_module_symbol(handle, "new_plugin_init", &gp)) { - g_warning("The plugin %s has no plugin_init routine", - name); - g_module_close(handle); - continue; + /* + * We have a new init routine which does not need the + * plugin api table. + */ + newinit = gp; + } else + { + newinit = NULL; + if (!g_module_symbol(handle, "plugin_init", &gp)) + { + /* + * We don't have an init routine. Close the plugin. + */ + report_failure("The plugin %s has no plugin_init routine", + name); + g_module_close(handle); + continue; + } + /* + * We have an old init routine. Throw a warning that + * support is going to be dropped. + */ + report_failure("The plugin %s has an old plugin init routine.\nSupport is going to be dropped in the near future.", + name); + init = gp; } - init = gp; /* * Do we have a reg_handoff routine? @@ -300,7 +321,7 @@ plugins_scan_dir(const char *dirname) /* * No. */ - g_warning("The plugin %s has neither a reg_handoff nor a register_tap_listener routine", + report_failure("The plugin %s has neither a reg_handoff nor a register_tap_listener routine", name); g_module_close(handle); continue; @@ -326,11 +347,17 @@ plugins_scan_dir(const char *dirname) /* * Call its init routine. */ + if(newinit != NULL) { + newinit(); + } + else + { #ifdef PLUGINS_NEED_ADDRESS_TABLE - init(&patable); + init(&patable); #else - init(NULL); + init(NULL); #endif + } } #if GLIB_MAJOR_VERSION < 2 closedir(dir); |