]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/dir_plugins.h
Backport from Bacula Enterprise
[bacula/bacula] / bacula / src / dird / dir_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 __DIR_PLUGINS_H
28 #define __DIR_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 */       /* return value */
65 typedef enum {
66   bDirVarJob       = 1,            // string
67   bDirVarLevel     = 2,            // int
68   bDirVarType      = 3,            // int
69   bDirVarJobId     = 4,            // int
70   bDirVarClient    = 5,            // string
71   bDirVarNumVols   = 6,            // int
72   bDirVarPool      = 7,            // string
73   bDirVarStorage   = 8,            // string
74   bDirVarWriteStorage = 9,         // string
75   bDirVarReadStorage  = 10,        // string
76   bDirVarCatalog   = 11,           // string
77   bDirVarMediaType = 12,           // string
78   bDirVarJobName   = 13,           // string
79   bDirVarJobStatus = 14,           // int
80   bDirVarPriority  = 15,           // int
81   bDirVarVolumeName = 16,          // string
82   bDirVarCatalogRes = 17,          // NYI
83   bDirVarJobErrors  = 18,          // int
84   bDirVarJobFiles   = 19,          // int
85   bDirVarSDJobFiles = 20,          // int
86   bDirVarSDErrors   = 21,          // int
87   bDirVarFDJobStatus = 22,         // int
88   bDirVarSDJobStatus = 23          // int
89 } brDirVariable;
90
91 typedef enum {
92   bwDirVarJobReport  = 1,
93   bwDirVarVolumeName = 2,
94   bwDirVarPriority   = 3,
95   bwDirVarJobLevel   = 4
96 } bwDirVariable;
97
98
99 typedef enum {
100   bDirEventJobStart      = 1,
101   bDirEventJobEnd        = 2,
102   bDirEventJobInit       = 3,
103   bDirEventJobRun        = 4,
104   bDirEventVolumePurged  = 5,
105   bDirEventNewVolume     = 6,
106   bDirEventNeedVolume    = 7,
107   bDirEventVolumeFull    = 8,
108   bDirEventRecyle        = 9,
109   bDirEventGetScratch    = 10
110 } bDirEventType;
111
112 typedef struct s_bDirEvent {
113    uint32_t eventType;
114 } bDirEvent;
115
116 typedef struct s_dirbaculaInfo {
117    uint32_t size;
118    uint32_t version;
119 } bDirInfo;
120
121 /* Bacula interface version and function pointers */
122 typedef struct s_dirbaculaFuncs {
123    uint32_t size;
124    uint32_t version;
125    bRC (*registerBaculaEvents)(bpContext *ctx, ...);
126    bRC (*getBaculaValue)(bpContext *ctx, brDirVariable var, void *value);
127    bRC (*setBaculaValue)(bpContext *ctx, bwDirVariable 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 } bDirFuncs;
133
134 /* Bacula Core Routines -- not used within a plugin */
135 #ifdef DIRECTOR_DAEMON
136 void load_dir_plugins(const char *plugin_dir);
137 void new_plugins(JCR *jcr);
138 void free_plugins(JCR *jcr);
139 int generate_plugin_event(JCR *jcr, bDirEventType event, void *value=NULL);
140 #endif
141
142
143 /****************************************************************************
144  *                                                                          *
145  *                Plugin definitions                                        *
146  *                                                                          *
147  ****************************************************************************/
148
149 typedef enum {
150   pDirVarName = 1,
151   pDirVarDescription = 2
152 } pDirVariable;
153
154
155 #define DIR_PLUGIN_MAGIC     "*DirPluginData*"
156 #define DIR_PLUGIN_INTERFACE_VERSION  1
157
158 typedef struct s_dirpluginInfo {
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 } pDirInfo;
168
169 typedef struct s_dirpluginFuncs {
170    uint32_t size;
171    uint32_t version;
172    bRC (*newPlugin)(bpContext *ctx);
173    bRC (*freePlugin)(bpContext *ctx);
174    bRC (*getPluginValue)(bpContext *ctx, pDirVariable var, void *value);
175    bRC (*setPluginValue)(bpContext *ctx, pDirVariable var, void *value);
176    bRC (*handlePluginEvent)(bpContext *ctx, bDirEvent *event, void *value);
177 } pDirFuncs;
178
179 #define dirplug_func(plugin) ((pDirFuncs *)(plugin->pfuncs))
180 #define dirplug_info(plugin) ((pDirInfo *)(plugin->pinfo))
181
182 #ifdef __cplusplus
183 }
184 #endif
185
186 #endif /* __FD_PLUGINS_H */