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