]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/plugins.h
Alpha integration of Dir plugin
[bacula/bacula] / bacula / src / lib / 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  * Bacula plugin loader/unloader
30  *
31  * Kern Sibbald, October 2007
32  */
33 #ifndef __PLUGINS_H
34 #define __PLUGINS_H
35
36 #include "bacula.h"
37 #ifndef HAVE_WIN32
38 #include <dlfcn.h>
39 #endif
40 #ifdef HAVE_DIRENT_H
41 #include <dirent.h>
42 #define NAMELEN(dirent) (strlen((dirent)->d_name))
43 #endif
44 #ifndef HAVE_READDIR_R
45 int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
46 #endif
47
48 #ifndef RTLD_NOW
49 #define RTLD_NOW 2
50 #endif
51
52 /****************************************************************************
53  *                                                                          *
54  *                Common definitions for all plugins                        *
55  *                                                                          *
56  ****************************************************************************/
57
58 extern alist *plugin_list;
59
60
61 /* Universal return code from all functions */
62 typedef int32_t bpError;
63
64 /* Context packet as first argument of all functions */
65 typedef struct s_bpContext {
66   void *bContext;                        /* Bacula private context */
67   void *pContext;                        /* Plugin private context */
68 } bpContext;
69
70 extern "C" {
71 typedef bpError (*t_loadPlugin)(void *binfo, void *bfuncs, void **pinfo, void **pfuncs);
72 typedef bpError (*t_unloadPlugin)(void);
73 }
74
75 class Plugin {
76 public:
77    char *file;
78    t_unloadPlugin unloadPlugin;
79    void *pinfo;
80    void *pfuncs;
81    void *pHandle;
82 };
83
84 /* Functions */
85 extern Plugin *new_plugin();
86 extern bool load_plugins(void *binfo, void *bfuncs, const char *plugin_dir, const char *type);
87 extern void unload_plugins();
88
89
90 #endif /* __PLUGINS_H */