annotate simtool/opldump.c @ 229:ed8cb3c0d312 default tip

new README, indicating repository move
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Mar 2021 18:26:13 +0000
parents 52c0da56e979
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the opl-dump command,
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * a companion command to pnn-dump.
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "simresp.h"
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "curfile.h"
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "file_id.h"
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
217
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
12 select_ef_opl()
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
13 {
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
14 int rc;
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
15
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
16 rc = select_op(DF_GSM);
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
17 if (rc < 0)
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
18 return(rc);
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
19 rc = select_op(EF_OPL);
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
20 if (rc < 0)
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
21 return(rc);
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
22 rc = parse_ef_select_response();
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
23 if (rc < 0)
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
24 return(rc);
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
25 if (curfile_structure != 0x01) {
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
26 fprintf(stderr, "error: EF_OPL is not linear fixed\n");
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
27 return(-1);
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
28 }
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
29 if (curfile_record_len < 8) {
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
30 fprintf(stderr,
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
31 "error: EF_OPL record length is less than the spec minimum of 8 bytes\n");
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
32 return(-1);
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
33 }
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
34 return(0);
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
35 }
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
36
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 static void
112
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
38 dump_record(recno, outf)
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 unsigned recno;
112
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
40 FILE *outf;
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 char ascbuf[8];
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 decode_plmn_3bytes(sim_resp_data, ascbuf, 0);
112
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
45 fprintf(outf, "#%u: %s %02X%02X-%02X%02X %u\n", recno, ascbuf,
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 sim_resp_data[3], sim_resp_data[4], sim_resp_data[5],
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 sim_resp_data[6], sim_resp_data[7]);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
112
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
50 cmd_opl_dump(argc, argv, outf)
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
51 char **argv;
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
52 FILE *outf;
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 int rc;
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 unsigned recno;
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56
217
52c0da56e979 simtool code: select_ef_opl() factored out
Mychaela Falconia <falcon@freecalypso.org>
parents: 112
diff changeset
57 rc = select_ef_opl();
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 if (rc < 0)
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 return(rc);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 for (recno = 1; recno <= curfile_record_count; recno++) {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 rc = readrec_op(recno, 0x04, curfile_record_len);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 if (rc < 0)
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 return(rc);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 if (check_simresp_all_blank())
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 continue;
112
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
66 dump_record(recno, outf);
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 }
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 return(0);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 }