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);
}
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;
}
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;
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) {
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:
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 */
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");