pcsc-lite  1.8.13
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  *
537  * $Id: tokenparser.l 7004 2014-10-02 09:26:36Z rousseau $
538  */
544 #line 44 "tokenparser.l"
545 
546 #include <config.h>
547 #include <stdio.h>
548 #include <string.h>
549 #include <errno.h>
550 #define NDEBUG
551 #include <assert.h>
552 
553 #include "simclist.h"
554 #include "debuglog.h"
555 #include "parser.h"
556 #include "strlcpycat.h"
557 
558 static void eval_key(char *pcToken, list_t *list_key);
559 static void eval_value(char *pcToken, list_t *list_values);
560 void tperrorCheck (char *pcToken_error);
561 
562 static list_t *ListKeys;
563 static list_t *ListValues;
564 
565 #define YY_NO_INPUT 1
566 #line 567 "tokenparser.c"
567 
568 #define INITIAL 0
569 
570 #ifndef YY_NO_UNISTD_H
571 /* Special case for "unistd.h", since it is non-ANSI. We include it way
572  * down here because we want the user's section 1 to have been scanned first.
573  * The user has a chance to override it with an option.
574  */
575 #include <unistd.h>
576 #endif
577 
578 #ifndef YY_EXTRA_TYPE
579 #define YY_EXTRA_TYPE void *
580 #endif
581 
582 static int yy_init_globals (void );
583 
584 /* Accessor methods to globals.
585  These are made visible to non-reentrant scanners for convenience. */
586 
587 int tplex_destroy (void );
588 
589 int tpget_debug (void );
590 
591 void tpset_debug (int debug_flag );
592 
593 YY_EXTRA_TYPE tpget_extra (void );
594 
595 void tpset_extra (YY_EXTRA_TYPE user_defined );
596 
597 FILE *tpget_in (void );
598 
599 void tpset_in (FILE * in_str );
600 
601 FILE *tpget_out (void );
602 
603 void tpset_out (FILE * out_str );
604 
605 yy_size_t tpget_leng (void );
606 
607 char *tpget_text (void );
608 
609 int tpget_lineno (void );
610 
611 void tpset_lineno (int line_number );
612 
613 /* Macros after this point can all be overridden by user definitions in
614  * section 1.
615  */
616 
617 #ifndef YY_SKIP_YYWRAP
618 #ifdef __cplusplus
619 extern "C" int tpwrap (void );
620 #else
621 extern int tpwrap (void );
622 #endif
623 #endif
624 
625 #ifndef yytext_ptr
626 static void yy_flex_strncpy (char *,yyconst char *,int );
627 #endif
628 
629 #ifdef YY_NEED_STRLEN
630 static int yy_flex_strlen (yyconst char * );
631 #endif
632 
633 #ifndef YY_NO_INPUT
634 
635 #ifdef __cplusplus
636 static int yyinput (void );
637 #else
638 static int input (void );
639 #endif
640 
641 #endif
642 
643 /* Amount of stuff to slurp up with each read. */
644 #ifndef YY_READ_BUF_SIZE
645 #ifdef __ia64__
646 /* On IA-64, the buffer size is 16k, not 8k */
647 #define YY_READ_BUF_SIZE 16384
648 #else
649 #define YY_READ_BUF_SIZE 8192
650 #endif /* __ia64__ */
651 #endif
652 
653 /* Copy whatever the last rule matched to the standard output. */
654 #ifndef ECHO
655 /* This used to be an fputs(), but since the string might contain NUL's,
656  * we now use fwrite().
657  */
658 #define ECHO do { if (fwrite( tptext, tpleng, 1, tpout )) {} } while (0)
659 #endif
660 
661 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
662  * is returned in "result".
663  */
664 #ifndef YY_INPUT
665 #define YY_INPUT(buf,result,max_size) \
666  if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
667  { \
668  int c = '*'; \
669  size_t n; \
670  for ( n = 0; n < max_size && \
671  (c = getc( tpin )) != EOF && c != '\n'; ++n ) \
672  buf[n] = (char) c; \
673  if ( c == '\n' ) \
674  buf[n++] = (char) c; \
675  if ( c == EOF && ferror( tpin ) ) \
676  YY_FATAL_ERROR( "input in flex scanner failed" ); \
677  result = n; \
678  } \
679  else \
680  { \
681  errno=0; \
682  while ( (result = fread(buf, 1, max_size, tpin))==0 && ferror(tpin)) \
683  { \
684  if( errno != EINTR) \
685  { \
686  YY_FATAL_ERROR( "input in flex scanner failed" ); \
687  break; \
688  } \
689  errno=0; \
690  clearerr(tpin); \
691  } \
692  }\
693 \
694 
695 #endif
696 
697 /* No semi-colon after return; correct usage is to write "yyterminate();" -
698  * we don't want an extra ';' after the "return" because that will cause
699  * some compilers to complain about unreachable statements.
700  */
701 #ifndef yyterminate
702 #define yyterminate() return YY_NULL
703 #endif
704 
705 /* Number of entries by which start-condition stack grows. */
706 #ifndef YY_START_STACK_INCR
707 #define YY_START_STACK_INCR 25
708 #endif
709 
710 /* Report a fatal error. */
711 #ifndef YY_FATAL_ERROR
712 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
713 #endif
714 
715 /* end tables serialization structures and prototypes */
716 
717 /* Default declaration of generated scanner - a define so the user can
718  * easily add parameters.
719  */
720 #ifndef YY_DECL
721 #define YY_DECL_IS_OURS 1
722 
723 extern int tplex (void);
724 
725 #define YY_DECL int tplex (void)
726 #endif /* !YY_DECL */
727 
728 /* Code executed at the beginning of each rule, after tptext and tpleng
729  * have been set up.
730  */
731 #ifndef YY_USER_ACTION
732 #define YY_USER_ACTION
733 #endif
734 
735 /* Code executed at the end of each rule. */
736 #ifndef YY_BREAK
737 #define YY_BREAK break;
738 #endif
739 
740 #define YY_RULE_SETUP \
741  YY_USER_ACTION
742 
745 YY_DECL
746 {
747  register yy_state_type yy_current_state;
748  register char *yy_cp, *yy_bp;
749  register int yy_act;
750 
751  if ( !(yy_init) )
752  {
753  (yy_init) = 1;
754 
755 #ifdef YY_USER_INIT
756  YY_USER_INIT;
757 #endif
758 
759  if ( ! (yy_start) )
760  (yy_start) = 1; /* first start state */
761 
762  if ( ! tpin )
763  tpin = stdin;
764 
765  if ( ! tpout )
766  tpout = stdout;
767 
768  if ( ! YY_CURRENT_BUFFER ) {
769  tpensure_buffer_stack ();
770  YY_CURRENT_BUFFER_LVALUE =
771  tp_create_buffer(tpin,YY_BUF_SIZE );
772  }
773 
774  tp_load_buffer_state( );
775  }
776 
777  {
778 #line 70 "tokenparser.l"
779 
780 
781 #line 782 "tokenparser.c"
782 
783  while ( 1 ) /* loops until end-of-file is reached */
784  {
785  yy_cp = (yy_c_buf_p);
786 
787  /* Support of tptext. */
788  *yy_cp = (yy_hold_char);
789 
790  /* yy_bp points to the position in yy_ch_buf of the start of
791  * the current run.
792  */
793  yy_bp = yy_cp;
794 
795  yy_current_state = (yy_start);
796 yy_match:
797  do
798  {
799  register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
800  if ( yy_accept[yy_current_state] )
801  {
802  (yy_last_accepting_state) = yy_current_state;
803  (yy_last_accepting_cpos) = yy_cp;
804  }
805  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
806  {
807  yy_current_state = (int) yy_def[yy_current_state];
808  if ( yy_current_state >= 39 )
809  yy_c = yy_meta[(unsigned int) yy_c];
810  }
811  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
812  ++yy_cp;
813  }
814  while ( yy_base[yy_current_state] != 50 );
815 
816 yy_find_action:
817  yy_act = yy_accept[yy_current_state];
818  if ( yy_act == 0 )
819  { /* have to back up */
820  yy_cp = (yy_last_accepting_cpos);
821  yy_current_state = (yy_last_accepting_state);
822  yy_act = yy_accept[yy_current_state];
823  }
824 
825  YY_DO_BEFORE_ACTION;
826 
827 do_action: /* This label is used only to access EOF actions. */
828 
829  switch ( yy_act )
830  { /* beginning of action switch */
831  case 0: /* must back up */
832  /* undo the effects of YY_DO_BEFORE_ACTION */
833  *yy_cp = (yy_hold_char);
834  yy_cp = (yy_last_accepting_cpos);
835  yy_current_state = (yy_last_accepting_state);
836  goto yy_find_action;
837 
838 case 1:
839 YY_RULE_SETUP
840 #line 72 "tokenparser.l"
841 {}
842  YY_BREAK
843 case 2:
844 /* rule 2 can match eol */
845 YY_RULE_SETUP
846 #line 73 "tokenparser.l"
847 {}
848  YY_BREAK
849 case 3:
850 YY_RULE_SETUP
851 #line 74 "tokenparser.l"
852 { eval_key(tptext, ListKeys); }
853  YY_BREAK
854 case 4:
855 YY_RULE_SETUP
856 #line 75 "tokenparser.l"
857 {}
858  YY_BREAK
859 case 5:
860 YY_RULE_SETUP
861 #line 76 "tokenparser.l"
862 { eval_value(tptext, ListValues); }
863  YY_BREAK
864 case 6:
865 YY_RULE_SETUP
866 #line 77 "tokenparser.l"
867 { tperrorCheck(tptext); }
868  YY_BREAK
869 case 7:
870 YY_RULE_SETUP
871 #line 78 "tokenparser.l"
872 ECHO;
873  YY_BREAK
874 #line 875 "tokenparser.c"
875 case YY_STATE_EOF(INITIAL):
876  yyterminate();
877 
878  case YY_END_OF_BUFFER:
879  {
880  /* Amount of text matched not including the EOB char. */
881  int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
882 
883  /* Undo the effects of YY_DO_BEFORE_ACTION. */
884  *yy_cp = (yy_hold_char);
885  YY_RESTORE_YY_MORE_OFFSET
886 
887  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
888  {
889  /* We're scanning a new file or input source. It's
890  * possible that this happened because the user
891  * just pointed tpin at a new source and called
892  * tplex(). If so, then we have to assure
893  * consistency between YY_CURRENT_BUFFER and our
894  * globals. Here is the right place to do so, because
895  * this is the first action (other than possibly a
896  * back-up) that will match for the new input source.
897  */
898  (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
899  YY_CURRENT_BUFFER_LVALUE->yy_input_file = tpin;
900  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
901  }
902 
903  /* Note that here we test for yy_c_buf_p "<=" to the position
904  * of the first EOB in the buffer, since yy_c_buf_p will
905  * already have been incremented past the NUL character
906  * (since all states make transitions on EOB to the
907  * end-of-buffer state). Contrast this with the test
908  * in input().
909  */
910  if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
911  { /* This was really a NUL. */
912  yy_state_type yy_next_state;
913 
914  (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
915 
916  yy_current_state = yy_get_previous_state( );
917 
918  /* Okay, we're now positioned to make the NUL
919  * transition. We couldn't have
920  * yy_get_previous_state() go ahead and do it
921  * for us because it doesn't know how to deal
922  * with the possibility of jamming (and we don't
923  * want to build jamming into it because then it
924  * will run more slowly).
925  */
926 
927  yy_next_state = yy_try_NUL_trans( yy_current_state );
928 
929  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
930 
931  if ( yy_next_state )
932  {
933  /* Consume the NUL. */
934  yy_cp = ++(yy_c_buf_p);
935  yy_current_state = yy_next_state;
936  goto yy_match;
937  }
938 
939  else
940  {
941  yy_cp = (yy_c_buf_p);
942  goto yy_find_action;
943  }
944  }
945 
946  else switch ( yy_get_next_buffer( ) )
947  {
948  case EOB_ACT_END_OF_FILE:
949  {
950  (yy_did_buffer_switch_on_eof) = 0;
951 
952  if ( tpwrap( ) )
953  {
954  /* Note: because we've taken care in
955  * yy_get_next_buffer() to have set up
956  * tptext, we can now set up
957  * yy_c_buf_p so that if some total
958  * hoser (like flex itself) wants to
959  * call the scanner after we return the
960  * YY_NULL, it'll still work - another
961  * YY_NULL will get returned.
962  */
963  (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
964 
965  yy_act = YY_STATE_EOF(YY_START);
966  goto do_action;
967  }
968 
969  else
970  {
971  if ( ! (yy_did_buffer_switch_on_eof) )
972  YY_NEW_FILE;
973  }
974  break;
975  }
976 
977  case EOB_ACT_CONTINUE_SCAN:
978  (yy_c_buf_p) =
979  (yytext_ptr) + yy_amount_of_matched_text;
980 
981  yy_current_state = yy_get_previous_state( );
982 
983  yy_cp = (yy_c_buf_p);
984  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
985  goto yy_match;
986 
987  case EOB_ACT_LAST_MATCH:
988  (yy_c_buf_p) =
989  &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
990 
991  yy_current_state = yy_get_previous_state( );
992 
993  yy_cp = (yy_c_buf_p);
994  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
995  goto yy_find_action;
996  }
997  break;
998  }
999 
1000  default:
1001  YY_FATAL_ERROR(
1002  "fatal flex scanner internal error--no action found" );
1003  } /* end of action switch */
1004  } /* end of scanning one token */
1005  } /* end of user's declarations */
1006 } /* end of tplex */
1007 
1008 /* yy_get_next_buffer - try to read in a new buffer
1009  *
1010  * Returns a code representing an action:
1011  * EOB_ACT_LAST_MATCH -
1012  * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1013  * EOB_ACT_END_OF_FILE - end of file
1014  */
1015 static int yy_get_next_buffer (void)
1016 {
1017  register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1018  register char *source = (yytext_ptr);
1019  register int number_to_move, i;
1020  int ret_val;
1021 
1022  if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1023  YY_FATAL_ERROR(
1024  "fatal flex scanner internal error--end of buffer missed" );
1025 
1026  if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1027  { /* Don't try to fill the buffer, so this is an EOF. */
1028  if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1029  {
1030  /* We matched a single character, the EOB, so
1031  * treat this as a final EOF.
1032  */
1033  return EOB_ACT_END_OF_FILE;
1034  }
1035 
1036  else
1037  {
1038  /* We matched some text prior to the EOB, first
1039  * process it.
1040  */
1041  return EOB_ACT_LAST_MATCH;
1042  }
1043  }
1044 
1045  /* Try to read more data. */
1046 
1047  /* First move last chars to start of buffer. */
1048  number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1049 
1050  for ( i = 0; i < number_to_move; ++i )
1051  *(dest++) = *(source++);
1052 
1053  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1054  /* don't do the read, it's not guaranteed to return an EOF,
1055  * just force an EOF
1056  */
1057  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1058 
1059  else
1060  {
1061  yy_size_t num_to_read =
1062  YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1063 
1064  while ( num_to_read <= 0 )
1065  { /* Not enough room in the buffer - grow it. */
1066 
1067  /* just a shorter name for the current buffer */
1068  YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1069 
1070  int yy_c_buf_p_offset =
1071  (int) ((yy_c_buf_p) - b->yy_ch_buf);
1072 
1073  if ( b->yy_is_our_buffer )
1074  {
1075  yy_size_t new_size = b->yy_buf_size * 2;
1076 
1077  if ( new_size <= 0 )
1078  b->yy_buf_size += b->yy_buf_size / 8;
1079  else
1080  b->yy_buf_size *= 2;
1081 
1082  b->yy_ch_buf = (char *)
1083  /* Include room in for 2 EOB chars. */
1084  tprealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1085  }
1086  else
1087  /* Can't grow it, we don't own it. */
1088  b->yy_ch_buf = 0;
1089 
1090  if ( ! b->yy_ch_buf )
1091  YY_FATAL_ERROR(
1092  "fatal error - scanner input buffer overflow" );
1093 
1094  (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1095 
1096  num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1097  number_to_move - 1;
1098 
1099  }
1100 
1101  if ( num_to_read > YY_READ_BUF_SIZE )
1102  num_to_read = YY_READ_BUF_SIZE;
1103 
1104  /* Read in more data. */
1105  YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1106  (yy_n_chars), num_to_read );
1107 
1108  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1109  }
1110 
1111  if ( (yy_n_chars) == 0 )
1112  {
1113  if ( number_to_move == YY_MORE_ADJ )
1114  {
1115  ret_val = EOB_ACT_END_OF_FILE;
1116  tprestart(tpin );
1117  }
1118 
1119  else
1120  {
1121  ret_val = EOB_ACT_LAST_MATCH;
1122  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1123  YY_BUFFER_EOF_PENDING;
1124  }
1125  }
1126 
1127  else
1128  ret_val = EOB_ACT_CONTINUE_SCAN;
1129 
1130  if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1131  /* Extend the array by 50%, plus the number we really need. */
1132  yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1133  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) tprealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1134  if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1135  YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1136  }
1137 
1138  (yy_n_chars) += number_to_move;
1139  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1140  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1141 
1142  (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1143 
1144  return ret_val;
1145 }
1146 
1147 /* yy_get_previous_state - get the state just before the EOB char was reached */
1148 
1149  static yy_state_type yy_get_previous_state (void)
1150 {
1151  register yy_state_type yy_current_state;
1152  register char *yy_cp;
1153 
1154  yy_current_state = (yy_start);
1155 
1156  for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1157  {
1158  register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1159  if ( yy_accept[yy_current_state] )
1160  {
1161  (yy_last_accepting_state) = yy_current_state;
1162  (yy_last_accepting_cpos) = yy_cp;
1163  }
1164  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1165  {
1166  yy_current_state = (int) yy_def[yy_current_state];
1167  if ( yy_current_state >= 39 )
1168  yy_c = yy_meta[(unsigned int) yy_c];
1169  }
1170  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1171  }
1172 
1173  return yy_current_state;
1174 }
1175 
1176 /* yy_try_NUL_trans - try to make a transition on the NUL character
1177  *
1178  * synopsis
1179  * next_state = yy_try_NUL_trans( current_state );
1180  */
1181  static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1182 {
1183  register int yy_is_jam;
1184  register char *yy_cp = (yy_c_buf_p);
1185 
1186  register YY_CHAR yy_c = 1;
1187  if ( yy_accept[yy_current_state] )
1188  {
1189  (yy_last_accepting_state) = yy_current_state;
1190  (yy_last_accepting_cpos) = yy_cp;
1191  }
1192  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1193  {
1194  yy_current_state = (int) yy_def[yy_current_state];
1195  if ( yy_current_state >= 39 )
1196  yy_c = yy_meta[(unsigned int) yy_c];
1197  }
1198  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1199  yy_is_jam = (yy_current_state == 38);
1200 
1201  return yy_is_jam ? 0 : yy_current_state;
1202 }
1203 
1204 #ifndef YY_NO_INPUT
1205 #ifdef __cplusplus
1206  static int yyinput (void)
1207 #else
1208  static int input (void)
1209 #endif
1210 
1211 {
1212  int c;
1213 
1214  *(yy_c_buf_p) = (yy_hold_char);
1215 
1216  if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1217  {
1218  /* yy_c_buf_p now points to the character we want to return.
1219  * If this occurs *before* the EOB characters, then it's a
1220  * valid NUL; if not, then we've hit the end of the buffer.
1221  */
1222  if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1223  /* This was really a NUL. */
1224  *(yy_c_buf_p) = '\0';
1225 
1226  else
1227  { /* need more input */
1228  yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
1229  ++(yy_c_buf_p);
1230 
1231  switch ( yy_get_next_buffer( ) )
1232  {
1233  case EOB_ACT_LAST_MATCH:
1234  /* This happens because yy_g_n_b()
1235  * sees that we've accumulated a
1236  * token and flags that we need to
1237  * try matching the token before
1238  * proceeding. But for input(),
1239  * there's no matching to consider.
1240  * So convert the EOB_ACT_LAST_MATCH
1241  * to EOB_ACT_END_OF_FILE.
1242  */
1243 
1244  /* Reset buffer status. */
1245  tprestart(tpin );
1246 
1247  /*FALLTHROUGH*/
1248 
1249  case EOB_ACT_END_OF_FILE:
1250  {
1251  if ( tpwrap( ) )
1252  return EOF;
1253 
1254  if ( ! (yy_did_buffer_switch_on_eof) )
1255  YY_NEW_FILE;
1256 #ifdef __cplusplus
1257  return yyinput();
1258 #else
1259  return input();
1260 #endif
1261  }
1262 
1263  case EOB_ACT_CONTINUE_SCAN:
1264  (yy_c_buf_p) = (yytext_ptr) + offset;
1265  break;
1266  }
1267  }
1268  }
1269 
1270  c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1271  *(yy_c_buf_p) = '\0'; /* preserve tptext */
1272  (yy_hold_char) = *++(yy_c_buf_p);
1273 
1274  return c;
1275 }
1276 #endif /* ifndef YY_NO_INPUT */
1277 
1283  void tprestart (FILE * input_file )
1284 {
1285 
1286  if ( ! YY_CURRENT_BUFFER ){
1287  tpensure_buffer_stack ();
1288  YY_CURRENT_BUFFER_LVALUE =
1289  tp_create_buffer(tpin,YY_BUF_SIZE );
1290  }
1291 
1292  tp_init_buffer(YY_CURRENT_BUFFER,input_file );
1293  tp_load_buffer_state( );
1294 }
1295 
1300  void tp_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1301 {
1302 
1303  /* TODO. We should be able to replace this entire function body
1304  * with
1305  * tppop_buffer_state();
1306  * tppush_buffer_state(new_buffer);
1307  */
1308  tpensure_buffer_stack ();
1309  if ( YY_CURRENT_BUFFER == new_buffer )
1310  return;
1311 
1312  if ( YY_CURRENT_BUFFER )
1313  {
1314  /* Flush out information for old buffer. */
1315  *(yy_c_buf_p) = (yy_hold_char);
1316  YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1317  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1318  }
1319 
1320  YY_CURRENT_BUFFER_LVALUE = new_buffer;
1321  tp_load_buffer_state( );
1322 
1323  /* We don't actually know whether we did this switch during
1324  * EOF (tpwrap()) processing, but the only time this flag
1325  * is looked at is after tpwrap() is called, so it's safe
1326  * to go ahead and always set it.
1327  */
1328  (yy_did_buffer_switch_on_eof) = 1;
1329 }
1330 
1331 static void tp_load_buffer_state (void)
1332 {
1333  (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1334  (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1335  tpin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1336  (yy_hold_char) = *(yy_c_buf_p);
1337 }
1338 
1345  YY_BUFFER_STATE tp_create_buffer (FILE * file, int size )
1346 {
1347  YY_BUFFER_STATE b;
1348 
1349  b = (YY_BUFFER_STATE) tpalloc(sizeof( struct yy_buffer_state ) );
1350  if ( ! b )
1351  YY_FATAL_ERROR( "out of dynamic memory in tp_create_buffer()" );
1352 
1353  b->yy_buf_size = size;
1354 
1355  /* yy_ch_buf has to be 2 characters longer than the size given because
1356  * we need to put in 2 end-of-buffer characters.
1357  */
1358  b->yy_ch_buf = (char *) tpalloc(b->yy_buf_size + 2 );
1359  if ( ! b->yy_ch_buf )
1360  YY_FATAL_ERROR( "out of dynamic memory in tp_create_buffer()" );
1361 
1362  b->yy_is_our_buffer = 1;
1363 
1364  tp_init_buffer(b,file );
1365 
1366  return b;
1367 }
1368 
1373  void tp_delete_buffer (YY_BUFFER_STATE b )
1374 {
1375 
1376  if ( ! b )
1377  return;
1378 
1379  if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1380  YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1381 
1382  if ( b->yy_is_our_buffer )
1383  tpfree((void *) b->yy_ch_buf );
1384 
1385  tpfree((void *) b );
1386 }
1387 
1388 /* Initializes or reinitializes a buffer.
1389  * This function is sometimes called more than once on the same buffer,
1390  * such as during a tprestart() or at EOF.
1391  */
1392  static void tp_init_buffer (YY_BUFFER_STATE b, FILE * file )
1393 
1394 {
1395  int oerrno = errno;
1396 
1397  tp_flush_buffer(b );
1398 
1399  b->yy_input_file = file;
1400  b->yy_fill_buffer = 1;
1401 
1402  /* If b is the current buffer, then tp_init_buffer was _probably_
1403  * called from tprestart() or through yy_get_next_buffer.
1404  * In that case, we don't want to reset the lineno or column.
1405  */
1406  if (b != YY_CURRENT_BUFFER){
1407  b->yy_bs_lineno = 1;
1408  b->yy_bs_column = 0;
1409  }
1410 
1411  b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1412 
1413  errno = oerrno;
1414 }
1415 
1420  void tp_flush_buffer (YY_BUFFER_STATE b )
1421 {
1422  if ( ! b )
1423  return;
1424 
1425  b->yy_n_chars = 0;
1426 
1427  /* We always need two end-of-buffer characters. The first causes
1428  * a transition to the end-of-buffer state. The second causes
1429  * a jam in that state.
1430  */
1431  b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1432  b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1433 
1434  b->yy_buf_pos = &b->yy_ch_buf[0];
1435 
1436  b->yy_at_bol = 1;
1437  b->yy_buffer_status = YY_BUFFER_NEW;
1438 
1439  if ( b == YY_CURRENT_BUFFER )
1440  tp_load_buffer_state( );
1441 }
1442 
1449 void tppush_buffer_state (YY_BUFFER_STATE new_buffer )
1450 {
1451  if (new_buffer == NULL)
1452  return;
1453 
1454  tpensure_buffer_stack();
1455 
1456  /* This block is copied from tp_switch_to_buffer. */
1457  if ( YY_CURRENT_BUFFER )
1458  {
1459  /* Flush out information for old buffer. */
1460  *(yy_c_buf_p) = (yy_hold_char);
1461  YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1462  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1463  }
1464 
1465  /* Only push if top exists. Otherwise, replace top. */
1466  if (YY_CURRENT_BUFFER)
1467  (yy_buffer_stack_top)++;
1468  YY_CURRENT_BUFFER_LVALUE = new_buffer;
1469 
1470  /* copied from tp_switch_to_buffer. */
1471  tp_load_buffer_state( );
1472  (yy_did_buffer_switch_on_eof) = 1;
1473 }
1474 
1479 void tppop_buffer_state (void)
1480 {
1481  if (!YY_CURRENT_BUFFER)
1482  return;
1483 
1484  tp_delete_buffer(YY_CURRENT_BUFFER );
1485  YY_CURRENT_BUFFER_LVALUE = NULL;
1486  if ((yy_buffer_stack_top) > 0)
1487  --(yy_buffer_stack_top);
1488 
1489  if (YY_CURRENT_BUFFER) {
1490  tp_load_buffer_state( );
1491  (yy_did_buffer_switch_on_eof) = 1;
1492  }
1493 }
1494 
1495 /* Allocates the stack if it does not exist.
1496  * Guarantees space for at least one push.
1497  */
1498 static void tpensure_buffer_stack (void)
1499 {
1500  yy_size_t num_to_alloc;
1501 
1502  if (!(yy_buffer_stack)) {
1503 
1504  /* First allocation is just for 2 elements, since we don't know if this
1505  * scanner will even need a stack. We use 2 instead of 1 to avoid an
1506  * immediate realloc on the next call.
1507  */
1508  num_to_alloc = 1;
1509  (yy_buffer_stack) = (struct yy_buffer_state**)tpalloc
1510  (num_to_alloc * sizeof(struct yy_buffer_state*)
1511  );
1512  if ( ! (yy_buffer_stack) )
1513  YY_FATAL_ERROR( "out of dynamic memory in tpensure_buffer_stack()" );
1514 
1515  memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1516 
1517  (yy_buffer_stack_max) = num_to_alloc;
1518  (yy_buffer_stack_top) = 0;
1519  return;
1520  }
1521 
1522  if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1523 
1524  /* Increase the buffer to prepare for a possible push. */
1525  int grow_size = 8 /* arbitrary grow size */;
1526 
1527  num_to_alloc = (yy_buffer_stack_max) + grow_size;
1528  (yy_buffer_stack) = (struct yy_buffer_state**)tprealloc
1529  ((yy_buffer_stack),
1530  num_to_alloc * sizeof(struct yy_buffer_state*)
1531  );
1532  if ( ! (yy_buffer_stack) )
1533  YY_FATAL_ERROR( "out of dynamic memory in tpensure_buffer_stack()" );
1534 
1535  /* zero only the new slots.*/
1536  memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1537  (yy_buffer_stack_max) = num_to_alloc;
1538  }
1539 }
1540 
1547 YY_BUFFER_STATE tp_scan_buffer (char * base, yy_size_t size )
1548 {
1549  YY_BUFFER_STATE b;
1550 
1551  if ( size < 2 ||
1552  base[size-2] != YY_END_OF_BUFFER_CHAR ||
1553  base[size-1] != YY_END_OF_BUFFER_CHAR )
1554  /* They forgot to leave room for the EOB's. */
1555  return 0;
1556 
1557  b = (YY_BUFFER_STATE) tpalloc(sizeof( struct yy_buffer_state ) );
1558  if ( ! b )
1559  YY_FATAL_ERROR( "out of dynamic memory in tp_scan_buffer()" );
1560 
1561  b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1562  b->yy_buf_pos = b->yy_ch_buf = base;
1563  b->yy_is_our_buffer = 0;
1564  b->yy_input_file = 0;
1565  b->yy_n_chars = b->yy_buf_size;
1566  b->yy_is_interactive = 0;
1567  b->yy_at_bol = 1;
1568  b->yy_fill_buffer = 0;
1569  b->yy_buffer_status = YY_BUFFER_NEW;
1570 
1571  tp_switch_to_buffer(b );
1572 
1573  return b;
1574 }
1575 
1584 YY_BUFFER_STATE tp_scan_string (yyconst char * yystr )
1585 {
1586 
1587  return tp_scan_bytes(yystr,strlen(yystr) );
1588 }
1589 
1597 YY_BUFFER_STATE tp_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
1598 {
1599  YY_BUFFER_STATE b;
1600  char *buf;
1601  yy_size_t n;
1602  yy_size_t i;
1603 
1604  /* Get memory for full buffer, including space for trailing EOB's. */
1605  n = _yybytes_len + 2;
1606  buf = (char *) tpalloc(n );
1607  if ( ! buf )
1608  YY_FATAL_ERROR( "out of dynamic memory in tp_scan_bytes()" );
1609 
1610  for ( i = 0; i < _yybytes_len; ++i )
1611  buf[i] = yybytes[i];
1612 
1613  buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1614 
1615  b = tp_scan_buffer(buf,n );
1616  if ( ! b )
1617  YY_FATAL_ERROR( "bad buffer in tp_scan_bytes()" );
1618 
1619  /* It's okay to grow etc. this buffer, and we should throw it
1620  * away when we're done.
1621  */
1622  b->yy_is_our_buffer = 1;
1623 
1624  return b;
1625 }
1626 
1627 #ifndef YY_EXIT_FAILURE
1628 #define YY_EXIT_FAILURE 2
1629 #endif
1630 
1631 static void yy_fatal_error (yyconst char* msg )
1632 {
1633  (void) fprintf( stderr, "%s\n", msg );
1634  exit( YY_EXIT_FAILURE );
1635 }
1636 
1637 /* Redefine yyless() so it works in section 3 code. */
1638 
1639 #undef yyless
1640 #define yyless(n) \
1641  do \
1642  { \
1643  /* Undo effects of setting up tptext. */ \
1644  int yyless_macro_arg = (n); \
1645  YY_LESS_LINENO(yyless_macro_arg);\
1646  tptext[tpleng] = (yy_hold_char); \
1647  (yy_c_buf_p) = tptext + yyless_macro_arg; \
1648  (yy_hold_char) = *(yy_c_buf_p); \
1649  *(yy_c_buf_p) = '\0'; \
1650  tpleng = yyless_macro_arg; \
1651  } \
1652  while ( 0 )
1653 
1654 /* Accessor methods (get/set functions) to struct members. */
1655 
1659 int tpget_lineno (void)
1660 {
1661 
1662  return tplineno;
1663 }
1664 
1668 FILE *tpget_in (void)
1669 {
1670  return tpin;
1671 }
1672 
1676 FILE *tpget_out (void)
1677 {
1678  return tpout;
1679 }
1680 
1684 yy_size_t tpget_leng (void)
1685 {
1686  return tpleng;
1687 }
1688 
1693 char *tpget_text (void)
1694 {
1695  return tptext;
1696 }
1697 
1702 void tpset_lineno (int line_number )
1703 {
1704 
1705  tplineno = line_number;
1706 }
1707 
1714 void tpset_in (FILE * in_str )
1715 {
1716  tpin = in_str ;
1717 }
1718 
1719 void tpset_out (FILE * out_str )
1720 {
1721  tpout = out_str ;
1722 }
1723 
1724 int tpget_debug (void)
1725 {
1726  return tp_flex_debug;
1727 }
1728 
1729 void tpset_debug (int bdebug )
1730 {
1731  tp_flex_debug = bdebug ;
1732 }
1733 
1734 static int yy_init_globals (void)
1735 {
1736  /* Initialization is the same as for the non-reentrant scanner.
1737  * This function is called from tplex_destroy(), so don't allocate here.
1738  */
1739 
1740  (yy_buffer_stack) = 0;
1741  (yy_buffer_stack_top) = 0;
1742  (yy_buffer_stack_max) = 0;
1743  (yy_c_buf_p) = (char *) 0;
1744  (yy_init) = 0;
1745  (yy_start) = 0;
1746 
1747 /* Defined in main.c */
1748 #ifdef YY_STDINIT
1749  tpin = stdin;
1750  tpout = stdout;
1751 #else
1752  tpin = (FILE *) 0;
1753  tpout = (FILE *) 0;
1754 #endif
1755 
1756  /* For future reference: Set errno on error, since we are called by
1757  * tplex_init()
1758  */
1759  return 0;
1760 }
1761 
1762 /* tplex_destroy is for both reentrant and non-reentrant scanners. */
1763 int tplex_destroy (void)
1764 {
1765 
1766  /* Pop the buffer stack, destroying each element. */
1767  while(YY_CURRENT_BUFFER){
1768  tp_delete_buffer(YY_CURRENT_BUFFER );
1769  YY_CURRENT_BUFFER_LVALUE = NULL;
1770  tppop_buffer_state();
1771  }
1772 
1773  /* Destroy the stack itself. */
1774  tpfree((yy_buffer_stack) );
1775  (yy_buffer_stack) = NULL;
1776 
1777  /* Reset the globals. This is important in a non-reentrant scanner so the next time
1778  * tplex() is called, initialization will occur. */
1779  yy_init_globals( );
1780 
1781  return 0;
1782 }
1783 
1784 /*
1785  * Internal utility routines.
1786  */
1787 
1788 #ifndef yytext_ptr
1789 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1790 {
1791  register int i;
1792  for ( i = 0; i < n; ++i )
1793  s1[i] = s2[i];
1794 }
1795 #endif
1796 
1797 #ifdef YY_NEED_STRLEN
1798 static int yy_flex_strlen (yyconst char * s )
1799 {
1800  register int n;
1801  for ( n = 0; s[n]; ++n )
1802  ;
1803 
1804  return n;
1805 }
1806 #endif
1807 
1808 void *tpalloc (yy_size_t size )
1809 {
1810  return (void *) malloc( size );
1811 }
1812 
1813 void *tprealloc (void * ptr, yy_size_t size )
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 (void *) realloc( (char *) 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  (void)strlcpy(elt->key, &pcToken[5], len);
1857 
1858  r = list_init(&elt->values);
1859  assert(r >= 0);
1860  (void)r;
1861 
1862  /* add the key/values */
1863  list_append(list_key, elt);
1864 
1865  /* set the list to store the values */
1866  ListValues = &elt->values;
1867 }
1868 
1869 static void eval_value(char *pcToken, list_t *list_values)
1870 {
1871  int r;
1872  size_t len;
1873  char *value;
1874  char *amp;
1875 
1876  /* <string>foobar</string>
1877  * 012345678 : 8 is the first string character index */
1878 
1879  /* calculate the argument length */
1880  for (len=0; pcToken[len+8] != '<'; len++)
1881  ;
1882  len++; /* final NULL byte */
1883 
1884  value = malloc(len);
1885  assert(value);
1886 
1887  (void)strlcpy(value, &pcToken[8], len);
1888 
1889  /* for all &amp; in the string */
1890  amp = value;
1891  while ((amp = strstr(amp, "&amp;")) != NULL)
1892  {
1893  char *p;
1894 
1895  /* just skip "amp;" substring (4 letters) */
1896  for (p = amp+1; *(p+4); p++)
1897  {
1898  *p = *(p+4);
1899  }
1900  /* terminate the now shorter string */
1901  *p = '\0';
1902 
1903  /* skip the & and continue */
1904  amp++;
1905  }
1906 
1907  r = list_append(list_values, value);
1908  assert(r >= 0);
1909  (void)r;
1910 }
1911 
1912 void tperrorCheck (char *token_error)
1913 {
1914  (void)token_error;
1915 }
1916 
1927 int LTPBundleFindValueWithKey(list_t *l, const char *key, list_t **values)
1928 {
1929  unsigned int i;
1930  int ret = 1;
1931 
1932  for (i=0; i < list_size(l); i++)
1933  {
1934  struct bundleElt *elt;
1935 
1936  elt = list_get_at(l, i);
1937  assert(elt);
1938 
1939  if (0 == strcmp(elt->key, key))
1940  {
1941  *values = &elt->values;
1942  ret = 0;
1943  }
1944  }
1945 
1946  return ret;
1947 }
1948 
1949 
1958 int bundleParse(const char *fileName, list_t *l)
1959 {
1960  FILE *file = NULL;
1961  int r;
1962 #ifndef NDEBUG
1963  int i;
1964 #endif
1965 
1966  file = fopen(fileName, "r");
1967  if (!file)
1968  {
1969  Log3(PCSC_LOG_CRITICAL, "Could not open bundle file %s: %s",
1970  fileName, strerror(errno));
1971  return 1;
1972  }
1973 
1974  r = list_init(l);
1975  assert(r >= 0);
1976  (void)r;
1977 
1978  ListKeys = l;
1979  tpin = file;
1980 
1981  do
1982  {
1983  (void)tplex();
1984  } while (!feof(file));
1985  tplex_destroy();
1986 
1987  (void)fclose(file);
1988 
1989 #ifndef NDEBUG
1990  printf("size: %d\n", list_size(l));
1991  for (i=0; i < list_size(l); i++)
1992  {
1993  struct bundleElt *elt;
1994  unsigned int j;
1995 
1996  elt = list_get_at(l, i);
1997  assert(elt);
1998  printf("Key: %s\n", elt->key);
1999 
2000  for (j=0; j<list_size(&elt->values); j++)
2001  {
2002  char *v = list_get_at(&elt->values, j);
2003  printf(" value: %s\n", v);
2004  }
2005  }
2006 #endif
2007 
2008  return 0;
2009 }
2010 
2016 void bundleRelease(list_t *l)
2017 {
2018  unsigned int i;
2019 
2020  for (i=0; i < list_size(l); i++)
2021  {
2022  struct bundleElt *elt;
2023  unsigned int j;
2024 
2025  elt = list_get_at(l, i);
2026  assert(elt);
2027 
2028  /* free all the values */
2029  for (j=0; j<list_size(&elt->values); j++)
2030  free(list_get_at(&elt->values, j));
2031  list_destroy(&elt->values);
2032 
2033  /* free the key */
2034  free(elt->key);
2035  free(elt);
2036  }
2037 
2038  list_destroy(l);
2039 }
2040 
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:235
Reads lexical config files and updates database.
prototypes of strlcpy()/strlcat() imported from OpenBSD
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:746
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:234