comparison src/g23m-aci/aci/ati_prs.c @ 162:53929b40109c

src/g23m-aci: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2016 02:02:43 +0000
parents
children
comparison
equal deleted inserted replaced
161:4557e2a9c18e 162:53929b40109c
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-F&D (8411)
4 | Modul : ATI
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 : AT Command parameter parser
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef ATI_PRS_C
22 #define ATI_PRS_C
23
24 #include "aci_all.h"
25
26 #include <stdio.h>
27 #include <stdarg.h>
28 #include <ctype.h>
29
30 #include "aci_cmh.h"
31 #include "ati_cmd.h"
32 #include "aci_cmd.h"
33 #include "aci_prs.h"
34
35 #ifdef GPRS
36 #include "gaci_cmh.h"
37 #endif /* GPRS */
38
39 #include "aci_lst.h"
40 #include "ati_int.h"
41
42 #ifdef OPTION_RELATIVE
43 LOCAL ULONG offset;
44 #endif
45
46 static UBYTE parse_index = 0;
47 /*
48 +--------------------------------------------------------------------+
49 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
50 | STATE : code ROUTINE : parseBin |
51 +--------------------------------------------------------------------+
52
53 PURPOSE : parse binary value
54
55 */
56
57 GLOBAL char *parseBin (int digits, char *b, SHORT *i)
58 {
59 int found = 0;
60
61 *i = 0;
62 while (digits-- AND *b >= '0' AND *b <= '1')
63 {
64 found++;
65 *i *= 2;
66 *i += *b - '0';
67 b++;
68 }
69
70 return ((found) ? b : 0);
71 }
72
73
74 /*
75 +--------------------------------------------------------------------+
76 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
77 | STATE : code ROUTINE : parseHex |
78 +--------------------------------------------------------------------+
79
80 PURPOSE : parse hexadecimal value
81
82 */
83
84 GLOBAL char *parseHex (int digits, char *b, UBYTE *i)
85 {
86 int found = 0;
87
88 *i = 0;
89 while (digits-- AND ((*b >= '0' AND *b <= '9') OR
90 (*b >= 'a' AND *b <= 'f') OR
91 (*b >= 'A' AND *b <= 'F')))
92 {
93 found++;
94 *i *= 16;
95 if (*b >= '0' AND *b <= '9')
96 *i += *b - '0';
97 if (*b >= 'a' AND *b <= 'f')
98 *i += *b - 'a' + 10;
99 if (*b >= 'A' AND *b <= 'F')
100 *i += *b - 'A' + 10;
101 b++;
102 }
103
104 return ((found AND found <= 2) ? b : 0);
105 }
106
107 /*
108 +--------------------------------------------------------------------+
109 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
110 | STATE : code ROUTINE : parseHexToLong |
111 +--------------------------------------------------------------------+
112
113 PURPOSE : parse hexadecimal value
114
115 */
116
117 GLOBAL char *parseHexToLong (int digits, char *b, LONG *i)
118 {
119 *i = 0;
120 while (digits-- AND ((*b >= '0' AND *b <= '9') OR
121 (*b >= 'a' AND *b <= 'f') OR
122 (*b >= 'A' AND *b <= 'F')))
123 {
124 *i *= 16;
125 if (*b >= '0' AND *b <= '9')
126 *i += *b - '0';
127 if (*b >= 'a' AND *b <= 'f')
128 *i += *b - 'a' + 10;
129 if (*b >= 'A' AND *b <= 'F')
130 *i += *b - 'A' + 10;
131 b++;
132 }
133
134 return ( digits EQ 0 ? 0 : b );
135 }
136
137 /*
138 +--------------------------------------------------------------------+
139 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
140 | STATE : code ROUTINE : parseEnum |
141 +--------------------------------------------------------------------+
142
143 PURPOSE : parse enum value
144
145 */
146
147 GLOBAL char *parseEnum (int digits, char *b, int *i)
148 {
149 int found = 0;
150
151 *i = 0;
152 while (digits-- AND *b >= '0' AND *b <= '9')
153 {
154 found++;
155 *i *= 10;
156 *i += *b - '0';
157 b++;
158 }
159
160 return ((found) ? b : 0);
161 }
162
163 /*
164 +--------------------------------------------------------------------+
165 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
166 | STATE : code ROUTINE : parseShort |
167 +--------------------------------------------------------------------+
168
169 PURPOSE : parse Short value
170
171 */
172
173 GLOBAL char *parseShort (int digits, char *b, SHORT *i)
174 {
175 int found = 0;
176
177 *i = 0;
178 while (digits-- AND *b >= '0' AND *b <= '9')
179 {
180 found++;
181 *i *= 10;
182 *i += *b - '0';
183 b++;
184 }
185
186 return ((found) ? b : 0);
187 }
188
189 /*
190 +--------------------------------------------------------------------+
191 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
192 | STATE : code ROUTINE : parseStr |
193 +--------------------------------------------------------------------+
194
195 PURPOSE : parse string value
196
197 */
198
199 GLOBAL char *parseStr (int digits, char *b, char *s)
200 {
201 int found = 0;
202
203 *s = 0;
204 if (*b NEQ '"')
205 return 0;
206 b++;
207 while (digits-- AND *b AND *b >= 0x20)
208 {
209 found++;
210 if (*b EQ '"')
211 {
212 *s = 0;
213 b++;
214 break;
215 }
216 if (*b EQ '\\')
217 {
218 b = parseHex(2,b+1,(UBYTE *) s); /* ES!! ZERO ? */
219 if (!b)
220 return 0;
221 s++;
222 }
223 else
224 *s++ = *b++;
225 }
226 if(*(b-1) NEQ '"')
227 return 0;
228 *s = 0; /* zero terminated */
229
230 return ((found) ? b : 0);
231 }
232
233 /*
234 +--------------------------------------------------------------------+
235 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
236 | STATE : code ROUTINE : parseZStr |
237 +--------------------------------------------------------------------+
238
239 PURPOSE : parse string value
240
241 */
242
243 GLOBAL char *parseZStr (int digits, char *b, char *s)
244 {
245 int found = 0;
246
247 *s = 0;
248 if (*b NEQ '"')
249 return 0;
250 b++;
251 while (digits--)
252 {
253 found++;
254 if (*b EQ '"')
255 {
256 *s = 0;
257 b++;
258 break;
259 }
260 if (*b EQ '\\')
261 {
262 b = parseHex(2,b+1,(UBYTE *) s); /* ES!! ZERO ? */
263 if (!b)
264 return 0;
265 s++;
266 }
267 else
268 *s++ = *b++;
269 }
270 if(*(b-1) NEQ '"')
271 return 0;
272 *s = 0; /* zero terminated */
273
274 return ((found) ? b : 0);
275 }
276
277 /*
278 +--------------------------------------------------------------------+
279 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
280 | STATE : code ROUTINE : parseNStr |
281 +--------------------------------------------------------------------+
282
283 PURPOSE : parse string value and if not numeric returns error
284
285 */
286
287 GLOBAL char *parseNStr (int digits, char *b, char *s)
288 {
289 int found = 0;
290
291 *s = 0;
292 if (*b NEQ '"')
293 return 0;
294 b++;
295 while (digits-- AND *b AND *b >= 0x20)
296 {
297 found++;
298 if (*b EQ '"')
299 {
300 *s = 0;
301 b++;
302 break;
303 }
304 if (*b EQ '\\')
305 {
306 b = parseHex(2,b+1,(UBYTE *) s); /* ES!! ZERO ? */
307 if (!b)
308 return 0;
309 s++;
310 }
311 if ( *b > '9' OR *b < '0') return 0; /*check if numeric value*/
312 else
313 *s++ = *b++;
314 }
315 if(*(b-1) NEQ '"')
316 return 0;
317 *s = 0; /* zero terminated */
318
319 return ((found) ? b : 0);
320 }
321
322 /*
323 +--------------------------------------------------------------------+
324 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
325 | STATE : code ROUTINE : parseASCII |
326 +--------------------------------------------------------------------+
327
328 PURPOSE : parse ASCII value
329
330 */
331
332 GLOBAL char *parseASCII (int digits, char *b, char *i)
333 {
334 int found = 0;
335
336 *i = 0;
337 while (digits-- AND *b NEQ ' ' AND *b NEQ ',' AND *b NEQ ';' )
338 {
339 found++;
340 *i = *b;
341 i++;
342 b++;
343 }
344
345 return ((found) ? b : 0);
346 }
347
348 /*
349 +--------------------------------------------------------------------+
350 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
351 | STATE : code ROUTINE : parseQASCII |
352 +--------------------------------------------------------------------+
353
354 PURPOSE : parse ASCII value and terminate with 0
355
356 */
357
358 GLOBAL char *parseQASCII (int digits, char *b, char *i)
359 {
360 int found = 0;
361
362 *i = 0;
363 while (digits-- AND *b NEQ ',' AND *b NEQ ';' AND *b NEQ '\0')
364 {
365 found++;
366 *i = *b;
367 i++;
368 b++;
369 }
370
371 if (found)
372 {
373 *i = 0;
374 return (b);
375 }
376
377 return (NULL);
378 }
379
380
381 /*
382 +--------------------------------------------------------------------+
383 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
384 | STATE : code ROUTINE : parseStrLen |
385 +--------------------------------------------------------------------+
386
387 PURPOSE : parse sting, return length and startpoint
388
389 */
390
391 GLOBAL char *parseStrLen (USHORT *len, char *b, char **p)
392 {
393 *len = 0;
394 if( *b EQ '"' )
395 b++;
396
397 /* Check if the string is a null string like "" */
398 if( *b EQ '"' )
399 {
400 b++;
401
402 /* return new buffer position without setting p, thereby omitting the parameter */
403 return b;
404 }
405
406 *p = b;
407
408 while ( *b NEQ '\0' AND *b NEQ ',' AND *b NEQ ';' AND *b NEQ '"' )
409 {
410 (*len)++;
411 b++;
412 }
413
414 if(*b EQ '"')
415 {
416 b++;
417 }
418
419 return ((*len) ? b : 0);
420 }
421
422
423 #ifdef GPRS
424
425 /*
426 +--------------------------------------------------------------------+
427 | PROJECT : UMTS MODULE : ACI_PRS |
428 | STATE : devellopment ROUTINE : parseExpo |
429 +--------------------------------------------------------------------+
430
431 PURPOSE : parse exponential expresion (ex. 2E3)
432
433 */
434
435 GLOBAL char *parseExpo( int digits, char *b, T_PS_ber *e )
436 {
437 BOOL valid = FALSE;
438
439 e->ratio_mant = 0;
440 e->ratio_exp = 0;
441 if( *b EQ '"' ) /* start of string */
442 {
443 b++;
444 while( digits-- AND *b >= '0' AND *b <= '9' )
445 {
446 e->ratio_mant *= 10;
447 e->ratio_mant += *b - '0';
448 b++;
449 }
450 if( *b EQ 'E' )
451 {
452 b++;
453 while( digits-- AND *b >= '0' AND *b <= '9' )
454 {
455 e->ratio_exp *= 10;
456 e->ratio_exp += *b - '0';
457 b++;
458 valid = TRUE;
459 }
460
461 if( *b EQ '"' ) /* end of string */
462 {
463 b++;
464 }
465 else
466 {
467 valid = FALSE;
468 }
469
470 }
471 else
472 {
473 valid = FALSE;
474 }
475 }
476 else
477 {
478 valid = FALSE;
479 }
480
481 return ((valid) ? b : 0);
482
483 } /* END parseExpo(...) */
484
485 /*
486 +--------------------------------------------------------------------+
487 | PROJECT : UMTS MODULE : ACI_PRS |
488 | STATE : Finished ROUTINE : parseCid_list |
489 +--------------------------------------------------------------------+
490
491 PURPOSE : Parse a list of Cids. If the parsing is sucessfull the
492 number of parsed cids is returned otherwise -1 is returned.
493
494 */
495 GLOBAL char *parseCid_list(char *b, U8 *cid_list_length, U8 *cid_list)
496 {
497 U8 no_of_cids;
498 char *end;
499
500 /* Parse all cids into the cid_list */
501 no_of_cids = 0;
502 do
503 {
504
505 /* If it's not the first cid remove the "," */
506 if( no_of_cids )
507 b++;
508
509 /* Set the entry to omitted. */
510 cid_list[no_of_cids] = PDP_CONTEXT_CID_OMITTED;
511
512 /* Parse the value */
513 cid_list[no_of_cids] = (U8) strtol( b, &end, 10 );
514 b = end;
515
516 /* If a cid is omitted no cids must be specified at all. */
517 if( cid_list[no_of_cids] EQ PDP_CONTEXT_CID_OMITTED )
518 {
519 if( no_of_cids NEQ 0 )
520 {
521 /* Don't accept omitted cids inside if it's not the first (ex. 1,,2,3 is not allowed). */
522 cmdCmeError( CME_ERR_OpNotSupp );
523 return( NULL );
524 }
525 /* Break the while */
526 break;
527 }
528 if( (!b) OR
529 (cid_list[no_of_cids] < PDP_CONTEXT_CID_MIN) OR
530 (cid_list[no_of_cids] > PDP_CONTEXT_CID_MAX) OR
531 (no_of_cids >= PDP_CONTEXT_CID_MAX) )
532 {
533 cmdCmeError( CME_ERR_OpNotSupp );
534 return( NULL );
535 }
536 no_of_cids++;
537 }
538
539 while( *b EQ ',' AND
540 no_of_cids < *cid_list_length );
541
542 cid_list[no_of_cids+1] = PDP_CONTEXT_CID_INVALID;
543
544 *cid_list_length = no_of_cids;
545 return( b );
546
547 }
548
549 #endif /* GPRS */
550
551 /*
552 +----------------------------------------------------------------------+
553 | PROJECT : UMTS MODULE : ATI_PRS |
554 | STATE : - ROUTINE : parsePointerToString |
555 -----------------------------------------------------------------------+
556
557 PURPOSE : Parse pointer to input string. returns pointer to end of string.
558
559 */
560 GLOBAL char *parsePointerToString(char chars, char *b, char **p_begin)
561 {
562 if( b AND *b EQ '"' )
563 {
564 b++;
565 *p_begin = b;
566
567 while (chars-- AND *b AND *b NEQ '"')
568 {
569 b++;
570 }
571 if( *b EQ '"' )
572 {
573 b++;
574 }
575 else
576 {
577 if( !chars )
578 {
579 b = NULL;
580 }
581 }
582 }
583
584 return b;
585 }
586
587 /*
588 +----------------------------------------------------------------------+
589 | PROJECT : UMTS MODULE : ATI_PRS |
590 | STATE : - ROUTINE : StrToU16 |
591 -----------------------------------------------------------------------+
592
593 PURPOSE : Parse string value to U16.
594
595 */
596
597 char *StrToU16(char *p_str, U16 *p_result)
598 {
599 U32 val = 0;
600
601 if( p_str )
602 {
603 if( *p_str >= '0' AND *p_str <= '9' )
604 {
605 while( *p_str >= '0' AND *p_str <= '9' )
606 {
607 val *= 10;
608 val += (int)(*p_str - '0');
609 p_str++;
610 }
611 }
612 }
613
614 if( val <= 0xffff ) /* 0xffff = max value of U16 */
615 *p_result = (U16)(val);
616 else
617 p_str = NULL;
618
619 return p_str;
620
621 }
622
623 /*
624 +---------------------------------------------------------------------+
625 | PROJECT : UMTS MODULE : ATI_PRS |
626 | STATE : - ROUTINE : parseDSNP_U16 |
627 ----------------------------------------------------------------------+
628
629 PURPOSE : parse dot-separated numeric parameters from the
630 input string to an array of U8.
631
632 ex. input p_in = "192.124.13.3"
633 output p_out = {192,124,13,3}
634
635 */
636 GLOBAL char *parseDSNP_U16( char blocks, char *p_in, U16 *p_out )
637 {
638 if( p_in AND p_out )
639 {
640 if( *p_in EQ '.' ) p_in++;
641 while( blocks-- AND *p_in NEQ 0x00 )
642 {
643 p_in = StrToU16(p_in, p_out);
644
645 if( p_in AND blocks AND *p_in EQ '.' )
646 {
647 p_in++;
648 p_out++;
649 }
650 else
651 break;
652 }
653 }
654 return p_in;
655 }
656
657 /*
658 +---------------------------------------------------------------------+
659 | PROJECT : UMTS MODULE : ATI_PRS |
660 | STATE : - ROUTINE : parseIPv4Address |
661 ----------------------------------------------------------------------+
662 */
663 GLOBAL char *parseIPv4Address(char *p_in, U8 * p_ip_addr, U8 * is_ip_valid)
664 {
665 U16 ip_addr[4];
666 char i;
667 char *p_out = NULL;
668
669 if( p_in AND p_ip_addr )
670 {
671 p_out = parseDSNP_U16(4, p_in, ip_addr);
672 for(i=0; i<4; i++)
673 {
674 if(ip_addr[i] <= 255)
675 {
676 p_ip_addr[i] = (U8) ip_addr[i];
677 }
678 else
679 {
680 p_out = NULL;
681 }
682
683 }
684 }
685 * is_ip_valid = (p_out NEQ NULL);
686
687 return p_out;
688 }
689
690 /*
691 +---------------------------------------------------------------------+
692 | PROJECT : UMTS MODULE : ATI_PRS |
693 | STATE : - ROUTINE : parseIPv6Address |
694 ----------------------------------------------------------------------+
695 */
696 GLOBAL char *parseIPv6Address(char *p_in, U8 *p_ip_addr, U8 * is_ip_valid)
697 {
698 U16 ip_addr[16];
699 char i;
700 char *p_out = NULL;
701
702 if( p_in AND p_ip_addr )
703 {
704 p_out = parseDSNP_U16(16, p_in, ip_addr);
705 for(i=0; i<16; i++)
706 {
707 if(ip_addr[i] > 255)
708 p_out = NULL;
709 else
710 p_ip_addr[i] = (U8) ip_addr[i];
711 }
712 }
713
714 * is_ip_valid = (p_out NEQ NULL);
715
716 return p_out;
717 }
718
719 /*
720 +--------------------------------------------------------------------+
721 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
722 | STATE : code ROUTINE : parse |
723 +--------------------------------------------------------------------+
724
725 PURPOSE : parse AT command parameter
726
727 */
728
729 GLOBAL char *parse (char *b, char *f, ...)
730 {
731 char fc;
732 USHORT *i;
733
734 #ifdef GPRS
735 U8 *j;
736 #endif /* GPRS */
737 LONG digits = -1;
738 BOOL value_is_valid;
739 /*lint -e516 -e10*/
740 va_list varpars;
741
742 va_start (varpars, f); /* Initialize variable arguments. */
743
744 parse_index=0;
745 while ((fc = *f++) NEQ 0)
746 {
747 parse_index++; /* Save the position of current parsing item */
748 value_is_valid = TRUE;
749 if (islower(fc))
750 {
751 if (*b EQ 0 OR *b EQ ';')
752 {
753 va_end (varpars); /* Reset variable arguments. */
754 return b;
755 }
756 if (*b EQ ',')
757 {
758 b++;
759 value_is_valid = FALSE;
760 }
761 }
762
763 switch (toupper(fc))
764 {
765 case 'B':
766 if (value_is_valid)
767 b = parseBin(-1,b,va_arg (varpars, short*));
768 else
769 (void)va_arg (varpars, short*);
770 break;
771
772 case 'X':
773 if (value_is_valid)
774 b = parseHex(-1,b,va_arg (varpars, unsigned char*));
775 else
776 (void)va_arg (varpars, short*);
777 break;
778
779 case 'Y':
780 if (value_is_valid)
781 b = parseHexToLong(-1,b,va_arg (varpars, long*));
782 else
783 (void)va_arg (varpars, short*);
784 break;
785
786 case 'D':
787 if (value_is_valid)
788 b = parseEnum(-1,b,va_arg (varpars, int*));
789 else
790 (void)va_arg (varpars, int*);
791 break;
792
793 case 'R':
794 if (value_is_valid)
795 b = parseShort(-1,b,va_arg (varpars, short*));
796 else
797 (void)va_arg (varpars, short*);
798 break;
799
800 case 'S':
801 if (value_is_valid)
802 {
803 digits=va_arg (varpars, long);
804 b = parseStr(digits,b,va_arg (varpars, char*));
805 }
806 else
807 {
808 (void)va_arg (varpars, long);
809 (void)va_arg (varpars, char*);
810 }
811 break;
812
813 case 'N':
814 if (value_is_valid)
815 {
816 digits=va_arg (varpars, long);
817 b = parseNStr(digits,b,va_arg (varpars, char*));
818 }
819 else
820 {
821 (void)va_arg (varpars, long);
822 (void)va_arg (varpars, char*);
823 }
824 break;
825
826 case 'Z':
827 if (value_is_valid)
828 {
829 char* c = b;
830 USHORT* plen = NULL;
831
832 char* cmdPtr;
833 USHORT cmdLen;
834
835 digits = va_arg ( varpars, long );
836 cmdLen = va_arg ( varpars, unsigned );
837 cmdPtr = va_arg ( varpars, char* );
838 plen = va_arg ( varpars, unsigned short*);
839 b = parseZStr
840 ( MINIMUM (digits, cmdLen - ( b - cmdPtr )),
841 b, va_arg ( varpars, char* ) );
842
843 if ( plen NEQ NULL )
844 {
845 if ( b NEQ NULL )
846 *plen = b - c - 2; /* a string always includes two characters '"' */
847 else
848 *plen = 0;
849 }
850 }
851 else
852 {
853 (void)va_arg (varpars, long);
854 (void)va_arg (varpars, unsigned short*);
855 (void)va_arg (varpars, char*);
856 }
857 break;
858
859 case 'A':
860 if (value_is_valid)
861 {
862 digits=va_arg (varpars, long);
863 b = parseASCII(digits,b,va_arg (varpars, char*));
864 }
865 else
866 {
867 (void)va_arg (varpars, long);
868 (void)va_arg (varpars, char*);
869 }
870 break;
871
872 case 'Q':
873 if (value_is_valid)
874 {
875 digits=va_arg (varpars, long);
876 b = parseQASCII(digits,b,va_arg (varpars, char*));
877 }
878 else
879 {
880 (void)va_arg (varpars, long);
881 (void)va_arg (varpars, char*);
882 }
883 break;
884
885 case 'L':
886 if (value_is_valid)
887 {
888 i = va_arg(varpars, unsigned short*);
889 b = parseStrLen (i,b,va_arg(varpars, char**));
890 }
891 else
892 {
893 (void)va_arg (varpars, int*);
894 (void)va_arg (varpars, char**);
895 }
896 break;
897
898 #ifdef GPRS
899
900 case 'E':
901 if (value_is_valid)
902 {/*lint -e78 -e26 -e530*/
903 b = parseExpo( -1, b, va_arg(varpars, T_PS_ber*));
904 }
905 else
906 {
907 (void)va_arg (varpars, T_PS_ber*);
908 }
909 break;
910
911 #endif
912
913 case 'C':
914 if (value_is_valid)
915 {
916 b = parseByte( -1, b, va_arg(varpars, unsigned char*));
917 }
918 else
919 {
920 (void)va_arg (varpars, unsigned char*);
921 }
922 break;
923
924 #ifdef GPRS
925
926 case 'I': /* Parse cid_list */
927 if( value_is_valid )
928 {
929 j = va_arg(varpars, unsigned char*);
930
931 b = parseCid_list( b, j, va_arg(varpars, unsigned char*) );
932 }
933 break;
934 #endif /* GPRS */
935
936 case 'P': /* Parse pointer to string */
937 if( value_is_valid )
938 {
939 b = parsePointerToString( (char)-1, b, va_arg(varpars, char**) );
940 }
941 break;
942
943 case '*': /* Parse '*' */
944 if( value_is_valid )
945 {
946 if( *b NEQ '*' )
947 {
948 return 0;
949 }
950 b++;
951 }
952 break;
953
954 case '#': /* Parse '#' */
955 if( value_is_valid )
956 {
957 if( *b NEQ '#' )
958 {
959 return 0;
960 }
961 b++;
962 }
963 break;
964 }
965 if (!b)
966 {
967 va_end (varpars); /* Reset variable arguments. */
968 return 0;
969 }
970
971 if (*f AND *b EQ ',' AND value_is_valid)
972 {
973 b++;
974 }
975 else if (*b AND *b NEQ ';' AND *b NEQ ',' AND value_is_valid) /* if comma or semicolon is missing */
976 {
977 TRACE_EVENT ("missing separator detected, aborting parse!");
978 va_end (varpars);
979 return 0;
980 }
981 }
982 if (*b AND *b NEQ ';')
983 {
984 va_end (varpars); /* Reset variable arguments. */
985 return 0;
986 }
987 va_end (varpars); /* Reset variable arguments. */
988 /*lint +e516 +e10*/
989 return b;
990 }
991
992
993 /*
994 +--------------------------------------------------------------------+
995 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
996 | STATE : code ROUTINE : parse |
997 +--------------------------------------------------------------------+
998
999 PURPOSE : get last parsed index (to determinate which component was malicious)
1000
1001 */
1002
1003 GLOBAL UBYTE get_parse_index ()
1004 {
1005 return parse_index;
1006 }
1007
1008 /*
1009 +--------------------------------------------------------------------+
1010 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
1011 | STATE : code ROUTINE : parseByte(U8) |
1012 +--------------------------------------------------------------------+
1013
1014 PURPOSE : parse U8 value
1015
1016 */
1017
1018 GLOBAL char *parseByte (int digits, char *b, U8 *i)
1019 {
1020 int found = 0;
1021
1022 *i = 0;
1023 while (digits-- AND *b >= '0' AND *b <= '9')
1024 {
1025 found++;
1026 *i *= 10;
1027 *i += *b - '0';
1028 b++;
1029 }
1030
1031 return ((found) ? b : 0);
1032 }
1033
1034 /*
1035 +--------------------------------------------------------------------+
1036 | PROJECT : GSM-F&D (8411) MODULE : ACI_PRS |
1037 | STATE : code ROUTINE : parseTimeStamp |
1038 +--------------------------------------------------------------------+
1039
1040 PURPOSE : Parse time stamp format in "yy/MM/dd,hh:mm:ss±zz"
1041
1042 */
1043
1044 GLOBAL UBYTE parseTimeStamp( char *p_in,U8 *years,U8 *months,U8 *days,
1045 U8 *hrs, U8 *mins,U8 *secs, char *sign, U8 *time_zone )
1046 {
1047 if( p_in[2] NEQ '/' OR p_in[5] NEQ '/' OR p_in[8] NEQ ',' OR p_in[11] NEQ ':' OR p_in[14] NEQ ':' )
1048 {
1049 return NO_TIME_STAMP_FIELD;
1050 }
1051 if(!parseByte (2, &p_in[0], years))
1052 {
1053 return NO_TIME_STAMP_FIELD;
1054 }
1055 if(!parseByte (2, &p_in[3], months))
1056 {
1057 return NO_TIME_STAMP_FIELD;
1058 }
1059 if(!parseByte (2, &p_in[6], days))
1060 {
1061 return NO_TIME_STAMP_FIELD;
1062 }
1063 if(!parseByte (2, &p_in[9], hrs))
1064 {
1065 return NO_TIME_STAMP_FIELD;
1066 }
1067 if(!parseByte (2, &p_in[12], mins))
1068 {
1069 return NO_TIME_STAMP_FIELD;
1070 }
1071 if(!parseByte (2, &p_in[15], secs))
1072 {
1073 return NO_TIME_STAMP_FIELD;
1074 }
1075 *sign = p_in[17];
1076
1077 if(*sign NEQ '+' AND *sign NEQ '-' )
1078 {
1079 return NO_TIME_STAMP_FIELD;
1080 }
1081 if(!parseByte (2, &p_in[18], time_zone))
1082 {
1083 return NO_TIME_STAMP_FIELD;
1084 }
1085
1086 return MAX_TIME_STAMP_FIELDS;
1087 }
1088
1089 #endif /* ATI_PRS_C */