FreeCalypso > hg > freecalypso-citrine
comparison g23m-aci/aci/cmh_phbf.c @ 0:75a11d740a02
initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 09 Jun 2016 00:02:41 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:75a11d740a02 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS (6147) | |
4 | Modul : CMH_PHBF | |
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 functions used by the command | |
18 | handler for the phonebook management. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef CMH_PHBF_C | |
23 #define CMH_PHBF_C | |
24 #endif | |
25 | |
26 #include "config.h" | |
27 #include "fixedconf.h" | |
28 #include "condat-features.h" | |
29 #include "aci_conf.h" | |
30 | |
31 #include "aci_all.h" | |
32 /*==== INCLUDES ===================================================*/ | |
33 #include "aci_cmh.h" | |
34 #include "ati_cmd.h" | |
35 #include "aci_cmd.h" | |
36 | |
37 #ifdef FAX_AND_DATA | |
38 #include "aci_fd.h" | |
39 #endif /* of #ifdef FAX_AND_DATA */ | |
40 | |
41 #include "aci.h" | |
42 #include "psa.h" | |
43 #include "phb.h" | |
44 #include "cmh.h" | |
45 #include "cmh_phb.h" | |
46 | |
47 /*==== CONSTANTS ==================================================*/ | |
48 | |
49 #define PHB_CMH_INVALID_TAG_ENTRY 0xFF /* fill up a tag */ | |
50 #define PHB_CMH_INVALID_BCD_ENTRY 0xF /* fill up a BCD number */ | |
51 | |
52 #define PHB_CMH_YEAR_INVLD (255) /* invalid year */ | |
53 #define PHB_CMH_MONTH_INVLD (255) /* invalid month */ | |
54 #define PHB_CMH_DAY_INVLD (255) /* invalid day */ | |
55 #define PHB_CMH_HOUR_INVLD (255) /* invalid hour */ | |
56 #define PHB_CMH_MINUTE_INVLD (255) /* invalid minute */ | |
57 #define PHB_CMH_SECOND_INVLD (255) /* invalid second */ | |
58 | |
59 /*==== TYPES ======================================================*/ | |
60 /* Implements Measure 108, 109 */ | |
61 /* | |
62 * Here we are having two SIM Phonebook as in our code we have two, | |
63 * one is FFS based that has been defined in phb_sim.h | |
64 * And the other one is RAM based has been defined in phb.h | |
65 */ | |
66 | |
67 /* | |
68 * Conversion Array that convert the type of phonebook used by | |
69 * phonebook management to the type of phonebook used by ACI. | |
70 */ | |
71 #ifdef TI_PS_FFS_PHB | |
72 /* | |
73 * FFS based SIM phonebook | |
74 */ | |
75 const T_ACI_PB_STOR cmhPHB_cvtPhbPsaType[]= | |
76 { | |
77 PB_STOR_Ed, /* ECC */ | |
78 PB_STOR_Ad, /* ADN */ | |
79 PB_STOR_Fd, /* FDN */ | |
80 PB_STOR_Bd, /* BDN */ | |
81 PB_STOR_Ld, /* LDN */ | |
82 PB_STOR_Lr, /* LRN */ | |
83 PB_STOR_Sd, /* SDN */ | |
84 PB_STOR_Lm, /* LMN */ | |
85 PB_STOR_Ud, /* UPN */ | |
86 PB_STOR_NotPresent, /* ME */ | |
87 PB_STOR_NotPresent, /* ADN_ME */ | |
88 PB_STOR_NotPresent, /* MAX_PHONEBOOK */ | |
89 }; | |
90 #else | |
91 /* | |
92 * Old RAM based SIM phonebook. | |
93 */ | |
94 const T_ACI_PB_STOR cmhPHB_cvtPhbPsaType[]= | |
95 { | |
96 PB_STOR_Ed, /* ECC */ | |
97 PB_STOR_Ad, /* ADN */ | |
98 PB_STOR_Fd, /* FDN */ | |
99 PB_STOR_Bd, /* BDN */ | |
100 PB_STOR_Ld, /* LDN */ | |
101 PB_STOR_Lr, /* LRN */ | |
102 PB_STOR_Sd, /* SDN */ | |
103 PB_STOR_Lm, /* LMN */ | |
104 PB_STOR_NotPresent, /* ADN_FDN */ | |
105 PB_STOR_Ud, /* UPN */ | |
106 PB_STOR_NotPresent /* MAX_PHONEBOOK */ | |
107 }; | |
108 #endif /* TI_PS_FFS_PHB */ | |
109 | |
110 /* | |
111 * Conversion Array that convert the type of phonebook used by | |
112 * used by ACI to the type of phonebook used by phonebook management. | |
113 */ | |
114 const T_PHB_TYPE cmhPHB_cvtPBType[]= | |
115 { | |
116 FDN, /* PB_STOR_Fd */ | |
117 LDN, /* PB_STOR_Ld */ | |
118 ECC, /* PB_STOR_Ed */ | |
119 ADN, /* PB_STOR_Ad */ | |
120 BDN, /* PB_STOR_Bd */ | |
121 LRN, /* PB_STOR_Lr */ | |
122 SDN, /* PB_STOR_Sd */ | |
123 LMN, /* PB_STOR_Lm */ | |
124 #ifdef TI_PS_FFS_PHB | |
125 INVALID_PHB, /* PB_STOR_Af , Not supported anymore */ | |
126 #else | |
127 UNUSED_INDEX, | |
128 #endif | |
129 UPN /* PB_STOR_Ud */ | |
130 }; | |
131 | |
132 /*==== EXPORT =====================================================*/ | |
133 | |
134 /*==== VARIABLES ==================================================*/ | |
135 | |
136 /*==== FUNCTIONS ==================================================*/ | |
137 /* | |
138 +-------------------------------------------------------------------+ | |
139 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
140 | STATE : code ROUTINE : cmhPHB_rplcIntnl | | |
141 +-------------------------------------------------------------------+ | |
142 | |
143 PURPOSE : | |
144 */ | |
145 GLOBAL BOOL cmhPHB_rplcIntnl ( CHAR* inNumber, | |
146 CHAR* outNumber, | |
147 UBYTE inCnt ) | |
148 { | |
149 USHORT inIdx = 0; | |
150 USHORT outIdx = 0; | |
151 UBYTE actCnt = 0; | |
152 BOOL international = FALSE; | |
153 | |
154 while ( inNumber[inIdx] NEQ '\0' ) | |
155 { | |
156 /* | |
157 *--------------------------------------------------------------- | |
158 * international indicator "+" | |
159 *--------------------------------------------------------------- | |
160 */ | |
161 if ( inNumber[inIdx] EQ '+' AND | |
162 inNumber[inIdx-1] EQ '*' ) | |
163 { | |
164 if ( actCnt EQ inCnt OR inCnt EQ 0xFF ) | |
165 { | |
166 international = TRUE; | |
167 } | |
168 else | |
169 { | |
170 outNumber[outIdx++] = inNumber[inIdx]; | |
171 } | |
172 } | |
173 /* PATCH LE 12.05.00 | |
174 * 00 is used in china as national number | |
175 * checked against competitor phone | |
176 * now ACI has the same behaviour | |
177 */ | |
178 /* | |
179 *--------------------------------------------------------------- | |
180 * international indicator "00" | |
181 *--------------------------------------------------------------- | |
182 */ | |
183 /* else if ( inNumber[inIdx+1] EQ '0' AND | |
184 inNumber[inIdx] EQ '0' AND | |
185 inNumber[inIdx-1] EQ '*' ) | |
186 { | |
187 if ( actCnt EQ inCnt OR inCnt EQ 0xFF ) | |
188 { | |
189 international = TRUE; | |
190 inIdx++; | |
191 } | |
192 else | |
193 { | |
194 outNumber[outIdx++] = inNumber[inIdx++]; | |
195 outNumber[outIdx++] = inNumber[inIdx]; | |
196 } | |
197 } */ | |
198 /* END PATCH LE 12.05.00 */ | |
199 /* | |
200 *--------------------------------------------------------------- | |
201 * national indicator | |
202 *--------------------------------------------------------------- | |
203 */ | |
204 else | |
205 { | |
206 if ( inNumber[inIdx] EQ '*' ) | |
207 { | |
208 actCnt++; | |
209 } | |
210 | |
211 outNumber[outIdx++] = inNumber[inIdx]; | |
212 } | |
213 | |
214 inIdx++; | |
215 } | |
216 | |
217 outNumber[outIdx] = '\0'; | |
218 | |
219 return international; | |
220 } | |
221 | |
222 /* | |
223 +-------------------------------------------------------------------+ | |
224 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
225 | STATE : code ROUTINE : cmhPHB_cvtPhbType | | |
226 +-------------------------------------------------------------------+ | |
227 | |
228 PURPOSE : This function is used to convert the type of phonebook | |
229 used by ACI to the type of phonebook used by phonebook | |
230 management. | |
231 */ | |
232 GLOBAL BOOL cmhPHB_cvtPhbType ( T_ACI_PB_STOR inMem, T_PHB_TYPE* outMem ) | |
233 { | |
234 /* Implements Measure 108, 109 */ | |
235 if ( (inMem <= PB_STOR_Ud) AND (inMem NEQ PB_STOR_Af) | |
236 AND (inMem > PB_STOR_NotPresent) ) | |
237 { | |
238 *outMem = ( T_PHB_TYPE ) cmhPHB_cvtPBType[inMem]; | |
239 return ( TRUE ); | |
240 } | |
241 else | |
242 { | |
243 return ( FALSE ); | |
244 } | |
245 } | |
246 | |
247 | |
248 /* | |
249 +--------------------------------------------------------------------+ | |
250 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
251 | STATE : code ROUTINE : cmhPHB_toaMrg | | |
252 +--------------------------------------------------------------------+ | |
253 | |
254 PURPOSE : This function is used to build the type of address octet | |
255 from T_ACI_TOA structure. | |
256 */ | |
257 GLOBAL void cmhPHB_toaMrg ( T_ACI_TOA* type, UBYTE* octet ) | |
258 { | |
259 *octet = ( ( ( type -> ton << 4 ) & 0xF0 ) + ( type -> npi & 0x0F ) ) | 0x80; | |
260 } | |
261 | |
262 /* | |
263 +--------------------------------------------------------------------+ | |
264 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
265 | STATE : code ROUTINE : cmhPHB_toaDmrg | | |
266 +--------------------------------------------------------------------+ | |
267 | |
268 PURPOSE : This function is used to build the T_ACI_TOA structure | |
269 from the type of address octet. | |
270 */ | |
271 GLOBAL void cmhPHB_toaDmrg ( UBYTE octet, T_ACI_TOA* type ) | |
272 { | |
273 if ( octet EQ 0xFF ) | |
274 { | |
275 type -> ton = TON_NotPresent; | |
276 type -> npi = NPI_NotPresent; | |
277 } | |
278 else | |
279 { | |
280 type -> ton = (T_ACI_TOA_TON)(( octet & 0x70 ) >> 4); | |
281 type -> npi = (T_ACI_TOA_NPI)(octet & 0x0F); | |
282 } | |
283 } | |
284 | |
285 /* | |
286 +--------------------------------------------------------------------+ | |
287 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
288 | STATE : code ROUTINE : cmhPHB_getAdrStr | | |
289 +--------------------------------------------------------------------+ | |
290 | |
291 PURPOSE : This function is used to convert the phone number | |
292 in BCD to the phone number as a string. | |
293 | |
294 BCD Note: Two digits are stored in one byte. | |
295 | |
296 +-------+-------+-------+-------+ | |
297 BCD: | 1 - 0 | 3 - 2 | F - 4 | F - F | | |
298 +-------+-------+-------+-------+ | |
299 | |
300 STRING: "01234" | |
301 | |
302 */ | |
303 GLOBAL CHAR cmhPHB_convertBCD2char( UBYTE bcd ) | |
304 { | |
305 switch ( bcd ) | |
306 { | |
307 case 0: | |
308 case 1: | |
309 case 2: | |
310 case 3: | |
311 case 4: | |
312 case 5: | |
313 case 6: | |
314 case 7: | |
315 case 8: | |
316 case 9: | |
317 return (bcd + '0'); | |
318 | |
319 case 0x0a: | |
320 return ('*'); | |
321 | |
322 case 0x0b: | |
323 return ('#'); | |
324 | |
325 case 0x0c: | |
326 return (PHB_DIAL_PAUSE); /* 'P' */ | |
327 | |
328 case 0x0d: | |
329 return (PHB_WILD_CRD); /* '?' */ | |
330 | |
331 case 0x0e: | |
332 return (PHB_EXP_DIGIT); /* 'E' */ | |
333 | |
334 default: | |
335 return ('\0'); | |
336 } | |
337 } | |
338 | |
339 GLOBAL UBYTE cmhPHB_getAdrStr ( CHAR* pStr, | |
340 UBYTE maxIdx, | |
341 const UBYTE* pBcd, | |
342 UBYTE numDigits ) | |
343 { | |
344 BOOL highNibble = FALSE; | |
345 | |
346 UBYTE bcdIdx = 0; | |
347 UBYTE strIdx = 0; | |
348 | |
349 UBYTE bcd; | |
350 char digit; | |
351 BOOL ignore_next = FALSE; | |
352 | |
353 while ( bcdIdx < numDigits AND strIdx < maxIdx ) | |
354 { | |
355 if ( highNibble ) | |
356 { | |
357 bcd = ( pBcd[bcdIdx] & 0xF0 ) >> 4; | |
358 bcdIdx++; | |
359 } | |
360 else | |
361 { | |
362 bcd = pBcd[bcdIdx] & 0x0F; | |
363 } | |
364 | |
365 highNibble = ! highNibble; | |
366 | |
367 if(bcd EQ PHB_CMH_INVALID_BCD_ENTRY) | |
368 { | |
369 break; | |
370 } | |
371 | |
372 digit = cmhPHB_convertBCD2char( bcd ); | |
373 if (ignore_next EQ TRUE) | |
374 { | |
375 ; /* skip the digit following on an extension flag since we do not support it */ | |
376 ignore_next = FALSE; /* reset flag */ | |
377 } | |
378 else if (digit EQ PHB_EXP_DIGIT) | |
379 { | |
380 ignore_next = TRUE; /* we currently do not support Expansion Digit so skip next digit */ | |
381 } | |
382 else | |
383 { | |
384 pStr[strIdx++] = cmhPHB_convertBCD2char( bcd ); /* normal and supported digit */ | |
385 } | |
386 | |
387 } | |
388 | |
389 pStr[strIdx] = '\0'; | |
390 return ( strIdx ); | |
391 } | |
392 | |
393 /* | |
394 +--------------------------------------------------------------------+ | |
395 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
396 | STATE : code ROUTINE : cmhPHB_getAdrBcd | | |
397 +--------------------------------------------------------------------+ | |
398 | |
399 PURPOSE : This function is used to convert the phone number | |
400 as a string to the phone number in BCD. | |
401 | |
402 STRING: "01234" | |
403 | |
404 BCD Note: Two digits are stored in one byte. | |
405 | |
406 +-------+-------+-------+-------+ | |
407 BCD: | 1 - 0 | 3 - 2 | F - 4 | F - F | | |
408 +-------+-------+-------+-------+ | |
409 */ | |
410 GLOBAL void cmhPHB_getAdrBcd ( UBYTE* pBcd, | |
411 UBYTE* pNumDigits, | |
412 UBYTE maxDigits, | |
413 CHAR* pStr ) | |
414 { | |
415 BOOL highNibble = FALSE; | |
416 | |
417 UBYTE bcdIdx = 0; | |
418 UBYTE strIdx; | |
419 SHORT restLen; | |
420 | |
421 UBYTE bcd; | |
422 | |
423 for(strIdx = 0; bcdIdx < maxDigits AND pStr[strIdx] NEQ '\0'; strIdx++) | |
424 { | |
425 switch ( pStr[strIdx] ) | |
426 { | |
427 case '0': | |
428 case '1': | |
429 case '2': | |
430 case '3': | |
431 case '4': | |
432 case '5': | |
433 case '6': | |
434 case '7': | |
435 case '8': | |
436 case '9': | |
437 bcd = pStr[strIdx] - '0'; | |
438 break; | |
439 | |
440 case '*': | |
441 bcd = 0x0a; | |
442 break; | |
443 | |
444 case '#': | |
445 bcd = 0x0b; | |
446 break; | |
447 | |
448 case 'w': | |
449 case 'p': | |
450 case 'W': | |
451 case 'P': | |
452 bcd = 0x0c; | |
453 break; | |
454 | |
455 case '?': | |
456 bcd = 0x0d; | |
457 break; | |
458 | |
459 case 'E': | |
460 bcd = 0x0e; | |
461 break; | |
462 | |
463 default: | |
464 continue; | |
465 } | |
466 | |
467 if ( highNibble ) | |
468 { | |
469 pBcd[bcdIdx] += ( bcd << 4 ); | |
470 bcdIdx++; | |
471 } | |
472 else | |
473 | |
474 pBcd[bcdIdx] = bcd; | |
475 | |
476 highNibble = ! highNibble; | |
477 } | |
478 | |
479 /* | |
480 *----------------------------------------------------------------- | |
481 * The last byte of the phone number is filled up with 'F' if | |
482 * necessary | |
483 *----------------------------------------------------------------- | |
484 */ | |
485 if ( highNibble ) | |
486 { | |
487 pBcd[bcdIdx] += ( PHB_CMH_INVALID_BCD_ENTRY << 4 ); | |
488 bcdIdx++; | |
489 } | |
490 | |
491 *pNumDigits = bcdIdx; | |
492 | |
493 /* | |
494 *----------------------------------------------------------------- | |
495 * The rest of the phone number is filled up with 'FF' | |
496 *----------------------------------------------------------------- | |
497 */ | |
498 restLen = maxDigits - bcdIdx; | |
499 if ( restLen > 0 ) | |
500 memset ( &pBcd[bcdIdx], | |
501 (PHB_CMH_INVALID_BCD_ENTRY << 4) + PHB_CMH_INVALID_BCD_ENTRY, | |
502 restLen ); | |
503 } | |
504 | |
505 /* | |
506 +--------------------------------------------------------------------+ | |
507 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
508 | STATE : code ROUTINE : cmhPHB_cpyRecEntr | | |
509 +--------------------------------------------------------------------+ | |
510 | |
511 PURPOSE : This function is used to copy the relevant data from the | |
512 T_PHB_RECORD structure to the T_ACI_PB_ENTR structure. | |
513 */ | |
514 GLOBAL void cmhPHB_cpyRecEntr ( T_ACI_PB_ENTR* entry, | |
515 #ifdef TI_PS_FFS_PHB | |
516 T_PHB_TYPE book, | |
517 #endif | |
518 const T_PHB_RECORD* record ) | |
519 { | |
520 #ifdef TI_PS_FFS_PHB | |
521 entry -> index = record->phy_recno; | |
522 #else | |
523 entry -> index = ( SHORT ) record -> index; | |
524 #endif | |
525 | |
526 cmhPHB_getAdrStr ( entry -> number, | |
527 MAX_PHB_NUM_LEN - 1, | |
528 record -> number, | |
529 record -> len ); | |
530 | |
531 cmhPHB_toaDmrg ( record -> ton_npi, &entry -> type ); | |
532 | |
533 cmhPHB_getMfwTagNt ( record -> tag, record -> tag_len, | |
534 entry -> text.data, &entry -> text.len ); | |
535 | |
536 entry -> text.cs = CS_Sim; | |
537 | |
538 /* Implements Measure 108, 109 */ | |
539 #ifdef TI_PS_FFS_PHB | |
540 if ( (book >= INVALID_PHB) AND (book <= MAX_PHONEBOOK) ) | |
541 { | |
542 entry -> book = ( T_ACI_PB_STOR ) cmhPHB_cvtPhbPsaType[book]; | |
543 } | |
544 #else | |
545 if ( record -> book <= MAX_PHONEBOOK ) | |
546 { | |
547 entry -> book = ( T_ACI_PB_STOR ) cmhPHB_cvtPhbPsaType[record -> book]; | |
548 } | |
549 #endif /* TI_PS_FFS_PHB */ | |
550 | |
551 cmhPHB_cpyPhbDateTime ( record, &entry -> dateTime ); | |
552 } | |
553 | |
554 /* | |
555 +--------------------------------------------------------------------+ | |
556 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
557 | STATE : code ROUTINE : cmhPHB_invldEntr | | |
558 +--------------------------------------------------------------------+ | |
559 | |
560 PURPOSE : This function is used to invalidate the elements of | |
561 a T_ACI_PB_ENTR structure. | |
562 */ | |
563 GLOBAL void cmhPHB_invldEntr ( T_ACI_PB_ENTR* entry ) | |
564 { | |
565 entry -> index = ACI_NumParmNotPresent; | |
566 entry -> number[0] = '\0'; | |
567 entry -> type.ton = TON_Unknown; | |
568 entry -> type.npi = NPI_IsdnTelephony; | |
569 entry -> text.len = 0; | |
570 entry -> book = PB_STOR_NotPresent; | |
571 | |
572 cmhPHB_invldCmhDateTime ( &entry -> dateTime); | |
573 } | |
574 | |
575 /* | |
576 +--------------------------------------------------------------------+ | |
577 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
578 | STATE : code ROUTINE : cmhPHB_getTagNt | | |
579 +--------------------------------------------------------------------+ | |
580 | |
581 PURPOSE : This function converts the actual tag in the format used | |
582 when storing it on the SIM into a null terminated string. | |
583 */ | |
584 GLOBAL void cmhPHB_getTagNt ( UBYTE* inTag, | |
585 UBYTE maxInLen, | |
586 CHAR* outTag, | |
587 UBYTE maxOutLen ) | |
588 { | |
589 UBYTE i = 0; | |
590 | |
591 while ( i < maxOutLen - 1 AND i < maxInLen AND | |
592 inTag[i] NEQ PHB_CMH_INVALID_TAG_ENTRY ) | |
593 { | |
594 /* | |
595 *----------------------------------------------------------------- | |
596 * Convert from default GSM to internal GSM alphabet | |
597 *----------------------------------------------------------------- | |
598 */ | |
599 outTag[i] = ( CHAR ) inTag[i] | 0x80; | |
600 i++; | |
601 } | |
602 | |
603 outTag[i] = '\0'; | |
604 } | |
605 | |
606 /* | |
607 +--------------------------------------------------------------------+ | |
608 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
609 | STATE : code ROUTINE : cmhPHB_getMfwTagNt | | |
610 +--------------------------------------------------------------------+ | |
611 | |
612 PURPOSE : This function copy the actual tag . | |
613 */ | |
614 GLOBAL void cmhPHB_getMfwTagNt ( const UBYTE* inTag, | |
615 UBYTE maxInLen, | |
616 UBYTE* outTag, | |
617 UBYTE* maxOutLen ) | |
618 { | |
619 UBYTE len; | |
620 | |
621 if(maxInLen EQ 0) | |
622 { | |
623 memset(outTag, 0, MAX_ALPHA_LEN); /* we need to set out tag to 0 to prevent to be recognized by UCS2 decoder */ | |
624 *maxOutLen = 0; | |
625 return; | |
626 } | |
627 | |
628 len = pb_get_entry_len(inTag, maxInLen); | |
629 | |
630 if (len >= MAX_ALPHA_LEN) | |
631 { | |
632 len = MAX_ALPHA_LEN; | |
633 } | |
634 | |
635 memcpy(outTag, inTag, len); | |
636 *maxOutLen = len; | |
637 } | |
638 | |
639 /* | |
640 +--------------------------------------------------------------------+ | |
641 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
642 | STATE : code ROUTINE : cmhPHB_getTagSim | | |
643 +--------------------------------------------------------------------+ | |
644 | |
645 PURPOSE : This function converts the actual tag as a null | |
646 terminated string in the format used when storing it on | |
647 the SIM. | |
648 */ | |
649 GLOBAL void cmhPHB_getTagSim ( T_ACI_PB_TEXT *inTag, | |
650 UBYTE *outTag, | |
651 UBYTE maxOutLen ) | |
652 { | |
653 UBYTE inLen = inTag->len; | |
654 UBYTE i = MINIMUM ( maxOutLen, inLen); | |
655 SHORT restLen = maxOutLen - inLen; | |
656 UBYTE j; | |
657 | |
658 /* | |
659 *----------------------------------------------------------------- | |
660 * Convert from internal GSM to default GSM alphabet | |
661 *----------------------------------------------------------------- | |
662 */ | |
663 for ( j = 0; j < i; j++ ) | |
664 outTag[j] = inTag->data[j] & 0x7F; | |
665 | |
666 if ( restLen > 0 ) | |
667 memset ( &outTag[i], PHB_CMH_INVALID_TAG_ENTRY, restLen); | |
668 } | |
669 | |
670 /* | |
671 +--------------------------------------------------------------------+ | |
672 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
673 | STATE : code ROUTINE : cmhPHB_getMfwTagSim | | |
674 +--------------------------------------------------------------------+ | |
675 | |
676 PURPOSE : This function converts the actual tag string in the | |
677 format used when storing it on the SIM. | |
678 */ | |
679 GLOBAL void cmhPHB_getMfwTagSim ( T_ACI_PB_TEXT* inTag, | |
680 UBYTE* outTag, | |
681 UBYTE* outTagLen, | |
682 UBYTE maxOutLen ) | |
683 { | |
684 UBYTE i = MINIMUM ( maxOutLen, inTag->len); | |
685 SHORT restLen = maxOutLen - inTag->len; | |
686 UBYTE j; | |
687 | |
688 /* | |
689 *----------------------------------------------------------------- | |
690 * Convert from internal GSM to default GSM alphabet | |
691 *----------------------------------------------------------------- | |
692 */ | |
693 for ( j = 0; j < i; j++ ) | |
694 outTag[j] = inTag->data[j]; | |
695 | |
696 *outTagLen = i; | |
697 | |
698 if ( restLen > 0 ) | |
699 memset ( &outTag[i], PHB_CMH_INVALID_TAG_ENTRY, restLen); | |
700 } | |
701 | |
702 /* | |
703 +-------------------------------------------------------------------+ | |
704 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
705 | STATE : code ROUTINE : cmhPHB_invldPhbDateTime | | |
706 +-------------------------------------------------------------------+ | |
707 | |
708 PURPOSE : This function is used to invalidate the date and time | |
709 of a phonebook entry. | |
710 */ | |
711 GLOBAL void cmhPHB_invldPhbDateTime ( T_PHB_RECORD* record ) | |
712 { | |
713 #ifdef TI_PS_FFS_PHB | |
714 record->v_time = FALSE; | |
715 | |
716 /* Backward compatibility. Setting v_time to FALSE would be sufficient */ | |
717 record->time.year = PHB_CMH_YEAR_INVLD; | |
718 record->time.month = PHB_CMH_MONTH_INVLD; | |
719 record->time.day = PHB_CMH_DAY_INVLD; | |
720 record->time.hour = PHB_CMH_HOUR_INVLD; | |
721 record->time.minute = PHB_CMH_MINUTE_INVLD; | |
722 record->time.second = PHB_CMH_SECOND_INVLD; | |
723 #else | |
724 record -> year = PHB_CMH_YEAR_INVLD; | |
725 record -> month = PHB_CMH_MONTH_INVLD; | |
726 record -> day = PHB_CMH_DAY_INVLD; | |
727 record -> hour = PHB_CMH_HOUR_INVLD; | |
728 record -> minute = PHB_CMH_MINUTE_INVLD; | |
729 record -> second = PHB_CMH_SECOND_INVLD; | |
730 #endif | |
731 } | |
732 | |
733 /* | |
734 +-------------------------------------------------------------------+ | |
735 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
736 | STATE : code ROUTINE : cmhPHB_invldCmhDateTime | | |
737 +-------------------------------------------------------------------+ | |
738 | |
739 PURPOSE : This function is used to invalidate the date and time | |
740 of a phonebook entry. | |
741 */ | |
742 GLOBAL void cmhPHB_invldCmhDateTime ( T_ACI_VP_ABS* dateTime ) | |
743 { | |
744 dateTime -> year [0] = PHB_CMH_INVALID_BCD_ENTRY; | |
745 dateTime -> year [1] = PHB_CMH_INVALID_BCD_ENTRY; | |
746 dateTime -> month [0] = PHB_CMH_INVALID_BCD_ENTRY; | |
747 dateTime -> month [1] = PHB_CMH_INVALID_BCD_ENTRY; | |
748 dateTime -> day [0] = PHB_CMH_INVALID_BCD_ENTRY; | |
749 dateTime -> day [1] = PHB_CMH_INVALID_BCD_ENTRY; | |
750 dateTime -> hour [0] = PHB_CMH_INVALID_BCD_ENTRY; | |
751 dateTime -> hour [1] = PHB_CMH_INVALID_BCD_ENTRY; | |
752 dateTime -> minute[0] = PHB_CMH_INVALID_BCD_ENTRY; | |
753 dateTime -> minute[1] = PHB_CMH_INVALID_BCD_ENTRY; | |
754 dateTime -> second[0] = PHB_CMH_INVALID_BCD_ENTRY; | |
755 dateTime -> second[1] = PHB_CMH_INVALID_BCD_ENTRY; | |
756 } | |
757 | |
758 /* | |
759 +-------------------------------------------------------------------+ | |
760 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
761 | STATE : code ROUTINE : cmhPHB_cpyCmhDateTime | | |
762 +-------------------------------------------------------------------+ | |
763 | |
764 PURPOSE : This function is used to convert the date and time used | |
765 within the command handler to the format used in the | |
766 phonebook management. | |
767 */ | |
768 GLOBAL void cmhPHB_cpyCmhDateTime ( const T_ACI_VP_ABS* dateTime, | |
769 T_PHB_RECORD* record ) | |
770 { | |
771 #ifdef TI_PS_FFS_PHB | |
772 record->time.year = (UBYTE)(dateTime -> year [0] << 4) + | |
773 dateTime -> year [1]; | |
774 record->time.month = (UBYTE)(dateTime -> month [0] << 4) + | |
775 dateTime -> month [1]; | |
776 record->time.day = (UBYTE)(dateTime -> day [0] << 4) + | |
777 dateTime -> day [1]; | |
778 record->time.hour = (UBYTE)(dateTime -> hour [0] << 4) + | |
779 dateTime -> hour [1]; | |
780 record->time.minute = (UBYTE)(dateTime -> minute[0] << 4) + | |
781 dateTime -> minute[1]; | |
782 record->time.second = (UBYTE)(dateTime -> second[0] << 4) + | |
783 dateTime -> second[1]; | |
784 record->v_time = (record->time.year NEQ 0xff); | |
785 #else | |
786 record -> year = (UBYTE)(dateTime -> year [0] << 4) + | |
787 dateTime -> year [1]; | |
788 record -> month = (UBYTE)(dateTime -> month [0] << 4) + | |
789 dateTime -> month [1]; | |
790 record -> day = (UBYTE)(dateTime -> day [0] << 4) + | |
791 dateTime -> day [1]; | |
792 record -> hour = (UBYTE)(dateTime -> hour [0] << 4) + | |
793 dateTime -> hour [1]; | |
794 record -> minute = (UBYTE)(dateTime -> minute[0] << 4) + | |
795 dateTime -> minute[1]; | |
796 record -> second = (UBYTE)(dateTime -> second[0] << 4) + | |
797 dateTime -> second[1]; | |
798 #endif | |
799 } | |
800 | |
801 /* | |
802 +-------------------------------------------------------------------+ | |
803 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
804 | STATE : code ROUTINE : cmhPHB_cpyPhbDateTime | | |
805 +-------------------------------------------------------------------+ | |
806 | |
807 PURPOSE : This function is used to convert the date and time used | |
808 within the phonebook management to the format used in | |
809 the command handler. | |
810 */ | |
811 GLOBAL void cmhPHB_cpyPhbDateTime ( const T_PHB_RECORD* record, | |
812 T_ACI_VP_ABS* dateTime ) | |
813 { | |
814 #ifdef TI_PS_FFS_PHB | |
815 dateTime -> year [0] = ( record->time.year ) >> 4; | |
816 dateTime -> year [1] = record->time.year & 0x0F; | |
817 dateTime -> month [0] = ( record->time.month ) >> 4; | |
818 dateTime -> month [1] = record->time.month & 0x0F; | |
819 dateTime -> day [0] = ( record->time.day ) >> 4; | |
820 dateTime -> day [1] = record->time.day & 0x0F; | |
821 dateTime -> hour [0] = ( record->time.hour ) >> 4; | |
822 dateTime -> hour [1] = record->time.hour & 0x0F; | |
823 dateTime -> minute[0] = ( record->time.minute ) >> 4; | |
824 dateTime -> minute[1] = record->time.minute & 0x0F; | |
825 dateTime -> second[0] = ( record->time.second ) >> 4; | |
826 dateTime -> second[1] = record->time.second & 0x0F; | |
827 #else | |
828 dateTime -> year [0] = ( record -> year ) >> 4; | |
829 dateTime -> year [1] = record -> year & 0x0F; | |
830 dateTime -> month [0] = ( record -> month ) >> 4; | |
831 dateTime -> month [1] = record -> month & 0x0F; | |
832 dateTime -> day [0] = ( record -> day ) >> 4; | |
833 dateTime -> day [1] = record -> day & 0x0F; | |
834 dateTime -> hour [0] = ( record -> hour ) >> 4; | |
835 dateTime -> hour [1] = record -> hour & 0x0F; | |
836 dateTime -> minute[0] = ( record -> minute ) >> 4; | |
837 dateTime -> minute[1] = record -> minute & 0x0F; | |
838 dateTime -> second[0] = ( record -> second ) >> 4; | |
839 dateTime -> second[1] = record -> second & 0x0F; | |
840 #endif | |
841 } | |
842 | |
843 /*==== EOF ========================================================*/ | |
844 |