FreeCalypso > hg > fc-pcsc-tools
comparison simtool/bfsearch.c @ 148:db43bc57ecf7
fc-simtool bfsearch: better reporting of EF structure
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 25 Feb 2021 07:00:51 +0000 |
parents | 8d55571c8118 |
children | 26d7a8815515 |
comparison
equal
deleted
inserted
replaced
147:dcbabc398c6a | 148:db43bc57ecf7 |
---|---|
24 return(-1); | 24 return(-1); |
25 } | 25 } |
26 array[n] = strtoul(argv[n], 0, 16); | 26 array[n] = strtoul(argv[n], 0, 16); |
27 } | 27 } |
28 return(0); | 28 return(0); |
29 } | |
30 | |
31 static void | |
32 report_ef_struct(outf) | |
33 FILE *outf; | |
34 { | |
35 unsigned total_size, record_len; | |
36 | |
37 fputs("EF, ", outf); | |
38 total_size = (sim_resp_data[2] << 8) | sim_resp_data[3]; | |
39 switch (sim_resp_data[13]) { | |
40 case 0x00: | |
41 fprintf(outf, "transparent, length %u\n", total_size); | |
42 return; | |
43 case 0x01: | |
44 fputs("linear fixed, ", outf); | |
45 break; | |
46 case 0x03: | |
47 fputs("cyclic, ", outf); | |
48 break; | |
49 default: | |
50 fprintf(outf, "struct 0x%02X\n", sim_resp_data[13]); | |
51 return; | |
52 } | |
53 if (sim_resp_data_len < 15) { | |
54 fprintf(outf, "response struct cut off\n"); | |
55 return; | |
56 } | |
57 record_len = sim_resp_data[14]; | |
58 fprintf(outf, "record length %u", record_len); | |
59 if (record_len && total_size % record_len == 0) | |
60 fprintf(outf, ", %u records", total_size / record_len); | |
61 putc('\n', outf); | |
29 } | 62 } |
30 | 63 |
31 cmd_bfsearch(argc, argv, outf) | 64 cmd_bfsearch(argc, argv, outf) |
32 char **argv; | 65 char **argv; |
33 FILE *outf; | 66 FILE *outf; |
61 if (!rc) | 94 if (!rc) |
62 continue; | 95 continue; |
63 rc = get_response_op(); | 96 rc = get_response_op(); |
64 if (rc < 0) | 97 if (rc < 0) |
65 return(rc); | 98 return(rc); |
99 fprintf(outf, "%04X: ", bfs); | |
66 if (sim_resp_data_len < 14) | 100 if (sim_resp_data_len < 14) |
67 fprintf(outf, "%04X: too-short response struct\n", bfs); | 101 fprintf(outf, "too-short response struct\n"); |
68 else { | 102 else { |
69 switch (sim_resp_data[6]) { | 103 switch (sim_resp_data[6]) { |
70 case 0x01: | 104 case 0x01: |
71 fprintf(outf, "%04X: MF\n", bfs); | 105 fprintf(outf, "MF\n"); |
72 break; | 106 break; |
73 case 0x02: | 107 case 0x02: |
74 fprintf(outf, "%04X: DF\n", bfs); | 108 fprintf(outf, "DF\n"); |
75 break; | 109 break; |
76 case 0x04: | 110 case 0x04: |
77 fprintf(outf, "%04X: EF (struct %02X)\n", bfs, | 111 report_ef_struct(outf); |
78 sim_resp_data[13]); | |
79 break; | 112 break; |
80 default: | 113 default: |
81 fprintf(outf, "%04X: unknown file type %02X\n", | 114 fprintf(outf, "unknown file type %02X\n", |
82 bfs, sim_resp_data[6]); | 115 sim_resp_data[6]); |
83 } | 116 } |
84 } | 117 } |
85 rc = elem_select_op(skip_ids[0]); | 118 rc = elem_select_op(skip_ids[0]); |
86 if (rc < 0) | 119 if (rc < 0) |
87 return(rc); | 120 return(rc); |