2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
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.
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.
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
23 Bacula® is a registered trademark of Kern Sibbald.
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.
29 * Main program to test loading and running Bacula plugins.
30 * Destined to become Bacula pluginloader, ...
32 * Kern Sibbald, October 2007
36 #include "lib/plugin.h"
37 #include "plugin-sd.h"
39 const char *plugin_type = "-sd.so";
42 /* Forward referenced functions */
43 static bpError baculaGetValue(bpContext *ctx, bVariable var, void *value);
44 static bpError baculaSetValue(bpContext *ctx, bVariable var, void *value);
47 /* Bacula entry points */
48 static bFuncs bfuncs = {
60 int main(int argc, char *argv[])
62 char plugin_dir[1000];
67 plugin_list = New(alist(10, not_owned_by_alist));
71 getcwd(plugin_dir, sizeof(plugin_dir)-1);
73 load_plugins((void *)&bfuncs, plugin_dir, plugin_type);
75 foreach_alist(plugin, plugin_list) {
76 printf("bacula: plugin_size=%d plugin_version=%d\n",
77 pref(plugin)->size, pref(plugin)->interface);
78 printf("License: %s\nAuthor: %s\nDate: %s\nVersion: %s\nDescription: %s\n",
79 pref(plugin)->plugin_license, pref(plugin)->plugin_author,
80 pref(plugin)->plugin_date, pref(plugin)->plugin_version,
81 pref(plugin)->plugin_description);
83 /* Start a new instance of the plugin */
84 pref(plugin)->newPlugin(&ctx);
85 event.eventType = bEventNewVolume;
86 pref(plugin)->handlePluginEvent(&ctx, &event);
87 /* Free the plugin instance */
88 pref(plugin)->freePlugin(&ctx);
90 /* Start a new instance of the plugin */
91 pref(plugin)->newPlugin(&ctx);
92 event.eventType = bEventNewVolume;
93 pref(plugin)->handlePluginEvent(&ctx, &event);
94 /* Free the plugin instance */
95 pref(plugin)->freePlugin(&ctx);
100 printf("bacula: OK ...\n");
106 static bpError baculaGetValue(bpContext *ctx, bVariable var, void *value)
108 printf("bacula: baculaGetValue var=%d\n", var);
110 *((int *)value) = 100;
115 static bpError baculaSetValue(bpContext *ctx, bVariable var, void *value)
117 printf("bacula: baculaSetValue var=%d\n", var);