]> err.no Git - yubikey-personalization/commitdiff
merge code for slot 1 and 2
authorKlas Lindfors <klas@yubico.com>
Mon, 26 Mar 2012 08:05:45 +0000 (10:05 +0200)
committerKlas Lindfors <klas@yubico.com>
Mon, 26 Mar 2012 08:05:45 +0000 (10:05 +0200)
ykpers-args.c

index 6617de2b6affada5e321f6409ccf75e50af85633..85ad4ae7dcb680d9628e1d05295bb6a242686ac5 100644 (file)
@@ -241,35 +241,26 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg,
 
                switch (c) {
                case '1':
-                       if (slot_chosen) {
-                               fprintf(stderr, "You may only choose slot (-1 / -2) once.\n");
-                               *exit_code = 1;
-                               return 0;
-                       }
-                       if (option_seen) {
-                               fprintf(stderr, "You must choose slot before any options (-o).\n");
-                               *exit_code = 1;
-                               return 0;
-                       }
-                       if (!ykp_configure_for(cfg, 1, st))
-                               return 0;
-                       slot_chosen = true;
-                       break;
-               case '2':
-                       if (slot_chosen) {
-                               fprintf(stderr, "You may only choose slot (-1 / -2) once.\n");
-                               *exit_code = 1;
-                               return 0;
-                       }
-                       if (option_seen) {
-                               fprintf(stderr, "You must choose slot before any options (-o).\n");
-                               *exit_code = 1;
-                               return 0;
+               case '2': {
+                               int slot = 1;
+                               if(c == '2') {
+                                       slot = 2;
+                               }
+                               if (slot_chosen) {
+                                       fprintf(stderr, "You may only choose slot (-1 / -2) once.\n");
+                                       *exit_code = 1;
+                                       return 0;
+                               }
+                               if (option_seen) {
+                                       fprintf(stderr, "You must choose slot before any options (-o).\n");
+                                       *exit_code = 1;
+                                       return 0;
+                               }
+                               if (!ykp_configure_for(cfg, slot, st))
+                                       return 0;
+                               slot_chosen = true;
+                               break;
                        }
-                       if (!ykp_configure_for(cfg, 2, st))
-                               return 0;
-                       slot_chosen = true;
-                       break;
                case 'i':
                        *infname = optarg;
                        break;