FreeCalypso > hg > fc-pcsc-tools
comparison uicc/readcmd.c @ 107:f1836c8d36cb
hexdump output commands reworked to support redirection
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 19 Feb 2021 06:43:01 +0000 |
parents | 1b1468869ccf |
children | ba8c35ecf796 |
comparison
equal
deleted
inserted
replaced
106:dcfec53643c5 | 107:f1836c8d36cb |
---|---|
4 #include <stdlib.h> | 4 #include <stdlib.h> |
5 #include "simresp.h" | 5 #include "simresp.h" |
6 | 6 |
7 extern unsigned last_sel_file_record_len; | 7 extern unsigned last_sel_file_record_len; |
8 | 8 |
9 cmd_readbin(argc, argv) | 9 cmd_readbin(argc, argv, outf) |
10 char **argv; | 10 char **argv; |
11 FILE *outf; | |
11 { | 12 { |
12 unsigned offset, len; | 13 unsigned offset, len; |
13 int rc; | 14 int rc; |
14 | 15 |
15 offset = strtoul(argv[1], 0, 0); | 16 offset = strtoul(argv[1], 0, 0); |
23 return(-1); | 24 return(-1); |
24 } | 25 } |
25 rc = readbin_op(offset, len); | 26 rc = readbin_op(offset, len); |
26 if (rc < 0) | 27 if (rc < 0) |
27 return(rc); | 28 return(rc); |
28 display_sim_resp_in_hex(); | 29 display_sim_resp_in_hex(outf); |
29 return(0); | 30 return(0); |
30 } | 31 } |
31 | 32 |
32 cmd_readrec(argc, argv) | 33 cmd_readrec(argc, argv, outf) |
33 char **argv; | 34 char **argv; |
35 FILE *outf; | |
34 { | 36 { |
35 unsigned recno, len; | 37 unsigned recno, len; |
36 int rc; | 38 int rc; |
37 | 39 |
38 recno = strtoul(argv[1], 0, 0); | 40 recno = strtoul(argv[1], 0, 0); |
57 len = last_sel_file_record_len; | 59 len = last_sel_file_record_len; |
58 } | 60 } |
59 rc = readrec_op(recno, 0x04, len); | 61 rc = readrec_op(recno, 0x04, len); |
60 if (rc < 0) | 62 if (rc < 0) |
61 return(rc); | 63 return(rc); |
62 display_sim_resp_in_hex(); | 64 display_sim_resp_in_hex(outf); |
63 return(0); | 65 return(0); |
64 } | 66 } |
65 | 67 |
66 cmd_readef(argc, argv) | 68 cmd_readef(argc, argv, outf) |
67 char **argv; | 69 char **argv; |
70 FILE *outf; | |
68 { | 71 { |
69 int file_id, rc; | 72 int file_id, rc; |
70 unsigned file_len, readlen; | 73 unsigned file_len, readlen; |
71 | 74 |
72 if (isxdigit(argv[1][0]) && isxdigit(argv[1][1]) && | 75 if (isxdigit(argv[1][0]) && isxdigit(argv[1][1]) && |
83 if (rc < 0) | 86 if (rc < 0) |
84 return(rc); | 87 return(rc); |
85 rc = select_resp_get_transparent(&file_len); | 88 rc = select_resp_get_transparent(&file_len); |
86 if (rc < 0) | 89 if (rc < 0) |
87 return(rc); | 90 return(rc); |
88 printf("Transparent EF of %u byte(s)\n", file_len); | 91 if (outf == stdout) |
92 printf("Transparent EF of %u byte(s)\n", file_len); | |
89 if (!file_len) | 93 if (!file_len) |
90 return(0); | 94 return(0); |
91 readlen = file_len; | 95 readlen = file_len; |
92 if (readlen > 256) | 96 if (readlen > 256) |
93 readlen = 256; | 97 readlen = 256; |
94 rc = readbin_op(0, readlen); | 98 rc = readbin_op(0, readlen); |
95 if (rc < 0) | 99 if (rc < 0) |
96 return(rc); | 100 return(rc); |
97 display_sim_resp_in_hex(); | 101 display_sim_resp_in_hex(outf); |
98 return(0); | 102 return(0); |
99 } | 103 } |