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