/* * Create a plugin event */ int generate_plugin_event(JCR *jcr, bsdEventType eventType, void *value) { bpContext *plugin_ctx; bsdEvent event; Plugin *plugin; int i = 0; bRC rc = bRC_OK; if (!bplugin_list || !jcr || !jcr->plugin_ctx_list) { return bRC_OK; /* Return if no plugins loaded */ } if (jcr->is_job_canceled()) { return bRC_Cancel; } bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list; event.eventType = eventType; Dmsg2(dbglvl, "sd-plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId); foreach_alist(plugin, bplugin_list) { plugin_ctx = &plugin_ctx_list[i++]; if (is_plugin_disabled(plugin_ctx)) { continue; } rc = sdplug_func(plugin)->handlePluginEvent(plugin_ctx, &event, value); if (rc != bRC_OK) { break; } }
static inline bRC trigger_plugin_event(JCR *jcr, bsdEventType eventType, bsdEvent *event, bpContext *ctx, void *value) { if (!is_event_enabled(ctx, eventType)) { Dmsg1(dbglvl, "Event %d disabled for this plugin.\n", eventType); return bRC_OK; } if (is_plugin_disabled(ctx)) { Dmsg0(dbglvl, "Plugin disabled.\n"); return bRC_OK; } return sdplug_func(ctx->plugin)->handlePluginEvent(ctx, event, value); }