FreeCalypso > hg > freecalypso-hwlab
comparison simtool/hexdump.c @ 88:91486a77643e
fc-simtool: implement hex display of full SIM responses
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 24 Jan 2021 05:09:48 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
87:2a0d1d5b9313 | 88:91486a77643e |
---|---|
1 #include <sys/types.h> | |
2 #include <stdio.h> | |
3 #include <stdlib.h> | |
4 #include <pcsclite.h> | |
5 #include <winscard.h> | |
6 #include "globals.h" | |
7 | |
8 display_sim_resp_in_hex() | |
9 { | |
10 unsigned off, cc, n, c; | |
11 | |
12 for (off = 0; off < sim_resp_data_len; off += cc) { | |
13 printf("%02X:", off); | |
14 cc = 16; | |
15 if (sim_resp_data_len - off < cc) | |
16 cc = sim_resp_data_len - off; | |
17 for (n = 0; n < 16; n++) { | |
18 if (n == 0 || n == 8) | |
19 putchar(' '); | |
20 putchar(' '); | |
21 if (n < cc) | |
22 printf("%02X", sim_resp_data[off + n]); | |
23 else { | |
24 putchar(' '); | |
25 putchar(' '); | |
26 } | |
27 } | |
28 putchar(' '); | |
29 putchar(' '); | |
30 for (n = 0; n < cc; n++) { | |
31 c = sim_resp_data[off + n]; | |
32 if (c < 0x20 || c > 0x7E) | |
33 c = '.'; | |
34 putchar(c); | |
35 } | |
36 putchar('\n'); | |
37 } | |
38 return(0); | |
39 } |