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