chiark / gitweb /
nicer args
authorian <ian>
Sun, 8 Aug 2004 20:26:47 +0000 (20:26 +0000)
committerian <ian>
Sun, 8 Aug 2004 20:26:47 +0000 (20:26 +0000)
parport/parport-ctl.c

index e368336b4315d760dc1952aaef95fbf17bd52ddb..febec4074cd9311abca61b3f6cddfb016d6738fb 100644 (file)
@@ -76,7 +76,7 @@ static const void badusage(const char *what) {
   
   fprintf(stderr,"bad usage: %s\n"
          "usage: parport-ctl <&parport ioctl"
-         " [input-type [input-args ...] [output-type]]\n"
+         " [output-type [input-type [input-args ...]]]\n"
          "ioctls:", what);
   for (ioi= ioctlinfos; ioi->name; ioi++) {
     fputc(' ',stderr);
@@ -124,7 +124,6 @@ static void parse_ppdfs(const char *const **argv) {
   parm.fs.mask= pa_uc(argv);
   parm.fs.val= pa_uc(argv);
 }
-static void parse_get(const char *const **argv) { }
 static void parse_mode(const char *const **argv) {
   const char *arg= pa_1arg(argv);
   const struct numvalinfo *mi;
@@ -133,6 +132,7 @@ static void parse_mode(const char *const **argv) {
 }
 
 static void print_none(void) { }
+static void print_set(void) { }
 static void print_int(void) { printf("%d\n",parm.i); }
 static void print_uc(void) { printf("0x%02x\n",parm.uc); }
 static void print_hex(void) {
@@ -167,7 +167,7 @@ static const struct typeinfo typeinfos[] = {
   T(uc)
   T(mode)
   TI(ppdfs)
-  TI(get)
+  TO(set)
   TO(hex)
   TO(dump)
   { 0 }
@@ -189,18 +189,18 @@ int main(int argc, const char *const *argv) {
   if (arg[0] == '-') badusage("no options supported");
   FIND(ioi, ioctlinfos, "ioctl name");
 
-  memset(&parm,0,sizeof(parm));
-  if ((arg= *argv)) {
-    argv++;
-    FINDT(iti, "input to ioctl", parse);
-    iti->parse(&argv);
-  }
   if ((arg= *argv)) {
     argv++;
     FINDT(oti, "type for output from ioctl", print);
   } else {
     oti= 0;
   }
+  memset(&parm,0,sizeof(parm));
+  if ((arg= *argv)) {
+    argv++;
+    FINDT(iti, "input to ioctl", parse);
+    iti->parse(&argv);
+  }
   if (*argv) badusage("too many args");
 
   r= ioctl(0, ioi->num, &parm);