# HG changeset patch # User Mychaela Falconia # Date 1614047686 0 # Node ID 58406ead24977cdda9513754e8eda7889104125d # Parent 277c66de296fd6c4f3d8e03a567e5e030dbe6581 fc-uicc-tool: support output redirection for select commands diff -r 277c66de296f -r 58406ead2497 uicc/dispatch.c --- 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}, diff -r 277c66de296f -r 58406ead2497 uicc/select.c --- 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 *