]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/plugins.h
Change copyright as per agreement with FSFE
[bacula/bacula] / bacula / src / lib / plugins.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2016 Kern Sibbald
5
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many 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    This notice must be preserved when any source code is 
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19 /*
20  * Common plugin definitions
21  *
22  * Kern Sibbald, October 2007
23  */
24 #ifndef __PLUGINS_H
25 #define __PLUGINS_H
26
27 /****************************************************************************
28  *                                                                          *
29  *                Common definitions for all plugins                        *
30  *                                                                          *
31  ****************************************************************************/
32
33 #ifndef BUILD_PLUGIN
34 extern DLL_IMP_EXP  alist *b_plugin_list;
35 #endif
36
37 /* Universal return codes from all plugin functions */
38 typedef enum {
39   bRC_OK     = 0,                        /* OK */
40   bRC_Stop   = 1,                        /* Stop calling other plugins */
41   bRC_Error  = 2,                        /* Some kind of error */
42   bRC_More   = 3,                        /* More files to backup */
43   bRC_Term   = 4,                        /* Unload me */
44   bRC_Seen   = 5,                        /* Return code from checkFiles */
45   bRC_Core   = 6,                        /* Let Bacula core handles this file */
46   bRC_Skip   = 7,                        /* Skip the proposed file */
47   bRC_Cancel = 8,                        /* Job cancelled */
48
49   bRC_Max    = 9999                      /* Max code Bacula can use */
50 } bRC;
51
52
53
54 /* Context packet as first argument of all functions */
55 struct bpContext {
56   void *bContext;                        /* Bacula private context */
57   void *pContext;                        /* Plugin private context */
58 };
59
60 extern "C" {
61 typedef bRC (*t_loadPlugin)(void *binfo, void *bfuncs, void **pinfo, void **pfuncs);
62 typedef bRC (*t_unloadPlugin)(void);
63 }
64
65 class Plugin {
66 public:
67    char *file;
68    int32_t file_len;
69    t_unloadPlugin unloadPlugin;
70    void *pinfo;
71    void *pfuncs;
72    void *pHandle;
73    bool disabled;
74    bool restoreFileStarted;
75    bool createFileCalled;
76 };
77
78 /* Functions */
79 extern Plugin *new_plugin();
80 extern bool load_plugins(void *binfo, void *bfuncs, const char *plugin_dir,
81         const char *type, bool is_plugin_compatible(Plugin *plugin));
82 extern void unload_plugins();
83
84 /* Each daemon can register a debug hook that will be called
85  * after a fatal signal
86  */
87 typedef void (dbg_plugin_hook_t)(Plugin *plug, FILE *fp);
88 extern void dbg_plugin_add_hook(dbg_plugin_hook_t *fct);
89
90 #endif /* __PLUGINS_H */