comparison src/g23m-aci/aci/aci_util.c @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : ACI_UTIL
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This module defines the utility functions for the AT
18 | command interpreter.
19 +-----------------------------------------------------------------------------
20 */
21
22
23
24 #ifndef ACI_UTIL_C
25 #define ACI_UTIL_C
26 #endif
27
28 #include "aci_all.h"
29
30 #include "aci_cmh.h"
31 #include "ati_cmd.h"
32
33 #include "aci_cmd.h"
34
35 #ifdef FAX_AND_DATA
36 #include "aci_fd.h"
37 #endif /* of #ifdef FAX_AND_DATA */
38
39 #include "psa.h"
40 #include "psa_sms.h"
41 #include "phb.h"
42 #include "cmh.h"
43 #include "cmh_sms.h"
44
45 #if defined (FF_ATI) || defined (FF_BAT)
46 #include "aci_mem.h"
47 #include "aci_lst.h"
48 #include "aci_io.h"
49 #include "ksd.h"
50 #include "cmh_ss.h"
51 #include "psa_ss.h"
52 #endif
53 #ifdef FF_ATI
54 #include "ati_int.h"
55 #endif
56 #ifdef FF_BAT
57 #include "aci_bat_cb.h"
58 #endif
59
60 #ifdef GPRS
61 #include "gaci_cmh.h"
62 #endif /* GPRS */
63
64 #ifdef TI_PS_OP_CNV_TAB_ROMBASED
65 #include "rom_tables.h"
66 #endif /* TI_PS_OP_CNV_TAB_ROMBASED */
67
68
69 #ifdef TI_PS_OP_CNV_TAB_ROMBASED
70 /* If this flag is enabled CSCS_CHSET_Chars is defined in rom_tables.h file */
71 #else
72 #define CSCS_CHSET_Chars 256
73 #endif
74
75 /*==== CONSTANTS ==================================================*/
76 #ifdef REL99
77 #define NUM_EXT_TABLE_CHARS 9
78 #define NUM_IRA_8859_TABLE_CHARS 1
79 #endif
80
81
82 /*==== TYPES ======================================================*/
83
84 /*==== EXPORT =====================================================*/
85 /* This fucntion cuts the pathname from the file
86 used by ACI_ASSERT makro*/
87 GLOBAL char * getFileName(char * file)
88 {
89 char *cursor = file;
90 do {
91 #ifdef _SIMULATION_
92 if(*cursor EQ '\\') { file = cursor+1;}
93 #else
94 if(*cursor EQ '/') { file = cursor+1;}
95 #endif
96 cursor++;
97 } while(*cursor NEQ '\0');
98 return file;
99 }
100
101
102 LOCAL USHORT utl_ucs2FromGsm ( UBYTE* in,
103 USHORT inLen,
104 UBYTE* out,
105 USHORT maxOutLen,
106 USHORT* outLen,
107 T_ACI_GSM_ALPHA gsm,
108 T_ACI_CSCS_ALPHA alphabet );
109
110 /*==== VARIABLES ==================================================*/
111 #ifdef TI_PS_OP_CNV_TAB_ROMBASED
112 /* Changes for ROM data */
113 /* NHK:
114 * Once the tables chset and gsmToAsciiTable go to ROM, their names below should match corresponding ROM addresses
115 * KSR: Moved to g23m\condat\com\src\drivers\rom_tables
116 */
117 #else
118 GLOBAL const UBYTE chset [CSCS_CHSET_Tables][CSCS_CHSET_Chars] =
119 {
120 /*
121 *-------------------------------------------------------------------
122 * Conversion table: IRA -> internal GSM
123 *-------------------------------------------------------------------
124 */
125 /* 0x00 */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
126 /* 0x08 */ 0x00, 0x00, 0x8A, 0x00, 0x00, 0x8D, 0x00, 0x00,
127 /* 0x10 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
128 /* 0x18 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
129 /* 0x20 */ 0xA0, 0xA1, 0xA2, 0xA3, 0x82, 0xA5, 0xA6, 0xA7,
130 /* 0x28 */ 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
131 /* 0x30 */ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
132 /* 0x38 */ 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
133 /* 0x40 */ 0x80, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
134 /* 0x48 */ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
135 /* 0x50 */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
136 /* 0x58 */ 0xD8, 0xD9, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x91/*00*/,
137 /* 0x60 */ 0x00, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
138 /* 0x68 */ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
139 /* 0x70 */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
140 /* 0x78 */ 0xF8, 0xF9, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00,
141 /* 0x80 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
142 /* 0x88 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
143 /* 0x90 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
144 /* 0x98 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
145 /* 0xA0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
146 /* 0xA8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
147 /* 0xB0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
148 /* 0xB8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
149 /* 0xC0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
150 /* 0xC8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
151 /* 0xD0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
152 /* 0xD8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
153 /* 0xE0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
154 /* 0xE8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
155 /* 0xF0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 /* 0xF8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
157
158 /*
159 *-------------------------------------------------------------------
160 * Conversion table: PC Danish/Norwegian -> internal GSM
161 *-------------------------------------------------------------------
162 */
163 /* 0x00 */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
164 /* 0x08 */ 0x00, 0x00, 0x8A, 0x00, 0x00, 0x8D, 0x00, 0x00,
165 /* 0x10 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0x00, 0x00,
166 /* 0x18 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
167 /* 0x20 */ 0xA0, 0xA1, 0xA2, 0xA3, 0x82, 0xA5, 0xA6, 0xA7,
168 /* 0x28 */ 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
169 /* 0x30 */ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
170 /* 0x38 */ 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
171 /* 0x40 */ 0x80, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
172 /* 0x48 */ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
173 /* 0x50 */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
174 /* 0x58 */ 0xD8, 0xD9, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x91/*00*/,
175 /* 0x60 */ 0x00, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
176 /* 0x68 */ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
177 /* 0x70 */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
178 /* 0x78 */ 0xF8, 0xF9, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00,
179 /* 0x80 */ 0x89, 0xFE, 0x85, 0xE1, 0xFB, 0xFF, 0x8F, 0x89,
180 /* 0x88 */ 0xE5, 0xE5, 0x84, 0xE9, 0xE9, 0x87, 0xDB, 0x8E,
181 /* 0x90 */ 0x9F/*C5*/, 0x9D, 0x9C, 0xEF, 0xFC, 0x88, 0xF5/*E5*/, 0x86,
182 /* 0x98 */ 0xF9/*E9*/, 0xDC, 0xDE, 0x8C, 0x81, 0x8B, 0x00, 0x00,
183 /* 0xA0 */ 0xE1, 0xE9, 0xEF, 0xF5, 0xFD, 0xDD, 0x00, 0x00,
184 /* 0xA8 */ 0xE0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00,
185 /* 0xB0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
186 /* 0xB8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
187 /* 0xC0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
188 /* 0xC8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
189 /* 0xD0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
190 /* 0xD8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
191 /* 0xE0 */ 0x00, 0x9E, 0x93, 0x00, 0x98, 0x00, 0x00, 0x00,
192 /* 0xE8 */ 0x92, 0x99, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00,
193 /* 0xF0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
194 /* 0xF8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
195
196 /*
197 *-------------------------------------------------------------------
198 * Conversion table: ISO 8859 Latin 1 -> internal GSM
199 *-------------------------------------------------------------------
200 */
201 /* 0x00 */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
202 /* 0x08 */ 0x00, 0x00, 0x8A, 0x00, 0x00, 0x8D, 0x00, 0x00,
203 /* 0x10 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
204 /* 0x18 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
205 /* 0x20 */ 0xA0, 0xA1, 0xA2, 0xA3, 0x82, 0xA5, 0xA6, 0xA7,
206 /* 0x28 */ 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
207 /* 0x30 */ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
208 /* 0x38 */ 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
209 /* 0x40 */ 0x80, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
210 /* 0x48 */ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
211 /* 0x50 */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
212 /* 0x58 */ 0xD8, 0xD9, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x91/*00*/,
213 /* 0x60 */ 0x00, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
214 /* 0x68 */ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
215 /* 0x70 */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
216 /* 0x78 */ 0xF8, 0xF9, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00,
217 /* 0x80 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
218 /* 0x88 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
219 /* 0x90 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
220 /* 0x98 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
221 /* 0xA0 */ 0x00, 0xC0, 0x00, 0x81, 0xA4, 0x83, 0x00, 0xDF,
222 /* 0xA8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
223 /* 0xB0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
224 /* 0xB8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0,
225 /* 0xC0 */ 0xC1, 0xC1, 0xC1, 0xC1, 0xDB, 0x8E, 0x9C, 0x89,
226 /* 0xC8 */ 0xC5, 0x9F/*C5*/, 0xC5, 0xC5, 0xC9, 0xC9, 0xC9, 0xC9,
227 /* 0xD0 */ 0x00, 0xDD, 0xCF, 0xCF, 0xCF, 0xCF, 0xDC, 0x00,
228 /* 0xD8 */ 0x8B, 0xD5, 0xD5, 0xD5, 0xDE, 0xD9, 0x00, 0x9E,
229 /* 0xE0 */ 0xFF, 0xE1, 0xE1, 0xE1, 0xFB, 0x8F, 0x9D, 0x89,
230 /* 0xE8 */ 0x84, 0x85, 0xE5, 0xE5, 0x87, 0xE9, 0xE9, 0xE9,
231 /* 0xF0 */ 0x00, 0xFD, 0x88, 0xEF, 0xEF, 0xEF, 0xFC, 0x00,
232 /* 0xF8 */ 0x8C, 0x86, 0xF5, 0xF5, 0xFE, 0xF9, 0x00, 0xF9 },
233
234 /*
235 *-------------------------------------------------------------------
236 * Conversion table: PC Code Page 437 -> internal GSM
237 *-------------------------------------------------------------------
238 */
239 /* 0x00 */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
240 /* 0x08 */ 0x00, 0x00, 0x8A, 0x00, 0x00, 0x8D, 0x00, 0x00,
241 /* 0x10 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0x00, 0x00,
242 /* 0x18 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
243 /* 0x20 */ 0xA0, 0xA1, 0xA2, 0xA3, 0x82, 0xA5, 0xA6, 0xA7,
244 /* 0x28 */ 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
245 /* 0x30 */ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
246 /* 0x38 */ 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
247 /* 0x40 */ 0x80, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
248 /* 0x48 */ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
249 /* 0x50 */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
250 /* 0x58 */ 0xD8, 0xD9, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x91/*00*/,
251 /* 0x60 */ 0x00, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
252 /* 0x68 */ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
253 /* 0x70 */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
254 /* 0x78 */ 0xF8, 0xF9, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00,
255 /* 0x80 */ 0x89, 0xFE, 0x85, 0xE1, 0xFB, 0xFF, 0x8F, 0x89,
256 /* 0x88 */ 0xE5, 0xE5, 0x84, 0xE9, 0xE9, 0x87, 0xDB, 0x8E,
257 /* 0x90 */ 0x9F/*C5*/, 0x9D, 0x9C, 0xEF, 0xFC, 0x88, 0xF5/*E5*/, 0x86,
258 /* 0x98 */ 0xF9/*E9*/, 0xDC, 0xDE, 0x00, 0x81, 0x83, 0x00, 0x00,
259 /* 0xA0 */ 0xE1, 0xE9, 0xEF, 0xF5, 0xFD, 0xDD, 0x00, 0x00,
260 /* 0xA8 */ 0xE0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00,
261 /* 0xB0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
262 /* 0xB8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
263 /* 0xC0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
264 /* 0xC8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
265 /* 0xD0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
266 /* 0xD8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
267 /* 0xE0 */ 0x00, 0x9E, 0x93, 0x00, 0x98, 0x00, 0x00, 0x00,
268 /* 0xE8 */ 0x92, 0x99, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00,
269 /* 0xF0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
270 /* 0xF8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
271
272 /*
273 *-------------------------------------------------------------------
274 * Conversion table: GSM -> internal GSM
275 *-------------------------------------------------------------------
276 */
277 /* 0x00 */ { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
278 /* 0x08 */ 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
279 /* 0x10 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
280 /* 0x18 */ 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
281 /* 0x20 */ 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
282 /* 0x28 */ 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
283 /* 0x30 */ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
284 /* 0x38 */ 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
285 /* 0x40 */ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
286 /* 0x48 */ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
287 /* 0x50 */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
288 /* 0x58 */ 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
289 /* 0x60 */ 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
290 /* 0x68 */ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
291 /* 0x70 */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
292 /* 0x78 */ 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
293 /* 0x80 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
294 /* 0x88 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
295 /* 0x90 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
296 /* 0x98 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
297 /* 0xA0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
298 /* 0xA8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
299 /* 0xB0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
300 /* 0xB8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
301 /* 0xC0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
302 /* 0xC8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
303 /* 0xD0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
304 /* 0xD8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
305 /* 0xE0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
306 /* 0xE8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
307 /* 0xF0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
308 /* 0xF8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
309 };
310
311
312 /*
313 *-------------------------------------------------------------------
314 * Conversion table: ASCII <-> internal GSM
315 * ( needed for the conversion of UCS2 <-> internal GSM )
316 *-------------------------------------------------------------------
317 */
318 /* GSM alphabet characters unknown in the ASCII table have been
319 replaced by <SP> characters */
320 LOCAL const UBYTE gsmToAsciiTable[128] =
321 {
322 /*n = 0 1 2 3 4 5 6 7 8 9 A B C D E F */
323 /* 0x0n */ 64,163, 36,165,232,233,249,236,242,199, 10,216,248, 13,197,229,
324 /* 0x1n */ 128, 95,129,130,131,132,133,134,135,136,137, 27,198,230,223,201,
325 /* 0x2n */ 32, 33, 34, 35,164, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
326 /* 0x3n */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
327 /* 0x4n */ 161, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
328 /* 0x5n */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,196,214,209,220,167,
329 /* 0x6n */ 191, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
330 /* 0x7n */ 112,113,114,115,116,117,118,119,120,121,122,228,246,241,252,224
331 };
332
333 LOCAL const UBYTE hexVal[] = {"0123456789ABCDEF"};
334
335 #endif
336
337 /*
338 * These tables are moved out of TI_PS_OP_CNV_TAB_ROMBASED
339 */
340
341 #ifdef REL99
342 /*
343 *-------------------------------------------------------------------
344 * Conversion table: Extension character table that can be used for
345 mapping IRA or PC D/N or ISO 8859 Latin 1 or PCCP 437
346 characters to GSM 7 extension table characters
347 * The first column contains the GSM 7 extension table character value and
348 * the second column contains the corresponding character in the other
349 * character sets
350 * Ref: 23.038 Sec 6.2.1.1
351 *-------------------------------------------------------------------
352 */
353 GLOBAL const UBYTE ext_common_chset_map [NUM_EXT_TABLE_CHARS][2] =
354 {
355 { 0x14, 0x5E }, /* ^ */
356 { 0x1B, 0x20 }, /* Reserved for another extension table. To be replaced by space */
357 { 0x28, 0x7B }, /* { */
358 { 0x29, 0x7D }, /* } */
359 { 0x2F, 0x5C }, /* \ */
360 { 0x3C, 0x5B }, /* [ */
361 { 0x3D, 0x7E }, /* ~ */
362 { 0x3E, 0x5D }, /* ] */
363 { 0x40, 0x7C } /* | */
364 };
365
366 /*
367 *-------------------------------------------------------------------
368 * Conversion table: Extension table character that is used only for
369 IRA OR ISO 8859 Latin 1, in addition to the character table given
370 above.
371 * Ref: 23.038 Sec 6.2.1.1
372 * The Euro character is treated separately as it there is no mapping
373 * character in PCCP 437 and PCDN.
374 *-------------------------------------------------------------------
375 */
376 GLOBAL const UBYTE ext_ira_8859_chset_map [NUM_IRA_8859_TABLE_CHARS][2] =
377 {
378 { 0x65, 0x80 } /* Euro symbol */
379 };
380 #endif
381
382
383 /*
384 static const unsigned char
385 gsm_2_ascii_table[128] =
386 {
387 0x40, 0x9C, 0x24, 0x9D, 0x8A, 0x82, 0x97, 0x8D, 0x95, 0x80, 0x0A, 0x02, 0x07, 0x0D, 0x8F, 0x86,
388 0x04, 0x5F, 0xE8, 0xE2, 0xEF, 0xEA, 0xE3, 0x05, 0xE6, 0xE9, 0xF0, 0x20, 0x92, 0x91, 0xE1, 0x90,
389 0x20, 0x21, 0x22, 0x23, 0x01, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
390 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
391 0xAD, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
392 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x8E, 0x99, 0xA5, 0x9A, 0x06,
393 0xA8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
394 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x84, 0x94, 0xA4, 0x81, 0x85
395 };
396 */
397
398 /*==== FUNCTIONS ==================================================*/
399 #ifdef FF_ATI
400 /*
401 +-------------------------------------------------------------------+
402 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
403 | STATE : code ROUTINE : strupper |
404 +-------------------------------------------------------------------+
405
406 PURPOSE : Converts all characters from 'a' to 'z' to capital
407 characters from 'A' to 'Z'.
408 */
409 GLOBAL char* strupper ( char* s )
410 {
411 USHORT i = 0;
412
413 while ( s NEQ 0 AND s[i] NEQ '\0')
414 {
415 if ( s[i] >= 0x61 AND s[i] <= 0x7a )
416
417 s[i] = s[i] - 0x20;
418
419 i++;
420 }
421
422 return s;
423 }
424 #endif
425
426 #ifdef FF_ATI
427 /*
428 +-------------------------------------------------------------------+
429 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
430 | STATE : code ROUTINE : utl_chsetToSim |
431 +-------------------------------------------------------------------+
432
433 PURPOSE : This function converts the characters of a string from
434 the character set used within the AT command interpreter
435 to the SIM GSM character set.
436 */
437 GLOBAL void utl_chsetToSim ( UBYTE* in,
438 USHORT inLen,
439 UBYTE* out,
440 USHORT* outLen,
441 T_ACI_GSM_ALPHA gsm )
442 {
443 UBYTE cvtdVal;
444 USHORT outIdx = 0;
445 USHORT inIdx;
446 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0xFF : 0x7F );
447 T_ACI_CSCS_CHSET cscsChset;
448 UBYTE srcId = srcId_cb;
449
450 cscsChset = ati_user_output_cfg[srcId].cscsChset;
451
452 if ( cscsChset EQ CSCS_CHSET_Hex )
453 {
454 utl_hexToGsm ( in, inLen, out, outLen, gsm, CSCS_ALPHA_8_Bit );
455 }
456 else if ( cscsChset EQ CSCS_CHSET_Ucs2 )
457 {
458 /* If the user chooses UCS2, then the best mode of coding should be
459 * used to store the characters in the SIM */
460 utl_ucs2ToSim(in, inLen, out, outLen, gsm, CSCS_ALPHA_8_Bit);
461 }
462 else
463 {
464 for ( inIdx = 0; inIdx < inLen; inIdx++ )
465 {
466 cvtdVal = chset[cscsChset][( UBYTE ) in[inIdx]];
467
468 if ( cvtdVal NEQ 0x00 )
469 {
470 out[outIdx] = ( CHAR ) cvtdVal & corr;
471 outIdx++;
472 }
473 }
474
475 if ( gsm EQ GSM_ALPHA_Int )
476 out[outIdx] = '\0';
477
478 *outLen = outIdx;
479 }
480 }
481 #endif
482
483 #ifdef FF_ATI
484 /*
485 +-------------------------------------------------------------------+
486 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
487 | STATE : code ROUTINE : utl_codeUcs2 |
488 +-------------------------------------------------------------------+
489
490 PURPOSE : This function finds optimal coding format to store the
491 UCS2 character string in the phone book.
492 */
493 GLOBAL void utl_ucs2ToSim( UBYTE* in,
494 USHORT inLen,
495 UBYTE* out,
496 USHORT* outLen,
497 T_ACI_GSM_ALPHA gsm,
498 T_ACI_CSCS_ALPHA alphabet)
499 {
500 int i;
501 BOOL flag = TRUE;
502 UBYTE hexOut[MAX_ALPHA_LEN * 4];
503 USHORT hexOutLen = 0;
504
505 /* Convert the hex character string to actual hex values */
506 hexOutLen = utl_HexStrToBin(in, inLen, hexOut, (MAX_ALPHA_LEN * 4));
507
508 /* Initial check is done for GSM or ASCII only characters */
509 for(i = 0; i < (hexOutLen/2); i++)
510 {
511 if(( hexOut[i*2] NEQ 0x00 ))
512 {
513 flag = FALSE;
514 break;
515 }
516 }
517 if (flag EQ TRUE)
518 {
519 utl_ConvUcs2ToGSM(hexOut, hexOutLen, out, outLen, gsm, alphabet);
520 if (*outLen)
521 return;
522 }
523
524 /* If possible UCS2 character string is coded in 0x81 format which
525 uses a one byte base pointer */
526 utl_Ucs2InFormat1 (hexOut, hexOutLen, out, outLen);
527 if (*outLen)
528 return;
529
530 /* If possible UCS2 character string is coded in 0x82 format which
531 uses two byte base pointer */
532 utl_Ucs2InFormat2 (hexOut, hexOutLen, out, outLen);
533 if (*outLen)
534 return;
535
536 /* If none of the above work, UCS2 character string is coded in 0x80 */
537 *out = 0x80;
538 utl_hexToGsm ( in, inLen, out + 1, outLen, gsm, CSCS_ALPHA_8_Bit );
539 (*outLen)++;
540 }
541 #endif
542
543 #ifdef FF_ATI
544 /*
545 +-------------------------------------------------------------------+
546 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
547 | STATE : code ROUTINE : utl_ConvUcs2ToGSM |
548 +-------------------------------------------------------------------+
549
550 PURPOSE : This function converts UCS2 charecter string consisting of
551 only ASCII charecters to default GSM values.
552 */
553 GLOBAL void utl_ConvUcs2ToGSM ( UBYTE* in,
554 USHORT inLen,
555 UBYTE* out,
556 USHORT* outLen,
557 T_ACI_GSM_ALPHA gsm,
558 T_ACI_CSCS_ALPHA alphabet )
559 {
560 int i, j;
561 BOOL flag;
562 UBYTE val = 0x00;
563 USHORT len;
564 UBYTE tmpOut;
565 USHORT outIdx = 0;
566 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0xFF : 0x7F );
567
568 len = inLen/2;
569 for (i = 0;i < len; i++)
570 {
571 tmpOut = in[(i*2) + 1];
572 /* convert the hexadecimal ASCII value to GSM, if the value is
573 * not convertible then we exit */
574 if ( tmpOut EQ ( gsmToAsciiTable[tmpOut])) /* ASCII and GSM are identical */
575 {
576 val = tmpOut;
577 }
578 else /* find match in the table and copy index of match */
579 {
580 flag = FALSE;
581 for (j=0; j<128; j++)
582 {
583 if (tmpOut EQ gsmToAsciiTable[j])
584 {
585 val = (UBYTE)j;
586 flag = TRUE;
587 break;
588 }
589 #ifdef REL99
590 else
591 {
592 /* There is a chance that this is in the mapping table */
593 UBYTE ext_tbl_idx = 0;
594 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
595 ext_common_chset_map[ext_tbl_idx][1] NEQ tmpOut )
596 {
597 ext_tbl_idx++;
598 }
599 if(ext_tbl_idx < NUM_EXT_TABLE_CHARS)
600 {
601 /*Insert the escape character, 0x1B, to output stream*/
602 out[outIdx++] = 0x1B |(corr &0x80);
603 /* Insert the mapping character into the output stream */
604 val = ( UBYTE )ext_common_chset_map[ext_tbl_idx][0] |(corr &0x80);
605 flag = TRUE;
606 break;
607 }
608 }
609 #endif /* REL99 */
610 }
611 if (!flag)
612 {
613 *outLen = 0;
614 return;
615 }
616 }
617
618 /* if necessary, cut the GSM value to 7bit */
619 if ( alphabet EQ CSCS_ALPHA_7_Bit AND !( val & 0x80 ) )
620 {
621 if ( gsm EQ GSM_ALPHA_Int )
622 {
623 out[outIdx++] = val | 0x80;
624 }
625 else
626 {
627 out[outIdx++] = val;
628 }
629 }
630 else
631 {
632 out[outIdx++] = val;
633 }
634 }
635
636 if ( gsm EQ GSM_ALPHA_Int )
637 {
638 out[outIdx] = '\0';
639 }
640
641 /* set the outlength */
642 *outLen = outIdx;
643 }
644 #endif
645
646 #ifdef FF_ATI
647 /*
648 +-------------------------------------------------------------------+
649 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
650 | STATE : code ROUTINE : utl_Ucs2InFormat1 |
651 +-------------------------------------------------------------------+
652
653 PURPOSE : This function converts the UCS2 character string in the
654 0x81 coding scheme for UCS2.
655 Octet 1: 0x81
656 Octet 2: Num of Characters
657 Octet 3: Bits 15 to 8 of Base pointer
658 Octet 4 onwards: Characters
659 */
660 GLOBAL void utl_Ucs2InFormat1( UBYTE* in,
661 USHORT inLen,
662 UBYTE* out,
663 USHORT* outLen)
664 {
665 int i, j;
666 UBYTE base_ptr = 0x00;
667 UBYTE temp_ptr;
668 USHORT len = inLen/2;
669 USHORT tmp_base;
670 USHORT tmp;
671 USHORT outIdx = 0;
672 UBYTE corr = 0x7F;
673
674
675 /* We first check if the UCS2 string can be coded
676 * using a single base pointer */
677 for (i = 0; i < len; i++)
678 {
679 if (in[i*2])
680 {
681 if ((in[i*2] & 0x80))
682 {
683 *outLen = 0;
684 return;
685 }
686 temp_ptr = in[i*2] & 0x7f;
687 temp_ptr <<= 1;
688 temp_ptr |= ((in[(i*2)+1] & 0x80) >> 7);
689
690 if (base_ptr)
691 {
692 if (temp_ptr NEQ base_ptr)
693 {
694 *outLen = 0;
695 return;
696 }
697 } else
698 {
699 base_ptr = temp_ptr;
700 }
701 }
702 }
703
704
705 /* Characters are coded using the base pointer below */
706 /* For details, see GSM 11.11 Annex B (normative) */
707 out[0] = 0x81;
708 if (len < PHB_MAX_TAG_LEN - 3)
709 {
710 out[1] = (UBYTE)len;
711 } else
712 {
713 out[1] = PHB_MAX_TAG_LEN - 3;
714 }
715 out[2] = base_ptr;
716 tmp_base = 0;
717 tmp_base = base_ptr << 7;
718 outIdx = 3;
719
720 len = out[1];
721 for (i = 0; i < len; i++)
722 {
723 if (in[i*2])
724 {
725 tmp = 0;
726 tmp = in[i*2] << 8;
727 tmp |= in[(i*2)+1];
728 out[outIdx++] = (tmp - tmp_base) | 0x80;
729 } else
730 {
731 for (j=0; j<128; j++)
732 {
733 if (in[(i*2)+1] EQ gsmToAsciiTable[j])
734 {
735 out[outIdx++] = (UBYTE)j;
736 break;
737 }
738 #ifdef REL99
739 else
740 {
741 /* There is a chance that this is in the mapping table */
742 UBYTE ext_tbl_idx = 0;
743 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
744 ext_common_chset_map[ext_tbl_idx][1] NEQ in[(i*2)+1] )
745 {
746 ext_tbl_idx++;
747 }
748 if(ext_tbl_idx < NUM_EXT_TABLE_CHARS)
749 {
750 /*Insert the escape character, 0x1B, to output stream*/
751 out[outIdx++] = 0x1B |(corr &0x80);
752 /* Insert the mapping character into the output stream */
753 out[outIdx++] = ( UBYTE )ext_common_chset_map[ext_tbl_idx][0] |(corr &0x80);
754 break;
755 }
756 }
757 #endif /* REL99 */
758 }
759 }
760 /* If the charecter cannot be found in ASCII table exit */
761 if (j EQ 128)
762 {
763 *outLen = 0;
764 return ;
765 }
766 }
767
768 #ifdef REL99
769 if (outIdx -3 > len)
770 {
771 if (outIdx >= PHB_MAX_TAG_LEN)
772 {
773 if (out[PHB_MAX_TAG_LEN - 1] EQ 0x1B)
774 {
775 outIdx = PHB_MAX_TAG_LEN - 1;
776 out[1] = PHB_MAX_TAG_LEN - 4;
777 }
778 else
779 {
780 outIdx = PHB_MAX_TAG_LEN;
781 out[1] = PHB_MAX_TAG_LEN - 3;
782 }
783 }
784 else
785 {
786 out[1] = outIdx -3;
787 }
788 }
789 #endif /* REL99 */
790
791 *outLen = outIdx;
792 }
793 #endif
794
795 #ifdef FF_ATI
796 /*
797 +-------------------------------------------------------------------+
798 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
799 | STATE : code ROUTINE : utl_Ucs2InFormat2 |
800 +-------------------------------------------------------------------+
801
802 PURPOSE : This function converts the UCS2 character string in the
803 0x82 coding scheme for UCS2.
804 Octet 1: 0x82
805 Octet 2: Number of characters
806 Octet 3 and Octet 4: 2 byte base pointer
807 Octet 5 onwards: Characters
808
809 */
810 GLOBAL void utl_Ucs2InFormat2( UBYTE* in,
811 USHORT inLen,
812 UBYTE* out,
813 USHORT* outLen)
814 {
815 int i, j;
816 USHORT len = inLen/2;
817 USHORT lowest_ch = 0;
818 USHORT highest_ch = 0;
819 USHORT tmp;
820 USHORT outIdx = 0;
821 UBYTE corr = 0x7F;
822
823 /* We first check if the UCS2 string can be coded
824 * using a smallest char as the base pointer */
825 for (i = 0; i < len; i++)
826 {
827 if (in[i*2])
828 {
829 tmp = 0;
830 tmp = in[i*2] << 8;
831 tmp |= in[(i*2)+1];
832
833 if (lowest_ch EQ 0 OR tmp < lowest_ch)
834 lowest_ch = tmp;
835
836 if (tmp > highest_ch)
837 highest_ch = tmp;
838 }
839 }
840
841 /* To use lowest char can be used as the base pointer, the distance
842 * between the lowest and highest char must not be more then 128 */
843 /* correct here: must not equal or more then 128. the max offset will be less then 0x80 = 128 */
844 //TI-SH-TEST-PATCH for CSR OMAPS00168884
845 if ((highest_ch - lowest_ch) >= 0x80)
846 {
847 *outLen = 0;
848 return;
849 }
850
851 /* Characters are coded using the base pointer below */
852 /* For details, see GSM 11.11 Annex B (normative) */
853 out[0] = 0x82;
854 if (len < PHB_MAX_TAG_LEN - 4)
855 {
856 out[1] = (UBYTE)len;
857 } else
858 {
859 out[1] = PHB_MAX_TAG_LEN - 4;
860 }
861 out[2] = (lowest_ch & 0xff00) >> 8;
862 out[3] = (lowest_ch & 0x00ff);
863 outIdx = 4;
864
865 len = out[1];
866 for (i = 0; i < len; i++)
867 {
868 if (in[i*2])
869 {
870 tmp = 0;
871 tmp = in[i*2] << 8;
872 tmp |= in[(i*2)+1];
873 out[outIdx++] = (tmp - lowest_ch) | 0x80;
874 } else
875 {
876 for (j=0; j<128; j++)
877 {
878 if (in[(i*2)+1] EQ gsmToAsciiTable[j])
879 {
880 out[outIdx++] = (UBYTE)j;
881 break;
882 }
883 #ifdef REL99
884 else
885 {
886 /* There is a chance that this is in the mapping table */
887 UBYTE ext_tbl_idx = 0;
888 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
889 ext_common_chset_map[ext_tbl_idx][1] NEQ in[(i*2)+1] )
890 {
891 ext_tbl_idx++;
892 }
893 if(ext_tbl_idx < NUM_EXT_TABLE_CHARS)
894 {
895 /*Insert the escape character, 0x1B, to output stream*/
896 out[outIdx++] = 0x1B |(corr &0x80);
897 /* Insert the mapping character into the output stream */
898 out[outIdx++] = ( UBYTE )ext_common_chset_map[ext_tbl_idx][0] |(corr &0x80);
899 break;
900 }
901 }
902 #endif /* REL99 */
903 }
904
905 /* If the charecter cannot be found in ASCII table exit */
906 if (j EQ 128)
907 {
908 *outLen = 0;
909 return ;
910 }
911 }
912 }
913
914 #ifdef REL99
915 if (outIdx -4 > len)
916 {
917 if (outIdx >= PHB_MAX_TAG_LEN)
918 {
919 if (out[PHB_MAX_TAG_LEN - 1] EQ 0x1B)
920 {
921 outIdx = PHB_MAX_TAG_LEN - 1;
922 out[1] = PHB_MAX_TAG_LEN - 5;
923 }
924 else
925 {
926 outIdx = PHB_MAX_TAG_LEN;
927 out[1] = PHB_MAX_TAG_LEN - 4;
928 }
929 }
930 else
931 {
932 out[1] = outIdx -4;
933 }
934 }
935 #endif /* REL99 */
936
937 *outLen = outIdx;
938 }
939 #endif
940
941 #ifdef FF_ATI
942
943 /*
944 +-------------------------------------------------------------------+
945 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
946 | STATE : code ROUTINE : utl_chsetToGsm |
947 +-------------------------------------------------------------------+
948
949 PURPOSE : This function converts the characters of a string from
950 the character set used within the AT command interpreter
951 to the ACI internal GSM character set. The outBufLen was added
952 so that buffer overflow is kept in check when replacing one
953 non-GSM character with two characters - an escape character 0x1B
954 and a character from the extension table.
955 */
956 GLOBAL void utl_chsetToGsm ( UBYTE* in,
957 USHORT inLen,
958 UBYTE* out,
959 USHORT* outLen,
960 #ifdef REL99
961 USHORT outBufLen,
962 #endif
963 T_ACI_GSM_ALPHA gsm )
964 {
965 UBYTE cvtdVal;
966 USHORT outIdx = 0;
967 USHORT inIdx;
968 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0xFF : 0x7F );
969 T_ACI_CSCS_CHSET cscsChset;
970 UBYTE srcId = srcId_cb;
971
972 cscsChset = ati_user_output_cfg[srcId].cscsChset;
973
974 if ( ati_user_output_cfg[srcId].cscsChset EQ CSCS_CHSET_Hex )
975 {
976 utl_hexToGsm ( in, inLen, out, outLen, gsm, CSCS_ALPHA_8_Bit );
977 }
978 else if ( cscsChset EQ CSCS_CHSET_Ucs2 )
979 {
980 utl_ucs2ToGsm ( in, inLen, out, outLen, gsm, CSCS_ALPHA_8_Bit );
981 }
982 else
983 {
984 #ifndef REL99
985 for ( inIdx = 0; inIdx < inLen; inIdx++ )
986 {
987 cvtdVal = chset[cscsChset][( UBYTE ) in[inIdx]];
988 if ( cvtdVal NEQ 0x00 )
989 {
990 out[outIdx] = ( CHAR ) cvtdVal & corr;
991 outIdx++;
992 }
993 }
994 #else
995 for ( inIdx = 0; inIdx < inLen AND outIdx < outBufLen; inIdx++ )
996 {
997 cvtdVal = chset[cscsChset][( UBYTE ) in[inIdx]];
998
999 if ( cvtdVal NEQ 0x00 )
1000 {
1001 out[outIdx] = ( CHAR ) cvtdVal & corr;
1002 outIdx++;
1003 }
1004 else
1005 {
1006 /* There is a chance that this is in the mapping table */
1007 UBYTE ext_tbl_idx = 0;
1008 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
1009 ext_common_chset_map[ext_tbl_idx][1] NEQ in[inIdx] )
1010 {
1011 ext_tbl_idx++;
1012 }
1013 if(ext_tbl_idx < NUM_EXT_TABLE_CHARS)
1014 {
1015 /*Insert the escape character, 0x1B, to output stream*/
1016 out[outIdx++] = 0x1B |(corr &0x80);
1017 /* Check that output buffer limit has not been reached */
1018 if(outIdx < outBufLen)
1019 {
1020 /* Insert the mapping character into the output stream */
1021 out[outIdx++] = ( UBYTE )ext_common_chset_map[ext_tbl_idx][0] |(corr &0x80);
1022 }
1023 }
1024 else if ( ( cscsChset EQ CSCS_CHSET_Ira ) OR ( cscsChset EQ CSCS_CHSET_8859_1 ) )
1025 {
1026 /* Check if the character is present in ext_ira_8859_chset_map */
1027 ext_tbl_idx = 0;
1028
1029 while( ext_tbl_idx < NUM_IRA_8859_TABLE_CHARS AND
1030 ext_ira_8859_chset_map[ext_tbl_idx][1] NEQ in[inIdx] )
1031 {
1032 ext_tbl_idx++;
1033 }
1034
1035 if( ext_tbl_idx < NUM_IRA_8859_TABLE_CHARS )
1036 {
1037 /*Insert the escape character, 0x1B, to output stream*/
1038 out[outIdx++] = 0x1B |(corr &0x80);
1039 /* Check that output buffer limit has not been reached */
1040 if(outIdx < outBufLen)
1041 {
1042 /* Insert the mapping character into the output stream */
1043 out[outIdx++] = ( UBYTE )ext_ira_8859_chset_map[ext_tbl_idx][0] |(corr &0x80);
1044 }
1045 }
1046 }
1047 }
1048 }
1049 #endif /* ifndef REL99 */
1050
1051 if ( gsm EQ GSM_ALPHA_Int )
1052 out[outIdx] = '\0';
1053
1054 *outLen = outIdx;
1055 }
1056 }
1057 #endif
1058
1059
1060 #ifdef FF_ATI
1061 /*
1062 +-------------------------------------------------------------------+
1063 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1064 | STATE : code ROUTINE : utl_hexFromAlpha |
1065 +-------------------------------------------------------------------+
1066
1067 PURPOSE : This function converts the characters of a string from
1068 the SIM with UCS2 form 0x81 or 0x82 to 16 Bit hex values.
1069 see GSM 11.11 Annex B Coding of Alpha fields in the SIM for UCS2
1070 UCS2 form 0x81:
1071 - octet 1 = 0x81
1072 - octet 2 = length
1073 - octet 3 = Bits 15 to 8 of the base pointer to a half page in the UCS2 code space
1074 0hhh hhhh h000 0000 , with h = bits of the half page base pointer
1075 16... .... .... ...1
1076
1077 UCS2 form 0x82:
1078 - octet 1 = 0x81
1079 - octet 2 = length
1080 - octet 3 = upper 8 Bit of 16 Bit base pointer to a half page in the UCS2 code space
1081 - octet 4 = lower 8 Bit of 16 Bit base pointer to a half page in the UCS2 code space
1082 */
1083 GLOBAL void utl_hexFromUCS2 ( UBYTE *in,
1084 UBYTE *out,
1085 USHORT maxOutlen,
1086 USHORT *outlen,
1087 T_ACI_GSM_ALPHA gsm)
1088 {
1089 USHORT outIdx = 0;
1090 USHORT base_pointer;
1091 USHORT length = in[1];
1092 USHORT tmp;
1093 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0x00 : 0x80 );
1094
1095 if (*in EQ 0x81)
1096 {
1097 base_pointer = in[2] << 7;
1098 in += 3;
1099 }
1100 else /* if (*in EQ 0x82) */
1101 {
1102 base_pointer = in[2]<<8 | in[3];
1103 in += 4;
1104 }
1105
1106 while ( length-- AND outIdx < maxOutlen-2)
1107 {
1108 if (*in & 0x80)
1109 {
1110 tmp = base_pointer + (*in & 0x7F);
1111 }
1112 else if((*in | corr) NEQ 0x9B)
1113 {
1114 tmp = 0x0000 + gsmToAsciiTable[*in];
1115 }
1116 #ifdef REL99
1117 else
1118 {
1119 UBYTE ext_tbl_idx = 0;
1120 BOOL mapping_char_found = FALSE;
1121 in++;
1122
1123 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
1124 ext_common_chset_map[ext_tbl_idx][0] NEQ (*in & 0x7F))
1125 {
1126 ext_tbl_idx++;
1127 }
1128 if( ext_tbl_idx < NUM_EXT_TABLE_CHARS )
1129 {
1130 /* Insert the mapping character into the output stream */
1131 tmp = 0x0000 + ( UBYTE )ext_common_chset_map[ext_tbl_idx][1];
1132 }
1133 }
1134 #endif
1135 out[outIdx++] = hexVal[(tmp >> 12) & 0x0F ];
1136 out[outIdx++] = hexVal[(tmp >> 8) & 0x0F ];
1137 out[outIdx++] = hexVal[(tmp >> 4) & 0x0F ];
1138 out[outIdx++] = hexVal[(tmp ) & 0x0F ];
1139
1140 in++;
1141 }
1142
1143 out[outIdx] = '\0';
1144 *outlen = outIdx;
1145 }
1146 #endif
1147
1148
1149 #ifdef FF_ATI
1150 /*
1151 +-------------------------------------------------------------------+
1152 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1153 | STATE : code ROUTINE : utl_chsetFromSim |
1154 +-------------------------------------------------------------------+
1155
1156 PURPOSE : This function converts the characters of a string from
1157 the SIM format to the character set
1158 used within the AT command interpreter.
1159 */
1160 GLOBAL void utl_chsetFromSim ( UBYTE* in,
1161 USHORT inLen,
1162 UBYTE* out,
1163 USHORT maxOutLen,
1164 USHORT* outLen,
1165 T_ACI_GSM_ALPHA gsm )
1166 {
1167 T_ACI_CSCS_CHSET cscsChset;
1168 UBYTE srcId = srcId_cb;
1169
1170 cscsChset = ati_user_output_cfg[srcId].cscsChset;
1171
1172 if ( cscsChset EQ CSCS_CHSET_Ucs2 AND
1173 (( *in EQ 0x80 ) OR ( *in EQ 0x81 ) OR ( *in EQ 0x82 )) )
1174 {
1175 /* UCS2 with form 0x81 or 0x82 as HEX string */
1176 if (( *in EQ 0x81 ) OR ( *in EQ 0x82 ))
1177 {
1178 utl_hexFromUCS2 ( in, out, maxOutLen, outLen, gsm);
1179 return;
1180 }
1181
1182 /* UCS2 form 0x80 as HEX string */
1183 utl_hexFromGsm ( in + 1, (USHORT)( inLen - 1 ), out, maxOutLen, outLen,
1184 gsm, CSCS_ALPHA_8_Bit );
1185 }
1186 else
1187 {
1188 utl_chsetFromGsm ( in, inLen, out, maxOutLen, outLen, gsm );
1189 }
1190 }
1191 #endif /* #ifdef FF_ATI */
1192
1193 #if defined(FF_ATI) || defined(FF_BAT)
1194 #ifdef TI_PS_OP_CNV_TAB_ROMBASED
1195 #endif
1196
1197 /*
1198 +-------------------------------------------------------------------+
1199 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1200 | STATE : code ROUTINE : utl_chsetFromGsm |
1201 +-------------------------------------------------------------------+
1202
1203 PURPOSE : This function converts the characters of a string from
1204 the ACI internal GSM character set to the character set
1205 used within the AT command interpreter.
1206 */
1207
1208 GLOBAL USHORT utl_chsetFromGsm(
1209 UBYTE* in,
1210 USHORT inLen,
1211 UBYTE* out,
1212 USHORT maxOutLen,
1213 USHORT* outLen,
1214 T_ACI_GSM_ALPHA gsm)
1215 {
1216 USHORT outIdx = 0;
1217 USHORT inIdx = 0;
1218 USHORT actLen = ( gsm EQ GSM_ALPHA_Int ?
1219 ( USHORT ) strlen ( ( CHAR* ) in ) : inLen );
1220 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0x00 : 0x80 );
1221 T_ACI_CSCS_CHSET cscsChset;
1222 UBYTE srcId = srcId_cb;
1223 USHORT tblIdx;
1224
1225 cscsChset = ati_user_output_cfg[srcId].cscsChset;
1226
1227 if ( cscsChset EQ CSCS_CHSET_Hex )
1228 {
1229 return utl_hexFromGsm ( in, inLen, out, maxOutLen, outLen, gsm, CSCS_ALPHA_8_Bit );
1230 }
1231 else if ( cscsChset EQ CSCS_CHSET_Ucs2 )
1232 {
1233 return utl_ucs2FromGsm ( in, inLen, out, maxOutLen, outLen, gsm, CSCS_ALPHA_8_Bit );
1234 }
1235 else
1236 {
1237 #ifndef REL99
1238
1239 while ( inIdx < actLen AND outIdx < maxOutLen - 1 )
1240 {
1241 tblIdx = 0;
1242
1243
1244 while ( tblIdx <= 0xFF AND
1245 chset[cscsChset][tblIdx] NEQ (( UBYTE )in[inIdx] | corr ))
1246 tblIdx++;
1247 if ( tblIdx <= 0xFF )
1248 {
1249 out[outIdx] = ( UBYTE )tblIdx;
1250 outIdx++;
1251 }
1252
1253 inIdx++;
1254 }
1255
1256 #else
1257 /* TODO: What if the CSCS is GSM7 itself. Do we have to do this? The following check
1258 if( cscsChset NEQ CSCS_CHSET_Gsm AND gsm EQ GSM_ALPHA_Def */
1259 while ( inIdx < actLen AND outIdx < maxOutLen - 1 )
1260 {
1261 /* Check if the character is a escape to an extension of the GSM 7 bit
1262 * default alphabet table. */
1263 if( cscsChset NEQ CSCS_CHSET_Gsm AND ((in[inIdx] | corr) EQ 0x9B) )
1264 {
1265 UBYTE ext_tbl_idx = 0;
1266 BOOL mapping_char_found = FALSE;
1267 inIdx++;
1268
1269 /* Check if the end of the array is reached */
1270 if(inIdx EQ actLen)
1271 {
1272 break;
1273 }
1274
1275 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
1276 ext_common_chset_map[ext_tbl_idx][0] NEQ (in[inIdx] & 0x7F))
1277 {
1278 ext_tbl_idx++;
1279 }
1280 if( ext_tbl_idx < NUM_EXT_TABLE_CHARS )
1281 {
1282 /* Insert the mapping character into the output stream */
1283 out[outIdx++] = ( UBYTE )ext_common_chset_map[ext_tbl_idx][1];
1284 mapping_char_found = TRUE;
1285 }
1286 else if( cscsChset EQ CSCS_CHSET_Ira OR cscsChset EQ CSCS_CHSET_8859_1 )
1287 {
1288 ext_tbl_idx = 0;
1289
1290 while( ext_tbl_idx < NUM_IRA_8859_TABLE_CHARS AND
1291 ext_ira_8859_chset_map[ext_tbl_idx][0] NEQ (in[inIdx]&0x7F))
1292 {
1293 ext_tbl_idx++;
1294 }
1295
1296 if(ext_tbl_idx < NUM_IRA_8859_TABLE_CHARS)
1297 {
1298 /* Insert the mapping character into the output stream */
1299 out[outIdx++] = ( UBYTE )ext_ira_8859_chset_map[ext_tbl_idx][1];
1300 mapping_char_found = TRUE;
1301 }
1302 }
1303
1304 if(mapping_char_found EQ FALSE)
1305 {
1306 /* From 23.038: In the event that an MS receives a code where a symbol
1307 is not represented in the extension table then the MS shall display
1308 the character shown in the main GSM 7 bit default alphabet table */
1309 tblIdx = 0;
1310 while ( tblIdx <= 0xFF AND
1311 chset[cscsChset][tblIdx] NEQ (( UBYTE )in[inIdx] | corr ))
1312 tblIdx++;
1313
1314 if ( tblIdx <= 0xFF )
1315 {
1316 out[outIdx] = ( UBYTE )tblIdx;
1317 outIdx++;
1318 }
1319
1320 }
1321 }
1322 else
1323 {
1324 tblIdx = 0;
1325
1326 while ( tblIdx <= 0xFF AND
1327 chset[cscsChset][tblIdx] NEQ (( UBYTE )in[inIdx] | corr ))
1328 tblIdx++;
1329
1330 if ( tblIdx <= 0xFF )
1331 {
1332 out[outIdx] = ( UBYTE )tblIdx;
1333 outIdx++;
1334 }
1335
1336 }
1337
1338 inIdx++;
1339 }
1340 #endif
1341
1342 out[outIdx] = '\0';
1343 *outLen = outIdx;
1344
1345 return inIdx;
1346 }
1347 }
1348 #endif
1349
1350
1351 #ifdef FF_ATI
1352 /*
1353 +-------------------------------------------------------------------+
1354 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1355 | STATE : code ROUTINE : utl_sprints |
1356 +-------------------------------------------------------------------+
1357
1358 PURPOSE : This function writes a not null terminated string to a
1359 buffer.
1360 */
1361 GLOBAL USHORT sprints ( CHAR* buf, CHAR* arg, USHORT len )
1362 {
1363 buf[0] = '\"';
1364
1365 memcpy ( &buf[1], arg, len );
1366
1367 buf[len + 1] = '\"';
1368 buf[len + 2] = '\0';
1369
1370 return (len + 2);
1371 }
1372 #endif
1373
1374 #ifdef FF_ATI
1375 /*
1376 +-------------------------------------------------------------------+
1377 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1378 | STATE : code ROUTINE : utl_sprintq |
1379 +-------------------------------------------------------------------+
1380
1381 PURPOSE : This function writes a not null terminated string to a
1382 buffer.
1383 */
1384 GLOBAL USHORT sprintq ( CHAR* buf, CHAR* arg, USHORT len )
1385 {
1386 memcpy ( &buf[0], arg, len );
1387
1388 buf[len] = '\0';
1389
1390 return (len);
1391 }
1392 #endif
1393
1394 #ifdef FF_ATI
1395 /*
1396 +-------------------------------------------------------------------+
1397 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1398 | STATE : code ROUTINE : utl_hexToIntGsm |
1399 +-------------------------------------------------------------------+
1400
1401 PURPOSE : This function converts the characters of a string from
1402 the "HEX" character set to the ACI internal GSM
1403 character set.
1404 */
1405 GLOBAL void utl_hexToGsm ( UBYTE* in,
1406 USHORT inLen,
1407 UBYTE* out,
1408 USHORT* outLen,
1409 T_ACI_GSM_ALPHA gsm,
1410 T_ACI_CSCS_ALPHA alphabet )
1411 {
1412 SHORT val = 0;
1413 UBYTE digit;
1414 USHORT inIdx = 0;
1415 USHORT outIdx = 0;
1416 SHORT base = 0x10;
1417
1418 while ( inIdx < inLen )
1419 {
1420 if ( in[inIdx] >= 0x30 AND in[inIdx] <= 0x39 ) /* '0' ... '9' */
1421 {
1422 digit = in[inIdx] - 0x30; /* ->0 ... 9 */
1423 }
1424 else if ( in[inIdx] >= 0x61 AND in[inIdx] <= 0x66 ) /* 'a' ... 'f' */
1425 {
1426 digit = in[inIdx] - 0x61 + 0x0A; /* ->0x0a...0x0f */
1427 }
1428 else if ( in[inIdx] >= 0x41 AND in[inIdx] <= 0x46 ) /* 'A' ... 'F' */
1429 {
1430 digit = in[inIdx] - 0x41 + 0x0A; /* ->0x0a...0x0f */
1431 }
1432 else
1433 {
1434 digit = 0xFF;
1435 }
1436
1437 if ( digit NEQ 0xFF ) /* skip invalid digit */
1438 {
1439 if ( base EQ 0x10 )
1440 {
1441 val = digit << 4;
1442 }
1443 else
1444 {
1445 val |= digit;
1446
1447 if ( alphabet EQ CSCS_ALPHA_7_Bit AND !( val & 0x80 ) )
1448 {
1449 if ( gsm EQ GSM_ALPHA_Int )
1450 {
1451 out[outIdx++] = ( CHAR ) val | 0x80;
1452 }
1453 else
1454 {
1455 out[outIdx++] = ( CHAR ) val;
1456 }
1457 }
1458 else if ( alphabet NEQ CSCS_ALPHA_7_Bit )
1459 {
1460 out[outIdx++] = ( CHAR ) val;
1461 }
1462 }
1463
1464 base ^= 0x10;
1465 }
1466
1467 inIdx++;
1468 }
1469
1470 if ( gsm EQ GSM_ALPHA_Int )
1471 out[outIdx] = '\0';
1472
1473 *outLen = outIdx;
1474 }
1475 #endif
1476
1477 #ifdef FF_ATI
1478 /*
1479 +-------------------------------------------------------------------+
1480 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1481 | STATE : code ROUTINE : utl_ucs2ToGsm |
1482 +-------------------------------------------------------------------+
1483
1484 PURPOSE : This function converts the characters of a string from
1485 the "UCS2" character set to the ACI internal GSM
1486 character set.
1487 */
1488 GLOBAL void utl_ucs2ToGsm ( UBYTE* in,
1489 USHORT inLen,
1490 UBYTE* out,
1491 USHORT* outLen,
1492 T_ACI_GSM_ALPHA gsm,
1493 T_ACI_CSCS_ALPHA alphabet )
1494 {
1495 int i, j;
1496 UBYTE val;
1497 USHORT len;
1498 UBYTE tmpIn[2]; /* store temporary two chars (HEX conversion) */
1499 UBYTE tmpInIdx; /* holds a temporary index for two chars (HEX conversion)*/
1500 UBYTE digit; /* holds a digit (HEX conversion) */
1501 SHORT tmpVal; /* hold a temporary value (HEX conversion) */
1502 UBYTE tmpOut; /* the HEX output (HEX conversion) */
1503 SHORT base = 0x10;
1504 USHORT outIdx = 0;
1505 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0xFF : 0x7F );
1506
1507 /* TRACE_FUNCTION(" utl_ucs2ToGsm() "); */
1508
1509 len = inLen/4;
1510
1511 for (i=0;i<len;i++)
1512 {
1513 /* check if this is a UCS2 character in 00xy format */
1514 if ( ( in[i*4] EQ '0' ) AND ( in[i*4+1] EQ '0' ) )
1515 {
1516 /* convert the next two character to HEX */
1517 tmpIn[0] = in[i*4+2];
1518 tmpIn[1] = in[i*4+3];
1519
1520 tmpVal = tmpOut = val = 0;
1521
1522 /* convert the two characters into the real hexadecimal ASCII value */
1523 for( tmpInIdx=0; tmpInIdx<2; tmpInIdx++ )
1524 {
1525 if ( tmpIn[tmpInIdx] >= '0' AND tmpIn[tmpInIdx] <= '9' )
1526 {
1527 digit = tmpIn[tmpInIdx] - '0';
1528 }
1529 else if ( tmpIn[tmpInIdx] >= 'a' AND tmpIn[tmpInIdx] <= 'f' )
1530 {
1531 digit = tmpIn[tmpInIdx] - 'a' + 0x0A;
1532 }
1533 else if ( tmpIn[tmpInIdx] >= 'A' AND tmpIn[tmpInIdx] <= 'F' )
1534 {
1535 digit = tmpIn[tmpInIdx] - 'A' + 0x0A;
1536 }
1537 else
1538 {
1539 digit = 0xFF;
1540 }
1541
1542 if ( digit NEQ 0xFF )
1543 {
1544 if ( base EQ 0x10 )
1545 {
1546 tmpVal = digit * 0x10;
1547 }
1548 else
1549 {
1550 tmpVal += digit;
1551 tmpOut = (UBYTE) tmpVal;
1552 }
1553
1554 base ^= 0x10;
1555 }
1556 }
1557
1558 /* convert the hexadecimal ASCII value to GSM */
1559 if (!(tmpOut & 0x80))
1560 {
1561 if ( tmpOut EQ ( gsmToAsciiTable[tmpOut])) /* ASCII and GSM are identical */
1562 {
1563 val = tmpOut;
1564 }
1565 else /* find match in the table and copy index of match */
1566 {
1567 for (j=0; j<128; j++)
1568 {
1569 if (tmpOut EQ gsmToAsciiTable[j])
1570 {
1571 val = (UBYTE)j;
1572 break;
1573 }
1574 #ifdef REL99
1575 else
1576 {
1577 /* There is a chance that this is in the mapping table */
1578 UBYTE ext_tbl_idx = 0;
1579 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
1580 ext_common_chset_map[ext_tbl_idx][1] NEQ tmpOut )
1581 {
1582 ext_tbl_idx++;
1583 }
1584 if(ext_tbl_idx < NUM_EXT_TABLE_CHARS)
1585 {
1586 /*Insert the escape character, 0x1B, to output stream*/
1587 out[outIdx++] = 0x1B |(corr &0x80);
1588 /* Insert the mapping character into the output stream */
1589 val = ( UBYTE )ext_common_chset_map[ext_tbl_idx][0] |(corr &0x80);
1590 break;
1591 }
1592 }
1593 #endif /* REL99 */
1594 }
1595 }
1596 }
1597 else /* find match in the table and copy index of match */
1598 {
1599 for (j=0; j<128; j++)
1600 {
1601 if (tmpOut EQ gsmToAsciiTable[j])
1602 {
1603 val = (UBYTE)j;
1604 break;
1605 }
1606 #ifdef REL99
1607 else
1608 {
1609 /* There is a chance that this is in the mapping table */
1610 UBYTE ext_tbl_idx = 0;
1611 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
1612 ext_common_chset_map[ext_tbl_idx][1] NEQ tmpOut )
1613 {
1614 ext_tbl_idx++;
1615 }
1616 if(ext_tbl_idx < NUM_EXT_TABLE_CHARS)
1617 {
1618 /*Insert the escape character, 0x1B, to output stream*/
1619 out[outIdx++] = 0x1B |(corr &0x80);
1620 /* Insert the mapping character into the output stream */
1621 val = ( UBYTE )ext_common_chset_map[ext_tbl_idx][0] |(corr &0x80);
1622 break;
1623 }
1624 }
1625 #endif /* REL99 */
1626 }
1627 }
1628
1629 /* if necessary, cut the GSM value to 7bit */
1630 if ( alphabet EQ CSCS_ALPHA_7_Bit AND !( val & 0x80 ) )
1631 {
1632 if ( gsm EQ GSM_ALPHA_Int )
1633 {
1634 out[outIdx++] = val | 0x80;
1635 }
1636 else
1637 {
1638 out[outIdx++] = val;
1639 }
1640 }
1641 else
1642 {
1643 out[outIdx++] = val;
1644 }
1645 }
1646
1647 else /* unknown char, skip it */
1648 {
1649 /* TRACE_EVENT("UCS2 MISMATCH: Unknown UCS2 entry, character skipped!"); */
1650 /* out[outIdx++] = '?'; */
1651 }
1652 }
1653
1654 if ( gsm EQ GSM_ALPHA_Int )
1655 {
1656 out[outIdx] = '\0';
1657 }
1658
1659 /* set the outlength */
1660 *outLen = outIdx;
1661
1662 }
1663 #endif
1664
1665 #ifdef FF_ATI
1666 /*
1667 +-------------------------------------------------------------------+
1668 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1669 | STATE : code ROUTINE : utl_hexFromGsm |
1670 +-------------------------------------------------------------------+
1671
1672 PURPOSE : This function converts the characters of a string from
1673 the ACI internal GSM character set to the "HEX"
1674 character set.
1675 */
1676 GLOBAL USHORT utl_hexFromGsm ( UBYTE* in,
1677 USHORT inLen,
1678 UBYTE* out,
1679 USHORT maxOutLen,
1680 USHORT* outLen,
1681 T_ACI_GSM_ALPHA gsm,
1682 T_ACI_CSCS_ALPHA alphabet )
1683 {
1684 USHORT inIdx = 0;
1685 USHORT outIdx = 0;
1686
1687 while ( inIdx < inLen AND outIdx < maxOutLen - 2 )
1688 {
1689 if ( alphabet NEQ CSCS_ALPHA_7_Bit OR
1690 ( gsm EQ GSM_ALPHA_Def AND !( in[inIdx] & 0x80 ) ) OR
1691 ( gsm EQ GSM_ALPHA_Int AND ( in[inIdx] & 0x80 ) ) )
1692 {
1693 /* Convert to 7bit default alphabet only if the data is
1694 coded in internal GSM character set */
1695 if ( gsm EQ GSM_ALPHA_Int AND ( in[inIdx] & 0x80 ) )
1696 {
1697 out[outIdx++] = hexVal[ (in[inIdx] & 0x7F) >> 4 ];
1698 }
1699 else
1700 {
1701 out[outIdx++] = hexVal[ in[inIdx] >> 4 ];
1702 }
1703 out[outIdx++] = hexVal[ in[inIdx] & 0x0F ];
1704 }
1705
1706 inIdx++;
1707 }
1708
1709 out[outIdx] = '\0';
1710 *outLen = outIdx;
1711
1712 return inIdx;
1713 }
1714 #endif
1715
1716 #ifdef FF_ATI
1717 /*
1718 +-------------------------------------------------------------------+
1719 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1720 | STATE : code ROUTINE : utl_ucs2FromGsm |
1721 +-------------------------------------------------------------------+
1722
1723 PURPOSE : This function converts the characters of a string from
1724 the ACI internal GSM character set to the "UCS2"
1725 character set.
1726 */
1727 LOCAL USHORT utl_ucs2FromGsm (UBYTE* in,
1728 USHORT inLen,
1729 UBYTE* out,
1730 USHORT maxOutLen,
1731 USHORT* outLen,
1732 T_ACI_GSM_ALPHA gsm,
1733 T_ACI_CSCS_ALPHA alphabet )
1734 {
1735 USHORT inIdx = 0;
1736 USHORT outIdx = 0;
1737 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0x00 : 0x80 );
1738
1739 while ( inIdx < inLen AND outIdx < maxOutLen - 4 )
1740 {
1741 if ( alphabet NEQ CSCS_ALPHA_7_Bit OR
1742 ( gsm EQ GSM_ALPHA_Def AND !( in[inIdx] & 0x80 ) ) OR
1743 ( gsm EQ GSM_ALPHA_Int AND ( in[inIdx] & 0x80 ) ) )
1744 {
1745 /* Insert two leading Os, convert GSM to ASCII and print out as HEX */
1746 out[outIdx++] = '0';
1747 out[outIdx++] = '0';
1748 #ifdef REL99
1749 if( (in[inIdx] | corr) EQ 0x9B)
1750 {
1751 UBYTE ext_tbl_idx = 0;
1752 inIdx++;
1753 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
1754 ext_common_chset_map[ext_tbl_idx][0] NEQ (in[inIdx] & 0x7F))
1755 {
1756 ext_tbl_idx++;
1757 }
1758 if( ext_tbl_idx < NUM_EXT_TABLE_CHARS )
1759 {
1760 /* Insert the mapping character into the output stream */
1761 out[outIdx++] = hexVal[(ext_common_chset_map[ext_tbl_idx][1] & 0x7F) >> 4 ];
1762 out[outIdx++] = hexVal[(ext_common_chset_map[ext_tbl_idx][1] & 0x7F) & 0x0F ];
1763 }
1764 }
1765 else
1766 {
1767 #endif /* REL99 */
1768 out[outIdx++] = hexVal[ gsmToAsciiTable[in[inIdx] & 0x7F] >> 4 ];
1769 out[outIdx++] = hexVal[ gsmToAsciiTable[in[inIdx] & 0x7F] & 0x0F ];
1770 #ifdef REL99
1771 }
1772 #endif /* REL99 */
1773
1774 }
1775
1776 inIdx++;
1777 }
1778
1779 out[outIdx] = '\0';
1780 *outLen = outIdx;
1781
1782 return inIdx;
1783
1784 }
1785 #endif
1786
1787 #ifdef FF_ATI
1788 /*
1789 +-------------------------------------------------------------------+
1790 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1791 | STATE : code ROUTINE : utl_ucs2FromGsm_ussd |
1792 +-------------------------------------------------------------------+
1793
1794 PURPOSE : This function converts the characters of USSD string from
1795 the ACI internal GSM character set to the "UCS2"
1796 character set with 2 bytes only.
1797 */
1798 GLOBAL USHORT utl_ucs2FromGsm_ussd(UBYTE* in,
1799 USHORT inLen,
1800 UBYTE* out,
1801 USHORT maxOutLen,
1802 USHORT* outLen,
1803 T_ACI_GSM_ALPHA gsm,
1804 T_ACI_CSCS_ALPHA alphabet )
1805 {
1806 USHORT inIdx = 0;
1807 USHORT outIdx = 0;
1808
1809 while ( inIdx < inLen AND outIdx < maxOutLen - 4 )
1810 {
1811 if ( alphabet NEQ CSCS_ALPHA_7_Bit OR
1812 ( gsm EQ GSM_ALPHA_Def AND !( in[inIdx] & 0x80 ) ) OR
1813 ( gsm EQ GSM_ALPHA_Int AND ( in[inIdx] & 0x80 ) ) )
1814 {
1815 /* 2 bytes for convertion from GSM to UCS2 */
1816 out[outIdx++] = 0x00;
1817 out[outIdx++] = gsmToAsciiTable[in[inIdx] & 0x7F];
1818 }
1819
1820 inIdx++;
1821 }
1822
1823 out[outIdx] = '\0';
1824 *outLen = outIdx;
1825
1826 return inIdx;
1827
1828 }
1829 #endif
1830 #ifdef FF_ATI
1831 /*
1832 +-------------------------------------------------------------------+
1833 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1834 | STATE : code ROUTINE : utl_smDtaToTe |
1835 +-------------------------------------------------------------------+
1836
1837 PURPOSE : This function converts the SM data in the format
1838 specified in Rec. GSM 07.05, message data parameter
1839 <data>, to the format used by the AT Command Interface.
1840 */
1841 GLOBAL void utl_smDtaToTe ( UBYTE* in,
1842 USHORT inLen,
1843 UBYTE* out,
1844 USHORT maxOutLen,
1845 USHORT* outLen,
1846 UBYTE fo,
1847 UBYTE dcs )
1848 {
1849 UBYTE alphabet = cmhSMS_getAlphabetPp ( dcs );
1850
1851 if ( alphabet EQ CSCS_ALPHA_7_Bit AND
1852 (fo & TP_UDHI_MASK) EQ TP_UDHI_WITHOUT_HEADER )
1853 {
1854 utl_chsetFromGsm ( in, inLen, out, maxOutLen, outLen, GSM_ALPHA_Def );
1855 }
1856 else if ( alphabet NEQ CSCS_ALPHA_7_Bit OR
1857 (fo & TP_UDHI_MASK) EQ TP_UDHI_WITH_HEADER )
1858 {
1859 utl_hexFromGsm ( in, inLen, out, maxOutLen, outLen, GSM_ALPHA_Def,
1860 CSCS_ALPHA_8_Bit );
1861 }
1862 else
1863 {
1864 *outLen = MINIMUM ( inLen, maxOutLen - 1 );
1865 memcpy ( out, in, *outLen );
1866 out[*outLen] = '\0';
1867 }
1868 }
1869 #endif
1870
1871 #ifdef FF_ATI
1872 /*
1873 +-------------------------------------------------------------------+
1874 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1875 | STATE : code ROUTINE : utl_smDtaFromTe |
1876 +-------------------------------------------------------------------+
1877
1878 PURPOSE : This function converts the SM data in the format used
1879 by the AT Command Interface to the format specified in
1880 Rec. GSM 07.05, message data parameter <data>.
1881 */
1882 GLOBAL void utl_smDtaFromTe ( UBYTE* in,
1883 USHORT inLen,
1884 UBYTE* out,
1885 USHORT* outLen,
1886 #ifdef REL99
1887 USHORT outBufLen,
1888 #endif
1889 UBYTE fo,
1890 UBYTE dcs )
1891 {
1892 UBYTE alphabet = cmhSMS_getAlphabetPp ( dcs );
1893
1894 if ( alphabet EQ CSCS_ALPHA_7_Bit AND
1895 ( fo & TP_UDHI_MASK ) EQ TP_UDHI_WITHOUT_HEADER )
1896 {
1897 #ifdef REL99
1898 utl_chsetToGsm ( in, inLen, out, outLen, outBufLen, GSM_ALPHA_Def );
1899 #else
1900 utl_chsetToGsm ( in, inLen, out, outLen, GSM_ALPHA_Def );
1901 #endif
1902
1903 }
1904 else if ( alphabet NEQ CSCS_ALPHA_7_Bit OR
1905 ( fo & TP_UDHI_MASK ) EQ TP_UDHI_WITH_HEADER )
1906 {
1907 utl_hexToGsm ( in, inLen, out, outLen, GSM_ALPHA_Def, (T_ACI_CSCS_ALPHA)alphabet );
1908 }
1909 else
1910 {
1911 memcpy ( out, in, inLen );
1912 *outLen = inLen;
1913 }
1914 }
1915 #endif
1916
1917 #ifdef FF_ATI
1918 /*
1919 +-------------------------------------------------------------------+
1920 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1921 | STATE : code ROUTINE : utl_ussdDtaFromTe |
1922 +-------------------------------------------------------------------+
1923
1924 PURPOSE : This function converts the USSD data in the format used
1925 by the AT Command Interface to the format specified in
1926 Rec. GSM 07.07.
1927 */
1928 GLOBAL void utl_ussdDtaFromTe ( UBYTE* in,
1929 USHORT inLen,
1930 UBYTE* out,
1931 USHORT* outLen,
1932 #ifdef REL99
1933 USHORT outBufLen,
1934 #endif
1935 UBYTE dcs )
1936 {
1937 /* Implements Measure 25 */
1938 UBYTE alphabet = cmh_getAlphabetCb ( dcs );
1939
1940 if ( alphabet EQ CSCS_ALPHA_7_Bit )
1941 {
1942 #ifdef REL99
1943 utl_chsetToGsm ( in, inLen, out, outLen, outBufLen, GSM_ALPHA_Def );
1944 #else
1945 utl_chsetToGsm ( in, inLen, out, outLen, GSM_ALPHA_Def );
1946 #endif
1947
1948 }
1949 else
1950 {
1951 utl_hexToGsm ( in, inLen, out, outLen, GSM_ALPHA_Def, (T_ACI_CSCS_ALPHA)alphabet );
1952 }
1953 }
1954 #endif
1955
1956 #ifdef FF_ATI
1957 /*
1958 +-------------------------------------------------------------------+
1959 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1960 | STATE : code ROUTINE : utl_ussdDtaToTe |
1961 +-------------------------------------------------------------------+
1962
1963 PURPOSE : This function converts the USSD data in the format
1964 specified in Rec. GSM 07.07 to the format used
1965 by the AT Command Interface.
1966 */
1967
1968 GLOBAL USHORT utl_ussdDtaToTe ( UBYTE* in,
1969 USHORT inLen,
1970 UBYTE* out,
1971 USHORT maxOutLen,
1972 USHORT* outLen,
1973 UBYTE dcs )
1974 {
1975 /* Implements Measure 25 */
1976 UBYTE alphabet = cmh_getAlphabetCb ( dcs );
1977 if ( alphabet EQ CSCS_ALPHA_7_Bit )
1978 {
1979 return utl_chsetFromGsm ( in, inLen, out, maxOutLen, outLen, GSM_ALPHA_Def );
1980 }
1981 else
1982 {
1983 return utl_hexFromGsm ( in, inLen, out, maxOutLen, outLen, GSM_ALPHA_Def, (T_ACI_CSCS_ALPHA)alphabet );
1984 }
1985 }
1986 #endif
1987
1988 #ifdef FF_ATI
1989 /*
1990 +-------------------------------------------------------------------+
1991 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1992 | STATE : code ROUTINE : utl_cbmDtaToTe |
1993 +-------------------------------------------------------------------+
1994
1995 PURPOSE : This function converts the CBM data in the format
1996 specified in Rec. GSM 07.05, message data parameter
1997 <data>, to the format used by the AT Command Interface.
1998 */
1999 GLOBAL void utl_cbmDtaToTe ( UBYTE* in,
2000 USHORT inLen,
2001 UBYTE* out,
2002 USHORT maxOutLen,
2003 USHORT* outLen,
2004 UBYTE fo,
2005 UBYTE dcs )
2006 {
2007 /* Implements Measure 25 */
2008 UBYTE alphabet = cmh_getAlphabetCb ( dcs );
2009 if ( alphabet EQ CSCS_ALPHA_7_Bit AND
2010 ( fo & TP_UDHI_MASK ) EQ TP_UDHI_WITHOUT_HEADER )
2011 {
2012 utl_chsetFromGsm ( in, inLen, out, maxOutLen, outLen, GSM_ALPHA_Def );
2013 }
2014 else if ( alphabet NEQ CSCS_ALPHA_7_Bit OR
2015 ( fo & TP_UDHI_MASK ) EQ TP_UDHI_WITH_HEADER )
2016 {
2017 utl_hexFromGsm ( in, inLen, out, maxOutLen, outLen, GSM_ALPHA_Def, (T_ACI_CSCS_ALPHA)alphabet );
2018 }
2019 else
2020 {
2021 *outLen = MINIMUM ( inLen, maxOutLen );
2022 memcpy ( out, in, *outLen );
2023 }
2024 }
2025 #endif
2026
2027 /*
2028 +-------------------------------------------------------------------+
2029 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
2030 | STATE : code ROUTINE : utl_cvtGsmIra |
2031 +-------------------------------------------------------------------+
2032
2033 PURPOSE : This function converts the characters of a string from
2034 the ACI internal GSM character set to the IRA character
2035 set or vice versa.
2036 */
2037 GLOBAL BOOL utl_cvtGsmIra ( UBYTE* in,
2038 USHORT inLen,
2039 UBYTE* out,
2040 USHORT outLen,
2041 T_ACI_CSCS_DIR dir )
2042 {
2043 USHORT inIdx = 0;
2044 USHORT outIdx = 0;
2045 USHORT tblIdx;
2046 UBYTE cvtdVal;
2047
2048 TRACE_FUNCTION("utl_cvtGsmIra()");
2049
2050
2051 if ( inLen > outLen )
2052 {
2053 return ( FALSE );
2054 }
2055
2056 if ( dir EQ CSCS_DIR_GsmToIra )
2057 {
2058 while ( inIdx < inLen )
2059 {
2060 tblIdx = 0;
2061
2062 while ( tblIdx <= 0xFF AND
2063 chset[CSCS_CHSET_Ira][tblIdx] NEQ (( UBYTE )in[inIdx] | 0x80 ))
2064 tblIdx++;
2065
2066 if ( tblIdx <= 0xFF )
2067 {
2068 out[outIdx] = ( UBYTE )tblIdx;
2069 outIdx++;
2070 }
2071 else
2072 {
2073 return ( FALSE );
2074 }
2075
2076 inIdx++;
2077 }
2078 }
2079 else if ( dir EQ CSCS_DIR_IraToGsm )
2080 {
2081 for ( inIdx = 0; inIdx < inLen; inIdx++ )
2082 {
2083 cvtdVal = chset[CSCS_CHSET_Ira][( UBYTE ) in[inIdx]];
2084
2085 if ( cvtdVal NEQ 0x00 )
2086 {
2087 out[outIdx] = ( CHAR ) cvtdVal & 0x7F;
2088 outIdx++;
2089 }
2090 else
2091 {
2092 return ( FALSE );
2093 }
2094 }
2095
2096 }
2097 else
2098 {
2099 return ( FALSE );
2100 }
2101
2102 return ( TRUE );
2103 }
2104
2105
2106 /*
2107 +-------------------------------------------------------------------+
2108 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
2109 | STATE : code ROUTINE : utl_binToHex |
2110 +-------------------------------------------------------------------+
2111
2112 PURPOSE : This function converts a binary string of bytes with a
2113 given length into an null terminated ASCII string
2114 representation.
2115 */
2116 GLOBAL void utl_binToHex (UBYTE* in,
2117 SHORT inLen,
2118 CHAR* out )
2119 {
2120 SHORT idx = 0;
2121 UBYTE hNib;
2122 UBYTE lNib;
2123
2124 while( idx < inLen )
2125 {
2126 hNib = (in[idx]&0xF0)>>4;
2127
2128 if( hNib > 9 ) *out = (hNib-10)+0x41;
2129 else *out = hNib + 0x30;
2130
2131 out++;
2132
2133 lNib = in[idx]&0x0F;
2134
2135 if( lNib > 9 ) *out = (lNib-10)+0x41;
2136 else *out = lNib + 0x30;
2137
2138 out++;
2139 idx++;
2140 }
2141 *out = 0x0;
2142 }
2143
2144
2145 #ifdef FF_ATI
2146 /*
2147 +-------------------------------------------------------------------+
2148 | PROJECT : GSM MODULE : ACI_UTIL |
2149 | STATE : code ROUTINE : utl_HexStrToBin |
2150 +-------------------------------------------------------------------+
2151
2152 PURPOSE : This function converts a null terminated string of HEX
2153 values in a binary buffer.
2154 RETURN: byte count.
2155 */
2156 GLOBAL USHORT utl_HexStrToBin (UBYTE *in,
2157 USHORT inLen,
2158 UBYTE *out,
2159 USHORT outLen)
2160 {
2161 USHORT inIdx = 0;
2162 USHORT outIdx = 0;
2163 UBYTE value;
2164 BOOL hNib = TRUE;
2165
2166 while ((inIdx < inLen) AND (outIdx < outLen))
2167 {
2168 if ((in[inIdx] >= 0x30) AND (in[inIdx] <= 0x39))
2169 {
2170 value = in[inIdx] - 0x30;
2171 }
2172 else if ((in[inIdx] >= 0x61) AND (in[inIdx] <= 0x66))
2173 {
2174 value = in[inIdx] - 0x61 + 0x0A;
2175 }
2176 else if ((in[inIdx] >= 0x41) AND (in[inIdx] <= 0x46))
2177 {
2178 value = in[inIdx] - 0x41 + 0x0A;
2179 }
2180 else
2181 {
2182 return (0);
2183 }
2184
2185 if (hNib)
2186 {
2187 out[outIdx] = (value << 0x04) & 0xF0;
2188 hNib = FALSE;
2189 }
2190 else
2191 {
2192 out[outIdx] |= value & 0x0F;
2193 hNib = TRUE;
2194 outIdx++;
2195 }
2196 inIdx++;
2197 }
2198
2199 return (outIdx);
2200 }
2201 #endif
2202
2203 #ifdef FF_ATI
2204 /*
2205 +-------------------------------------------------------------------+
2206 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
2207 | STATE : code ROUTINE : trace_cmd_line |
2208 +-------------------------------------------------------------------+
2209
2210 PURPOSE : This function trace the command line and check
2211 this string for % character
2212 */
2213
2214 GLOBAL void trace_cmd_line (char *prefix, char *output, UBYTE srcId, USHORT output_len)
2215 {
2216 char trcBuf[80];
2217 int dst_i;
2218
2219 dst_i = sprintf (trcBuf, "%s(Src %d)[lth %d]", (prefix) ? prefix : "", srcId, output_len);
2220
2221 strncpy(&trcBuf[dst_i], output, 79-dst_i);
2222 trcBuf[79] = '\0';
2223
2224 if (trcBuf[76])
2225 {
2226 trcBuf[76] = trcBuf[77] = trcBuf[78] = '.'; /* add trailing "..." if string is >=76 */
2227 }
2228
2229 /* Send the trace if either EVENT or CLASS8 is turned on */
2230 TRACE_USER_CLASS_P1(TC_EVENT|TC_USER8, "%s",trcBuf);
2231 }
2232 #endif
2233
2234
2235 #ifdef FF_ATI
2236 /*
2237 +-------------------------------------------------------------------+
2238 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
2239 | STATE : code ROUTINE : trace_cmd_state |
2240 +-------------------------------------------------------------------+
2241
2242 PURPOSE : This function trace the command line state
2243 */
2244
2245 GLOBAL void trace_cmd_state (UBYTE srcId,
2246 T_ATI_CMD_STATE old_state,
2247 T_ATI_CMD_STATE new_state)
2248 {
2249 char trcBuf[50];
2250
2251 if (old_state EQ new_state)
2252 {
2253 return;
2254 }
2255
2256 sprintf (trcBuf, "(Src %d) cmd_state: ", srcId );
2257
2258 switch (old_state)
2259 {
2260 case (CMD_IDLE):
2261 strcat (trcBuf, "CMD_IDLE -> ");
2262 break;
2263 case (CMD_TYPING):
2264 strcat (trcBuf, "CMD_TYPING -> ");
2265 break;
2266 case (CMD_RUNNING):
2267 strcat (trcBuf, "CMD_RUNNING -> ");
2268 break;
2269 default:
2270 strcat (trcBuf, "CMD_UNKNOWN ! ");
2271 }
2272
2273 switch (new_state)
2274 {
2275 case (CMD_IDLE):
2276 strcat (trcBuf, "CMD_IDLE");
2277 break;
2278 case (CMD_TYPING):
2279 strcat (trcBuf, "CMD_TYPING");
2280 break;
2281 case (CMD_RUNNING):
2282 strcat (trcBuf, "CMD_RUNNING");
2283 break;
2284 default:
2285 strcat (trcBuf, "CMD_UNKNOWN !");
2286 }
2287
2288 TRACE_EVENT_P1("%s",trcBuf);
2289 }
2290 #endif
2291
2292 /*
2293 +--------------------------------------------------------------------+
2294 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2295 | STATE : code ROUTINE : toa_merge |
2296 +--------------------------------------------------------------------+
2297
2298 PURPOSE : builds type of address octet from TOA structure
2299
2300 */
2301
2302 GLOBAL UBYTE toa_merge (T_ACI_TOA type)
2303 {
2304
2305 return ((type.ton << 4) & 0xF0)
2306 | ( type.npi & 0x0F)
2307 | 0x80;
2308 }
2309
2310
2311
2312 #ifdef GPRS
2313 /*
2314 +-----------------------------------------------------------------------------
2315 | Function : utl_create_pco
2316 +-----------------------------------------------------------------------------
2317 | Description : The function create_pco() creates protocol configuration
2318 | options needed to activate a PDPcontext.
2319 |
2320 | Parameters : buffer - buffer to write the PCOs
2321 | length - on call: buffer size; on return: written bytes
2322 | content - mask to specify the PCO content
2323 | config_prot - used configuration protocol (currently PPP)
2324 | auth_prot - authentication protocol (currently PAP)
2325 | user_name - string with the user name
2326 | password - string with the password
2327 | dns1 - requested primary DNS address
2328 | dns2 - requested secondary DNS address
2329 |
2330 | Return : 0 - operation successful
2331 | -1 - operation fails
2332 |
2333 +-----------------------------------------------------------------------------
2334 */
2335 GLOBAL int utl_create_pco (UBYTE* buffer,
2336 USHORT* length,
2337 ULONG content,
2338 UBYTE config_prot,
2339 USHORT auth_prot,
2340 UBYTE* user_name,
2341 UBYTE* password,
2342 ULONG dns1,
2343 ULONG dns2)
2344 {
2345 USHORT size;
2346 USHORT temp_len;
2347 USHORT len_user;
2348 USHORT len_pwd;
2349 USHORT written;
2350 UBYTE* pos;
2351 UBYTE* len_pos1;
2352 UBYTE* len_pos2;
2353
2354 TRACE_FUNCTION( "create_pco" );
2355
2356 /*
2357 * store buffer size
2358 */
2359 size = *length;
2360 /*
2361 * initialize values
2362 */
2363 *length = 0;
2364 written = 0;
2365 pos = buffer;
2366 /*
2367 * calculate if requested content is writeable
2368 */
2369 temp_len = 1;
2370 if(content & ACI_PCO_CONTENTMASK_AUTH)
2371 {
2372 len_user = strlen((char*)user_name);
2373 len_pwd = strlen((char*)password);
2374 temp_len+= ACI_PCO_PAP_OVERHEAD + len_user + len_pwd;
2375 }
2376 if((content & ACI_PCO_CONTENTMASK_DNS1) ||
2377 (content & ACI_PCO_CONTENTMASK_DNS2))
2378 {
2379 temp_len+= ACI_PCO_IPCP_OVERHEAD;
2380 if(content & ACI_PCO_CONTENTMASK_DNS1)
2381 temp_len+= ACI_PCO_IPCP_LENGTH_DNS1;
2382 if(content & ACI_PCO_CONTENTMASK_DNS2)
2383 temp_len+= ACI_PCO_IPCP_LENGTH_DNS2;
2384 }
2385 TRACE_EVENT_P2("temp_len=%d size=%d", temp_len, size);
2386 if(temp_len > size)
2387 {
2388 /*
2389 * content is to long
2390 */
2391 return -1;
2392 }
2393 /*
2394 * set configuration protocol identifier
2395 */
2396 *pos = 0x80 | config_prot;
2397 pos++;
2398 written++;
2399
2400 /*
2401 * authentication
2402 */
2403 if(content & ACI_PCO_CONTENTMASK_AUTH)
2404 {
2405 /*
2406 * set authentication protocol
2407 */
2408 *pos = (UBYTE)((auth_prot >> 8) & 0x00ff);
2409 pos++;
2410 written++;
2411 *pos = (UBYTE)(auth_prot & 0x00ff);
2412 pos++;
2413 written++;
2414 /*
2415 * store first length position
2416 */
2417 len_pos1 = pos;
2418 pos++;
2419 written++;
2420 /*
2421 * Code field
2422 */
2423 *pos = ACI_PCO_PAP_AUTH_REQ;
2424 pos++;
2425 written++;
2426 /*
2427 * Identifier field (just some value)
2428 */
2429 *pos = 0x01;
2430 pos++;
2431 written++;
2432 /*
2433 * Length field (store length position)
2434 */
2435 *pos = 0x00;
2436 pos++;
2437 written++;
2438 len_pos2 = pos;
2439 pos++;
2440 written++;
2441 /*
2442 * User Name Length field
2443 */
2444 *pos = (UBYTE)(/*lint -e(644) */len_user & 0x00ff);
2445 pos++;
2446 written++;
2447 /*
2448 * User Name field
2449 */
2450 memcpy(pos, user_name, len_user);
2451 pos += len_user;
2452 written+= len_user;
2453 /*
2454 * Password Length field
2455 */
2456 *pos = (UBYTE)(/*lint -e(644) */len_pwd & 0x00ff);
2457 pos++;
2458 written++;
2459 /*
2460 * Password field
2461 */
2462 memcpy(pos, password, len_pwd);
2463 pos += len_pwd;
2464 written+= len_pwd;
2465 /*
2466 * fill length fields
2467 */
2468 *len_pos1 = (UBYTE)(pos - len_pos1 - 1);
2469 *len_pos2 = *len_pos1;
2470 }
2471 /*
2472 * DNS addresses
2473 */
2474 if((content & ACI_PCO_CONTENTMASK_DNS1) ||
2475 (content & ACI_PCO_CONTENTMASK_DNS2))
2476 {
2477 /*
2478 * set IPCP protocol
2479 */
2480 *pos = ACI_PCO_IPCP_PROT_MSB;
2481 pos++;
2482 written++;
2483 *pos = ACI_PCO_IPCP_PROT_LSB;
2484 pos++;
2485 written++;
2486 /*
2487 * store first length position
2488 */
2489 len_pos1 = pos;
2490 pos++;
2491 written++;
2492 /*
2493 * Code field
2494 */
2495 *pos = ACI_PCO_IPCP_CONF_REQ;
2496 pos++;
2497 written++;
2498 /*
2499 * Identifier field (just some value)
2500 */
2501 *pos = 0x01;
2502 pos++;
2503 written++;
2504 /*
2505 * Length field (store length position)
2506 */
2507 *pos = 0x00;
2508 pos++;
2509 written++;
2510 len_pos2 = pos;
2511 pos++;
2512 written++;
2513 /*
2514 * primary DNS address
2515 */
2516 if(content & ACI_PCO_CONTENTMASK_DNS1)
2517 {
2518 /*
2519 * Type field
2520 */
2521 *pos = ACI_PCO_IPCP_TYPE_DNS1;
2522 pos++;
2523 written++;
2524 /*
2525 * Length field
2526 */
2527 *pos = ACI_PCO_IPCP_LENGTH_DNS1;
2528 pos++;
2529 written++;
2530 /*
2531 * primary DNS address
2532 */
2533 *pos = (UBYTE)((dns1 >> 24) & 0x000000ff);
2534 pos++;
2535 written++;
2536 *pos = (UBYTE)((dns1 >> 16) & 0x000000ff);
2537 pos++;
2538 written++;
2539 *pos = (UBYTE)((dns1 >> 8) & 0x000000ff);
2540 pos++;
2541 written++;
2542 *pos = (UBYTE)(dns1 & 0x000000ff);
2543 pos++;
2544 written++;
2545 }
2546 /*
2547 * secondary DNS address
2548 */
2549 if(content & ACI_PCO_CONTENTMASK_DNS2)
2550 {
2551 /*
2552 * Type field
2553 */
2554 *pos = ACI_PCO_IPCP_TYPE_DNS2;
2555 pos++;
2556 written++;
2557 /*
2558 * Length field
2559 */
2560 *pos = ACI_PCO_IPCP_LENGTH_DNS2;
2561 pos++;
2562 written++;
2563 /*
2564 * primary DNS address
2565 */
2566 *pos = (UBYTE)((dns2 >> 24) & 0x000000ff);
2567 pos++;
2568 written++;
2569 *pos = (UBYTE)((dns2 >> 16) & 0x000000ff);
2570 pos++;
2571 written++;
2572 *pos = (UBYTE)((dns2 >> 8) & 0x000000ff);
2573 pos++;
2574 written++;
2575 *pos = (UBYTE)(dns2 & 0x000000ff);
2576 pos++;
2577 written++;
2578 }
2579 /*
2580 * fill length fields
2581 */
2582 *len_pos1 = (UBYTE)(pos - len_pos1 - 1);
2583 *len_pos2 = *len_pos1;
2584 }
2585 /*
2586 * pass written bytes to caller
2587 */
2588 *length = written;
2589 /*
2590 * return result
2591 */
2592 return 0;
2593 } /* utl_create_pco() */
2594
2595
2596
2597 /*
2598 +-----------------------------------------------------------------------------
2599 | Function : utl_analyze_pco
2600 +-----------------------------------------------------------------------------
2601 | Description : The function analyze_pco() analyzes the response protocol
2602 | configuration from the network
2603 |
2604 | Parameters : buffer - buffer with the response PCOs
2605 | length - length of PCOs
2606 | dns1 - returns primary DNS address
2607 | dns2 - returns secondary DNS address
2608 | gateway - returns Gateway address
2609 |
2610 | Return : 0 - operation successful
2611 | -1 - operation fails
2612 |
2613 +-----------------------------------------------------------------------------
2614 */
2615 GLOBAL int utl_analyze_pco (UBYTE* buffer,
2616 USHORT length,
2617 ULONG* dns1,
2618 ULONG* dns2,
2619 ULONG* gateway)
2620 {
2621 UBYTE* pos;
2622 USHORT pos_len;
2623 USHORT packet_len;
2624 USHORT start_pos;
2625 USHORT dist_to_next;
2626 UBYTE type_len;
2627
2628 TRACE_FUNCTION( "utl_analyze_pco" );
2629
2630 /*
2631 * initialize values
2632 */
2633 pos = buffer;
2634 pos_len = 0;
2635 *dns1 = 0;
2636 *dns2 = 0;
2637 *gateway = 0;
2638 /*
2639 * check configuration protocol
2640 */
2641 if( (length <= pos_len) ||
2642 !(*pos & 0x80) )
2643 {
2644 return -1;
2645 }
2646
2647 #if 0
2648 /* Table 10.5.154/3GPP TS 24.008 states:
2649 "All other values are interpreded as PPP in this version of the protocol.
2650 so the next check should not be performed
2651 */
2652 if((*pos & 0x07) NEQ ACI_PCO_CONFIG_PROT_PPP)
2653 {
2654 /*
2655 * configuration protocol is not PPP
2656 */
2657 return 0;
2658 }
2659 #endif
2660
2661 pos++;
2662 pos_len++;
2663
2664 /*
2665 * search for IPCP packet
2666 */
2667 while(length > (pos_len + ACI_PCO_IPCP_OVERHEAD))
2668 {
2669 /*
2670 * initialize distance to next packet
2671 */
2672 dist_to_next = *(pos + 2) + 3;
2673 /*
2674 * check for IPCP packet
2675 */
2676 if((*pos EQ ACI_PCO_IPCP_PROT_MSB) AND
2677 (*(pos + 1) EQ ACI_PCO_IPCP_PROT_LSB))
2678 {
2679 /*
2680 * check for correct length field
2681 */
2682 pos += 2;
2683 pos_len += 2;
2684 dist_to_next-= 2;
2685 packet_len = *(pos + 3);
2686 packet_len = packet_len << 8;
2687 packet_len += *(pos + 4);
2688 if((packet_len EQ *pos) AND
2689 (length > (pos_len + packet_len)))
2690 {
2691 pos++;
2692 pos_len++;
2693 dist_to_next--;
2694 /*
2695 * check of code field
2696 */
2697 start_pos = pos_len;
2698 switch(*pos)
2699 {
2700 case ACI_PCO_IPCP_CONF_REQ:
2701 /*
2702 * search for Gateway address
2703 */
2704 pos += 4;
2705 pos_len+= 4;
2706 while((pos_len + 1 - start_pos) < packet_len)
2707 {
2708 type_len = *(pos + 1);
2709 if((*pos EQ ACI_PCO_IPCP_TYPE_IP) AND
2710 (type_len EQ ACI_PCO_IPCP_LENGTH_IP) AND
2711 ((pos_len +
2712 ACI_PCO_IPCP_LENGTH_IP -
2713 start_pos) <= packet_len))
2714 {
2715 *gateway = *(pos + 2);
2716 *gateway = ((*gateway) << 8);
2717 *gateway+= *(pos + 3);
2718 *gateway = ((*gateway) << 8);
2719 *gateway+= *(pos + 4);
2720 *gateway = ((*gateway) << 8);
2721 *gateway+= *(pos + 5);
2722 }
2723 pos += type_len;
2724 pos_len+= type_len;
2725 }
2726 if((pos_len - start_pos) <= packet_len)
2727 {
2728 dist_to_next = packet_len + start_pos - pos_len;
2729 }
2730 else
2731 {
2732 dist_to_next = 0;
2733 pos -= (pos_len - start_pos - packet_len);
2734 pos_len -= (pos_len - start_pos - packet_len);
2735 }
2736 break;
2737
2738 case ACI_PCO_IPCP_CONF_ACK:
2739 case ACI_PCO_IPCP_CONF_NAK:
2740 /*
2741 * search for DNS addresses
2742 */
2743 pos += 4;
2744 pos_len+= 4;
2745 while((pos_len + 1 - start_pos) < packet_len)
2746 {
2747 type_len = *(pos + 1);
2748 if((*pos EQ ACI_PCO_IPCP_TYPE_DNS1) AND
2749 (type_len EQ ACI_PCO_IPCP_LENGTH_DNS1) AND
2750 ((pos_len +
2751 ACI_PCO_IPCP_LENGTH_DNS1 -
2752 start_pos) <= packet_len))
2753 {
2754 *dns1 = *(pos + 2);
2755 *dns1 = ((*dns1) << 8);
2756 *dns1+= *(pos + 3);
2757 *dns1 = ((*dns1) << 8);
2758 *dns1+= *(pos + 4);
2759 *dns1 = ((*dns1) << 8);
2760 *dns1+= *(pos + 5);
2761 }
2762 else if((*pos EQ ACI_PCO_IPCP_TYPE_DNS2) AND
2763 (type_len EQ ACI_PCO_IPCP_LENGTH_DNS2) AND
2764 ((pos_len +
2765 ACI_PCO_IPCP_LENGTH_DNS2 -
2766 start_pos) <= packet_len))
2767 {
2768 *dns2 = *(pos + 2);
2769 *dns2 = ((*dns2) << 8);
2770 *dns2+= *(pos + 3);
2771 *dns2 = ((*dns2) << 8);
2772 *dns2+= *(pos + 4);
2773 *dns2 = ((*dns2) << 8);
2774 *dns2+= *(pos + 5);
2775 }
2776 pos += type_len;
2777 pos_len+= type_len;
2778 }
2779 if((pos_len - start_pos) <= packet_len)
2780 {
2781 dist_to_next = packet_len + start_pos - pos_len;
2782 }
2783 else
2784 {
2785 dist_to_next = 0;
2786 pos -= (pos_len - start_pos - packet_len);
2787 pos_len -= (pos_len - start_pos - packet_len);
2788 }
2789 break;
2790 }
2791 }
2792 }
2793 /*
2794 * go to next packet
2795 */
2796 pos_len+= dist_to_next;
2797 pos += dist_to_next;
2798 }
2799 /*
2800 * return
2801 */
2802 return 0;
2803 } /* utl_analyze_pco() */
2804
2805
2806
2807
2808 GLOBAL int utl_strcasecmp (const char *s1, const char *s2)
2809 {
2810 char c1, c2;
2811 int i;
2812
2813 int len1 = (s1 EQ NULL) ? 0 : strlen(s1);
2814 int len2 = (s2 EQ NULL) ? 0 : strlen(s2);
2815
2816 if (len1 > len2)
2817 {
2818 return (1);
2819 }
2820 if(len1 < len2)
2821 {
2822 return (-1);
2823 }
2824 for (i = 0; i < len1; i++)
2825 {
2826 c1 = s1[i]; /*lint !e613 (Warning -- 613: Possible use of null pointer 's1' in left argument to operator '[' [Reference: file condat\ms\src\aci\aci_util.c: line 2349] ) */
2827 c2 = s2[i]; /*lint !e613 (Warning -- 613: Possible use of null pointer 's2' in left argument to operator '[' [Reference: file condat\ms\src\aci\aci_util.c: line 2349] ) */
2828 if (c1 EQ c2)
2829 {
2830 continue ;
2831 }
2832 if (c1 >= 'a' AND c1 <= 'z')
2833 {
2834 c1 = c1 - ('a'-'A');
2835 }
2836 if (c2 >= 'a' AND c2 <= 'z')
2837 {
2838 c2 = c2 - ('a'-'A');
2839 }
2840 if (c1 NEQ c2)
2841 {
2842 return (1);
2843 }
2844 }
2845 return (0);
2846 }
2847
2848
2849 #endif /* GPRS */
2850
2851
2852
2853 #if defined (FF_ATI) || defined (FF_BAT)
2854
2855 /*
2856 +--------------------------------------------------------------------+
2857 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
2858 | STATE : code ROUTINE : rci_display_USSD |
2859 +--------------------------------------------------------------------+
2860
2861 PURPOSE : used by rCI_PlusCUSD and utl_cb_percentKSIR
2862 */
2863 GLOBAL void rci_display_USSD (UBYTE srcId,
2864 T_ACI_CUSD_MOD mode,
2865 UBYTE *ussd_str,
2866 UBYTE ussd_len,
2867 BOOL cvtStr,
2868 SHORT dcs )
2869 {
2870 SHORT pos = 0;
2871 USHORT chunksize;
2872 USHORT lenCvtdStr;
2873 CHAR sa[80];
2874
2875
2876 TRACE_FUNCTION("rci_display_USSD()");
2877
2878 pos = sprintf(sa,"+CUSD: ");
2879
2880 if (mode NEQ CUSD_MOD_NotPresent)
2881 {
2882 pos += sprintf(sa+pos,"%d,",mode);
2883 }
2884 else
2885 pos += sprintf(sa+pos,",");
2886
2887 if(ussd_str NEQ NULL)
2888 {
2889 pos += sprintf(sa+pos,"\""); /* beginning double quote */
2890 while (ussd_len)
2891 {
2892 if( cvtStr EQ CONVERT_STRING )
2893 {
2894 chunksize = utl_ussdDtaToTe( ussd_str,
2895 (USHORT)ussd_len,
2896 (UBYTE*)(sa + pos),
2897 sizeof(sa)-pos,
2898 &lenCvtdStr,
2899 (UBYTE)dcs );
2900
2901 pos += lenCvtdStr;
2902 }
2903 else
2904 {
2905 /*
2906 * How much space do we have left in the output array?
2907 */
2908 chunksize=(sizeof(sa)-pos)-1;
2909
2910 if (ussd_len<chunksize)
2911 {
2912 /*
2913 * Remaining data fits within the output array.
2914 */
2915 chunksize=ussd_len;
2916 }
2917 else if (chunksize>3)
2918 {
2919 /*
2920 * If the remaining data will not fit in the output
2921 * array, and we have more than 3 bytes available (which
2922 * we will), make sure that the amount of data output
2923 * divides by 4. This is so we don't split UCS2 characters
2924 * between two lines of output.
2925 */
2926 chunksize &= ~0x3;
2927 }
2928
2929 memcpy(sa+pos,ussd_str,chunksize);
2930
2931 pos += chunksize;
2932
2933 sa[pos]=0;
2934 }
2935 ussd_len-=chunksize;
2936 ussd_str+=chunksize;
2937
2938 if (ussd_len OR (sizeof(sa)-pos) < 10)
2939 {
2940 #ifdef _SIMULATION_
2941 io_sendMessage(srcId, sa, ATI_NORMAL_OUTPUT); /* append CR+LF only for testcase */
2942 #else
2943 io_sendMessage(srcId, sa, ATI_ECHO_OUTPUT); /* normal output a chunk */
2944 #endif
2945 pos=0;
2946 memset(sa, 0, 80);
2947 }
2948 }
2949
2950 pos+=sprintf(sa+pos,"\","); /* ending double quote */
2951
2952 if (dcs EQ ACI_NumParmNotPresent)
2953 {
2954 /* see 07.07: default is 0 */
2955 dcs = 0;
2956 }
2957
2958 pos+=sprintf(sa+pos,"%d",dcs);
2959 }
2960
2961 ci_remTrailCom(sa, pos);
2962 io_sendMessage(srcId, sa, ATI_NORMAL_OUTPUT);
2963 }
2964
2965 /*
2966 ****************************************************************
2967 */
2968 LOCAL void utl_cvtCLIRStat ( UBYTE clirOpt,
2969 UBYTE ssSt,
2970 T_ACI_CLIR_STAT *clirStat )
2971 {
2972 if ( clirOpt EQ KSD_CO_NOT_VALID )
2973 {
2974 /* SS Status of class - T_ACI_KSD_ST */
2975 if ( ssSt EQ KSD_ST_NOT_VALID )
2976 *clirStat = CLIR_STAT_Unknown;
2977 else if ( ssSt & SSS_P )
2978 *clirStat = CLIR_STAT_Permanent;
2979 else
2980 *clirStat = CLIR_STAT_NotProv;
2981 }
2982 else
2983 {
2984 switch ( clirOpt )
2985 {
2986 case( CLIR_OPT_PERMANENT ):
2987 *clirStat = CLIR_STAT_Permanent;
2988 break;
2989
2990 case( CLIR_OPT_TEMPORARY ):
2991 *clirStat = CLIR_STAT_RestrictTemp;
2992 break;
2993
2994 case( CLIR_OPT_ALLOWED ):
2995 *clirStat = CLIR_STAT_AllowTemp;
2996 break;
2997
2998 default:
2999 *clirStat = CLIR_STAT_Unknown;
3000 break;
3001 }
3002 }
3003 }
3004
3005 /*
3006 ****************************************************************
3007 */
3008 LOCAL void utl_cb_ccbs( UBYTE srcId, T_ACI_KSIR * ksStat )
3009 {
3010 T_ACI_CCBS_SET *CCBS_Setting = NULL;
3011
3012 T_ACI_CCBS_STAT status;
3013 T_basicService basicServ;
3014 int i;
3015 T_CC_FEAT *ccbs_features;
3016
3017 TRACE_FUNCTION("utl_cb_ccbs()");
3018
3019 /* SS Status of CCBS */
3020 if (ksStat->ir.rKSCC.ssSt EQ KSD_ST_NOT_VALID)
3021 status = CCBS_STAT_NotPresent;
3022 else if (!(ksStat->ir.rKSCC.ssSt & SSS_P))
3023 status = CCBS_STAT_NotProvisioned;
3024 else if (ksStat->ir.rKSCC.ssSt & SSS_A)
3025 status = CCBS_STAT_Active;
3026 else
3027 status = CCBS_STAT_Provisioned;
3028
3029 ACI_MALLOC(CCBS_Setting, sizeof(T_ACI_CCBS_SET));
3030
3031 /* CCBS_Setting infos */
3032 if (!ksStat->ir.rKSCC.c_ccFeatLst)
3033 {
3034 TRACE_EVENT("KSD_CMD_CCBS: no feature list");
3035
3036 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3037 {
3038 rCI_PercentCCBS(CCBS_IND_IrgtResult,
3039 status,
3040 CCBS_Setting,
3041 TRUE);
3042 }
3043 #ifdef FF_BAT
3044 else /* CMD_MODE_BAT */
3045 {
3046 rBAT_PercentCCBS(CCBS_IND_IrgtResult,
3047 status,
3048 CCBS_Setting,
3049 TRUE);
3050 }
3051 #endif
3052 return;
3053 }
3054
3055 for (i=0; i<ksStat->ir.rKSCC.c_ccFeatLst; i++)
3056 {
3057 ccbs_features = ksStat->ir.rKSCC.ccFeatLst + i;
3058
3059 memcpy( CCBS_Setting->number, ccbs_features->num, MAX_B_SUBSCR_NUM_LEN);
3060 memcpy( CCBS_Setting->subaddr, ccbs_features->sub, MAX_SUBADDR_LEN);
3061
3062 CCBS_Setting->type.npi = ccbs_features->npi NEQ 0xFF
3063 ? (T_ACI_TOA_NPI)ccbs_features->npi
3064 : NPI_NotPresent;
3065 CCBS_Setting->type.ton = ccbs_features->ton NEQ 0xFF
3066 ? (T_ACI_TOA_TON)ccbs_features->ton
3067 : TON_NotPresent;
3068 CCBS_Setting->satype.tos = ccbs_features->tos NEQ 0xFF
3069 ? (T_ACI_TOS_TOS)ccbs_features->tos
3070 : TOS_NotPresent;
3071 CCBS_Setting->satype.oe = ccbs_features->oe NEQ 0xFF
3072 ? (T_ACI_TOS_OE)ccbs_features->oe
3073 : OE_NotPresent;
3074
3075 if( ccbs_features->bsTp EQ BS_TELE_SRV )
3076 {
3077 basicServ.v_teleservice = TRUE;
3078 basicServ.v_bearerService = FALSE;
3079 basicServ.teleservice = ccbs_features->bsCd;
3080 }
3081 else /* if( p_servType EQ BS_BEAR_SRV ) */
3082 {
3083 basicServ.v_bearerService = TRUE;
3084 basicServ.v_teleservice = FALSE;
3085 basicServ.bearerService = ccbs_features->bsCd;
3086 }
3087
3088 CCBS_Setting->class_type = cmhSS_GetClass( &basicServ );
3089
3090 CCBS_Setting->idx = ccbs_features->idx NEQ 0xFF
3091 ? ccbs_features->idx
3092 : ACI_NumParmNotPresent;
3093
3094 CCBS_Setting->alrtPtn = ALPT_NotPresent;
3095
3096 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3097 {
3098 rCI_PercentCCBS(CCBS_IND_IrgtResult,
3099 status,
3100 CCBS_Setting,
3101 TRUE);
3102 }
3103 #ifdef FF_BAT
3104 else /* CMD_MODE_BAT */
3105 {
3106 rBAT_PercentCCBS(CCBS_IND_IrgtResult,
3107 status,
3108 CCBS_Setting,
3109 TRUE);
3110 }
3111 #endif
3112 }
3113
3114 ACI_MFREE( CCBS_Setting );
3115 }
3116
3117 /*
3118 ****************************************************************
3119 */
3120 LOCAL void utl_cb_callwaiting( UBYTE srcId, T_ACI_KSIR *ksStat )
3121 {
3122 T_ACI_CLSSTAT classStat;
3123 UBYTE idx;
3124 T_ACI_TOA type;
3125
3126 TRACE_FUNCTION("utl_cb_callwaiting()");
3127
3128 if ( ksStat->ir.rKSCW.opCd NEQ KSD_OP_IRGT )
3129 return;
3130
3131 /* SS Status of class - T_ACI_KSD_ST */
3132 if ( ksStat->ir.rKSCW.ssSt EQ KSD_ST_NOT_VALID )
3133 {
3134 classStat.status = STATUS_NotPresent;
3135 }
3136 else if ( ksStat->ir.rKSCW.ssSt & KSD_ST_A )
3137 {
3138 classStat.status = STATUS_Active;
3139 }
3140 else
3141 {
3142 classStat.status = STATUS_NotActive;
3143 }
3144
3145 /* init parameter type: */
3146 type.npi = NPI_NotPresent;
3147 type.ton = TON_NotPresent;
3148
3149 for( idx = 0; idx < ksStat->ir.rKSCW.c_cwBSGLst; idx++ )
3150 {
3151 /* type of class */
3152 classStat.class_type = cmhSS_GetClassType(ksStat->ir.rKSCW.cwBSGLst[idx].bsTp,
3153 ksStat->ir.rKSCW.cwBSGLst[idx].bsCd);
3154 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3155 {
3156 }
3157 else /* CMD_MODE_BAT */
3158 {
3159 }
3160
3161 rCI_PlusCCWA(&classStat,"\0", &type, MNCC_PRES_NOT_PRES, CLASS_NotPresent, NULL);
3162 }
3163 }
3164
3165 /*
3166 ****************************************************************
3167 */
3168 LOCAL void utl_cb_lineidentification( UBYTE srcId, T_ACI_KSIR * ksStat )
3169 {
3170 T_ACI_CLIP_STAT clipStat;
3171 T_ACI_CLIR_MOD clirMode;
3172 T_ACI_CLIR_STAT clirStat;
3173 T_ACI_COLP_STAT colpStat;
3174 T_ACI_COLR_STAT colrStat;
3175
3176 TRACE_FUNCTION("utl_cb_lineidentification()");
3177
3178 if ( ksStat->ir.rKSCL.opCd NEQ KSD_OP_IRGT )
3179 return;
3180
3181 switch ( ksStat->ir.rKSCL.ssCd )
3182 {
3183 case KSD_SS_CLIP:
3184 {
3185 /* SS Status of class - T_ACI_KSD_ST */
3186 if ( ksStat->ir.rKSCL.ssSt EQ KSD_ST_NOT_VALID )
3187 clipStat = CLIP_STAT_Unknown;
3188 else if ( ksStat->ir.rKSCL.ssSt & SSS_P )
3189 clipStat = CLIP_STAT_Prov;
3190 else
3191 clipStat = CLIP_STAT_NotProv;
3192
3193 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3194 {
3195 rCI_PlusCLIP ( clipStat, NULL, NULL, MNCC_PRES_NOT_PRES, NULL, NULL, NULL );
3196 }
3197 #ifdef FF_BAT
3198 else /* CMD_MODE_BAT */
3199 {
3200 rBAT_PlusCLIP ( clipStat, NULL, NULL, MNCC_PRES_NOT_PRES, NULL, NULL, NULL );
3201 }
3202 #endif
3203 break;
3204 }
3205 case KSD_SS_CLIR:
3206 {
3207 clirMode = ksStat->ir.rKSCL.mode;
3208 utl_cvtCLIRStat(ksStat->ir.rKSCL.clirOpt,
3209 ksStat->ir.rKSCL.ssSt,
3210 &clirStat);
3211 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3212 {
3213 rCI_PlusCLIR (clirMode, clirStat);
3214 }
3215 #ifdef FF_BAT
3216 else /* CMD_MODE_BAT */
3217 {
3218 rBAT_PlusCLIR (clirMode, clirStat);
3219 }
3220 #endif
3221 break;
3222 }
3223 case KSD_SS_COLP:
3224 {
3225 /* SS Status of class - T_ACI_KSD_ST */
3226 if ( ksStat->ir.rKSCL.ssSt EQ KSD_ST_NOT_VALID )
3227 colpStat = COLP_STAT_Unknown;
3228 else if ( ksStat->ir.rKSCL.ssSt & SSS_P )
3229 colpStat = COLP_STAT_Prov;
3230 else
3231 colpStat = COLP_STAT_NotProv;
3232
3233 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3234 {
3235 rCI_PlusCOLP ( colpStat, NULL, NULL, NULL, NULL, NULL );
3236 }
3237 #ifdef FF_BAT
3238 else /* CMD_MODE_BAT */
3239 {
3240 rBAT_PlusCOLP ( colpStat, NULL, NULL, NULL, NULL, NULL );
3241 }
3242 #endif
3243 break;
3244 }
3245 case KSD_SS_COLR:
3246 {
3247 /* SS Status of class - T_ACI_KSD_ST */
3248 if ( ksStat->ir.rKSCL.ssSt EQ KSD_ST_NOT_VALID )
3249 colrStat = COLR_STAT_Unknown;
3250 else if ( ksStat->ir.rKSCL.ssSt & SSS_P )
3251 colrStat = COLR_STAT_Prov;
3252 else
3253 colrStat = COLR_STAT_NotProv;
3254
3255 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3256 {
3257 rCI_PercentCOLR(colrStat);
3258 }
3259 #ifdef FF_BAT
3260 else /* CMD_MODE_BAT */
3261 {
3262 rBAT_PercentCOLR(colrStat);
3263 }
3264 #endif
3265 break;
3266 }
3267 }
3268 }
3269
3270 /*
3271 ****************************************************************
3272 */
3273 LOCAL void utl_cb_callforwarding( UBYTE srcId, T_ACI_KSIR * ksStat )
3274 {
3275 T_ACI_CCFC_SET ccfcSetting;
3276 UBYTE idx;
3277
3278 TRACE_FUNCTION("utl_cb_callforwarding()");
3279
3280 if ( ksStat->ir.rKSCF.opCd NEQ KSD_OP_IRGT )
3281 return;
3282
3283 for( idx = 0; idx < ksStat->ir.rKSCF.c_cfFeatLst; idx++ )
3284 {
3285 /* SS Status of class - T_ACI_KSD_ST */
3286 if ( ksStat->ir.rKSCF.cfFeatLst[idx].ssSt EQ KSD_ST_NOT_VALID )
3287 ccfcSetting.clsstat.status = STATUS_NotPresent;
3288 else if ( ksStat->ir.rKSCF.cfFeatLst[idx].ssSt & SSS_A )
3289 ccfcSetting.clsstat.status = STATUS_Active;
3290 else
3291 ccfcSetting.clsstat.status = STATUS_NotActive;
3292 /* type of class */
3293 if ( ksStat->ir.rKSCF.cfFeatLst[idx].bsTp EQ KSD_BS_TP_None
3294 AND ksStat->ir.rKSCF.cfFeatLst[idx].bsCd EQ KSD_BS_TeleBearerUnknown)
3295 {
3296 if (ccfcSetting.clsstat.status EQ STATUS_NotPresent)
3297 ccfcSetting.clsstat.class_type = CLASS_None;
3298 else
3299 ccfcSetting.clsstat.class_type = CLASS_VceDatFax;
3300 }
3301 else
3302 ccfcSetting.clsstat.class_type = cmhSS_GetClassType(ksStat->ir.rKSCF.cfFeatLst[idx].bsTp,
3303 ksStat->ir.rKSCF.cfFeatLst[idx].bsCd);
3304 /* number */
3305 strcpy(ccfcSetting.number, (char *)ksStat->ir.rKSCF.cfFeatLst[idx].num);
3306 if ( !strlen ( ccfcSetting.number ))
3307 {
3308 ccfcSetting.type.npi = NPI_NotPresent;
3309 ccfcSetting.type.ton = TON_NotPresent;
3310 ccfcSetting.subaddr[0] = 0x0;
3311 ccfcSetting.satype.tos = TOS_NotPresent;
3312 ccfcSetting.satype.oe = OE_NotPresent;
3313 ccfcSetting.time = ACI_NumParmNotPresent;
3314 }
3315 else
3316 {
3317 T_CF_FEAT *cfFeat = &ksStat->ir.rKSCF.cfFeatLst[idx];
3318 /* toa */
3319 ccfcSetting.type.ton = cfFeat->ton NEQ 0xFF
3320 ? (T_ACI_TOA_TON)cfFeat->ton
3321 : TON_NotPresent;
3322 ccfcSetting.type.npi = cfFeat->npi NEQ 0xFF
3323 ? (T_ACI_TOA_NPI)cfFeat->npi
3324 : NPI_NotPresent;
3325 /* subaddr */
3326 strcpy(ccfcSetting.subaddr, (char *)ksStat->ir.rKSCF.cfFeatLst[idx].sub);
3327 /* tos */
3328 ccfcSetting.satype.tos = cfFeat->tos NEQ 0xFF
3329 ? (T_ACI_TOS_TOS)cfFeat->tos
3330 : TOS_NotPresent;
3331 ccfcSetting.satype.oe = cfFeat->oe NEQ 0xFF
3332 ? (T_ACI_TOS_OE)cfFeat->oe
3333 : OE_NotPresent;
3334 /* time */
3335 ccfcSetting.time = cfFeat->time NEQ 0xFF
3336 ? cfFeat->time
3337 : ACI_NumParmNotPresent;
3338 }
3339 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3340 {
3341 rCI_PlusCCFC (&ccfcSetting);
3342 }
3343 #ifdef FF_BAT
3344 else
3345 {
3346 rBAT_PlusCCFC (&ccfcSetting);
3347 }
3348 #endif
3349 }
3350 }
3351
3352 /*
3353 ****************************************************************
3354 */
3355 LOCAL void utl_cb_callbarring( UBYTE srcId, T_ACI_KSIR * ksStat )
3356 {
3357 T_ACI_CLSSTAT classStat;
3358 UBYTE idx;
3359
3360 TRACE_FUNCTION("utl_cb_callbarring()");
3361
3362 if (ksStat->ir.rKSCB.opCd NEQ KSD_OP_IRGT)
3363 {
3364 return;
3365 }
3366 for (idx = 0; idx < ksStat->ir.rKSCB.c_cbInfoLst; idx++)
3367 {
3368 /* type of class */
3369 classStat.class_type = cmhSS_GetCbClassType(ksStat->ir.rKSCB.cbInfoLst[idx].bsTp,
3370 ksStat->ir.rKSCB.cbInfoLst[idx].bsCd);
3371
3372 /* SS Status of class */
3373 if (classStat.class_type EQ CLASS_VceDatFaxSms
3374 OR classStat.class_type EQ CLASS_None)
3375 {
3376 classStat.status = STATUS_NotActive;
3377 }
3378 else
3379 {
3380 classStat.status = STATUS_Active;
3381 }
3382 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3383 {
3384 rCI_PlusCLCK(&classStat);
3385 }
3386 #ifdef FF_BAT
3387 else /* CMD_MODE_BAT */
3388 {
3389 rBAT_PlusCLCK(&classStat);
3390 }
3391 #endif
3392 }
3393 }
3394
3395 /*
3396 ****************************************************************
3397 */
3398 LOCAL void utl_cb_imei( UBYTE srcId, T_ACI_KSIR * ksStat )
3399 {
3400 TRACE_FUNCTION("utl_cb_imei()");
3401
3402 sprintf ( g_sa,
3403 "%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d",
3404 (ksStat->ir.rKSIMEI.tac1 >> 4) & 0x0F,
3405 ksStat->ir.rKSIMEI.tac1 & 0x0F,
3406
3407 (ksStat->ir.rKSIMEI.tac2 >> 4) & 0x0F,
3408 ksStat->ir.rKSIMEI.tac2 & 0x0F,
3409
3410 (ksStat->ir.rKSIMEI.tac3 >> 4) & 0x0F,
3411 ksStat->ir.rKSIMEI.tac3 & 0x0F,
3412
3413 (ksStat->ir.rKSIMEI.fac >> 4) & 0x0F,
3414 ksStat->ir.rKSIMEI.fac & 0x0F,
3415
3416 (ksStat->ir.rKSIMEI.snr1 >> 4) & 0x0F,
3417 ksStat->ir.rKSIMEI.snr1 & 0x0F,
3418
3419 (ksStat->ir.rKSIMEI.snr2 >> 4) & 0x0F,
3420 ksStat->ir.rKSIMEI.snr2 & 0x0F,
3421
3422 (ksStat->ir.rKSIMEI.snr3 >> 4) & 0x0F,
3423 ksStat->ir.rKSIMEI.snr3 & 0x0F,
3424
3425 ksStat->ir.rKSIMEI.cd,
3426 (ksStat->ir.rKSIMEI.svn >> 4) & 0x0F,
3427 ksStat->ir.rKSIMEI.svn & 0x0F );
3428
3429 io_sendMessage ( srcId, g_sa, ATI_NORMAL_OUTPUT );
3430 }
3431
3432 /*
3433 +--------------------------------------------------------------------+
3434 | PROJECT : GSM-F&D (8411) MODULE : ACI_UTIL |
3435 | STATE : code ROUTINE : |
3436 +--------------------------------------------------------------------+
3437
3438 PURPOSE : handles PercentKSIR call back
3439
3440 */
3441 GLOBAL void utl_cb_percentKSIR (U8 srcId, T_ACI_KSIR *ksStat)
3442 {
3443 #ifdef FF_BAT
3444 T_ACI_USSD_DATA ussd;
3445 #endif /* FF_BAT */
3446
3447 TRACE_FUNCTION("utl_cb_percentKSIR()");
3448
3449 switch (ksStat->ksdCmd)
3450 {
3451 case (KSD_CMD_IMEI):
3452 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3453 {
3454 utl_cb_imei(srcId, ksStat);
3455 }
3456 #ifdef FF_BAT
3457 else /* CMD_MODE_BAT */
3458 {
3459 rBAT_PercentIMEI(&(ksStat->ir.rKSIMEI));
3460 }
3461 #endif
3462 break;
3463
3464 case (KSD_CMD_CB):
3465 utl_cb_callbarring(srcId, ksStat);
3466 break;
3467
3468 case (KSD_CMD_CF):
3469 utl_cb_callforwarding(srcId, ksStat);
3470 break;
3471
3472 case (KSD_CMD_CL):
3473 utl_cb_lineidentification(srcId, ksStat);
3474 break;
3475
3476 case (KSD_CMD_CW):
3477 utl_cb_callwaiting(srcId, ksStat);
3478 break;
3479
3480 case (KSD_CMD_PWD):
3481 /* no specific answer to +CPWD which is the corresponding AT cmd */
3482 break;
3483
3484 case (KSD_CMD_UBLK):
3485 /* no specific answer to +CPIN which is the corresponding AT cmd */
3486 break;
3487
3488 case (KSD_CMD_USSD):
3489 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3490 {
3491 rci_display_USSD(srcId,
3492 ksStat->ir.rKSUS.mode,
3493 (UBYTE *)ksStat->ir.rKSUS.ussd,
3494 ksStat->ir.rKSUS.len,
3495 FALSE, /* means DO NOT CONVERT STRING */
3496 ksStat->ir.rKSUS.dcs);
3497 }
3498 #ifdef FF_BAT
3499 else /* CMD_MODE_BAT */
3500 {
3501 ussd.len = ksStat->ir.rKSUS.len;
3502 memcpy (ussd.data, (UBYTE *)ksStat->ir.rKSUS.ussd, ussd.len);
3503 rBAT_PlusCUSD(ksStat->ir.rKSUS.mode, &ussd, ksStat->ir.rKSUS.dcs);
3504 }
3505 #endif
3506 break;
3507
3508 case (KSD_CMD_CCBS):
3509 utl_cb_ccbs(srcId, ksStat);
3510 break;
3511 }
3512
3513 }
3514 #endif /* defined (FF_ATI) || defined (FF_BAT) */