comparison simtool/telsum.c @ 98:66c0cb0e9876

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