comparison uicc/hlread.c @ 15:b70d35f5476f

fc-uicc-tool ported over
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Mar 2021 07:41:09 +0000
parents
children 97646b363eaa
comparison
equal deleted inserted replaced
14:b7ee2e85686b 15:b70d35f5476f
1 /*
2 * This module implements some high-level or user-friendly read commands.
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include "simresp.h"
8 #include "file_id.h"
9
10 cmd_iccid(argc, argv, outf)
11 char **argv;
12 FILE *outf;
13 {
14 int rc;
15 unsigned len;
16 char buf[21], *cp;
17
18 rc = select_op(FILEID_MF);
19 if (rc < 0)
20 return(rc);
21 rc = select_op(EF_ICCID);
22 if (rc < 0)
23 return(rc);
24 rc = select_resp_get_transparent(&len);
25 if (rc < 0)
26 return(rc);
27 if (len != 10) {
28 fprintf(stderr, "error: expected transparent EF of 10 bytes\n");
29 return(-1);
30 }
31 rc = readbin_op(0, 10);
32 if (rc < 0)
33 return(rc);
34 decode_reversed_nibbles(sim_resp_data, 10, buf);
35 for (cp = buf + 20; (cp > buf + 1) && (cp[-1] == 'F'); cp--)
36 ;
37 *cp = '\0';
38 fprintf(outf, "%s\n", buf);
39 return(0);
40 }