]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/dir-plugins.h
kes Implement DB Driver = string for the DBI driver.
[bacula/bacula] / bacula / src / dird / dir-plugins.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version two of the GNU General Public
10    License as published by the Free Software Foundation, which is 
11    listed in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of John Walker.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /*
29  * Interface definition for Bacula Plugins
30  *
31  * Kern Sibbald, October 2007
32  *
33  */
34  
35 #ifndef __FD_PLUGINS_H 
36 #define __FD_PLUGINS_H
37
38 #include <sys/types.h>
39 #ifndef __CONFIG_H
40 #define __CONFIG_H
41 #include "config.h"
42 #endif
43 #include "bc_types.h"
44 #include "lib/plugins.h"
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50
51
52
53 /****************************************************************************
54  *                                                                          *
55  *                Bacula definitions                                        *
56  *                                                                          *
57  ****************************************************************************/
58
59 /* Bacula Variable Ids */
60 typedef enum {
61   bVarJob       = 1,
62   bVarLevel     = 2,
63   bVarType      = 3,
64   bVarJobId     = 4,
65   bVarClient    = 5,
66   bVarNumVols   = 6,
67   bVarPool      = 7,
68   bVarStorage   = 8,
69   bVarCatalog   = 9,
70   bVarMediaType = 10,
71   bVarJobName   = 11,
72   bVarJobStatus = 12,
73   bVarPriority  = 13,
74   bVarVolumeName = 14,
75   bVarCatalogRes = 15,
76   bVarJobErrors  = 16,
77   bVarJobFiles   = 17,
78   bVarSDJobFiles = 18,
79   bVarSDErrors   = 19,
80   bVarFDJobStatus = 20,
81   bVarSDJobStatus = 21
82 } brVariable;
83
84 typedef enum {
85   bwVarJobReport  = 1,
86   bwVarVolumeName = 2,
87   bwVarPriority   = 3,
88   bwVarJobLevel   = 4,
89 } bwVariable;
90
91
92 typedef enum {
93   bEventJobStart      = 1,
94   bEventJobEnd        = 2,
95 } bEventType;
96
97 typedef struct s_bEvent {
98    uint32_t eventType;
99 } bEvent;
100
101 typedef struct s_baculaInfo {
102    uint32_t size;
103    uint32_t version;  
104 } bInfo;
105
106 /* Bacula interface version and function pointers */
107 typedef struct s_baculaFuncs {  
108    uint32_t size;
109    uint32_t version;
110    bpError (*registerBaculaEvents)(bpContext *ctx, ...);
111    bpError (*getBaculaValue)(bpContext *ctx, brVariable var, void *value);
112    bpError (*setBaculaValue)(bpContext *ctx, bwVariable var, void *value);
113    bpError (*JobMessage)(bpContext *ctx, const char *file, int line, 
114        int type, time_t mtime, const char *msg);     
115    bpError (*DebugMessage)(bpContext *ctx, const char *file, int line,
116        int level, const char *msg);
117 } bFuncs;
118
119 /* Bacula Subroutines */
120 void load_dir_plugins(const char *plugin_dir);
121 void new_plugins(JCR *jcr);
122 void free_plugins(JCR *jcr);
123 void generate_plugin_event(JCR *jcr, bEventType event);
124
125
126
127 /****************************************************************************
128  *                                                                          *
129  *                Plugin definitions                                        *
130  *                                                                          *
131  ****************************************************************************/
132
133 typedef enum {
134   pVarName = 1,
135   pVarDescription = 2
136 } pVariable;
137
138
139 #define PLUGIN_MAGIC     "*PluginData*" 
140 #define PLUGIN_INTERFACE  1
141
142 typedef struct s_pluginInfo {
143    uint32_t size;
144    uint32_t version;
145    char *plugin_magic;
146    char *plugin_license;
147    char *plugin_author;
148    char *plugin_date;
149    char *plugin_version;
150    char *plugin_description;
151 } pInfo;
152
153 typedef struct s_pluginFuncs {  
154    uint32_t size;
155    uint32_t version;
156    bpError (*newPlugin)(bpContext *ctx);
157    bpError (*freePlugin)(bpContext *ctx);
158    bpError (*getPluginValue)(bpContext *ctx, pVariable var, void *value);
159    bpError (*setPluginValue)(bpContext *ctx, pVariable var, void *value);
160    bpError (*handlePluginEvent)(bpContext *ctx, bEvent *event);
161 } pFuncs;
162
163 #define plug_func(plugin) ((pFuncs *)(plugin->pfuncs))
164 #define plug_info(plugin) ((pInfo *)(plugin->pinfo))
165
166 #ifdef __cplusplus
167 }
168 #endif
169
170 #endif /* __FD_PLUGINS_H */