comparison simtool/opldump.c @ 112:440a4582d2a5

fc-simtool opl-dump: support output redirection
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 19 Feb 2021 07:09:21 +0000
parents 2d1679c7975b
children 52c0da56e979
comparison
equal deleted inserted replaced
111:869488ef86b6 112:440a4582d2a5
8 #include "simresp.h" 8 #include "simresp.h"
9 #include "curfile.h" 9 #include "curfile.h"
10 #include "file_id.h" 10 #include "file_id.h"
11 11
12 static void 12 static void
13 dump_record(recno) 13 dump_record(recno, outf)
14 unsigned recno; 14 unsigned recno;
15 FILE *outf;
15 { 16 {
16 char ascbuf[8]; 17 char ascbuf[8];
17 18
18 decode_plmn_3bytes(sim_resp_data, ascbuf, 0); 19 decode_plmn_3bytes(sim_resp_data, ascbuf, 0);
19 printf("#%u: %s %02X%02X-%02X%02X %u\n", recno, ascbuf, 20 fprintf(outf, "#%u: %s %02X%02X-%02X%02X %u\n", recno, ascbuf,
20 sim_resp_data[3], sim_resp_data[4], sim_resp_data[5], 21 sim_resp_data[3], sim_resp_data[4], sim_resp_data[5],
21 sim_resp_data[6], sim_resp_data[7]); 22 sim_resp_data[6], sim_resp_data[7]);
22 } 23 }
23 24
24 cmd_opl_dump() 25 cmd_opl_dump(argc, argv, outf)
26 char **argv;
27 FILE *outf;
25 { 28 {
26 int rc; 29 int rc;
27 unsigned recno; 30 unsigned recno;
28 31
29 rc = select_op(DF_GSM); 32 rc = select_op(DF_GSM);
48 rc = readrec_op(recno, 0x04, curfile_record_len); 51 rc = readrec_op(recno, 0x04, curfile_record_len);
49 if (rc < 0) 52 if (rc < 0)
50 return(rc); 53 return(rc);
51 if (check_simresp_all_blank()) 54 if (check_simresp_all_blank())
52 continue; 55 continue;
53 dump_record(recno); 56 dump_record(recno, outf);
54 } 57 }
55 return(0); 58 return(0);
56 } 59 }