aboutsummaryrefslogtreecommitdiffstats
path: root/src/rspamadm/rspamadm.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-01 12:37:33 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-01 12:37:52 +0100
commit1937eac90de00ba64b7cd3fd51777c5b286e00b8 (patch)
treeb9b64d7ad5c4db3d9b4999b4e7111e7c015efd78 /src/rspamadm/rspamadm.c
parent111fb4d10cc15830e52611b663b2dbf5d8571b21 (diff)
downloadrspamd-1937eac90de00ba64b7cd3fd51777c5b286e00b8.tar.gz
rspamd-1937eac90de00ba64b7cd3fd51777c5b286e00b8.zip
[Minor] Fix option parsing in rspamadm
Diffstat (limited to 'src/rspamadm/rspamadm.c')
-rw-r--r--src/rspamadm/rspamadm.c73
1 files changed, 37 insertions, 36 deletions
diff --git a/src/rspamadm/rspamadm.c b/src/rspamadm/rspamadm.c
index 45a9171ed..9eeccb545 100644
--- a/src/rspamadm/rspamadm.c
+++ b/src/rspamadm/rspamadm.c
@@ -61,7 +61,7 @@ static GOptionEntry entries[] = {
"Redefine UCL variable", NULL},
{"help", 'h', 0, G_OPTION_ARG_NONE, &show_help,
"Show help", NULL},
- {"version", 'v', 0, G_OPTION_ARG_NONE, &show_version,
+ {"version", 'V', 0, G_OPTION_ARG_NONE, &show_version,
"Show version", NULL},
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}
};
@@ -346,38 +346,6 @@ main (gint argc, gchar **argv, gchar **env)
rspamadm_fill_internal_commands (all_commands);
help_command.command_data = all_commands;
- /* Setup logger */
- if (verbose) {
- cfg->log_level = G_LOG_LEVEL_DEBUG;
- }
- else {
- cfg->log_level = G_LOG_LEVEL_MESSAGE;
- }
-
- cfg->log_type = RSPAMD_LOG_CONSOLE;
- /* Avoid timestamps printing */
- cfg->log_flags = RSPAMD_LOG_FLAG_RSPAMADM;
- rspamd_set_logger (cfg, process_quark, &rspamd_main->logger,
- rspamd_main->server_pool);
- (void) rspamd_log_open (rspamd_main->logger);
- g_log_set_default_handler (rspamd_glib_log_function, rspamd_main->logger);
- g_set_printerr_handler (rspamd_glib_printerr_function);
- rspamd_config_post_load (cfg,
- RSPAMD_CONFIG_INIT_LIBS|RSPAMD_CONFIG_INIT_URL|RSPAMD_CONFIG_INIT_NO_TLD);
-
- pworker = &workers[0];
- while (*pworker) {
- /* Init string quarks */
- (void) g_quark_from_static_string ((*pworker)->name);
- pworker++;
- }
-
- cfg->compiled_modules = modules;
- cfg->compiled_workers = workers;
-
- gperf_profiler_init (cfg, "rspamadm");
- setproctitle ("rspamdadm");
-
/* Now read options and store everything till the first non-dash argument */
nargv = g_malloc0 (sizeof (gchar *) * (argc + 1));
nargv[0] = g_strdup (argv[0]);
@@ -400,19 +368,52 @@ main (gint argc, gchar **argv, gchar **env)
g_option_group_add_entries (og, entries);
g_option_context_set_summary (context,
"Summary:\n Rspamd administration utility version "
- RVERSION
- "\n Release id: "
- RID);
+ RVERSION
+ "\n Release id: "
+ RID);
g_option_context_set_main_group (context, og);
targv = nargv;
targc = nargc;
+
if (!g_option_context_parse (context, &targc, &targv, &error)) {
fprintf (stderr, "option parsing failed: %s\n", error->message);
g_error_free (error);
exit (1);
}
+ /* Setup logger */
+ if (verbose) {
+ cfg->log_level = G_LOG_LEVEL_DEBUG;
+ }
+ else {
+ cfg->log_level = G_LOG_LEVEL_MESSAGE;
+ }
+
+ cfg->log_type = RSPAMD_LOG_CONSOLE;
+ /* Avoid timestamps printing */
+ cfg->log_flags = RSPAMD_LOG_FLAG_RSPAMADM;
+ rspamd_set_logger (cfg, process_quark, &rspamd_main->logger,
+ rspamd_main->server_pool);
+ (void) rspamd_log_open (rspamd_main->logger);
+ g_log_set_default_handler (rspamd_glib_log_function, rspamd_main->logger);
+ g_set_printerr_handler (rspamd_glib_printerr_function);
+ rspamd_config_post_load (cfg,
+ RSPAMD_CONFIG_INIT_LIBS|RSPAMD_CONFIG_INIT_URL|RSPAMD_CONFIG_INIT_NO_TLD);
+
+ pworker = &workers[0];
+ while (*pworker) {
+ /* Init string quarks */
+ (void) g_quark_from_static_string ((*pworker)->name);
+ pworker++;
+ }
+
+ cfg->compiled_modules = modules;
+ cfg->compiled_workers = workers;
+
+ gperf_profiler_init (cfg, "rspamadm");
+ setproctitle ("rspamdadm");
+
L = cfg->lua_state;
rspamd_lua_set_path (L, NULL, ucl_vars);
rspamd_lua_set_globals (cfg, L, ucl_vars);