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