- exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext;
- char *name;
- int i;
-
- switch (event->eventType) {
- case bEventJobStart:
- _DebugMessage(0, "JobStart=%s\n", (char *)value);
- break;
- case bEventJobEnd:
- _DebugMessage(0, "JobEnd\n");
- break;
- case bEventStartBackupJob:
- _DebugMessage(0, "BackupStart\n");
- context->job_type = JOB_TYPE_BACKUP;
- // level should have been specified by now - check it
- // if level is D or I, since should have been specified too
- switch (context->job_level)
- {
- case 'F':
- if (context->notrunconfull_option) {
- context->truncate_logs = false;
- } else {
- context->truncate_logs = true;
- }
- break;
- case 'D':
- context->truncate_logs = false;
- break;
- case 'I':
- context->truncate_logs = false;
- break;
- default:
- _DebugMessage(0, "Invalid job level %c\n", context->job_level);
- return bRC_Error;
- }
- break;
- case bEventEndBackupJob:
- _DebugMessage(0, "BackupEnd\n");
- break;
- case bEventLevel:
- _DebugMessage(0, "JobLevel=%c %d\n", (int)value, (int)value);
- context->job_level = (int)value;
- break;
- case bEventSince:
- _DebugMessage(0, "since=%d\n", (int)value);
- context->job_since = (time_t)value;
- break;
- case bEventStartRestoreJob:
- _DebugMessage(0, "StartRestoreJob\n");
- context->job_type = JOB_TYPE_RESTORE;
- break;
- case bEventEndRestoreJob:
- _DebugMessage(0, "EndRestoreJob\n");
- break;
-
- /* Plugin command e.g. plugin = <plugin-name>:<name-space>:command */
- case bEventRestoreCommand:
- _DebugMessage(0, "restore\n"); // command=%s\n", (char *)value);
- break;
-
- case bEventBackupCommand:
- {
- _DebugMessage(0, "backup command=%s\n", (char *)value);
- char *command = new char[strlen((char *)value)];
- strcpy(command, (char *)value);
- char *plugin_name = strtok((char *)command, ":");
- char *path = strtok(NULL, ":");
- char *option;
- while ((option = strtok(NULL, ":")) != NULL)
- {
- _DebugMessage(100, "option %s\n", option);
- if (stricmp(option, "notrunconfull") == 0)
- {
- context->notrunconfull_option = true;
- }
- else
- {
- _JobMessage(M_WARNING, "Unknown plugin option '%s'\n", option);
- }
- }
- _DebugMessage(0, "name = %s\n", plugin_name);
- _DebugMessage(0, "path = %s\n", path);
- if (*path != '/')
- {
- _JobMessage(M_ERROR, "Path does not begin with a '/'\n");
- return bRC_Error;
- }
-
- for (i = 0; i < 6; i++)
- context->path_bits[i] = NULL;
-
- char *path_bit = strtok(path, "/");
- for (i = 0; path_bit != NULL && i < 6; i++)
- {
- context->path_bits[i] = new char[strlen(path_bit) + 1];
- strcpy(context->path_bits[i], path_bit);
- path_bit = strtok(NULL, "/");
- }
-
- if (i < 2 || i > 4)
- {
- _JobMessage(M_ERROR, "Invalid plugin backup path\n");
- return bRC_Error;
- }
- context->root_node = new root_node_t(context->path_bits[0]);
- context->current_node = context->root_node;
-
- }
- break;
+ exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext;
+ char *name;
+ int i, intval;
+ int accurate;
+ char *command;
+ char *plugin_name;
+
+ switch (event->eventType) {
+ case bEventJobStart:
+ _DebugMessage(0, "JobStart=%s\n", (char *)value);
+ context->plugin_active = false;
+ break;
+ case bEventJobEnd:
+ _DebugMessage(0, "JobEnd\n");
+ break;
+ case bEventPluginCommand:
+ _DebugMessage(0, "bEventPluginCommand %s\n", value);
+ command = bstrdup((char *)value);
+ /* this isn't really unused */
+ plugin_name = strtok((char *)command, ":");
+ if (strcmp(plugin_name, "exchange") != 0) {
+ context->plugin_active = false;
+ } else {
+ context->plugin_active = true;
+ }
+ free(command);
+ break;
+ case bEventStartBackupJob:
+ if (!context->plugin_active) {
+ break;
+ }
+ _DebugMessage(0, "BackupStart\n");
+ bfuncs->getBaculaValue(ctx, bVarAccurate, (void *)&accurate);
+ context->accurate = accurate;
+ context->job_type = JOB_TYPE_BACKUP;
+ // level should have been specified by now - check it
+ // if level is D or I, since should have been specified too
+ switch (context->job_level) {
+ case 'F':
+ if (context->notrunconfull_option) {
+ context->truncate_logs = false;
+ } else {
+ context->truncate_logs = true;
+ }
+ break;
+ case 'D':
+ context->truncate_logs = false;
+ break;
+ case 'I':
+ context->truncate_logs = false;
+ break;
+ default:
+ _DebugMessage(0, "Invalid job level %c\n", context->job_level);
+ return bRC_Error;
+ }
+ break;
+ case bEventEndBackupJob:
+ _DebugMessage(0, "BackupEnd\n");
+ if (!context->plugin_active) {
+ break;
+ }
+ break;
+ case bEventLevel:
+ if (!context->plugin_active) {
+ break;
+ }
+ intval = (intptr_t)value;
+ _DebugMessage(0, "JobLevel=%c %d\n", intval, intval);
+ context->job_level = intval;
+ break;
+ case bEventSince:
+ if (!context->plugin_active) {
+ break;
+ }
+ intval = (intptr_t)value;
+ _DebugMessage(0, "since=%d\n", intval);
+ context->job_since = (time_t)value;
+ break;
+ case bEventStartRestoreJob:
+ _DebugMessage(0, "StartRestoreJob\n");
+ context->job_type = JOB_TYPE_RESTORE;
+ context->plugin_active = true;
+ break;
+ case bEventEndRestoreJob:
+ if (!context->plugin_active) {
+ break;
+ }
+ _DebugMessage(0, "EndRestoreJob\n");
+ context->plugin_active = false;
+ break;
+
+ /* Plugin command e.g. plugin = <plugin-name>:<name-space>:command */
+ case bEventRestoreCommand:
+ _DebugMessage(0, "restore\n"); // command=%s\n", (char *)value);
+ if (!context->plugin_active) {
+ break;
+ }
+ break;
+
+ case bEventBackupCommand:
+ if (!context->plugin_active) {
+ break;
+ }
+ {
+ _DebugMessage(0, "backup command=%s\n", (char *)value);
+ char *command = new char[strlen((char *)value)];
+ strcpy(command, (char *)value);
+ char *plugin_name = strtok((char *)command, ":");
+ char *path = strtok(NULL, ":");
+ char *option;
+ while ((option = strtok(NULL, ":")) != NULL) {
+ _DebugMessage(100, "option %s\n", option);
+ if (stricmp(option, "notrunconfull") == 0) {
+ context->notrunconfull_option = true;
+ } else {
+ _JobMessage(M_WARNING, "Unknown plugin option '%s'\n", option);
+ }
+ }
+ _DebugMessage(0, "name = %s\n", plugin_name);
+ _DebugMessage(0, "path = %s\n", path);
+ if (*path != '/') {
+ _JobMessage(M_FATAL, "Path does not begin with a '/'\n");
+ return bRC_Error;
+ }
+
+ for (i = 0; i < 6; i++) {
+ context->path_bits[i] = NULL;
+ }
+
+ char *path_bit = strtok(path, "/");
+ for (i = 0; path_bit != NULL && i < 6; i++) {
+ context->path_bits[i] = new char[strlen(path_bit) + 1];
+ strcpy(context->path_bits[i], path_bit);
+ path_bit = strtok(NULL, "/");
+ }
+
+ if (i < 2 || i > 4) {
+ _JobMessage(M_FATAL, "Invalid plugin backup path\n");
+ return bRC_Error;
+ }
+ context->root_node = new root_node_t(context->path_bits[0]);
+ context->current_node = context->root_node;
+
+ }
+ break;