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