summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikola Pajkovsky <npajkovs@redhat.com>2010-10-05 13:38:44 +0200
committerNikola Pajkovsky <npajkovs@redhat.com>2010-10-05 13:38:44 +0200
commit4f54992eac73d4400b07ff1978accbf118f7e8bd (patch)
tree087162941da7acbd7bee0898326c14c57f1026df
parent6d49343abb0f90fdb2dd88ca639038cc7302c3dc (diff)
downloadabrt-4f54992eac73d4400b07ff1978accbf118f7e8bd.tar.gz
abrt-4f54992eac73d4400b07ff1978accbf118f7e8bd.tar.xz
abrt-4f54992eac73d4400b07ff1978accbf118f7e8bd.zip
add INTEGER option
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
-rw-r--r--lib/utils/parse_options.c5
-rw-r--r--lib/utils/parse_options.h2
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/utils/parse_options.c b/lib/utils/parse_options.c
index b891066b..21f007f0 100644
--- a/lib/utils/parse_options.c
+++ b/lib/utils/parse_options.c
@@ -82,6 +82,8 @@ void parse_opts(int argc, char **argv, const struct options *opt,
break;
case OPTION_END:
break;
+ case OPTION_INTEGER:
+ break;
}
longopts[ii].flag = 0;
longopts[ii].val = opt[ii].short_name;
@@ -117,6 +119,9 @@ void parse_opts(int argc, char **argv, const struct options *opt,
case OPTION_BOOL:
*(int*)opt[ii].value += 1;
break;
+ case OPTION_INTEGER:
+ *(int*)opt[ii].value = xatoi(optarg);
+ break;
case OPTION_STRING:
if (optarg)
*(char**)opt[ii].value = (char*)optarg;
diff --git a/lib/utils/parse_options.h b/lib/utils/parse_options.h
index c9d849f7..29101925 100644
--- a/lib/utils/parse_options.h
+++ b/lib/utils/parse_options.h
@@ -10,6 +10,7 @@ extern "C" {
enum parse_opt_type {
OPTION_BOOL,
OPTION_STRING,
+ OPTION_INTEGER,
OPTION_END,
};
@@ -31,6 +32,7 @@ struct options {
*/
#define OPT_END() { OPTION_END }
#define OPT_BOOL(s, l, v, h) { OPTION_BOOL, (s), (l), (v), NULL, (h) }
+#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), "n", (h) }
#define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) }
void parse_opts(int argc, char **argv, const struct options *opt,