FreeCalypso > hg > freecalypso-hwlab
comparison uicc/pbcommon.c @ 136:a21d348e01db
fc-uicc-tool: pb-dump command ported over
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 04 Feb 2021 03:40:55 +0000 |
parents | |
children | 0b8a936f4542 |
comparison
equal
deleted
inserted
replaced
135:51d6aaa43a7b | 136:a21d348e01db |
---|---|
1 /* | |
2 * This module implements the common functions for all phonebook commands. | |
3 */ | |
4 | |
5 #include <string.h> | |
6 #include <strings.h> | |
7 #include <stdio.h> | |
8 #include <stdlib.h> | |
9 #include "file_id.h" | |
10 | |
11 static struct map { | |
12 char *user_name; | |
13 char *canon_name; | |
14 int file_id; | |
15 } phonebook_map[] = { | |
16 {"adn", "EF_ADN", EF_ADN}, | |
17 {"ADN", "EF_ADN", EF_ADN}, | |
18 {"EF_ADN", "EF_ADN", EF_ADN}, | |
19 {"fdn", "EF_FDN", EF_FDN}, | |
20 {"FDN", "EF_FDN", EF_FDN}, | |
21 {"EF_FDN", "EF_FDN", EF_FDN}, | |
22 {"sdn", "EF_SDN", EF_SDN}, | |
23 {"SDN", "EF_SDN", EF_SDN}, | |
24 {"EF_SDN", "EF_SDN", EF_SDN}, | |
25 {"msisdn", "EF_MSISDN", EF_MSISDN}, | |
26 {"MSISDN", "EF_MSISDN", EF_MSISDN}, | |
27 {"EF_MSISDN", "EF_MSISDN", EF_MSISDN}, | |
28 /* table search terminator */ | |
29 {0, 0, -1} | |
30 }; | |
31 | |
32 phonebook_op_common(reqname, rec_len_ret, rec_count_ret) | |
33 char *reqname; | |
34 unsigned *rec_len_ret, *rec_count_ret; | |
35 { | |
36 struct map *tp; | |
37 int rc; | |
38 | |
39 for (tp = phonebook_map; tp->user_name; tp++) | |
40 if (!strcmp(tp->user_name, reqname)) | |
41 break; | |
42 if (!tp->canon_name) { | |
43 fprintf(stderr, "error: phone book name \"%s\" not known\n", | |
44 reqname); | |
45 return(-1); | |
46 } | |
47 rc = select_op(DF_TELECOM); | |
48 if (rc < 0) | |
49 return(rc); | |
50 rc = select_op(tp->file_id); | |
51 if (rc < 0) | |
52 return(rc); | |
53 rc = select_resp_get_linear_fixed(rec_len_ret, rec_count_ret); | |
54 if (rc < 0) | |
55 return(rc); | |
56 if (rec_len_ret && *rec_len_ret < 14) { | |
57 fprintf(stderr, | |
58 "error: %s has record length of %u bytes, less than minimum 14\n", | |
59 tp->canon_name, *rec_len_ret); | |
60 return(-1); | |
61 } | |
62 return(0); | |
63 } |