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