FreeCalypso > hg > fc-sim-tools
comparison simtool/opldump.c @ 10:ddd767f6e15b
fc-simtool ported over
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Mar 2021 07:11:25 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9:c9ef9e91dd8e | 10:ddd767f6e15b |
---|---|
1 /* | |
2 * This module implements the opl-dump command, | |
3 * a companion command to pnn-dump. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <stdio.h> | |
8 #include "simresp.h" | |
9 #include "curfile.h" | |
10 #include "file_id.h" | |
11 | |
12 select_ef_opl() | |
13 { | |
14 int rc; | |
15 | |
16 rc = select_op(DF_GSM); | |
17 if (rc < 0) | |
18 return(rc); | |
19 rc = select_op(EF_OPL); | |
20 if (rc < 0) | |
21 return(rc); | |
22 rc = parse_ef_select_response(); | |
23 if (rc < 0) | |
24 return(rc); | |
25 if (curfile_structure != 0x01) { | |
26 fprintf(stderr, "error: EF_OPL is not linear fixed\n"); | |
27 return(-1); | |
28 } | |
29 if (curfile_record_len < 8) { | |
30 fprintf(stderr, | |
31 "error: EF_OPL record length is less than the spec minimum of 8 bytes\n"); | |
32 return(-1); | |
33 } | |
34 return(0); | |
35 } | |
36 | |
37 static void | |
38 dump_record(recno, outf) | |
39 unsigned recno; | |
40 FILE *outf; | |
41 { | |
42 char ascbuf[8]; | |
43 | |
44 decode_plmn_3bytes(sim_resp_data, ascbuf, 0); | |
45 fprintf(outf, "#%u: %s %02X%02X-%02X%02X %u\n", recno, ascbuf, | |
46 sim_resp_data[3], sim_resp_data[4], sim_resp_data[5], | |
47 sim_resp_data[6], sim_resp_data[7]); | |
48 } | |
49 | |
50 cmd_opl_dump(argc, argv, outf) | |
51 char **argv; | |
52 FILE *outf; | |
53 { | |
54 int rc; | |
55 unsigned recno; | |
56 | |
57 rc = select_ef_opl(); | |
58 if (rc < 0) | |
59 return(rc); | |
60 for (recno = 1; recno <= curfile_record_count; recno++) { | |
61 rc = readrec_op(recno, 0x04, curfile_record_len); | |
62 if (rc < 0) | |
63 return(rc); | |
64 if (check_simresp_all_blank()) | |
65 continue; | |
66 dump_record(recno, outf); | |
67 } | |
68 return(0); | |
69 } |