FreeCalypso > hg > fc-pcsc-tools
comparison simtool/telsum.c @ 1:2071b28cd0c7
simtool: first refactored version
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 11 Feb 2021 23:04:28 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:f7145c77b7fb | 1:2071b28cd0c7 |
---|---|
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 "simresp.h" | |
9 #include "curfile.h" | |
10 #include "file_id.h" | |
11 | |
12 static | |
13 do_phonebook_file(file_id, book_name) | |
14 unsigned file_id; | |
15 char *book_name; | |
16 { | |
17 int rc; | |
18 | |
19 rc = select_op(file_id); | |
20 if (rc < 0) { | |
21 printf("%s not present\n", book_name); | |
22 return(rc); | |
23 } | |
24 rc = parse_ef_select_response(); | |
25 if (rc < 0) { | |
26 fprintf(stderr, "error occurred on SELECT of EF_%s\n", | |
27 book_name); | |
28 return(rc); | |
29 } | |
30 if (curfile_structure != 0x01) { | |
31 fprintf(stderr, "error: EF_%s is not linear fixed\n", | |
32 book_name); | |
33 return(-1); | |
34 } | |
35 if (curfile_record_len < 14) { | |
36 fprintf(stderr, | |
37 "error: EF_%s has record length of %u bytes, less than minimum 14\n", | |
38 book_name, curfile_record_len); | |
39 return(-1); | |
40 } | |
41 printf("%s has %u entries, %u bytes of alpha tag\n", book_name, | |
42 curfile_record_count, curfile_record_len - 14); | |
43 return(0); | |
44 } | |
45 | |
46 static | |
47 do_sms_store() | |
48 { | |
49 int rc; | |
50 | |
51 rc = select_op(EF_SMS); | |
52 if (rc < 0) { | |
53 printf("EF_SMS not present\n"); | |
54 return(rc); | |
55 } | |
56 rc = parse_ef_select_response(); | |
57 if (rc < 0) { | |
58 fprintf(stderr, "error occurred on SELECT of EF_SMS\n"); | |
59 return(rc); | |
60 } | |
61 if (curfile_structure != 0x01 || curfile_record_len != 176) { | |
62 fprintf(stderr, | |
63 "error: EF_SMS is not linear fixed with 176-byte records\n"); | |
64 return(-1); | |
65 } | |
66 printf("SMS store has %u entries\n", curfile_record_count); | |
67 return(0); | |
68 } | |
69 | |
70 cmd_telecom_sum() | |
71 { | |
72 int rc; | |
73 | |
74 rc = select_op(DF_TELECOM); | |
75 if (rc < 0) | |
76 return(rc); | |
77 do_phonebook_file(EF_ADN, "ADN"); | |
78 do_phonebook_file(EF_FDN, "FDN"); | |
79 do_phonebook_file(EF_SDN, "SDN"); | |
80 do_phonebook_file(EF_MSISDN, "MSISDN"); | |
81 do_sms_store(); | |
82 return(0); | |
83 } |