struct save_pkt *sp = (struct save_pkt *)jcr->plugin_sp;
Dmsg1(000, "send_plugin_name=%s\n", sp->cmd);
+ /* Send stream header */
if (!sd->fsend("%ld %d 0", jcr->JobFiles+1, STREAM_PLUGIN_NAME)) {
Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
sd->bstrerror());
Dmsg1(000, "send: %s\n", sd->msg);
if (start) {
+ /* Send data -- not much */
stat = sd->fsend("%ld 1 %d %s%c", jcr->JobFiles+1, sp->portable, sp->cmd, 0);
} else {
- stat = sd->fsend("%ld 0");
+ /* Send end of data */
+ stat = sd->fsend("0 0");
}
if (!stat) {
Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
skip_nonspaces(&p); /* skip over jcr->JobFiles */
skip_spaces(&p);
start = *p == '1';
- skip_nonspaces(&p); /* skip start/end flag */
- skip_spaces(&p);
- portable = *p == '1';
- skip_nonspaces(&p); /* skip portable flag */
- skip_spaces(&p);
- cmd = p;
-
- /* Check for restore end */
- if (!start) {
+ if (start) {
+ /* Start of plugin data */
+ skip_nonspaces(&p); /* skip start/end flag */
+ skip_spaces(&p);
+ portable = *p == '1';
+ skip_nonspaces(&p); /* skip portable flag */
+ skip_spaces(&p);
+ cmd = p;
+ } else {
/*
- * If end of restore, notify plugin, then clear flags
+ * End of plugin data, notify plugin, then clear flags
*/
plugin = (Plugin *)jcr->plugin;
plug_func(plugin)->endRestoreFile(&plugin_ctx_list[i]);
return true;
}
+/*
+ * This entry point is called internally by Bacula to ensure
+ * that the plugin IO calls come into this code.
+ */
void load_fd_plugins(const char *plugin_dir)
{
Plugin *plugin;
#endif
#include <sys/types.h>
+
+#if defined(HAVE_WIN32)
+#if defined(HAVE_MINGW)
+#include "mingwconfig.h"
+#else
+#include "winconfig.h"
+#endif
+#else
#ifndef __CONFIG_H
-#define __CONFIG_H
#include "config.h"
+#define __CONFIG_H
+#endif
#endif
+
#include "bc_types.h"
#include "lib/plugins.h"
#include <sys/stat.h>
#define PLUGIN_AUTHOR "Kern Sibbald"
#define PLUGIN_DATE "January 2008"
#define PLUGIN_VERSION "1"
-#define PLUGIN_DESCRIPTION "Pipe File Daemon Plugin"
+#define PLUGIN_DESCRIPTION "Bacula Pipe File Daemon Plugin"
/* Forward referenced functions */
static bRC newPlugin(bpContext *ctx);
static bRC newPlugin(bpContext *ctx)
{
struct plugin_ctx *p_ctx = (struct plugin_ctx *)malloc(sizeof(struct plugin_ctx));
+ if (!p_ctx) {
+ return bRC_Error;
+ }
memset(p_ctx, 0, sizeof(struct plugin_ctx));
ctx->pContext = (void *)p_ctx; /* set our context pointer */
return bRC_OK;
free(p_ctx->cmd); /* free any allocated command string */
}
free(p_ctx); /* free our private context */
+ p_ctx = NULL;
return bRC_OK;
}
struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext;
// char *name;
+ /*
+ * Most events don't interest us so we ignore them.
+ * the printfs are so that plugin writers can enable them to see
+ * what is really going on.
+ */
switch (event->eventType) {
case bEventJobStart:
// printf("bpipe-fd: JobStart=%s\n", (char *)value);
// printf("bpipe-fd: JobEnd\n");
break;
case bEventStartBackupJob:
-// printf("bpipe-fd: BackupStart\n");
+// printf("bpipe-fd: StartBackupJob\n");
break;
case bEventEndBackupJob:
-// printf("bpipe-fd: BackupEnd\n");
+// printf("bpipe-fd: EndBackupJob\n");
break;
case bEventLevel:
// printf("bpipe-fd: JobLevel=%c %d\n", (int)value, (int)value);
break;
case bEventStartRestoreJob:
+// printf("bpipe-fd: StartRestoreJob\n");
break;
case bEventEndRestoreJob:
+// printf("bpipe-fd: EndRestoreJob\n");
break;
/* Plugin command e.g. plugin = <plugin-name>:<name-space>:read command:write command */
case bEventRestoreCommand:
printf("bpipe-fd: EventRestoreCommand cmd=%s\n", (char *)value);
+ /* Fall-through wanted */
case bEventBackupCommand:
char *p;
printf("bpipe-fd: pluginEvent cmd=%s\n", (char *)value);
omsg = (char*)malloc(strlen(imsg) + (w_count * (strlen(p_ctx->where)-2)) - r_count + 1);
if (!omsg) {
fprintf(stderr, "Out of memory.");
- exit(1);
+ return NULL;
}
*omsg = 0;
#undef VERSION
#define VERSION "2.5.3"
-#define BDATE "18 September 2008"
-#define LSMDATE "18Sep08"
+#define BDATE "24 September 2008"
+#define LSMDATE "24Sep08"
#define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
#define BYEAR "2008" /* year for copyright messages in progs */
remove reader/writer in FOPTS????
General:
+24Sep08
+kes Add more plugin documentation and fix include of config.h for
+ Win32 build (I hope).
22Sep08
ebl Revert to htable instead of rblist
ebl Cleanup accurate code (remove tcdbm parts) and use red/black