]> git.itanic.dy.fi Git - glucose/commitdiff
options: Make verbose level adjustable
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Fri, 29 Apr 2011 20:04:58 +0000 (23:04 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Fri, 29 Apr 2011 20:05:25 +0000 (23:05 +0300)
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
options.c

index 4e2a5398d99467758779c526dc6abd1a15845b7c..90fb44867d5f6696f0d085eb09a519fba3ac1368 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1,5 +1,6 @@
 #include <getopt.h>
 #include <string.h>
+#include <stdlib.h>
 
 #include "options.h"
 
@@ -8,7 +9,7 @@ int read_args(int argc, char *argv[], struct user_options *opts)
         int option_index = 0, c;
         static struct option long_options[] = {
                 { .val = 'd', .name = "device", .has_arg = 1, },
-                { .val = 'v', .name = "verbose", },
+                { .val = 'v', .name = "verbose", .has_arg = 2},
         };
         char short_options[] = "d:v";
 
@@ -26,7 +27,10 @@ int read_args(int argc, char *argv[], struct user_options *opts)
                        opts->usbdev = optarg;
                        break;
                case 'v':
-                       opts->trace_level++;
+                       if (optarg)
+                               opts->trace_level = atoi(optarg);
+                       else
+                               opts->trace_level++;
                 case '?':
                        return -1;
                 }