pcsc-lite  1.8.11
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 35
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 extern int tpleng;
184 
185 extern FILE *tpin, *tpout;
186 
187 #define EOB_ACT_CONTINUE_SCAN 0
188 #define EOB_ACT_END_OF_FILE 1
189 #define EOB_ACT_LAST_MATCH 2
190 
191  #define YY_LESS_LINENO(n)
192 
193 /* Return all but the first "n" matched characters back to the input stream. */
194 #define yyless(n) \
195  do \
196  { \
197  /* Undo effects of setting up tptext. */ \
198  int yyless_macro_arg = (n); \
199  YY_LESS_LINENO(yyless_macro_arg);\
200  *yy_cp = (yy_hold_char); \
201  YY_RESTORE_YY_MORE_OFFSET \
202  (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
203  YY_DO_BEFORE_ACTION; /* set up tptext again */ \
204  } \
205  while ( 0 )
206 
207 #define unput(c) yyunput( c, (yytext_ptr) )
208 
209 #ifndef YY_TYPEDEF_YY_SIZE_T
210 #define YY_TYPEDEF_YY_SIZE_T
211 typedef size_t yy_size_t;
212 #endif
213 
214 #ifndef YY_STRUCT_YY_BUFFER_STATE
215 #define YY_STRUCT_YY_BUFFER_STATE
216 struct yy_buffer_state
217  {
218  FILE *yy_input_file;
219 
220  char *yy_ch_buf; /* input buffer */
221  char *yy_buf_pos; /* current position in input buffer */
222 
223  /* Size of input buffer in bytes, not including room for EOB
224  * characters.
225  */
226  yy_size_t yy_buf_size;
227 
228  /* Number of characters read into yy_ch_buf, not including EOB
229  * characters.
230  */
231  int yy_n_chars;
232 
233  /* Whether we "own" the buffer - i.e., we know we created it,
234  * and can realloc() it to grow it, and should free() it to
235  * delete it.
236  */
237  int yy_is_our_buffer;
238 
239  /* Whether this is an "interactive" input source; if so, and
240  * if we're using stdio for input, then we want to use getc()
241  * instead of fread(), to make sure we stop fetching input after
242  * each newline.
243  */
244  int yy_is_interactive;
245 
246  /* Whether we're considered to be at the beginning of a line.
247  * If so, '^' rules will be active on the next match, otherwise
248  * not.
249  */
250  int yy_at_bol;
251 
252  int yy_bs_lineno;
253  int yy_bs_column;
255  /* Whether to try to fill the input buffer when we reach the
256  * end of it.
257  */
258  int yy_fill_buffer;
259 
260  int yy_buffer_status;
261 
262 #define YY_BUFFER_NEW 0
263 #define YY_BUFFER_NORMAL 1
264  /* When an EOF's been seen but there's still some text to process
265  * then we mark the buffer as YY_EOF_PENDING, to indicate that we
266  * shouldn't try reading from the input source any more. We might
267  * still have a bunch of tokens to match, though, because of
268  * possible backing-up.
269  *
270  * When we actually see the EOF, we change the status to "new"
271  * (via tprestart()), so that the user can continue scanning by
272  * just pointing tpin at a new input file.
273  */
274 #define YY_BUFFER_EOF_PENDING 2
275 
276  };
277 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
278 
279 /* Stack of input buffers. */
280 static size_t yy_buffer_stack_top = 0;
281 static size_t yy_buffer_stack_max = 0;
282 static YY_BUFFER_STATE * yy_buffer_stack = 0;
284 /* We provide macros for accessing buffer states in case in the
285  * future we want to put the buffer states in a more general
286  * "scanner state".
287  *
288  * Returns the top of the stack, or NULL.
289  */
290 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
291  ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
292  : NULL)
293 
294 /* Same as previous macro, but useful when we know that the buffer stack is not
295  * NULL or when we need an lvalue. For internal use only.
296  */
297 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
298 
299 /* yy_hold_char holds the character lost when tptext is formed. */
300 static char yy_hold_char;
301 static int yy_n_chars; /* number of characters read into yy_ch_buf */
302 int tpleng;
303 
304 /* Points to current character in buffer. */
305 static char *yy_c_buf_p = (char *) 0;
306 static int yy_init = 0; /* whether we need to initialize */
307 static int yy_start = 0; /* start state number */
308 
309 /* Flag which is used to allow tpwrap()'s to do buffer switches
310  * instead of setting up a fresh tpin. A bit of a hack ...
311  */
312 static int yy_did_buffer_switch_on_eof;
313 
314 void tprestart (FILE *input_file );
315 void tp_switch_to_buffer (YY_BUFFER_STATE new_buffer );
316 YY_BUFFER_STATE tp_create_buffer (FILE *file,int size );
317 void tp_delete_buffer (YY_BUFFER_STATE b );
318 void tp_flush_buffer (YY_BUFFER_STATE b );
319 void tppush_buffer_state (YY_BUFFER_STATE new_buffer );
320 void tppop_buffer_state (void );
321 
322 static void tpensure_buffer_stack (void );
323 static void tp_load_buffer_state (void );
324 static void tp_init_buffer (YY_BUFFER_STATE b,FILE *file );
325 
326 #define YY_FLUSH_BUFFER tp_flush_buffer(YY_CURRENT_BUFFER )
327 
328 YY_BUFFER_STATE tp_scan_buffer (char *base,yy_size_t size );
329 YY_BUFFER_STATE tp_scan_string (yyconst char *yy_str );
330 YY_BUFFER_STATE tp_scan_bytes (yyconst char *bytes,int len );
331 
332 void *tpalloc (yy_size_t );
333 void *tprealloc (void *,yy_size_t );
334 void tpfree (void * );
335 
336 #define yy_new_buffer tp_create_buffer
337 
338 #define yy_set_interactive(is_interactive) \
339  { \
340  if ( ! YY_CURRENT_BUFFER ){ \
341  tpensure_buffer_stack (); \
342  YY_CURRENT_BUFFER_LVALUE = \
343  tp_create_buffer(tpin,YY_BUF_SIZE ); \
344  } \
345  YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
346  }
347 
348 #define yy_set_bol(at_bol) \
349  { \
350  if ( ! YY_CURRENT_BUFFER ){\
351  tpensure_buffer_stack (); \
352  YY_CURRENT_BUFFER_LVALUE = \
353  tp_create_buffer(tpin,YY_BUF_SIZE ); \
354  } \
355  YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
356  }
357 
358 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
359 
360 /* Begin user sect3 */
361 
362 #define tpwrap(n) 1
363 #define YY_SKIP_YYWRAP
364 
365 typedef unsigned char YY_CHAR;
366 
367 FILE *tpin = (FILE *) 0, *tpout = (FILE *) 0;
368 
369 typedef int yy_state_type;
370 
371 extern int tplineno;
372 
373 int tplineno = 1;
374 
375 extern char *tptext;
376 #define yytext_ptr tptext
377 
378 static yy_state_type yy_get_previous_state (void );
379 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
380 static int yy_get_next_buffer (void );
381 static void yy_fatal_error (yyconst char msg[] );
382 
383 /* Done after the current pattern has been matched and before the
384  * corresponding action - sets up tptext.
385  */
386 #define YY_DO_BEFORE_ACTION \
387  (yytext_ptr) = yy_bp; \
388  tpleng = (size_t) (yy_cp - yy_bp); \
389  (yy_hold_char) = *yy_cp; \
390  *yy_cp = '\0'; \
391  (yy_c_buf_p) = yy_cp;
392 
393 #define YY_NUM_RULES 7
394 #define YY_END_OF_BUFFER 8
395 /* This struct is not used in this scanner,
396  but its presence is necessary. */
397 struct yy_trans_info
398  {
399  flex_int32_t yy_verify;
400  flex_int32_t yy_nxt;
401  };
402 static yyconst flex_int16_t yy_accept[39] =
403  { 0,
404  0, 0, 8, 6, 4, 2, 1, 6, 1, 0,
405  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
406  0, 0, 0, 0, 0, 0, 0, 0, 0, 3,
407  0, 0, 0, 0, 0, 0, 5, 0
408  } ;
409 
410 static yyconst flex_int32_t yy_ec[256] =
411  { 0,
412  1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
413  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
414  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
415  1, 2, 4, 4, 5, 4, 4, 4, 4, 4,
416  4, 4, 4, 4, 4, 4, 6, 7, 7, 7,
417  7, 7, 7, 7, 7, 7, 7, 4, 4, 8,
418  4, 9, 4, 4, 10, 10, 10, 10, 10, 10,
419  10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
420  10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
421  4, 1, 4, 4, 4, 1, 11, 11, 11, 11,
422 
423  12, 11, 13, 11, 14, 11, 15, 11, 11, 16,
424  11, 11, 11, 17, 18, 19, 11, 11, 11, 11,
425  20, 11, 1, 1, 1, 4, 1, 1, 1, 1,
426  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
427  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
428  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
429  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
431  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
432  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
433 
434  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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
440  } ;
441 
442 static yyconst flex_int32_t yy_meta[21] =
443  { 0,
444  1, 2, 3, 4, 4, 4, 2, 1, 1, 2,
445  2, 2, 2, 2, 2, 2, 2, 2, 2, 2
446  } ;
447 
448 static yyconst flex_int16_t yy_base[43] =
449  { 0,
450  0, 7, 49, 50, 50, 50, 0, 1, 0, 36,
451  28, 26, 28, 35, 29, 0, 26, 33, 27, 33,
452  29, 22, 0, 24, 27, 14, 27, 23, 13, 50,
453  10, 9, 4, 1, 0, 2, 50, 50, 19, 23,
454  2, 26
455  } ;
456 
457 static yyconst flex_int16_t yy_def[43] =
458  { 0,
459  39, 39, 38, 38, 38, 38, 40, 38, 40, 38,
460  38, 38, 38, 38, 38, 41, 38, 41, 38, 38,
461  38, 38, 42, 38, 42, 38, 38, 38, 38, 38,
462  38, 38, 38, 38, 38, 38, 38, 0, 38, 38,
463  38, 38
464  } ;
465 
466 static yyconst flex_int16_t yy_nxt[71] =
467  { 0,
468  38, 5, 6, 18, 7, 38, 38, 8, 5, 6,
469  37, 7, 36, 38, 8, 10, 35, 34, 11, 4,
470  4, 4, 4, 9, 9, 33, 9, 25, 32, 25,
471  31, 30, 29, 28, 27, 26, 24, 23, 22, 21,
472  20, 19, 17, 16, 15, 14, 13, 12, 38, 3,
473  38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
474  38, 38, 38, 38, 38, 38, 38, 38, 38, 38
475  } ;
476 
477 static yyconst flex_int16_t yy_chk[71] =
478  { 0,
479  0, 1, 1, 41, 1, 0, 0, 1, 2, 2,
480  36, 2, 35, 0, 2, 8, 34, 33, 8, 39,
481  39, 39, 39, 40, 40, 32, 40, 42, 31, 42,
482  29, 28, 27, 26, 25, 24, 22, 21, 20, 19,
483  18, 17, 15, 14, 13, 12, 11, 10, 3, 38,
484  38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
485  38, 38, 38, 38, 38, 38, 38, 38, 38, 38
486  } ;
487 
488 static yy_state_type yy_last_accepting_state;
489 static char *yy_last_accepting_cpos;
490 
491 extern int tp_flex_debug;
492 int tp_flex_debug = 0;
493 
494 /* The intent behind this definition is that it'll catch
495  * any uses of REJECT which flex missed.
496  */
497 #define REJECT reject_used_but_not_detected
498 #define yymore() yymore_used_but_not_detected
499 #define YY_MORE_ADJ 0
500 #define YY_RESTORE_YY_MORE_OFFSET
501 char *tptext;
502 #line 1 "tokenparser.l"
503 /*
504  * Reads lexical config files and updates database.
505  *
506  * MUSCLE SmartCard Development ( http://pcsclite.alioth.debian.org/pcsclite.html )
507  *
508  * Copyright (C) 2001-2003
509  * David Corcoran <corcoran@musclecard.com>
510  * Copyright (C) 2003-2010
511  * Ludovic Rousseau <ludovic.rousseau@free.fr>
512  *
513 Redistribution and use in source and binary forms, with or without
514 modification, are permitted provided that the following conditions
515 are met:
516 
517 1. Redistributions of source code must retain the above copyright
518  notice, this list of conditions and the following disclaimer.
519 2. Redistributions in binary form must reproduce the above copyright
520  notice, this list of conditions and the following disclaimer in the
521  documentation and/or other materials provided with the distribution.
522 3. The name of the author may not be used to endorse or promote products
523  derived from this software without specific prior written permission.
524 
525 Changes to this license can be made only by the copyright author with
526 explicit written consent.
527 
528 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
529 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
530 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
531 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
532 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
533 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
534 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
535 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
536 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
537 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
538  *
539  * $Id: tokenparser.l 6851 2014-02-14 15:43:32Z rousseau $
540  */
546 #line 47 "tokenparser.l"
547 
548 #include "config.h"
549 #include <stdio.h>
550 #include <string.h>
551 #include <errno.h>
552 #define NDEBUG
553 #include <assert.h>
554 
555 #include "simclist.h"
556 #include "debuglog.h"
557 #include "parser.h"
558 #include "strlcpycat.h"
559 
560 static void eval_key(char *pcToken, list_t *list_key);
561 static void eval_value(char *pcToken, list_t *list_values);
562 void tperrorCheck (char *pcToken_error);
563 
564 static list_t *ListKeys;
565 static list_t *ListValues;
566 
567 #define YY_NO_INPUT 1
568 #line 569 "tokenparser.c"
569 
570 #define INITIAL 0
571 
572 #ifndef YY_NO_UNISTD_H
573 /* Special case for "unistd.h", since it is non-ANSI. We include it way
574  * down here because we want the user's section 1 to have been scanned first.
575  * The user has a chance to override it with an option.
576  */
577 #include <unistd.h>
578 #endif
579 
580 #ifndef YY_EXTRA_TYPE
581 #define YY_EXTRA_TYPE void *
582 #endif
583 
584 static int yy_init_globals (void );
585 
586 /* Accessor methods to globals.
587  These are made visible to non-reentrant scanners for convenience. */
588 
589 int tplex_destroy (void );
590 
591 int tpget_debug (void );
592 
593 void tpset_debug (int debug_flag );
594 
595 YY_EXTRA_TYPE tpget_extra (void );
596 
597 void tpset_extra (YY_EXTRA_TYPE user_defined );
598 
599 FILE *tpget_in (void );
600 
601 void tpset_in (FILE * in_str );
602 
603 FILE *tpget_out (void );
604 
605 void tpset_out (FILE * out_str );
606 
607 int tpget_leng (void );
608 
609 char *tpget_text (void );
610 
611 int tpget_lineno (void );
612 
613 void tpset_lineno (int line_number );
614 
615 /* Macros after this point can all be overridden by user definitions in
616  * section 1.
617  */
618 
619 #ifndef YY_SKIP_YYWRAP
620 #ifdef __cplusplus
621 extern "C" int tpwrap (void );
622 #else
623 extern int tpwrap (void );
624 #endif
625 #endif
626 
627 #ifndef yytext_ptr
628 static void yy_flex_strncpy (char *,yyconst char *,int );
629 #endif
630 
631 #ifdef YY_NEED_STRLEN
632 static int yy_flex_strlen (yyconst char * );
633 #endif
634 
635 #ifndef YY_NO_INPUT
636 
637 #ifdef __cplusplus
638 static int yyinput (void );
639 #else
640 static int input (void );
641 #endif
642 
643 #endif
644 
645 /* Amount of stuff to slurp up with each read. */
646 #ifndef YY_READ_BUF_SIZE
647 #ifdef __ia64__
648 /* On IA-64, the buffer size is 16k, not 8k */
649 #define YY_READ_BUF_SIZE 16384
650 #else
651 #define YY_READ_BUF_SIZE 8192
652 #endif /* __ia64__ */
653 #endif
654 
655 /* Copy whatever the last rule matched to the standard output. */
656 #ifndef ECHO
657 /* This used to be an fputs(), but since the string might contain NUL's,
658  * we now use fwrite().
659  */
660 #define ECHO do { if (fwrite( tptext, tpleng, 1, tpout )) {} } while (0)
661 #endif
662 
663 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
664  * is returned in "result".
665  */
666 #ifndef YY_INPUT
667 #define YY_INPUT(buf,result,max_size) \
668  if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
669  { \
670  int c = '*'; \
671  size_t n; \
672  for ( n = 0; n < max_size && \
673  (c = getc( tpin )) != EOF && c != '\n'; ++n ) \
674  buf[n] = (char) c; \
675  if ( c == '\n' ) \
676  buf[n++] = (char) c; \
677  if ( c == EOF && ferror( tpin ) ) \
678  YY_FATAL_ERROR( "input in flex scanner failed" ); \
679  result = n; \
680  } \
681  else \
682  { \
683  errno=0; \
684  while ( (result = fread(buf, 1, max_size, tpin))==0 && ferror(tpin)) \
685  { \
686  if( errno != EINTR) \
687  { \
688  YY_FATAL_ERROR( "input in flex scanner failed" ); \
689  break; \
690  } \
691  errno=0; \
692  clearerr(tpin); \
693  } \
694  }\
695 \
696 
697 #endif
698 
699 /* No semi-colon after return; correct usage is to write "yyterminate();" -
700  * we don't want an extra ';' after the "return" because that will cause
701  * some compilers to complain about unreachable statements.
702  */
703 #ifndef yyterminate
704 #define yyterminate() return YY_NULL
705 #endif
706 
707 /* Number of entries by which start-condition stack grows. */
708 #ifndef YY_START_STACK_INCR
709 #define YY_START_STACK_INCR 25
710 #endif
711 
712 /* Report a fatal error. */
713 #ifndef YY_FATAL_ERROR
714 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
715 #endif
716 
717 /* end tables serialization structures and prototypes */
718 
719 /* Default declaration of generated scanner - a define so the user can
720  * easily add parameters.
721  */
722 #ifndef YY_DECL
723 #define YY_DECL_IS_OURS 1
724 
725 extern int tplex (void);
726 
727 #define YY_DECL int tplex (void)
728 #endif /* !YY_DECL */
729 
730 /* Code executed at the beginning of each rule, after tptext and tpleng
731  * have been set up.
732  */
733 #ifndef YY_USER_ACTION
734 #define YY_USER_ACTION
735 #endif
736 
737 /* Code executed at the end of each rule. */
738 #ifndef YY_BREAK
739 #define YY_BREAK break;
740 #endif
741 
742 #define YY_RULE_SETUP \
743  YY_USER_ACTION
744 
747 YY_DECL
748 {
749  register yy_state_type yy_current_state;
750  register char *yy_cp, *yy_bp;
751  register int yy_act;
752 
753 #line 73 "tokenparser.l"
754 
755 
756 #line 757 "tokenparser.c"
757 
758  if ( !(yy_init) )
759  {
760  (yy_init) = 1;
761 
762 #ifdef YY_USER_INIT
763  YY_USER_INIT;
764 #endif
765 
766  if ( ! (yy_start) )
767  (yy_start) = 1; /* first start state */
768 
769  if ( ! tpin )
770  tpin = stdin;
771 
772  if ( ! tpout )
773  tpout = stdout;
774 
775  if ( ! YY_CURRENT_BUFFER ) {
776  tpensure_buffer_stack ();
777  YY_CURRENT_BUFFER_LVALUE =
778  tp_create_buffer(tpin,YY_BUF_SIZE );
779  }
780 
781  tp_load_buffer_state( );
782  }
783 
784  while ( 1 ) /* loops until end-of-file is reached */
785  {
786  yy_cp = (yy_c_buf_p);
787 
788  /* Support of tptext. */
789  *yy_cp = (yy_hold_char);
790 
791  /* yy_bp points to the position in yy_ch_buf of the start of
792  * the current run.
793  */
794  yy_bp = yy_cp;
795 
796  yy_current_state = (yy_start);
797 yy_match:
798  do
799  {
800  register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
801  if ( yy_accept[yy_current_state] )
802  {
803  (yy_last_accepting_state) = yy_current_state;
804  (yy_last_accepting_cpos) = yy_cp;
805  }
806  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
807  {
808  yy_current_state = (int) yy_def[yy_current_state];
809  if ( yy_current_state >= 39 )
810  yy_c = yy_meta[(unsigned int) yy_c];
811  }
812  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
813  ++yy_cp;
814  }
815  while ( yy_base[yy_current_state] != 50 );
816 
817 yy_find_action:
818  yy_act = yy_accept[yy_current_state];
819  if ( yy_act == 0 )
820  { /* have to back up */
821  yy_cp = (yy_last_accepting_cpos);
822  yy_current_state = (yy_last_accepting_state);
823  yy_act = yy_accept[yy_current_state];
824  }
825 
826  YY_DO_BEFORE_ACTION;
827 
828 do_action: /* This label is used only to access EOF actions. */
829 
830  switch ( yy_act )
831  { /* beginning of action switch */
832  case 0: /* must back up */
833  /* undo the effects of YY_DO_BEFORE_ACTION */
834  *yy_cp = (yy_hold_char);
835  yy_cp = (yy_last_accepting_cpos);
836  yy_current_state = (yy_last_accepting_state);
837  goto yy_find_action;
838 
839 case 1:
840 YY_RULE_SETUP
841 #line 75 "tokenparser.l"
842 {}
843  YY_BREAK
844 case 2:
845 /* rule 2 can match eol */
846 YY_RULE_SETUP
847 #line 76 "tokenparser.l"
848 {}
849  YY_BREAK
850 case 3:
851 YY_RULE_SETUP
852 #line 77 "tokenparser.l"
853 { eval_key(tptext, ListKeys); }
854  YY_BREAK
855 case 4:
856 YY_RULE_SETUP
857 #line 78 "tokenparser.l"
858 {}
859  YY_BREAK
860 case 5:
861 YY_RULE_SETUP
862 #line 79 "tokenparser.l"
863 { eval_value(tptext, ListValues); }
864  YY_BREAK
865 case 6:
866 YY_RULE_SETUP
867 #line 80 "tokenparser.l"
868 { tperrorCheck(tptext); }
869  YY_BREAK
870 case 7:
871 YY_RULE_SETUP
872 #line 81 "tokenparser.l"
873 ECHO;
874  YY_BREAK
875 #line 876 "tokenparser.c"
876 case YY_STATE_EOF(INITIAL):
877  yyterminate();
878 
879  case YY_END_OF_BUFFER:
880  {
881  /* Amount of text matched not including the EOB char. */
882  int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
883 
884  /* Undo the effects of YY_DO_BEFORE_ACTION. */
885  *yy_cp = (yy_hold_char);
886  YY_RESTORE_YY_MORE_OFFSET
887 
888  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
889  {
890  /* We're scanning a new file or input source. It's
891  * possible that this happened because the user
892  * just pointed tpin at a new source and called
893  * tplex(). If so, then we have to assure
894  * consistency between YY_CURRENT_BUFFER and our
895  * globals. Here is the right place to do so, because
896  * this is the first action (other than possibly a
897  * back-up) that will match for the new input source.
898  */
899  (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
900  YY_CURRENT_BUFFER_LVALUE->yy_input_file = tpin;
901  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
902  }
903 
904  /* Note that here we test for yy_c_buf_p "<=" to the position
905  * of the first EOB in the buffer, since yy_c_buf_p will
906  * already have been incremented past the NUL character
907  * (since all states make transitions on EOB to the
908  * end-of-buffer state). Contrast this with the test
909  * in input().
910  */
911  if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
912  { /* This was really a NUL. */
913  yy_state_type yy_next_state;
914 
915  (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
916 
917  yy_current_state = yy_get_previous_state( );
918 
919  /* Okay, we're now positioned to make the NUL
920  * transition. We couldn't have
921  * yy_get_previous_state() go ahead and do it
922  * for us because it doesn't know how to deal
923  * with the possibility of jamming (and we don't
924  * want to build jamming into it because then it
925  * will run more slowly).
926  */
927 
928  yy_next_state = yy_try_NUL_trans( yy_current_state );
929 
930  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
931 
932  if ( yy_next_state )
933  {
934  /* Consume the NUL. */
935  yy_cp = ++(yy_c_buf_p);
936  yy_current_state = yy_next_state;
937  goto yy_match;
938  }
939 
940  else
941  {
942  yy_cp = (yy_c_buf_p);
943  goto yy_find_action;
944  }
945  }
946 
947  else switch ( yy_get_next_buffer( ) )
948  {
949  case EOB_ACT_END_OF_FILE:
950  {
951  (yy_did_buffer_switch_on_eof) = 0;
952 
953  if ( tpwrap( ) )
954  {
955  /* Note: because we've taken care in
956  * yy_get_next_buffer() to have set up
957  * tptext, we can now set up
958  * yy_c_buf_p so that if some total
959  * hoser (like flex itself) wants to
960  * call the scanner after we return the
961  * YY_NULL, it'll still work - another
962  * YY_NULL will get returned.
963  */
964  (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
965 
966  yy_act = YY_STATE_EOF(YY_START);
967  goto do_action;
968  }
969 
970  else
971  {
972  if ( ! (yy_did_buffer_switch_on_eof) )
973  YY_NEW_FILE;
974  }
975  break;
976  }
977 
978  case EOB_ACT_CONTINUE_SCAN:
979  (yy_c_buf_p) =
980  (yytext_ptr) + yy_amount_of_matched_text;
981 
982  yy_current_state = yy_get_previous_state( );
983 
984  yy_cp = (yy_c_buf_p);
985  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
986  goto yy_match;
987 
988  case EOB_ACT_LAST_MATCH:
989  (yy_c_buf_p) =
990  &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
991 
992  yy_current_state = yy_get_previous_state( );
993 
994  yy_cp = (yy_c_buf_p);
995  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
996  goto yy_find_action;
997  }
998  break;
999  }
1000 
1001  default:
1002  YY_FATAL_ERROR(
1003  "fatal flex scanner internal error--no action found" );
1004  } /* end of action switch */
1005  } /* end of scanning one token */
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  int 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;
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  int 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), (size_t) 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  int 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 #ifndef __cplusplus
1389 extern int isatty (int );
1390 #endif /* __cplusplus */
1391 
1392 /* Initializes or reinitializes a buffer.
1393  * This function is sometimes called more than once on the same buffer,
1394  * such as during a tprestart() or at EOF.
1395  */
1396  static void tp_init_buffer (YY_BUFFER_STATE b, FILE * file )
1397 
1398 {
1399  int oerrno = errno;
1400 
1401  tp_flush_buffer(b );
1402 
1403  b->yy_input_file = file;
1404  b->yy_fill_buffer = 1;
1405 
1406  /* If b is the current buffer, then tp_init_buffer was _probably_
1407  * called from tprestart() or through yy_get_next_buffer.
1408  * In that case, we don't want to reset the lineno or column.
1409  */
1410  if (b != YY_CURRENT_BUFFER){
1411  b->yy_bs_lineno = 1;
1412  b->yy_bs_column = 0;
1413  }
1414 
1415  b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1416 
1417  errno = oerrno;
1418 }
1419 
1424  void tp_flush_buffer (YY_BUFFER_STATE b )
1425 {
1426  if ( ! b )
1427  return;
1428 
1429  b->yy_n_chars = 0;
1430 
1431  /* We always need two end-of-buffer characters. The first causes
1432  * a transition to the end-of-buffer state. The second causes
1433  * a jam in that state.
1434  */
1435  b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1436  b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1437 
1438  b->yy_buf_pos = &b->yy_ch_buf[0];
1439 
1440  b->yy_at_bol = 1;
1441  b->yy_buffer_status = YY_BUFFER_NEW;
1442 
1443  if ( b == YY_CURRENT_BUFFER )
1444  tp_load_buffer_state( );
1445 }
1446 
1453 void tppush_buffer_state (YY_BUFFER_STATE new_buffer )
1454 {
1455  if (new_buffer == NULL)
1456  return;
1457 
1458  tpensure_buffer_stack();
1459 
1460  /* This block is copied from tp_switch_to_buffer. */
1461  if ( YY_CURRENT_BUFFER )
1462  {
1463  /* Flush out information for old buffer. */
1464  *(yy_c_buf_p) = (yy_hold_char);
1465  YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1466  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1467  }
1468 
1469  /* Only push if top exists. Otherwise, replace top. */
1470  if (YY_CURRENT_BUFFER)
1471  (yy_buffer_stack_top)++;
1472  YY_CURRENT_BUFFER_LVALUE = new_buffer;
1473 
1474  /* copied from tp_switch_to_buffer. */
1475  tp_load_buffer_state( );
1476  (yy_did_buffer_switch_on_eof) = 1;
1477 }
1478 
1484 {
1485  if (!YY_CURRENT_BUFFER)
1486  return;
1487 
1488  tp_delete_buffer(YY_CURRENT_BUFFER );
1489  YY_CURRENT_BUFFER_LVALUE = NULL;
1490  if ((yy_buffer_stack_top) > 0)
1491  --(yy_buffer_stack_top);
1492 
1493  if (YY_CURRENT_BUFFER) {
1494  tp_load_buffer_state( );
1495  (yy_did_buffer_switch_on_eof) = 1;
1496  }
1497 }
1498 
1499 /* Allocates the stack if it does not exist.
1500  * Guarantees space for at least one push.
1501  */
1502 static void tpensure_buffer_stack (void)
1503 {
1504  int num_to_alloc;
1505 
1506  if (!(yy_buffer_stack)) {
1507 
1508  /* First allocation is just for 2 elements, since we don't know if this
1509  * scanner will even need a stack. We use 2 instead of 1 to avoid an
1510  * immediate realloc on the next call.
1511  */
1512  num_to_alloc = 1;
1513  (yy_buffer_stack) = (struct yy_buffer_state**)tpalloc
1514  (num_to_alloc * sizeof(struct yy_buffer_state*)
1515  );
1516  if ( ! (yy_buffer_stack) )
1517  YY_FATAL_ERROR( "out of dynamic memory in tpensure_buffer_stack()" );
1518 
1519  memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1520 
1521  (yy_buffer_stack_max) = num_to_alloc;
1522  (yy_buffer_stack_top) = 0;
1523  return;
1524  }
1525 
1526  if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1527 
1528  /* Increase the buffer to prepare for a possible push. */
1529  int grow_size = 8 /* arbitrary grow size */;
1530 
1531  num_to_alloc = (yy_buffer_stack_max) + grow_size;
1532  (yy_buffer_stack) = (struct yy_buffer_state**)tprealloc
1533  ((yy_buffer_stack),
1534  num_to_alloc * sizeof(struct yy_buffer_state*)
1535  );
1536  if ( ! (yy_buffer_stack) )
1537  YY_FATAL_ERROR( "out of dynamic memory in tpensure_buffer_stack()" );
1538 
1539  /* zero only the new slots.*/
1540  memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1541  (yy_buffer_stack_max) = num_to_alloc;
1542  }
1543 }
1544 
1551 YY_BUFFER_STATE tp_scan_buffer (char * base, yy_size_t size )
1552 {
1553  YY_BUFFER_STATE b;
1554 
1555  if ( size < 2 ||
1556  base[size-2] != YY_END_OF_BUFFER_CHAR ||
1557  base[size-1] != YY_END_OF_BUFFER_CHAR )
1558  /* They forgot to leave room for the EOB's. */
1559  return 0;
1560 
1561  b = (YY_BUFFER_STATE) tpalloc(sizeof( struct yy_buffer_state ) );
1562  if ( ! b )
1563  YY_FATAL_ERROR( "out of dynamic memory in tp_scan_buffer()" );
1564 
1565  b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1566  b->yy_buf_pos = b->yy_ch_buf = base;
1567  b->yy_is_our_buffer = 0;
1568  b->yy_input_file = 0;
1569  b->yy_n_chars = b->yy_buf_size;
1570  b->yy_is_interactive = 0;
1571  b->yy_at_bol = 1;
1572  b->yy_fill_buffer = 0;
1573  b->yy_buffer_status = YY_BUFFER_NEW;
1574 
1575  tp_switch_to_buffer(b );
1576 
1577  return b;
1578 }
1579 
1588 YY_BUFFER_STATE tp_scan_string (yyconst char * yystr )
1589 {
1590 
1591  return tp_scan_bytes(yystr,strlen(yystr) );
1592 }
1593 
1601 YY_BUFFER_STATE tp_scan_bytes (yyconst char * yybytes, int _yybytes_len )
1602 {
1603  YY_BUFFER_STATE b;
1604  char *buf;
1605  yy_size_t n;
1606  int i;
1607 
1608  /* Get memory for full buffer, including space for trailing EOB's. */
1609  n = _yybytes_len + 2;
1610  buf = (char *) tpalloc(n );
1611  if ( ! buf )
1612  YY_FATAL_ERROR( "out of dynamic memory in tp_scan_bytes()" );
1613 
1614  for ( i = 0; i < _yybytes_len; ++i )
1615  buf[i] = yybytes[i];
1616 
1617  buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1618 
1619  b = tp_scan_buffer(buf,n );
1620  if ( ! b )
1621  YY_FATAL_ERROR( "bad buffer in tp_scan_bytes()" );
1622 
1623  /* It's okay to grow etc. this buffer, and we should throw it
1624  * away when we're done.
1625  */
1626  b->yy_is_our_buffer = 1;
1627 
1628  return b;
1629 }
1630 
1631 #ifndef YY_EXIT_FAILURE
1632 #define YY_EXIT_FAILURE 2
1633 #endif
1634 
1635 static void yy_fatal_error (yyconst char* msg )
1636 {
1637  (void) fprintf( stderr, "%s\n", msg );
1638  exit( YY_EXIT_FAILURE );
1639 }
1640 
1641 /* Redefine yyless() so it works in section 3 code. */
1642 
1643 #undef yyless
1644 #define yyless(n) \
1645  do \
1646  { \
1647  /* Undo effects of setting up tptext. */ \
1648  int yyless_macro_arg = (n); \
1649  YY_LESS_LINENO(yyless_macro_arg);\
1650  tptext[tpleng] = (yy_hold_char); \
1651  (yy_c_buf_p) = tptext + yyless_macro_arg; \
1652  (yy_hold_char) = *(yy_c_buf_p); \
1653  *(yy_c_buf_p) = '\0'; \
1654  tpleng = yyless_macro_arg; \
1655  } \
1656  while ( 0 )
1657 
1658 /* Accessor methods (get/set functions) to struct members. */
1659 
1663 int tpget_lineno (void)
1664 {
1665 
1666  return tplineno;
1667 }
1668 
1672 FILE *tpget_in (void)
1673 {
1674  return tpin;
1675 }
1676 
1680 FILE *tpget_out (void)
1681 {
1682  return tpout;
1683 }
1684 
1688 int tpget_leng (void)
1689 {
1690  return tpleng;
1691 }
1692 
1697 char *tpget_text (void)
1698 {
1699  return tptext;
1700 }
1701 
1706 void tpset_lineno (int line_number )
1707 {
1708 
1709  tplineno = line_number;
1710 }
1711 
1718 void tpset_in (FILE * in_str )
1719 {
1720  tpin = in_str ;
1721 }
1722 
1723 void tpset_out (FILE * out_str )
1724 {
1725  tpout = out_str ;
1726 }
1727 
1728 int tpget_debug (void)
1729 {
1730  return tp_flex_debug;
1731 }
1732 
1733 void tpset_debug (int bdebug )
1734 {
1735  tp_flex_debug = bdebug ;
1736 }
1737 
1738 static int yy_init_globals (void)
1739 {
1740  /* Initialization is the same as for the non-reentrant scanner.
1741  * This function is called from tplex_destroy(), so don't allocate here.
1742  */
1743 
1744  (yy_buffer_stack) = 0;
1745  (yy_buffer_stack_top) = 0;
1746  (yy_buffer_stack_max) = 0;
1747  (yy_c_buf_p) = (char *) 0;
1748  (yy_init) = 0;
1749  (yy_start) = 0;
1750 
1751 /* Defined in main.c */
1752 #ifdef YY_STDINIT
1753  tpin = stdin;
1754  tpout = stdout;
1755 #else
1756  tpin = (FILE *) 0;
1757  tpout = (FILE *) 0;
1758 #endif
1759 
1760  /* For future reference: Set errno on error, since we are called by
1761  * tplex_init()
1762  */
1763  return 0;
1764 }
1765 
1766 /* tplex_destroy is for both reentrant and non-reentrant scanners. */
1767 int tplex_destroy (void)
1768 {
1769 
1770  /* Pop the buffer stack, destroying each element. */
1771  while(YY_CURRENT_BUFFER){
1772  tp_delete_buffer(YY_CURRENT_BUFFER );
1773  YY_CURRENT_BUFFER_LVALUE = NULL;
1775  }
1776 
1777  /* Destroy the stack itself. */
1778  tpfree((yy_buffer_stack) );
1779  (yy_buffer_stack) = NULL;
1780 
1781  /* Reset the globals. This is important in a non-reentrant scanner so the next time
1782  * tplex() is called, initialization will occur. */
1783  yy_init_globals( );
1784 
1785  return 0;
1786 }
1787 
1788 /*
1789  * Internal utility routines.
1790  */
1791 
1792 #ifndef yytext_ptr
1793 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1794 {
1795  register int i;
1796  for ( i = 0; i < n; ++i )
1797  s1[i] = s2[i];
1798 }
1799 #endif
1800 
1801 #ifdef YY_NEED_STRLEN
1802 static int yy_flex_strlen (yyconst char * s )
1803 {
1804  register int n;
1805  for ( n = 0; s[n]; ++n )
1806  ;
1807 
1808  return n;
1809 }
1810 #endif
1811 
1812 void *tpalloc (yy_size_t size )
1813 {
1814  return (void *) malloc( size );
1815 }
1816 
1817 void *tprealloc (void * ptr, yy_size_t size )
1818 {
1819  /* The cast to (char *) in the following accommodates both
1820  * implementations that use char* generic pointers, and those
1821  * that use void* generic pointers. It works with the latter
1822  * because both ANSI C and C++ allow castless assignment from
1823  * any pointer type to void*, and deal with argument conversions
1824  * as though doing an assignment.
1825  */
1826  return (void *) realloc( (char *) ptr, size );
1827 }
1828 
1829 void tpfree (void * ptr )
1830 {
1831  free( (char *) ptr ); /* see tprealloc() for (char *) cast */
1832 }
1833 
1834 #define YYTABLES_NAME "yytables"
1835 
1836 #line 81 "tokenparser.l"
1837 
1838 
1839 
1840 
1841 static void eval_key(char *pcToken, list_t *list_key)
1842 {
1843  struct bundleElt *elt;
1844  int r;
1845  size_t len;
1846 
1847  /* create a new list element */
1848  elt = malloc(sizeof(*elt));
1849  assert(elt);
1850 
1851  /* <key>foobar</key>
1852  * 012345 : 5 is the first key character index */
1853 
1854  /* calculate the argument length */
1855  for (len=0; pcToken[len+5] != '<'; len++)
1856  ;
1857  len++; /* final NULL byte */
1858 
1859  elt->key = malloc(len);
1860  (void)strlcpy(elt->key, &pcToken[5], len);
1861 
1862  r = list_init(&elt->values);
1863  assert(r >= 0);
1864  (void)r;
1865 
1866  /* add the key/values */
1867  list_append(list_key, elt);
1868 
1869  /* set the list to store the values */
1870  ListValues = &elt->values;
1871 }
1872 
1873 static void eval_value(char *pcToken, list_t *list_values)
1874 {
1875  int r;
1876  size_t len;
1877  char *value;
1878  char *amp;
1879 
1880  /* <string>foobar</string>
1881  * 012345678 : 8 is the first string character index */
1882 
1883  /* calculate the argument length */
1884  for (len=0; pcToken[len+8] != '<'; len++)
1885  ;
1886  len++; /* final NULL byte */
1887 
1888  value = malloc(len);
1889  assert(value);
1890 
1891  (void)strlcpy(value, &pcToken[8], len);
1892 
1893  /* for all &amp; in the string */
1894  amp = value;
1895  while ((amp = strstr(amp, "&amp;")) != NULL)
1896  {
1897  char *p;
1898 
1899  /* just skip "amp;" substring (4 letters) */
1900  for (p = amp+1; *(p+4); p++)
1901  {
1902  *p = *(p+4);
1903  }
1904  /* terminate the now shorter string */
1905  *p = '\0';
1906 
1907  /* skip the & and continue */
1908  amp++;
1909  }
1910 
1911  r = list_append(list_values, value);
1912  assert(r >= 0);
1913  (void)r;
1914 }
1915 
1916 void tperrorCheck (char *token_error)
1917 {
1918  (void)token_error;
1919 }
1920 
1931 int LTPBundleFindValueWithKey(list_t *l, const char *key, list_t **values)
1932 {
1933  unsigned int i;
1934  int ret = 1;
1935 
1936  for (i=0; i < list_size(l); i++)
1937  {
1938  struct bundleElt *elt;
1939 
1940  elt = list_get_at(l, i);
1941  assert(elt);
1942 
1943  if (0 == strcmp(elt->key, key))
1944  {
1945  *values = &elt->values;
1946  ret = 0;
1947  }
1948  }
1949 
1950  return ret;
1951 }
1952 
1953 
1962 int bundleParse(const char *fileName, list_t *l)
1963 {
1964  FILE *file = NULL;
1965  int r;
1966 #ifndef NDEBUG
1967  int i;
1968 #endif
1969 
1970  file = fopen(fileName, "r");
1971  if (!file)
1972  {
1973  Log3(PCSC_LOG_CRITICAL, "Could not open bundle file %s: %s",
1974  fileName, strerror(errno));
1975  return 1;
1976  }
1977 
1978  r = list_init(l);
1979  assert(r >= 0);
1980  (void)r;
1981 
1982  ListKeys = l;
1983  tpin = file;
1984 
1985  do
1986  {
1987  (void)tplex();
1988  } while (!feof(file));
1989  tplex_destroy();
1990 
1991  (void)fclose(file);
1992 
1993 #ifndef NDEBUG
1994  printf("size: %d\n", list_size(l));
1995  for (i=0; i < list_size(l); i++)
1996  {
1997  struct bundleElt *elt;
1998  unsigned int j;
1999 
2000  elt = list_get_at(l, i);
2001  assert(elt);
2002  printf("Key: %s\n", elt->key);
2003 
2004  for (j=0; j<list_size(&elt->values); j++)
2005  {
2006  char *v = list_get_at(&elt->values, j);
2007  printf(" value: %s\n", v);
2008  }
2009  }
2010 #endif
2011 
2012  return 0;
2013 }
2014 
2021 {
2022  unsigned int i;
2023 
2024  for (i=0; i < list_size(l); i++)
2025  {
2026  struct bundleElt *elt;
2027  unsigned int j;
2028 
2029  elt = list_get_at(l, i);
2030  assert(elt);
2031 
2032  /* free all the values */
2033  for (j=0; j<list_size(&elt->values); j++)
2034  free(list_get_at(&elt->values, j));
2035  list_destroy(&elt->values);
2036 
2037  /* free the key */
2038  free(elt->key);
2039  free(elt);
2040  }
2041 
2042  list_destroy(l);
2043 }
2044 
list object
Definition: simclist.h:181
void tp_flush_buffer(YY_BUFFER_STATE b)
Discard all buffered characters.
Definition: tokenparser.c:1424
void tp_switch_to_buffer(YY_BUFFER_STATE new_buffer)
Switch to a different input buffer.
Definition: tokenparser.c:1300
static YY_BUFFER_STATE * yy_buffer_stack
Stack as an array.
Definition: tokenparser.c:282
void tpset_in(FILE *in_str)
Set the input stream.
Definition: tokenparser.c:1718
YY_BUFFER_STATE tp_scan_string(yyconst char *yy_str)
Setup the input buffer state to scan a string.
Definition: tokenparser.c:1588
int yy_bs_column
The column count.
Definition: configfile.c:234
int tpget_leng(void)
Get the length of the current token.
Definition: tokenparser.c:1688
int tpget_lineno(void)
Get the current line number.
Definition: tokenparser.c:1663
FILE * tpget_in(void)
Get the input stream.
Definition: tokenparser.c:1672
void tppush_buffer_state(YY_BUFFER_STATE new_buffer)
Pushes the new state onto the stack.
Definition: tokenparser.c:1453
FILE * tpget_out(void)
Get the output stream.
Definition: tokenparser.c:1680
Reads lexical config files and updates database.
int bundleParse(const char *fileName, list_t *l)
Parse a Info.plist file and file a list.
Definition: tokenparser.c:1962
char * tpget_text(void)
Get the current token.
Definition: tokenparser.c:1697
void tp_delete_buffer(YY_BUFFER_STATE b)
Destroy the buffer.
Definition: tokenparser.c:1373
prototypes of strlcpy()/strlcat() imported from OpenBSD
static size_t yy_buffer_stack_max
capacity of stack.
Definition: tokenparser.c:281
YY_BUFFER_STATE tp_scan_bytes(yyconst char *bytes, int len)
Setup the input buffer state to scan the given bytes.
Definition: tokenparser.c:1601
int LTPBundleFindValueWithKey(list_t *l, const char *key, list_t **values)
Find an optional key in a configuration file No error is logged if the key is not found...
Definition: tokenparser.c:1931
YY_DECL
The main scanner function which does all the work.
Definition: tokenparser.c:748
static size_t yy_buffer_stack_top
index of top of stack.
Definition: tokenparser.c:280
void tppop_buffer_state(void)
Removes and deletes the top of the stack, if present.
Definition: tokenparser.c:1483
YY_BUFFER_STATE tp_scan_buffer(char *base, yy_size_t size)
Setup the input buffer state to scan directly from a user-specified character buffer.
Definition: tokenparser.c:1551
void tpset_lineno(int line_number)
Set the current line number.
Definition: tokenparser.c:1706
YY_BUFFER_STATE tp_create_buffer(FILE *file, int size)
Allocate and initialize an input buffer state.
Definition: tokenparser.c:1345
void tprestart(FILE *input_file)
Immediately switch to a different input stream.
Definition: tokenparser.c:1283
This handles debugging.
int yy_bs_lineno
The line count.
Definition: configfile.c:233
void bundleRelease(list_t *l)
Free the list created by bundleParse()
Definition: tokenparser.c:2020