pcsc-lite  1.8.26
tokenparser.c
Go to the documentation of this file.
1 
2 #line 3 "tokenparser.c"
3 
4 #define YY_INT_ALIGNED short int
5 
6 /* A lexical scanner generated by flex */
7 
8 #define yy_create_buffer tp_create_buffer
9 #define yy_delete_buffer tp_delete_buffer
10 #define yy_flex_debug tp_flex_debug
11 #define yy_init_buffer tp_init_buffer
12 #define yy_flush_buffer tp_flush_buffer
13 #define yy_load_buffer_state tp_load_buffer_state
14 #define yy_switch_to_buffer tp_switch_to_buffer
15 #define yyin tpin
16 #define yyleng tpleng
17 #define yylex tplex
18 #define yylineno tplineno
19 #define yyout tpout
20 #define yyrestart tprestart
21 #define yytext tptext
22 #define yywrap tpwrap
23 #define yyalloc tpalloc
24 #define yyrealloc tprealloc
25 #define yyfree tpfree
26 
27 #define FLEX_SCANNER
28 #define YY_FLEX_MAJOR_VERSION 2
29 #define YY_FLEX_MINOR_VERSION 6
30 #define YY_FLEX_SUBMINOR_VERSION 1
31 #if YY_FLEX_SUBMINOR_VERSION > 0
32 #define FLEX_BETA
33 #endif
34 
35 /* First, we deal with platform-specific or compiler-specific issues. */
36 
37 /* begin standard C headers. */
38 #include <stdio.h>
39 #include <string.h>
40 #include <errno.h>
41 #include <stdlib.h>
42 
43 /* end standard C headers. */
44 
45 /* flex integer type definitions */
46 
47 #ifndef FLEXINT_H
48 #define FLEXINT_H
49 
50 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
51 
52 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
53 
54 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
55  * if you want the limit (max/min) macros for int types.
56  */
57 #ifndef __STDC_LIMIT_MACROS
58 #define __STDC_LIMIT_MACROS 1
59 #endif
60 
61 #include <inttypes.h>
62 typedef int8_t flex_int8_t;
63 typedef uint8_t flex_uint8_t;
64 typedef int16_t flex_int16_t;
65 typedef uint16_t flex_uint16_t;
66 typedef int32_t flex_int32_t;
67 typedef uint32_t flex_uint32_t;
68 #else
69 typedef signed char flex_int8_t;
70 typedef short int flex_int16_t;
71 typedef int flex_int32_t;
72 typedef unsigned char flex_uint8_t;
73 typedef unsigned short int flex_uint16_t;
74 typedef unsigned int flex_uint32_t;
75 
76 /* Limits of integral types. */
77 #ifndef INT8_MIN
78 #define INT8_MIN (-128)
79 #endif
80 #ifndef INT16_MIN
81 #define INT16_MIN (-32767-1)
82 #endif
83 #ifndef INT32_MIN
84 #define INT32_MIN (-2147483647-1)
85 #endif
86 #ifndef INT8_MAX
87 #define INT8_MAX (127)
88 #endif
89 #ifndef INT16_MAX
90 #define INT16_MAX (32767)
91 #endif
92 #ifndef INT32_MAX
93 #define INT32_MAX (2147483647)
94 #endif
95 #ifndef UINT8_MAX
96 #define UINT8_MAX (255U)
97 #endif
98 #ifndef UINT16_MAX
99 #define UINT16_MAX (65535U)
100 #endif
101 #ifndef UINT32_MAX
102 #define UINT32_MAX (4294967295U)
103 #endif
104 
105 #endif /* ! C99 */
106 
107 #endif /* ! FLEXINT_H */
108 
109 /* TODO: this is always defined, so inline it */
110 #define yyconst const
111 
112 #if defined(__GNUC__) && __GNUC__ >= 3
113 #define yynoreturn __attribute__((__noreturn__))
114 #else
115 #define yynoreturn
116 #endif
117 
118 /* Returned upon end-of-file. */
119 #define YY_NULL 0
120 
121 /* Promotes a possibly negative, possibly signed char to an unsigned
122  * integer for use as an array index. If the signed char is negative,
123  * we want to instead treat it as an 8-bit unsigned char, hence the
124  * double cast.
125  */
126 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
127 
128 /* Enter a start condition. This macro really ought to take a parameter,
129  * but we do it the disgusting crufty way forced on us by the ()-less
130  * definition of BEGIN.
131  */
132 #define BEGIN (yy_start) = 1 + 2 *
133 
134 /* Translate the current start state into a value that can be later handed
135  * to BEGIN to return to the state. The YYSTATE alias is for lex
136  * compatibility.
137  */
138 #define YY_START (((yy_start) - 1) / 2)
139 #define YYSTATE YY_START
140 
141 /* Action number for EOF rule of a given start state. */
142 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
143 
144 /* Special action meaning "start processing a new file". */
145 #define YY_NEW_FILE tprestart(tpin )
146 
147 #define YY_END_OF_BUFFER_CHAR 0
148 
149 /* Size of default input buffer. */
150 #ifndef YY_BUF_SIZE
151 #ifdef __ia64__
152 /* On IA-64, the buffer size is 16k, not 8k.
153  * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
154  * Ditto for the __ia64__ case accordingly.
155  */
156 #define YY_BUF_SIZE 32768
157 #else
158 #define YY_BUF_SIZE 16384
159 #endif /* __ia64__ */
160 #endif
161 
162 /* The state buf must be large enough to hold one state per character in the main buffer.
163  */
164 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
165 
166 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
167 #define YY_TYPEDEF_YY_BUFFER_STATE
168 typedef struct yy_buffer_state *YY_BUFFER_STATE;
169 #endif
170 
171 #ifndef YY_TYPEDEF_YY_SIZE_T
172 #define YY_TYPEDEF_YY_SIZE_T
173 typedef size_t yy_size_t;
174 #endif
175 
176 extern int tpleng;
177 
178 extern FILE *tpin, *tpout;
179 
180 #define EOB_ACT_CONTINUE_SCAN 0
181 #define EOB_ACT_END_OF_FILE 1
182 #define EOB_ACT_LAST_MATCH 2
183 
184  #define YY_LESS_LINENO(n)
185  #define YY_LINENO_REWIND_TO(ptr)
186 
187 /* Return all but the first "n" matched characters back to the input stream. */
188 #define yyless(n) \
189  do \
190  { \
191  /* Undo effects of setting up tptext. */ \
192  int yyless_macro_arg = (n); \
193  YY_LESS_LINENO(yyless_macro_arg);\
194  *yy_cp = (yy_hold_char); \
195  YY_RESTORE_YY_MORE_OFFSET \
196  (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
197  YY_DO_BEFORE_ACTION; /* set up tptext again */ \
198  } \
199  while ( 0 )
200 
201 #define unput(c) yyunput( c, (yytext_ptr) )
202 
203 #ifndef YY_STRUCT_YY_BUFFER_STATE
204 #define YY_STRUCT_YY_BUFFER_STATE
205 struct yy_buffer_state
206  {
207  FILE *yy_input_file;
208 
209  char *yy_ch_buf; /* input buffer */
210  char *yy_buf_pos; /* current position in input buffer */
211 
212  /* Size of input buffer in bytes, not including room for EOB
213  * characters.
214  */
215  int yy_buf_size;
216 
217  /* Number of characters read into yy_ch_buf, not including EOB
218  * characters.
219  */
220  int yy_n_chars;
221 
222  /* Whether we "own" the buffer - i.e., we know we created it,
223  * and can realloc() it to grow it, and should free() it to
224  * delete it.
225  */
226  int yy_is_our_buffer;
227 
228  /* Whether this is an "interactive" input source; if so, and
229  * if we're using stdio for input, then we want to use getc()
230  * instead of fread(), to make sure we stop fetching input after
231  * each newline.
232  */
233  int yy_is_interactive;
234 
235  /* Whether we're considered to be at the beginning of a line.
236  * If so, '^' rules will be active on the next match, otherwise
237  * not.
238  */
239  int yy_at_bol;
240 
241  int yy_bs_lineno;
242  int yy_bs_column;
244  /* Whether to try to fill the input buffer when we reach the
245  * end of it.
246  */
247  int yy_fill_buffer;
248 
249  int yy_buffer_status;
250 
251 #define YY_BUFFER_NEW 0
252 #define YY_BUFFER_NORMAL 1
253  /* When an EOF's been seen but there's still some text to process
254  * then we mark the buffer as YY_EOF_PENDING, to indicate that we
255  * shouldn't try reading from the input source any more. We might
256  * still have a bunch of tokens to match, though, because of
257  * possible backing-up.
258  *
259  * When we actually see the EOF, we change the status to "new"
260  * (via tprestart()), so that the user can continue scanning by
261  * just pointing tpin at a new input file.
262  */
263 #define YY_BUFFER_EOF_PENDING 2
264 
265  };
266 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
267 
268 /* Stack of input buffers. */
269 static size_t yy_buffer_stack_top = 0;
270 static size_t yy_buffer_stack_max = 0;
273 /* We provide macros for accessing buffer states in case in the
274  * future we want to put the buffer states in a more general
275  * "scanner state".
276  *
277  * Returns the top of the stack, or NULL.
278  */
279 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
280  ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
281  : NULL)
282 
283 /* Same as previous macro, but useful when we know that the buffer stack is not
284  * NULL or when we need an lvalue. For internal use only.
285  */
286 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
287 
288 /* yy_hold_char holds the character lost when tptext is formed. */
289 static char yy_hold_char;
290 static int yy_n_chars; /* number of characters read into yy_ch_buf */
291 int tpleng;
292 
293 /* Points to current character in buffer. */
294 static char *yy_c_buf_p = NULL;
295 static int yy_init = 0; /* whether we need to initialize */
296 static int yy_start = 0; /* start state number */
297 
298 /* Flag which is used to allow tpwrap()'s to do buffer switches
299  * instead of setting up a fresh tpin. A bit of a hack ...
300  */
301 static int yy_did_buffer_switch_on_eof;
302 
303 void tprestart (FILE *input_file );
304 void tp_switch_to_buffer (YY_BUFFER_STATE new_buffer );
305 YY_BUFFER_STATE tp_create_buffer (FILE *file,int size );
306 void tp_delete_buffer (YY_BUFFER_STATE b );
307 void tp_flush_buffer (YY_BUFFER_STATE b );
308 void tppush_buffer_state (YY_BUFFER_STATE new_buffer );
309 void tppop_buffer_state (void );
310 
311 static void tpensure_buffer_stack (void );
312 static void tp_load_buffer_state (void );
313 static void tp_init_buffer (YY_BUFFER_STATE b,FILE *file );
314 
315 #define YY_FLUSH_BUFFER tp_flush_buffer(YY_CURRENT_BUFFER )
316 
317 YY_BUFFER_STATE tp_scan_buffer (char *base,yy_size_t size );
318 YY_BUFFER_STATE tp_scan_string (yyconst char *yy_str );
319 YY_BUFFER_STATE tp_scan_bytes (yyconst char *bytes,int len );
320 
321 void *tpalloc (yy_size_t );
322 void *tprealloc (void *,yy_size_t );
323 void tpfree (void * );
324 
325 #define yy_new_buffer tp_create_buffer
326 
327 #define yy_set_interactive(is_interactive) \
328  { \
329  if ( ! YY_CURRENT_BUFFER ){ \
330  tpensure_buffer_stack (); \
331  YY_CURRENT_BUFFER_LVALUE = \
332  tp_create_buffer(tpin,YY_BUF_SIZE ); \
333  } \
334  YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
335  }
336 
337 #define yy_set_bol(at_bol) \
338  { \
339  if ( ! YY_CURRENT_BUFFER ){\
340  tpensure_buffer_stack (); \
341  YY_CURRENT_BUFFER_LVALUE = \
342  tp_create_buffer(tpin,YY_BUF_SIZE ); \
343  } \
344  YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
345  }
346 
347 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
348 
349 /* Begin user sect3 */
350 
351 #define tpwrap() (/*CONSTCOND*/1)
352 #define YY_SKIP_YYWRAP
353 
354 typedef unsigned char YY_CHAR;
355 
356 FILE *tpin = NULL, *tpout = NULL;
357 
358 typedef int yy_state_type;
359 
360 extern int tplineno;
361 
362 int tplineno = 1;
363 
364 extern char *tptext;
365 #ifdef yytext_ptr
366 #undef yytext_ptr
367 #endif
368 #define yytext_ptr tptext
369 
370 static yy_state_type yy_get_previous_state (void );
371 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
372 static int yy_get_next_buffer (void );
373 static void yynoreturn yy_fatal_error (yyconst char* msg );
374 
375 /* Done after the current pattern has been matched and before the
376  * corresponding action - sets up tptext.
377  */
378 #define YY_DO_BEFORE_ACTION \
379  (yytext_ptr) = yy_bp; \
380  tpleng = (int) (yy_cp - yy_bp); \
381  (yy_hold_char) = *yy_cp; \
382  *yy_cp = '\0'; \
383  (yy_c_buf_p) = yy_cp;
384 
385 #define YY_NUM_RULES 7
386 #define YY_END_OF_BUFFER 8
387 /* This struct is not used in this scanner,
388  but its presence is necessary. */
389 struct yy_trans_info
390  {
391  flex_int32_t yy_verify;
392  flex_int32_t yy_nxt;
393  };
394 static yyconst flex_int16_t yy_accept[39] =
395  { 0,
396  0, 0, 8, 6, 4, 2, 1, 6, 1, 0,
397  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
398  0, 0, 0, 0, 0, 0, 0, 0, 0, 3,
399  0, 0, 0, 0, 0, 0, 5, 0
400  } ;
401 
402 static yyconst YY_CHAR yy_ec[256] =
403  { 0,
404  1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
405  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
406  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
407  1, 2, 4, 4, 5, 4, 4, 4, 4, 4,
408  4, 4, 4, 4, 4, 4, 6, 7, 7, 7,
409  7, 7, 7, 7, 7, 7, 7, 4, 4, 8,
410  4, 9, 4, 4, 10, 10, 10, 10, 10, 10,
411  10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
412  10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
413  4, 1, 4, 4, 4, 1, 11, 11, 11, 11,
414 
415  12, 11, 13, 11, 14, 11, 15, 11, 11, 16,
416  11, 11, 11, 17, 18, 19, 11, 11, 11, 11,
417  20, 11, 1, 1, 1, 4, 1, 1, 1, 1,
418  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
419  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
420  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
421  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
422  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
424  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
425 
426  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
427  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
428  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
429  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
431  1, 1, 1, 1, 1
432  } ;
433 
434 static yyconst YY_CHAR yy_meta[21] =
435  { 0,
436  1, 2, 3, 4, 4, 4, 2, 1, 1, 2,
437  2, 2, 2, 2, 2, 2, 2, 2, 2, 2
438  } ;
439 
440 static yyconst flex_uint16_t yy_base[43] =
441  { 0,
442  0, 7, 49, 50, 50, 50, 0, 1, 0, 36,
443  28, 26, 28, 35, 29, 0, 26, 33, 27, 33,
444  29, 22, 0, 24, 27, 14, 27, 23, 13, 50,
445  10, 9, 4, 1, 0, 2, 50, 50, 19, 23,
446  2, 26
447  } ;
448 
449 static yyconst flex_int16_t yy_def[43] =
450  { 0,
451  39, 39, 38, 38, 38, 38, 40, 38, 40, 38,
452  38, 38, 38, 38, 38, 41, 38, 41, 38, 38,
453  38, 38, 42, 38, 42, 38, 38, 38, 38, 38,
454  38, 38, 38, 38, 38, 38, 38, 0, 38, 38,
455  38, 38
456  } ;
457 
458 static yyconst flex_uint16_t yy_nxt[71] =
459  { 0,
460  38, 5, 6, 18, 7, 38, 38, 8, 5, 6,
461  37, 7, 36, 38, 8, 10, 35, 34, 11, 4,
462  4, 4, 4, 9, 9, 33, 9, 25, 32, 25,
463  31, 30, 29, 28, 27, 26, 24, 23, 22, 21,
464  20, 19, 17, 16, 15, 14, 13, 12, 38, 3,
465  38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
466  38, 38, 38, 38, 38, 38, 38, 38, 38, 38
467  } ;
468 
469 static yyconst flex_int16_t yy_chk[71] =
470  { 0,
471  0, 1, 1, 41, 1, 0, 0, 1, 2, 2,
472  36, 2, 35, 0, 2, 8, 34, 33, 8, 39,
473  39, 39, 39, 40, 40, 32, 40, 42, 31, 42,
474  29, 28, 27, 26, 25, 24, 22, 21, 20, 19,
475  18, 17, 15, 14, 13, 12, 11, 10, 3, 38,
476  38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
477  38, 38, 38, 38, 38, 38, 38, 38, 38, 38
478  } ;
479 
480 static yy_state_type yy_last_accepting_state;
481 static char *yy_last_accepting_cpos;
482 
483 extern int tp_flex_debug;
484 int tp_flex_debug = 0;
485 
486 /* The intent behind this definition is that it'll catch
487  * any uses of REJECT which flex missed.
488  */
489 #define REJECT reject_used_but_not_detected
490 #define yymore() yymore_used_but_not_detected
491 #define YY_MORE_ADJ 0
492 #define YY_RESTORE_YY_MORE_OFFSET
493 char *tptext;
494 #line 1 "tokenparser.l"
495 /*
496  * Reads lexical config files and updates database.
497  *
498  * MUSCLE SmartCard Development ( https://pcsclite.apdu.fr/ )
499  *
500  * Copyright (C) 2001-2003
501  * David Corcoran <corcoran@musclecard.com>
502  * Copyright (C) 2003-2010
503  * Ludovic Rousseau <ludovic.rousseau@free.fr>
504  *
505 Redistribution and use in source and binary forms, with or without
506 modification, are permitted provided that the following conditions
507 are met:
508 
509 1. Redistributions of source code must retain the above copyright
510  notice, this list of conditions and the following disclaimer.
511 2. Redistributions in binary form must reproduce the above copyright
512  notice, this list of conditions and the following disclaimer in the
513  documentation and/or other materials provided with the distribution.
514 3. The name of the author may not be used to endorse or promote products
515  derived from this software without specific prior written permission.
516 
517 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
518 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
519 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
520 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
521 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
522 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
523 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
524 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
525 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
526 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
527  */
533 #line 42 "tokenparser.l"
534 
535 #include "config.h"
536 #include <stdio.h>
537 #include <string.h>
538 #include <errno.h>
539 #ifndef NDEBUG
540 #define NDEBUG
541 #endif
542 #include <assert.h>
543 
544 #include "simclist.h"
545 #include "debuglog.h"
546 #include "parser.h"
547 
548 static void eval_key(char *pcToken, list_t *list_key);
549 static void eval_value(char *pcToken, list_t *list_values);
550 void tperrorCheck (char *pcToken_error);
551 
552 static list_t *ListKeys;
553 static list_t *ListValues;
554 
555 #define YY_NO_INPUT 1
556 #line 557 "tokenparser.c"
557 
558 #define INITIAL 0
559 
560 #ifndef YY_NO_UNISTD_H
561 /* Special case for "unistd.h", since it is non-ANSI. We include it way
562  * down here because we want the user's section 1 to have been scanned first.
563  * The user has a chance to override it with an option.
564  */
565 #include <unistd.h>
566 #endif
567 
568 #ifndef YY_EXTRA_TYPE
569 #define YY_EXTRA_TYPE void *
570 #endif
571 
572 static int yy_init_globals (void );
573 
574 /* Accessor methods to globals.
575  These are made visible to non-reentrant scanners for convenience. */
576 
577 int tplex_destroy (void );
578 
579 int tpget_debug (void );
580 
581 void tpset_debug (int debug_flag );
582 
583 YY_EXTRA_TYPE tpget_extra (void );
584 
585 void tpset_extra (YY_EXTRA_TYPE user_defined );
586 
587 FILE *tpget_in (void );
588 
589 void tpset_in (FILE * _in_str );
590 
591 FILE *tpget_out (void );
592 
593 void tpset_out (FILE * _out_str );
594 
595  int tpget_leng (void );
596 
597 char *tpget_text (void );
598 
599 int tpget_lineno (void );
600 
601 void tpset_lineno (int _line_number );
602 
603 /* Macros after this point can all be overridden by user definitions in
604  * section 1.
605  */
606 
607 #ifndef YY_SKIP_YYWRAP
608 #ifdef __cplusplus
609 extern "C" int tpwrap (void );
610 #else
611 extern int tpwrap (void );
612 #endif
613 #endif
614 
615 #ifndef YY_NO_UNPUT
616 
617 #endif
618 
619 #ifndef yytext_ptr
620 static void yy_flex_strncpy (char *,yyconst char *,int );
621 #endif
622 
623 #ifdef YY_NEED_STRLEN
624 static int yy_flex_strlen (yyconst char * );
625 #endif
626 
627 #ifndef YY_NO_INPUT
628 
629 #ifdef __cplusplus
630 static int yyinput (void );
631 #else
632 static int input (void );
633 #endif
634 
635 #endif
636 
637 /* Amount of stuff to slurp up with each read. */
638 #ifndef YY_READ_BUF_SIZE
639 #ifdef __ia64__
640 /* On IA-64, the buffer size is 16k, not 8k */
641 #define YY_READ_BUF_SIZE 16384
642 #else
643 #define YY_READ_BUF_SIZE 8192
644 #endif /* __ia64__ */
645 #endif
646 
647 /* Copy whatever the last rule matched to the standard output. */
648 #ifndef ECHO
649 /* This used to be an fputs(), but since the string might contain NUL's,
650  * we now use fwrite().
651  */
652 #define ECHO do { if (fwrite( tptext, (size_t) tpleng, 1, tpout )) {} } while (0)
653 #endif
654 
655 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
656  * is returned in "result".
657  */
658 #ifndef YY_INPUT
659 #define YY_INPUT(buf,result,max_size) \
660  if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
661  { \
662  int c = '*'; \
663  size_t n; \
664  for ( n = 0; n < max_size && \
665  (c = getc( tpin )) != EOF && c != '\n'; ++n ) \
666  buf[n] = (char) c; \
667  if ( c == '\n' ) \
668  buf[n++] = (char) c; \
669  if ( c == EOF && ferror( tpin ) ) \
670  YY_FATAL_ERROR( "input in flex scanner failed" ); \
671  result = n; \
672  } \
673  else \
674  { \
675  errno=0; \
676  while ( (result = (int) fread(buf, 1, max_size, tpin))==0 && ferror(tpin)) \
677  { \
678  if( errno != EINTR) \
679  { \
680  YY_FATAL_ERROR( "input in flex scanner failed" ); \
681  break; \
682  } \
683  errno=0; \
684  clearerr(tpin); \
685  } \
686  }\
687 \
688 
689 #endif
690 
691 /* No semi-colon after return; correct usage is to write "yyterminate();" -
692  * we don't want an extra ';' after the "return" because that will cause
693  * some compilers to complain about unreachable statements.
694  */
695 #ifndef yyterminate
696 #define yyterminate() return YY_NULL
697 #endif
698 
699 /* Number of entries by which start-condition stack grows. */
700 #ifndef YY_START_STACK_INCR
701 #define YY_START_STACK_INCR 25
702 #endif
703 
704 /* Report a fatal error. */
705 #ifndef YY_FATAL_ERROR
706 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
707 #endif
708 
709 /* end tables serialization structures and prototypes */
710 
711 /* Default declaration of generated scanner - a define so the user can
712  * easily add parameters.
713  */
714 #ifndef YY_DECL
715 #define YY_DECL_IS_OURS 1
716 
717 extern int tplex (void);
718 
719 #define YY_DECL int tplex (void)
720 #endif /* !YY_DECL */
721 
722 /* Code executed at the beginning of each rule, after tptext and tpleng
723  * have been set up.
724  */
725 #ifndef YY_USER_ACTION
726 #define YY_USER_ACTION
727 #endif
728 
729 /* Code executed at the end of each rule. */
730 #ifndef YY_BREAK
731 #define YY_BREAK /*LINTED*/break;
732 #endif
733 
734 #define YY_RULE_SETUP \
735  YY_USER_ACTION
736 
739 YY_DECL
740 {
741  yy_state_type yy_current_state;
742  char *yy_cp, *yy_bp;
743  int yy_act;
744 
745  if ( !(yy_init) )
746  {
747  (yy_init) = 1;
748 
749 #ifdef YY_USER_INIT
750  YY_USER_INIT;
751 #endif
752 
753  if ( ! (yy_start) )
754  (yy_start) = 1; /* first start state */
755 
756  if ( ! tpin )
757  tpin = stdin;
758 
759  if ( ! tpout )
760  tpout = stdout;
761 
762  if ( ! YY_CURRENT_BUFFER ) {
763  tpensure_buffer_stack ();
764  YY_CURRENT_BUFFER_LVALUE =
765  tp_create_buffer(tpin,YY_BUF_SIZE );
766  }
767 
768  tp_load_buffer_state( );
769  }
770 
771  {
772 #line 69 "tokenparser.l"
773 
774 
775 #line 776 "tokenparser.c"
776 
777  while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
778  {
779  yy_cp = (yy_c_buf_p);
780 
781  /* Support of tptext. */
782  *yy_cp = (yy_hold_char);
783 
784  /* yy_bp points to the position in yy_ch_buf of the start of
785  * the current run.
786  */
787  yy_bp = yy_cp;
788 
789  yy_current_state = (yy_start);
790 yy_match:
791  do
792  {
793  YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
794  if ( yy_accept[yy_current_state] )
795  {
796  (yy_last_accepting_state) = yy_current_state;
797  (yy_last_accepting_cpos) = yy_cp;
798  }
799  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
800  {
801  yy_current_state = (int) yy_def[yy_current_state];
802  if ( yy_current_state >= 39 )
803  yy_c = yy_meta[(unsigned int) yy_c];
804  }
805  yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
806  ++yy_cp;
807  }
808  while ( yy_base[yy_current_state] != 50 );
809 
810 yy_find_action:
811  yy_act = yy_accept[yy_current_state];
812  if ( yy_act == 0 )
813  { /* have to back up */
814  yy_cp = (yy_last_accepting_cpos);
815  yy_current_state = (yy_last_accepting_state);
816  yy_act = yy_accept[yy_current_state];
817  }
818 
819  YY_DO_BEFORE_ACTION;
820 
821 do_action: /* This label is used only to access EOF actions. */
822 
823  switch ( yy_act )
824  { /* beginning of action switch */
825  case 0: /* must back up */
826  /* undo the effects of YY_DO_BEFORE_ACTION */
827  *yy_cp = (yy_hold_char);
828  yy_cp = (yy_last_accepting_cpos);
829  yy_current_state = (yy_last_accepting_state);
830  goto yy_find_action;
831 
832 case 1:
833 YY_RULE_SETUP
834 #line 71 "tokenparser.l"
835 {}
836  YY_BREAK
837 case 2:
838 /* rule 2 can match eol */
839 YY_RULE_SETUP
840 #line 72 "tokenparser.l"
841 {}
842  YY_BREAK
843 case 3:
844 YY_RULE_SETUP
845 #line 73 "tokenparser.l"
846 { eval_key(tptext, ListKeys); }
847  YY_BREAK
848 case 4:
849 YY_RULE_SETUP
850 #line 74 "tokenparser.l"
851 {}
852  YY_BREAK
853 case 5:
854 YY_RULE_SETUP
855 #line 75 "tokenparser.l"
856 { eval_value(tptext, ListValues); }
857  YY_BREAK
858 case 6:
859 YY_RULE_SETUP
860 #line 76 "tokenparser.l"
861 { tperrorCheck(tptext); }
862  YY_BREAK
863 case 7:
864 YY_RULE_SETUP
865 #line 77 "tokenparser.l"
866 ECHO;
867  YY_BREAK
868 #line 869 "tokenparser.c"
869 case YY_STATE_EOF(INITIAL):
870  yyterminate();
871 
872  case YY_END_OF_BUFFER:
873  {
874  /* Amount of text matched not including the EOB char. */
875  int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
876 
877  /* Undo the effects of YY_DO_BEFORE_ACTION. */
878  *yy_cp = (yy_hold_char);
879  YY_RESTORE_YY_MORE_OFFSET
880 
881  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
882  {
883  /* We're scanning a new file or input source. It's
884  * possible that this happened because the user
885  * just pointed tpin at a new source and called
886  * tplex(). If so, then we have to assure
887  * consistency between YY_CURRENT_BUFFER and our
888  * globals. Here is the right place to do so, because
889  * this is the first action (other than possibly a
890  * back-up) that will match for the new input source.
891  */
892  (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
893  YY_CURRENT_BUFFER_LVALUE->yy_input_file = tpin;
894  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
895  }
896 
897  /* Note that here we test for yy_c_buf_p "<=" to the position
898  * of the first EOB in the buffer, since yy_c_buf_p will
899  * already have been incremented past the NUL character
900  * (since all states make transitions on EOB to the
901  * end-of-buffer state). Contrast this with the test
902  * in input().
903  */
904  if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
905  { /* This was really a NUL. */
906  yy_state_type yy_next_state;
907 
908  (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
909 
910  yy_current_state = yy_get_previous_state( );
911 
912  /* Okay, we're now positioned to make the NUL
913  * transition. We couldn't have
914  * yy_get_previous_state() go ahead and do it
915  * for us because it doesn't know how to deal
916  * with the possibility of jamming (and we don't
917  * want to build jamming into it because then it
918  * will run more slowly).
919  */
920 
921  yy_next_state = yy_try_NUL_trans( yy_current_state );
922 
923  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
924 
925  if ( yy_next_state )
926  {
927  /* Consume the NUL. */
928  yy_cp = ++(yy_c_buf_p);
929  yy_current_state = yy_next_state;
930  goto yy_match;
931  }
932 
933  else
934  {
935  yy_cp = (yy_c_buf_p);
936  goto yy_find_action;
937  }
938  }
939 
940  else switch ( yy_get_next_buffer( ) )
941  {
942  case EOB_ACT_END_OF_FILE:
943  {
944  (yy_did_buffer_switch_on_eof) = 0;
945 
946  if ( tpwrap( ) )
947  {
948  /* Note: because we've taken care in
949  * yy_get_next_buffer() to have set up
950  * tptext, we can now set up
951  * yy_c_buf_p so that if some total
952  * hoser (like flex itself) wants to
953  * call the scanner after we return the
954  * YY_NULL, it'll still work - another
955  * YY_NULL will get returned.
956  */
957  (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
958 
959  yy_act = YY_STATE_EOF(YY_START);
960  goto do_action;
961  }
962 
963  else
964  {
965  if ( ! (yy_did_buffer_switch_on_eof) )
966  YY_NEW_FILE;
967  }
968  break;
969  }
970 
971  case EOB_ACT_CONTINUE_SCAN:
972  (yy_c_buf_p) =
973  (yytext_ptr) + yy_amount_of_matched_text;
974 
975  yy_current_state = yy_get_previous_state( );
976 
977  yy_cp = (yy_c_buf_p);
978  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
979  goto yy_match;
980 
981  case EOB_ACT_LAST_MATCH:
982  (yy_c_buf_p) =
983  &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
984 
985  yy_current_state = yy_get_previous_state( );
986 
987  yy_cp = (yy_c_buf_p);
988  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
989  goto yy_find_action;
990  }
991  break;
992  }
993 
994  default:
995  YY_FATAL_ERROR(
996  "fatal flex scanner internal error--no action found" );
997  } /* end of action switch */
998  } /* end of scanning one token */
999  } /* end of user's declarations */
1000 } /* end of tplex */
1001 
1002 /* yy_get_next_buffer - try to read in a new buffer
1003  *
1004  * Returns a code representing an action:
1005  * EOB_ACT_LAST_MATCH -
1006  * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1007  * EOB_ACT_END_OF_FILE - end of file
1008  */
1009 static int yy_get_next_buffer (void)
1010 {
1011  char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1012  char *source = (yytext_ptr);
1013  yy_size_t number_to_move, i;
1014  int ret_val;
1015 
1016  if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1017  YY_FATAL_ERROR(
1018  "fatal flex scanner internal error--end of buffer missed" );
1019 
1020  if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1021  { /* Don't try to fill the buffer, so this is an EOF. */
1022  if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1023  {
1024  /* We matched a single character, the EOB, so
1025  * treat this as a final EOF.
1026  */
1027  return EOB_ACT_END_OF_FILE;
1028  }
1029 
1030  else
1031  {
1032  /* We matched some text prior to the EOB, first
1033  * process it.
1034  */
1035  return EOB_ACT_LAST_MATCH;
1036  }
1037  }
1038 
1039  /* Try to read more data. */
1040 
1041  /* First move last chars to start of buffer. */
1042  number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1043 
1044  for ( i = 0; i < number_to_move; ++i )
1045  *(dest++) = *(source++);
1046 
1047  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1048  /* don't do the read, it's not guaranteed to return an EOF,
1049  * just force an EOF
1050  */
1051  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1052 
1053  else
1054  {
1055  int num_to_read =
1056  YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1057 
1058  while ( num_to_read <= 0 )
1059  { /* Not enough room in the buffer - grow it. */
1060 
1061  /* just a shorter name for the current buffer */
1062  YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1063 
1064  int yy_c_buf_p_offset =
1065  (int) ((yy_c_buf_p) - b->yy_ch_buf);
1066 
1067  if ( b->yy_is_our_buffer )
1068  {
1069  int new_size = b->yy_buf_size * 2;
1070 
1071  if ( new_size <= 0 )
1072  b->yy_buf_size += b->yy_buf_size / 8;
1073  else
1074  b->yy_buf_size *= 2;
1075 
1076  b->yy_ch_buf = (char *)
1077  /* Include room in for 2 EOB chars. */
1078  tprealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1079  }
1080  else
1081  /* Can't grow it, we don't own it. */
1082  b->yy_ch_buf = NULL;
1083 
1084  if ( ! b->yy_ch_buf )
1085  YY_FATAL_ERROR(
1086  "fatal error - scanner input buffer overflow" );
1087 
1088  (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1089 
1090  num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1091  number_to_move - 1;
1092 
1093  }
1094 
1095  if ( num_to_read > YY_READ_BUF_SIZE )
1096  num_to_read = YY_READ_BUF_SIZE;
1097 
1098  /* Read in more data. */
1099  YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1100  (yy_n_chars), num_to_read );
1101 
1102  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1103  }
1104 
1105  if ( (yy_n_chars) == 0 )
1106  {
1107  if ( number_to_move == YY_MORE_ADJ )
1108  {
1109  ret_val = EOB_ACT_END_OF_FILE;
1110  tprestart(tpin );
1111  }
1112 
1113  else
1114  {
1115  ret_val = EOB_ACT_LAST_MATCH;
1116  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1117  YY_BUFFER_EOF_PENDING;
1118  }
1119  }
1120 
1121  else
1122  ret_val = EOB_ACT_CONTINUE_SCAN;
1123 
1124  if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1125  /* Extend the array by 50%, plus the number we really need. */
1126  int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1127  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) tprealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1128  if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1129  YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1130  }
1131 
1132  (yy_n_chars) += number_to_move;
1133  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1134  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1135 
1136  (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1137 
1138  return ret_val;
1139 }
1140 
1141 /* yy_get_previous_state - get the state just before the EOB char was reached */
1142 
1143  static yy_state_type yy_get_previous_state (void)
1144 {
1145  yy_state_type yy_current_state;
1146  char *yy_cp;
1147 
1148  yy_current_state = (yy_start);
1149 
1150  for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1151  {
1152  YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1153  if ( yy_accept[yy_current_state] )
1154  {
1155  (yy_last_accepting_state) = yy_current_state;
1156  (yy_last_accepting_cpos) = yy_cp;
1157  }
1158  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1159  {
1160  yy_current_state = (int) yy_def[yy_current_state];
1161  if ( yy_current_state >= 39 )
1162  yy_c = yy_meta[(unsigned int) yy_c];
1163  }
1164  yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
1165  }
1166 
1167  return yy_current_state;
1168 }
1169 
1170 /* yy_try_NUL_trans - try to make a transition on the NUL character
1171  *
1172  * synopsis
1173  * next_state = yy_try_NUL_trans( current_state );
1174  */
1175  static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1176 {
1177  int yy_is_jam;
1178  char *yy_cp = (yy_c_buf_p);
1179 
1180  YY_CHAR yy_c = 1;
1181  if ( yy_accept[yy_current_state] )
1182  {
1183  (yy_last_accepting_state) = yy_current_state;
1184  (yy_last_accepting_cpos) = yy_cp;
1185  }
1186  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1187  {
1188  yy_current_state = (int) yy_def[yy_current_state];
1189  if ( yy_current_state >= 39 )
1190  yy_c = yy_meta[(unsigned int) yy_c];
1191  }
1192  yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
1193  yy_is_jam = (yy_current_state == 38);
1194 
1195  return yy_is_jam ? 0 : yy_current_state;
1196 }
1197 
1198 #ifndef YY_NO_UNPUT
1199 
1200 #endif
1201 
1202 #ifndef YY_NO_INPUT
1203 #ifdef __cplusplus
1204  static int yyinput (void)
1205 #else
1206  static int input (void)
1207 #endif
1208 
1209 {
1210  int c;
1211 
1212  *(yy_c_buf_p) = (yy_hold_char);
1213 
1214  if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1215  {
1216  /* yy_c_buf_p now points to the character we want to return.
1217  * If this occurs *before* the EOB characters, then it's a
1218  * valid NUL; if not, then we've hit the end of the buffer.
1219  */
1220  if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1221  /* This was really a NUL. */
1222  *(yy_c_buf_p) = '\0';
1223 
1224  else
1225  { /* need more input */
1226  int offset = (yy_c_buf_p) - (yytext_ptr);
1227  ++(yy_c_buf_p);
1228 
1229  switch ( yy_get_next_buffer( ) )
1230  {
1231  case EOB_ACT_LAST_MATCH:
1232  /* This happens because yy_g_n_b()
1233  * sees that we've accumulated a
1234  * token and flags that we need to
1235  * try matching the token before
1236  * proceeding. But for input(),
1237  * there's no matching to consider.
1238  * So convert the EOB_ACT_LAST_MATCH
1239  * to EOB_ACT_END_OF_FILE.
1240  */
1241 
1242  /* Reset buffer status. */
1243  tprestart(tpin );
1244 
1245  /*FALLTHROUGH*/
1246 
1247  case EOB_ACT_END_OF_FILE:
1248  {
1249  if ( tpwrap( ) )
1250  return 0;
1251 
1252  if ( ! (yy_did_buffer_switch_on_eof) )
1253  YY_NEW_FILE;
1254 #ifdef __cplusplus
1255  return yyinput();
1256 #else
1257  return input();
1258 #endif
1259  }
1260 
1261  case EOB_ACT_CONTINUE_SCAN:
1262  (yy_c_buf_p) = (yytext_ptr) + offset;
1263  break;
1264  }
1265  }
1266  }
1267 
1268  c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1269  *(yy_c_buf_p) = '\0'; /* preserve tptext */
1270  (yy_hold_char) = *++(yy_c_buf_p);
1271 
1272  return c;
1273 }
1274 #endif /* ifndef YY_NO_INPUT */
1275 
1281  void tprestart (FILE * input_file )
1282 {
1283 
1284  if ( ! YY_CURRENT_BUFFER ){
1285  tpensure_buffer_stack ();
1286  YY_CURRENT_BUFFER_LVALUE =
1287  tp_create_buffer(tpin,YY_BUF_SIZE );
1288  }
1289 
1290  tp_init_buffer(YY_CURRENT_BUFFER,input_file );
1291  tp_load_buffer_state( );
1292 }
1293 
1298  void tp_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1299 {
1300 
1301  /* TODO. We should be able to replace this entire function body
1302  * with
1303  * tppop_buffer_state();
1304  * tppush_buffer_state(new_buffer);
1305  */
1306  tpensure_buffer_stack ();
1307  if ( YY_CURRENT_BUFFER == new_buffer )
1308  return;
1309 
1310  if ( YY_CURRENT_BUFFER )
1311  {
1312  /* Flush out information for old buffer. */
1313  *(yy_c_buf_p) = (yy_hold_char);
1314  YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1315  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1316  }
1317 
1318  YY_CURRENT_BUFFER_LVALUE = new_buffer;
1319  tp_load_buffer_state( );
1320 
1321  /* We don't actually know whether we did this switch during
1322  * EOF (tpwrap()) processing, but the only time this flag
1323  * is looked at is after tpwrap() is called, so it's safe
1324  * to go ahead and always set it.
1325  */
1326  (yy_did_buffer_switch_on_eof) = 1;
1327 }
1328 
1329 static void tp_load_buffer_state (void)
1330 {
1331  (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1332  (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1333  tpin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1334  (yy_hold_char) = *(yy_c_buf_p);
1335 }
1336 
1343  YY_BUFFER_STATE tp_create_buffer (FILE * file, int size )
1344 {
1345  YY_BUFFER_STATE b;
1346 
1347  b = (YY_BUFFER_STATE) tpalloc(sizeof( struct yy_buffer_state ) );
1348  if ( ! b )
1349  YY_FATAL_ERROR( "out of dynamic memory in tp_create_buffer()" );
1350 
1351  b->yy_buf_size = (yy_size_t)size;
1352 
1353  /* yy_ch_buf has to be 2 characters longer than the size given because
1354  * we need to put in 2 end-of-buffer characters.
1355  */
1356  b->yy_ch_buf = (char *) tpalloc(b->yy_buf_size + 2 );
1357  if ( ! b->yy_ch_buf )
1358  YY_FATAL_ERROR( "out of dynamic memory in tp_create_buffer()" );
1359 
1360  b->yy_is_our_buffer = 1;
1361 
1362  tp_init_buffer(b,file );
1363 
1364  return b;
1365 }
1366 
1371  void tp_delete_buffer (YY_BUFFER_STATE b )
1372 {
1373 
1374  if ( ! b )
1375  return;
1376 
1377  if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1378  YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1379 
1380  if ( b->yy_is_our_buffer )
1381  tpfree((void *) b->yy_ch_buf );
1382 
1383  tpfree((void *) b );
1384 }
1385 
1386 /* Initializes or reinitializes a buffer.
1387  * This function is sometimes called more than once on the same buffer,
1388  * such as during a tprestart() or at EOF.
1389  */
1390  static void tp_init_buffer (YY_BUFFER_STATE b, FILE * file )
1391 
1392 {
1393  int oerrno = errno;
1394 
1395  tp_flush_buffer(b );
1396 
1397  b->yy_input_file = file;
1398  b->yy_fill_buffer = 1;
1399 
1400  /* If b is the current buffer, then tp_init_buffer was _probably_
1401  * called from tprestart() or through yy_get_next_buffer.
1402  * In that case, we don't want to reset the lineno or column.
1403  */
1404  if (b != YY_CURRENT_BUFFER){
1405  b->yy_bs_lineno = 1;
1406  b->yy_bs_column = 0;
1407  }
1408 
1409  b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1410 
1411  errno = oerrno;
1412 }
1413 
1418  void tp_flush_buffer (YY_BUFFER_STATE b )
1419 {
1420  if ( ! b )
1421  return;
1422 
1423  b->yy_n_chars = 0;
1424 
1425  /* We always need two end-of-buffer characters. The first causes
1426  * a transition to the end-of-buffer state. The second causes
1427  * a jam in that state.
1428  */
1429  b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1430  b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1431 
1432  b->yy_buf_pos = &b->yy_ch_buf[0];
1433 
1434  b->yy_at_bol = 1;
1435  b->yy_buffer_status = YY_BUFFER_NEW;
1436 
1437  if ( b == YY_CURRENT_BUFFER )
1438  tp_load_buffer_state( );
1439 }
1440 
1447 void tppush_buffer_state (YY_BUFFER_STATE new_buffer )
1448 {
1449  if (new_buffer == NULL)
1450  return;
1451 
1452  tpensure_buffer_stack();
1453 
1454  /* This block is copied from tp_switch_to_buffer. */
1455  if ( YY_CURRENT_BUFFER )
1456  {
1457  /* Flush out information for old buffer. */
1458  *(yy_c_buf_p) = (yy_hold_char);
1459  YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1460  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1461  }
1462 
1463  /* Only push if top exists. Otherwise, replace top. */
1464  if (YY_CURRENT_BUFFER)
1465  (yy_buffer_stack_top)++;
1466  YY_CURRENT_BUFFER_LVALUE = new_buffer;
1467 
1468  /* copied from tp_switch_to_buffer. */
1469  tp_load_buffer_state( );
1470  (yy_did_buffer_switch_on_eof) = 1;
1471 }
1472 
1477 void tppop_buffer_state (void)
1478 {
1479  if (!YY_CURRENT_BUFFER)
1480  return;
1481 
1482  tp_delete_buffer(YY_CURRENT_BUFFER );
1483  YY_CURRENT_BUFFER_LVALUE = NULL;
1484  if ((yy_buffer_stack_top) > 0)
1485  --(yy_buffer_stack_top);
1486 
1487  if (YY_CURRENT_BUFFER) {
1488  tp_load_buffer_state( );
1489  (yy_did_buffer_switch_on_eof) = 1;
1490  }
1491 }
1492 
1493 /* Allocates the stack if it does not exist.
1494  * Guarantees space for at least one push.
1495  */
1496 static void tpensure_buffer_stack (void)
1497 {
1498  int num_to_alloc;
1499 
1500  if (!(yy_buffer_stack)) {
1501 
1502  /* First allocation is just for 2 elements, since we don't know if this
1503  * scanner will even need a stack. We use 2 instead of 1 to avoid an
1504  * immediate realloc on the next call.
1505  */
1506  num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
1507  (yy_buffer_stack) = (struct yy_buffer_state**)tpalloc
1508  (num_to_alloc * sizeof(struct yy_buffer_state*)
1509  );
1510  if ( ! (yy_buffer_stack) )
1511  YY_FATAL_ERROR( "out of dynamic memory in tpensure_buffer_stack()" );
1512 
1513  memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1514 
1515  (yy_buffer_stack_max) = num_to_alloc;
1516  (yy_buffer_stack_top) = 0;
1517  return;
1518  }
1519 
1520  if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1521 
1522  /* Increase the buffer to prepare for a possible push. */
1523  yy_size_t grow_size = 8 /* arbitrary grow size */;
1524 
1525  num_to_alloc = (yy_buffer_stack_max) + grow_size;
1526  (yy_buffer_stack) = (struct yy_buffer_state**)tprealloc
1527  ((yy_buffer_stack),
1528  num_to_alloc * sizeof(struct yy_buffer_state*)
1529  );
1530  if ( ! (yy_buffer_stack) )
1531  YY_FATAL_ERROR( "out of dynamic memory in tpensure_buffer_stack()" );
1532 
1533  /* zero only the new slots.*/
1534  memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1535  (yy_buffer_stack_max) = num_to_alloc;
1536  }
1537 }
1538 
1545 YY_BUFFER_STATE tp_scan_buffer (char * base, yy_size_t size )
1546 {
1547  YY_BUFFER_STATE b;
1548 
1549  if ( size < 2 ||
1550  base[size-2] != YY_END_OF_BUFFER_CHAR ||
1551  base[size-1] != YY_END_OF_BUFFER_CHAR )
1552  /* They forgot to leave room for the EOB's. */
1553  return NULL;
1554 
1555  b = (YY_BUFFER_STATE) tpalloc(sizeof( struct yy_buffer_state ) );
1556  if ( ! b )
1557  YY_FATAL_ERROR( "out of dynamic memory in tp_scan_buffer()" );
1558 
1559  b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1560  b->yy_buf_pos = b->yy_ch_buf = base;
1561  b->yy_is_our_buffer = 0;
1562  b->yy_input_file = NULL;
1563  b->yy_n_chars = b->yy_buf_size;
1564  b->yy_is_interactive = 0;
1565  b->yy_at_bol = 1;
1566  b->yy_fill_buffer = 0;
1567  b->yy_buffer_status = YY_BUFFER_NEW;
1568 
1569  tp_switch_to_buffer(b );
1570 
1571  return b;
1572 }
1573 
1582 YY_BUFFER_STATE tp_scan_string (yyconst char * yystr )
1583 {
1584 
1585  return tp_scan_bytes(yystr,(int) strlen(yystr) );
1586 }
1587 
1595 YY_BUFFER_STATE tp_scan_bytes (yyconst char * yybytes, int _yybytes_len )
1596 {
1597  YY_BUFFER_STATE b;
1598  char *buf;
1599  yy_size_t n;
1600  yy_size_t i;
1601 
1602  /* Get memory for full buffer, including space for trailing EOB's. */
1603  n = (yy_size_t) _yybytes_len + 2;
1604  buf = (char *) tpalloc(n );
1605  if ( ! buf )
1606  YY_FATAL_ERROR( "out of dynamic memory in tp_scan_bytes()" );
1607 
1608  for ( i = 0; i < _yybytes_len; ++i )
1609  buf[i] = yybytes[i];
1610 
1611  buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1612 
1613  b = tp_scan_buffer(buf,n );
1614  if ( ! b )
1615  YY_FATAL_ERROR( "bad buffer in tp_scan_bytes()" );
1616 
1617  /* It's okay to grow etc. this buffer, and we should throw it
1618  * away when we're done.
1619  */
1620  b->yy_is_our_buffer = 1;
1621 
1622  return b;
1623 }
1624 
1625 #ifndef YY_EXIT_FAILURE
1626 #define YY_EXIT_FAILURE 2
1627 #endif
1628 
1629 static void yynoreturn yy_fatal_error (yyconst char* msg )
1630 {
1631  (void) fprintf( stderr, "%s\n", msg );
1632  exit( YY_EXIT_FAILURE );
1633 }
1634 
1635 /* Redefine yyless() so it works in section 3 code. */
1636 
1637 #undef yyless
1638 #define yyless(n) \
1639  do \
1640  { \
1641  /* Undo effects of setting up tptext. */ \
1642  int yyless_macro_arg = (n); \
1643  YY_LESS_LINENO(yyless_macro_arg);\
1644  tptext[tpleng] = (yy_hold_char); \
1645  (yy_c_buf_p) = tptext + yyless_macro_arg; \
1646  (yy_hold_char) = *(yy_c_buf_p); \
1647  *(yy_c_buf_p) = '\0'; \
1648  tpleng = yyless_macro_arg; \
1649  } \
1650  while ( 0 )
1651 
1652 /* Accessor methods (get/set functions) to struct members. */
1653 
1657 int tpget_lineno (void)
1658 {
1659 
1660  return tplineno;
1661 }
1662 
1666 FILE *tpget_in (void)
1667 {
1668  return tpin;
1669 }
1670 
1674 FILE *tpget_out (void)
1675 {
1676  return tpout;
1677 }
1678 
1682 int tpget_leng (void)
1683 {
1684  return tpleng;
1685 }
1686 
1691 char *tpget_text (void)
1692 {
1693  return tptext;
1694 }
1695 
1700 void tpset_lineno (int _line_number )
1701 {
1702 
1703  tplineno = _line_number;
1704 }
1705 
1712 void tpset_in (FILE * _in_str )
1713 {
1714  tpin = _in_str ;
1715 }
1716 
1717 void tpset_out (FILE * _out_str )
1718 {
1719  tpout = _out_str ;
1720 }
1721 
1722 int tpget_debug (void)
1723 {
1724  return tp_flex_debug;
1725 }
1726 
1727 void tpset_debug (int _bdebug )
1728 {
1729  tp_flex_debug = _bdebug ;
1730 }
1731 
1732 static int yy_init_globals (void)
1733 {
1734  /* Initialization is the same as for the non-reentrant scanner.
1735  * This function is called from tplex_destroy(), so don't allocate here.
1736  */
1737 
1738  (yy_buffer_stack) = NULL;
1739  (yy_buffer_stack_top) = 0;
1740  (yy_buffer_stack_max) = 0;
1741  (yy_c_buf_p) = NULL;
1742  (yy_init) = 0;
1743  (yy_start) = 0;
1744 
1745 /* Defined in main.c */
1746 #ifdef YY_STDINIT
1747  tpin = stdin;
1748  tpout = stdout;
1749 #else
1750  tpin = NULL;
1751  tpout = NULL;
1752 #endif
1753 
1754  /* For future reference: Set errno on error, since we are called by
1755  * tplex_init()
1756  */
1757  return 0;
1758 }
1759 
1760 /* tplex_destroy is for both reentrant and non-reentrant scanners. */
1761 int tplex_destroy (void)
1762 {
1763 
1764  /* Pop the buffer stack, destroying each element. */
1765  while(YY_CURRENT_BUFFER){
1766  tp_delete_buffer(YY_CURRENT_BUFFER );
1767  YY_CURRENT_BUFFER_LVALUE = NULL;
1768  tppop_buffer_state();
1769  }
1770 
1771  /* Destroy the stack itself. */
1772  tpfree((yy_buffer_stack) );
1773  (yy_buffer_stack) = NULL;
1774 
1775  /* Reset the globals. This is important in a non-reentrant scanner so the next time
1776  * tplex() is called, initialization will occur. */
1777  yy_init_globals( );
1778 
1779  return 0;
1780 }
1781 
1782 /*
1783  * Internal utility routines.
1784  */
1785 
1786 #ifndef yytext_ptr
1787 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1788 {
1789 
1790  int i;
1791  for ( i = 0; i < n; ++i )
1792  s1[i] = s2[i];
1793 }
1794 #endif
1795 
1796 #ifdef YY_NEED_STRLEN
1797 static int yy_flex_strlen (yyconst char * s )
1798 {
1799  int n;
1800  for ( n = 0; s[n]; ++n )
1801  ;
1802 
1803  return n;
1804 }
1805 #endif
1806 
1807 void *tpalloc (yy_size_t size )
1808 {
1809  return malloc(size);
1810 }
1811 
1812 void *tprealloc (void * ptr, yy_size_t size )
1813 {
1814 
1815  /* The cast to (char *) in the following accommodates both
1816  * implementations that use char* generic pointers, and those
1817  * that use void* generic pointers. It works with the latter
1818  * because both ANSI C and C++ allow castless assignment from
1819  * any pointer type to void*, and deal with argument conversions
1820  * as though doing an assignment.
1821  */
1822  return realloc(ptr, size);
1823 }
1824 
1825 void tpfree (void * ptr )
1826 {
1827  free( (char *) ptr ); /* see tprealloc() for (char *) cast */
1828 }
1829 
1830 #define YYTABLES_NAME "yytables"
1831 
1832 #line 77 "tokenparser.l"
1833 
1834 
1835 
1836 
1837 static void eval_key(char *pcToken, list_t *list_key)
1838 {
1839  struct bundleElt *elt;
1840  int r;
1841  size_t len;
1842 
1843  /* create a new list element */
1844  elt = malloc(sizeof(*elt));
1845  assert(elt);
1846 
1847  /* <key>foobar</key>
1848  * 012345 : 5 is the first key character index */
1849 
1850  /* calculate the argument length */
1851  for (len=0; pcToken[len+5] != '<'; len++)
1852  ;
1853  len++; /* final NULL byte */
1854 
1855  elt->key = malloc(len);
1856  memcpy(elt->key, &pcToken[5], len-1);
1857  elt->key[len-1] = '\0';
1858 
1859  r = list_init(&elt->values);
1860  assert(r >= 0);
1861  (void)r;
1862 
1863  /* add the key/values */
1864  list_append(list_key, elt);
1865 
1866  /* set the list to store the values */
1867  ListValues = &elt->values;
1868 }
1869 
1870 static void eval_value(char *pcToken, list_t *list_values)
1871 {
1872  int r;
1873  size_t len;
1874  char *value;
1875  char *amp;
1876 
1877  /* <string>foobar</string>
1878  * 012345678 : 8 is the first string character index */
1879 
1880  /* calculate the argument length */
1881  for (len=0; pcToken[len+8] != '<'; len++)
1882  ;
1883  len++; /* final NULL byte */
1884 
1885  value = malloc(len);
1886  assert(value);
1887 
1888  memcpy(value, &pcToken[8], len-1);
1889  value[len-1] = '\0';
1890 
1891  /* for all &amp; in the string */
1892  amp = value;
1893  while ((amp = strstr(amp, "&amp;")) != NULL)
1894  {
1895  char *p;
1896 
1897  /* just skip "amp;" substring (4 letters) */
1898  for (p = amp+1; *(p+4); p++)
1899  {
1900  *p = *(p+4);
1901  }
1902  /* terminate the now shorter string */
1903  *p = '\0';
1904 
1905  /* skip the & and continue */
1906  amp++;
1907  }
1908 
1909  r = list_append(list_values, value);
1910  assert(r >= 0);
1911  (void)r;
1912 }
1913 
1914 void tperrorCheck (char *token_error)
1915 {
1916  (void)token_error;
1917 }
1918 
1929 int LTPBundleFindValueWithKey(list_t *l, const char *key, list_t **values)
1930 {
1931  unsigned int i;
1932  int ret = 1;
1933 
1934  for (i=0; i < list_size(l); i++)
1935  {
1936  struct bundleElt *elt;
1937 
1938  elt = list_get_at(l, i);
1939  assert(elt);
1940 
1941  if (0 == strcmp(elt->key, key))
1942  {
1943  *values = &elt->values;
1944  ret = 0;
1945  }
1946  }
1947 
1948  return ret;
1949 }
1950 
1951 
1960 int bundleParse(const char *fileName, list_t *l)
1961 {
1962  FILE *file = NULL;
1963  int r;
1964 #ifndef NDEBUG
1965  int i;
1966 #endif
1967 
1968  file = fopen(fileName, "r");
1969  if (!file)
1970  {
1971  Log3(PCSC_LOG_CRITICAL, "Could not open bundle file %s: %s",
1972  fileName, strerror(errno));
1973  return 1;
1974  }
1975 
1976  r = list_init(l);
1977  assert(r >= 0);
1978  (void)r;
1979 
1980  ListKeys = l;
1981  tpin = file;
1982 
1983  do
1984  {
1985  (void)tplex();
1986  } while (!feof(file));
1987  tplex_destroy();
1988 
1989  (void)fclose(file);
1990 
1991 #ifndef NDEBUG
1992  printf("size: %d\n", list_size(l));
1993  for (i=0; i < list_size(l); i++)
1994  {
1995  struct bundleElt *elt;
1996  unsigned int j;
1997 
1998  elt = list_get_at(l, i);
1999  assert(elt);
2000  printf("Key: %s\n", elt->key);
2001 
2002  for (j=0; j<list_size(&elt->values); j++)
2003  {
2004  char *v = list_get_at(&elt->values, j);
2005  printf(" value: %s\n", v);
2006  }
2007  }
2008 #endif
2009 
2010  return 0;
2011 }
2012 
2018 void bundleRelease(list_t *l)
2019 {
2020  unsigned int i;
2021 
2022  for (i=0; i < list_size(l); i++)
2023  {
2024  struct bundleElt *elt;
2025  unsigned int j;
2026 
2027  elt = list_get_at(l, i);
2028  assert(elt);
2029 
2030  /* free all the values */
2031  for (j=0; j<list_size(&elt->values); j++)
2032  free(list_get_at(&elt->values, j));
2033  list_destroy(&elt->values);
2034 
2035  /* free the key */
2036  free(elt->key);
2037  free(elt);
2038  }
2039 
2040  list_destroy(l);
2041 }
2042 
list object
Definition: simclist.h:181
static YY_BUFFER_STATE * yy_buffer_stack
Stack as an array.
Definition: tokenparser.c:271
int yy_bs_column
The column count.
Definition: configfile.c:223
Reads lexical config files and updates database.
static size_t yy_buffer_stack_max
capacity of stack.
Definition: tokenparser.c:270
YY_DECL
The main scanner function which does all the work.
Definition: tokenparser.c:740
static size_t yy_buffer_stack_top
index of top of stack.
Definition: tokenparser.c:269
This handles debugging.
int yy_bs_lineno
The line count.
Definition: configfile.c:222