FreeCalypso > hg > fc-pcsc-tools
comparison simtool/opldump.c @ 54:2d1679c7975b
fc-simtool opl-dump implemented
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sat, 13 Feb 2021 06:44:34 +0000 |
| parents | |
| children | 440a4582d2a5 |
comparison
equal
deleted
inserted
replaced
| 53:4eb447be01c0 | 54:2d1679c7975b |
|---|---|
| 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 static void | |
| 13 dump_record(recno) | |
| 14 unsigned recno; | |
| 15 { | |
| 16 char ascbuf[8]; | |
| 17 | |
| 18 decode_plmn_3bytes(sim_resp_data, ascbuf, 0); | |
| 19 printf("#%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[6], sim_resp_data[7]); | |
| 22 } | |
| 23 | |
| 24 cmd_opl_dump() | |
| 25 { | |
| 26 int rc; | |
| 27 unsigned recno; | |
| 28 | |
| 29 rc = select_op(DF_GSM); | |
| 30 if (rc < 0) | |
| 31 return(rc); | |
| 32 rc = select_op(EF_OPL); | |
| 33 if (rc < 0) | |
| 34 return(rc); | |
| 35 rc = parse_ef_select_response(); | |
| 36 if (rc < 0) | |
| 37 return(rc); | |
| 38 if (curfile_structure != 0x01) { | |
| 39 fprintf(stderr, "error: EF_OPL is not linear fixed\n"); | |
| 40 return(-1); | |
| 41 } | |
| 42 if (curfile_record_len < 8) { | |
| 43 fprintf(stderr, | |
| 44 "error: EF_OPL record length is less than the spec minimum of 8 bytes\n"); | |
| 45 return(-1); | |
| 46 } | |
| 47 for (recno = 1; recno <= curfile_record_count; recno++) { | |
| 48 rc = readrec_op(recno, 0x04, curfile_record_len); | |
| 49 if (rc < 0) | |
| 50 return(rc); | |
| 51 if (check_simresp_all_blank()) | |
| 52 continue; | |
| 53 dump_record(recno); | |
| 54 } | |
| 55 return(0); | |
| 56 } |
