FreeCalypso > hg > fc-pcsc-tools
changeset 138:58406ead2497
fc-uicc-tool: support output redirection for select commands
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 23 Feb 2021 02:34:46 +0000 |
parents | 277c66de296f |
children | c13ed9194ecd |
files | uicc/dispatch.c uicc/select.c |
diffstat | 2 files changed, 23 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/uicc/dispatch.c Mon Feb 22 00:08:42 2021 +0000 +++ b/uicc/dispatch.c Tue Feb 23 02:34:46 2021 +0000 @@ -59,10 +59,10 @@ {"readbin", 2, 2, 1, cmd_readbin}, {"readef", 1, 1, 1, cmd_readef}, {"readrec", 1, 2, 1, cmd_readrec}, - {"select", 1, 1, 0, cmd_select}, - {"select-aid", 1, 1, 0, cmd_select_aid}, - {"select-isim", 0, 0, 0, cmd_select_isim}, - {"select-usim", 0, 0, 0, cmd_select_usim}, + {"select", 1, 1, 1, cmd_select}, + {"select-aid", 1, 1, 1, cmd_select_aid}, + {"select-isim", 0, 0, 1, cmd_select_isim}, + {"select-usim", 0, 0, 1, cmd_select_usim}, {"sim-resp", 0, 0, 1, cmd_sim_resp}, {"unblock-pin", 3, 3, 0, cmd_unblock_pin}, {"update-bin", 2, 2, 0, cmd_update_bin},
--- a/uicc/select.c Mon Feb 22 00:08:42 2021 +0000 +++ b/uicc/select.c Tue Feb 23 02:34:46 2021 +0000 @@ -164,7 +164,8 @@ last_sel_file_record_len = reclen; } -parse_and_display_select_response() +parse_and_display_select_response(outf) + FILE *outf; { unsigned offset, totlen, reclen, n; u_char *dp, *endp; @@ -198,16 +199,17 @@ check_for_record_struct(dp); for (n = 0; n < reclen; n++) { if (n) - putchar(' '); - printf("%02X", *dp++); + putc(' ', outf); + fprintf(outf, "%02X", *dp++); } - putchar('\n'); + putc('\n', outf); } return(0); } -cmd_select(argc, argv) +cmd_select(argc, argv, outf) char **argv; + FILE *outf; { int file_id, rc; @@ -224,11 +226,12 @@ rc = select_op(file_id); if (rc < 0) return(rc); - return parse_and_display_select_response(); + return parse_and_display_select_response(outf); } -cmd_select_aid(argc, argv) +cmd_select_aid(argc, argv, outf) char **argv; + FILE *outf; { u_char aid[16]; unsigned aid_len; @@ -241,27 +244,31 @@ rc = select_aid_op(aid, aid_len); if (rc < 0) return(rc); - return parse_and_display_select_response(); + return parse_and_display_select_response(outf); } -cmd_select_usim() +cmd_select_usim(argc, argv, outf) + char **argv; + FILE *outf; { int rc; rc = select_aid_op(std_aid_usim, 7); if (rc < 0) return(rc); - return parse_and_display_select_response(); + return parse_and_display_select_response(outf); } -cmd_select_isim() +cmd_select_isim(argc, argv, outf) + char **argv; + FILE *outf; { int rc; rc = select_aid_op(std_aid_isim, 7); if (rc < 0) return(rc); - return parse_and_display_select_response(); + return parse_and_display_select_response(outf); } u_char *