# HG changeset patch # User Mychaela Falconia # Date 1613717996 0 # Node ID 2aa92dfcb4b5c447f555cc5dac816aab719af86f # Parent 8a27f45bc1e697497e8d2cb6c60ad4ba6658f35b fc-simtool iccid, imsi, spn: support output redirection diff -r 8a27f45bc1e6 -r 2aa92dfcb4b5 simtool/dispatch.c --- a/simtool/dispatch.c Fri Feb 19 06:53:14 2021 +0000 +++ b/simtool/dispatch.c Fri Feb 19 06:59:56 2021 +0000 @@ -126,8 +126,8 @@ {"grcard2-set-puk2", 1, 1, 0, cmd_grcard2_set_puk}, {"grcard2-set-super", 1, 1, 0, cmd_grcard2_set_super}, {"grcard2-set-super-hex", 1, 1, 0, cmd_grcard2_set_super_hex}, - {"iccid", 0, 0, 0, cmd_iccid}, - {"imsi", 0, 0, 0, cmd_imsi}, + {"iccid", 0, 0, 1, cmd_iccid}, + {"imsi", 0, 0, 1, cmd_imsi}, {"lnd-dump", 0, 1, 0, cmd_lnd_dump}, {"lnd-erase", 0, 0, 0, cmd_lnd_erase}, {"lnd-restore", 1, 1, 0, cmd_lnd_restore}, @@ -166,7 +166,7 @@ {"smsp-restore", 1, 1, 0, cmd_smsp_restore}, {"smsp-set", 2, 6, 0, cmd_smsp_set}, {"smsp-set-tag", 3, 7, 0, cmd_smsp_set_tag}, - {"spn", 0, 0, 0, cmd_spn}, + {"spn", 0, 0, 1, cmd_spn}, {"sst", 0, 0, 0, cmd_sst}, {"telecom-sum", 0, 0, 0, cmd_telecom_sum}, {"uicc-dir", 0, 0, 1, cmd_uicc_dir}, diff -r 8a27f45bc1e6 -r 2aa92dfcb4b5 simtool/hlread.c --- a/simtool/hlread.c Fri Feb 19 06:53:14 2021 +0000 +++ b/simtool/hlread.c Fri Feb 19 06:59:56 2021 +0000 @@ -8,7 +8,9 @@ #include "curfile.h" #include "file_id.h" -cmd_iccid() +cmd_iccid(argc, argv, outf) + char **argv; + FILE *outf; { int rc; char buf[21], *cp; @@ -33,11 +35,13 @@ for (cp = buf + 20; (cp > buf + 1) && (cp[-1] == 'F'); cp--) ; *cp = '\0'; - printf("%s\n", buf); + fprintf(outf, "%s\n", buf); return(0); } -cmd_imsi() +cmd_imsi(argc, argv, outf) + char **argv; + FILE *outf; { int rc; char buf[17]; @@ -60,11 +64,14 @@ return(rc); decode_reversed_nibbles(sim_resp_data + 1, 8, buf); buf[16] = '\0'; - printf("%s parity=%c len=%u\n", buf + 1, buf[0], sim_resp_data[0]); + fprintf(outf, "%s parity=%c len=%u\n", buf + 1, buf[0], + sim_resp_data[0]); return(0); } -cmd_spn() +cmd_spn(argc, argv, outf) + char **argv; + FILE *outf; { int rc; unsigned textlen; @@ -85,13 +92,13 @@ rc = readbin_op(0, 17); if (rc < 0) return(rc); - printf("Display condition: %02X\n", sim_resp_data[0]); - printf("SPN: "); + fprintf(outf, "Display condition: %02X\n", sim_resp_data[0]); + fputs("SPN: ", outf); rc = validate_alpha_field(sim_resp_data + 1, 16, &textlen); if (rc >= 0) - print_alpha_field(sim_resp_data, textlen, stdout); + print_alpha_field(sim_resp_data, textlen, outf); else - printf("malformed alpha field"); - putchar('\n'); + fputs("malformed alpha field", outf); + putc('\n', outf); return(0); }