From: Steve Sloan Date: Sat, 24 Mar 2012 19:39:53 +0000 (-0700) Subject: Fixed option handling. X-Git-Url: http://git.itanic.dy.fi/?p=glucose;a=commitdiff_plain;h=d450201cc18c2b7bac84f229c36136d3cff132d1 Fixed option handling. --- diff --git a/main.c b/main.c index 0f2b641..954d733 100644 --- a/main.c +++ b/main.c @@ -37,12 +37,13 @@ char *token(char **str, char sep); int main(int argc, char *argv[]) { FILE *outf; - struct user_options opts = { .output_format = CLEAN }; + struct user_options opts = { .usbdev = NULL, .output_path = NULL, .output_format = CLEAN, .trace_level = 0 }; struct msg msg; int fd, usage_code, ret, error; int entries = 0; - read_args(argc, argv, &opts); + if ( read_args(argc, argv, &opts) ) + return -1; trace_level = opts.trace_level; diff --git a/options.c b/options.c index 7bd5b9b..8392f99 100644 --- a/options.c +++ b/options.c @@ -30,13 +30,11 @@ int read_args(int argc, char *argv[], struct user_options *opts) static struct option long_options[] = { { .val = 'd', .name = "device", .has_arg = 1, }, { .val = 'v', .name = "verbose", .has_arg = 2 }, - { .val = 'o', .name = "output", .has_arg = 1 }, + { .val = 'o', .name = "output", .has_arg = 1 }, { .val = 'f', .name = "format", .has_arg = 1, }, }; char short_options[] = "d:v:o:f:"; - memset(opts, 0, sizeof(*opts)); - while (1) { c = getopt_long(argc, argv, short_options, long_options, &option_index);