summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/daemon/Daemon.cpp50
-rw-r--r--src/daemon/abrt-action-save-package-data.c42
-rw-r--r--src/daemon/abrt-handle-crashdump.c13
-rw-r--r--src/daemon/abrt-server.c36
-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
15 files changed, 148 insertions, 149 deletions
diff --git a/src/daemon/Daemon.cpp b/src/daemon/Daemon.cpp
index 8d972a9a..7c063d9d 100644
--- a/src/daemon/Daemon.cpp
+++ b/src/daemon/Daemon.cpp
@@ -34,6 +34,8 @@
#include "Daemon.h"
#include "parse_options.h"
+#define PROGNAME "abrtd"
+
using namespace std;
@@ -463,10 +465,10 @@ static void run_main_loop(GMainLoop* loop)
fds = (GPollFD *)xrealloc(fds, fds_size * sizeof(fds[0]));
}
- if (s_timeout)
+ if (s_timeout != 0)
alarm(s_timeout);
g_poll(fds, nfds, timeout);
- if (s_timeout)
+ if (s_timeout != 0)
alarm(0);
some_ready = g_main_context_check(context, max_priority, fds, nfds);
@@ -486,7 +488,7 @@ static void start_syslog_logging()
* Otherwise fprintf(stderr) dumps messages into random fds, etc. */
xdup2(STDIN_FILENO, STDOUT_FILENO);
xdup2(STDIN_FILENO, STDERR_FILENO);
- openlog("abrtd", 0, LOG_DAEMON);
+ openlog(PROGNAME, 0, LOG_DAEMON);
logmode = LOGMODE_SYSLOG;
putenv((char*)"ABRT_SYSLOG=1");
}
@@ -523,23 +525,6 @@ static void sanitize_dump_dir_rights()
ensure_writable_dir(VAR_RUN"/abrt", 0755, "root");
}
-static char *timeout_opt;
-static const char* abrtd_usage = _("abrtd [options]");
-enum {
- OPT_v = 1 << 0,
- OPT_d = 1 << 1,
- OPT_s = 1 << 2,
- OPT_t = 1 << 3,
-};
-/* Keep enum above and order of options below in sync! */
-static struct options abrtd_options[] = {
- OPT__VERBOSE(&g_verbose),
- OPT_BOOL( 'd' , 0, NULL, _("Do not daemonize")),
- OPT_BOOL( 's' , 0, NULL, _("Log to syslog even with -d")),
- OPT_INTEGER( 't' , 0, &timeout_opt, _("Exit after SEC seconds of inactivity")),
- OPT_END()
-};
-
int main(int argc, char** argv)
{
int parent_pid = getpid();
@@ -558,9 +543,24 @@ int main(int argc, char** argv)
if (env_verbose)
g_verbose = atoi(env_verbose);
- unsigned opts = parse_opts(argc, argv, abrtd_options, abrtd_usage);
-
- msg_prefix = "abrtd"; /* for log(), error_msg() and such */
+ const char *program_usage_string = _(
+ PROGNAME" [options]"
+ );
+ enum {
+ OPT_v = 1 << 0,
+ OPT_d = 1 << 1,
+ OPT_s = 1 << 2,
+ OPT_t = 1 << 3,
+ };
+ /* Keep enum above and order of options below in sync! */
+ struct options program_options[] = {
+ OPT__VERBOSE(&g_verbose),
+ OPT_BOOL( 'd', NULL, NULL , _("Do not daemonize")),
+ OPT_BOOL( 's', NULL, NULL , _("Log to syslog even with -d")),
+ OPT_INTEGER('t', NULL, &s_timeout, _("Exit after SEC seconds of inactivity")),
+ OPT_END()
+ };
+ unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
unsetenv("ABRT_SYSLOG");
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
@@ -571,7 +571,7 @@ int main(int argc, char** argv)
const char *env_path = getenv("PATH");
if (!env_path || !env_path[0])
putenv((char*)"PATH=/usr/sbin:/usr/bin:/sbin:/bin");
-
+ msg_prefix = PROGNAME; /* for log(), error_msg() and such */
if (opts & OPT_s)
start_syslog_logging();
@@ -581,7 +581,7 @@ int main(int argc, char** argv)
signal(SIGTERM, handle_signal);
signal(SIGINT, handle_signal);
signal(SIGCHLD, handle_signal);
- if (s_timeout)
+ if (s_timeout != 0)
signal(SIGALRM, handle_signal);
/* Daemonize unless -d */
diff --git a/src/daemon/abrt-action-save-package-data.c b/src/daemon/abrt-action-save-package-data.c
index d912dec4..8ddd1d8c 100644
--- a/src/daemon/abrt-action-save-package-data.c
+++ b/src/daemon/abrt-action-save-package-data.c
@@ -267,36 +267,36 @@ static int SavePackageDescriptionToDebugDump(const char *dump_dir_name)
return error;
}
-static const char *dump_dir_name = ".";
-static const char abrt_action_save_package_data_usage[] =
- PROGNAME" [options] -d DIR\n"
- "\n"
- "Query package database and save package name, component, and description";
-enum {
- OPT_v = 1 << 0,
- OPT_d = 1 << 1,
- OPT_s = 1 << 2,
-};
-/* Keep enum above and order of options below in sync! */
-static struct options abrt_action_save_package_data_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_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_save_package_data_options,
- abrt_action_save_package_data_usage);
+ const char *dump_dir_name = ".";
+
+ /* Can't keep these strings/structs static: _() doesn't support that */
+ const char *program_usage_string = _(
+ PROGNAME" [options] -d DIR\n"
+ "\n"
+ "Query package database and save package name, component, and description"
+ );
+ enum {
+ OPT_v = 1 << 0,
+ OPT_d = 1 << 1,
+ 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_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);
diff --git a/src/daemon/abrt-handle-crashdump.c b/src/daemon/abrt-handle-crashdump.c
index 2286de60..c778c792 100644
--- a/src/daemon/abrt-handle-crashdump.c
+++ b/src/daemon/abrt-handle-crashdump.c
@@ -38,11 +38,13 @@ 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" [-vs]" /*" [-c CONFFILE]"*/ " -d DIR -e EVENT\n"
" or: "PROGNAME" [-vs]" /*" [-c CONFFILE]"*/ " [-d DIR] -l[PFX]\n"
"\n"
- "Handle crash dump according to rules in abrt_event.conf");
+ "Handle crash dump according to rules in abrt_event.conf"
+ );
enum {
OPT_v = 1 << 0,
OPT_s = 1 << 1,
@@ -61,11 +63,12 @@ int main(int argc, char **argv)
// OPT_STRING( 'c', NULL, &conf_filename, "CONFFILE", _("Configuration file" )),
OPT_END()
};
-
- unsigned opts = parse_opts(argc, argv, program_options, program_usage);
+ unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
if (!(opts & (OPT_e|OPT_l)))
- show_usage_and_die(program_usage, program_options);
+ show_usage_and_die(program_usage_string, program_options);
+
putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose));
+ msg_prefix = PROGNAME;
if (opts & OPT_s)
{
openlog(msg_prefix, 0, LOG_DAEMON);
diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c
index 47457aaf..3415e95c 100644
--- a/src/daemon/abrt-server.c
+++ b/src/daemon/abrt-server.c
@@ -21,6 +21,7 @@
#include "hooklib.h"
#include "parse_options.h"
+#define PROGNAME "abrt-server"
/* Maximal length of backtrace. */
#define MAX_BACKTRACE_SIZE (1024*1024)
@@ -275,31 +276,32 @@ static void process_message(const char *message)
static void dummy_handler(int sig_unused) {}
-static const char abrt_server_usage[] = "abrt-server [options]";
-enum {
- OPT_v = 1 << 0,
- OPT_u = 1 << 1,
- OPT_s = 1 << 2,
-};
-/* Keep enum above and order of options below in sync! */
-static struct options abrt_server_options[] = {
- OPT__VERBOSE(&g_verbose),
- OPT_INTEGER( 'u' , 0, &client_uid, "Use UID as client uid"),
- OPT_BOOL( 's' , 0, 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_server_options,
- abrt_server_usage);
+ /* Can't keep these strings/structs static: _() doesn't support that */
+ const char *program_usage_string = _(
+ PROGNAME" [options]"
+ );
+ enum {
+ OPT_v = 1 << 0,
+ OPT_u = 1 << 1,
+ OPT_s = 1 << 2,
+ };
+ /* Keep enum above and order of options below in sync! */
+ struct options program_options[] = {
+ OPT__VERBOSE(&g_verbose),
+ OPT_INTEGER('u', NULL, &client_uid, _("Use UID as client uid")),
+ 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 = xasprintf("abrt-server[%u]", getpid());
+ msg_prefix = xasprintf(PROGNAME"[%u]", getpid());
if (opts & OPT_s)
{
openlog(msg_prefix, 0, LOG_DAEMON);
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)
{