FreeCalypso > hg > freecalypso-hwlab
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/uicc/telsum.c Thu Feb 04 02:55:31 2021 +0000 @@ -0,0 +1,77 @@ +/* + * This module implements the telecom-sum (summary info) command. + */ + +#include <stdio.h> +#include <stdlib.h> +#include "file_id.h" + +static +do_phonebook_file(file_id, book_name) + unsigned file_id; + char *book_name; +{ + unsigned record_len, record_count; + int rc; + + rc = select_op(file_id); + if (rc < 0) { + printf("%s not present\n", book_name); + return(rc); + } + rc = select_resp_get_linear_fixed(&record_len, &record_count); + if (rc < 0) { + fprintf(stderr, "error occurred on SELECT of EF_%s\n", + book_name); + return(rc); + } + if (record_len < 14) { + fprintf(stderr, + "error: EF_%s has record length of %u bytes, less than minimum 14\n", + book_name, record_len); + return(-1); + } + printf("%s has %u entries, %u bytes of alpha tag\n", book_name, + record_count, record_len - 14); + return(0); +} + +static +do_sms_store() +{ + unsigned record_len, record_count; + int rc; + + rc = select_op(EF_SMS); + if (rc < 0) { + printf("EF_SMS not present\n"); + return(rc); + } + rc = select_resp_get_linear_fixed(&record_len, &record_count); + if (rc < 0) { + fprintf(stderr, "error occurred on SELECT of EF_SMS\n"); + return(rc); + } + if (record_len != 176) { + fprintf(stderr, + "error: EF_SMS is not linear fixed with 176-byte records\n"); + return(-1); + } + printf("SMS store has %u entries\n", record_count); + return(0); +} + +cmd_telecom_sum() +{ + int rc; + + rc = select_op(DF_TELECOM); + if (rc < 0) + return(rc); + do_phonebook_file(EF_ADN, "ADN"); + do_phonebook_file(EF_FDN, "FDN"); + do_phonebook_file(EF_SDN, "SDN"); + do_phonebook_file(EF_MSISDN, "MSISDN"); + do_sms_store(); + return(0); +}