FreeCalypso > hg > fc-sim-tools
comparison uicc/readcmd.c @ 89:db131929ee96
fc-uicc-tool: extended readef ported over from fc-simtool
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 11 Apr 2021 04:17:58 +0000 |
parents | b70d35f5476f |
children |
comparison
equal
deleted
inserted
replaced
88:49b7e02787c1 | 89:db131929ee96 |
---|---|
1 /* | |
2 * This module implements elementary low-level readbin and readrec commands. | |
3 */ | |
4 | |
1 #include <sys/types.h> | 5 #include <sys/types.h> |
2 #include <ctype.h> | |
3 #include <stdio.h> | 6 #include <stdio.h> |
4 #include <stdlib.h> | 7 #include <stdlib.h> |
5 #include "simresp.h" | 8 #include "simresp.h" |
6 | 9 |
7 extern unsigned last_sel_file_record_len; | 10 extern unsigned last_sel_file_record_len; |
62 if (rc < 0) | 65 if (rc < 0) |
63 return(rc); | 66 return(rc); |
64 display_sim_resp_in_hex(outf); | 67 display_sim_resp_in_hex(outf); |
65 return(0); | 68 return(0); |
66 } | 69 } |
67 | |
68 cmd_readef(argc, argv, outf) | |
69 char **argv; | |
70 FILE *outf; | |
71 { | |
72 int file_id, rc; | |
73 unsigned file_len, readlen; | |
74 | |
75 if (isxdigit(argv[1][0]) && isxdigit(argv[1][1]) && | |
76 isxdigit(argv[1][2]) && isxdigit(argv[1][3]) && !argv[1][4]) | |
77 file_id = strtoul(argv[1], 0, 16); | |
78 else | |
79 file_id = find_symbolic_file_name(argv[1]); | |
80 if (file_id < 0) { | |
81 fprintf(stderr, | |
82 "error: file ID argument is not a hex value or a recognized symbolic name\n"); | |
83 return(-1); | |
84 } | |
85 rc = select_op(file_id); | |
86 if (rc < 0) | |
87 return(rc); | |
88 rc = select_resp_get_transparent(&file_len); | |
89 if (rc < 0) | |
90 return(rc); | |
91 fprintf(outf, "Transparent EF of %u byte(s)\n", file_len); | |
92 if (!file_len) | |
93 return(0); | |
94 readlen = file_len; | |
95 if (readlen > 256) | |
96 readlen = 256; | |
97 rc = readbin_op(0, readlen); | |
98 if (rc < 0) | |
99 return(rc); | |
100 display_sim_resp_in_hex(outf); | |
101 return(0); | |
102 } |