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