# HG changeset patch # User Mychaela Falconia # Date 1613603940 0 # Node ID 63c76f9d678a0d4cb9b2a64e8f1c4c8c96002312 # Parent a75c0aafb3672681baf863e0190f47f5a6b58334 plmnsel-dump can now write to file diff -r a75c0aafb367 -r 63c76f9d678a simtool/dispatch.c --- 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}, diff -r a75c0aafb367 -r 63c76f9d678a simtool/plmnsel.c --- 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); }