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