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