[BACK]Return to cmds.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / sectok

Diff for /src/usr.bin/sectok/Attic/cmds.c between version 1.11 and 1.12

version 1.11, 2001/07/20 15:52:54 version 1.12, 2001/07/26 16:10:01
Line 60 
Line 60 
   
     /* 7816-4 commands */      /* 7816-4 commands */
     { "apdu", "[ -c class ] ins p1 p2 p3 data ...", apdu },      { "apdu", "[ -c class ] ins p1 p2 p3 data ...", apdu },
     { "fid", "[ -v ] fid", selfid },      { "fid", "[ -v ] fid/aid", selfid },
     { "isearch", "", isearch },      { "isearch", "", isearch },
     { "class", "[ class ]", class },      { "class", "[ class ]", class },
     { "read", "[ -x ] filesize", dread },      { "read", "[ -x ] filesize", dread },
Line 78 
Line 78 
     { "jaut", "", jaut },      { "jaut", "", jaut },
     { "jload", "[ -p progID ] [ -c contID ] [ -s cont_size ] [ -i inst_size ] [ -a aid ] [ -v ] filename", jload },      { "jload", "[ -p progID ] [ -c contID ] [ -s cont_size ] [ -i inst_size ] [ -a aid ] [ -v ] filename", jload },
     { "junload", "[ -p progID ] [ -c contID ]", junload },      { "junload", "[ -p progID ] [ -c contID ]", junload },
     { "jselect", "[ -a aid ] [ -d ]", jselect },  
     { "setpass", "[ -d ] [ -x hex-aut0 ]", jsetpass },      { "setpass", "[ -d ] [ -x hex-aut0 ]", jsetpass },
     { NULL, NULL, NULL }      { NULL, NULL, NULL }
 };  };
Line 133 
Line 132 
   
     optind = optreset = 1;      optind = optreset = 1;
   
     while ((i = getopt(ac, av, "1234ivf")) != -1) {      while ((i = getopt(ac, av, "0123ivf")) != -1) {
         switch (i) {          switch (i) {
           case '0':
         case '1':          case '1':
         case '2':          case '2':
         case '3':          case '3':
         case '4':              port = i - '0';
             port = i - '1';  
             break;              break;
         case 'i':          case 'i':
             oflags |= STONOWAIT;              oflags |= STONOWAIT;
Line 234 
Line 233 
   
 int selfid(int ac, char *av[])  int selfid(int ac, char *av[])
 {  {
     unsigned char fid[2], obuf[256];      unsigned char fid[16], obuf[256];
     int i, n, olen = 0, sw;      char *fname;
       int i, n, sel, fidlen, olen = 0, sw;
   
     optind = optreset = 1;      optind = optreset = 1;
   
     while ((i = getopt(ac, av, "v")) != -1) {      while ((i = getopt(ac, av, "v")) != -1) {
         switch (i) {          switch (i) {
         case 'v':          case 'v':
             olen = sizeof obuf;              olen = 256;
             break;              break;
         }          }
     }      }
   
     if (ac - optind != 1) {      if (ac - optind == 0) {
         printf("usage: f [ -v ] fid\n");          /* No fid/aid given; select null aid (default loader for Cyberflex) */
         return -1;          sel = 4;
           fidlen = 0;
       } else {
           fname = av[optind++];
           if (!strcmp(fname, "..")) {
               /* Special case ".." means parent */
               sel = 3;
               fidlen = 0;
           } else if (strlen(fname) < 5) {
               /* fid */
               sel = 0;
               fidlen = 2;
               sectok_parse_fname(fname, fid);
           } else {
               /* aid */
               sel = 4;
               fidlen = sectok_parse_input(fname, fid, sizeof fid);
           }
     }      }
     sectok_parse_fname(av[optind++], fid);  
   
     if (fd < 0 && reset(0, NULL) < 0)      if (fd < 0 && reset(0, NULL) < 0)
         return -1;          return -1;
   
     n = sectok_apdu(fd, cla, 0xa4, 0, 0, 2, fid, olen, obuf, &sw);      n = sectok_apdu(fd, cla, 0xa4, sel, 0, fidlen, fid, olen, obuf, &sw);
     if (!sectok_swOK(sw)) {      if (!sectok_swOK(sw)) {
         printf("Select %02x%02x: %s\n", fid[0], fid[1], sectok_get_sw(sw));          printf("Select %02x%02x: %s\n", fid[0], fid[1], sectok_get_sw(sw));
         return -1;          return -1;
       }
   
       if (olen && !n && sectok_r1(sw) == 0x61 && sectok_r2(sw)) {
           /* The card has out data but we must explicitly ask for it */
           n = sectok_apdu(fd, cla, 0xc0, 0, 0, 0, NULL, sectok_r2(sw), obuf, &sw);
     }      }
   
     if (olen)      if (olen)

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12