From: Eric Bollengier Date: Tue, 23 Nov 2010 21:27:00 +0000 (+0100) Subject: Tweak how we select a plugin for an event X-Git-Tag: Release-5.2.1~885 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=391cf2ca1302c0fb5883d60cee97f46838ef55fc;p=bacula%2Fbacula Tweak how we select a plugin for an event --- diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index d57faacf66..e02f023f80 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -87,6 +87,7 @@ static ssize_t my_plugin_bread(BFILE *bfd, void *buf, size_t count); static ssize_t my_plugin_bwrite(BFILE *bfd, void *buf, size_t count); static boffset_t my_plugin_blseek(BFILE *bfd, boffset_t offset, int whence); +#define for_this_plug(plugin, str, len) (((len) == (plugin)->len) && strncmp((plugin)->file, str, len) == 0) /* Bacula info */ static bInfo binfo = { @@ -197,7 +198,7 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) /* Pass event to every plugin (except if name is set) */ foreach_alist(plugin, plugin_list) { - if (name && strncmp(plugin->file, name, len) != 0) { + if (name && !for_this_plug(plugin, name, len)) { i++; continue; } @@ -254,7 +255,7 @@ bool plugin_check_file(JCR *jcr, char *fname) /* Get the first part of the the plugin command * systemstate:/@SYSTEMSTATE/ * => ret = 11 - * => can use strncmp(plugin_name, cmd, ret); + * => can use for_this_plug(plug, cmd, ret); * * The plugin command can contain only the plugin name * Plugin = alldrives @@ -328,7 +329,7 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) /* Note, we stop the loop on the first plugin that matches the name */ foreach_alist(plugin, plugin_list) { Dmsg4(0, "plugin=%s plen=%d cmd=%s len=%d\n", plugin->file, plugin->len, cmd, len); - if ((plugin->len != len) || (strncmp(plugin->file, cmd, len) != 0)) { + if (!for_this_plug(plugin, cmd, len)) { i++; continue; } @@ -538,7 +539,7 @@ bool plugin_name_stream(JCR *jcr, char *name) foreach_alist(plugin, plugin_list) { bEvent event; Dmsg3(dbglvl, "plugin=%s cmd=%s len=%d\n", plugin->file, cmd, len); - if ((plugin->len != len) || (strncmp(plugin->file, cmd, len) != 0)) { + if (!for_this_plug(plugin, cmd, len)) { i++; continue; }