FreeCalypso > hg > fc-pcsc-tools
comparison simtool/usersum.c @ 117:b89bc690dec4
fc-simtool user-sum: support output redirection
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 19 Feb 2021 07:39:26 +0000 |
parents | 633033af6fb8 |
children |
comparison
equal
deleted
inserted
replaced
116:9c16cf1a79af | 117:b89bc690dec4 |
---|---|
49 bzero(sstbuf + rdlen, SST_BYTES_USED - rdlen); | 49 bzero(sstbuf + rdlen, SST_BYTES_USED - rdlen); |
50 return(0); | 50 return(0); |
51 } | 51 } |
52 | 52 |
53 static | 53 static |
54 do_phonebook_file(file_id, ef_name, book_name) | 54 do_phonebook_file(file_id, ef_name, book_name, outf) |
55 unsigned file_id; | 55 unsigned file_id; |
56 char *ef_name, *book_name; | 56 char *ef_name, *book_name; |
57 FILE *outf; | |
57 { | 58 { |
58 int rc; | 59 int rc; |
59 | 60 |
60 rc = select_op(file_id); | 61 rc = select_op(file_id); |
61 if (rc < 0) | 62 if (rc < 0) |
72 fprintf(stderr, | 73 fprintf(stderr, |
73 "error: %s has record length of %u bytes, less than minimum 14\n", | 74 "error: %s has record length of %u bytes, less than minimum 14\n", |
74 ef_name, curfile_record_len); | 75 ef_name, curfile_record_len); |
75 return(-1); | 76 return(-1); |
76 } | 77 } |
77 printf("%s: %u entries, %u bytes of alpha tag\n", book_name, | 78 fprintf(outf, "%s: %u entries, %u bytes of alpha tag\n", book_name, |
78 curfile_record_count, curfile_record_len - 14); | 79 curfile_record_count, curfile_record_len - 14); |
79 return(0); | 80 return(0); |
80 } | 81 } |
81 | 82 |
82 static | 83 static |
83 do_sms_store() | 84 do_sms_store(outf) |
85 FILE *outf; | |
84 { | 86 { |
85 int rc; | 87 int rc; |
86 | 88 |
87 rc = select_op(EF_SMS); | 89 rc = select_op(EF_SMS); |
88 if (rc < 0) | 90 if (rc < 0) |
93 if (curfile_structure != 0x01 || curfile_record_len != 176) { | 95 if (curfile_structure != 0x01 || curfile_record_len != 176) { |
94 fprintf(stderr, | 96 fprintf(stderr, |
95 "error: EF_SMS is not linear fixed with 176-byte records\n"); | 97 "error: EF_SMS is not linear fixed with 176-byte records\n"); |
96 return(-1); | 98 return(-1); |
97 } | 99 } |
98 printf("SMS store: %u entries\n", curfile_record_count); | 100 fprintf(outf, "SMS store: %u entries\n", curfile_record_count); |
99 return(0); | 101 return(0); |
100 } | 102 } |
101 | 103 |
102 static | 104 static |
103 do_smsp_store() | 105 do_smsp_store(outf) |
106 FILE *outf; | |
104 { | 107 { |
105 int rc; | 108 int rc; |
106 | 109 |
107 rc = select_op(EF_SMSP); | 110 rc = select_op(EF_SMSP); |
108 if (rc < 0) | 111 if (rc < 0) |
118 fprintf(stderr, | 121 fprintf(stderr, |
119 "error: EF_SMSP has record length of %u bytes, less than minimum 14\n", | 122 "error: EF_SMSP has record length of %u bytes, less than minimum 14\n", |
120 curfile_record_len); | 123 curfile_record_len); |
121 return(-1); | 124 return(-1); |
122 } | 125 } |
123 printf("SMS parameter store: %u entries, %u bytes of alpha tag\n", | 126 fprintf(outf, |
127 "SMS parameter store: %u entries, %u bytes of alpha tag\n", | |
124 curfile_record_count, curfile_record_len - 28); | 128 curfile_record_count, curfile_record_len - 28); |
125 return(0); | 129 return(0); |
126 } | 130 } |
127 | 131 |
128 cmd_user_sum() | 132 cmd_user_sum(argc, argv, outf) |
133 char **argv; | |
134 FILE *outf; | |
129 { | 135 { |
130 int rc; | 136 int rc; |
131 u_char sst[SST_BYTES_USED]; | 137 u_char sst[SST_BYTES_USED]; |
132 | 138 |
133 rc = read_sst(sst); | 139 rc = read_sst(sst); |
135 return(rc); | 141 return(rc); |
136 rc = select_op(DF_TELECOM); | 142 rc = select_op(DF_TELECOM); |
137 if (rc < 0) | 143 if (rc < 0) |
138 return(rc); | 144 return(rc); |
139 if ((sst[0] & 0x0C) == 0x0C) { | 145 if ((sst[0] & 0x0C) == 0x0C) { |
140 rc = do_phonebook_file(EF_ADN, "EF_ADN", "ADN phonebook"); | 146 rc = do_phonebook_file(EF_ADN, "EF_ADN", "ADN phonebook", outf); |
141 if (rc < 0) | 147 if (rc < 0) |
142 return(rc); | 148 return(rc); |
143 } | 149 } |
144 if ((sst[0] & 0x30) == 0x30) { | 150 if ((sst[0] & 0x30) == 0x30) { |
145 rc = do_phonebook_file(EF_FDN, "EF_FDN", "FDN phonebook"); | 151 rc = do_phonebook_file(EF_FDN, "EF_FDN", "FDN phonebook", outf); |
146 if (rc < 0) | 152 if (rc < 0) |
147 return(rc); | 153 return(rc); |
148 } | 154 } |
149 if ((sst[0] & 0xC0) == 0xC0) { | 155 if ((sst[0] & 0xC0) == 0xC0) { |
150 rc = do_sms_store(); | 156 rc = do_sms_store(outf); |
151 if (rc < 0) | 157 if (rc < 0) |
152 return(rc); | 158 return(rc); |
153 } | 159 } |
154 if ((sst[1] & 0x03) == 0x03) | 160 if ((sst[1] & 0x03) == 0x03) |
155 printf("AoC service present\n"); | 161 fprintf(outf, "AoC service present\n"); |
156 if ((sst[2] & 0x03) == 0x03) { | 162 if ((sst[2] & 0x03) == 0x03) { |
157 rc = do_phonebook_file(EF_MSISDN, "EF_MSISDN", "MSISDN record"); | 163 rc = do_phonebook_file(EF_MSISDN, "EF_MSISDN", "MSISDN record", |
164 outf); | |
158 if (rc < 0) | 165 if (rc < 0) |
159 return(rc); | 166 return(rc); |
160 } | 167 } |
161 if ((sst[2] & 0xC0) == 0xC0) { | 168 if ((sst[2] & 0xC0) == 0xC0) { |
162 rc = do_smsp_store(); | 169 rc = do_smsp_store(outf); |
163 if (rc < 0) | 170 if (rc < 0) |
164 return(rc); | 171 return(rc); |
165 } | 172 } |
166 if ((sst[3] & 0x03) == 0x03) { | 173 if ((sst[3] & 0x03) == 0x03) { |
167 rc = do_phonebook_file(EF_LND, "EF_LND", "LND cyclic store"); | 174 rc = do_phonebook_file(EF_LND, "EF_LND", "LND cyclic store", |
175 outf); | |
168 if (rc < 0) | 176 if (rc < 0) |
169 return(rc); | 177 return(rc); |
170 } | 178 } |
171 if ((sst[4] & 0x0C) == 0x0C) { | 179 if ((sst[4] & 0x0C) == 0x0C) { |
172 rc = do_phonebook_file(EF_SDN, "EF_SDN", "SDN phonebook"); | 180 rc = do_phonebook_file(EF_SDN, "EF_SDN", "SDN phonebook", outf); |
173 if (rc < 0) | 181 if (rc < 0) |
174 return(rc); | 182 return(rc); |
175 } | 183 } |
176 if ((sst[13] & 0x03) == 0x03) | 184 if ((sst[13] & 0x03) == 0x03) |
177 printf("MBDN present\n"); | 185 fprintf(outf, "MBDN present\n"); |
178 if ((sst[13] & 0x0C) == 0x0C) | 186 if ((sst[13] & 0x0C) == 0x0C) |
179 printf("MWIS present\n"); | 187 fprintf(outf, "MWIS present\n"); |
180 return(0); | 188 return(0); |
181 } | 189 } |