static int
add_plugin(void *handle, gchar *name, gchar *version,
void (*register_protoinfo)(void), void (*reg_handoff)(void),
- void (*register_tap_listener)(void))
+ void (*register_tap_listener)(void),
+ void (*register_wtap_module)(void),
+ void (*register_codec_module)(void))
{
plugin *new_plug, *pt_plug;
new_plug->register_protoinfo = register_protoinfo;
new_plug->reg_handoff = reg_handoff;
new_plug->register_tap_listener = register_tap_listener;
+ new_plug->register_wtap_module = register_wtap_module;
+ new_plug->register_codec_module = register_codec_module;
new_plug->next = NULL;
+
return 0;
}
void (*register_protoinfo)(void);
void (*reg_handoff)(void);
void (*register_tap_listener)(void);
+ void (*register_wtap_module)(void);
+ void (*register_codec_module)(void);
+
gchar *dot;
int cr;
if ((dir = eth_dir_open(dirname, 0, NULL)) != NULL)
{
+
while ((file = eth_dir_read_name(dir)) != NULL)
{
name = eth_dir_get_name(file);
+
#if GLIB_MAJOR_VERSION < 2
/* don't try to open "." and ".." */
if (!(strcmp(name, "..") &&
g_module_error());
continue;
}
+
if (!g_module_symbol(handle, "version", &gp))
{
report_failure("The plugin %s has no version symbol", name);
register_tap_listener = NULL;
}
- /*
+ /*
* Do we have an old-style init routine?
*/
if (g_module_symbol(handle, "plugin_init", &gp))
{
- /*
- * Yes - do we also have a register routine or a
- * register_tap_listener routine? If so, this is a bogus
- * hybrid of an old-style and new-style plugin.
- */
- if (register_protoinfo != NULL || register_tap_listener != NULL)
- {
- report_failure("The plugin %s has an old plugin init routine\nand a new register or register_tap_listener routine.",
- name);
- g_module_close(handle);
- continue;
- }
+ /*
+ * Yes - do we also have a register routine or a
+ * register_tap_listener routine? If so, this is a bogus
+ * hybrid of an old-style and new-style plugin.
+ */
+ if (register_protoinfo != NULL || register_tap_listener != NULL)
+ {
+ report_failure("The plugin '%s' has an old plugin init routine\nand a new register or register_tap_listener routine.",
+ name);
+ g_module_close(handle);
+ continue;
+ }
- /*
- * It's just an unsupported old-style plugin;
- */
- report_failure("The plugin %s has an old plugin init routine. Support has been dropped.\n Information on how to update your plugin is available at \nhttp://anonsvn.wireshark.org/wireshark/trunk/doc/README.plugins",
- name);
- g_module_close(handle);
- continue;
+ /*
+ * It's just an unsupported old-style plugin;
+ */
+ report_failure("The plugin '%s' has an old plugin init routine. Support has been dropped.\n Information on how to update your plugin is available at \nhttp://anonsvn.wireshark.org/wireshark/trunk/doc/README.plugins",
+ name);
+ g_module_close(handle);
+ continue;
}
-
+
/*
- * Does this dissector do anything useful?
- */
+ * Do we have a register_wtap_module routine?
+ */
+ if (g_module_symbol(handle, "register_wtap_module", &gp))
+ {
+ register_wtap_module = gp;
+ } else {
+ register_wtap_module = NULL;
+ }
+
+ /*
+ * Do we have a register_codec_module routine?
+ */
+ if (g_module_symbol(handle, "register_codec_module", &gp))
+ {
+ register_codec_module = gp;
+ } else {
+ register_codec_module = NULL;
+ }
+
+ /*
+ * Does this dissector do anything useful?
+ */
if (register_protoinfo == NULL &&
- register_tap_listener == NULL)
+ register_tap_listener == NULL &&
+ register_wtap_module == NULL &&
+ register_codec_module == NULL )
{
/*
* No.
*/
- report_failure("The plugin %s has neither a register routine, or a register_tap_listener routine",
+ report_failure("The plugin '%s' has neither a register routine, "
+ "a register_tap_listener or a register_wtap_module or a register_codec_module routine",
name);
g_module_close(handle);
continue;
*/
if ((cr = add_plugin(handle, g_strdup(name), version,
register_protoinfo, reg_handoff,
- register_tap_listener)))
+ register_tap_listener,register_wtap_module,register_codec_module)))
{
if (cr == EEXIST)
fprintf(stderr, "The plugin %s, version %s\n"
g_module_close(handle);
continue;
}
-
- /*
- * Call its register routine if it has one.
- * XXX - just save this and call it with the built-in
- * dissector register routines?
- */
- if (register_protoinfo != NULL)
- register_protoinfo();
-
+
}
eth_dir_close(dir);
}
g_free(plugins_pers_dir);
}
}
+ register_all_wiretap_modules();
+ register_all_codecs();
+}
+
+void
+register_all_plugin_registrations(void)
+{
+ plugin *pt_plug;
+
+ /*
+ * For all plugins with register-handoff routines, call the routines.
+ * This is called from "proto_init()"; it must be called after
+ * "register_all_protocols()" and "init_plugins()" are called,
+ * in case one plugin registers itself either with a built-in
+ * dissector or with another plugin; we must first register all
+ * dissectors, whether built-in or plugin, so their dissector tables
+ * are initialized, and only then register all handoffs.
+ */
+ for (pt_plug = plugin_list; pt_plug != NULL; pt_plug = pt_plug->next)
+ {
+ if (pt_plug->register_protoinfo)
+ (pt_plug->register_protoinfo)();
+ }
}
void
(pt_plug->register_tap_listener)();
}
}
+
+void
+register_all_wiretap_modules(void)
+{
+ plugin *pt_plug;
+
+ /*
+ * For all plugins with register_wtap_module routines, call the
+ * routines.
+ */
+ for (pt_plug = plugin_list; pt_plug != NULL; pt_plug = pt_plug->next)
+ {
+ if (pt_plug->register_wtap_module)
+ (pt_plug->register_wtap_module)();
+ }
+}
+
+void
+register_all_codecs(void)
+{
+ plugin *pt_plug;
+
+ /*
+ * For all plugins with register_wtap_module routines, call the
+ * routines.
+ */
+ for (pt_plug = plugin_list; pt_plug != NULL; pt_plug = pt_plug->next)
+ {
+ if (pt_plug->register_codec_module)
+ (pt_plug->register_codec_module)();
+ }
+}
#endif