FreeCalypso > hg > fc-pcsc-tools
annotate uicc/hlread.c @ 129:94d87d05f6c5
libcommon: initial support for file search
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 20 Feb 2021 21:00:24 +0000 |
parents | d4b5a6e547ca |
children | ede661d78730 |
rev | line source |
---|---|
22
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements some high-level or user-friendly read commands. |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include "simresp.h" |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include "file_id.h" |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 cmd_iccid() |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 { |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 int rc; |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 unsigned len; |
56
d4b5a6e547ca
fc-uicc-tool iccid command: same change as in fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
14 char buf[21], *cp; |
22
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 rc = select_op(FILEID_MF); |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 if (rc < 0) |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 return(rc); |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 rc = select_op(EF_ICCID); |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 if (rc < 0) |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 return(rc); |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 rc = select_resp_get_transparent(&len); |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 if (rc < 0) |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 return(rc); |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 if (len != 10) { |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 fprintf(stderr, "error: expected transparent EF of 10 bytes\n"); |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 return(-1); |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 } |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 rc = readbin_op(0, 10); |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 if (rc < 0) |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 return(rc); |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 decode_reversed_nibbles(sim_resp_data, 10, buf); |
56
d4b5a6e547ca
fc-uicc-tool iccid command: same change as in fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
33 for (cp = buf + 20; (cp > buf + 1) && (cp[-1] == 'F'); cp--) |
d4b5a6e547ca
fc-uicc-tool iccid command: same change as in fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
34 ; |
d4b5a6e547ca
fc-uicc-tool iccid command: same change as in fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
22
diff
changeset
|
35 *cp = '\0'; |
22
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 printf("%s\n", buf); |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 return(0); |
1b1468869ccf
new trimmed fc-uicc-tool is here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |