]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/stored/sd_plugins.h
Backport from BEE
[bacula/bacula] / bacula / src / stored / sd_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  * Interface definition for Bacula Plugins
18  *
19  * Kern Sibbald, October 2007
20  *
21  */
22
23 #ifndef __SD_PLUGINS_H
24 #define __SD_PLUGINS_H
25
26 #ifndef _BACULA_H
27 #ifdef __cplusplus
28 /* Workaround for SGI IRIX 6.5 */
29 #define _LANGUAGE_C_PLUS_PLUS 1
30 #endif
31 #define _REENTRANT    1
32 #define _THREAD_SAFE  1
33 #define _POSIX_PTHREAD_SEMANTICS 1
34 #define _FILE_OFFSET_BITS 64
35 #define _LARGEFILE_SOURCE 1
36 #define _LARGE_FILES 1
37 #endif
38
39 #include <sys/types.h>
40 #ifndef __CONFIG_H
41 #define __CONFIG_H
42 #include "config.h"
43 #endif
44 #include "bc_types.h"
45 #include "lib/plugins.h"
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51
52
53
54 /****************************************************************************
55  *                                                                          *
56  *                Bacula definitions                                        *
57  *                                                                          *
58  ****************************************************************************/
59
60 /* Bacula Variable Ids */
61 typedef enum {
62   bsdVarJob         = 1,
63   bsdVarLevel       = 2,
64   bsdVarType        = 3,
65   bsdVarJobId       = 4,
66   bsdVarClient      = 5,
67   bsdVarNumVols     = 6,
68   bsdVarPool        = 7,
69   bsdVarStorage     = 8,
70   bsdVarCatalog     = 9,
71   bsdVarMediaType   = 10,
72   bsdVarJobName     = 11,
73   bsdVarJobStatus   = 12,
74   bsdVarPriority    = 13,
75   bsdVarVolumeName  = 14,
76   bsdVarCatalogRes  = 15,
77   bsdVarJobErrors   = 16,
78   bsdVarJobFiles    = 17,
79   bsdVarSDJobFiles  = 18,
80   bsdVarSDErrors    = 19,
81   bsdVarFDJobStatus = 20,
82   bsdVarSDJobStatus = 21
83 } bsdrVariable;
84
85 typedef enum {
86   bsdVarDevTypes    = 1
87 } bsdrGlobalVariable;
88
89
90 typedef enum {
91   bsdwVarJobReport  = 1,
92   bsdwVarVolumeName = 2,
93   bsdwVarPriority   = 3,
94   bsdwVarJobLevel   = 4
95 } bsdwVariable;
96
97
98 typedef enum {
99   bsdEventJobStart       = 1,
100   bsdEventJobEnd         = 2,
101   bsdEventDeviceInit     = 3,
102   bsdEventDeviceOpen     = 4,
103   bsdEventDeviceTryOpen  = 5,
104   bsdEventDeviceClose    = 6
105 } bsdEventType;
106
107 typedef enum {
108   bsdGlobalEventDeviceInit = 1
109 } bsdGlobalEventType;
110
111
112 typedef struct s_bsdEvent {
113    uint32_t eventType;
114 } bsdEvent;
115
116 typedef struct s_sdbaculaInfo {
117    uint32_t size;
118    uint32_t version;
119 } bsdInfo;
120
121 /* Bacula interface version and function pointers */
122 typedef struct s_sdbaculaFuncs {
123    uint32_t size;
124    uint32_t version;
125    bRC (*registerBaculaEvents)(bpContext *ctx, ...);
126    bRC (*getBaculaValue)(bpContext *ctx, bsdrVariable var, void *value);
127    bRC (*setBaculaValue)(bpContext *ctx, bsdwVariable var, void *value);
128    bRC (*JobMessage)(bpContext *ctx, const char *file, int line,
129        int type, utime_t mtime, const char *fmt, ...);
130    bRC (*DebugMessage)(bpContext *ctx, const char *file, int line,
131        int level, const char *fmt, ...);
132    char *(*EditDeviceCodes)(DCR *dcr, char *omsg,
133        const char *imsg, const char *cmd);
134    bRC (*getBaculaGlobal)(bsdrGlobalVariable var, void *value);
135 } bsdFuncs;
136
137 /* Bacula Subroutines */
138 void load_sd_plugins(const char *plugin_dir);
139 void new_plugins(JCR *jcr);
140 void free_plugins(JCR *jcr);
141 int generate_plugin_event(JCR *jcr, bsdEventType event, void *value=NULL);
142 int generate_global_plugin_event(bsdGlobalEventType event, void *value=NULL);
143
144
145 /****************************************************************************
146  *                                                                          *
147  *                Plugin definitions                                        *
148  *                                                                          *
149  ****************************************************************************/
150
151 typedef enum {
152   psdVarName = 1,
153   psdVarDescription = 2
154 } psdVariable;
155
156
157 # define SD_PLUGIN_MAGIC  "*BaculaSDPluginData*"
158
159 #define SD_PLUGIN_INTERFACE_VERSION  ( 12 )
160
161 typedef struct s_sdpluginInfo {
162    uint32_t size;
163    uint32_t version;
164    const char *plugin_magic;
165    const char *plugin_license;
166    const char *plugin_author;
167    const char *plugin_date;
168    const char *plugin_version;
169    const char *plugin_description;
170 } psdInfo;
171
172 /*
173  * Functions that must be defined in every plugin
174  */
175 typedef struct s_sdpluginFuncs {
176    uint32_t size;
177    uint32_t version;
178    bRC (*newPlugin)(bpContext *ctx);
179    bRC (*freePlugin)(bpContext *ctx);
180    bRC (*getPluginValue)(bpContext *ctx, psdVariable var, void *value);
181    bRC (*setPluginValue)(bpContext *ctx, psdVariable var, void *value);
182    bRC (*handlePluginEvent)(bpContext *ctx, bsdEvent *event, void *value);
183    bRC (*handleGlobalPluginEvent)(bsdEvent *event, void *value);
184 } psdFuncs;
185
186 #define sdplug_func(plugin) ((psdFuncs *)(plugin->pfuncs))
187 #define sdplug_info(plugin) ((psdInfo *)(plugin->pinfo))
188
189 #ifdef __cplusplus
190 }
191 #endif
192
193 #endif /* __SD_PLUGINS_H */