/* Bacula info */
static bInfo binfo = {
sizeof(bFuncs),
- PLUGIN_INTERFACE,
+ PLUGIN_INTERFACE_VERSION
};
/* Bacula entry points */
static bFuncs bfuncs = {
sizeof(bFuncs),
- PLUGIN_INTERFACE,
+ PLUGIN_INTERFACE_VERSION,
baculaRegisterEvents,
baculaGetValue,
baculaSetValue,
/*
* Create a plugin event
*/
-void generate_plugin_event(JCR *jcr, bEventType eventType)
+void generate_plugin_event(JCR *jcr, bEventType eventType, void *value)
{
bEvent event;
Plugin *plugin;
Dmsg2(dbglvl, "plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx, jcr->JobId);
event.eventType = eventType;
foreach_alist(plugin, plugin_list) {
- plug_func(plugin)->handlePluginEvent(&plugin_ctx[i++], &event);
+ plug_func(plugin)->handlePluginEvent(&plugin_ctx[i++], &event, value);
}
}
#ifdef TEST_PROGRAM
-
int main(int argc, char *argv[])
{
char plugin_dir[1000];
#include "bc_types.h"
#include "lib/plugins.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-
/****************************************************************************
* *
typedef enum {
bEventJobStart = 1,
bEventJobEnd = 2,
+ bEventBackupStart = 3,
+ bEventBackupEnd = 4,
+ bEventRestoreStart = 5,
+ bEventRestoreEnd = 6,
+ bEventVerifyStart = 7,
+ bEventVerifyEnd = 8,
+ bEventPluginCommand = 9,
+ bEventPluginFile = 10,
+ bEventLevel = 11,
+ bEventSince = 12,
} bEventType;
typedef struct s_bEvent {
uint32_t version;
} bInfo;
+/* Bacula Core Routines -- not used by plugins */
+void load_fd_plugins(const char *plugin_dir);
+void new_plugins(JCR *jcr);
+void free_plugins(JCR *jcr);
+void generate_plugin_event(JCR *jcr, bEventType event, void *value=NULL);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Bacula interface version and function pointers */
typedef struct s_baculaFuncs {
uint32_t size;
int level, const char *msg);
} bFuncs;
-/* Bacula Subroutines */
-void load_fd_plugins(const char *plugin_dir);
-void new_plugins(JCR *jcr);
-void free_plugins(JCR *jcr);
-void generate_plugin_event(JCR *jcr, bEventType event);
#define PLUGIN_MAGIC "*PluginData*"
-#define PLUGIN_INTERFACE 1
+#define PLUGIN_INTERFACE_VERSION 1
typedef struct s_pluginInfo {
uint32_t size;
bpError (*freePlugin)(bpContext *ctx);
bpError (*getPluginValue)(bpContext *ctx, pVariable var, void *value);
bpError (*setPluginValue)(bpContext *ctx, pVariable var, void *value);
- bpError (*handlePluginEvent)(bpContext *ctx, bEvent *event);
+ bpError (*handlePluginEvent)(bpContext *ctx, bEvent *event, void *value);
} pFuncs;
#define plug_func(plugin) ((pFuncs *)(plugin->pfuncs))
jcr->sd_auth_key = bstrdup(sd_auth_key);
free_pool_memory(sd_auth_key);
Dmsg2(120, "JobId=%d Auth=%s\n", jcr->JobId, jcr->sd_auth_key);
+ generate_plugin_event(jcr, bEventJobStart, (void *)dir->msg);
return dir->fsend(OKjob, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER);
}
Dmsg2(100, "adj = %d since_time=%d\n", (int)adj, (int)since_time);
jcr->incremental = 1; /* set incremental or decremental backup */
jcr->mtime = (time_t)since_time; /* set since time */
+ generate_plugin_event(jcr, bEventSince, (void *)jcr->mtime);
} else {
Jmsg1(jcr, M_FATAL, 0, _("Unknown backup level: %s\n"), level);
free_memory(level);
if (buf) {
free_memory(buf);
}
+ generate_plugin_event(jcr, bEventLevel, (void *)jcr->JobLevel);
return dir->fsend(OKlevel);
bail_out:
}
generate_daemon_event(jcr, "JobStart");
- generate_plugin_event(jcr, bEventJobStart);
+ generate_plugin_event(jcr, bEventBackupStart);
#if defined(WIN32_VSS)
- /* START VSS ON WIN 32 */
+ /* START VSS ON WIN32 */
if (jcr->VSS) {
if (g_pVSSClient->InitializeForBackup()) {
/* tell vss which drives to snapshot */
cleanup:
#if defined(WIN32_VSS)
- /* STOP VSS ON WIN 32 */
+ /* STOP VSS ON WIN32 */
/* tell vss to close the backup session */
if (jcr->VSS) {
if (g_pVSSClient->CloseBackup()) {
}
#endif
+ generate_plugin_event(jcr, bEventBackupEnd);
return 0; /* return and stop command loop */
}
dir->fsend(OKverify);
generate_daemon_event(jcr, "JobStart");
- generate_plugin_event(jcr, bEventJobStart);
+ generate_plugin_event(jcr, bEventLevel, (void *)jcr->JobLevel);
+ generate_plugin_event(jcr, bEventVerifyStart);
Dmsg1(110, "bfiled>dird: %s", dir->msg);
}
dir->signal(BNET_EOD);
-
+ generate_plugin_event(jcr, bEventVerifyEnd);
return 0; /* return and terminate command loop */
}
*/
start_dir_heartbeat(jcr);
generate_daemon_event(jcr, "JobStart");
- generate_plugin_event(jcr, bEventJobStart);
+ generate_plugin_event(jcr, bEventRestoreStart);
do_restore(jcr);
stop_dir_heartbeat(jcr);
}
Dmsg0(130, "Done in job.c\n");
+ generate_plugin_event(jcr, bEventRestoreEnd);
return 0; /* return and terminate command loop */
}
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
return 0; /* error return */
}
}
+ foreach_dlist(node, &incexe->plugin_list) {
+ char *fname = node->c_str();
+ Dmsg1(100, "P %s\n", fname);
+ ff->top_fname = fname;
+ generate_plugin_event(jcr, bEventPluginCommand, (void *)fname);
+ }
}
}
return 1;
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2008 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
#include "jcr.h"
#include "bfile.h"
+#include "../filed/fd-plugins.h"
#ifdef HAVE_DIRENT_H
#include <dirent.h>
extern DLL_IMP_EXP alist *plugin_list;
-
/* Universal return code from all functions */
typedef int32_t bpError;
static bpError freePlugin(bpContext *ctx);
static bpError getPluginValue(bpContext *ctx, pVariable var, void *value);
static bpError setPluginValue(bpContext *ctx, pVariable var, void *value);
-static bpError handlePluginEvent(bpContext *ctx, bEvent *event);
+static bpError handlePluginEvent(bpContext *ctx, bEvent *event, void *value);
/* Pointers to Bacula functions */
static pInfo pluginInfo = {
sizeof(pluginInfo),
- PLUGIN_INTERFACE,
+ PLUGIN_INTERFACE_VERSION,
PLUGIN_MAGIC,
PLUGIN_LICENSE,
PLUGIN_AUTHOR,
static pFuncs pluginFuncs = {
sizeof(pluginFuncs),
- PLUGIN_INTERFACE,
+ PLUGIN_INTERFACE_VERSION,
/* Entry points into plugin */
newPlugin, /* new plugin instance */
return 0;
}
-static bpError handlePluginEvent(bpContext *ctx, bEvent *event)
+static bpError handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
{
char *name;
switch (event->eventType) {
Dmsg2(500, "Vol=%s num_parts=%d\n", dcr->VolCatInfo.VolCatName, dcr->VolCatInfo.VolCatParts);
return 1;
}
+
+void generate_plugin_event(JCR *jcr, bEventType eventType, void *value)
+{ return; }
Dmsg2(500, "Vol=%s num_parts=%d\n", dcr->VolCatInfo.VolCatName, dcr->VolCatInfo.VolCatParts);
return 1;
}
+
+void generate_plugin_event(JCR *jcr, bEventType eventType, void *value)
+{ return; }
$(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $<
testfind: ../findlib/libfind.a ../lib/libbac.a $(FINDOBJS)
- $(CXX) -g $(LDFLAGS) -L. -L../lib -L../findlib -o $@ $(FINDOBJS) \
+ $(CXX) -g $(LDFLAGS) -o $@ $(FINDOBJS) -L. -L../lib -L../findlib \
$(DLIB) -lfind -lbac -lm $(LIBS) $(GETTEXT_LIBS) $(OPENSSL_LIBS)
testls: ../findlib/libfind.a ../lib/libbac.a testls.o
-/*
- * Test program for find files
- *
- * Kern Sibbald, MM
- *
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ * Test program for find files
+ *
+ * Kern Sibbald, MM
+ *
+ */
#include "bacula.h"
#include "dird/dird.h"
#include "findlib/find.h"
-
#if defined(HAVE_WIN32)
#define isatty(fd) (fd==0)
#endif
/* Dummy functions */
int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
int generate_job_event(JCR *jcr, const char *event) { return 1; }
+void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) { }
/* Global variables */
static int num_files = 0;
-/*
- * Test program for listing files during regression testing
- *
- * Kern Sibbald, MM
- *
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ * Test program for listing files during regression testing
+ *
+ * Kern Sibbald, MM
+ *
+ */
#include "bacula.h"
#include "findlib/find.h"
/* Dummy functions */
int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
int generate_job_event(JCR *jcr, const char *event) { return 1; }
+void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) { }
/* Global variables */