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