FreeCalypso > hg > fc-pcsc-tools
comparison libcommon/hexdump.c @ 0:f7145c77b7fb
starting libcommon: factored out of fc-simtool
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 11 Feb 2021 22:28:45 +0000 |
parents | |
children | f1836c8d36cb |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f7145c77b7fb |
---|---|
1 #include <sys/types.h> | |
2 #include <stdio.h> | |
3 #include "simresp.h" | |
4 | |
5 display_sim_resp_in_hex() | |
6 { | |
7 unsigned off, cc, n, c; | |
8 | |
9 for (off = 0; off < sim_resp_data_len; off += cc) { | |
10 printf("%02X:", off); | |
11 cc = 16; | |
12 if (sim_resp_data_len - off < cc) | |
13 cc = sim_resp_data_len - off; | |
14 for (n = 0; n < 16; n++) { | |
15 if (n == 0 || n == 8) | |
16 putchar(' '); | |
17 putchar(' '); | |
18 if (n < cc) | |
19 printf("%02X", sim_resp_data[off + n]); | |
20 else { | |
21 putchar(' '); | |
22 putchar(' '); | |
23 } | |
24 } | |
25 putchar(' '); | |
26 putchar(' '); | |
27 for (n = 0; n < cc; n++) { | |
28 c = sim_resp_data[off + n]; | |
29 if (c < 0x20 || c > 0x7E) | |
30 c = '.'; | |
31 putchar(c); | |
32 } | |
33 putchar('\n'); | |
34 } | |
35 return(0); | |
36 } |