FreeCalypso > hg > fc-pcsc-tools
changeset 143:be1a759453ef
simtool code: added elem_select_op() function
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 25 Feb 2021 05:40:19 +0000 |
parents | 878d66dce6d3 |
children | 60411fd4b803 |
files | simtool/select.c |
diffstat | 1 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/simtool/select.c Wed Feb 24 17:32:03 2021 +0000 +++ b/simtool/select.c Thu Feb 25 05:40:19 2021 +0000 @@ -7,6 +7,34 @@ #include "simresp.h" #include "curfile.h" +elem_select_op(file_id) + unsigned file_id; +{ + u_char cmd[7]; + int rc; + unsigned expect_resp_len; + + /* SELECT command APDU */ + cmd[0] = 0xA0; + cmd[1] = 0xA4; + cmd[2] = 0; + cmd[3] = 0; + cmd[4] = 2; + cmd[5] = file_id >> 8; + cmd[6] = file_id; + rc = apdu_exchange(cmd, 7); + if (rc < 0) + return(rc); + if (sim_resp_sw == 0x9404) + return(0); + if ((sim_resp_sw & 0xFF00) == 0x9F00) + return(1); + fprintf(stderr, + "error or unexpected SW response to SELECT of 0x%04X: %04X\n", + file_id, sim_resp_sw); + return(-1); +} + select_op(file_id) unsigned file_id; {