2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2015 Kern Sibbald
5 Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
7 The original author of Bacula is Kern Sibbald, with contributions
8 from many others, a complete list can be found in the file AUTHORS.
10 You may use this file and others of this release according to the
11 license defined in the LICENSE file, which includes the Affero General
12 Public License, v3.0 ("AGPLv3") and some additional permissions and
13 terms pursuant to its AGPLv3 Section 7.
15 This notice must be preserved when any source code is
16 conveyed and/or propagated.
18 Bacula(R) is a registered trademark of Kern Sibbald.
21 * Main program to test loading and running Bacula plugins.
22 * Destined to become Bacula pluginloader, ...
24 * Kern Sibbald, October 2007
28 #include "lib/plugin.h"
29 #include "plugin-sd.h"
31 const char *plugin_type = "-sd.so";
34 /* Forward referenced functions */
35 static bpError baculaGetValue(bpContext *ctx, bVariable var, void *value);
36 static bpError baculaSetValue(bpContext *ctx, bVariable var, void *value);
39 /* Bacula entry points */
40 static bFuncs bfuncs = {
52 int main(int argc, char *argv[])
54 char plugin_dir[1000];
59 b_plugin_list = New(alist(10, not_owned_by_alist));
63 getcwd(plugin_dir, sizeof(plugin_dir)-1);
65 load_plugins((void *)&bfuncs, plugin_dir, plugin_type);
67 foreach_alist(plugin, b_plugin_list) {
68 printf("bacula: plugin_size=%d plugin_version=%d\n",
69 pref(plugin)->size, pref(plugin)->interface);
70 printf("License: %s\nAuthor: %s\nDate: %s\nVersion: %s\nDescription: %s\n",
71 pref(plugin)->plugin_license, pref(plugin)->plugin_author,
72 pref(plugin)->plugin_date, pref(plugin)->plugin_version,
73 pref(plugin)->plugin_description);
75 /* Start a new instance of the plugin */
76 pref(plugin)->newPlugin(&ctx);
77 event.eventType = bEventNewVolume;
78 pref(plugin)->handlePluginEvent(&ctx, &event);
79 /* Free the plugin instance */
80 pref(plugin)->freePlugin(&ctx);
82 /* Start a new instance of the plugin */
83 pref(plugin)->newPlugin(&ctx);
84 event.eventType = bEventNewVolume;
85 pref(plugin)->handlePluginEvent(&ctx, &event);
86 /* Free the plugin instance */
87 pref(plugin)->freePlugin(&ctx);
92 printf("bacula: OK ...\n");
98 static bpError baculaGetValue(bpContext *ctx, bVariable var, void *value)
100 printf("bacula: baculaGetValue var=%d\n", var);
102 *((int *)value) = 100;
107 static bpError baculaSetValue(bpContext *ctx, bVariable var, void *value)
109 printf("bacula: baculaSetValue var=%d\n", var);