Plugin *plugin;
int i = 0;
- if (!plugin_list) {
+ if (!plugin_list || !jcr || !jcr->plugin_ctx_list) {
return;
}
Plugin *plugin;
int i = 0;
- if (!plugin_list) {
+ if (!plugin_list || !jcr->plugin_ctx_list) {
return;
}
*/
static bRC baculaGetValue(bpContext *ctx, brVariable var, void *value)
{
+ bRC ret=bRC_OK;
+
+ if (!ctx) {
+ return bRC_Error;
+ }
JCR *jcr = (JCR *)(ctx->bContext);
// Dmsg1(dbglvl, "bacula: baculaGetValue var=%d\n", var);
- if (!value) {
+ if (!jcr || !value) {
return bRC_Error;
}
// Dmsg1(dbglvl, "Bacula: jcr=%p\n", jcr);
*((int *)value) = jcr->JobId;
Dmsg1(dbglvl, "Bacula: return bVarJobId=%d\n", jcr->JobId);
break;
+ case bVarJobName:
+ *((char **)value) = jcr->Job;
+ Dmsg1(dbglvl, "Bacula: return bVarJobName=%s\n", jcr->Job);
+ break;
default:
+ ret = bRC_Error;
break;
}
- return bRC_OK;
+ return ret;
}
static bRC baculaSetValue(bpContext *ctx, bwVariable var, void *value)
typedef enum {
bEventJobStart = 1,
bEventJobEnd = 2,
- bEventExit = 3
+ bEventJobInit = 3,
+ bEventJobRun = 4,
+ bEventVolumePurged = 5
} bEventType;
typedef struct s_bEvent {
jcr->JobId, jcr->Job, jcr->jr.JobType, jcr->jr.JobLevel);
generate_daemon_event(jcr, "JobStart");
+ new_plugins(jcr); /* instantiate plugins for this jcr */
+ generate_plugin_event(jcr, bEventJobStart);
if (job_canceled(jcr)) {
goto bail_out;
}
generate_job_event(jcr, "JobInit");
+ generate_plugin_event(jcr, bEventJobInit);
Dsm_check(1);
return true;
Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
}
generate_job_event(jcr, "JobRun");
+ generate_plugin_event(jcr, bEventJobRun);
switch (jcr->get_JobType()) {
case JT_BACKUP:
}
generate_daemon_event(jcr, "JobEnd");
+ generate_plugin_event(jcr, bEventJobEnd);
Dmsg1(50, "======== End Job stat=%c ==========\n", jcr->JobStatus);
sm_check(__FILE__, __LINE__, true);
return NULL;
jcr->rstore_source = NULL;
}
+ free_plugins(jcr); /* release instantiated plugins */
+
/* Delete lists setup to hold storage pointers */
free_rwstorage(jcr);
}
pm_strcpy(jcr->VolumeName, mr->VolumeName);
generate_job_event(jcr, "VolumePurged");
+ generate_plugin_event(jcr, bEventVolumePurged);
/*
* If the RecyclePool is defined, move the volume there
*/
Plugin *plugin;
int i = 0;
- if (!plugin_list || !jcr->plugin_ctx_list) {
+ if (!plugin_list || !jcr || !jcr->plugin_ctx_list) {
return; /* Return if no plugins loaded */
}
switch (event->eventType) {
case bEventJobStart:
- printf("plugin: JobStart=%s\n", (char *)value);
+ printf("plugin: JobStart=%s\n", NPRT((char *)value));
break;
case bEventJobEnd:
printf("plugin: JobEnd\n");
printf("plugin: BackupEnd\n");
break;
case bEventLevel:
- printf("plugin: JobLevel=%c %d\n", *(int*)value, *(int*)value);
+ printf("plugin: JobLevel=%c %d\n", (int64_t)value, (int64_t)value);
break;
case bEventSince:
- printf("plugin: since=%d\n", *(int*)value);
+ printf("plugin: since=%d\n", (int64_t)value);
break;
case bEventStartRestoreJob:
printf("plugin: StartRestoreJob\n");
/* Plugin command e.g. plugin = <plugin-name>:<name-space>:command */
case bEventRestoreCommand:
- printf("plugin: backup command=%s\n", (char *)value);
+ printf("plugin: backup command=%s\n", NPRT((char *)value));
break;
case bEventBackupCommand:
- printf("plugin: backup command=%s\n", (char *)value);
+ printf("plugin: backup command=%s\n", NPRT((char *)value));
break;
default: