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