annotate libcommon/hexdump.c @ 198:3bde063234aa

fc-simtool plmnsel-write-list command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Mar 2021 02:48:12 +0000
parents f1836c8d36cb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <sys/types.h>
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <stdio.h>
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include "simresp.h"
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
107
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
5 display_sim_resp_in_hex(outf)
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
6 FILE *outf;
0
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 {
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 unsigned off, cc, n, c;
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 for (off = 0; off < sim_resp_data_len; off += cc) {
107
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
11 fprintf(outf, "%02X:", off);
0
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 cc = 16;
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 if (sim_resp_data_len - off < cc)
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 cc = sim_resp_data_len - off;
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 for (n = 0; n < 16; n++) {
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 if (n == 0 || n == 8)
107
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
17 putc(' ', outf);
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
18 putc(' ', outf);
0
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 if (n < cc)
107
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
20 fprintf(outf, "%02X", sim_resp_data[off + n]);
0
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 else {
107
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
22 putc(' ', outf);
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
23 putc(' ', outf);
0
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
107
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
26 putc(' ', outf);
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
27 putc(' ', outf);
0
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 for (n = 0; n < cc; n++) {
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 c = sim_resp_data[off + n];
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 if (c < 0x20 || c > 0x7E)
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 c = '.';
107
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
32 putc(c, outf);
0
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }
107
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
34 putc('\n', outf);
0
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 return(0);
f7145c77b7fb starting libcommon: factored out of fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 }
107
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
38
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
39 cmd_sim_resp(argc, argv, outf)
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
40 char **argv;
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
41 FILE *outf;
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
42 {
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
43 return display_sim_resp_in_hex(outf);
f1836c8d36cb hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
44 }