# HG changeset patch # User Mychaela Falconia # Date 1614231619 0 # Node ID be1a759453ef76cc2af4c028f6047b5300640f3f # Parent 878d66dce6d377812952c97929fe895d4de51fbb simtool code: added elem_select_op() function diff -r 878d66dce6d3 -r be1a759453ef simtool/select.c --- 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; {