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