FreeCalypso > hg > fc-pcsc-tools
changeset 101:63c76f9d678a
plmnsel-dump can now write to file
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 17 Feb 2021 23:19:00 +0000 |
parents | a75c0aafb367 |
children | 9ce95d9c5c34 |
files | simtool/dispatch.c simtool/plmnsel.c |
diffstat | 2 files changed, 20 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/simtool/dispatch.c Wed Feb 17 22:54:35 2021 +0000 +++ b/simtool/dispatch.c Wed Feb 17 23:19:00 2021 +0000 @@ -132,7 +132,7 @@ {"pb-update", 2, 2, cmd_pb_update}, {"pb-update-imm", 3, 4, cmd_pb_update_imm}, {"pb-update-imm-hex", 4, 4, cmd_pb_update_imm_hex}, - {"plmnsel-dump", 0, 0, cmd_plmnsel_dump}, + {"plmnsel-dump", 0, 1, cmd_plmnsel_dump}, {"plmnsel-erase", 1, 2, cmd_plmnsel_erase}, {"plmnsel-write", 2, 2, cmd_plmnsel_write}, {"pnn-dump", 0, 0, cmd_pnn_dump},
--- a/simtool/plmnsel.c Wed Feb 17 22:54:35 2021 +0000 +++ b/simtool/plmnsel.c Wed Feb 17 23:19:00 2021 +0000 @@ -47,12 +47,14 @@ return(0); } -cmd_plmnsel_dump() +cmd_plmnsel_dump(argc, argv) + char **argv; { int rc, gap_flag; u_char *dp, *endp; char ascbuf[8]; unsigned idx, linelen; + FILE *outf; rc = select_ef_plmnsel(); if (rc < 0) @@ -60,6 +62,14 @@ rc = readbin_op(0, curfile_total_size); if (rc < 0) return(rc); + if (argv[1]) { + outf = fopen(argv[1], "w"); + if (!outf) { + perror(argv[1]); + return(-1); + } + } else + outf = stdout; dp = sim_resp_data; endp = sim_resp_data + sim_resp_data_len; gap_flag = 0; @@ -71,24 +81,26 @@ } if (gap_flag) { if (linelen) { - putchar('\n'); + putc('\n', outf); linelen = 0; } - printf("GAP, continuing at index %u:\n", idx); + fprintf(outf, "GAP, continuing at index %u:\n", idx); gap_flag = 0; } if (linelen >= 10) { - putchar('\n'); + putc('\n', outf); linelen = 0; } decode_plmn_3bytes(dp, ascbuf, 1); if (linelen) - putchar(' '); - fputs(ascbuf, stdout); + putc(' ', outf); + fputs(ascbuf, outf); linelen++; } if (linelen) - putchar('\n'); + putc('\n', outf); + if (argv[1]) + fclose(outf); return(0); }