]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/plugins.h
ebl Add Plugin debug after a fatal signal.
[bacula/bacula] / bacula / src / lib / plugins.h
index be08be96595b666ff1b5721965196852831bcced..9934a4eb10c2d2451e8024865f29eda2081fb658 100644 (file)
    Switzerland, email:ftf@fsfeurope.org.
 */
 /*
- * Bacula plugin loader/unloader
+ * Common plugin definitions
  *
  * Kern Sibbald, October 2007
  */
 #ifndef __PLUGINS_H
 #define __PLUGINS_H
 
-#include "bacula.h"
-#include <dlfcn.h>
-#ifdef HAVE_DIRENT_H
-#include <dirent.h>
-#define NAMELEN(dirent) (strlen((dirent)->d_name))
-#endif
-#ifndef HAVE_READDIR_R
-int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
-#endif
-
-#ifndef RTLD_NOW
-#define RTLD_NOW 2
-#endif
-
 /****************************************************************************
  *                                                                          *
  *                Common definitions for all plugins                        *
  *                                                                          *
  ****************************************************************************/
 
+#ifndef BUILD_PLUGIN
 extern DLL_IMP_EXP alist *plugin_list;
+#endif
 
-/* Universal return codes from all functions */
+/* Universal return codes from all plugin functions */
 typedef enum {
-  bRC_OK    = 0,                         /* OK */
-  bRC_Stop  = 1,                         /* Stop calling other plugins */
-  bRC_Error = 2,                         /* Some kind of error */
-  bRC_More  = 3,                         /* More files to backup */
+  bRC_OK     = 0,                        /* OK */
+  bRC_Stop   = 1,                        /* Stop calling other plugins */
+  bRC_Error  = 2,                        /* Some kind of error */
+  bRC_More   = 3,                        /* More files to backup */
+  bRC_Term   = 4                         /* Unload me */
 } bRC;
 
+
 /* Context packet as first argument of all functions */
-typedef struct s_bpContext {
+struct bpContext {
   void *bContext;                        /* Bacula private context */
   void *pContext;                        /* Plugin private context */
-} bpContext;
+};
 
 extern "C" {
 typedef bRC (*t_loadPlugin)(void *binfo, void *bfuncs, void **pinfo, void **pfuncs);
@@ -81,6 +71,7 @@ public:
    void *pinfo;
    void *pfuncs;
    void *pHandle;
+   bool disabled;
 };
 
 /* Functions */
@@ -88,5 +79,10 @@ extern Plugin *new_plugin();
 extern bool load_plugins(void *binfo, void *bfuncs, const char *plugin_dir, const char *type);
 extern void unload_plugins();
 
+/* Each daemon can register a debug hook that will be called
+ * after a fatal signal
+ */
+typedef void (dbg_plugin_hook_t)(Plugin *plug, FILE *fp);
+extern void dbg_plugin_add_hook(dbg_plugin_hook_t *fct);
 
 #endif /* __PLUGINS_H */