configfile.c

00001 
00002 #line 3 "configfile.c"
00003 
00004 #define  YY_INT_ALIGNED short int
00005 
00006 /* A lexical scanner generated by flex */
00007 
00008 #define FLEX_SCANNER
00009 #define YY_FLEX_MAJOR_VERSION 2
00010 #define YY_FLEX_MINOR_VERSION 5
00011 #define YY_FLEX_SUBMINOR_VERSION 35
00012 #if YY_FLEX_SUBMINOR_VERSION > 0
00013 #define FLEX_BETA
00014 #endif
00015 
00016 /* First, we deal with  platform-specific or compiler-specific issues. */
00017 
00018 /* begin standard C headers. */
00019 #include <stdio.h>
00020 #include <string.h>
00021 #include <errno.h>
00022 #include <stdlib.h>
00023 
00024 /* end standard C headers. */
00025 
00026 /* flex integer type definitions */
00027 
00028 #ifndef FLEXINT_H
00029 #define FLEXINT_H
00030 
00031 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
00032 
00033 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
00034 
00035 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
00036  * if you want the limit (max/min) macros for int types. 
00037  */
00038 #ifndef __STDC_LIMIT_MACROS
00039 #define __STDC_LIMIT_MACROS 1
00040 #endif
00041 
00042 #include <inttypes.h>
00043 typedef int8_t flex_int8_t;
00044 typedef uint8_t flex_uint8_t;
00045 typedef int16_t flex_int16_t;
00046 typedef uint16_t flex_uint16_t;
00047 typedef int32_t flex_int32_t;
00048 typedef uint32_t flex_uint32_t;
00049 #else
00050 typedef signed char flex_int8_t;
00051 typedef short int flex_int16_t;
00052 typedef int flex_int32_t;
00053 typedef unsigned char flex_uint8_t; 
00054 typedef unsigned short int flex_uint16_t;
00055 typedef unsigned int flex_uint32_t;
00056 
00057 /* Limits of integral types. */
00058 #ifndef INT8_MIN
00059 #define INT8_MIN               (-128)
00060 #endif
00061 #ifndef INT16_MIN
00062 #define INT16_MIN              (-32767-1)
00063 #endif
00064 #ifndef INT32_MIN
00065 #define INT32_MIN              (-2147483647-1)
00066 #endif
00067 #ifndef INT8_MAX
00068 #define INT8_MAX               (127)
00069 #endif
00070 #ifndef INT16_MAX
00071 #define INT16_MAX              (32767)
00072 #endif
00073 #ifndef INT32_MAX
00074 #define INT32_MAX              (2147483647)
00075 #endif
00076 #ifndef UINT8_MAX
00077 #define UINT8_MAX              (255U)
00078 #endif
00079 #ifndef UINT16_MAX
00080 #define UINT16_MAX             (65535U)
00081 #endif
00082 #ifndef UINT32_MAX
00083 #define UINT32_MAX             (4294967295U)
00084 #endif
00085 
00086 #endif /* ! C99 */
00087 
00088 #endif /* ! FLEXINT_H */
00089 
00090 #ifdef __cplusplus
00091 
00092 /* The "const" storage-class-modifier is valid. */
00093 #define YY_USE_CONST
00094 
00095 #else   /* ! __cplusplus */
00096 
00097 /* C99 requires __STDC__ to be defined as 1. */
00098 #if defined (__STDC__)
00099 
00100 #define YY_USE_CONST
00101 
00102 #endif  /* defined (__STDC__) */
00103 #endif  /* ! __cplusplus */
00104 
00105 #ifdef YY_USE_CONST
00106 #define yyconst const
00107 #else
00108 #define yyconst
00109 #endif
00110 
00111 /* Returned upon end-of-file. */
00112 #define YY_NULL 0
00113 
00114 /* Promotes a possibly negative, possibly signed char to an unsigned
00115  * integer for use as an array index.  If the signed char is negative,
00116  * we want to instead treat it as an 8-bit unsigned char, hence the
00117  * double cast.
00118  */
00119 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
00120 
00121 /* Enter a start condition.  This macro really ought to take a parameter,
00122  * but we do it the disgusting crufty way forced on us by the ()-less
00123  * definition of BEGIN.
00124  */
00125 #define BEGIN (yy_start) = 1 + 2 *
00126 
00127 /* Translate the current start state into a value that can be later handed
00128  * to BEGIN to return to the state.  The YYSTATE alias is for lex
00129  * compatibility.
00130  */
00131 #define YY_START (((yy_start) - 1) / 2)
00132 #define YYSTATE YY_START
00133 
00134 /* Action number for EOF rule of a given start state. */
00135 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
00136 
00137 /* Special action meaning "start processing a new file". */
00138 #define YY_NEW_FILE yyrestart(yyin  )
00139 
00140 #define YY_END_OF_BUFFER_CHAR 0
00141 
00142 /* Size of default input buffer. */
00143 #ifndef YY_BUF_SIZE
00144 #ifdef __ia64__
00145 /* On IA-64, the buffer size is 16k, not 8k.
00146  * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
00147  * Ditto for the __ia64__ case accordingly.
00148  */
00149 #define YY_BUF_SIZE 32768
00150 #else
00151 #define YY_BUF_SIZE 16384
00152 #endif /* __ia64__ */
00153 #endif
00154 
00155 /* The state buf must be large enough to hold one state per character in the main buffer.
00156  */
00157 #define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
00158 
00159 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
00160 #define YY_TYPEDEF_YY_BUFFER_STATE
00161 typedef struct yy_buffer_state *YY_BUFFER_STATE;
00162 #endif
00163 
00164 extern int yyleng;
00165 
00166 extern FILE *yyin, *yyout;
00167 
00168 #define EOB_ACT_CONTINUE_SCAN 0
00169 #define EOB_ACT_END_OF_FILE 1
00170 #define EOB_ACT_LAST_MATCH 2
00171 
00172     #define YY_LESS_LINENO(n)
00173     
00174 /* Return all but the first "n" matched characters back to the input stream. */
00175 #define yyless(n) \
00176     do \
00177         { \
00178         /* Undo effects of setting up yytext. */ \
00179         int yyless_macro_arg = (n); \
00180         YY_LESS_LINENO(yyless_macro_arg);\
00181         *yy_cp = (yy_hold_char); \
00182         YY_RESTORE_YY_MORE_OFFSET \
00183         (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
00184         YY_DO_BEFORE_ACTION; /* set up yytext again */ \
00185         } \
00186     while ( 0 )
00187 
00188 #define unput(c) yyunput( c, (yytext_ptr)  )
00189 
00190 #ifndef YY_TYPEDEF_YY_SIZE_T
00191 #define YY_TYPEDEF_YY_SIZE_T
00192 typedef size_t yy_size_t;
00193 #endif
00194 
00195 #ifndef YY_STRUCT_YY_BUFFER_STATE
00196 #define YY_STRUCT_YY_BUFFER_STATE
00197 struct yy_buffer_state
00198     {
00199     FILE *yy_input_file;
00200 
00201     char *yy_ch_buf;        /* input buffer */
00202     char *yy_buf_pos;       /* current position in input buffer */
00203 
00204     /* Size of input buffer in bytes, not including room for EOB
00205      * characters.
00206      */
00207     yy_size_t yy_buf_size;
00208 
00209     /* Number of characters read into yy_ch_buf, not including EOB
00210      * characters.
00211      */
00212     int yy_n_chars;
00213 
00214     /* Whether we "own" the buffer - i.e., we know we created it,
00215      * and can realloc() it to grow it, and should free() it to
00216      * delete it.
00217      */
00218     int yy_is_our_buffer;
00219 
00220     /* Whether this is an "interactive" input source; if so, and
00221      * if we're using stdio for input, then we want to use getc()
00222      * instead of fread(), to make sure we stop fetching input after
00223      * each newline.
00224      */
00225     int yy_is_interactive;
00226 
00227     /* Whether we're considered to be at the beginning of a line.
00228      * If so, '^' rules will be active on the next match, otherwise
00229      * not.
00230      */
00231     int yy_at_bol;
00232 
00233     int yy_bs_lineno; 
00234     int yy_bs_column; 
00236     /* Whether to try to fill the input buffer when we reach the
00237      * end of it.
00238      */
00239     int yy_fill_buffer;
00240 
00241     int yy_buffer_status;
00242 
00243 #define YY_BUFFER_NEW 0
00244 #define YY_BUFFER_NORMAL 1
00245     /* When an EOF's been seen but there's still some text to process
00246      * then we mark the buffer as YY_EOF_PENDING, to indicate that we
00247      * shouldn't try reading from the input source any more.  We might
00248      * still have a bunch of tokens to match, though, because of
00249      * possible backing-up.
00250      *
00251      * When we actually see the EOF, we change the status to "new"
00252      * (via yyrestart()), so that the user can continue scanning by
00253      * just pointing yyin at a new input file.
00254      */
00255 #define YY_BUFFER_EOF_PENDING 2
00256 
00257     };
00258 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
00259 
00260 /* Stack of input buffers. */
00261 static size_t yy_buffer_stack_top = 0; 
00262 static size_t yy_buffer_stack_max = 0; 
00263 static YY_BUFFER_STATE * yy_buffer_stack = 0; 
00265 /* We provide macros for accessing buffer states in case in the
00266  * future we want to put the buffer states in a more general
00267  * "scanner state".
00268  *
00269  * Returns the top of the stack, or NULL.
00270  */
00271 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
00272                           ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
00273                           : NULL)
00274 
00275 /* Same as previous macro, but useful when we know that the buffer stack is not
00276  * NULL or when we need an lvalue. For internal use only.
00277  */
00278 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
00279 
00280 /* yy_hold_char holds the character lost when yytext is formed. */
00281 static char yy_hold_char;
00282 static int yy_n_chars;      /* number of characters read into yy_ch_buf */
00283 int yyleng;
00284 
00285 /* Points to current character in buffer. */
00286 static char *yy_c_buf_p = (char *) 0;
00287 static int yy_init = 0;     /* whether we need to initialize */
00288 static int yy_start = 0;    /* start state number */
00289 
00290 /* Flag which is used to allow yywrap()'s to do buffer switches
00291  * instead of setting up a fresh yyin.  A bit of a hack ...
00292  */
00293 static int yy_did_buffer_switch_on_eof;
00294 
00295 void yyrestart (FILE *input_file  );
00296 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
00297 YY_BUFFER_STATE yy_create_buffer (FILE *file,int size  );
00298 void yy_delete_buffer (YY_BUFFER_STATE b  );
00299 void yy_flush_buffer (YY_BUFFER_STATE b  );
00300 void yypush_buffer_state (YY_BUFFER_STATE new_buffer  );
00301 void yypop_buffer_state (void );
00302 
00303 static void yyensure_buffer_stack (void );
00304 static void yy_load_buffer_state (void );
00305 static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file  );
00306 
00307 #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
00308 
00309 YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size  );
00310 YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str  );
00311 YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len  );
00312 
00313 void *yyalloc (yy_size_t  );
00314 void *yyrealloc (void *,yy_size_t  );
00315 void yyfree (void *  );
00316 
00317 #define yy_new_buffer yy_create_buffer
00318 
00319 #define yy_set_interactive(is_interactive) \
00320     { \
00321     if ( ! YY_CURRENT_BUFFER ){ \
00322         yyensure_buffer_stack (); \
00323         YY_CURRENT_BUFFER_LVALUE =    \
00324             yy_create_buffer(yyin,YY_BUF_SIZE ); \
00325     } \
00326     YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
00327     }
00328 
00329 #define yy_set_bol(at_bol) \
00330     { \
00331     if ( ! YY_CURRENT_BUFFER ){\
00332         yyensure_buffer_stack (); \
00333         YY_CURRENT_BUFFER_LVALUE =    \
00334             yy_create_buffer(yyin,YY_BUF_SIZE ); \
00335     } \
00336     YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
00337     }
00338 
00339 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
00340 
00341 /* Begin user sect3 */
00342 
00343 #define yywrap(n) 1
00344 #define YY_SKIP_YYWRAP
00345 
00346 typedef unsigned char YY_CHAR;
00347 
00348 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
00349 
00350 typedef int yy_state_type;
00351 
00352 extern int yylineno;
00353 
00354 int yylineno = 1;
00355 
00356 extern char *yytext;
00357 #define yytext_ptr yytext
00358 
00359 static yy_state_type yy_get_previous_state (void );
00360 static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
00361 static int yy_get_next_buffer (void );
00362 static void yy_fatal_error (yyconst char msg[]  );
00363 
00364 /* Done after the current pattern has been matched and before the
00365  * corresponding action - sets up yytext.
00366  */
00367 #define YY_DO_BEFORE_ACTION \
00368     (yytext_ptr) = yy_bp; \
00369     yyleng = (size_t) (yy_cp - yy_bp); \
00370     (yy_hold_char) = *yy_cp; \
00371     *yy_cp = '\0'; \
00372     (yy_c_buf_p) = yy_cp;
00373 
00374 #define YY_NUM_RULES 7
00375 #define YY_END_OF_BUFFER 8
00376 /* This struct is not used in this scanner,
00377    but its presence is necessary. */
00378 struct yy_trans_info
00379     {
00380     flex_int32_t yy_verify;
00381     flex_int32_t yy_nxt;
00382     };
00383 static yyconst flex_int16_t yy_accept[17] =
00384     {   0,
00385         0,    0,    8,    6,    4,    2,    6,    1,    6,    5,
00386         0,    3,    1,    0,    5,    0
00387     } ;
00388 
00389 static yyconst flex_int32_t yy_ec[256] =
00390     {   0,
00391         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
00392         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00393         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00394         1,    2,    1,    4,    5,    1,    1,    1,    6,    1,
00395         1,    1,    1,    1,    7,    7,    7,    8,    8,    8,
00396         8,    8,    8,    8,    8,    8,    8,    7,    1,    1,
00397         1,    1,    1,    7,    9,    9,    9,    9,    9,    9,
00398         9,    9,    9,    9,    9,    9,    9,    9,    9,    9,
00399         9,    9,    9,    9,    9,    9,    9,    9,    9,    9,
00400         1,    7,    1,    1,    7,    1,   10,   10,   10,   10,
00401 
00402        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
00403        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
00404        10,   10,    1,    1,    1,    1,    1,    1,    1,    1,
00405         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00406         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00407         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00408         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00409         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00410         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00411         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00412 
00413         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00414         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00415         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00416         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00417         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00418         1,    1,    1,    1,    1
00419     } ;
00420 
00421 static yyconst flex_int32_t yy_meta[11] =
00422     {   0,
00423         1,    1,    2,    1,    1,    1,    1,    1,    1,    1
00424     } ;
00425 
00426 static yyconst flex_int16_t yy_base[20] =
00427     {   0,
00428         0,    0,   15,   31,   31,   31,    8,    0,   10,   10,
00429        18,   31,    0,   20,    0,   31,   26,   13,   28
00430     } ;
00431 
00432 static yyconst flex_int16_t yy_def[20] =
00433     {   0,
00434        16,    1,   16,   16,   16,   16,   17,   18,   19,   16,
00435        17,   16,   18,   19,   10,    0,   16,   16,   16
00436     } ;
00437 
00438 static yyconst flex_int16_t yy_nxt[42] =
00439     {   0,
00440         4,    5,    6,    7,    8,    9,   10,   10,   10,   10,
00441        12,   12,   12,   13,   16,   12,   15,   15,   15,   15,
00442        12,   12,   12,   16,   16,   12,   11,   11,   14,   14,
00443         3,   16,   16,   16,   16,   16,   16,   16,   16,   16,
00444        16
00445     } ;
00446 
00447 static yyconst flex_int16_t yy_chk[42] =
00448     {   0,
00449         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00450         7,    7,    9,   18,    3,    9,   10,   10,   10,   10,
00451        11,   11,   14,    0,    0,   14,   17,   17,   19,   19,
00452        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
00453        16
00454     } ;
00455 
00456 static yy_state_type yy_last_accepting_state;
00457 static char *yy_last_accepting_cpos;
00458 
00459 extern int yy_flex_debug;
00460 int yy_flex_debug = 0;
00461 
00462 /* The intent behind this definition is that it'll catch
00463  * any uses of REJECT which flex missed.
00464  */
00465 #define REJECT reject_used_but_not_detected
00466 #define yymore() yymore_used_but_not_detected
00467 #define YY_MORE_ADJ 0
00468 #define YY_RESTORE_YY_MORE_OFFSET
00469 char *yytext;
00470 #line 1 "configfile.l"
00471 /*
00472  * Reads lexical config files and updates database.
00473  *
00474  * MUSCLE SmartCard Development ( http://www.linuxnet.com )
00475  *
00476  * Copyright (C) 1999-2002
00477  *  David Corcoran <corcoran@linuxnet.com>
00478  * Copyright (C) 2004
00479  *  Damien Sauveron <damien.sauveron@labri.fr>
00480  * Copyright (C) 2004-2009
00481  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
00482  *
00483  * $Id: configfile.l 4836 2010-03-19 12:34:32Z rousseau $
00484  */
00485 #line 17 "configfile.l"
00486 #include <dirent.h>
00487 
00488 #include "wintypes.h"
00489 #include "pcscd.h"
00490 #include "readerfactory.h"
00491 #include "configfile.h"
00492 
00493 int evaluatetoken(char *pcToken);
00494 
00495 static int iLinenumber;
00496 static int iOldLinenumber;
00497 static char *pcPrevious;
00498 static char *pcCurrent;
00499 static char *pcFriendlyname;
00500 static char *pcDevicename;
00501 static char *pcLibpath;
00502 static char *pcChannelid;
00503 static int badError;
00504 static SerialReader *reader_list;
00505 static int reader_list_size;
00506 const char *ConfFile;
00507 
00508 void tok_error(char *pcToken_error);
00509 
00510 #define YY_NO_INPUT 1
00511 #line 512 "configfile.c"
00512 
00513 #define INITIAL 0
00514 
00515 #ifndef YY_NO_UNISTD_H
00516 /* Special case for "unistd.h", since it is non-ANSI. We include it way
00517  * down here because we want the user's section 1 to have been scanned first.
00518  * The user has a chance to override it with an option.
00519  */
00520 #include <unistd.h>
00521 #endif
00522 
00523 #ifndef YY_EXTRA_TYPE
00524 #define YY_EXTRA_TYPE void *
00525 #endif
00526 
00527 static int yy_init_globals (void );
00528 
00529 /* Accessor methods to globals.
00530    These are made visible to non-reentrant scanners for convenience. */
00531 
00532 int yylex_destroy (void );
00533 
00534 int yyget_debug (void );
00535 
00536 void yyset_debug (int debug_flag  );
00537 
00538 YY_EXTRA_TYPE yyget_extra (void );
00539 
00540 void yyset_extra (YY_EXTRA_TYPE user_defined  );
00541 
00542 FILE *yyget_in (void );
00543 
00544 void yyset_in  (FILE * in_str  );
00545 
00546 FILE *yyget_out (void );
00547 
00548 void yyset_out  (FILE * out_str  );
00549 
00550 int yyget_leng (void );
00551 
00552 char *yyget_text (void );
00553 
00554 int yyget_lineno (void );
00555 
00556 void yyset_lineno (int line_number  );
00557 
00558 /* Macros after this point can all be overridden by user definitions in
00559  * section 1.
00560  */
00561 
00562 #ifndef YY_SKIP_YYWRAP
00563 #ifdef __cplusplus
00564 extern "C" int yywrap (void );
00565 #else
00566 extern int yywrap (void );
00567 #endif
00568 #endif
00569 
00570 #ifndef yytext_ptr
00571 static void yy_flex_strncpy (char *,yyconst char *,int );
00572 #endif
00573 
00574 #ifdef YY_NEED_STRLEN
00575 static int yy_flex_strlen (yyconst char * );
00576 #endif
00577 
00578 #ifndef YY_NO_INPUT
00579 
00580 #ifdef __cplusplus
00581 static int yyinput (void );
00582 #else
00583 static int input (void );
00584 #endif
00585 
00586 #endif
00587 
00588 /* Amount of stuff to slurp up with each read. */
00589 #ifndef YY_READ_BUF_SIZE
00590 #ifdef __ia64__
00591 /* On IA-64, the buffer size is 16k, not 8k */
00592 #define YY_READ_BUF_SIZE 16384
00593 #else
00594 #define YY_READ_BUF_SIZE 8192
00595 #endif /* __ia64__ */
00596 #endif
00597 
00598 /* Copy whatever the last rule matched to the standard output. */
00599 #ifndef ECHO
00600 /* This used to be an fputs(), but since the string might contain NUL's,
00601  * we now use fwrite().
00602  */
00603 #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
00604 #endif
00605 
00606 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
00607  * is returned in "result".
00608  */
00609 #ifndef YY_INPUT
00610 #define YY_INPUT(buf,result,max_size) \
00611     if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
00612         { \
00613         int c = '*'; \
00614         size_t n; \
00615         for ( n = 0; n < max_size && \
00616                  (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
00617             buf[n] = (char) c; \
00618         if ( c == '\n' ) \
00619             buf[n++] = (char) c; \
00620         if ( c == EOF && ferror( yyin ) ) \
00621             YY_FATAL_ERROR( "input in flex scanner failed" ); \
00622         result = n; \
00623         } \
00624     else \
00625         { \
00626         errno=0; \
00627         while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
00628             { \
00629             if( errno != EINTR) \
00630                 { \
00631                 YY_FATAL_ERROR( "input in flex scanner failed" ); \
00632                 break; \
00633                 } \
00634             errno=0; \
00635             clearerr(yyin); \
00636             } \
00637         }\
00638 \
00639 
00640 #endif
00641 
00642 /* No semi-colon after return; correct usage is to write "yyterminate();" -
00643  * we don't want an extra ';' after the "return" because that will cause
00644  * some compilers to complain about unreachable statements.
00645  */
00646 #ifndef yyterminate
00647 #define yyterminate() return YY_NULL
00648 #endif
00649 
00650 /* Number of entries by which start-condition stack grows. */
00651 #ifndef YY_START_STACK_INCR
00652 #define YY_START_STACK_INCR 25
00653 #endif
00654 
00655 /* Report a fatal error. */
00656 #ifndef YY_FATAL_ERROR
00657 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
00658 #endif
00659 
00660 /* end tables serialization structures and prototypes */
00661 
00662 /* Default declaration of generated scanner - a define so the user can
00663  * easily add parameters.
00664  */
00665 #ifndef YY_DECL
00666 #define YY_DECL_IS_OURS 1
00667 
00668 extern int yylex (void);
00669 
00670 #define YY_DECL int yylex (void)
00671 #endif /* !YY_DECL */
00672 
00673 /* Code executed at the beginning of each rule, after yytext and yyleng
00674  * have been set up.
00675  */
00676 #ifndef YY_USER_ACTION
00677 #define YY_USER_ACTION
00678 #endif
00679 
00680 /* Code executed at the end of each rule. */
00681 #ifndef YY_BREAK
00682 #define YY_BREAK break;
00683 #endif
00684 
00685 #define YY_RULE_SETUP \
00686     YY_USER_ACTION
00687 
00690 YY_DECL
00691 {
00692     register yy_state_type yy_current_state;
00693     register char *yy_cp, *yy_bp;
00694     register int yy_act;
00695     
00696 #line 47 "configfile.l"
00697 
00698 
00699 #line 700 "configfile.c"
00700 
00701     if ( !(yy_init) )
00702         {
00703         (yy_init) = 1;
00704 
00705 #ifdef YY_USER_INIT
00706         YY_USER_INIT;
00707 #endif
00708 
00709         if ( ! (yy_start) )
00710             (yy_start) = 1; /* first start state */
00711 
00712         if ( ! yyin )
00713             yyin = stdin;
00714 
00715         if ( ! yyout )
00716             yyout = stdout;
00717 
00718         if ( ! YY_CURRENT_BUFFER ) {
00719             yyensure_buffer_stack ();
00720             YY_CURRENT_BUFFER_LVALUE =
00721                 yy_create_buffer(yyin,YY_BUF_SIZE );
00722         }
00723 
00724         yy_load_buffer_state( );
00725         }
00726 
00727     while ( 1 )     /* loops until end-of-file is reached */
00728         {
00729         yy_cp = (yy_c_buf_p);
00730 
00731         /* Support of yytext. */
00732         *yy_cp = (yy_hold_char);
00733 
00734         /* yy_bp points to the position in yy_ch_buf of the start of
00735          * the current run.
00736          */
00737         yy_bp = yy_cp;
00738 
00739         yy_current_state = (yy_start);
00740 yy_match:
00741         do
00742             {
00743             register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
00744             if ( yy_accept[yy_current_state] )
00745                 {
00746                 (yy_last_accepting_state) = yy_current_state;
00747                 (yy_last_accepting_cpos) = yy_cp;
00748                 }
00749             while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
00750                 {
00751                 yy_current_state = (int) yy_def[yy_current_state];
00752                 if ( yy_current_state >= 17 )
00753                     yy_c = yy_meta[(unsigned int) yy_c];
00754                 }
00755             yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
00756             ++yy_cp;
00757             }
00758         while ( yy_base[yy_current_state] != 31 );
00759 
00760 yy_find_action:
00761         yy_act = yy_accept[yy_current_state];
00762         if ( yy_act == 0 )
00763             { /* have to back up */
00764             yy_cp = (yy_last_accepting_cpos);
00765             yy_current_state = (yy_last_accepting_state);
00766             yy_act = yy_accept[yy_current_state];
00767             }
00768 
00769         YY_DO_BEFORE_ACTION;
00770 
00771 do_action:  /* This label is used only to access EOF actions. */
00772 
00773         switch ( yy_act )
00774     { /* beginning of action switch */
00775             case 0: /* must back up */
00776             /* undo the effects of YY_DO_BEFORE_ACTION */
00777             *yy_cp = (yy_hold_char);
00778             yy_cp = (yy_last_accepting_cpos);
00779             yy_current_state = (yy_last_accepting_state);
00780             goto yy_find_action;
00781 
00782 case 1:
00783 YY_RULE_SETUP
00784 #line 49 "configfile.l"
00785 {}
00786     YY_BREAK
00787 case 2:
00788 /* rule 2 can match eol */
00789 YY_RULE_SETUP
00790 #line 50 "configfile.l"
00791 { iLinenumber++; }
00792     YY_BREAK
00793 case 3:
00794 /* rule 3 can match eol */
00795 YY_RULE_SETUP
00796 #line 51 "configfile.l"
00797 { (void)evaluatetoken(yytext); }
00798     YY_BREAK
00799 case 4:
00800 YY_RULE_SETUP
00801 #line 52 "configfile.l"
00802 {}
00803     YY_BREAK
00804 case 5:
00805 YY_RULE_SETUP
00806 #line 53 "configfile.l"
00807 { (void)evaluatetoken(yytext); }
00808     YY_BREAK
00809 case 6:
00810 YY_RULE_SETUP
00811 #line 54 "configfile.l"
00812 { tok_error(yytext); }
00813     YY_BREAK
00814 case 7:
00815 YY_RULE_SETUP
00816 #line 55 "configfile.l"
00817 ECHO;
00818     YY_BREAK
00819 #line 820 "configfile.c"
00820 case YY_STATE_EOF(INITIAL):
00821     yyterminate();
00822 
00823     case YY_END_OF_BUFFER:
00824         {
00825         /* Amount of text matched not including the EOB char. */
00826         int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
00827 
00828         /* Undo the effects of YY_DO_BEFORE_ACTION. */
00829         *yy_cp = (yy_hold_char);
00830         YY_RESTORE_YY_MORE_OFFSET
00831 
00832         if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
00833             {
00834             /* We're scanning a new file or input source.  It's
00835              * possible that this happened because the user
00836              * just pointed yyin at a new source and called
00837              * yylex().  If so, then we have to assure
00838              * consistency between YY_CURRENT_BUFFER and our
00839              * globals.  Here is the right place to do so, because
00840              * this is the first action (other than possibly a
00841              * back-up) that will match for the new input source.
00842              */
00843             (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
00844             YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
00845             YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
00846             }
00847 
00848         /* Note that here we test for yy_c_buf_p "<=" to the position
00849          * of the first EOB in the buffer, since yy_c_buf_p will
00850          * already have been incremented past the NUL character
00851          * (since all states make transitions on EOB to the
00852          * end-of-buffer state).  Contrast this with the test
00853          * in input().
00854          */
00855         if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
00856             { /* This was really a NUL. */
00857             yy_state_type yy_next_state;
00858 
00859             (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
00860 
00861             yy_current_state = yy_get_previous_state(  );
00862 
00863             /* Okay, we're now positioned to make the NUL
00864              * transition.  We couldn't have
00865              * yy_get_previous_state() go ahead and do it
00866              * for us because it doesn't know how to deal
00867              * with the possibility of jamming (and we don't
00868              * want to build jamming into it because then it
00869              * will run more slowly).
00870              */
00871 
00872             yy_next_state = yy_try_NUL_trans( yy_current_state );
00873 
00874             yy_bp = (yytext_ptr) + YY_MORE_ADJ;
00875 
00876             if ( yy_next_state )
00877                 {
00878                 /* Consume the NUL. */
00879                 yy_cp = ++(yy_c_buf_p);
00880                 yy_current_state = yy_next_state;
00881                 goto yy_match;
00882                 }
00883 
00884             else
00885                 {
00886                 yy_cp = (yy_c_buf_p);
00887                 goto yy_find_action;
00888                 }
00889             }
00890 
00891         else switch ( yy_get_next_buffer(  ) )
00892             {
00893             case EOB_ACT_END_OF_FILE:
00894                 {
00895                 (yy_did_buffer_switch_on_eof) = 0;
00896 
00897                 if ( yywrap( ) )
00898                     {
00899                     /* Note: because we've taken care in
00900                      * yy_get_next_buffer() to have set up
00901                      * yytext, we can now set up
00902                      * yy_c_buf_p so that if some total
00903                      * hoser (like flex itself) wants to
00904                      * call the scanner after we return the
00905                      * YY_NULL, it'll still work - another
00906                      * YY_NULL will get returned.
00907                      */
00908                     (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
00909 
00910                     yy_act = YY_STATE_EOF(YY_START);
00911                     goto do_action;
00912                     }
00913 
00914                 else
00915                     {
00916                     if ( ! (yy_did_buffer_switch_on_eof) )
00917                         YY_NEW_FILE;
00918                     }
00919                 break;
00920                 }
00921 
00922             case EOB_ACT_CONTINUE_SCAN:
00923                 (yy_c_buf_p) =
00924                     (yytext_ptr) + yy_amount_of_matched_text;
00925 
00926                 yy_current_state = yy_get_previous_state(  );
00927 
00928                 yy_cp = (yy_c_buf_p);
00929                 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
00930                 goto yy_match;
00931 
00932             case EOB_ACT_LAST_MATCH:
00933                 (yy_c_buf_p) =
00934                 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
00935 
00936                 yy_current_state = yy_get_previous_state(  );
00937 
00938                 yy_cp = (yy_c_buf_p);
00939                 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
00940                 goto yy_find_action;
00941             }
00942         break;
00943         }
00944 
00945     default:
00946         YY_FATAL_ERROR(
00947             "fatal flex scanner internal error--no action found" );
00948     } /* end of action switch */
00949         } /* end of scanning one token */
00950 } /* end of yylex */
00951 
00952 /* yy_get_next_buffer - try to read in a new buffer
00953  *
00954  * Returns a code representing an action:
00955  *  EOB_ACT_LAST_MATCH -
00956  *  EOB_ACT_CONTINUE_SCAN - continue scanning from current position
00957  *  EOB_ACT_END_OF_FILE - end of file
00958  */
00959 static int yy_get_next_buffer (void)
00960 {
00961         register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
00962     register char *source = (yytext_ptr);
00963     register int number_to_move, i;
00964     int ret_val;
00965 
00966     if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
00967         YY_FATAL_ERROR(
00968         "fatal flex scanner internal error--end of buffer missed" );
00969 
00970     if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
00971         { /* Don't try to fill the buffer, so this is an EOF. */
00972         if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
00973             {
00974             /* We matched a single character, the EOB, so
00975              * treat this as a final EOF.
00976              */
00977             return EOB_ACT_END_OF_FILE;
00978             }
00979 
00980         else
00981             {
00982             /* We matched some text prior to the EOB, first
00983              * process it.
00984              */
00985             return EOB_ACT_LAST_MATCH;
00986             }
00987         }
00988 
00989     /* Try to read more data. */
00990 
00991     /* First move last chars to start of buffer. */
00992     number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
00993 
00994     for ( i = 0; i < number_to_move; ++i )
00995         *(dest++) = *(source++);
00996 
00997     if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
00998         /* don't do the read, it's not guaranteed to return an EOF,
00999          * just force an EOF
01000          */
01001         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
01002 
01003     else
01004         {
01005             int num_to_read =
01006             YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
01007 
01008         while ( num_to_read <= 0 )
01009             { /* Not enough room in the buffer - grow it. */
01010 
01011             /* just a shorter name for the current buffer */
01012             YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
01013 
01014             int yy_c_buf_p_offset =
01015                 (int) ((yy_c_buf_p) - b->yy_ch_buf);
01016 
01017             if ( b->yy_is_our_buffer )
01018                 {
01019                 int new_size = b->yy_buf_size * 2;
01020 
01021                 if ( new_size <= 0 )
01022                     b->yy_buf_size += b->yy_buf_size / 8;
01023                 else
01024                     b->yy_buf_size *= 2;
01025 
01026                 b->yy_ch_buf = (char *)
01027                     /* Include room in for 2 EOB chars. */
01028                     yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
01029                 }
01030             else
01031                 /* Can't grow it, we don't own it. */
01032                 b->yy_ch_buf = 0;
01033 
01034             if ( ! b->yy_ch_buf )
01035                 YY_FATAL_ERROR(
01036                 "fatal error - scanner input buffer overflow" );
01037 
01038             (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
01039 
01040             num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
01041                         number_to_move - 1;
01042 
01043             }
01044 
01045         if ( num_to_read > YY_READ_BUF_SIZE )
01046             num_to_read = YY_READ_BUF_SIZE;
01047 
01048         /* Read in more data. */
01049         YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
01050             (yy_n_chars), (size_t) num_to_read );
01051 
01052         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
01053         }
01054 
01055     if ( (yy_n_chars) == 0 )
01056         {
01057         if ( number_to_move == YY_MORE_ADJ )
01058             {
01059             ret_val = EOB_ACT_END_OF_FILE;
01060             yyrestart(yyin  );
01061             }
01062 
01063         else
01064             {
01065             ret_val = EOB_ACT_LAST_MATCH;
01066             YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
01067                 YY_BUFFER_EOF_PENDING;
01068             }
01069         }
01070 
01071     else
01072         ret_val = EOB_ACT_CONTINUE_SCAN;
01073 
01074     if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
01075         /* Extend the array by 50%, plus the number we really need. */
01076         yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
01077         YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
01078         if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
01079             YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
01080     }
01081 
01082     (yy_n_chars) += number_to_move;
01083     YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
01084     YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
01085 
01086     (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
01087 
01088     return ret_val;
01089 }
01090 
01091 /* yy_get_previous_state - get the state just before the EOB char was reached */
01092 
01093     static yy_state_type yy_get_previous_state (void)
01094 {
01095     register yy_state_type yy_current_state;
01096     register char *yy_cp;
01097     
01098     yy_current_state = (yy_start);
01099 
01100     for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
01101         {
01102         register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
01103         if ( yy_accept[yy_current_state] )
01104             {
01105             (yy_last_accepting_state) = yy_current_state;
01106             (yy_last_accepting_cpos) = yy_cp;
01107             }
01108         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
01109             {
01110             yy_current_state = (int) yy_def[yy_current_state];
01111             if ( yy_current_state >= 17 )
01112                 yy_c = yy_meta[(unsigned int) yy_c];
01113             }
01114         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
01115         }
01116 
01117     return yy_current_state;
01118 }
01119 
01120 /* yy_try_NUL_trans - try to make a transition on the NUL character
01121  *
01122  * synopsis
01123  *  next_state = yy_try_NUL_trans( current_state );
01124  */
01125     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
01126 {
01127     register int yy_is_jam;
01128         register char *yy_cp = (yy_c_buf_p);
01129 
01130     register YY_CHAR yy_c = 1;
01131     if ( yy_accept[yy_current_state] )
01132         {
01133         (yy_last_accepting_state) = yy_current_state;
01134         (yy_last_accepting_cpos) = yy_cp;
01135         }
01136     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
01137         {
01138         yy_current_state = (int) yy_def[yy_current_state];
01139         if ( yy_current_state >= 17 )
01140             yy_c = yy_meta[(unsigned int) yy_c];
01141         }
01142     yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
01143     yy_is_jam = (yy_current_state == 16);
01144 
01145     return yy_is_jam ? 0 : yy_current_state;
01146 }
01147 
01148 #ifndef YY_NO_INPUT
01149 #ifdef __cplusplus
01150     static int yyinput (void)
01151 #else
01152     static int input  (void)
01153 #endif
01154 
01155 {
01156     int c;
01157     
01158     *(yy_c_buf_p) = (yy_hold_char);
01159 
01160     if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
01161         {
01162         /* yy_c_buf_p now points to the character we want to return.
01163          * If this occurs *before* the EOB characters, then it's a
01164          * valid NUL; if not, then we've hit the end of the buffer.
01165          */
01166         if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
01167             /* This was really a NUL. */
01168             *(yy_c_buf_p) = '\0';
01169 
01170         else
01171             { /* need more input */
01172             int offset = (yy_c_buf_p) - (yytext_ptr);
01173             ++(yy_c_buf_p);
01174 
01175             switch ( yy_get_next_buffer(  ) )
01176                 {
01177                 case EOB_ACT_LAST_MATCH:
01178                     /* This happens because yy_g_n_b()
01179                      * sees that we've accumulated a
01180                      * token and flags that we need to
01181                      * try matching the token before
01182                      * proceeding.  But for input(),
01183                      * there's no matching to consider.
01184                      * So convert the EOB_ACT_LAST_MATCH
01185                      * to EOB_ACT_END_OF_FILE.
01186                      */
01187 
01188                     /* Reset buffer status. */
01189                     yyrestart(yyin );
01190 
01191                     /*FALLTHROUGH*/
01192 
01193                 case EOB_ACT_END_OF_FILE:
01194                     {
01195                     if ( yywrap( ) )
01196                         return EOF;
01197 
01198                     if ( ! (yy_did_buffer_switch_on_eof) )
01199                         YY_NEW_FILE;
01200 #ifdef __cplusplus
01201                     return yyinput();
01202 #else
01203                     return input();
01204 #endif
01205                     }
01206 
01207                 case EOB_ACT_CONTINUE_SCAN:
01208                     (yy_c_buf_p) = (yytext_ptr) + offset;
01209                     break;
01210                 }
01211             }
01212         }
01213 
01214     c = *(unsigned char *) (yy_c_buf_p);    /* cast for 8-bit char's */
01215     *(yy_c_buf_p) = '\0';   /* preserve yytext */
01216     (yy_hold_char) = *++(yy_c_buf_p);
01217 
01218     return c;
01219 }
01220 #endif  /* ifndef YY_NO_INPUT */
01221 
01227     void yyrestart  (FILE * input_file )
01228 {
01229     
01230     if ( ! YY_CURRENT_BUFFER ){
01231         yyensure_buffer_stack ();
01232         YY_CURRENT_BUFFER_LVALUE =
01233             yy_create_buffer(yyin,YY_BUF_SIZE );
01234     }
01235 
01236     yy_init_buffer(YY_CURRENT_BUFFER,input_file );
01237     yy_load_buffer_state( );
01238 }
01239 
01244     void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
01245 {
01246     
01247     /* TODO. We should be able to replace this entire function body
01248      * with
01249      *      yypop_buffer_state();
01250      *      yypush_buffer_state(new_buffer);
01251      */
01252     yyensure_buffer_stack ();
01253     if ( YY_CURRENT_BUFFER == new_buffer )
01254         return;
01255 
01256     if ( YY_CURRENT_BUFFER )
01257         {
01258         /* Flush out information for old buffer. */
01259         *(yy_c_buf_p) = (yy_hold_char);
01260         YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
01261         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
01262         }
01263 
01264     YY_CURRENT_BUFFER_LVALUE = new_buffer;
01265     yy_load_buffer_state( );
01266 
01267     /* We don't actually know whether we did this switch during
01268      * EOF (yywrap()) processing, but the only time this flag
01269      * is looked at is after yywrap() is called, so it's safe
01270      * to go ahead and always set it.
01271      */
01272     (yy_did_buffer_switch_on_eof) = 1;
01273 }
01274 
01275 static void yy_load_buffer_state  (void)
01276 {
01277         (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
01278     (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
01279     yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
01280     (yy_hold_char) = *(yy_c_buf_p);
01281 }
01282 
01289     YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size )
01290 {
01291     YY_BUFFER_STATE b;
01292     
01293     b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
01294     if ( ! b )
01295         YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
01296 
01297     b->yy_buf_size = size;
01298 
01299     /* yy_ch_buf has to be 2 characters longer than the size given because
01300      * we need to put in 2 end-of-buffer characters.
01301      */
01302     b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2  );
01303     if ( ! b->yy_ch_buf )
01304         YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
01305 
01306     b->yy_is_our_buffer = 1;
01307 
01308     yy_init_buffer(b,file );
01309 
01310     return b;
01311 }
01312 
01317     void yy_delete_buffer (YY_BUFFER_STATE  b )
01318 {
01319     
01320     if ( ! b )
01321         return;
01322 
01323     if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
01324         YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
01325 
01326     if ( b->yy_is_our_buffer )
01327         yyfree((void *) b->yy_ch_buf  );
01328 
01329     yyfree((void *) b  );
01330 }
01331 
01332 #ifndef __cplusplus
01333 extern int isatty (int );
01334 #endif /* __cplusplus */
01335     
01336 /* Initializes or reinitializes a buffer.
01337  * This function is sometimes called more than once on the same buffer,
01338  * such as during a yyrestart() or at EOF.
01339  */
01340     static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
01341 
01342 {
01343     int oerrno = errno;
01344     
01345     yy_flush_buffer(b );
01346 
01347     b->yy_input_file = file;
01348     b->yy_fill_buffer = 1;
01349 
01350     /* If b is the current buffer, then yy_init_buffer was _probably_
01351      * called from yyrestart() or through yy_get_next_buffer.
01352      * In that case, we don't want to reset the lineno or column.
01353      */
01354     if (b != YY_CURRENT_BUFFER){
01355         b->yy_bs_lineno = 1;
01356         b->yy_bs_column = 0;
01357     }
01358 
01359         b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
01360     
01361     errno = oerrno;
01362 }
01363 
01368     void yy_flush_buffer (YY_BUFFER_STATE  b )
01369 {
01370         if ( ! b )
01371         return;
01372 
01373     b->yy_n_chars = 0;
01374 
01375     /* We always need two end-of-buffer characters.  The first causes
01376      * a transition to the end-of-buffer state.  The second causes
01377      * a jam in that state.
01378      */
01379     b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
01380     b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
01381 
01382     b->yy_buf_pos = &b->yy_ch_buf[0];
01383 
01384     b->yy_at_bol = 1;
01385     b->yy_buffer_status = YY_BUFFER_NEW;
01386 
01387     if ( b == YY_CURRENT_BUFFER )
01388         yy_load_buffer_state( );
01389 }
01390 
01397 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
01398 {
01399         if (new_buffer == NULL)
01400         return;
01401 
01402     yyensure_buffer_stack();
01403 
01404     /* This block is copied from yy_switch_to_buffer. */
01405     if ( YY_CURRENT_BUFFER )
01406         {
01407         /* Flush out information for old buffer. */
01408         *(yy_c_buf_p) = (yy_hold_char);
01409         YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
01410         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
01411         }
01412 
01413     /* Only push if top exists. Otherwise, replace top. */
01414     if (YY_CURRENT_BUFFER)
01415         (yy_buffer_stack_top)++;
01416     YY_CURRENT_BUFFER_LVALUE = new_buffer;
01417 
01418     /* copied from yy_switch_to_buffer. */
01419     yy_load_buffer_state( );
01420     (yy_did_buffer_switch_on_eof) = 1;
01421 }
01422 
01427 void yypop_buffer_state (void)
01428 {
01429         if (!YY_CURRENT_BUFFER)
01430         return;
01431 
01432     yy_delete_buffer(YY_CURRENT_BUFFER );
01433     YY_CURRENT_BUFFER_LVALUE = NULL;
01434     if ((yy_buffer_stack_top) > 0)
01435         --(yy_buffer_stack_top);
01436 
01437     if (YY_CURRENT_BUFFER) {
01438         yy_load_buffer_state( );
01439         (yy_did_buffer_switch_on_eof) = 1;
01440     }
01441 }
01442 
01443 /* Allocates the stack if it does not exist.
01444  *  Guarantees space for at least one push.
01445  */
01446 static void yyensure_buffer_stack (void)
01447 {
01448     int num_to_alloc;
01449     
01450     if (!(yy_buffer_stack)) {
01451 
01452         /* First allocation is just for 2 elements, since we don't know if this
01453          * scanner will even need a stack. We use 2 instead of 1 to avoid an
01454          * immediate realloc on the next call.
01455          */
01456         num_to_alloc = 1;
01457         (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
01458                                 (num_to_alloc * sizeof(struct yy_buffer_state*)
01459                                 );
01460         if ( ! (yy_buffer_stack) )
01461             YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
01462                                   
01463         memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
01464                 
01465         (yy_buffer_stack_max) = num_to_alloc;
01466         (yy_buffer_stack_top) = 0;
01467         return;
01468     }
01469 
01470     if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
01471 
01472         /* Increase the buffer to prepare for a possible push. */
01473         int grow_size = 8 /* arbitrary grow size */;
01474 
01475         num_to_alloc = (yy_buffer_stack_max) + grow_size;
01476         (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
01477                                 ((yy_buffer_stack),
01478                                 num_to_alloc * sizeof(struct yy_buffer_state*)
01479                                 );
01480         if ( ! (yy_buffer_stack) )
01481             YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
01482 
01483         /* zero only the new slots.*/
01484         memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
01485         (yy_buffer_stack_max) = num_to_alloc;
01486     }
01487 }
01488 
01495 YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size )
01496 {
01497     YY_BUFFER_STATE b;
01498     
01499     if ( size < 2 ||
01500          base[size-2] != YY_END_OF_BUFFER_CHAR ||
01501          base[size-1] != YY_END_OF_BUFFER_CHAR )
01502         /* They forgot to leave room for the EOB's. */
01503         return 0;
01504 
01505     b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
01506     if ( ! b )
01507         YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
01508 
01509     b->yy_buf_size = size - 2;  /* "- 2" to take care of EOB's */
01510     b->yy_buf_pos = b->yy_ch_buf = base;
01511     b->yy_is_our_buffer = 0;
01512     b->yy_input_file = 0;
01513     b->yy_n_chars = b->yy_buf_size;
01514     b->yy_is_interactive = 0;
01515     b->yy_at_bol = 1;
01516     b->yy_fill_buffer = 0;
01517     b->yy_buffer_status = YY_BUFFER_NEW;
01518 
01519     yy_switch_to_buffer(b  );
01520 
01521     return b;
01522 }
01523 
01532 YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
01533 {
01534     
01535     return yy_scan_bytes(yystr,strlen(yystr) );
01536 }
01537 
01545 YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
01546 {
01547     YY_BUFFER_STATE b;
01548     char *buf;
01549     yy_size_t n;
01550     int i;
01551     
01552     /* Get memory for full buffer, including space for trailing EOB's. */
01553     n = _yybytes_len + 2;
01554     buf = (char *) yyalloc(n  );
01555     if ( ! buf )
01556         YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
01557 
01558     for ( i = 0; i < _yybytes_len; ++i )
01559         buf[i] = yybytes[i];
01560 
01561     buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
01562 
01563     b = yy_scan_buffer(buf,n );
01564     if ( ! b )
01565         YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
01566 
01567     /* It's okay to grow etc. this buffer, and we should throw it
01568      * away when we're done.
01569      */
01570     b->yy_is_our_buffer = 1;
01571 
01572     return b;
01573 }
01574 
01575 #ifndef YY_EXIT_FAILURE
01576 #define YY_EXIT_FAILURE 2
01577 #endif
01578 
01579 static void yy_fatal_error (yyconst char* msg )
01580 {
01581         (void) fprintf( stderr, "%s\n", msg );
01582     exit( YY_EXIT_FAILURE );
01583 }
01584 
01585 /* Redefine yyless() so it works in section 3 code. */
01586 
01587 #undef yyless
01588 #define yyless(n) \
01589     do \
01590         { \
01591         /* Undo effects of setting up yytext. */ \
01592         int yyless_macro_arg = (n); \
01593         YY_LESS_LINENO(yyless_macro_arg);\
01594         yytext[yyleng] = (yy_hold_char); \
01595         (yy_c_buf_p) = yytext + yyless_macro_arg; \
01596         (yy_hold_char) = *(yy_c_buf_p); \
01597         *(yy_c_buf_p) = '\0'; \
01598         yyleng = yyless_macro_arg; \
01599         } \
01600     while ( 0 )
01601 
01602 /* Accessor  methods (get/set functions) to struct members. */
01603 
01607 int yyget_lineno  (void)
01608 {
01609         
01610     return yylineno;
01611 }
01612 
01616 FILE *yyget_in  (void)
01617 {
01618         return yyin;
01619 }
01620 
01624 FILE *yyget_out  (void)
01625 {
01626         return yyout;
01627 }
01628 
01632 int yyget_leng  (void)
01633 {
01634         return yyleng;
01635 }
01636 
01641 char *yyget_text  (void)
01642 {
01643         return yytext;
01644 }
01645 
01650 void yyset_lineno (int  line_number )
01651 {
01652     
01653     yylineno = line_number;
01654 }
01655 
01662 void yyset_in (FILE *  in_str )
01663 {
01664         yyin = in_str ;
01665 }
01666 
01667 void yyset_out (FILE *  out_str )
01668 {
01669         yyout = out_str ;
01670 }
01671 
01672 int yyget_debug  (void)
01673 {
01674         return yy_flex_debug;
01675 }
01676 
01677 void yyset_debug (int  bdebug )
01678 {
01679         yy_flex_debug = bdebug ;
01680 }
01681 
01682 static int yy_init_globals (void)
01683 {
01684         /* Initialization is the same as for the non-reentrant scanner.
01685      * This function is called from yylex_destroy(), so don't allocate here.
01686      */
01687 
01688     (yy_buffer_stack) = 0;
01689     (yy_buffer_stack_top) = 0;
01690     (yy_buffer_stack_max) = 0;
01691     (yy_c_buf_p) = (char *) 0;
01692     (yy_init) = 0;
01693     (yy_start) = 0;
01694 
01695 /* Defined in main.c */
01696 #ifdef YY_STDINIT
01697     yyin = stdin;
01698     yyout = stdout;
01699 #else
01700     yyin = (FILE *) 0;
01701     yyout = (FILE *) 0;
01702 #endif
01703 
01704     /* For future reference: Set errno on error, since we are called by
01705      * yylex_init()
01706      */
01707     return 0;
01708 }
01709 
01710 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
01711 int yylex_destroy  (void)
01712 {
01713     
01714     /* Pop the buffer stack, destroying each element. */
01715     while(YY_CURRENT_BUFFER){
01716         yy_delete_buffer(YY_CURRENT_BUFFER  );
01717         YY_CURRENT_BUFFER_LVALUE = NULL;
01718         yypop_buffer_state();
01719     }
01720 
01721     /* Destroy the stack itself. */
01722     yyfree((yy_buffer_stack) );
01723     (yy_buffer_stack) = NULL;
01724 
01725     /* Reset the globals. This is important in a non-reentrant scanner so the next time
01726      * yylex() is called, initialization will occur. */
01727     yy_init_globals( );
01728 
01729     return 0;
01730 }
01731 
01732 /*
01733  * Internal utility routines.
01734  */
01735 
01736 #ifndef yytext_ptr
01737 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
01738 {
01739     register int i;
01740     for ( i = 0; i < n; ++i )
01741         s1[i] = s2[i];
01742 }
01743 #endif
01744 
01745 #ifdef YY_NEED_STRLEN
01746 static int yy_flex_strlen (yyconst char * s )
01747 {
01748     register int n;
01749     for ( n = 0; s[n]; ++n )
01750         ;
01751 
01752     return n;
01753 }
01754 #endif
01755 
01756 void *yyalloc (yy_size_t  size )
01757 {
01758     return (void *) malloc( size );
01759 }
01760 
01761 void *yyrealloc  (void * ptr, yy_size_t  size )
01762 {
01763     /* The cast to (char *) in the following accommodates both
01764      * implementations that use char* generic pointers, and those
01765      * that use void* generic pointers.  It works with the latter
01766      * because both ANSI C and C++ allow castless assignment from
01767      * any pointer type to void*, and deal with argument conversions
01768      * as though doing an assignment.
01769      */
01770     return (void *) realloc( (char *) ptr, size );
01771 }
01772 
01773 void yyfree (void * ptr )
01774 {
01775     free( (char *) ptr );   /* see yyrealloc() for (char *) cast */
01776 }
01777 
01778 #define YYTABLES_NAME "yytables"
01779 
01780 #line 55 "configfile.l"
01781 
01782 
01783 
01784 #include <stdio.h>
01785 #include <string.h>
01786 #include <errno.h>
01787 
01788 #include "config.h"
01789 #include "misc.h"
01790 #include "pcsclite.h"
01791 #include "pcscd.h"
01792 #include "debuglog.h"
01793 #include "sys_generic.h"
01794 #include "readerfactory.h"
01795 
01796 int evaluatetoken(char *pcToken)
01797 {
01798 
01799     int channelId = 0;
01800     int p = 0;
01801     unsigned int n = 0;
01802 
01803     if (pcPrevious == NULL)
01804     {   /* This is the key */
01805         pcPrevious = strdup(pcToken);
01806         iOldLinenumber = iLinenumber;
01807     }
01808     else
01809     {
01810         /* first and second tokens are not on the same line */
01811         if (iOldLinenumber != iLinenumber)
01812         {
01813             tok_error(pcPrevious);
01814             pcPrevious = strdup(pcToken);
01815             iOldLinenumber = iLinenumber;
01816             return 1;
01817         }
01818 
01819         pcCurrent = pcToken;
01820         if (strcmp(pcPrevious, "FRIENDLYNAME") == 0)
01821         {
01822             if (pcFriendlyname == NULL)
01823             {
01824                 pcFriendlyname = malloc(strlen(pcCurrent) - 1);
01825                 for (n = 0; n < strlen(pcCurrent); n++)
01826                 {
01827                     if (pcCurrent[n] != '"')
01828                     {   /* Strip off the quotes */
01829                         pcFriendlyname[p++] = pcCurrent[n];
01830                     }
01831                 }
01832                 pcFriendlyname[p++] = '\0';
01833             }
01834             else
01835             {
01836                 tok_error(pcPrevious);
01837                 return 1;
01838             }
01839         }
01840         else if (strcmp(pcPrevious, "DEVICENAME") == 0)
01841         {
01842             if (pcDevicename == NULL)
01843             {
01844                 struct stat fStatBuf;
01845 
01846                 pcDevicename = strdup(pcCurrent);
01847                 if ((NULL == strchr(pcDevicename, ':'))
01848                     && (stat(pcDevicename, &fStatBuf) != 0))
01849                 {
01850                     Log3(PCSC_LOG_CRITICAL, "Error with device %s: %s",
01851                         pcDevicename, strerror(errno));
01852                     Log1(PCSC_LOG_CRITICAL, "You should use 'DEVICENAME /dev/null' if your driver does not use this field");
01853                     badError = 1;
01854                 }
01855             }
01856             else
01857             {
01858                 tok_error(pcPrevious);
01859                 return 1;
01860             }
01861         }
01862         else if (strcmp(pcPrevious, "LIBPATH") == 0)
01863         {
01864             if (pcLibpath == NULL)
01865             {
01866                 struct stat fStatBuf;
01867 
01868                 pcLibpath = strdup(pcCurrent);
01869                 if (stat(pcLibpath, &fStatBuf) != 0)
01870                 {
01871                     Log3(PCSC_LOG_CRITICAL, "Error with library %s: %s",
01872                         pcLibpath, strerror(errno));
01873                     badError = 1;
01874                 }
01875 
01876                 if (strstr(pcLibpath, ".bundle") != NULL)
01877                 {
01878                     Log1(PCSC_LOG_ERROR, "WARNING *************************************");
01879                     Log2(PCSC_LOG_ERROR, "WARNING: USB drivers SHOULD NOT be declared in reader.conf: %s", pcLibpath);
01880                     Log1(PCSC_LOG_ERROR, "WARNING *************************************");
01881                 }
01882             }
01883             else
01884             {
01885                 tok_error(pcPrevious);
01886                 return 1;
01887             }
01888         }
01889         else if (strcmp(pcPrevious, "CHANNELID") == 0)
01890         {
01891             if (pcChannelid == NULL)
01892                 pcChannelid = strdup(pcCurrent);
01893             else
01894             {
01895                 tok_error(pcPrevious);
01896                 return 1;
01897             }
01898         }
01899         else
01900         {
01901             tok_error(pcPrevious);
01902             free(pcPrevious);
01903             pcPrevious = NULL;
01904             return 1;
01905         }
01906 
01907         free(pcPrevious);
01908         pcPrevious = NULL;
01909     }
01910 
01911     if (pcFriendlyname != NULL && pcDevicename != NULL &&
01912         pcLibpath != NULL && pcChannelid != NULL && badError != 1)
01913     {
01914         if (0 == reader_list_size)
01915         {
01916             /* one real reader and one end marker */
01917             reader_list_size = 2;
01918             reader_list = malloc(reader_list_size * sizeof(SerialReader));
01919         }
01920         else
01921         {
01922             reader_list_size++;
01923             reader_list = realloc(reader_list, reader_list_size *
01924                 sizeof(SerialReader));
01925         }
01926 
01927         /* end marker */
01928         reader_list[reader_list_size-1].pcFriendlyname = NULL;
01929 
01930         channelId = strtoul(pcChannelid, 0, 16);
01931         reader_list[reader_list_size-2].pcFriendlyname = strdup(pcFriendlyname);
01932         reader_list[reader_list_size-2].pcDevicename = strdup(pcDevicename);
01933         reader_list[reader_list_size-2].pcLibpath = strdup(pcLibpath),
01934         reader_list[reader_list_size-2].channelId = channelId;
01935 
01936         pcFriendlyname = NULL;
01937         pcDevicename = NULL;
01938         pcLibpath = NULL;
01939         pcChannelid = NULL;
01940     }
01941 
01942     return 0;
01943 }
01944 
01945 void tok_error(char *token_error)
01946 {
01947     Log4(PCSC_LOG_ERROR, "tok_error: invalid value line %d in %s: %s",
01948         iOldLinenumber, ConfFile, token_error);
01949     badError = 1;
01950 }
01951 
01952 int DBGetReaderListDir(const char *readerconf_dir,
01953     SerialReader **caller_reader_list)
01954 {
01955     DIR *dir;
01956     int ret = 0;
01957 
01958     /* (re)start with an empty list */
01959     reader_list = NULL;
01960     reader_list_size = 0;
01961 
01962     dir = opendir(readerconf_dir);
01963     if (dir)
01964     {
01965         /* the configuration file is a directory */
01966         struct dirent *direntry;
01967 
01968         /* for each configuration file */
01969         while ((direntry = readdir(dir)) != NULL)
01970         {
01971             char filename[FILENAME_MAX];
01972             int r;
01973 
01974             /* skip . and .. */
01975             if ((strcmp(direntry->d_name, ".") == 0) ||
01976                 (strcmp(direntry->d_name, "..") == 0))
01977                 continue;
01978 
01979             snprintf(filename, sizeof(filename), "%s/%s",
01980                 readerconf_dir, direntry->d_name);
01981 
01982             /* each call to DBGetReaderList() will append to the list */
01983             r = DBGetReaderList(filename, caller_reader_list);
01984 
01985             /* set the global return value to the latest error */
01986             if (r)
01987                 ret = r;
01988         }
01989 
01990         closedir(dir);
01991     }
01992     else
01993         /* the configuration file is really a file */
01994         ret = DBGetReaderList(readerconf_dir, caller_reader_list);
01995 
01996     return ret;
01997 }
01998 
01999 int DBGetReaderList(const char *readerconf, SerialReader **caller_reader_list)
02000 {
02001     FILE *configFile = NULL;
02002 
02003     *caller_reader_list = NULL; /* no list by default */
02004 
02005     /* used by tok_error() */
02006     ConfFile = readerconf;
02007 
02008     Log2(PCSC_LOG_DEBUG, "Parsing conf file: %s", ConfFile);
02009 
02010     configFile = fopen(readerconf, "r");
02011 
02012     if (configFile == NULL)
02013         return 1;
02014 
02015     yyin = configFile;
02016 
02017     /* (re)start with a clean state */
02018     iLinenumber = 1;
02019     iOldLinenumber = -1;
02020     pcFriendlyname = NULL;
02021     pcDevicename = NULL;
02022     pcLibpath = NULL;
02023     pcChannelid = NULL;
02024     pcPrevious = NULL;
02025     pcCurrent = NULL;
02026     badError = 0;
02027 
02028     do
02029     {
02030         (void)yylex();
02031     }
02032     while (!feof(configFile));
02033 
02034     (void)fclose(configFile);
02035 
02036     *caller_reader_list = reader_list;
02037 
02038     if (badError == 1)
02039         return -1;
02040     else
02041         return 0;
02042 } /* End of configfile.c */
02043 
02044