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

Generated on Mon Aug 17 01:00:11 2009 for pcsc-lite by  doxygen 1.5.9