2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2016 Kern Sibbald
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.
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.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * Interface definition for Bacula Plugins
22 * Kern Sibbald, October 2007
26 #ifndef __SD_PLUGINS_H
27 #define __SD_PLUGINS_H
31 /* Workaround for SGI IRIX 6.5 */
32 #define _LANGUAGE_C_PLUS_PLUS 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
42 #include <sys/types.h>
48 #include "lib/plugins.h"
57 /****************************************************************************
59 * Bacula definitions *
61 ****************************************************************************/
63 /* Bacula Variable Ids */
78 bsdVarVolumeName = 14,
79 bsdVarCatalogRes = 15,
82 bsdVarSDJobFiles = 18,
84 bsdVarFDJobStatus = 20,
85 bsdVarSDJobStatus = 21
90 bsdwVarVolumeName = 2,
99 bsdEventDeviceInit = 3,
100 bsdEventDeviceOpen = 4,
101 bsdEventDeviceTryOpen = 5,
102 bsdEventDeviceClose = 6
106 bsdGlobalEventDeviceInit = 1
107 } bsdGlobalEventType;
110 typedef struct s_bsdEvent {
114 typedef struct s_sdbaculaInfo {
119 /* Bacula interface version and function pointers */
120 typedef struct s_sdbaculaFuncs {
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);
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);
142 /****************************************************************************
144 * Plugin definitions *
146 ****************************************************************************/
150 psdVarDescription = 2
154 #define SD_PLUGIN_MAGIC "*BaculaSDPluginData*"
156 #define SD_PLUGIN_INTERFACE_VERSION ( 12 )
158 typedef struct s_sdpluginInfo {
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;
170 * Functions that must be defined in every plugin
172 typedef struct s_sdpluginFuncs {
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);
183 #define sdplug_func(plugin) ((psdFuncs *)(plugin->pfuncs))
184 #define sdplug_info(plugin) ((psdInfo *)(plugin->pinfo))
190 #endif /* __SD_PLUGINS_H */