FreeCalypso > hg > freecalypso-hwlab
comparison simtool/select.c @ 89:fb75855a74a9
fc-simtool: select response parsing: show number of records
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 24 Jan 2021 18:03:55 +0000 |
parents | 2a0d1d5b9313 |
children | d4150123ca45 |
comparison
equal
deleted
inserted
replaced
88:91486a77643e | 89:fb75855a74a9 |
---|---|
81 | 81 |
82 cmd_select(argc, argv) | 82 cmd_select(argc, argv) |
83 char **argv; | 83 char **argv; |
84 { | 84 { |
85 int file_id, rc; | 85 int file_id, rc; |
86 unsigned file_size; | |
86 | 87 |
87 if (isxdigit(argv[1][0]) && isxdigit(argv[1][1]) && | 88 if (isxdigit(argv[1][0]) && isxdigit(argv[1][1]) && |
88 isxdigit(argv[1][2]) && isxdigit(argv[1][3]) && !argv[1][4]) | 89 isxdigit(argv[1][2]) && isxdigit(argv[1][3]) && !argv[1][4]) |
89 file_id = strtoul(argv[1], 0, 16); | 90 file_id = strtoul(argv[1], 0, 16); |
90 else | 91 else |
125 show_secret_code_status("PIN2", sim_resp_data[20]); | 126 show_secret_code_status("PIN2", sim_resp_data[20]); |
126 show_secret_code_status("PUK2", sim_resp_data[21]); | 127 show_secret_code_status("PUK2", sim_resp_data[21]); |
127 break; | 128 break; |
128 case 0x04: | 129 case 0x04: |
129 printf("File type: EF\n"); | 130 printf("File type: EF\n"); |
130 printf("File size: %u\n", | 131 file_size = (sim_resp_data[2] << 8) | sim_resp_data[3]; |
131 (sim_resp_data[2] << 8) | sim_resp_data[3]); | 132 printf("File size: %u\n", file_size); |
132 switch (sim_resp_data[13]) { | 133 switch (sim_resp_data[13]) { |
133 case 0x00: | 134 case 0x00: |
134 printf("Structure: transparent\n"); | 135 printf("Structure: transparent\n"); |
135 break; | 136 break; |
136 case 0x01: | 137 case 0x01: |
144 "error: response length of %u bytes is too short for record-based EF\n", | 145 "error: response length of %u bytes is too short for record-based EF\n", |
145 sim_resp_data_len); | 146 sim_resp_data_len); |
146 return(-1); | 147 return(-1); |
147 } | 148 } |
148 printf("Record length: %u\n", sim_resp_data[14]); | 149 printf("Record length: %u\n", sim_resp_data[14]); |
150 curfile_record_len = sim_resp_data[14]; | |
151 if (file_size % curfile_record_len == 0) | |
152 printf("Number of records: %u\n", | |
153 file_size / curfile_record_len); | |
149 break; | 154 break; |
150 default: | 155 default: |
151 printf("Structure: %02X (unknown)\n", | 156 printf("Structure: %02X (unknown)\n", |
152 sim_resp_data[13]); | 157 sim_resp_data[13]); |
153 } | 158 } |