FreeCalypso > hg > fc-pcsc-tools
annotate simtool/smsp_dump.c @ 38:f5a26c1d0b93
fc-simtool smsp-dump implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 12 Feb 2021 20:39:15 +0000 |
parents | simtool/pbdump.c@72a24b8538eb |
children | f1ea981ab225 |
rev | line source |
---|---|
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
2 * This module implements intelligent dumping of EF_SMSP (smsp-dump). |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
19
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
7 #include "simresp.h" |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include "curfile.h" |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
19
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
10 static |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
11 check_blank_area(dp, endp) |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
12 u_char *dp, *endp; |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
13 { |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
14 while (dp < endp) |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
15 if (*dp++ != 0xFF) |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
16 return(-1); |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
17 return(0); |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
18 } |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
19 |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
20 static void |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
21 dump_da_field(binaddr, outf) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
22 u_char *binaddr; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
23 FILE *outf; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
24 { |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
25 char digits[21]; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
26 |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
27 fputs("DA=", outf); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
28 if (binaddr[0] < 1 || binaddr[0] > 20) { |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
29 malformed: fputs("malformed ", outf); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
30 return; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
31 } |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
32 if ((binaddr[0] & 1) && (binaddr[(binaddr[0] >> 1) + 2] & 0xF0) != 0xF0) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
33 goto malformed; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
34 if (check_blank_area(binaddr + 2 + ((binaddr[0] + 1) >> 1), |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
35 binaddr + 12) < 0) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
36 goto malformed; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
37 /* all checks passed */ |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
38 decode_address_digits(binaddr + 2, digits, binaddr[0]); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
39 fprintf(outf, "%s,0x%02X ", digits, binaddr[1]); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
40 } |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
41 |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
42 static void |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
43 dump_sca_field(binaddr, outf) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
44 u_char *binaddr; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
45 FILE *outf; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
46 { |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
47 char digits[21]; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
48 int rc; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
49 |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
50 fputs("SC=", outf); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
51 if (binaddr[0] < 2 || binaddr[0] > 11) { |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
52 malformed: fputs("malformed ", outf); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
53 return; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
54 } |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
55 rc = decode_phone_number(binaddr + 2, binaddr[0] - 1, digits); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
56 if (rc < 0) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
57 goto malformed; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
58 rc = check_blank_area(binaddr + 1 + binaddr[0], binaddr + 12); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
59 if (rc < 0) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
60 goto malformed; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
61 /* all checks passed */ |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
62 fprintf(outf, "%s,0x%02X ", digits, binaddr[1]); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
63 } |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
64 |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
65 static void |
19
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
66 dump_record(recno, outf) |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
67 unsigned recno; |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
68 FILE *outf; |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
69 { |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
70 int rc; |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
71 unsigned textlen; |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
72 u_char *fixp; |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
73 |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
74 fprintf(outf, "#%u: ", recno); |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
75 if (sim_resp_data_len > 28) { |
19
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
76 rc = validate_alpha_field(sim_resp_data, |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
77 sim_resp_data_len - 28, |
19
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
78 &textlen); |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
79 if (rc < 0) { |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
80 malformed: fprintf(outf, "malformed record\n"); |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
81 return; |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
82 } |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
83 } else |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
84 textlen = 0; |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
85 fixp = sim_resp_data + sim_resp_data_len - 28; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
86 if ((fixp[0] & 0xE0) != 0xE0) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
87 goto malformed; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
88 if ((fixp[0] & 0x01) && check_blank_area(fixp + 1, fixp + 13) < 0) |
19
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
89 goto malformed; |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
90 if ((fixp[0] & 0x02) && check_blank_area(fixp + 13, fixp + 25) < 0) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
91 goto malformed; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
92 if ((fixp[0] & 0x04) && fixp[25] != 0xFF) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
93 goto malformed; |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
94 if ((fixp[0] & 0x08) && fixp[26] != 0xFF) |
19
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
95 goto malformed; |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
96 if ((fixp[0] & 0x10) && fixp[27] != 0xFF) |
19
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
97 goto malformed; |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
98 /* basic checks passed, emit present fields */ |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
99 if (!(fixp[0] & 0x01)) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
100 dump_da_field(fixp + 1, outf); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
101 if (!(fixp[0] & 0x02)) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
102 dump_sca_field(fixp + 13, outf); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
103 if (!(fixp[0] & 0x04)) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
104 fprintf(outf, "PID=0x%02X ", fixp[25]); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
105 if (!(fixp[0] & 0x08)) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
106 fprintf(outf, "DCS=0x%02X ", fixp[26]); |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
107 if (!(fixp[0] & 0x10)) |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
108 fprintf(outf, "VP=%u ", fixp[27]); |
19
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
109 print_alpha_field(sim_resp_data, textlen, outf); |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
110 putc('\n', outf); |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
111 } |
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
112 |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
113 cmd_smsp_dump(argc, argv) |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 char **argv; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 int rc; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 FILE *outf; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 unsigned recno; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
120 rc = select_ef_smsp(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 if (rc < 0) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 return(rc); |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
123 if (argv[1]) { |
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
124 outf = fopen(argv[1], "w"); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 if (!outf) { |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
126 perror(argv[1]); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 } else |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 outf = stdout; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 for (recno = 1; recno <= curfile_record_count; recno++) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 rc = readrec_op(recno, 0x04, curfile_record_len); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 if (rc < 0) { |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
134 if (argv[1]) |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 fclose(outf); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 return(rc); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 } |
19
72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
138 dump_record(recno, outf); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 } |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
19
diff
changeset
|
140 if (argv[1]) |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 fclose(outf); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 return(0); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 } |