summaryrefslogtreecommitdiffstats
path: root/src/plugins/abrt-action-rhtsupport.c
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-01-20 21:32:58 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2011-01-20 21:32:58 +0100
commita0dc58e8355a0d4b98b9c88e0f26172b1418d7c9 (patch)
tree7baf8c43b8530cfd2d5557a6ae7479595e1c6fea /src/plugins/abrt-action-rhtsupport.c
parent3380e13c62e1b7a8309423f4eccfb4b6cbaa0310 (diff)
downloadabrt-a0dc58e8355a0d4b98b9c88e0f26172b1418d7c9.tar.gz
abrt-a0dc58e8355a0d4b98b9c88e0f26172b1418d7c9.tar.xz
abrt-a0dc58e8355a0d4b98b9c88e0f26172b1418d7c9.zip
add OPT_LIST mechanism to handle multiply occurring options
This allowed to convert abrt-action-bugzilla, abrt-action-rhtsupport and abrt-action-kerneloops to parse_opts() Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/plugins/abrt-action-rhtsupport.c')
-rw-r--r--src/plugins/abrt-action-rhtsupport.c68
1 files changed, 31 insertions, 37 deletions
diff --git a/src/plugins/abrt-action-rhtsupport.c b/src/plugins/abrt-action-rhtsupport.c
index 42859d5c..337adae1 100644
--- a/src/plugins/abrt-action-rhtsupport.c
+++ b/src/plugins/abrt-action-rhtsupport.c
@@ -22,7 +22,7 @@
#include "abrt_curl.h"
#include "abrt_xmlrpc.h"
#include "abrt_rh_support.h"
-#include "abrt_crash_data.h"
+#include "parse_options.h"
#define PROGNAME "abrt-action-rhtsupport"
@@ -256,44 +256,29 @@ int main(int argc, char **argv)
map_string_h *settings = new_map_string();
const char *dump_dir_name = ".";
+ GList *conf_file = NULL;
+
+ /* Can't keep these strings/structs static: _() doesn't support that */
+ const char *program_usage_string = _(
+ PROGNAME" [-vs] -c CONFFILE -d DIR"
+ "\n"
+ "\nReport a crash to RHTSupport"
+ );
enum {
- OPT_s = (1 << 0),
+ OPT_v = 1 << 0,
+ OPT_s = 1 << 1,
+ OPT_d = 1 << 2,
+ OPT_c = 1 << 3,
};
- int opts = 0;
- int opt;
- while ((opt = getopt(argc, argv, "c:d:vs")) != -1)
- {
- switch (opt)
- {
- case 'c':
- VERB1 log("Loading settings from '%s'", optarg);
- load_conf_file(optarg, settings, /*skip key w/o values:*/ true);
- VERB3 log("Loaded '%s'", optarg);
- break;
- case 'd':
- dump_dir_name = optarg;
- break;
- case 'v':
- g_verbose++;
- break;
- case 's':
- opts |= OPT_s;
- break;
- default:
- /* Careful: the string below contains tabs, dont replace with spaces */
- error_msg_and_die(
- "Usage: "PROGNAME" -c CONFFILE -d DIR [-vs]"
- "\n"
- "\nReport a crash to RHTSupport"
- "\n"
- "\nOptions:"
- "\n -c FILE Configuration file (may be given many times)"
- "\n -d DIR Crash dump directory"
- "\n -v Be verbose"
- "\n -s Log to syslog"
- );
- }
- }
+ /* Keep enum above and order of options below in sync! */
+ struct options program_options[] = {
+ OPT__VERBOSE(&g_verbose),
+ OPT_BOOL( 's', NULL, NULL , _("Log to syslog")),
+ OPT_STRING('d', NULL, &dump_dir_name, "DIR" , _("Crash dump directory")),
+ OPT_LIST( 'c', NULL, &conf_file , "FILE", _("Configuration file (may be given many times)")),
+ OPT_END()
+ };
+ unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
//DONT! our stdout/stderr goes directly to daemon, don't want to have prefix there.
@@ -304,6 +289,15 @@ int main(int argc, char **argv)
logmode = LOGMODE_SYSLOG;
}
+ while (conf_file)
+ {
+ char *fn = (char *)conf_file->data;
+ VERB1 log("Loading settings from '%s'", fn);
+ load_conf_file(fn, settings, /*skip key w/o values:*/ true);
+ VERB3 log("Loaded '%s'", fn);
+ conf_file = g_list_remove(conf_file, fn);
+ }
+
VERB1 log("Initializing XML-RPC library");
xmlrpc_env env;
xmlrpc_env_init(&env);