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

Generated on Fri Mar 24 04:30:06 2006 for pcsc-lite by  doxygen 1.4.6