~ubuntu-branches/debian/squeeze/libmusclecard/squeeze

« back to all changes in this revision

Viewing changes to src/tokenparser.c

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Rousseau
  • Date: 2009-05-01 18:34:32 UTC
  • mfrom: (1.2.1 upstream) (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090501183432-hl0bvuaol8zej369
Tags: 1.3.6-1
* new upstream release
 - Fix "FTBFS: musclecard.c:1384: error: conflicting types for
   'MSCCreateObject'" fixed upstream (Closes: #526498)

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
#define FLEX_SCANNER
9
9
#define YY_FLEX_MAJOR_VERSION 2
10
10
#define YY_FLEX_MINOR_VERSION 5
11
 
#define YY_FLEX_SUBMINOR_VERSION 33
 
11
#define YY_FLEX_SUBMINOR_VERSION 35
12
12
#if YY_FLEX_SUBMINOR_VERSION > 0
13
13
#define FLEX_BETA
14
14
#endif
30
30
 
31
31
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
32
32
 
33
 
#if __STDC_VERSION__ >= 199901L
 
33
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
34
34
 
35
35
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
36
36
 * if you want the limit (max/min) macros for int types. 
53
53
typedef unsigned char flex_uint8_t; 
54
54
typedef unsigned short int flex_uint16_t;
55
55
typedef unsigned int flex_uint32_t;
56
 
#endif /* ! C99 */
57
56
 
58
57
/* Limits of integral types. */
59
58
#ifndef INT8_MIN
84
83
#define UINT32_MAX             (4294967295U)
85
84
#endif
86
85
 
 
86
#endif /* ! C99 */
 
87
 
87
88
#endif /* ! FLEXINT_H */
88
89
 
89
90
#ifdef __cplusplus
93
94
 
94
95
#else   /* ! __cplusplus */
95
96
 
96
 
#if __STDC__
 
97
/* C99 requires __STDC__ to be defined as 1. */
 
98
#if defined (__STDC__)
97
99
 
98
100
#define YY_USE_CONST
99
101
 
100
 
#endif  /* __STDC__ */
 
102
#endif  /* defined (__STDC__) */
101
103
#endif  /* ! __cplusplus */
102
104
 
103
105
#ifdef YY_USE_CONST
139
141
 
140
142
/* Size of default input buffer. */
141
143
#ifndef YY_BUF_SIZE
 
144
#ifdef __ia64__
 
145
/* On IA-64, the buffer size is 16k, not 8k.
 
146
 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
 
147
 * Ditto for the __ia64__ case accordingly.
 
148
 */
 
149
#define YY_BUF_SIZE 32768
 
150
#else
142
151
#define YY_BUF_SIZE 16384
 
152
#endif /* __ia64__ */
143
153
#endif
144
154
 
145
155
/* The state buf must be large enough to hold one state per character in the main buffer.
177
187
 
178
188
#define unput(c) yyunput( c, (yytext_ptr)  )
179
189
 
180
 
/* The following is because we cannot portably get our hands on size_t
181
 
 * (without autoconf's help, which isn't available because we want
182
 
 * flex-generated scanners to compile on their own).
183
 
 */
184
 
 
185
190
#ifndef YY_TYPEDEF_YY_SIZE_T
186
191
#define YY_TYPEDEF_YY_SIZE_T
187
 
typedef unsigned int yy_size_t;
 
192
typedef size_t yy_size_t;
188
193
#endif
189
194
 
190
195
#ifndef YY_STRUCT_YY_BUFFER_STATE
335
340
 
336
341
/* Begin user sect3 */
337
342
 
338
 
#define yywrap() 1
 
343
#define yywrap(n) 1
339
344
#define YY_SKIP_YYWRAP
340
345
 
341
346
typedef unsigned char YY_CHAR;
485
490
 *  David Corcoran <corcoran@linuxnet.com>
486
491
 *  Ludovic Rousseau <ludovic.rousseau@free.fr>
487
492
 *
488
 
 * $Id: tokenparser.l 1960 2006-03-21 15:57:38Z rousseau $
 
493
 * $Id: tokenparser.l 3247 2009-01-02 13:22:46Z rousseau $
489
494
 */
490
495
/**
491
496
 * @file
506
511
 
507
512
void tpevalToken(char *pcToken, int tokType);
508
513
 
509
 
static char *pcDesiredKey = 0;
 
514
static const char *pcDesiredKey = NULL;
510
515
static char pcKey[TOKEN_MAX_KEY_SIZE];
511
516
static char pcValue[TOKEN_MAX_VALUE_SIZE];
512
517
static char pcFinValue[TOKEN_MAX_VALUE_SIZE];
515
520
 
516
521
void tperrorCheck (char *pcToken_error);
517
522
 
518
 
#line 519 "tokenparser.c"
 
523
#line 524 "tokenparser.c"
519
524
 
520
525
#define INITIAL 0
521
526
 
533
538
 
534
539
static int yy_init_globals (void );
535
540
 
 
541
/* Accessor methods to globals.
 
542
   These are made visible to non-reentrant scanners for convenience. */
 
543
 
 
544
int yylex_destroy (void );
 
545
 
 
546
int yyget_debug (void );
 
547
 
 
548
void yyset_debug (int debug_flag  );
 
549
 
 
550
YY_EXTRA_TYPE yyget_extra (void );
 
551
 
 
552
void yyset_extra (YY_EXTRA_TYPE user_defined  );
 
553
 
 
554
FILE *yyget_in (void );
 
555
 
 
556
void yyset_in  (FILE * in_str  );
 
557
 
 
558
FILE *yyget_out (void );
 
559
 
 
560
void yyset_out  (FILE * out_str  );
 
561
 
 
562
int yyget_leng (void );
 
563
 
 
564
char *yyget_text (void );
 
565
 
 
566
int yyget_lineno (void );
 
567
 
 
568
void yyset_lineno (int line_number  );
 
569
 
536
570
/* Macros after this point can all be overridden by user definitions in
537
571
 * section 1.
538
572
 */
565
599
 
566
600
/* Amount of stuff to slurp up with each read. */
567
601
#ifndef YY_READ_BUF_SIZE
 
602
#ifdef __ia64__
 
603
/* On IA-64, the buffer size is 16k, not 8k */
 
604
#define YY_READ_BUF_SIZE 16384
 
605
#else
568
606
#define YY_READ_BUF_SIZE 8192
 
607
#endif /* __ia64__ */
569
608
#endif
570
609
 
571
610
/* Copy whatever the last rule matched to the standard output. */
573
612
/* This used to be an fputs(), but since the string might contain NUL's,
574
613
 * we now use fwrite().
575
614
 */
576
 
#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
 
615
#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
577
616
#endif
578
617
 
579
618
/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
669
708
#line 47 "tokenparser.l"
670
709
 
671
710
 
672
 
#line 673 "tokenparser.c"
 
711
#line 712 "tokenparser.c"
673
712
 
674
713
        if ( !(yy_init) )
675
714
                {
788
827
#line 55 "tokenparser.l"
789
828
ECHO;
790
829
        YY_BREAK
791
 
#line 792 "tokenparser.c"
 
830
#line 831 "tokenparser.c"
792
831
case YY_STATE_EOF(INITIAL):
793
832
        yyterminate();
794
833
 
1019
1058
 
1020
1059
                /* Read in more data. */
1021
1060
                YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1022
 
                        (yy_n_chars), num_to_read );
 
1061
                        (yy_n_chars), (size_t) num_to_read );
1023
1062
 
1024
1063
                YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1025
1064
                }
1043
1082
        else
1044
1083
                ret_val = EOB_ACT_CONTINUE_SCAN;
1045
1084
 
 
1085
        if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
 
1086
                /* Extend the array by 50%, plus the number we really need. */
 
1087
                yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
 
1088
                YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
 
1089
                if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
 
1090
                        YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
 
1091
        }
 
1092
 
1046
1093
        (yy_n_chars) += number_to_move;
1047
1094
        YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1048
1095
        YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1421
1468
                (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1422
1469
                                                                (num_to_alloc * sizeof(struct yy_buffer_state*)
1423
1470
                                                                );
1424
 
                
 
1471
                if ( ! (yy_buffer_stack) )
 
1472
                        YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
 
1473
                                                                  
1425
1474
                memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1426
1475
                                
1427
1476
                (yy_buffer_stack_max) = num_to_alloc;
1439
1488
                                                                ((yy_buffer_stack),
1440
1489
                                                                num_to_alloc * sizeof(struct yy_buffer_state*)
1441
1490
                                                                );
 
1491
                if ( ! (yy_buffer_stack) )
 
1492
                        YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1442
1493
 
1443
1494
                /* zero only the new slots.*/
1444
1495
                memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1497
1548
 
1498
1549
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1499
1550
 * scan from a @e copy of @a bytes.
1500
 
 * @param bytes the byte buffer to scan
1501
 
 * @param len the number of bytes in the buffer pointed to by @a bytes.
 
1551
 * @param yybytes the byte buffer to scan
 
1552
 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1502
1553
 * 
1503
1554
 * @return the newly allocated buffer state object.
1504
1555
 */
1744
1795
 
1745
1796
void tpevalToken(char *pcToken, int tokType)
1746
1797
{
1747
 
        int len;
 
1798
        unsigned int len;
1748
1799
        len = 0;
1749
1800
 
1750
1801
        if (tokType == TOKEN_TYPE_KEY)
1758
1809
                len++;  /* final NULL byte */
1759
1810
 
1760
1811
                if (len > sizeof(pcKey))
1761
 
                        strlcpy(pcKey, &pcToken[5], sizeof(pcKey));
 
1812
                        (void)strlcpy(pcKey, &pcToken[5], sizeof(pcKey));
1762
1813
                else
1763
 
                        strlcpy(pcKey, &pcToken[5], len);
 
1814
                        (void)strlcpy(pcKey, &pcToken[5], len);
1764
1815
        }
1765
1816
 
1766
1817
        if (tokType == TOKEN_TYPE_STRING)
1774
1825
                len++;  /* final NULL byte */
1775
1826
 
1776
1827
                if (len > sizeof(pcValue))
1777
 
                        strlcpy(pcValue, &pcToken[8], sizeof(pcValue));
 
1828
                        (void)strlcpy(pcValue, &pcToken[8], sizeof(pcValue));
1778
1829
                else
1779
 
                        strlcpy(pcValue, &pcToken[8], len);
 
1830
                        (void)strlcpy(pcValue, &pcToken[8], len);
1780
1831
 
1781
1832
                if (strcmp(pcKey, pcDesiredKey) == 0)
1782
1833
                        if (desiredIndex == valueIndex)
1783
 
                                strlcpy(pcFinValue, pcValue, sizeof(pcFinValue));
 
1834
                                (void)strlcpy(pcFinValue, pcValue, sizeof(pcFinValue));
1784
1835
        }
1785
1836
}
1786
1837
 
1799
1850
 * @retval 0 OK
1800
1851
 * @retval 1 key not found
1801
1852
 */
1802
 
int LTPBundleFindValueWithKey(char *fileName, char *tokenKey,
 
1853
int LTPBundleFindValueWithKey(const char *fileName, const char *tokenKey,
1803
1854
                              char *tokenValue, int tokenIndice)
1804
1855
{
1805
1856
        FILE *file = NULL;
1822
1873
 
1823
1874
        do
1824
1875
        {
1825
 
                yylex();
 
1876
                (void)yylex();
1826
1877
        } while (!feof(file));
1827
1878
 
1828
1879
        if (pcFinValue[0] == 0)
1836
1887
                ret = -1;
1837
1888
        }
1838
1889
        else
1839
 
                strlcpy(tokenValue, pcFinValue, TOKEN_MAX_VALUE_SIZE);
 
1890
                (void)strlcpy(tokenValue, pcFinValue, TOKEN_MAX_VALUE_SIZE);
1840
1891
 
1841
 
        fclose(file);
 
1892
        (void)fclose(file);
1842
1893
        return ret;
1843
1894
}
1844
1895