FreeCalypso > hg > freecalypso-hwlab
diff simtool/select.c @ 93:d4150123ca45
fc-simtool: some refactoring of SELECT response parsing
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 24 Jan 2021 20:25:04 +0000 |
parents | fb75855a74a9 |
children | b84df973cd8b |
line wrap: on
line diff
--- a/simtool/select.c Sun Jan 24 19:59:10 2021 +0000 +++ b/simtool/select.c Sun Jan 24 20:25:04 2021 +0000 @@ -83,7 +83,6 @@ char **argv; { int file_id, rc; - unsigned file_size; if (isxdigit(argv[1][0]) && isxdigit(argv[1][1]) && isxdigit(argv[1][2]) && isxdigit(argv[1][3]) && !argv[1][4]) @@ -128,9 +127,10 @@ break; case 0x04: printf("File type: EF\n"); - file_size = (sim_resp_data[2] << 8) | sim_resp_data[3]; - printf("File size: %u\n", file_size); - switch (sim_resp_data[13]) { + curfile_total_size = (sim_resp_data[2] << 8) | sim_resp_data[3]; + printf("File size: %u\n", curfile_total_size); + curfile_structure = sim_resp_data[13]; + switch (curfile_structure) { case 0x00: printf("Structure: transparent\n"); break; @@ -148,13 +148,18 @@ } printf("Record length: %u\n", sim_resp_data[14]); curfile_record_len = sim_resp_data[14]; - if (file_size % curfile_record_len == 0) + if (curfile_record_len && + curfile_total_size % curfile_record_len == 0) { + curfile_record_count = + curfile_total_size / curfile_record_len; printf("Number of records: %u\n", - file_size / curfile_record_len); + curfile_record_count); + } else + curfile_record_count = 0; break; default: printf("Structure: %02X (unknown)\n", - sim_resp_data[13]); + curfile_structure); } printf("File status: %02X\n", sim_resp_data[11]); show_access_conditions("UPDATE", sim_resp_data[8] & 0xF);