From 6088008d6c307a553b896eacee60a7ae69fda9dd Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 19 Mar 2009 12:25:14 +0300 Subject: * With flag -t syntax of modules variables is also inspected * Set "C" locale on start to avoid some troubles with logging --- src/main.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 16af301dc..56bad7e67 100644 --- a/src/main.c +++ b/src/main.c @@ -383,7 +383,15 @@ main (int argc, char **argv, char **env) else { cfg->log_level = G_LOG_LEVEL_CRITICAL; } - + +#ifdef HAVE_SETLOCALE + /* Set locale setting to C locale to avoid problems in future */ + setlocale (LC_ALL, "C"); + setlocale (LC_CTYPE, "C"); + setlocale (LC_MESSAGES, "C"); + setlocale (LC_TIME, "C"); +#endif + /* First set logger to console logger */ cfg->log_fd = STDERR_FILENO; g_log_set_default_handler (file_log_function, cfg); @@ -406,9 +414,26 @@ main (int argc, char **argv, char **env) fclose (f); + /* Init C modules */ + for (i = 0; i < MODULES_NUM; i ++) { + cur_module = memory_pool_alloc (rspamd->cfg->cfg_pool, sizeof (struct module_ctx)); + if (modules[i].module_init_func(cfg, &cur_module) == 0) { + g_hash_table_insert (cfg->c_modules, (gpointer)modules[i].name, cur_module); + } + } + if (cfg->config_test) { - fprintf (stderr, "syntax OK\n"); - return EXIT_SUCCESS; + /* Init events to test modules */ + event_init (); + res = TRUE; + /* Perform modules configuring */ + for (i = 0; i < MODULES_NUM; i ++) { + if (!modules[i].module_config_func (cfg)) { + res = FALSE; + } + } + fprintf (stderr, "syntax %s\n", res ? "OK" : "BAD"); + return res ? EXIT_SUCCESS : EXIT_FAILURE; } /* Create listen socket */ @@ -450,14 +475,6 @@ main (int argc, char **argv, char **env) exit (-errno); } - /* Init C modules */ - for (i = 0; i < MODULES_NUM; i ++) { - cur_module = memory_pool_alloc (rspamd->cfg->cfg_pool, sizeof (struct module_ctx)); - if (modules[i].module_init_func(cfg, &cur_module) == 0) { - g_hash_table_insert (cfg->c_modules, (gpointer)modules[i].name, cur_module); - } - } - rspamd->pid = getpid(); rspamd->type = TYPE_MAIN; -- cgit v1.2.3