From c48d1aea1792ca3bcdd08b0662591046771244fa Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Tue, 23 Nov 2010 22:27:00 +0100 Subject: [PATCH] Tweak how we select a plugin for an event --- bacula/src/filed/fd_plugins.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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; } -- 2.39.5