/* Forward referenced functions */
-static bpError baculaGetValue(bpContext *ctx, brVariable var, void *value);
-static bpError baculaSetValue(bpContext *ctx, bwVariable var, void *value);
-static bpError baculaRegisterEvents(bpContext *ctx, ...);
-static bpError baculaJobMsg(bpContext *ctx, const char *file, int line,
+static bRC baculaGetValue(bpContext *ctx, brVariable var, void *value);
+static bRC baculaSetValue(bpContext *ctx, bwVariable var, void *value);
+static bRC baculaRegisterEvents(bpContext *ctx, ...);
+static bRC baculaJobMsg(bpContext *ctx, const char *file, int line,
int type, time_t mtime, const char *msg);
-static bpError baculaDebugMsg(bpContext *ctx, const char *file, int line,
+static bRC baculaDebugMsg(bpContext *ctx, const char *file, int line,
int level, const char *msg);
return;
}
- bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
- Dmsg2(dbglvl, "plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx, jcr->JobId);
+ bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list;
+ Dmsg2(dbglvl, "plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId);
event.eventType = eventType;
foreach_alist(plugin, plugin_list) {
- plug_func(plugin)->handlePluginEvent(&plugin_ctx[i++], &event);
+ plug_func(plugin)->handlePluginEvent(&plugin_ctx_list[i++], &event);
}
}
return;
}
- jcr->plugin_ctx = (void *)malloc(sizeof(bpContext) * num);
+ jcr->plugin_ctx_list = (void *)malloc(sizeof(bpContext) * num);
- bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
- Dmsg2(dbglvl, "Instantiate plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx, jcr->JobId);
+ bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list;
+ Dmsg2(dbglvl, "Instantiate plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId);
foreach_alist(plugin, plugin_list) {
/* Start a new instance of each plugin */
- plugin_ctx[i].bContext = (void *)jcr;
- plugin_ctx[i].pContext = NULL;
- plug_func(plugin)->newPlugin(&plugin_ctx[i++]);
+ plugin_ctx_list[i].bContext = (void *)jcr;
+ plugin_ctx_list[i].pContext = NULL;
+ plug_func(plugin)->newPlugin(&plugin_ctx_list[i++]);
}
}
return;
}
- bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
- Dmsg2(dbglvl, "Free instance plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx, jcr->JobId);
+ bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list;
+ Dmsg2(dbglvl, "Free instance plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId);
foreach_alist(plugin, plugin_list) {
/* Free the plugin instance */
- plug_func(plugin)->freePlugin(&plugin_ctx[i++]);
+ plug_func(plugin)->freePlugin(&plugin_ctx_list[i++]);
}
- free(plugin_ctx);
- jcr->plugin_ctx = NULL;
+ free(plugin_ctx_list);
+ jcr->plugin_ctx_list = NULL;
}
*
* ==============================================================
*/
-static bpError baculaGetValue(bpContext *ctx, brVariable var, void *value)
+static bRC baculaGetValue(bpContext *ctx, brVariable var, void *value)
{
JCR *jcr = (JCR *)(ctx->bContext);
// Dmsg1(dbglvl, "bacula: baculaGetValue var=%d\n", var);
if (!value) {
- return 1;
+ return bRC_Error;
}
// Dmsg1(dbglvl, "Bacula: jcr=%p\n", jcr);
switch (var) {
default:
break;
}
- return 0;
+ return bRC_OK;
}
-static bpError baculaSetValue(bpContext *ctx, bwVariable var, void *value)
+static bRC baculaSetValue(bpContext *ctx, bwVariable var, void *value)
{
Dmsg1(dbglvl, "bacula: baculaSetValue var=%d\n", var);
- return 0;
+ return bRC_OK;
}
-static bpError baculaRegisterEvents(bpContext *ctx, ...)
+static bRC baculaRegisterEvents(bpContext *ctx, ...)
{
va_list args;
uint32_t event;
Dmsg1(dbglvl, "Plugin wants event=%u\n", event);
}
va_end(args);
- return 0;
+ return bRC_OK;
}
-static bpError baculaJobMsg(bpContext *ctx, const char *file, int line,
+static bRC baculaJobMsg(bpContext *ctx, const char *file, int line,
int type, time_t mtime, const char *msg)
{
Dmsg5(dbglvl, "Job message: %s:%d type=%d time=%ld msg=%s\n",
file, line, type, mtime, msg);
- return 0;
+ return bRC_OK;
}
-static bpError baculaDebugMsg(bpContext *ctx, const char *file, int line,
+static bRC baculaDebugMsg(bpContext *ctx, const char *file, int line,
int level, const char *msg)
{
Dmsg4(dbglvl, "Debug message: %s:%d level=%d msg=%s\n",
file, line, level, msg);
- return 0;
+ return bRC_OK;
}
#ifdef TEST_PROGRAM
typedef struct s_baculaFuncs {
uint32_t size;
uint32_t version;
- bpError (*registerBaculaEvents)(bpContext *ctx, ...);
- bpError (*getBaculaValue)(bpContext *ctx, brVariable var, void *value);
- bpError (*setBaculaValue)(bpContext *ctx, bwVariable var, void *value);
- bpError (*JobMessage)(bpContext *ctx, const char *file, int line,
+ bRC (*registerBaculaEvents)(bpContext *ctx, ...);
+ bRC (*getBaculaValue)(bpContext *ctx, brVariable var, void *value);
+ bRC (*setBaculaValue)(bpContext *ctx, bwVariable var, void *value);
+ bRC (*JobMessage)(bpContext *ctx, const char *file, int line,
int type, time_t mtime, const char *msg);
- bpError (*DebugMessage)(bpContext *ctx, const char *file, int line,
+ bRC (*DebugMessage)(bpContext *ctx, const char *file, int line,
int level, const char *msg);
} bFuncs;
typedef struct s_pluginFuncs {
uint32_t size;
uint32_t version;
- bpError (*newPlugin)(bpContext *ctx);
- 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);
+ bRC (*newPlugin)(bpContext *ctx);
+ bRC (*freePlugin)(bpContext *ctx);
+ bRC (*getPluginValue)(bpContext *ctx, pVariable var, void *value);
+ bRC (*setPluginValue)(bpContext *ctx, pVariable var, void *value);
+ bRC (*handlePluginEvent)(bpContext *ctx, bEvent *event);
} pFuncs;
#define plug_func(plugin) ((pFuncs *)(plugin->pfuncs))
#include "filed.h"
/* Forward referenced functions */
-static int save_file(FF_PKT *ff_pkt, void *pkt, bool top_level);
+int save_file(FF_PKT *ff_pkt, void *pkt, bool top_level);
static void strip_path(FF_PKT *ff_pkt);
static void unstrip_path(FF_PKT *ff_pkt);
static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, DIGEST *signature_digest);
* 0 if error
* -1 to ignore file/directory (not used here)
*/
-static int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level)
+int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level)
{
bool do_read = false;
int stat, data_stream;
ff_pkt->type == FT_REPARSE ||
(!is_portable_backup(&ff_pkt->bfd) && ff_pkt->type == FT_DIREND)) {
do_read = true;
+ } else if (ff_pkt->cmd_plugin) {
+ do_read = true;
}
if (do_read) {
* Kern Sibbald, October 2007
*/
#include "bacula.h"
-#include "jcr.h"
-#include "fd-plugins.h"
+#include "filed.h"
const int dbglvl = 50;
const char *plugin_type = "-fd.so";
+extern int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level);
+
+
/* Function pointers to be set here */
extern int (*plugin_bopen)(JCR *jcr, const char *fname, int flags, mode_t mode);
extern int (*plugin_bclose)(JCR *jcr);
return;
}
- bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
+ bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list;
event.eventType = eventType;
- Dmsg2(dbglvl, "plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx, jcr->JobId);
+ Dmsg2(dbglvl, "plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId);
if (eventType != bEventPluginCommand) {
/* Pass event to every plugin */
foreach_alist(plugin, plugin_list) {
- plug_func(plugin)->handlePluginEvent(&plugin_ctx[i++], &event, value);
+ plug_func(plugin)->handlePluginEvent(&plugin_ctx_list[i++], &event, value);
}
- return;
+ goto bail_out;
}
/* Handle plugin command here (backup/restore of file) */
+ Dmsg1(000, "plugin cmd=%s\n", cmd);
if (!(p = strchr(cmd, ':'))) {
Jmsg1(jcr, M_ERROR, 0, "Malformed plugin command: %s\n", cmd);
- return;
+ goto bail_out;
}
len = p - cmd;
- if (len > 0) {
- foreach_alist(plugin, plugin_list) {
- Dmsg3(000, "plugin=%s cmd=%s len=%d\n", plugin->file, cmd, len);
- if (strncmp(plugin->file, cmd, len) == 0) {
- Dmsg1(000, "Command plugin = %s\n", cmd);
- plug_func(plugin)->handlePluginEvent(&plugin_ctx[i], &event, value);
- return;
+ if (len <= 0) {
+ goto bail_out;
+ }
+
+ foreach_alist(plugin, plugin_list) {
+ Dmsg3(000, "plugin=%s cmd=%s len=%d\n", plugin->file, cmd, len);
+ if (strncmp(plugin->file, cmd, len) == 0) {
+ struct save_pkt sp;
+ FF_PKT *ff_pkt;
+ Dmsg1(000, "Command plugin = %s\n", cmd);
+ if (plug_func(plugin)->handlePluginEvent(&plugin_ctx_list[i], &event, value) != bRC_OK) {
+ goto bail_out;
}
- i++;
+ memset(&sp, 0, sizeof(sp));
+ sp.type = FT_REG;
+ sp.portable = true;
+ Dmsg0(000, "Plugin startBackup\n");
+ if (plug_func(plugin)->startPluginBackup(&plugin_ctx_list[i], &sp) != bRC_OK) {
+ goto bail_out;
+ }
+ jcr->plugin_ctx = &plugin_ctx_list[i];
+ jcr->plugin = plugin;
+ ff_pkt = jcr->ff;
+ ff_pkt->fname = sp.fname;
+ ff_pkt->type = sp.type;
+ ff_pkt->statp = sp.statp; /* structure copy */
+ Dmsg1(000, "Save_file: file=%s\n", ff_pkt->fname);
+ save_file(ff_pkt, (void *)jcr, true);
+ goto bail_out;
}
+ i++;
}
+bail_out:
+ return;
}
void load_fd_plugins(const char *plugin_dir)
plugin_list = New(alist(10, not_owned_by_alist));
load_plugins((void *)&binfo, (void *)&bfuncs, plugin_dir, plugin_type);
- plugin_bopen = my_plugin_bopen;
- plugin_bclose = my_plugin_bclose;
- plugin_bread = my_plugin_bread;
- plugin_bwrite = my_plugin_bwrite;
+ plugin_bopen = my_plugin_bopen;
+ plugin_bclose = my_plugin_bclose;
+ plugin_bread = my_plugin_bread;
+ plugin_bwrite = my_plugin_bwrite;
}
return;
}
- jcr->plugin_ctx = (void *)malloc(sizeof(bpContext) * num);
+ jcr->plugin_ctx_list = (void *)malloc(sizeof(bpContext) * num);
- bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
- Dmsg2(dbglvl, "Instantiate plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx, jcr->JobId);
+ bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list;
+ Dmsg2(dbglvl, "Instantiate plugin_ctx=%p JobId=%d\n", plugin_ctx_list, jcr->JobId);
foreach_alist(plugin, plugin_list) {
/* Start a new instance of each plugin */
- plugin_ctx[i].bContext = (void *)jcr;
- plugin_ctx[i].pContext = NULL;
- plug_func(plugin)->newPlugin(&plugin_ctx[i++]);
+ plugin_ctx_list[i].bContext = (void *)jcr;
+ plugin_ctx_list[i].pContext = NULL;
+ plug_func(plugin)->newPlugin(&plugin_ctx_list[i++]);
}
}
return;
}
- bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
- Dmsg2(dbglvl, "Free instance plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx, jcr->JobId);
+ bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list;
+ Dmsg2(dbglvl, "Free instance plugin_ctx=%p JobId=%d\n", plugin_ctx_list, jcr->JobId);
foreach_alist(plugin, plugin_list) {
/* Free the plugin instance */
- plug_func(plugin)->freePlugin(&plugin_ctx[i++]);
+ plug_func(plugin)->freePlugin(&plugin_ctx_list[i++]);
}
- free(plugin_ctx);
- jcr->plugin_ctx = NULL;
+ free(plugin_ctx_list);
+ jcr->plugin_ctx_list = NULL;
}
static int my_plugin_bopen(JCR *jcr, const char *fname, int flags, mode_t mode)
{
+ Plugin *plugin = (Plugin *)jcr->plugin;
+ bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
struct io_pkt io;
Dmsg0(000, "plugin_bopen\n");
io.func = IO_OPEN;
io.count = 0;
io.buf = NULL;
-
- return 0;
+ plug_func(plugin)->pluginIO(plugin_ctx, &io);
+ return io.status;
}
static int my_plugin_bclose(JCR *jcr)
{
+ Plugin *plugin = (Plugin *)jcr->plugin;
+ bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
struct io_pkt io;
Dmsg0(000, "plugin_bclose\n");
io.func = IO_CLOSE;
io.count = 0;
io.buf = NULL;
- return 0;
+ plug_func(plugin)->pluginIO(plugin_ctx, &io);
+ return io.status;
}
static ssize_t my_plugin_bread(JCR *jcr, void *buf, size_t count)
{
+ Plugin *plugin = (Plugin *)jcr->plugin;
+ bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
struct io_pkt io;
Dmsg0(000, "plugin_bread\n");
io.func = IO_READ;
io.count = count;
io.buf = (char *)buf;
- return 0;
+ plug_func(plugin)->pluginIO(plugin_ctx, &io);
+ return (ssize_t)io.status;
}
static ssize_t my_plugin_bwrite(JCR *jcr, void *buf, size_t count)
{
+ Plugin *plugin = (Plugin *)jcr->plugin;
+ bpContext *plugin_ctx = (bpContext *)jcr->plugin_ctx;
struct io_pkt io;
Dmsg0(000, "plugin_bwrite\n");
io.func = IO_WRITE;
io.count = count;
io.buf = (char *)buf;
- return 0;
+ plug_func(plugin)->pluginIO(plugin_ctx, &io);
+ return (ssize_t)io.status;
}
/* ==============================================================
ssize_t (*plugin_bread)(JCR *jcr, void *buf, size_t count) = NULL;
ssize_t (*plugin_bwrite)(JCR *jcr, void *buf, size_t count) = NULL;
+int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level)
+{
+ return 0;
+}
int main(int argc, char *argv[])
{
#undef _POSIX_C_SOURCE
#include <Python.h>
-/* External function pointers to be set */
-extern bool (*python_set_prog)(JCR *jcr, const char *prog);
-extern int (*python_open)(BFILE *bfd, const char *fname, int flags, mode_t mode);
-extern int (*python_close)(BFILE *bfd);
-extern ssize_t (*python_read)(BFILE *bfd, void *buf, size_t count);
-
extern JCR *get_jcr_from_PyObject(PyObject *self);
extern PyObject *find_method(PyObject *eventsObject, PyObject *method,
};
-bool my_python_set_prog(JCR *jcr, const char *prog);
-int my_python_open(BFILE *bfd, const char *fname, int flags, mode_t mode);
-int my_python_close(BFILE *bfd);
-ssize_t my_python_read(BFILE *bfd, void *buf, size_t count);
-
-
struct s_vars {
const char *name;
char *fmt;
Py_INCREF(eObject);
jcr->Python_events = (void *)eObject; /* set new events */
- /* Set function pointers to call here */
- python_set_prog = my_python_set_prog;
- python_open = my_python_open;
- python_close = my_python_close;
- python_read = my_python_read;
-
Py_INCREF(Py_None);
return Py_None;
}
}
-bool my_python_set_prog(JCR *jcr, const char *prog)
-{
- PyObject *events = (PyObject *)jcr->Python_events;
- BFILE *bfd = &jcr->ff->bfd;
- char method[MAX_NAME_LENGTH];
-
- if (!events) {
- return false;
- }
- bstrncpy(method, prog, sizeof(method));
- bstrncat(method, "_", sizeof(method));
- bstrncat(method, "open", sizeof(method));
- bfd->pio.fo = find_method(events, bfd->pio.fo, method);
- bstrncpy(method, prog, sizeof(method));
- bstrncat(method, "_", sizeof(method));
- bstrncat(method, "read", sizeof(method));
- bfd->pio.fr = find_method(events, bfd->pio.fr, method);
- bstrncpy(method, prog, sizeof(method));
- bstrncat(method, "_", sizeof(method));
- bstrncat(method, "close", sizeof(method));
- bfd->pio.fc = find_method(events, bfd->pio.fc, method);
- return bfd->pio.fo && bfd->pio.fr && bfd->pio.fc;
-}
-
-int my_python_open(BFILE *bfd, const char *fname, int flags, mode_t mode)
-{
- return -1;
-}
-
-int my_python_close(BFILE *bfd)
-{
- return 0;
-}
-
-ssize_t my_python_read(BFILE *bfd, void *buf, size_t count)
-{
- return -1;
-}
-
#else
/* Dummy if Python not configured */
#include "bacula.h"
#include "find.h"
-bool (*python_set_prog)(JCR *jcr, const char *prog) = NULL;
-int (*python_open)(BFILE *bfd, const char *fname, int flags, mode_t mode) = NULL;
-int (*python_close)(BFILE *bfd) = NULL;
-ssize_t (*python_read)(BFILE *bfd, void *buf, size_t count) = NULL;
-ssize_t (*python_write)(BFILE *bfd, void *buf, size_t count) = NULL;
-
int (*plugin_bopen)(JCR *jcr, const char *fname, int flags, mode_t mode) = NULL;
int (*plugin_bclose)(JCR *jcr) = NULL;
ssize_t (*plugin_bread)(JCR *jcr, void *buf, size_t count) = NULL;
#ifndef __BFILE_H
#define __BFILE_H
-#ifdef HAVE_PYTHON
-#undef _POSIX_C_SOURCE
-#include <Python.h>
-struct Python_IO {
- PyObject *fo;
- PyObject *fr;
- PyObject *fc;
-};
-#else
-struct Python_IO {
-};
-#endif
-
/* this should physically correspond to WIN32_STREAM_ID
* from winbase.h on Win32. We didn't inlcude cStreamName
DWORD lerror; /* Last error code */
int berrno; /* errno */
JCR *jcr; /* jcr for editing job codes */
- Python_IO pio; /* Python I/O routines */
PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */
int use_backup_decomp; /* set if using BackupRead Stream Decomposition */
bool reparse_point; /* set if reparse point */
int m_flags; /* open flags */
int berrno;
JCR *jcr; /* jcr for editing job codes */
- Python_IO pio; /* Python I/O routines */
PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */
int use_backup_decomp; /* set if using BackupRead Stream Decomposition */
bool reparse_point; /* not used in Unix */
}
foreach_dlist(node, &incexe->plugin_list) {
char *fname = node->c_str();
- Dmsg1(100, "P %s\n", fname);
+ Dmsg1(000, "PluginCommand: %s\n", fname);
ff->top_fname = fname;
ff->cmd_plugin = true;
generate_plugin_event(jcr, bEventPluginCommand, (void *)fname);
ATTR_DBR *ar; /* DB attribute record */
guid_list *id_list; /* User/group id to name list */
- void *plugin_ctx;
+ void *plugin_ctx_list; /* list of contexts for plugins */
+ void *plugin_ctx; /* current plugin context */
+ void *plugin; /* plugin instance */
/* Daemon specific part of JCR */
/* This should be empty in the library */
plugin->pHandle = dlopen(fname.c_str(), RTLD_NOW);
if (!plugin->pHandle) {
Jmsg(NULL, M_ERROR, 0, _("Plugin load %s failed: ERR=%s\n"),
- fname.c_str(), dlerror());
+ fname.c_str(), NPRT(dlerror()));
goto get_out;
}
loadPlugin = (t_loadPlugin)dlsym(plugin->pHandle, "loadPlugin");
if (!loadPlugin) {
Jmsg(NULL, M_ERROR, 0, _("Lookup of loadPlugin in plugin %s failed: ERR=%s\n"),
- fname.c_str(), dlerror());
+ fname.c_str(), NPRT(dlerror()));
goto get_out;
}
plugin->unloadPlugin = (t_unloadPlugin)dlsym(plugin->pHandle, "unloadPlugin");
if (!plugin->unloadPlugin) {
Jmsg(NULL, M_ERROR, 0, _("Lookup of unloadPlugin in plugin %s failed: ERR=%s\n"),
- fname.c_str(), dlerror());
+ fname.c_str(), NPRT(dlerror()));
goto get_out;
}
#include <stdio.h>
#include "fd-plugins.h"
+#undef malloc
+#undef free
+
#ifdef __cplusplus
extern "C" {
#endif
pluginIO
};
+struct plugin_ctx {
+ int record;
+};
+
bRC loadPlugin(bInfo *lbinfo, bFuncs *lbfuncs, pInfo **pinfo, pFuncs **pfuncs)
{
bfuncs = lbfuncs; /* set Bacula funct pointers */
binfo = lbinfo;
- printf("plugin: Loaded: size=%d version=%d\n", bfuncs->size, bfuncs->version);
+ printf("bpipe-fd: Loaded: size=%d version=%d\n", bfuncs->size, bfuncs->version);
*pinfo = &pluginInfo; /* return pointer to our info */
*pfuncs = &pluginFuncs; /* return pointer to our functions */
bRC unloadPlugin()
{
- printf("plugin: Unloaded\n");
+ printf("bpipe-fd: Unloaded\n");
return bRC_OK;
}
static bRC newPlugin(bpContext *ctx)
{
- int JobId = 0;
- bfuncs->getBaculaValue(ctx, bVarJobId, (void *)&JobId);
-// printf("plugin: newPlugin JobId=%d\n", JobId);
- bfuncs->registerBaculaEvents(ctx, 1, 2, 0);
+ struct plugin_ctx *p_ctx = (struct plugin_ctx *)malloc(sizeof(struct plugin_ctx));
+
+ p_ctx->record = -1;
+ ctx->pContext = (void *)p_ctx; /* set our context pointer */
return bRC_OK;
}
static bRC freePlugin(bpContext *ctx)
{
- int JobId = 0;
- bfuncs->getBaculaValue(ctx, bVarJobId, (void *)&JobId);
-// printf("plugin: freePlugin JobId=%d\n", JobId);
+ struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext;
+ free(p_ctx);
return bRC_OK;
}
static bRC getPluginValue(bpContext *ctx, pVariable var, void *value)
{
-// printf("plugin: getPluginValue var=%d\n", var);
return bRC_OK;
}
static bRC setPluginValue(bpContext *ctx, pVariable var, void *value)
{
-// printf("plugin: setPluginValue var=%d\n", var);
return bRC_OK;
}
switch (event->eventType) {
case bEventJobStart:
- printf("plugin: JobStart=%s\n", (char *)value);
+ printf("bpipe-fd: JobStart=%s\n", (char *)value);
break;
case bEventJobEnd:
- printf("plugin: JobEnd\n");
+ printf("bpipe-fd: JobEnd\n");
break;
case bEventBackupStart:
- printf("plugin: BackupStart\n");
+ printf("bpipe-fd: BackupStart\n");
break;
case bEventBackupEnd:
- printf("plugin: BackupEnd\n");
+ printf("bpipe-fd: BackupEnd\n");
break;
case bEventLevel:
- printf("plugin: JobLevel=%c %d\n", (int)value, (int)value);
+ printf("bpipe-fd: JobLevel=%c %d\n", (int)value, (int)value);
break;
case bEventSince:
- printf("plugin: since=%d\n", (int)value);
+ printf("bpipe-fd: since=%d\n", (int)value);
break;
/* Plugin command e.g. plugin = <plugin-name>:<name-space>:command */
case bEventPluginCommand:
- printf("plugin: command=%s\n", (char *)value);
+ printf("bpipe-fd: command=%s\n", (char *)value);
break;
default:
- printf("plugin: unknown event=%d\n", event->eventType);
+ printf("bpipe-fd: unknown event=%d\n", event->eventType);
}
bfuncs->getBaculaValue(ctx, bVarFDName, (void *)&name);
// printf("FD Name=%s\n", name);
static bRC startPluginBackup(bpContext *ctx, struct save_pkt *sp)
{
+ static char *fname = (char *)"/BPIPE/test.txt";
+ time_t now = time(NULL);
+ sp->fname = fname;
+ sp->statp.st_mode = 0700;
+ sp->statp.st_ctime = now;
+ sp->statp.st_mtime = now;
+ sp->statp.st_atime = now;
+ sp->statp.st_size = 100;
+ sp->statp.st_blksize = 4096;
+ sp->statp.st_blocks = 1;
+ printf("bpipe-fd: startPluginBackup\n");
return bRC_OK;
}
*/
static bRC pluginIO(bpContext *ctx, struct io_pkt *io)
{
+ struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext;
+
io->status = 0;
io->io_errno = 0;
switch(io->func) {
case IO_OPEN:
- printf("plugin: IO_OPEN\n");
+ p_ctx->record = 0;
+ printf("bpipe-fd: IO_OPEN\n");
break;
case IO_READ:
- printf("plugin: IO_READ buf=%p len=%d\n", io->buf, io->count);
+ printf("bpipe-fd: IO_READ buf=%p len=%d\n", io->buf, io->count);
+ if (p_ctx->record == 0) {
+ strcpy(io->buf, "This is a test string.\n");
+ io->status = strlen(io->buf);
+ p_ctx->record = 1;
+ return bRC_OK;
+ }
+ io->status = 0;
break;
case IO_WRITE:
- printf("plugin: IO_WRITE buf=%p len=%d\n", io->buf, io->count);
+ printf("bpipe-fd: IO_WRITE buf=%p len=%d\n", io->buf, io->count);
break;
case IO_CLOSE:
- printf("plugin: IO_CLOSE\n");
+ printf("bpipe-fd: IO_CLOSE\n");
break;
}
return bRC_OK;
#undef VERSION
#define VERSION "2.3.9"
-#define BDATE "02 February 2008"
-#define LSMDATE "02Feb08"
+#define BDATE "05 February 2008"
+#define LSMDATE "05Feb08"
#define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
#define BYEAR "2008" /* year for copyright messages in progs */