Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

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

Generated on Wed Apr 2 13:59:22 2008 for pcsc-lite by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002