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