annotate simtool/pbdump.c @ 58:1861d9fb7751

fc-simtool dump-lnd command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 13 Feb 2021 21:40:38 +0000
parents 72a24b8538eb
children 0b29c0d19db4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
9
dc565e91069d pb-dump meaty function factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 8
diff changeset
2 * This module implements pb-dump and pb-dump-rec commands.
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>
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdlib.h>
19
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
8 #include "simresp.h"
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "curfile.h"
58
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
10 #include "file_id.h"
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
19
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
12 static
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
13 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
14 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
15 {
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
16 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
17 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
18 return(-1);
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
19 return(0);
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
20 }
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
21
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
22 static void
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
23 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
24 unsigned recno;
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
25 FILE *outf;
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
26 {
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
27 int rc;
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
28 unsigned textlen;
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
29 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
30 char digits[21];
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
31
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
32 fprintf(outf, "#%u: ", recno);
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
33 if (sim_resp_data_len > 14) {
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
34 rc = validate_alpha_field(sim_resp_data,
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
35 sim_resp_data_len - 14,
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
36 &textlen);
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
37 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
38 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
39 return;
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
40 }
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
41 } else
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
42 textlen = 0;
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
43 fixp = sim_resp_data + sim_resp_data_len - 14;
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
44 if (fixp[0] < 2 || fixp[0] > 11)
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
45 goto malformed;
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
46 rc = decode_phone_number(fixp + 2, fixp[0] - 1, digits);
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
47 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
48 goto malformed;
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
49 rc = check_blank_area(fixp + 1 + fixp[0], fixp + 12);
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
50 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
51 goto malformed;
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
52 /* all checks passed */
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
53 fprintf(outf, "%s,0x%02X ", digits, fixp[1]);
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
54 if (fixp[12] != 0xFF)
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
55 fprintf(outf, "CCP=%u ", fixp[12]);
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
56 if (fixp[13] != 0xFF)
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
57 fprintf(outf, "EXT=%u ", fixp[13]);
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
58 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
59 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
60 }
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
61
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 cmd_pb_dump(argc, argv)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 char **argv;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 int rc;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 FILE *outf;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 unsigned recno;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 rc = phonebook_op_common(argv[1]);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 if (argv[2]) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 outf = fopen(argv[2], "w");
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 if (!outf) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 perror(argv[2]);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 } else
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 outf = stdout;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 for (recno = 1; recno <= curfile_record_count; recno++) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 rc = readrec_op(recno, 0x04, curfile_record_len);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 if (rc < 0) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 if (argv[2])
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 fclose(outf);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 }
5
ce189c97b7b1 check_simresp_all_blank() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 1
diff changeset
87 if (check_simresp_all_blank())
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 continue;
19
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
89 dump_record(recno, outf);
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 if (argv[2])
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 fclose(outf);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 return(0);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 cmd_pb_dump_rec(argc, argv)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 char **argv;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 int rc;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 unsigned recno, startrec, endrec;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 rc = phonebook_op_common(argv[1]);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 startrec = strtoul(argv[2], 0, 0);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 if (startrec < 1 || startrec > curfile_record_count) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 fprintf(stderr,
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 "error: specified starting record number is invalid\n");
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 if (argv[3]) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 endrec = strtoul(argv[3], 0, 0);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 if (endrec < 1 || endrec > curfile_record_count) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 fprintf(stderr,
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 "error: specified final record number is invalid\n");
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 if (startrec > endrec) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 fprintf(stderr,
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 "error: reverse record range specified\n");
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 } else
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 endrec = startrec;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 for (recno = startrec; recno <= endrec; recno++) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 rc = readrec_op(recno, 0x04, curfile_record_len);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 return(rc);
5
ce189c97b7b1 check_simresp_all_blank() factored out into libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 1
diff changeset
129 if (check_simresp_all_blank())
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 continue;
19
72a24b8538eb meaty function of pb-dump moved back into simtool, out of libcommon
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
131 dump_record(recno, stdout);
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 return(0);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 }
58
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
135
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
136 cmd_dump_lnd()
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
137 {
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
138 int rc;
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
139 unsigned recno;
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
140
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
141 rc = select_op(DF_TELECOM);
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
142 if (rc < 0)
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
143 return(rc);
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
144 rc = select_op(EF_LND);
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
145 if (rc < 0)
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
146 return(rc);
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
147 rc = parse_ef_select_response();
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
148 if (rc < 0)
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
149 return(rc);
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
150 if (curfile_structure != 0x03) {
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
151 fprintf(stderr, "error: EF_LND is not cyclic\n");
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
152 return(-1);
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
153 }
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
154 if (curfile_record_len < 14) {
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
155 fprintf(stderr,
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
156 "error: EF_LND has record length of %u bytes, less than minimum 14\n",
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
157 curfile_record_len);
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
158 return(-1);
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
159 }
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
160 for (recno = 1; recno <= curfile_record_count; recno++) {
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
161 rc = readrec_op(recno, 0x04, curfile_record_len);
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
162 if (rc < 0)
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
163 return(rc);
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
164 if (check_simresp_all_blank())
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
165 continue;
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
166 dump_record(recno, stdout);
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
167 }
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
168 return(0);
1861d9fb7751 fc-simtool dump-lnd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
169 }