comparison uicc/telsum.c @ 135:51d6aaa43a7b

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