FreeCalypso > hg > fc-sim-tools
annotate uicc/dumpdir.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 |
rev | line source |
---|---|
15
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements the dump of EF_DIR. |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include "file_id.h" |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 cmd_dir(argc, argv, outf) |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 char **argv; |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 FILE *outf; |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 { |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 int rc; |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 unsigned record_len, record_count; |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 unsigned recno; |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 rc = select_op(FILEID_MF); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 if (rc < 0) |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 return(rc); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 rc = select_op(EF_DIR); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 if (rc < 0) |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 return(rc); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 rc = select_resp_get_linear_fixed(&record_len, &record_count); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (rc < 0) |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 return(rc); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 if (record_len < 5) { |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 fprintf(stderr, "error: EF_DIR record length is too short\n"); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 return(-1); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 } |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 for (recno = 1; recno <= record_count; recno++) { |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 rc = readrec_op(recno, 0x04, record_len); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 if (rc < 0) |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 return(rc); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (check_simresp_all_blank()) |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 continue; |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 fprintf(outf, "Record #%u:\n", recno); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 dump_efdir_record(outf); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 return(0); |
b70d35f5476f
fc-uicc-tool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 } |