static bRC baculaNewOptions(bpContext *ctx);
static bRC baculaNewInclude(bpContext *ctx);
static bool is_plugin_compatible(Plugin *plugin);
+static bool get_plugin_name(JCR *jcr, char *cmd, int *ret);
/*
* These will be plugged into the global pointer structure for
bEvent event;
Plugin *plugin;
int i = 0;
+ char *name=NULL;
+ int len;
+ bRC rc;
if (!plugin_list || !jcr || !jcr->plugin_ctx_list || jcr->is_job_canceled()) {
return; /* Return if no plugins loaded */
}
+
+ /* Some events are sent to only a particular plugin */
+ switch(eventType) {
+ case bEventPluginCommand:
+ name = (char *)value;
+ if (!get_plugin_name(jcr, name, &len)) {
+ return;
+ }
+ break;
+ default:
+ break;
+ }
bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list;
event.eventType = eventType;
Dmsg2(dbglvl, "plugin_ctx=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId);
- /* Pass event to every plugin */
+ /* Pass event to every plugin (except if name is set) */
foreach_alist(plugin, plugin_list) {
- bRC rc;
+ if (name && strncmp(plugin->file, name, len) != 0) {
+ i++;
+ continue;
+ }
jcr->plugin_ctx = &plugin_ctx_list[i++];
jcr->plugin = plugin;
if (is_plugin_disabled(jcr)) {
return rc == bRC_Seen;
}
+static bool get_plugin_name(JCR *jcr, char *cmd, int *ret)
+{
+ char *p;
+ int len;
+ if (!cmd) {
+ return false;
+ }
+ /* Handle plugin command here backup */
+ Dmsg1(dbglvl, "plugin cmd=%s\n", cmd);
+ if (!(p = strchr(cmd, ':'))) {
+ Jmsg1(jcr, M_ERROR, 0, "Malformed plugin command: %s\n", cmd);
+ return false;
+ }
+ len = p - cmd;
+ if (len <= 0) {
+ return false;
+ }
+ *ret = len;
+ return true;
+}
/**
* Sequence of calls for a backup:
Plugin *plugin;
int i = 0;
int len;
- char *p;
char *cmd = ff_pkt->top_fname;
struct save_pkt sp;
bEvent event;
bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list;
event.eventType = bEventBackupCommand;
- /* Handle plugin command here backup */
- Dmsg1(dbglvl, "plugin cmd=%s\n", cmd);
- if (!(p = strchr(cmd, ':'))) {
- Jmsg1(jcr, M_ERROR, 0, "Malformed plugin command: %s\n", cmd);
- goto bail_out;
- }
- len = p - cmd;
- if (len <= 0) {
+ if (!get_plugin_name(jcr, cmd, &len)) {
goto bail_out;
}
bEventVssRestoreLoadComponentMetadata = 15,
bEventVssRestoreSetComponentsSelected = 16,
bEventRestoreObject = 17,
- bEventEndFileSet = 18
+ bEventEndFileSet = 18,
+ bEventPluginCommand = 19
} bEventType;
typedef struct s_bEvent {
return true;
}
+static void append_file(JCR *jcr, findINCEXE *incexe,
+ const char *buf, bool is_file)
+{
+ if (is_file) {
+ incexe->name_list.append(new_dlistString(buf));
+
+ } else if (me->plugin_directory) {
+ generate_plugin_event(jcr, bEventPluginCommand, (void *)buf);
+ incexe->plugin_list.append(new_dlistString(buf));
+
+ } else {
+ Jmsg(jcr, M_FATAL, 0,
+ _("Plugin Directory not defined. Cannot use plugin: \"%s\"\n"),
+ buf);
+ }
+}
/**
* Add fname to include/exclude fileset list. First check for
free_pool_memory(fn);
while (fgets(buf, sizeof(buf), bpipe->rfd)) {
strip_trailing_junk(buf);
- if (is_file) {
- fileset->incexe->name_list.append(new_dlistString(buf));
- } else {
- fileset->incexe->plugin_list.append(new_dlistString(buf));
- }
+ append_file(jcr, fileset->incexe, buf, is_file);
}
if ((stat=close_bpipe(bpipe)) != 0) {
berrno be;
p++; /* skip over < */
if ((ffd = fopen(p, "rb")) == NULL) {
berrno be;
- Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"),
+ Jmsg(jcr, M_FATAL, 0,
+ _("Cannot open FileSet input file: %s. ERR=%s\n"),
p, be.bstrerror());
return;
}
while (fgets(buf, sizeof(buf), ffd)) {
strip_trailing_junk(buf);
- Dmsg1(100, "%s\n", buf);
- if (is_file) {
- fileset->incexe->name_list.append(new_dlistString(buf));
- } else {
- fileset->incexe->plugin_list.append(new_dlistString(buf));
- }
- }
+ append_file(jcr, fileset->incexe, buf, is_file);
+ }
fclose(ffd);
break;
default:
- if (is_file) {
- fileset->incexe->name_list.append(new_dlistString(fname));
- } else {
- if (me->plugin_directory) {
- fileset->incexe->plugin_list.append(new_dlistString(fname));
- } else {
- Jmsg(jcr, M_FATAL, 0, _("Plugin Directory not defined. Cannot use plugin: \"%\"\n"),
- fname);
- }
- }
+ append_file(jcr, fileset->incexe, fname, is_file);
break;
}
}