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