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