comparison uicc/select.c @ 130:f691a19f191d

fc-uicc-tool skeleton started
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 04 Feb 2021 00:08:12 +0000
parents
children d0929cb42e1c
comparison
equal deleted inserted replaced
129:2adb802b2a98 130:f691a19f191d
1 #include <sys/types.h>
2 #include <ctype.h>
3 #include <string.h>
4 #include <strings.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <pcsclite.h>
8 #include <winscard.h>
9 #include "globals.h"
10
11 select_op(file_id)
12 unsigned file_id;
13 {
14 u_char cmd[7];
15 int rc;
16
17 /* SELECT command APDU */
18 cmd[0] = 0x00;
19 cmd[1] = 0xA4;
20 cmd[2] = 0x00;
21 cmd[3] = 0x04;
22 cmd[4] = 2;
23 cmd[5] = file_id >> 8;
24 cmd[6] = file_id;
25 rc = apdu_exchange(cmd, 7);
26 if (rc < 0)
27 return(rc);
28 printf("SW response to SELECT: %04X\n", sim_resp_sw);
29 return(0);
30 }
31
32 cmd_select(argc, argv)
33 char **argv;
34 {
35 int file_id;
36
37 if (isxdigit(argv[1][0]) && isxdigit(argv[1][1]) &&
38 isxdigit(argv[1][2]) && isxdigit(argv[1][3]) && !argv[1][4])
39 file_id = strtoul(argv[1], 0, 16);
40 else
41 file_id = find_symbolic_file_name(argv[1]);
42 if (file_id < 0) {
43 fprintf(stderr,
44 "error: file ID argument is not a hex value or a recognized symbolic name\n");
45 return(-1);
46 }
47 return select_op(file_id);
48 }