comparison uicc/createfile.c @ 140:13ab44761ea6

fc-uicc-tool delete-file implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 24 Feb 2021 17:16:04 +0000
parents c13ed9194ecd
children 878d66dce6d3
comparison
equal deleted inserted replaced
139:c13ed9194ecd 140:13ab44761ea6
2 * This module implements commands that exercise ETSI TS 102 222 2 * This module implements commands that exercise ETSI TS 102 222
3 * CREATE FILE and DELETE FILE operations. 3 * CREATE FILE and DELETE FILE operations.
4 */ 4 */
5 5
6 #include <sys/types.h> 6 #include <sys/types.h>
7 #include <ctype.h>
7 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h>
8 #include <string.h> 10 #include <string.h>
9 #include <strings.h> 11 #include <strings.h>
10 #include "simresp.h" 12 #include "simresp.h"
11 13
12 cmd_create_file(argc, argv) 14 cmd_create_file(argc, argv)
44 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); 46 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
45 return(-1); 47 return(-1);
46 } 48 }
47 return(0); 49 return(0);
48 } 50 }
51
52 cmd_delete_file(argc, argv)
53 char **argv;
54 {
55 u_char apdu[7];
56 unsigned file_id;
57 int rc;
58
59 if (!isxdigit(argv[1][0]) || !isxdigit(argv[1][1]) ||
60 !isxdigit(argv[1][2]) || !isxdigit(argv[1][3]) || argv[1][4]) {
61 fprintf(stderr, "error: 4-digit hex argument required\n");
62 return(-1);
63 }
64 file_id = strtoul(argv[1], 0, 16);
65 /* form command APDU */
66 apdu[0] = 0x00;
67 apdu[1] = 0xE4;
68 apdu[2] = 0;
69 apdu[3] = 0;
70 apdu[4] = 2;
71 apdu[5] = file_id >> 8;
72 apdu[6] = file_id;
73 rc = apdu_exchange(apdu, 7);
74 if (rc < 0)
75 return(rc);
76 if (sim_resp_sw != 0x9000) {
77 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
78 return(-1);
79 }
80 return(0);
81 }