---
src/plugins.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 54 insertions(+), 7 deletions(-)
diff --git a/src/plugins.c b/src/plugins.c
index 3600293..085366b 100644
--- a/src/plugins.c
+++ b/src/plugins.c
@@ -406,8 +406,8 @@ plugin_dump_fields (void)
plugin.dump_plugin ();
}
-void
-plugin_config (const char *key, const char *value)
+static int
+final_plugin_config (const char *key, const char *value)
{
assert (dl);
@@ -422,21 +422,68 @@ plugin_config (const char *key, const char *value)
exit (EXIT_FAILURE);
}
- if (plugin.config (key, value) == -1)
- exit (EXIT_FAILURE);
+ return plugin.config (key, value);
+}
+
+static int
+filter_plugin_config (void *data, const char *key, const char *value)
+{
+ if (data == NULL)
+ return final_plugin_config (key, value);
+ else {
+ struct filter *f = data;
+
+ debug ("%s: config key=%s, value=%s", f->filename, key, value);
+
+ if (f->filter.config)
+ if (f->filter.config (key, value, filter_plugin_config, f->next) == -1)
+ return -1;
+ return 0;
+ }
}
void
-plugin_config_complete (void)
+plugin_config (const char *key, const char *value)
+{
+ if (filter_plugin_config (filters, key, value) == -1)
+ exit (EXIT_FAILURE);
+}
+
+static int
+final_plugin_config_complete (void)
{
assert (dl);
debug ("%s: config_complete", filename);
if (!plugin.config_complete)
- return;
+ return 0;
+
+ return plugin.config_complete ();
+}
+
+static int
+filter_plugin_config_complete (void *data)
+{
+ if (data == NULL)
+ return final_plugin_config_complete ();
+ else {
+ struct filter *f = data;
+
+ debug ("%s: config_complete", f->filename);
- if (plugin.config_complete () == -1)
+ if (f->filter.config_complete)
+ if (f->filter.config_complete (filter_plugin_config_complete,
+ f->next) == -1)
+ return -1;
+ return 0;
+ }
+}
+
+void
+plugin_config_complete (void)
+{
+ if (filter_plugin_config_complete (filters) == -1)
exit (EXIT_FAILURE);
}
--
2.15.1