]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/filed/fd-plugins.h
Alpha integration of Dir plugin
[bacula/bacula] / bacula / src / filed / fd-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   bVarJobId     = 1,
62   bVarFDName    = 2,
63   bVarLevel     = 3,
64   bVarType      = 4,
65   bVarClient    = 5,
66   bVarJobName   = 6,
67   bVarJobStatus = 7,
68   bVarSinceTime = 8
69 } bVariable;
70
71 typedef enum {
72   bEventJobStart      = 1,
73   bEventJobEnd        = 2,
74 } bEventType;
75
76 typedef struct s_bEvent {
77    uint32_t eventType;
78 } bEvent;
79
80 typedef struct s_baculaInfo {
81    uint32_t size;
82    uint32_t interface;
83 } bInfo;
84
85 /* Bacula interface version and function pointers */
86 typedef struct s_baculaFuncs {  
87    uint32_t size;
88    uint32_t interface;
89    bpError (*registerBaculaEvents)(bpContext *ctx, ...);
90    bpError (*getBaculaValue)(bpContext *ctx, bVariable var, void *value);
91    bpError (*setBaculaValue)(bpContext *ctx, bVariable var, void *value);
92    bpError (*JobMessage)(bpContext *ctx, const char *file, int line, 
93        int type, time_t mtime, const char *msg);     
94    bpError (*DebugMessage)(bpContext *ctx, const char *file, int line,
95        int level, const char *msg);
96 } bFuncs;
97
98 /* Bacula Subroutines */
99 void load_fd_plugins(const char *plugin_dir);
100 void new_plugins(JCR *jcr);
101 void free_plugins(JCR *jcr);
102 void generate_plugin_event(JCR *jcr, bEventType event);
103
104
105
106 /****************************************************************************
107  *                                                                          *
108  *                Plugin definitions                                        *
109  *                                                                          *
110  ****************************************************************************/
111
112 typedef enum {
113   pVarName = 1,
114   pVarDescription = 2
115 } pVariable;
116
117
118 #define PLUGIN_MAGIC     "*PluginData*" 
119 #define PLUGIN_INTERFACE  1
120
121 typedef struct s_pluginInfo {
122    uint32_t size;
123    uint32_t interface;
124    char *plugin_magic;
125    char *plugin_license;
126    char *plugin_author;
127    char *plugin_date;
128    char *plugin_version;
129    char *plugin_description;
130 } pInfo;
131
132 typedef struct s_pluginFuncs {  
133    uint32_t size;
134    uint32_t interface;
135    bpError (*newPlugin)(bpContext *ctx);
136    bpError (*freePlugin)(bpContext *ctx);
137    bpError (*getPluginValue)(bpContext *ctx, pVariable var, void *value);
138    bpError (*setPluginValue)(bpContext *ctx, pVariable var, void *value);
139    bpError (*handlePluginEvent)(bpContext *ctx, bEvent *event);
140 } pFuncs;
141
142 #define plug_func(plugin) ((pFuncs *)(plugin->pfuncs))
143 #define plug_info(plugin) ((pInfo *)(plugin->pinfo))
144
145 #ifdef __cplusplus
146 }
147 #endif
148
149 #endif /* __FD_PLUGINS_H */