patch from Tomasz
authorDavid Schleef <ds@schleef.org>
Sat, 27 May 2000 00:55:34 +0000 (00:55 +0000)
committerDavid Schleef <ds@schleef.org>
Sat, 27 May 2000 00:55:34 +0000 (00:55 +0000)
demo/main.c

index 0e67cac3937c1504bca026342e1b083cab933288..06e67378ca858c51f9a42fb765266bbec8374670 100644 (file)
@@ -28,33 +28,22 @@ int parse_options(int argc, char *argv[])
        int c;
 
 
-       while (optind<argc) {
-               c = getopt(argc, argv, "acsrfvdgom");
+       while (-1 != (c = getopt(argc, argv, "a:c:s:r:f:vdgom"))) {
                switch (c) {
-               case -1:
-                       /* data value */
-                       sscanf(argv[optind],"%d",&value);
-                       optind++;
-                       break;
                case 'f':
-                       filename = argv[optind];
-                       optind++;
+                       filename = optarg;
                        break;
                case 's':
-                       sscanf(argv[optind],"%d",&subdevice);
-                       optind++;
+                       sscanf(optarg,"%d",&subdevice);
                        break;
                case 'c':
-                       sscanf(argv[optind],"%d",&channel);
-                       optind++;
+                       sscanf(optarg,"%d",&channel);
                        break;
                case 'a':
-                       sscanf(argv[optind],"%d",&aref);
-                       optind++;
+                       sscanf(optarg,"%d",&aref);
                        break;
                case 'r':
-                       sscanf(argv[optind],"%d",&range);
-                       optind++;
+                       sscanf(optarg,"%d",&range);
                        break;
                case 'v':
                        verbose_flag = 1;
@@ -76,6 +65,10 @@ int parse_options(int argc, char *argv[])
                        exit(1);
                }
        }
+       if(optind < argc) {
+               /* data value */
+               sscanf(argv[optind++],"%d",&value);
+       }
 
        return argc;
 }