2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2017 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many 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 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * Main program to test loading and running Bacula plugins.
21 * Destined to become Bacula pluginloader, ...
23 * Kern Sibbald, October 2007
27 #include "lib/plugin.h"
28 #include "plugin-sd.h"
30 const char *plugin_type = "-sd.so";
33 /* Forward referenced functions */
34 static bpError baculaGetValue(bpContext *ctx, bVariable var, void *value);
35 static bpError baculaSetValue(bpContext *ctx, bVariable var, void *value);
38 /* Bacula entry points */
39 static bFuncs bfuncs = {
51 int main(int argc, char *argv[])
53 char plugin_dir[1000];
58 b_plugin_list = New(alist(10, not_owned_by_alist));
62 getcwd(plugin_dir, sizeof(plugin_dir)-1);
64 load_plugins((void *)&bfuncs, plugin_dir, plugin_type);
66 foreach_alist(plugin, b_plugin_list) {
67 printf("bacula: plugin_size=%d plugin_version=%d\n",
68 pref(plugin)->size, pref(plugin)->interface);
69 printf("License: %s\nAuthor: %s\nDate: %s\nVersion: %s\nDescription: %s\n",
70 pref(plugin)->plugin_license, pref(plugin)->plugin_author,
71 pref(plugin)->plugin_date, pref(plugin)->plugin_version,
72 pref(plugin)->plugin_description);
74 /* Start a new instance of the plugin */
75 pref(plugin)->newPlugin(&ctx);
76 event.eventType = bEventNewVolume;
77 pref(plugin)->handlePluginEvent(&ctx, &event);
78 /* Free the plugin instance */
79 pref(plugin)->freePlugin(&ctx);
81 /* Start a new instance of the plugin */
82 pref(plugin)->newPlugin(&ctx);
83 event.eventType = bEventNewVolume;
84 pref(plugin)->handlePluginEvent(&ctx, &event);
85 /* Free the plugin instance */
86 pref(plugin)->freePlugin(&ctx);
91 printf("bacula: OK ...\n");
97 static bpError baculaGetValue(bpContext *ctx, bVariable var, void *value)
99 printf("bacula: baculaGetValue var=%d\n", var);
101 *((int *)value) = 100;
106 static bpError baculaSetValue(bpContext *ctx, bVariable var, void *value)
108 printf("bacula: baculaSetValue var=%d\n", var);