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