From: Kern Sibbald Date: Wed, 24 Sep 2008 13:03:29 +0000 (+0000) Subject: Add more plugin documentation and fix include of config.h for X-Git-Tag: Release-3.0.0~951 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=51dacba2d1b2083ea184462bbfad789061006f3d;p=bacula%2Fbacula Add more plugin documentation and fix include of config.h for Win32 build (I hope). git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7626 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index d193027be1..d72f7700f1 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -206,6 +206,7 @@ bool send_plugin_name(JCR *jcr, BSOCK *sd, bool start) 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()); @@ -214,9 +215,11 @@ bool send_plugin_name(JCR *jcr, BSOCK *sd, bool start) 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"), @@ -246,17 +249,17 @@ void plugin_name_stream(JCR *jcr, char *name) 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]); @@ -359,6 +362,10 @@ bool plugin_set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd) 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; diff --git a/bacula/src/filed/fd_plugins.h b/bacula/src/filed/fd_plugins.h index 191f6fc965..8625de7fc8 100644 --- a/bacula/src/filed/fd_plugins.h +++ b/bacula/src/filed/fd_plugins.h @@ -49,10 +49,20 @@ #endif #include + +#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 diff --git a/bacula/src/plugins/fd/bpipe-fd.c b/bacula/src/plugins/fd/bpipe-fd.c index c6787d9035..fa2488a6ad 100644 --- a/bacula/src/plugins/fd/bpipe-fd.c +++ b/bacula/src/plugins/fd/bpipe-fd.c @@ -45,7 +45,7 @@ extern "C" { #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); @@ -153,6 +153,9 @@ bRC unloadPlugin() 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; @@ -168,6 +171,7 @@ static bRC freePlugin(bpContext *ctx) free(p_ctx->cmd); /* free any allocated command string */ } free(p_ctx); /* free our private context */ + p_ctx = NULL; return bRC_OK; } @@ -195,6 +199,11 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) 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); @@ -203,10 +212,10 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *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); @@ -216,14 +225,17 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) break; case bEventStartRestoreJob: +// printf("bpipe-fd: StartRestoreJob\n"); break; case bEventEndRestoreJob: +// printf("bpipe-fd: EndRestoreJob\n"); break; /* Plugin command e.g. plugin = ::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); @@ -460,7 +472,7 @@ static char *apply_rp_codes(struct plugin_ctx * p_ctx) 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; diff --git a/bacula/src/version.h b/bacula/src/version.h index 9e37690438..94e7bf20f1 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #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 */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index ea88e2de3a..4c9ec3f11c 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -18,6 +18,9 @@ dbdriver 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