]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/plugins/dir/plugin-dir.h
Commit 0th cut of plugins
[bacula/bacula] / bacula / src / plugins / dir / plugin-dir.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2007-2007 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 __PLUGIN_H 
36 #define __PLUGIN_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
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49
50 /****************************************************************************
51  *                                                                          *
52  *                Common definitions                                        *
53  *                                                                          *
54  ****************************************************************************/
55
56 /* Universal return code from all functions */
57 typedef int32_t bpError;
58
59 /* Context packet as first argument of all functions */
60 typedef struct s_bpContext {
61   void *bContext;                        /* Bacula private context */
62   void *pContext;                        /* Plugin private context */
63 } bpContext;
64
65
66 /****************************************************************************
67  *                                                                          *
68  *                Bacula definitions                                        *
69  *                                                                          *
70  ****************************************************************************/
71
72 /* Bacula Variable Ids */
73 typedef enum {
74   bVarJobId = 1
75 } bVariable;
76
77 typedef enum {
78   bEventJobStart      = 1,
79   bEventJobInit       = 2,
80   bEventJobRun        = 3,
81   bEventJobEnd        = 4,
82   bEventNewVolume     = 5,
83   bEventVolumePurged  = 6,
84   bEventReload        = 7
85 } bEventType;
86
87 typedef struct s_bEvent {
88    uint32_t eventType;
89 } bEvent;
90
91
92 /* Bacula interface version and function pointers */
93 typedef struct s_baculaFuncs {  
94    uint32_t size;
95    uint32_t version; 
96    bpError (*bGetValue)(bpContext *ctx, bVariable var, void *value);
97    bpError (*bSetValue)(bpContext *ctx, bVariable var, void *value);
98    bpError (*bMemAlloc)(bpContext *ctx, uint32_t size, char *addr);
99    bpError (*bMemFree)(bpContext *ctx, char *addr);
100    bpError (*bMemFlush)(bpContext *ctx);
101    bpError (*bVersion)(bVariable var, void *value);
102 } bFuncs;
103
104
105 /****************************************************************************
106  *                                                                          *
107  *                Plugin definitions                                        *
108  *                                                                          *
109  ****************************************************************************/
110
111 typedef enum {
112   pVarName = 1,
113   pVarDescription = 2
114 } pVariable;
115
116
117 typedef struct s_pluginFuncs {  
118    uint32_t size;
119    uint32_t version; 
120    bpError (*pNew)(bpContext *ctx);
121    bpError (*pDestroy)(bpContext *ctx);
122    bpError (*pGetValue)(bpContext *ctx, pVariable var, void *value);
123    bpError (*pSetValue)(bpContext *ctx, pVariable var, void *value);
124    bpError (*pHandleEvent)(bpContext *ctx, bEvent *event);
125 } pFuncs;
126
127 typedef bpError (*t_bpInitialize)(bFuncs *bfuncs, pFuncs *pfuncs);
128 typedef bpError (*t_bpShutdown)(void);
129
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif /* __PLUGIN_H */