summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-01-20 20:33:34 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2011-01-20 20:33:34 +0100
commite3d48ee0458f1d0078da65bad99804d2ba58aaf0 (patch)
tree5495c0a50ba3357025a3deb7b5c72c3af9cfc9fe /src/plugins
parentd7d62ea5ee19f5cad52dcfb2f2a49d8d36fa1228 (diff)
downloadabrt-e3d48ee0458f1d0078da65bad99804d2ba58aaf0.tar.gz
abrt-e3d48ee0458f1d0078da65bad99804d2ba58aaf0.tar.xz
abrt-e3d48ee0458f1d0078da65bad99804d2ba58aaf0.zip
make option handling more regular across all tools
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/abrt-action-analyze-c.c12
-rw-r--r--src/plugins/abrt-action-analyze-oops.c8
-rw-r--r--src/plugins/abrt-action-analyze-python.c12
-rw-r--r--src/plugins/abrt-action-bugzilla.cpp8
-rw-r--r--src/plugins/abrt-action-generate-backtrace.c58
-rw-r--r--src/plugins/abrt-action-kerneloops.c8
-rw-r--r--src/plugins/abrt-action-mailx.c8
-rw-r--r--src/plugins/abrt-action-print.c9
-rw-r--r--src/plugins/abrt-action-rhtsupport.c8
-rw-r--r--src/plugins/abrt-action-upload.c8
-rw-r--r--src/plugins/abrt-dump-oops.c17
11 files changed, 75 insertions, 81 deletions
diff --git a/src/plugins/abrt-action-analyze-c.c b/src/plugins/abrt-action-analyze-c.c
index e45e39cf..a736c4f8 100644
--- a/src/plugins/abrt-action-analyze-c.c
+++ b/src/plugins/abrt-action-analyze-c.c
@@ -149,28 +149,28 @@ int main(int argc, char **argv)
if (env_verbose)
g_verbose = atoi(env_verbose);
+ const char *dump_dir_name = ".";
+
/* Can't keep these strings/structs static: _() doesn't support that */
const char *program_usage_string = _(
- PROGNAME" [-vs] -d DIR\n\n"
+ PROGNAME" [-v] -d DIR\n\n"
"Calculates and saves UUID of coredumps"
- );
- const char *dump_dir_name = ".";
+ );
enum {
OPT_v = 1 << 0,
OPT_d = 1 << 1,
- OPT_s = 1 << 2,
+// OPT_s = 1 << 2,
};
/* Keep enum above and order of options below in sync! */
struct options program_options[] = {
OPT__VERBOSE(&g_verbose),
OPT_STRING('d', NULL, &dump_dir_name, "DIR", _("Crash dump directory")),
- OPT_BOOL( 's', NULL, NULL, _("Log to syslog" )),
+// OPT_BOOL( 's', NULL, NULL, _("Log to syslog" )),
OPT_END()
};
/*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage_string);
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
-
msg_prefix = PROGNAME;
//Maybe we will want this... later
// if (opts & OPT_s)
diff --git a/src/plugins/abrt-action-analyze-oops.c b/src/plugins/abrt-action-analyze-oops.c
index 24538641..0072c71d 100644
--- a/src/plugins/abrt-action-analyze-oops.c
+++ b/src/plugins/abrt-action-analyze-oops.c
@@ -126,28 +126,28 @@ int main(int argc, char **argv)
if (env_verbose)
g_verbose = atoi(env_verbose);
+ const char *dump_dir_name = ".";
+
/* Can't keep these strings/structs static: _() doesn't support that */
const char *program_usage_string = _(
PROGNAME" [-vs] -d DIR\n\n"
"Calculates and saves UUID and DUPHASH of oops crash dumps"
);
- const char *dump_dir_name = ".";
enum {
OPT_v = 1 << 0,
OPT_d = 1 << 1,
- OPT_s = 1 << 2,
+// OPT_s = 1 << 2,
};
/* Keep enum above and order of options below in sync! */
struct options program_options[] = {
OPT__VERBOSE(&g_verbose),
OPT_STRING('d', NULL, &dump_dir_name, "DIR", _("Crash dump directory")),
- OPT_BOOL( 's', NULL, NULL, _("Log to syslog" )),
+// OPT_BOOL( 's', NULL, NULL, _("Log to syslog" )),
OPT_END()
};
/*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage_string);
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
-
msg_prefix = PROGNAME;
//Maybe we will want this... later
// if (opts & OPT_s)
diff --git a/src/plugins/abrt-action-analyze-python.c b/src/plugins/abrt-action-analyze-python.c
index 9fe563db..feffb439 100644
--- a/src/plugins/abrt-action-analyze-python.c
+++ b/src/plugins/abrt-action-analyze-python.c
@@ -31,28 +31,28 @@ int main(int argc, char **argv)
if (env_verbose)
g_verbose = atoi(env_verbose);
+ const char *dump_dir_name = ".";
+
/* Can't keep these strings/structs static: _() doesn't support that */
const char *program_usage_string = _(
- PROGNAME" [-vs] -d DIR\n\n"
+ PROGNAME" [-v] -d DIR\n\n"
"Calculates and saves UUID and DUPHASH of python crash dumps"
- );
- const char *dump_dir_name = ".";
+ );
enum {
OPT_v = 1 << 0,
OPT_d = 1 << 1,
- OPT_s = 1 << 2,
+// OPT_s = 1 << 2,
};
/* Keep enum above and order of options below in sync! */
struct options program_options[] = {
OPT__VERBOSE(&g_verbose),
OPT_STRING('d', NULL, &dump_dir_name, "DIR", _("Crash dump directory")),
- OPT_BOOL( 's', NULL, NULL, _("Log to syslog" )),
+// OPT_BOOL( 's', NULL, NULL, _("Log to syslog" )),
OPT_END()
};
/*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage_string);
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
-
msg_prefix = PROGNAME;
//Maybe we will want this... later
// if (opts & OPT_s)
diff --git a/src/plugins/abrt-action-bugzilla.cpp b/src/plugins/abrt-action-bugzilla.cpp
index 19735452..9d849d99 100644
--- a/src/plugins/abrt-action-bugzilla.cpp
+++ b/src/plugins/abrt-action-bugzilla.cpp
@@ -906,7 +906,7 @@ int main(int argc, char **argv)
enum {
OPT_s = (1 << 0),
};
- int optflags = 0;
+ int opts = 0;
int opt;
while ((opt = getopt(argc, argv, "c:d:vs")) != -1)
{
@@ -924,7 +924,7 @@ int main(int argc, char **argv)
g_verbose++;
break;
case 's':
- optflags |= OPT_s;
+ opts |= OPT_s;
break;
default:
/* Careful: the string below contains tabs, dont replace with spaces */
@@ -943,11 +943,9 @@ int main(int argc, char **argv)
}
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
-
//DONT! our stdout/stderr goes directly to daemon, don't want to have prefix there.
// msg_prefix = xasprintf("abrt-action-bugzilla[%u]", getpid());
-
- if (optflags & OPT_s)
+ if (opts & OPT_s)
{
openlog(msg_prefix, 0, LOG_DAEMON);
logmode = LOGMODE_SYSLOG;
diff --git a/src/plugins/abrt-action-generate-backtrace.c b/src/plugins/abrt-action-generate-backtrace.c
index a575a191..05f878e2 100644
--- a/src/plugins/abrt-action-generate-backtrace.c
+++ b/src/plugins/abrt-action-generate-backtrace.c
@@ -28,7 +28,7 @@
#define DEBUGINFO_CACHE_DIR LOCALSTATEDIR"/cache/abrt-di"
static const char *dump_dir_name = ".";
-static const char *debuginfo_dirs;
+static const char *debuginfo_dirs = DEBUGINFO_CACHE_DIR;
static int exec_timeout_sec = 60;
@@ -244,49 +244,49 @@ static char *get_backtrace(struct dump_dir *dd)
return bt;
}
-static char *i_opt;
-static const char abrt_action_generage_backtrace_usage[] = PROGNAME" [options] -d DIR";
-enum {
- OPT_v = 1 << 0,
- OPT_d = 1 << 1,
- OPT_i = 1 << 2,
- OPT_t = 1 << 3,
- OPT_s = 1 << 4,
-};
-/* Keep enum above and order of options below in sync! */
-static struct options abrt_action_generate_backtrace_options[] = {
- OPT__VERBOSE(&g_verbose),
- OPT_STRING( 'd', NULL, &dump_dir_name, "DIR", "Crash dump directory"),
- OPT_STRING( 'i', NULL, &i_opt, "dir1[:dir2]...", "Additional debuginfo directories"),
- OPT_INTEGER('t', NULL, &exec_timeout_sec, "Kill gdb if it runs for more than N seconds"),
- OPT_BOOL( 's', NULL, NULL, "Log to syslog"),
- OPT_END()
-};
-
int main(int argc, char **argv)
{
char *env_verbose = getenv("ABRT_VERBOSE");
if (env_verbose)
g_verbose = atoi(env_verbose);
- unsigned opts = parse_opts(argc, argv, abrt_action_generate_backtrace_options,
- abrt_action_generage_backtrace_usage);
-
- debuginfo_dirs = DEBUGINFO_CACHE_DIR;
- if (i_opt)
- {
- debuginfo_dirs = xasprintf("%s:%s", DEBUGINFO_CACHE_DIR, i_opt);
- }
+ char *i_opt = NULL;
+
+ /* Can't keep these strings/structs static: _() doesn't support that */
+ const char *program_usage_string = _(
+ PROGNAME" [options] -d DIR"
+ );
+ enum {
+ OPT_v = 1 << 0,
+ OPT_d = 1 << 1,
+ OPT_i = 1 << 2,
+ OPT_t = 1 << 3,
+ OPT_s = 1 << 4,
+ };
+ /* Keep enum above and order of options below in sync! */
+ struct options program_options[] = {
+ OPT__VERBOSE(&g_verbose),
+ OPT_STRING( 'd', NULL, &dump_dir_name , "DIR" , _("Crash dump directory")),
+ OPT_STRING( 'i', NULL, &i_opt , "dir1[:dir2]...", _("Additional debuginfo directories")),
+ OPT_INTEGER('t', NULL, &exec_timeout_sec, _("Kill gdb if it runs for more than N seconds")),
+ OPT_BOOL( 's', NULL, NULL , _("Log to syslog")),
+ OPT_END()
+ };
+ unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
msg_prefix = PROGNAME;
-
if (opts & OPT_s)
{
openlog(msg_prefix, 0, LOG_DAEMON);
logmode = LOGMODE_SYSLOG;
}
+ if (i_opt)
+ {
+ debuginfo_dirs = xasprintf("%s:%s", DEBUGINFO_CACHE_DIR, i_opt);
+ }
+
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
if (!dd)
return 1;
diff --git a/src/plugins/abrt-action-kerneloops.c b/src/plugins/abrt-action-kerneloops.c
index 160b6412..4fef19b4 100644
--- a/src/plugins/abrt-action-kerneloops.c
+++ b/src/plugins/abrt-action-kerneloops.c
@@ -129,7 +129,7 @@ int main(int argc, char **argv)
enum {
OPT_s = (1 << 0),
};
- int optflags = 0;
+ int opts = 0;
int opt;
while ((opt = getopt(argc, argv, "c:d:vs")) != -1)
{
@@ -147,7 +147,7 @@ int main(int argc, char **argv)
g_verbose++;
break;
case 's':
- optflags |= OPT_s;
+ opts |= OPT_s;
break;
default:
/* Careful: the string below contains tabs, dont replace with spaces */
@@ -166,11 +166,9 @@ int main(int argc, char **argv)
}
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
-
//DONT! our stdout/stderr goes directly to daemon, don't want to have prefix there.
// msg_prefix = xasprintf(PROGNAME"[%u]", getpid());
-
- if (optflags & OPT_s)
+ if (opts & OPT_s)
{
openlog(msg_prefix, 0, LOG_DAEMON);
logmode = LOGMODE_SYSLOG;
diff --git a/src/plugins/abrt-action-mailx.c b/src/plugins/abrt-action-mailx.c
index 00f73d03..0ac5454d 100644
--- a/src/plugins/abrt-action-mailx.c
+++ b/src/plugins/abrt-action-mailx.c
@@ -133,7 +133,8 @@ int main(int argc, char **argv)
const char *dump_dir_name = ".";
const char *conf_file = NULL;
- const char *program_usage = _(
+ /* Can't keep these strings/structs static: _() doesn't support that */
+ const char *program_usage_string = _(
PROGNAME" [-v] -d DIR [-c CONFFILE]\n"
"\n"
"Upload compressed tarball of crash dump"
@@ -150,12 +151,11 @@ int main(int argc, char **argv)
OPT_STRING('c', NULL, &conf_file , "CONFFILE", _("Config file")),
OPT_END()
};
-
- /*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage);
+ /*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage_string);
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
//msg_prefix = PROGNAME;
- //if (optflags & OPT_s)
+ //if (opts & OPT_s)
//{
// openlog(msg_prefix, 0, LOG_DAEMON);
// logmode = LOGMODE_SYSLOG;
diff --git a/src/plugins/abrt-action-print.c b/src/plugins/abrt-action-print.c
index 86a9a1d0..830d0b11 100644
--- a/src/plugins/abrt-action-print.c
+++ b/src/plugins/abrt-action-print.c
@@ -34,10 +34,12 @@ int main(int argc, char **argv)
if (env_verbose)
g_verbose = atoi(env_verbose);
- const char *program_usage = _(
+ /* Can't keep these strings/structs static: _() doesn't support that */
+ const char *program_usage_string = _(
PROGNAME" [-v] [-o FILE] -d DIR\n"
"\n"
- "Print information about the crash to standard output");
+ "Print information about the crash to standard output"
+ );
enum {
OPT_v = 1 << 0,
OPT_d = 1 << 1,
@@ -50,8 +52,7 @@ int main(int argc, char **argv)
OPT_STRING('o', NULL, &output_file , "FILE", _("Output file")),
OPT_END()
};
-
- /*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage);
+ /*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage_string);
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
//msg_prefix = PROGNAME;
diff --git a/src/plugins/abrt-action-rhtsupport.c b/src/plugins/abrt-action-rhtsupport.c
index a596ac40..42859d5c 100644
--- a/src/plugins/abrt-action-rhtsupport.c
+++ b/src/plugins/abrt-action-rhtsupport.c
@@ -259,7 +259,7 @@ int main(int argc, char **argv)
enum {
OPT_s = (1 << 0),
};
- int optflags = 0;
+ int opts = 0;
int opt;
while ((opt = getopt(argc, argv, "c:d:vs")) != -1)
{
@@ -277,7 +277,7 @@ int main(int argc, char **argv)
g_verbose++;
break;
case 's':
- optflags |= OPT_s;
+ opts |= OPT_s;
break;
default:
/* Careful: the string below contains tabs, dont replace with spaces */
@@ -296,11 +296,9 @@ int main(int argc, char **argv)
}
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
-
//DONT! our stdout/stderr goes directly to daemon, don't want to have prefix there.
// msg_prefix = xasprintf(PROGNAME"[%u]", getpid());
-
- if (optflags & OPT_s)
+ if (opts & OPT_s)
{
openlog(msg_prefix, 0, LOG_DAEMON);
logmode = LOGMODE_SYSLOG;
diff --git a/src/plugins/abrt-action-upload.c b/src/plugins/abrt-action-upload.c
index 4bc5a458..6b54962b 100644
--- a/src/plugins/abrt-action-upload.c
+++ b/src/plugins/abrt-action-upload.c
@@ -244,7 +244,8 @@ int main(int argc, char **argv)
const char *conf_file = NULL;
const char *url = NULL;
- const char *program_usage = _(
+ /* Can't keep these strings/structs static: _() doesn't support that */
+ const char *program_usage_string = _(
PROGNAME" [-v] -d DIR [-c CONFFILE] [-u URL]\n"
"\n"
"Upload compressed tarball of crash dump"
@@ -263,12 +264,11 @@ int main(int argc, char **argv)
OPT_STRING('u', NULL, &url , "URL" , _("Base URL to upload to")),
OPT_END()
};
-
- /*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage);
+ /*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage_string);
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
//msg_prefix = PROGNAME;
- //if (optflags & OPT_s)
+ //if (opts & OPT_s)
//{
// openlog(msg_prefix, 0, LOG_DAEMON);
// logmode = LOGMODE_SYSLOG;
diff --git a/src/plugins/abrt-dump-oops.c b/src/plugins/abrt-dump-oops.c
index 07e2618b..bf4f1e96 100644
--- a/src/plugins/abrt-dump-oops.c
+++ b/src/plugins/abrt-dump-oops.c
@@ -534,9 +534,8 @@ int main(int argc, char **argv)
if (env_verbose)
g_verbose = atoi(env_verbose);
- const char *filename = "/var/log/messages";
-
- const char *program_usage = _(
+ /* Can't keep these strings/structs static: _() doesn't support that */
+ const char *program_usage_string = _(
PROGNAME" [-vsrdow] FILE\n"
"\n"
"Extract oops from syslog/dmesg file"
@@ -559,12 +558,7 @@ int main(int argc, char **argv)
OPT_BOOL('w', NULL, NULL, _("Do not exit, watch the file for new oopses")),
OPT_END()
};
-
- unsigned opts = parse_opts(argc, argv, program_options, program_usage);
- argv += optind;
- if (!argv[0])
- show_usage_and_die(program_usage, program_options);
- filename = argv[0];
+ unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
msg_prefix = PROGNAME;
@@ -575,6 +569,11 @@ int main(int argc, char **argv)
logmode = LOGMODE_SYSLOG;
}
+ argv += optind;
+ if (!argv[0])
+ show_usage_and_die(program_usage_string, program_options);
+ const char *filename = argv[0];
+
int inotify_fd = -1;
if (opts & OPT_w)
{