FreeCalypso > hg > freecalypso-hwlab
annotate uicc/telsum.c @ 151:d515cfbb3f39
fc-simtool: hex string parsing: add minimum length parameter
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 07 Feb 2021 00:18:30 +0000 |
parents | 0b8a936f4542 |
children |
rev | line source |
---|---|
135
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements the telecom-sum (summary info) command. |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdio.h> |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdlib.h> |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include "file_id.h" |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 static |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 do_phonebook_file(file_id, book_name) |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 unsigned file_id; |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 char *book_name; |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 { |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 unsigned record_len, record_count; |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int rc; |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 rc = select_op(file_id); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 if (rc < 0) { |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 printf("%s not present\n", book_name); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 return(rc); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 } |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 rc = select_resp_get_linear_fixed(&record_len, &record_count); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 if (rc < 0) { |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 fprintf(stderr, "error occurred on SELECT of EF_%s\n", |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 book_name); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 return(rc); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 if (record_len < 14) { |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 fprintf(stderr, |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 "error: EF_%s has record length of %u bytes, less than minimum 14\n", |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 book_name, record_len); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 return(-1); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 printf("%s has %u entries, %u bytes of alpha tag\n", book_name, |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 record_count, record_len - 14); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 return(0); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 } |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 static |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 do_sms_store() |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 { |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 unsigned record_len, record_count; |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 int rc; |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 rc = select_op(EF_SMS); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 if (rc < 0) { |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 printf("EF_SMS not present\n"); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 return(rc); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 } |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 rc = select_resp_get_linear_fixed(&record_len, &record_count); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 if (rc < 0) { |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 fprintf(stderr, "error occurred on SELECT of EF_SMS\n"); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 return(rc); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 } |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 if (record_len != 176) { |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 fprintf(stderr, |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 "error: EF_SMS is not linear fixed with 176-byte records\n"); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 return(-1); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 } |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 printf("SMS store has %u entries\n", record_count); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 return(0); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 cmd_telecom_sum() |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 { |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 int rc; |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 |
141
0b8a936f4542
fc-uicc-tool: need to select MF before DF_TELECOM
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
68 rc = select_op(FILEID_MF); |
0b8a936f4542
fc-uicc-tool: need to select MF before DF_TELECOM
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
69 if (rc < 0) |
0b8a936f4542
fc-uicc-tool: need to select MF before DF_TELECOM
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
70 return(rc); |
135
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 rc = select_op(DF_TELECOM); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 if (rc < 0) |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 return(rc); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 do_phonebook_file(EF_ADN, "ADN"); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 do_phonebook_file(EF_FDN, "FDN"); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 do_phonebook_file(EF_SDN, "SDN"); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 do_phonebook_file(EF_MSISDN, "MSISDN"); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 do_sms_store(); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 return(0); |
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 } |