]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/plugins.h
Backport from BEE
[bacula/bacula] / bacula / src / lib / plugins.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from many
7    others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    Bacula® is a registered trademark of Kern Sibbald.
15 */
16 /*
17  * Common plugin definitions
18  *
19  * Kern Sibbald, October 2007
20  */
21 #ifndef __PLUGINS_H
22 #define __PLUGINS_H
23
24 /****************************************************************************
25  *                                                                          *
26  *                Common definitions for all plugins                        *
27  *                                                                          *
28  ****************************************************************************/
29
30 #ifndef BUILD_PLUGIN
31 extern DLL_IMP_EXP alist *bplugin_list;
32 #endif
33
34 /* Universal return codes from all plugin functions */
35 typedef enum {
36   bRC_OK     = 0,                        /* OK */
37   bRC_Stop   = 1,                        /* Stop calling other plugins */
38   bRC_Error  = 2,                        /* Some kind of error */
39   bRC_More   = 3,                        /* More files to backup */
40   bRC_Term   = 4,                        /* Unload me */
41   bRC_Seen   = 5,                        /* Return code from checkFiles */
42   bRC_Core   = 6,                        /* Let Bacula core handles this file */
43   bRC_Skip   = 7,                        /* Skip the proposed file */
44   bRC_Cancel = 8,                        /* Job cancelled */
45
46   bRC_Max    = 9999                      /* Max code Bacula can use */
47 } bRC;
48
49
50
51 /* Context packet as first argument of all functions */
52 struct bpContext {
53   void *bContext;                        /* Bacula private context */
54   void *pContext;                        /* Plugin private context */
55 };
56
57 extern "C" {
58 typedef bRC (*t_loadPlugin)(void *binfo, void *bfuncs, void **pinfo, void **pfuncs);
59 typedef bRC (*t_unloadPlugin)(void);
60 }
61
62 class Plugin {
63 public:
64    char *file;
65    int32_t file_len;
66    t_unloadPlugin unloadPlugin;
67    void *pinfo;
68    void *pfuncs;
69    void *pHandle;
70    bool disabled;
71    bool restoreFileStarted;
72    bool createFileCalled;
73 };
74
75 /* Functions */
76 extern Plugin *new_plugin();
77 extern bool load_plugins(void *binfo, void *bfuncs, const char *plugin_dir,
78         const char *type, bool is_plugin_compatible(Plugin *plugin));
79 extern void unload_plugins();
80
81 /* Each daemon can register a debug hook that will be called
82  * after a fatal signal
83  */
84 typedef void (dbg_plugin_hook_t)(Plugin *plug, FILE *fp);
85 extern void dbg_plugin_add_hook(dbg_plugin_hook_t *fct);
86
87 #endif /* __PLUGINS_H */