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 three of the GNU Affero 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 Affero 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 * Sample Plugin program
31 * Kern Sibbald, October 2007
35 #include "plugin-sd.h"
41 #define PLUGIN_LICENSE "GPL"
42 #define PLUGIN_AUTHOR "Kern Sibbald"
43 #define PLUGIN_DATE "November 2007"
44 #define PLUGIN_VERSION "1"
45 #define PLUGIN_DESCRIPTION "Test Storage Daemon Plugin"
47 /* Forward referenced functions */
48 static bpError newPlugin(bpContext *ctx);
49 static bpError freePlugin(bpContext *ctx);
50 static bpError getPluginValue(bpContext *ctx, pVariable var, void *value);
51 static bpError setPluginValue(bpContext *ctx, pVariable var, void *value);
52 static bpError handlePluginEvent(bpContext *ctx, bEvent *event);
55 /* Pointers to Bacula functions */
56 static bFuncs *bfuncs = NULL;
58 static pFuncs pluginFuncs = {
68 /* Entry points into plugin */
69 newPlugin, /* new plugin instance */
70 freePlugin, /* free plugin instance */
76 bpError loadPlugin(bFuncs *lbfuncs, pFuncs **pfuncs)
78 bfuncs = lbfuncs; /* set Bacula funct pointers */
79 printf("plugin: Loaded: size=%d version=%d\n", bfuncs->size, bfuncs->interface);
81 *pfuncs = &pluginFuncs; /* return pointer to our functions */
86 bpError unloadPlugin()
88 printf("plugin: Unloaded\n");
92 static bpError newPlugin(bpContext *ctx)
95 bfuncs->getBaculaValue(ctx, bVarJobId, (void *)&JobId);
96 printf("plugin: newPlugin JobId=%d\n", JobId);
100 static bpError freePlugin(bpContext *ctx)
103 bfuncs->getBaculaValue(ctx, bVarJobId, (void *)&JobId);
104 printf("plugin: freePlugin JobId=%d\n", JobId);
108 static bpError getPluginValue(bpContext *ctx, pVariable var, void *value)
110 printf("plugin: getPluginValue var=%d\n", var);
114 static bpError setPluginValue(bpContext *ctx, pVariable var, void *value)
116 printf("plugin: setPluginValue var=%d\n", var);
120 static bpError handlePluginEvent(bpContext *ctx, bEvent *event)
122 printf("plugin: HandleEvent Event=%d\n", event->eventType);