2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from many
7 others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 Bacula® is a registered trademark of Kern Sibbald.
17 * Main program to test loading and running Bacula plugins.
18 * Destined to become Bacula pluginloader, ...
20 * Kern Sibbald, October 2007
24 #include "lib/plugin.h"
25 #include "plugin-sd.h"
27 const char *plugin_type = "-sd.so";
30 /* Forward referenced functions */
31 static bpError baculaGetValue(bpContext *ctx, bVariable var, void *value);
32 static bpError baculaSetValue(bpContext *ctx, bVariable var, void *value);
35 /* Bacula entry points */
36 static bFuncs bfuncs = {
48 int main(int argc, char *argv[])
50 char plugin_dir[1000];
55 bplugin_list = New(alist(10, not_owned_by_alist));
59 getcwd(plugin_dir, sizeof(plugin_dir)-1);
61 load_plugins((void *)&bfuncs, plugin_dir, plugin_type);
63 foreach_alist(plugin, bplugin_list) {
64 printf("bacula: plugin_size=%d plugin_version=%d\n",
65 pref(plugin)->size, pref(plugin)->interface);
66 printf("License: %s\nAuthor: %s\nDate: %s\nVersion: %s\nDescription: %s\n",
67 pref(plugin)->plugin_license, pref(plugin)->plugin_author,
68 pref(plugin)->plugin_date, pref(plugin)->plugin_version,
69 pref(plugin)->plugin_description);
71 /* Start a new instance of the plugin */
72 pref(plugin)->newPlugin(&ctx);
73 event.eventType = bEventNewVolume;
74 pref(plugin)->handlePluginEvent(&ctx, &event);
75 /* Free the plugin instance */
76 pref(plugin)->freePlugin(&ctx);
78 /* Start a new instance of the plugin */
79 pref(plugin)->newPlugin(&ctx);
80 event.eventType = bEventNewVolume;
81 pref(plugin)->handlePluginEvent(&ctx, &event);
82 /* Free the plugin instance */
83 pref(plugin)->freePlugin(&ctx);
88 printf("bacula: OK ...\n");
94 static bpError baculaGetValue(bpContext *ctx, bVariable var, void *value)
96 printf("bacula: baculaGetValue var=%d\n", var);
98 *((int *)value) = 100;
103 static bpError baculaSetValue(bpContext *ctx, bVariable var, void *value)
105 printf("bacula: baculaSetValue var=%d\n", var);