FreeCalypso > hg > fc-pcsc-tools
changeset 114:2c07684a3980
fc-simtool pnn-dump: support output redirection
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 19 Feb 2021 07:22:56 +0000 |
parents | 32acef9d20ff |
children | f1ea981ab225 |
files | simtool/dispatch.c simtool/pnndump.c |
diffstat | 2 files changed, 17 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/simtool/dispatch.c Fri Feb 19 07:17:59 2021 +0000 +++ b/simtool/dispatch.c Fri Feb 19 07:22:56 2021 +0000 @@ -146,7 +146,7 @@ {"plmnsel-erase", 1, 2, 0, cmd_plmnsel_erase}, {"plmnsel-erase-all", 0, 0, 0, cmd_plmnsel_erase_all}, {"plmnsel-write", 2, 2, 0, cmd_plmnsel_write}, - {"pnn-dump", 0, 0, 0, cmd_pnn_dump}, + {"pnn-dump", 0, 0, 1, cmd_pnn_dump}, {"quit", 0, 0, 0, good_exit}, {"readbin", 2, 2, 1, cmd_readbin}, {"readef", 1, 1, 1, cmd_readef},
--- a/simtool/pnndump.c Fri Feb 19 07:17:59 2021 +0000 +++ b/simtool/pnndump.c Fri Feb 19 07:22:56 2021 +0000 @@ -10,15 +10,16 @@ #include "file_id.h" static void -dump_record(recno) +dump_record(recno, outf) unsigned recno; + FILE *outf; { u_char *dp, *endp; char *name_kw; unsigned ielen, code_byte, nsept; u_char gsm7_buf[288]; - printf("#%u:", recno); + fprintf(outf, "#%u:", recno); dp = sim_resp_data; endp = sim_resp_data + sim_resp_data_len; while (dp < endp) { @@ -32,44 +33,46 @@ name_kw = "Sn"; break; default: - printf(" unknown-IEI\n"); + fprintf(outf, " unknown-IEI\n"); return; } if (dp >= endp) { - printf(" truncated-IE\n"); + fprintf(outf, " truncated-IE\n"); return; } ielen = *dp++; if (ielen < 1 || ielen > (endp - dp)) { - printf(" bad-length\n"); + fprintf(outf, " bad-length\n"); return; } code_byte = *dp++; ielen--; - printf(" %s=0x%02X", name_kw, code_byte); + fprintf(outf, " %s=0x%02X", name_kw, code_byte); if (!ielen) continue; - putchar(','); + putc(',', outf); if ((code_byte & 0x70) == 0) { nsept = ielen * 8 / 7; gsm7_unpack(dp, gsm7_buf, nsept); dp += ielen; - print_gsm7_string_to_file(gsm7_buf, nsept, stdout); + print_gsm7_string_to_file(gsm7_buf, nsept, outf); } else { for (; ielen; ielen--) - printf("%02X", *dp++); + fprintf(outf, "%02X", *dp++); } } for (; dp < endp; dp++) { if (*dp != 0xFF) { - printf(" bad-padding\n"); + fprintf(outf, " bad-padding\n"); return; } } - putchar('\n'); + putc('\n', outf); } -cmd_pnn_dump() +cmd_pnn_dump(argc, argv, outf) + char **argv; + FILE *outf; { int rc; unsigned recno; @@ -98,7 +101,7 @@ return(rc); if (check_simresp_all_blank()) continue; - dump_record(recno); + dump_record(recno, outf); } return(0); }