pcsc-lite  1.8.8
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://www.linuxnet.com )
475  *
476  * Copyright (C) 1999-2002
477  * David Corcoran <corcoran@linuxnet.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  * $Id: configfile.l 6501 2013-01-15 19:28:04Z rousseau $
484  */
485 #line 17 "configfile.l"
486 #include <dirent.h>
487 
488 #include "wintypes.h"
489 #include "pcscd.h"
490 #include "readerfactory.h"
491 #include "configfile.h"
492 
493 int evaluatetoken(char *pcToken);
494 
495 static int iLinenumber;
496 static int iOldLinenumber;
497 static char *pcPrevious;
498 static char *pcCurrent;
499 static char *pcFriendlyname;
500 static const char *pcDevicename;
501 static char *pcLibpath;
502 static char *pcChannelid;
503 static int badError;
504 static SerialReader *reader_list;
505 static int reader_list_size;
506 const char *ConfFile;
507 
508 void tok_error(char *pcToken_error);
509 
510 #define YY_NO_INPUT 1
511 #line 512 "configfile.c"
512 
513 #define INITIAL 0
514 
515 #ifndef YY_NO_UNISTD_H
516 /* Special case for "unistd.h", since it is non-ANSI. We include it way
517  * down here because we want the user's section 1 to have been scanned first.
518  * The user has a chance to override it with an option.
519  */
520 #include <unistd.h>
521 #endif
522 
523 #ifndef YY_EXTRA_TYPE
524 #define YY_EXTRA_TYPE void *
525 #endif
526 
527 static int yy_init_globals (void );
528 
529 /* Accessor methods to globals.
530  These are made visible to non-reentrant scanners for convenience. */
531 
532 int yylex_destroy (void );
533 
534 int yyget_debug (void );
535 
536 void yyset_debug (int debug_flag );
537 
538 YY_EXTRA_TYPE yyget_extra (void );
539 
540 void yyset_extra (YY_EXTRA_TYPE user_defined );
541 
542 FILE *yyget_in (void );
543 
544 void yyset_in (FILE * in_str );
545 
546 FILE *yyget_out (void );
547 
548 void yyset_out (FILE * out_str );
549 
550 int yyget_leng (void );
551 
552 char *yyget_text (void );
553 
554 int yyget_lineno (void );
555 
556 void yyset_lineno (int line_number );
557 
558 /* Macros after this point can all be overridden by user definitions in
559  * section 1.
560  */
561 
562 #ifndef YY_SKIP_YYWRAP
563 #ifdef __cplusplus
564 extern "C" int yywrap (void );
565 #else
566 extern int yywrap (void );
567 #endif
568 #endif
569 
570 #ifndef yytext_ptr
571 static void yy_flex_strncpy (char *,yyconst char *,int );
572 #endif
573 
574 #ifdef YY_NEED_STRLEN
575 static int yy_flex_strlen (yyconst char * );
576 #endif
577 
578 #ifndef YY_NO_INPUT
579 
580 #ifdef __cplusplus
581 static int yyinput (void );
582 #else
583 static int input (void );
584 #endif
585 
586 #endif
587 
588 /* Amount of stuff to slurp up with each read. */
589 #ifndef YY_READ_BUF_SIZE
590 #ifdef __ia64__
591 /* On IA-64, the buffer size is 16k, not 8k */
592 #define YY_READ_BUF_SIZE 16384
593 #else
594 #define YY_READ_BUF_SIZE 8192
595 #endif /* __ia64__ */
596 #endif
597 
598 /* Copy whatever the last rule matched to the standard output. */
599 #ifndef ECHO
600 /* This used to be an fputs(), but since the string might contain NUL's,
601  * we now use fwrite().
602  */
603 #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
604 #endif
605 
606 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
607  * is returned in "result".
608  */
609 #ifndef YY_INPUT
610 #define YY_INPUT(buf,result,max_size) \
611  if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
612  { \
613  int c = '*'; \
614  size_t n; \
615  for ( n = 0; n < max_size && \
616  (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
617  buf[n] = (char) c; \
618  if ( c == '\n' ) \
619  buf[n++] = (char) c; \
620  if ( c == EOF && ferror( yyin ) ) \
621  YY_FATAL_ERROR( "input in flex scanner failed" ); \
622  result = n; \
623  } \
624  else \
625  { \
626  errno=0; \
627  while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
628  { \
629  if( errno != EINTR) \
630  { \
631  YY_FATAL_ERROR( "input in flex scanner failed" ); \
632  break; \
633  } \
634  errno=0; \
635  clearerr(yyin); \
636  } \
637  }\
638 \
639 
640 #endif
641 
642 /* No semi-colon after return; correct usage is to write "yyterminate();" -
643  * we don't want an extra ';' after the "return" because that will cause
644  * some compilers to complain about unreachable statements.
645  */
646 #ifndef yyterminate
647 #define yyterminate() return YY_NULL
648 #endif
649 
650 /* Number of entries by which start-condition stack grows. */
651 #ifndef YY_START_STACK_INCR
652 #define YY_START_STACK_INCR 25
653 #endif
654 
655 /* Report a fatal error. */
656 #ifndef YY_FATAL_ERROR
657 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
658 #endif
659 
660 /* end tables serialization structures and prototypes */
661 
662 /* Default declaration of generated scanner - a define so the user can
663  * easily add parameters.
664  */
665 #ifndef YY_DECL
666 #define YY_DECL_IS_OURS 1
667 
668 extern int yylex (void);
669 
670 #define YY_DECL int yylex (void)
671 #endif /* !YY_DECL */
672 
673 /* Code executed at the beginning of each rule, after yytext and yyleng
674  * have been set up.
675  */
676 #ifndef YY_USER_ACTION
677 #define YY_USER_ACTION
678 #endif
679 
680 /* Code executed at the end of each rule. */
681 #ifndef YY_BREAK
682 #define YY_BREAK break;
683 #endif
684 
685 #define YY_RULE_SETUP \
686  YY_USER_ACTION
687 
690 YY_DECL
691 {
692  register yy_state_type yy_current_state;
693  register char *yy_cp, *yy_bp;
694  register int yy_act;
695 
696 #line 47 "configfile.l"
697 
698 
699 #line 700 "configfile.c"
700 
701  if ( !(yy_init) )
702  {
703  (yy_init) = 1;
704 
705 #ifdef YY_USER_INIT
706  YY_USER_INIT;
707 #endif
708 
709  if ( ! (yy_start) )
710  (yy_start) = 1; /* first start state */
711 
712  if ( ! yyin )
713  yyin = stdin;
714 
715  if ( ! yyout )
716  yyout = stdout;
717 
718  if ( ! YY_CURRENT_BUFFER ) {
719  yyensure_buffer_stack ();
720  YY_CURRENT_BUFFER_LVALUE =
721  yy_create_buffer(yyin,YY_BUF_SIZE );
722  }
723 
724  yy_load_buffer_state( );
725  }
726 
727  while ( 1 ) /* loops until end-of-file is reached */
728  {
729  yy_cp = (yy_c_buf_p);
730 
731  /* Support of yytext. */
732  *yy_cp = (yy_hold_char);
733 
734  /* yy_bp points to the position in yy_ch_buf of the start of
735  * the current run.
736  */
737  yy_bp = yy_cp;
738 
739  yy_current_state = (yy_start);
740 yy_match:
741  do
742  {
743  register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
744  if ( yy_accept[yy_current_state] )
745  {
746  (yy_last_accepting_state) = yy_current_state;
747  (yy_last_accepting_cpos) = yy_cp;
748  }
749  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
750  {
751  yy_current_state = (int) yy_def[yy_current_state];
752  if ( yy_current_state >= 17 )
753  yy_c = yy_meta[(unsigned int) yy_c];
754  }
755  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
756  ++yy_cp;
757  }
758  while ( yy_base[yy_current_state] != 31 );
759 
760 yy_find_action:
761  yy_act = yy_accept[yy_current_state];
762  if ( yy_act == 0 )
763  { /* have to back up */
764  yy_cp = (yy_last_accepting_cpos);
765  yy_current_state = (yy_last_accepting_state);
766  yy_act = yy_accept[yy_current_state];
767  }
768 
769  YY_DO_BEFORE_ACTION;
770 
771 do_action: /* This label is used only to access EOF actions. */
772 
773  switch ( yy_act )
774  { /* beginning of action switch */
775  case 0: /* must back up */
776  /* undo the effects of YY_DO_BEFORE_ACTION */
777  *yy_cp = (yy_hold_char);
778  yy_cp = (yy_last_accepting_cpos);
779  yy_current_state = (yy_last_accepting_state);
780  goto yy_find_action;
781 
782 case 1:
783 YY_RULE_SETUP
784 #line 49 "configfile.l"
785 {}
786  YY_BREAK
787 case 2:
788 /* rule 2 can match eol */
789 YY_RULE_SETUP
790 #line 50 "configfile.l"
791 { iLinenumber++; }
792  YY_BREAK
793 case 3:
794 /* rule 3 can match eol */
795 YY_RULE_SETUP
796 #line 51 "configfile.l"
797 { (void)evaluatetoken(yytext); }
798  YY_BREAK
799 case 4:
800 YY_RULE_SETUP
801 #line 52 "configfile.l"
802 {}
803  YY_BREAK
804 case 5:
805 YY_RULE_SETUP
806 #line 53 "configfile.l"
807 { (void)evaluatetoken(yytext); }
808  YY_BREAK
809 case 6:
810 YY_RULE_SETUP
811 #line 54 "configfile.l"
812 { iOldLinenumber = iLinenumber; tok_error(yytext); }
813  YY_BREAK
814 case 7:
815 YY_RULE_SETUP
816 #line 55 "configfile.l"
817 ECHO;
818  YY_BREAK
819 #line 820 "configfile.c"
820 case YY_STATE_EOF(INITIAL):
821  yyterminate();
822 
823  case YY_END_OF_BUFFER:
824  {
825  /* Amount of text matched not including the EOB char. */
826  int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
827 
828  /* Undo the effects of YY_DO_BEFORE_ACTION. */
829  *yy_cp = (yy_hold_char);
830  YY_RESTORE_YY_MORE_OFFSET
831 
832  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
833  {
834  /* We're scanning a new file or input source. It's
835  * possible that this happened because the user
836  * just pointed yyin at a new source and called
837  * yylex(). If so, then we have to assure
838  * consistency between YY_CURRENT_BUFFER and our
839  * globals. Here is the right place to do so, because
840  * this is the first action (other than possibly a
841  * back-up) that will match for the new input source.
842  */
843  (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
844  YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
845  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
846  }
847 
848  /* Note that here we test for yy_c_buf_p "<=" to the position
849  * of the first EOB in the buffer, since yy_c_buf_p will
850  * already have been incremented past the NUL character
851  * (since all states make transitions on EOB to the
852  * end-of-buffer state). Contrast this with the test
853  * in input().
854  */
855  if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
856  { /* This was really a NUL. */
857  yy_state_type yy_next_state;
858 
859  (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
860 
861  yy_current_state = yy_get_previous_state( );
862 
863  /* Okay, we're now positioned to make the NUL
864  * transition. We couldn't have
865  * yy_get_previous_state() go ahead and do it
866  * for us because it doesn't know how to deal
867  * with the possibility of jamming (and we don't
868  * want to build jamming into it because then it
869  * will run more slowly).
870  */
871 
872  yy_next_state = yy_try_NUL_trans( yy_current_state );
873 
874  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
875 
876  if ( yy_next_state )
877  {
878  /* Consume the NUL. */
879  yy_cp = ++(yy_c_buf_p);
880  yy_current_state = yy_next_state;
881  goto yy_match;
882  }
883 
884  else
885  {
886  yy_cp = (yy_c_buf_p);
887  goto yy_find_action;
888  }
889  }
890 
891  else switch ( yy_get_next_buffer( ) )
892  {
893  case EOB_ACT_END_OF_FILE:
894  {
895  (yy_did_buffer_switch_on_eof) = 0;
896 
897  if ( yywrap( ) )
898  {
899  /* Note: because we've taken care in
900  * yy_get_next_buffer() to have set up
901  * yytext, we can now set up
902  * yy_c_buf_p so that if some total
903  * hoser (like flex itself) wants to
904  * call the scanner after we return the
905  * YY_NULL, it'll still work - another
906  * YY_NULL will get returned.
907  */
908  (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
909 
910  yy_act = YY_STATE_EOF(YY_START);
911  goto do_action;
912  }
913 
914  else
915  {
916  if ( ! (yy_did_buffer_switch_on_eof) )
917  YY_NEW_FILE;
918  }
919  break;
920  }
921 
922  case EOB_ACT_CONTINUE_SCAN:
923  (yy_c_buf_p) =
924  (yytext_ptr) + yy_amount_of_matched_text;
925 
926  yy_current_state = yy_get_previous_state( );
927 
928  yy_cp = (yy_c_buf_p);
929  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
930  goto yy_match;
931 
932  case EOB_ACT_LAST_MATCH:
933  (yy_c_buf_p) =
934  &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
935 
936  yy_current_state = yy_get_previous_state( );
937 
938  yy_cp = (yy_c_buf_p);
939  yy_bp = (yytext_ptr) + YY_MORE_ADJ;
940  goto yy_find_action;
941  }
942  break;
943  }
944 
945  default:
946  YY_FATAL_ERROR(
947  "fatal flex scanner internal error--no action found" );
948  } /* end of action switch */
949  } /* end of scanning one token */
950 } /* end of yylex */
951 
952 /* yy_get_next_buffer - try to read in a new buffer
953  *
954  * Returns a code representing an action:
955  * EOB_ACT_LAST_MATCH -
956  * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
957  * EOB_ACT_END_OF_FILE - end of file
958  */
959 static int yy_get_next_buffer (void)
960 {
961  register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
962  register char *source = (yytext_ptr);
963  register int number_to_move, i;
964  int ret_val;
965 
966  if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
967  YY_FATAL_ERROR(
968  "fatal flex scanner internal error--end of buffer missed" );
969 
970  if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
971  { /* Don't try to fill the buffer, so this is an EOF. */
972  if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
973  {
974  /* We matched a single character, the EOB, so
975  * treat this as a final EOF.
976  */
977  return EOB_ACT_END_OF_FILE;
978  }
979 
980  else
981  {
982  /* We matched some text prior to the EOB, first
983  * process it.
984  */
985  return EOB_ACT_LAST_MATCH;
986  }
987  }
988 
989  /* Try to read more data. */
990 
991  /* First move last chars to start of buffer. */
992  number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
993 
994  for ( i = 0; i < number_to_move; ++i )
995  *(dest++) = *(source++);
996 
997  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
998  /* don't do the read, it's not guaranteed to return an EOF,
999  * just force an EOF
1000  */
1001  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1002 
1003  else
1004  {
1005  int num_to_read =
1006  YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1007 
1008  while ( num_to_read <= 0 )
1009  { /* Not enough room in the buffer - grow it. */
1010 
1011  /* just a shorter name for the current buffer */
1012  YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1013 
1014  int yy_c_buf_p_offset =
1015  (int) ((yy_c_buf_p) - b->yy_ch_buf);
1016 
1017  if ( b->yy_is_our_buffer )
1018  {
1019  int new_size = b->yy_buf_size * 2;
1020 
1021  if ( new_size <= 0 )
1022  b->yy_buf_size += b->yy_buf_size / 8;
1023  else
1024  b->yy_buf_size *= 2;
1025 
1026  b->yy_ch_buf = (char *)
1027  /* Include room in for 2 EOB chars. */
1028  yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1029  }
1030  else
1031  /* Can't grow it, we don't own it. */
1032  b->yy_ch_buf = 0;
1033 
1034  if ( ! b->yy_ch_buf )
1035  YY_FATAL_ERROR(
1036  "fatal error - scanner input buffer overflow" );
1037 
1038  (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1039 
1040  num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1041  number_to_move - 1;
1042 
1043  }
1044 
1045  if ( num_to_read > YY_READ_BUF_SIZE )
1046  num_to_read = YY_READ_BUF_SIZE;
1047 
1048  /* Read in more data. */
1049  YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1050  (yy_n_chars), (size_t) num_to_read );
1051 
1052  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1053  }
1054 
1055  if ( (yy_n_chars) == 0 )
1056  {
1057  if ( number_to_move == YY_MORE_ADJ )
1058  {
1059  ret_val = EOB_ACT_END_OF_FILE;
1060  yyrestart(yyin );
1061  }
1062 
1063  else
1064  {
1065  ret_val = EOB_ACT_LAST_MATCH;
1066  YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1067  YY_BUFFER_EOF_PENDING;
1068  }
1069  }
1070 
1071  else
1072  ret_val = EOB_ACT_CONTINUE_SCAN;
1073 
1074  if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1075  /* Extend the array by 50%, plus the number we really need. */
1076  yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1077  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1078  if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1079  YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1080  }
1081 
1082  (yy_n_chars) += number_to_move;
1083  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1084  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1085 
1086  (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1087 
1088  return ret_val;
1089 }
1090 
1091 /* yy_get_previous_state - get the state just before the EOB char was reached */
1092 
1093  static yy_state_type yy_get_previous_state (void)
1094 {
1095  register yy_state_type yy_current_state;
1096  register char *yy_cp;
1097 
1098  yy_current_state = (yy_start);
1099 
1100  for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1101  {
1102  register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1103  if ( yy_accept[yy_current_state] )
1104  {
1105  (yy_last_accepting_state) = yy_current_state;
1106  (yy_last_accepting_cpos) = yy_cp;
1107  }
1108  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1109  {
1110  yy_current_state = (int) yy_def[yy_current_state];
1111  if ( yy_current_state >= 17 )
1112  yy_c = yy_meta[(unsigned int) yy_c];
1113  }
1114  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1115  }
1116 
1117  return yy_current_state;
1118 }
1119 
1120 /* yy_try_NUL_trans - try to make a transition on the NUL character
1121  *
1122  * synopsis
1123  * next_state = yy_try_NUL_trans( current_state );
1124  */
1125  static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1126 {
1127  register int yy_is_jam;
1128  register char *yy_cp = (yy_c_buf_p);
1129 
1130  register YY_CHAR yy_c = 1;
1131  if ( yy_accept[yy_current_state] )
1132  {
1133  (yy_last_accepting_state) = yy_current_state;
1134  (yy_last_accepting_cpos) = yy_cp;
1135  }
1136  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1137  {
1138  yy_current_state = (int) yy_def[yy_current_state];
1139  if ( yy_current_state >= 17 )
1140  yy_c = yy_meta[(unsigned int) yy_c];
1141  }
1142  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1143  yy_is_jam = (yy_current_state == 16);
1144 
1145  return yy_is_jam ? 0 : yy_current_state;
1146 }
1147 
1148 #ifndef YY_NO_INPUT
1149 #ifdef __cplusplus
1150  static int yyinput (void)
1151 #else
1152  static int input (void)
1153 #endif
1154 
1155 {
1156  int c;
1157 
1158  *(yy_c_buf_p) = (yy_hold_char);
1159 
1160  if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1161  {
1162  /* yy_c_buf_p now points to the character we want to return.
1163  * If this occurs *before* the EOB characters, then it's a
1164  * valid NUL; if not, then we've hit the end of the buffer.
1165  */
1166  if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1167  /* This was really a NUL. */
1168  *(yy_c_buf_p) = '\0';
1169 
1170  else
1171  { /* need more input */
1172  int offset = (yy_c_buf_p) - (yytext_ptr);
1173  ++(yy_c_buf_p);
1174 
1175  switch ( yy_get_next_buffer( ) )
1176  {
1177  case EOB_ACT_LAST_MATCH:
1178  /* This happens because yy_g_n_b()
1179  * sees that we've accumulated a
1180  * token and flags that we need to
1181  * try matching the token before
1182  * proceeding. But for input(),
1183  * there's no matching to consider.
1184  * So convert the EOB_ACT_LAST_MATCH
1185  * to EOB_ACT_END_OF_FILE.
1186  */
1187 
1188  /* Reset buffer status. */
1189  yyrestart(yyin );
1190 
1191  /*FALLTHROUGH*/
1192 
1193  case EOB_ACT_END_OF_FILE:
1194  {
1195  if ( yywrap( ) )
1196  return EOF;
1197 
1198  if ( ! (yy_did_buffer_switch_on_eof) )
1199  YY_NEW_FILE;
1200 #ifdef __cplusplus
1201  return yyinput();
1202 #else
1203  return input();
1204 #endif
1205  }
1206 
1207  case EOB_ACT_CONTINUE_SCAN:
1208  (yy_c_buf_p) = (yytext_ptr) + offset;
1209  break;
1210  }
1211  }
1212  }
1213 
1214  c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1215  *(yy_c_buf_p) = '\0'; /* preserve yytext */
1216  (yy_hold_char) = *++(yy_c_buf_p);
1217 
1218  return c;
1219 }
1220 #endif /* ifndef YY_NO_INPUT */
1221 
1227  void yyrestart (FILE * input_file )
1228 {
1229 
1230  if ( ! YY_CURRENT_BUFFER ){
1231  yyensure_buffer_stack ();
1232  YY_CURRENT_BUFFER_LVALUE =
1233  yy_create_buffer(yyin,YY_BUF_SIZE );
1234  }
1235 
1236  yy_init_buffer(YY_CURRENT_BUFFER,input_file );
1237  yy_load_buffer_state( );
1238 }
1239 
1244  void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1245 {
1246 
1247  /* TODO. We should be able to replace this entire function body
1248  * with
1249  * yypop_buffer_state();
1250  * yypush_buffer_state(new_buffer);
1251  */
1252  yyensure_buffer_stack ();
1253  if ( YY_CURRENT_BUFFER == new_buffer )
1254  return;
1255 
1256  if ( YY_CURRENT_BUFFER )
1257  {
1258  /* Flush out information for old buffer. */
1259  *(yy_c_buf_p) = (yy_hold_char);
1260  YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1261  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1262  }
1263 
1264  YY_CURRENT_BUFFER_LVALUE = new_buffer;
1265  yy_load_buffer_state( );
1266 
1267  /* We don't actually know whether we did this switch during
1268  * EOF (yywrap()) processing, but the only time this flag
1269  * is looked at is after yywrap() is called, so it's safe
1270  * to go ahead and always set it.
1271  */
1272  (yy_did_buffer_switch_on_eof) = 1;
1273 }
1274 
1275 static void yy_load_buffer_state (void)
1276 {
1277  (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1278  (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1279  yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1280  (yy_hold_char) = *(yy_c_buf_p);
1281 }
1282 
1289  YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
1290 {
1291  YY_BUFFER_STATE b;
1292 
1293  b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
1294  if ( ! b )
1295  YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1296 
1297  b->yy_buf_size = size;
1298 
1299  /* yy_ch_buf has to be 2 characters longer than the size given because
1300  * we need to put in 2 end-of-buffer characters.
1301  */
1302  b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
1303  if ( ! b->yy_ch_buf )
1304  YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1305 
1306  b->yy_is_our_buffer = 1;
1307 
1308  yy_init_buffer(b,file );
1309 
1310  return b;
1311 }
1312 
1317  void yy_delete_buffer (YY_BUFFER_STATE b )
1318 {
1319 
1320  if ( ! b )
1321  return;
1322 
1323  if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1324  YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1325 
1326  if ( b->yy_is_our_buffer )
1327  yyfree((void *) b->yy_ch_buf );
1328 
1329  yyfree((void *) b );
1330 }
1331 
1332 #ifndef __cplusplus
1333 extern int isatty (int );
1334 #endif /* __cplusplus */
1335 
1336 /* Initializes or reinitializes a buffer.
1337  * This function is sometimes called more than once on the same buffer,
1338  * such as during a yyrestart() or at EOF.
1339  */
1340  static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
1341 
1342 {
1343  int oerrno = errno;
1344 
1345  yy_flush_buffer(b );
1346 
1347  b->yy_input_file = file;
1348  b->yy_fill_buffer = 1;
1349 
1350  /* If b is the current buffer, then yy_init_buffer was _probably_
1351  * called from yyrestart() or through yy_get_next_buffer.
1352  * In that case, we don't want to reset the lineno or column.
1353  */
1354  if (b != YY_CURRENT_BUFFER){
1355  b->yy_bs_lineno = 1;
1356  b->yy_bs_column = 0;
1357  }
1358 
1359  b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1360 
1361  errno = oerrno;
1362 }
1363 
1368  void yy_flush_buffer (YY_BUFFER_STATE b )
1369 {
1370  if ( ! b )
1371  return;
1372 
1373  b->yy_n_chars = 0;
1374 
1375  /* We always need two end-of-buffer characters. The first causes
1376  * a transition to the end-of-buffer state. The second causes
1377  * a jam in that state.
1378  */
1379  b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1380  b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1381 
1382  b->yy_buf_pos = &b->yy_ch_buf[0];
1383 
1384  b->yy_at_bol = 1;
1385  b->yy_buffer_status = YY_BUFFER_NEW;
1386 
1387  if ( b == YY_CURRENT_BUFFER )
1388  yy_load_buffer_state( );
1389 }
1390 
1397 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1398 {
1399  if (new_buffer == NULL)
1400  return;
1401 
1402  yyensure_buffer_stack();
1403 
1404  /* This block is copied from yy_switch_to_buffer. */
1405  if ( YY_CURRENT_BUFFER )
1406  {
1407  /* Flush out information for old buffer. */
1408  *(yy_c_buf_p) = (yy_hold_char);
1409  YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1410  YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1411  }
1412 
1413  /* Only push if top exists. Otherwise, replace top. */
1414  if (YY_CURRENT_BUFFER)
1415  (yy_buffer_stack_top)++;
1416  YY_CURRENT_BUFFER_LVALUE = new_buffer;
1417 
1418  /* copied from yy_switch_to_buffer. */
1419  yy_load_buffer_state( );
1420  (yy_did_buffer_switch_on_eof) = 1;
1421 }
1422 
1427 void yypop_buffer_state (void)
1428 {
1429  if (!YY_CURRENT_BUFFER)
1430  return;
1431 
1432  yy_delete_buffer(YY_CURRENT_BUFFER );
1433  YY_CURRENT_BUFFER_LVALUE = NULL;
1434  if ((yy_buffer_stack_top) > 0)
1435  --(yy_buffer_stack_top);
1436 
1437  if (YY_CURRENT_BUFFER) {
1438  yy_load_buffer_state( );
1439  (yy_did_buffer_switch_on_eof) = 1;
1440  }
1441 }
1442 
1443 /* Allocates the stack if it does not exist.
1444  * Guarantees space for at least one push.
1445  */
1446 static void yyensure_buffer_stack (void)
1447 {
1448  int num_to_alloc;
1449 
1450  if (!(yy_buffer_stack)) {
1451 
1452  /* First allocation is just for 2 elements, since we don't know if this
1453  * scanner will even need a stack. We use 2 instead of 1 to avoid an
1454  * immediate realloc on the next call.
1455  */
1456  num_to_alloc = 1;
1457  (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1458  (num_to_alloc * sizeof(struct yy_buffer_state*)
1459  );
1460  if ( ! (yy_buffer_stack) )
1461  YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1462 
1463  memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1464 
1465  (yy_buffer_stack_max) = num_to_alloc;
1466  (yy_buffer_stack_top) = 0;
1467  return;
1468  }
1469 
1470  if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1471 
1472  /* Increase the buffer to prepare for a possible push. */
1473  int grow_size = 8 /* arbitrary grow size */;
1474 
1475  num_to_alloc = (yy_buffer_stack_max) + grow_size;
1476  (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1477  ((yy_buffer_stack),
1478  num_to_alloc * sizeof(struct yy_buffer_state*)
1479  );
1480  if ( ! (yy_buffer_stack) )
1481  YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1482 
1483  /* zero only the new slots.*/
1484  memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1485  (yy_buffer_stack_max) = num_to_alloc;
1486  }
1487 }
1488 
1495 YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
1496 {
1497  YY_BUFFER_STATE b;
1498 
1499  if ( size < 2 ||
1500  base[size-2] != YY_END_OF_BUFFER_CHAR ||
1501  base[size-1] != YY_END_OF_BUFFER_CHAR )
1502  /* They forgot to leave room for the EOB's. */
1503  return 0;
1504 
1505  b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
1506  if ( ! b )
1507  YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1508 
1509  b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1510  b->yy_buf_pos = b->yy_ch_buf = base;
1511  b->yy_is_our_buffer = 0;
1512  b->yy_input_file = 0;
1513  b->yy_n_chars = b->yy_buf_size;
1514  b->yy_is_interactive = 0;
1515  b->yy_at_bol = 1;
1516  b->yy_fill_buffer = 0;
1517  b->yy_buffer_status = YY_BUFFER_NEW;
1518 
1519  yy_switch_to_buffer(b );
1520 
1521  return b;
1522 }
1523 
1532 YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
1533 {
1534 
1535  return yy_scan_bytes(yystr,strlen(yystr) );
1536 }
1537 
1545 YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
1546 {
1547  YY_BUFFER_STATE b;
1548  char *buf;
1549  yy_size_t n;
1550  int i;
1551 
1552  /* Get memory for full buffer, including space for trailing EOB's. */
1553  n = _yybytes_len + 2;
1554  buf = (char *) yyalloc(n );
1555  if ( ! buf )
1556  YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1557 
1558  for ( i = 0; i < _yybytes_len; ++i )
1559  buf[i] = yybytes[i];
1560 
1561  buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1562 
1563  b = yy_scan_buffer(buf,n );
1564  if ( ! b )
1565  YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1566 
1567  /* It's okay to grow etc. this buffer, and we should throw it
1568  * away when we're done.
1569  */
1570  b->yy_is_our_buffer = 1;
1571 
1572  return b;
1573 }
1574 
1575 #ifndef YY_EXIT_FAILURE
1576 #define YY_EXIT_FAILURE 2
1577 #endif
1578 
1579 static void yy_fatal_error (yyconst char* msg )
1580 {
1581  (void) fprintf( stderr, "%s\n", msg );
1582  exit( YY_EXIT_FAILURE );
1583 }
1584 
1585 /* Redefine yyless() so it works in section 3 code. */
1586 
1587 #undef yyless
1588 #define yyless(n) \
1589  do \
1590  { \
1591  /* Undo effects of setting up yytext. */ \
1592  int yyless_macro_arg = (n); \
1593  YY_LESS_LINENO(yyless_macro_arg);\
1594  yytext[yyleng] = (yy_hold_char); \
1595  (yy_c_buf_p) = yytext + yyless_macro_arg; \
1596  (yy_hold_char) = *(yy_c_buf_p); \
1597  *(yy_c_buf_p) = '\0'; \
1598  yyleng = yyless_macro_arg; \
1599  } \
1600  while ( 0 )
1601 
1602 /* Accessor methods (get/set functions) to struct members. */
1603 
1607 int yyget_lineno (void)
1608 {
1609 
1610  return yylineno;
1611 }
1612 
1616 FILE *yyget_in (void)
1617 {
1618  return yyin;
1619 }
1620 
1624 FILE *yyget_out (void)
1625 {
1626  return yyout;
1627 }
1628 
1632 int yyget_leng (void)
1633 {
1634  return yyleng;
1635 }
1636 
1641 char *yyget_text (void)
1642 {
1643  return yytext;
1644 }
1645 
1650 void yyset_lineno (int line_number )
1651 {
1652 
1653  yylineno = line_number;
1654 }
1655 
1662 void yyset_in (FILE * in_str )
1663 {
1664  yyin = in_str ;
1665 }
1666 
1667 void yyset_out (FILE * out_str )
1668 {
1669  yyout = out_str ;
1670 }
1671 
1672 int yyget_debug (void)
1673 {
1674  return yy_flex_debug;
1675 }
1676 
1677 void yyset_debug (int bdebug )
1678 {
1679  yy_flex_debug = bdebug ;
1680 }
1681 
1682 static int yy_init_globals (void)
1683 {
1684  /* Initialization is the same as for the non-reentrant scanner.
1685  * This function is called from yylex_destroy(), so don't allocate here.
1686  */
1687 
1688  (yy_buffer_stack) = 0;
1689  (yy_buffer_stack_top) = 0;
1690  (yy_buffer_stack_max) = 0;
1691  (yy_c_buf_p) = (char *) 0;
1692  (yy_init) = 0;
1693  (yy_start) = 0;
1694 
1695 /* Defined in main.c */
1696 #ifdef YY_STDINIT
1697  yyin = stdin;
1698  yyout = stdout;
1699 #else
1700  yyin = (FILE *) 0;
1701  yyout = (FILE *) 0;
1702 #endif
1703 
1704  /* For future reference: Set errno on error, since we are called by
1705  * yylex_init()
1706  */
1707  return 0;
1708 }
1709 
1710 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
1711 int yylex_destroy (void)
1712 {
1713 
1714  /* Pop the buffer stack, destroying each element. */
1715  while(YY_CURRENT_BUFFER){
1716  yy_delete_buffer(YY_CURRENT_BUFFER );
1717  YY_CURRENT_BUFFER_LVALUE = NULL;
1718  yypop_buffer_state();
1719  }
1720 
1721  /* Destroy the stack itself. */
1722  yyfree((yy_buffer_stack) );
1723  (yy_buffer_stack) = NULL;
1724 
1725  /* Reset the globals. This is important in a non-reentrant scanner so the next time
1726  * yylex() is called, initialization will occur. */
1727  yy_init_globals( );
1728 
1729  return 0;
1730 }
1731 
1732 /*
1733  * Internal utility routines.
1734  */
1735 
1736 #ifndef yytext_ptr
1737 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1738 {
1739  register int i;
1740  for ( i = 0; i < n; ++i )
1741  s1[i] = s2[i];
1742 }
1743 #endif
1744 
1745 #ifdef YY_NEED_STRLEN
1746 static int yy_flex_strlen (yyconst char * s )
1747 {
1748  register int n;
1749  for ( n = 0; s[n]; ++n )
1750  ;
1751 
1752  return n;
1753 }
1754 #endif
1755 
1756 void *yyalloc (yy_size_t size )
1757 {
1758  return (void *) malloc( size );
1759 }
1760 
1761 void *yyrealloc (void * ptr, yy_size_t size )
1762 {
1763  /* The cast to (char *) in the following accommodates both
1764  * implementations that use char* generic pointers, and those
1765  * that use void* generic pointers. It works with the latter
1766  * because both ANSI C and C++ allow castless assignment from
1767  * any pointer type to void*, and deal with argument conversions
1768  * as though doing an assignment.
1769  */
1770  return (void *) realloc( (char *) ptr, size );
1771 }
1772 
1773 void yyfree (void * ptr )
1774 {
1775  free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
1776 }
1777 
1778 #define YYTABLES_NAME "yytables"
1779 
1780 #line 55 "configfile.l"
1781 
1782 
1783 
1784 #include <stdio.h>
1785 #include <string.h>
1786 #include <errno.h>
1787 
1788 #include "config.h"
1789 #include "misc.h"
1790 #include "pcsclite.h"
1791 #include "pcscd.h"
1792 #include "debuglog.h"
1793 #include "sys_generic.h"
1794 #include "readerfactory.h"
1795 
1796 int evaluatetoken(char *pcToken)
1797 {
1798  if (pcPrevious == NULL)
1799  { /* This is the key */
1800  pcPrevious = strdup(pcToken);
1801  iOldLinenumber = iLinenumber;
1802  }
1803  else
1804  {
1805  /* first and second tokens are not on the same line */
1806  if (iOldLinenumber != iLinenumber)
1807  {
1808  tok_error(pcPrevious);
1809  pcPrevious = strdup(pcToken);
1810  iOldLinenumber = iLinenumber;
1811  return 1;
1812  }
1813 
1814  pcCurrent = pcToken;
1815  if (strcmp(pcPrevious, "FRIENDLYNAME") == 0)
1816  {
1817  if (pcFriendlyname == NULL)
1818  {
1819  size_t n, p;
1820 
1821  pcFriendlyname = malloc(strlen(pcCurrent) + 1);
1822  for (n = 0, p = 0; n < strlen(pcCurrent); n++)
1823  {
1824  if (pcCurrent[n] != '"')
1825  { /* Strip off the quotes */
1826  pcFriendlyname[p++] = pcCurrent[n];
1827  }
1828  }
1829  pcFriendlyname[p++] = '\0';
1830  }
1831  else
1832  {
1833  tok_error(pcPrevious);
1834  return 1;
1835  }
1836  }
1837  else if (strcmp(pcPrevious, "DEVICENAME") == 0)
1838  {
1839  if (pcDevicename == NULL)
1840  {
1841  struct stat fStatBuf;
1842 
1843  pcDevicename = strdup(pcCurrent);
1844  if ((NULL == strchr(pcDevicename, ':'))
1845  && (stat(pcDevicename, &fStatBuf) != 0))
1846  {
1847  Log3(PCSC_LOG_CRITICAL, "Error with device %s: %s",
1848  pcDevicename, strerror(errno));
1849  Log1(PCSC_LOG_CRITICAL, "You should remove the DEVICENAME line if your driver does not use this field");
1850  badError = 1;
1851  }
1852  }
1853  else
1854  {
1855  tok_error(pcPrevious);
1856  return 1;
1857  }
1858  }
1859  else if (strcmp(pcPrevious, "LIBPATH") == 0)
1860  {
1861  if (pcLibpath == NULL)
1862  {
1863  struct stat fStatBuf;
1864 
1865  pcLibpath = strdup(pcCurrent);
1866  if (stat(pcLibpath, &fStatBuf) != 0)
1867  {
1868  Log3(PCSC_LOG_CRITICAL, "Error with library %s: %s",
1869  pcLibpath, strerror(errno));
1870  badError = 1;
1871  }
1872 
1873  if (strstr(pcLibpath, ".bundle") != NULL)
1874  {
1875  Log1(PCSC_LOG_ERROR, "WARNING *************************************");
1876  Log2(PCSC_LOG_ERROR, "WARNING: USB drivers SHOULD NOT be declared in reader.conf: %s", pcLibpath);
1877  Log1(PCSC_LOG_ERROR, "WARNING *************************************");
1878  }
1879  }
1880  else
1881  {
1882  tok_error(pcPrevious);
1883  return 1;
1884  }
1885  }
1886  else if (strcmp(pcPrevious, "CHANNELID") == 0)
1887  {
1888  if (pcChannelid == NULL)
1889  pcChannelid = strdup(pcCurrent);
1890  else
1891  {
1892  tok_error(pcPrevious);
1893  return 1;
1894  }
1895  }
1896  else
1897  {
1898  tok_error(pcPrevious);
1899  free(pcPrevious);
1900  pcPrevious = NULL;
1901  return 1;
1902  }
1903 
1904  free(pcPrevious);
1905  pcPrevious = NULL;
1906  }
1907 
1908  if (pcFriendlyname != NULL &&
1909  pcLibpath != NULL && pcChannelid != NULL && badError != 1)
1910  {
1911  int channelId;
1912 
1913  if (0 == reader_list_size)
1914  {
1915  /* one real reader and one end marker */
1916  reader_list_size = 2;
1917  reader_list = malloc(reader_list_size * sizeof(SerialReader));
1918  }
1919  else
1920  {
1921  reader_list_size++;
1922  reader_list = realloc(reader_list, reader_list_size *
1923  sizeof(SerialReader));
1924  }
1925 
1926  /* end marker */
1927  reader_list[reader_list_size-1].pcFriendlyname = NULL;
1928 
1929  /* the DEVICENAME parameter is optional */
1930  if (NULL == pcDevicename)
1931  pcDevicename = "";
1932 
1933  channelId = strtoul(pcChannelid, NULL, 0);
1934  reader_list[reader_list_size-2].pcFriendlyname = strdup(pcFriendlyname);
1935  reader_list[reader_list_size-2].pcDevicename = strdup(pcDevicename);
1936  reader_list[reader_list_size-2].pcLibpath = strdup(pcLibpath),
1937  reader_list[reader_list_size-2].channelId = channelId;
1938 
1939  pcFriendlyname = NULL;
1940  pcDevicename = NULL;
1941  pcLibpath = NULL;
1942  pcChannelid = NULL;
1943  }
1944 
1945  return 0;
1946 }
1947 
1948 void tok_error(char *token_error)
1949 {
1950  Log4(PCSC_LOG_ERROR, "tok_error: invalid value line %d in %s: %s",
1951  iOldLinenumber, ConfFile, token_error);
1952  badError = 1;
1953 }
1954 
1955 int DBGetReaderListDir(const char *readerconf_dir,
1956  SerialReader **caller_reader_list)
1957 {
1958  DIR *dir;
1959  int ret = 0;
1960 
1961  /* (re)start with an empty list */
1962  reader_list = NULL;
1963  reader_list_size = 0;
1964 
1965  dir = opendir(readerconf_dir);
1966  if (dir)
1967  {
1968  /* the configuration file is a directory */
1969  struct dirent *direntry;
1970 
1971  Log2(PCSC_LOG_DEBUG, "Parsing conf directory: %s", readerconf_dir);
1972 
1973  /* for each configuration file */
1974  while ((direntry = readdir(dir)) != NULL)
1975  {
1976  char filename[FILENAME_MAX];
1977  int r;
1978 
1979  /* skip non regular files */
1980  if (direntry->d_type != DT_REG)
1981  {
1982  Log2(PCSC_LOG_DEBUG, "Skipping non regular file: %s",
1983  direntry->d_name);
1984  continue;
1985  }
1986 
1987  /* skip files starting with . like ., .., .svn, etc */
1988  if ('.' == direntry->d_name[0])
1989  {
1990  Log2(PCSC_LOG_DEBUG, "Skipping hidden file: %s",
1991  direntry->d_name);
1992  continue;
1993  }
1994 
1995  snprintf(filename, sizeof(filename), "%s/%s",
1996  readerconf_dir, direntry->d_name);
1997 
1998  /* each call to DBGetReaderList() will append to the list */
1999  r = DBGetReaderList(filename, caller_reader_list);
2000 
2001  /* set the global return value to the latest error */
2002  if (r)
2003  ret = r;
2004  }
2005 
2006  closedir(dir);
2007  }
2008  else
2009  /* the configuration file is really a file */
2010  ret = DBGetReaderList(readerconf_dir, caller_reader_list);
2011 
2012  return ret;
2013 }
2014 
2015 int DBGetReaderList(const char *readerconf, SerialReader **caller_reader_list)
2016 {
2017  FILE *configFile = NULL;
2018 
2019  *caller_reader_list = NULL; /* no list by default */
2020 
2021  /* used by tok_error() */
2022  ConfFile = readerconf;
2023 
2024  Log2(PCSC_LOG_DEBUG, "Parsing conf file: %s", ConfFile);
2025 
2026  configFile = fopen(readerconf, "r");
2027 
2028  if (configFile == NULL)
2029  return 1;
2030 
2031  yyin = configFile;
2032 
2033  /* (re)start with a clean state */
2034  iLinenumber = 1;
2035  iOldLinenumber = -1;
2036  pcFriendlyname = NULL;
2037  pcDevicename = NULL;
2038  pcLibpath = NULL;
2039  pcChannelid = NULL;
2040  pcPrevious = NULL;
2041  pcCurrent = NULL;
2042  badError = 0;
2043 
2044  do
2045  {
2046  (void)yylex();
2047  }
2048  while (!feof(configFile));
2049 
2050  (void)fclose(configFile);
2051 
2052  *caller_reader_list = reader_list;
2053 
2054  if (badError == 1)
2055  return -1;
2056  else
2057  return 0;
2058 } /* End of configfile.c */
2059 
2060 
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:31
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:722
int channelId
CHANNELID.
Definition: readerfactory.h:32
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:30
char * pcFriendlyname
FRIENDLYNAME.
Definition: readerfactory.h:29
This handles debugging.
int yy_bs_lineno
The line count.
Definition: configfile.c:233