diff options
author | Jim Rees <rees@cvs.openbsd.org> | 2001-10-02 16:22:41 +0000 |
---|---|---|
committer | Jim Rees <rees@cvs.openbsd.org> | 2001-10-02 16:22:41 +0000 |
commit | d0bb683ec3093f54d4f617ddb976acd439b15def (patch) | |
tree | abf73927ea85c41e6d5d54170b0a9cdb5869f0e6 | |
parent | 6fd3f20a0a7a04d54828f31225f7c808002f18b6 (diff) |
add csearch
call sectok_close on exit
-rw-r--r-- | usr.bin/sectok/cmds.c | 21 | ||||
-rw-r--r-- | usr.bin/sectok/main.c | 5 | ||||
-rw-r--r-- | usr.bin/sectok/sc.h | 3 |
3 files changed, 25 insertions, 4 deletions
diff --git a/usr.bin/sectok/cmds.c b/usr.bin/sectok/cmds.c index ac5df0da770..47387b5d70a 100644 --- a/usr.bin/sectok/cmds.c +++ b/usr.bin/sectok/cmds.c @@ -1,4 +1,4 @@ -/* $Id: cmds.c,v 1.16 2001/08/15 19:48:39 rees Exp $ */ +/* $Id: cmds.c,v 1.17 2001/10/02 16:22:40 rees Exp $ */ /* * Smartcard commander. @@ -75,6 +75,7 @@ struct dispatchtable dispatch_table[] = { { "apdu", "[ -c class ] ins p1 p2 p3 data ...", apdu }, { "fid", "[ -v ] fid/aid", selfid }, { "isearch", "", isearch }, + { "csearch", "", csearch }, { "class", "[ class ]", class }, { "read", "[ -x ] filesize", dread }, { "write", "input-filename", dwrite }, @@ -212,6 +213,7 @@ int dclose(int ac, char *av[]) int quit(int ac, char *av[]) { + dclose(0, NULL); #ifndef __palmos__ exit(0); #else @@ -346,6 +348,23 @@ int isearch(int ac, char *av[]) return 0; } +int csearch(int ac, char *av[]) +{ + int i, r1, sw; + + if (fd < 0 && reset(0, NULL) < 0) + return -1; + + /* find app classes */ + for (i = 0; i <= 0xff; i++) { + sectok_apdu(fd, i, 0xa4, 0, 0, 2, root_fid, 0, NULL, &sw); + r1 = sectok_r1(sw); + if (r1 != 0x06 && r1 != 0x6d && r1 != 0x6e) + printf("%02x %s\n", i, sectok_get_sw(sw)); + } + return 0; +} + int class(int ac, char *av[]) { if (ac > 1) diff --git a/usr.bin/sectok/main.c b/usr.bin/sectok/main.c index 89e009feb31..6643f407afa 100644 --- a/usr.bin/sectok/main.c +++ b/usr.bin/sectok/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.5 2001/09/09 17:23:21 mickey Exp $ */ +/* $Id: main.c,v 1.6 2001/10/02 16:22:40 rees Exp $ */ /* * Smartcard commander. @@ -145,7 +145,8 @@ char *av[]; dispatch(tc, tv); } - exit(0); + quit(0, NULL); + return 0; } void onintr(int sigraised) diff --git a/usr.bin/sectok/sc.h b/usr.bin/sectok/sc.h index 72efe479f57..b8bbec0b420 100644 --- a/usr.bin/sectok/sc.h +++ b/usr.bin/sectok/sc.h @@ -1,4 +1,4 @@ -/* $Id: sc.h,v 1.9 2001/08/15 19:48:39 rees Exp $ */ +/* $Id: sc.h,v 1.10 2001/10/02 16:22:40 rees Exp $ */ /* * Smartcard commander. @@ -51,6 +51,7 @@ int quit(int ac, char *av[]); int apdu(int ac, char *av[]); int selfid(int ac, char *av[]); int isearch(int ac, char *av[]); +int csearch(int ac, char *av[]); int class(int ac, char *av[]); int dread(int ac, char *av[]); int dwrite(int ac, char *av[]); |