]> source.dussan.org Git - rspamd.git/commitdiff
Init modules and workers in confighelp to get more doc strings
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 29 Dec 2015 09:04:41 +0000 (09:04 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 29 Dec 2015 09:04:41 +0000 (09:04 +0000)
src/rspamadm/confighelp.c

index 6a0492f1b8a3774b96b8cde3dbc071e84573dd80..1988989e5d615e9bf6bc2db1d0ce03ce5bb54062 100644 (file)
@@ -112,6 +112,9 @@ rspamadm_confighelp (gint argc, gchar **argv)
        const ucl_object_t *doc_obj;
        GOptionContext *context;
        GError *error = NULL;
+       module_t *mod, **pmod;
+       worker_t **pworker;
+       struct module_ctx *mod_ctx;
        gint i = 1, ret = 0;
 
        context = g_option_context_new (
@@ -131,9 +134,28 @@ rspamadm_confighelp (gint argc, gchar **argv)
        }
 
        cfg = rspamd_config_new ();
+       cfg->compiled_modules = modules;
+       cfg->compiled_workers = workers;
 
        top = rspamd_rcl_config_init (cfg);
 
+       /* Init modules to get documentation strings */
+       for (pmod = cfg->compiled_modules; pmod != NULL && *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);
+                       mod_ctx->mod = mod;
+               }
+       }
+       /* Also init all workers */
+       for (pworker = cfg->compiled_workers; *pworker != NULL; pworker ++) {
+               (*pworker)->worker_init_func (cfg);
+       }
+
        if (argc > 1) {
                while (argc > 1) {
                        if (argv[i][0] != '-') {
@@ -159,5 +181,7 @@ rspamadm_confighelp (gint argc, gchar **argv)
                rspamadm_confighelp_show (NULL, cfg->doc_strings);
        }
 
+       rspamd_config_free (cfg);
+
        exit (ret);
 }