annotate simtool/opldump.c @ 130:9c10afbb745a

fc-simtool: search added to file-reading commands
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 20 Feb 2021 21:54:12 +0000
parents 440a4582d2a5
children 52c0da56e979
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
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 static void
112
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
13 dump_record(recno, outf)
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 unsigned recno;
112
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
15 FILE *outf;
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 char ascbuf[8];
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 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
20 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
21 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
22 sim_resp_data[6], sim_resp_data[7]);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 }
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
112
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
25 cmd_opl_dump(argc, argv, outf)
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
26 char **argv;
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
27 FILE *outf;
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 int rc;
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 unsigned recno;
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 rc = select_op(DF_GSM);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 if (rc < 0)
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 return(rc);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 rc = select_op(EF_OPL);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (rc < 0)
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 return(rc);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 rc = parse_ef_select_response();
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 if (rc < 0)
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 return(rc);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 if (curfile_structure != 0x01) {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 fprintf(stderr, "error: EF_OPL is not linear fixed\n");
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 return(-1);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (curfile_record_len < 8) {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 fprintf(stderr,
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 "error: EF_OPL record length is less than the spec minimum of 8 bytes\n");
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 return(-1);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 for (recno = 1; recno <= curfile_record_count; recno++) {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 rc = readrec_op(recno, 0x04, curfile_record_len);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 if (rc < 0)
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 return(rc);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 if (check_simresp_all_blank())
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 continue;
112
440a4582d2a5 fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
56 dump_record(recno, outf);
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 }
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 return(0);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 }