comparison src/ui/mfw/mfw_cnvt.c @ 188:92abb46dc1ba

src/ui/mfw/*.[ch]: rm trailing white space
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 19 Jan 2021 06:10:27 +0000
parents 67bfe9f274f6
children
comparison
equal deleted inserted replaced
187:a33dd8a5dcc9 188:92abb46dc1ba
72 #define FAILED 1 72 #define FAILED 1
73 #define LEN_OFFSET 1 73 #define LEN_OFFSET 1
74 74
75 /* Added to remove warning Aug - 11 */ 75 /* Added to remove warning Aug - 11 */
76 EXTERN char ATB_char_GSM (char ascii_character); 76 EXTERN char ATB_char_GSM (char ascii_character);
77 /* End - remove warning Aug - 11 */ 77 /* End - remove warning Aug - 11 */
78 /* 78 /*
79 +---------------------------------------------------------------+ 79 +---------------------------------------------------------------+
80 | PROJECT: MMI-Framework (8417) MODULE: MFW_CNVT | 80 | PROJECT: MMI-Framework (8417) MODULE: MFW_CNVT |
81 | STATE : code ROUTINE: mfw_getStrMode | 81 | STATE : code ROUTINE: mfw_getStrMode |
82 +---------------------------------------------------------------+ 82 +---------------------------------------------------------------+
83 83
84 PURPOSE : This function is used to request the coding format 84 PURPOSE : This function is used to request the coding format
85 of a given string. The return value is 85 of a given string. The return value is
86 "MFW_DCS_7bits" or " MFW_DCS_UCS2". 86 "MFW_DCS_7bits" or " MFW_DCS_UCS2".
87 87
88 */ 88 */
89 89
90 T_MFW_DCS mfw_getStrMode( UBYTE *str, // alpha string in MFW 90 T_MFW_DCS mfw_getStrMode( UBYTE *str, // alpha string in MFW
91 UBYTE len) // length of alpha string 91 UBYTE len) // length of alpha string
92 92
93 { 93 {
94 94
95 if( str[0] == 0x80) 95 if( str[0] == 0x80)
96 return MFW_DCS_UCS2; 96 return MFW_DCS_UCS2;
97 else 97 else
98 return MFW_DCS_7bits; 98 return MFW_DCS_7bits;
99 } 99 }
106 106
107 PURPOSE : This function is used to convert the MFW alpha 107 PURPOSE : This function is used to convert the MFW alpha
108 formatted string (consisting of alpha name and 108 formatted string (consisting of alpha name and
109 length of name in bytes) to a GSM default string 109 length of name in bytes) to a GSM default string
110 (including zero-termination) and to additionally 110 (including zero-termination) and to additionally
111 set the @ code to 0x80. 111 set the @ code to 0x80.
112 112
113 */ 113 */
114 114
115 T_MFW mfw_SIM2GsmStr( UBYTE inLen, 115 T_MFW mfw_SIM2GsmStr( UBYTE inLen,
116 UBYTE *inMfwStr, 116 UBYTE *inMfwStr,
117 UBYTE maxOutSize, /* in byte */ 117 UBYTE maxOutSize, /* in byte */
118 UBYTE *outGsmStr ) 118 UBYTE *outGsmStr )
119 119
120 { 120 {
121 int i; 121 int i;
122 UBYTE len; 122 UBYTE len;
123 123
124 if (!inLen OR !maxOutSize) 124 if (!inLen OR !maxOutSize)
125 return FAILED; /* string is zero length */ 125 return FAILED; /* string is zero length */
126 126
127 if (*inMfwStr EQ 0x80) /* input UCS, output GSM default */ 127 if (*inMfwStr EQ 0x80) /* input UCS, output GSM default */
128 { 128 {
129 len = inLen / 2; /* GSM string is half length of unicode string */ 129 len = inLen / 2; /* GSM string is half length of unicode string */
130 for( i=0; i<MINIMUM(len,maxOutSize-1); i++ ) 130 for( i=0; i<MINIMUM(len,maxOutSize-1); i++ )
131 { 131 {
146 else 146 else
147 * (outGsmStr + i) = inMfwStr[i]; 147 * (outGsmStr + i) = inMfwStr[i];
148 } 148 }
149 outGsmStr[i] = '\0'; 149 outGsmStr[i] = '\0';
150 return PASSED; 150 return PASSED;
151 } 151 }
152 152
153 } 153 }
154 154
155 /* 155 /*
156 +---------------------------------------------------------------+ 156 +---------------------------------------------------------------+
160 160
161 PURPOSE : This function is used to convert the MFW alpha 161 PURPOSE : This function is used to convert the MFW alpha
162 formatted string to a unicode string. The first 162 formatted string to a unicode string. The first
163 two bytes of this unicode string indicates the 163 two bytes of this unicode string indicates the
164 number of characters in the string. 164 number of characters in the string.
165 165
166 */ 166 */
167 167
168 T_MFW mfw_SIM2UcsStr( UBYTE inLen, 168 T_MFW mfw_SIM2UcsStr( UBYTE inLen,
169 UBYTE* inMfwStr, 169 UBYTE* inMfwStr,
170 UBYTE maxOutSize, /* in short */ 170 UBYTE maxOutSize, /* in short */
171 U16* outUcsStr) 171 U16* outUcsStr)
172 172
173 { 173 {
174 int i; 174 int i;
175 short cnt; 175 short cnt;
176 176
177 if (!inLen OR !maxOutSize) 177 if (!inLen OR !maxOutSize)
178 return FAILED; 178 return FAILED;
179 179
180 if (inMfwStr[0] EQ 0x80) /* input UCS, output UCS */ 180 if (inMfwStr[0] EQ 0x80) /* input UCS, output UCS */
181 { 181 {
182 TRACE_FUNCTION("First byte is indeed 0x80"); 182 TRACE_FUNCTION("First byte is indeed 0x80");
183 //inMfwStr++; 183 //inMfwStr++;
184 inLen--; 184 inLen--;
185 185
186 // NOTE: do not add '\0' termination! 186 // NOTE: do not add '\0' termination!
187 // len should not include termination 187 // len should not include termination
188 cnt = 1; 188 cnt = 1;
189 for( i=0; i<MINIMUM(inLen/2,maxOutSize-1); i++ ) 189 for( i=0; i<MINIMUM(inLen/2,maxOutSize-1); i++ )
190 { 190 {
191 outUcsStr[ i + LEN_OFFSET] = ((U16)inMfwStr[cnt] << 8)&0xFF00 + ((U16)inMfwStr[cnt + 1])&0xFF; 191 outUcsStr[ i + LEN_OFFSET] = ((U16)inMfwStr[cnt] << 8)&0xFF00 + ((U16)inMfwStr[cnt + 1])&0xFF;
192 cnt += 2; 192 cnt += 2;
193 } 193 }
194 outUcsStr[0] = i; 194 outUcsStr[0] = i;
195 return PASSED; 195 return PASSED;
196 } 196 }
197 else /* input GSM default, output UCS */ 197 else /* input GSM default, output UCS */
198 { 198 {
199 for( i=0; i<MINIMUM(inLen,maxOutSize-1); i++ ) 199 for( i=0; i<MINIMUM(inLen,maxOutSize-1); i++ )
200 * (outUcsStr + i + LEN_OFFSET) = (U16) inMfwStr[i]; 200 * (outUcsStr + i + LEN_OFFSET) = (U16) inMfwStr[i];
201 201
202 outUcsStr[0] = i; /* length of unicode string */ 202 outUcsStr[0] = i; /* length of unicode string */
203 return PASSED; 203 return PASSED;
204 } 204 }
205 } 205 }
206 206
209 | PROJECT: MMI-Framework (8417) MODULE: MFW_CNVT | 209 | PROJECT: MMI-Framework (8417) MODULE: MFW_CNVT |
210 | STATE : code ROUTINE: mfw_Gsm2SIMStr | 210 | STATE : code ROUTINE: mfw_Gsm2SIMStr |
211 +---------------------------------------------------------------+ 211 +---------------------------------------------------------------+
212 212
213 PURPOSE : This function is used to convert a zero-terminated 213 PURPOSE : This function is used to convert a zero-terminated
214 GSM default string ( @ code is 0x80) to a MFW 214 GSM default string ( @ code is 0x80) to a MFW
215 alpha formatted string (consisting of alpha name 215 alpha formatted string (consisting of alpha name
216 and length of name in bytes and @ code is 0x00). 216 and length of name in bytes and @ code is 0x00).
217 The MFW alpha format is dependent on the parameter "outMode" 217 The MFW alpha format is dependent on the parameter "outMode"
218 "outMode" is set to either " MFW_DCS_7bits" or " MFW_DCS_UCS2" 218 "outMode" is set to either " MFW_DCS_7bits" or " MFW_DCS_UCS2"
219 219
220 GW-SPR#762- Increased array size - required for larger phonebook entries (>40 chars). 220 GW-SPR#762- Increased array size - required for larger phonebook entries (>40 chars).
221 */ 221 */
222 222
223 #define MAX_CONVERT_LEN 255 223 #define MAX_CONVERT_LEN 255
224 T_MFW mfw_Gsm2SIMStr( T_MFW_DCS outMode, 224 T_MFW mfw_Gsm2SIMStr( T_MFW_DCS outMode,
225 UBYTE *inGsmStr, 225 UBYTE *inGsmStr,
226 UBYTE maxOutSize, 226 UBYTE maxOutSize,
227 UBYTE *outMfwStr, 227 UBYTE *outMfwStr,
228 UBYTE *outLen ) 228 UBYTE *outLen )
229 { 229 {
230 230
231 UBYTE temp_str[MAX_CONVERT_LEN]; 231 UBYTE temp_str[MAX_CONVERT_LEN];
232 int i; 232 int i;
233 UBYTE len = (UBYTE) strlen( (char *)inGsmStr ); 233 UBYTE len = (UBYTE) strlen( (char *)inGsmStr );
234 char GSM_char;/*SPR2175*/ 234 char GSM_char;/*SPR2175*/
235 235
236 len=MINIMUM(len,sizeof(temp_str)); 236 len=MINIMUM(len,sizeof(temp_str));
237 memcpy( temp_str,inGsmStr,len ); 237 memcpy( temp_str,inGsmStr,len );
238 238
239 if( outMode EQ MFW_DCS_7bits ) 239 if( outMode EQ MFW_DCS_7bits )
240 { 240 {
241 /* write to outMfwStr */ 241 /* write to outMfwStr */
242 for( i=0; i<MINIMUM(len,maxOutSize); i++ ) 242 for( i=0; i<MINIMUM(len,maxOutSize); i++ )
243 { /*SPR2175, convert to GSM encoding*/ 243 { /*SPR2175, convert to GSM encoding*/
267 else 267 else
268 { 268 {
269 TRACE_EVENT ("mfw_Gsm2SIMStr() - outMode is not valid"); 269 TRACE_EVENT ("mfw_Gsm2SIMStr() - outMode is not valid");
270 return FAILED; 270 return FAILED;
271 } 271 }
272 272
273 // return PASSED; // RAVI 273 // return PASSED; // RAVI
274 } 274 }
275 275
276 /* 276 /*
277 +---------------------------------------------------------------+ 277 +---------------------------------------------------------------+
278 | PROJECT: MMI-Framework (8417) MODULE: MFW_CNVT | 278 | PROJECT: MMI-Framework (8417) MODULE: MFW_CNVT |
279 | STATE : code ROUTINE: mfw_Ucs2SIMStr | 279 | STATE : code ROUTINE: mfw_Ucs2SIMStr |
280 +---------------------------------------------------------------+ 280 +---------------------------------------------------------------+
281 281
282 PURPOSE : This function is used to convert a unicode string 282 PURPOSE : This function is used to convert a unicode string
283 to MFW alpha format. The MFW alpha format is 283 to MFW alpha format. The MFW alpha format is
284 dependent on the parameter "outMode". "outMode" 284 dependent on the parameter "outMode". "outMode"
285 is " MFW_DCS_7bits" or " MFW_DCS_UCS2". 285 is " MFW_DCS_7bits" or " MFW_DCS_UCS2".
286 286
287 */ 287 */
288 288
289 T_MFW mfw_Ucs2SIMStr( T_MFW_DCS outMode, 289 T_MFW mfw_Ucs2SIMStr( T_MFW_DCS outMode,
290 U16 *inDcsStr, 290 U16 *inDcsStr,
291 UBYTE maxOutSize, 291 UBYTE maxOutSize,
292 UBYTE *outMfwStr, 292 UBYTE *outMfwStr,
293 UBYTE *outLen ) 293 UBYTE *outLen )
294 { 294 {
295 int i; 295 int i;
296 U16 len; 296 U16 len;
297 297
298 len = inDcsStr[0]; 298 len = inDcsStr[0];
299 299
300 if( outMode EQ MFW_DCS_7bits ) 300 if( outMode EQ MFW_DCS_7bits )
301 { 301 {
302 /* write to outMfwStr */ 302 /* write to outMfwStr */
303 for( i=0; i<MINIMUM(len,maxOutSize); i++ ) 303 for( i=0; i<MINIMUM(len,maxOutSize); i++ )
304 { 304 {
305 * (outMfwStr + (i*2) + 1) = (UBYTE) (inDcsStr[i+1] & 0xff); 305 * (outMfwStr + (i*2) + 1) = (UBYTE) (inDcsStr[i+1] & 0xff);
306 * (outMfwStr + (i*2)) = (UBYTE) ((inDcsStr[i+1] & 0xff00) >> 8); 306 * (outMfwStr + (i*2)) = (UBYTE) ((inDcsStr[i+1] & 0xff00) >> 8);
307 } 307 }
308 /* write length of name to outLen */ 308 /* write length of name to outLen */
309 *outLen = len * 2; 309 *outLen = len * 2;
310 310
311 return PASSED; 311 return PASSED;
312 } 312 }
313 else if( outMode EQ MFW_DCS_UCS2 ) 313 else if( outMode EQ MFW_DCS_UCS2 )
314 { 314 {
315 /* write to outMfwStr */ 315 /* write to outMfwStr */
319 * (outMfwStr + (i*2) + 1) = (UBYTE) (inDcsStr[i+1] & 0xff); 319 * (outMfwStr + (i*2) + 1) = (UBYTE) (inDcsStr[i+1] & 0xff);
320 * (outMfwStr + (i*2) + 2) = (UBYTE) ((inDcsStr[i+1] & 0xff00) >> 8); 320 * (outMfwStr + (i*2) + 2) = (UBYTE) ((inDcsStr[i+1] & 0xff00) >> 8);
321 } 321 }
322 /* write length to outLen */ 322 /* write length to outLen */
323 *outLen = (len*2) + 1; 323 *outLen = (len*2) + 1;
324 324
325 return PASSED; 325 return PASSED;
326 326
327 } 327 }
328 else /* string does not require conversion to unicode */ 328 else /* string does not require conversion to unicode */
329 { 329 {
330 TRACE_EVENT ("mfw_Ucs2SIMStr() - outMode is not valid"); 330 TRACE_EVENT ("mfw_Ucs2SIMStr() - outMode is not valid");
331 return FAILED; 331 return FAILED;
332 } 332 }
333 333
334 // return PASSED; // RAVI 334 // return PASSED; // RAVI
335 } 335 }
336 336
337 /*CONQUEST 5992(related) MC added function to convert GSM string to ASCII*/ 337 /*CONQUEST 5992(related) MC added function to convert GSM string to ASCII*/
338 static const unsigned char gsm_2_ascii_table[128] = { 64, 156, 36, 157, 138, 130, 151, 141, 149, 128, 338 static const unsigned char gsm_2_ascii_table[128] = { 64, 156, 36, 157, 138, 130, 151, 141, 149, 128,