From: Kern Sibbald Date: Tue, 12 Feb 2008 15:59:55 +0000 (+0000) Subject: Plugin update X-Git-Tag: Release-7.0.0~5035 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8bd6a629a4b9c1dcfa9ca1b60d2aeb8d3bfd4ca0;p=bacula%2Fbacula Plugin update git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6404 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/filed/fd-plugins.c b/bacula/src/filed/fd-plugins.c index e562df1a05..f8a9bfb37d 100644 --- a/bacula/src/filed/fd-plugins.c +++ b/bacula/src/filed/fd-plugins.c @@ -53,9 +53,9 @@ static bRC baculaGetValue(bpContext *ctx, bVariable var, void *value); static bRC baculaSetValue(bpContext *ctx, bVariable 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); + int type, time_t mtime, const char *fmt, ...); static bRC baculaDebugMsg(bpContext *ctx, const char *file, int line, - int level, const char *msg); + int level, const char *fmt, ...); static int my_plugin_bopen(JCR *jcr, const char *fname, int flags, mode_t mode); static int my_plugin_bclose(JCR *jcr); @@ -499,18 +499,29 @@ static bRC baculaRegisterEvents(bpContext *ctx, ...) } static bRC baculaJobMsg(bpContext *ctx, const char *file, int line, - int type, time_t mtime, const char *msg) + int type, time_t mtime, const char *fmt, ...) { - Dmsg5(dbglvl, "Job message: %s:%d type=%d time=%ld msg=%s\n", - file, line, type, mtime, msg); + va_list arg_ptr; + char buf[2000]; + JCR *jcr = (JCR *)(ctx->bContext); + + va_start(arg_ptr, fmt); + bvsnprintf(buf, sizeof(buf), fmt, arg_ptr); + va_end(arg_ptr); + Jmsg(jcr, type, mtime, "%s", buf); return bRC_OK; } static bRC baculaDebugMsg(bpContext *ctx, const char *file, int line, - int level, const char *msg) + int level, const char *fmt, ...) { - Dmsg4(dbglvl, "Debug message: %s:%d level=%d msg=%s\n", - file, line, level, msg); + va_list arg_ptr; + char buf[2000]; + + va_start(arg_ptr, fmt); + bvsnprintf(buf, sizeof(buf), fmt, arg_ptr); + va_end(arg_ptr); + d_msg(file, line, level, "%s", buf); return bRC_OK; } diff --git a/bacula/src/filed/fd-plugins.h b/bacula/src/filed/fd-plugins.h index 941192be2c..78de898382 100644 --- a/bacula/src/filed/fd-plugins.h +++ b/bacula/src/filed/fd-plugins.h @@ -162,9 +162,9 @@ typedef struct s_baculaFuncs { bRC (*getBaculaValue)(bpContext *ctx, bVariable var, void *value); bRC (*setBaculaValue)(bpContext *ctx, bVariable var, void *value); bRC (*JobMessage)(bpContext *ctx, const char *file, int line, - int type, time_t mtime, const char *msg); + int type, time_t mtime, const char *fmt, ...); bRC (*DebugMessage)(bpContext *ctx, const char *file, int line, - int level, const char *msg); + int level, const char *fmt, ...); } bFuncs; diff --git a/bacula/src/lib/plugins.c b/bacula/src/lib/plugins.c index 3089a979a7..1e55091652 100644 --- a/bacula/src/lib/plugins.c +++ b/bacula/src/lib/plugins.c @@ -105,7 +105,7 @@ bool load_plugins(void *binfo, void *bfuncs, const char *plugin_dir, const char if (len < type_len+1 || strcmp(&result->d_name[len-type_len], type) != 0) { continue; } - Dmsg2(000, "Loaded plugin: name=%s len=%d\n", result->d_name, len); + Dmsg2(100, "Loaded plugin: name=%s len=%d\n", result->d_name, len); pm_strcpy(fname, plugin_dir); if (need_slash) { diff --git a/bacula/src/plugins/fd/bpipe-fd.c b/bacula/src/plugins/fd/bpipe-fd.c index 85aa062bca..9b16235e33 100644 --- a/bacula/src/plugins/fd/bpipe-fd.c +++ b/bacula/src/plugins/fd/bpipe-fd.c @@ -155,7 +155,7 @@ static bRC setPluginValue(bpContext *ctx, pVariable var, void *value) static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) { struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext; - char *name; +// char *name; switch (event->eventType) { case bEventJobStart: @@ -191,21 +191,21 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) p_ctx->cmd = strdup((char *)value); p = strchr(p_ctx->cmd, ':'); if (!p) { - printf("Plugin terminator not found: %s\n", (char *)value); + bfuncs->JobMessage(ctx, __FILE__, __LINE__, M_FATAL, 0, "Plugin terminator not found: %s\n", (char *)value); return bRC_Error; } *p++ = 0; /* terminate plugin */ p_ctx->fname = p; p = strchr(p, ':'); if (!p) { - printf("File terminator not found: %s\n", (char *)value); + bfuncs->JobMessage(ctx, __FILE__, __LINE__, M_FATAL, 0, "File terminator not found: %s\n", (char *)value); return bRC_Error; } *p++ = 0; /* terminate file */ p_ctx->reader = p; p = strchr(p, ':'); if (!p) { - printf("Reader terminator not found: %s\n", (char *)value); + bfuncs->JobMessage(ctx, __FILE__, __LINE__, M_FATAL, 0, "Reader terminator not found: %s\n", (char *)value); return bRC_Error; } *p++ = 0; /* terminate reader string */ @@ -217,7 +217,7 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) default: printf("bpipe-fd: unknown event=%d\n", event->eventType); } - bfuncs->getBaculaValue(ctx, bVarFDName, (void *)&name); +// bfuncs->getBaculaValue(ctx, bVarFDName, (void *)&name); // printf("FD Name=%s\n", name); // bfuncs->JobMessage(ctx, __FILE__, __LINE__, 1, 0, "JobMesssage message"); // bfuncs->DebugMessage(ctx, __FILE__, __LINE__, 1, "DebugMesssage message");