/*
Bacula® - The Network Backup Solution
- Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
/*
* Load all the plugins in the specified directory.
*/
-bool load_plugins(void *binfo, void *bfuncs, const char *plugin_dir, const char *type)
+bool load_plugins(void *binfo, void *bfuncs, const char *plugin_dir,
+ const char *type, bool is_plugin_compatible(Plugin *plugin))
{
bool found = false;
t_loadPlugin loadPlugin;
if (loadPlugin(binfo, bfuncs, &plugin->pinfo, &plugin->pfuncs) != bRC_OK) {
goto get_out;
}
+ if (!is_plugin_compatible) {
+ Dmsg0(50, "Plugin compatibility pointer not set.\n");
+ } else if (!is_plugin_compatible(plugin)) {
+ goto get_out;
+ }
found = true; /* found a plugin */
plugin_list->append(plugin);
get_out:
if (!found && plugin) {
+ if (plugin->file) {
+ Dmsg1(50, "Got plugin=%s but not accepted.\n", plugin->file);
+ }
+ if (plugin->unloadPlugin) {
+ plugin->unloadPlugin();
+ }
+ if (plugin->pHandle) {
+ dlclose(plugin->pHandle);
+ }
+ if (plugin->file) {
+ free(plugin->file);
+ }
free(plugin);
}
if (entry) {
delete plugin_list;
plugin_list = NULL;
}
+
+/*
+ * Dump plugin information
+ * Each daemon can register a hook that will be called
+ * after a fatal signal.
+ */
+#define DBG_MAX_HOOK 10
+static dbg_plugin_hook_t *dbg_plugin_hooks[DBG_MAX_HOOK];
+static int dbg_plugin_hook_count=0;
+
+void dbg_plugin_add_hook(dbg_plugin_hook_t *fct)
+{
+ ASSERT(dbg_plugin_hook_count < DBG_MAX_HOOK);
+ dbg_plugin_hooks[dbg_plugin_hook_count++] = fct;
+}
+
+void dbg_print_plugin(FILE *fp)
+{
+ Plugin *plugin;
+ fprintf(fp, "Attempt to dump plugins\n");
+
+ if (!plugin_list) {
+ return;
+ }
+
+ foreach_alist(plugin, plugin_list) {
+ for(int i=0; i < dbg_plugin_hook_count; i++) {
+ dbg_plugin_hook_t *fct = dbg_plugin_hooks[i];
+ fprintf(fp, "Plugin %p name=\"%s\" disabled=%d\n",
+ plugin, plugin->file, plugin->disabled);
+ fct(plugin, fp);
+ }
+ }
+}