aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/cfg_utils.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-17 13:49:11 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-17 13:49:11 +0100
commit775530cc7484286079af2ca103fbe4dc351726d9 (patch)
treee4ade64a797fbc18400af5fcd65503c990a76549 /src/libserver/cfg_utils.c
parent85cb173e351c97dc559f1319ad2fc5ec8efd3bbf (diff)
downloadrspamd-775530cc7484286079af2ca103fbe4dc351726d9.tar.gz
rspamd-775530cc7484286079af2ca103fbe4dc351726d9.zip
Rework filters initialization.
Diffstat (limited to 'src/libserver/cfg_utils.c')
-rw-r--r--src/libserver/cfg_utils.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index cf9179d0a..510a6661a 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -815,6 +815,55 @@ rspamd_ucl_fin_cb (rspamd_mempool_t * pool, struct map_cb_data *data)
}
}
+gboolean
+rspamd_init_filters (struct rspamd_config *cfg, bool reconfig)
+{
+ GList *cur;
+ module_t *mod, **pmod;
+ struct module_ctx *mod_ctx;
+
+ /* Init all compiled modules */
+ for (pmod = modules; *pmod != NULL; pmod ++) {
+ mod = *pmod;
+ mod_ctx = g_slice_alloc0 (sizeof (struct module_ctx));
+
+ if (mod->module_init_func (cfg, &mod_ctx) == 0) {
+ g_hash_table_insert (cfg->c_modules,
+ (gpointer) mod->name,
+ mod_ctx);
+ }
+ }
+
+ cur = g_list_first (cfg->filters);
+
+ while (cur) {
+ /* Perform modules configuring */
+ mod = NULL;
+ for (pmod = modules; *pmod != NULL; pmod ++) {
+ if ((*pmod)->name && g_ascii_strcasecmp ((*pmod)->name,
+ cur->data) == 0) {
+ mod = *pmod;
+
+ if (reconfig) {
+ (void)mod->module_reconfig_func (cfg);
+ msg_debug ("reconfig of %s", mod->name);
+ }
+ else {
+ (void)mod->module_config_func (cfg);
+ }
+ }
+ }
+
+ if (mod == NULL) {
+ msg_warn ("requested unknown module %s", cur->data);
+ }
+
+ cur = g_list_next (cur);
+ }
+
+ return rspamd_init_lua_filters (cfg);
+}
+
/*
* vi:ts=4
*/