1 #include "config.h" 2 3 #line 2 "<stdout>" 4 5 #define YY_INT_ALIGNED short int 6 7 /* A lexical scanner generated by flex */ 8 9 #define FLEX_SCANNER 10 #define YY_FLEX_MAJOR_VERSION 2 11 #define YY_FLEX_MINOR_VERSION 6 12 #define YY_FLEX_SUBMINOR_VERSION 4 13 #if YY_FLEX_SUBMINOR_VERSION > 0 14 #define FLEX_BETA 15 #endif 16 17 /* First, we deal with platform-specific or compiler-specific issues. */ 18 19 /* begin standard C headers. */ 20 #include <stdio.h> 21 #include <string.h> 22 #include <errno.h> 23 #include <stdlib.h> 24 25 /* end standard C headers. */ 26 27 /* flex integer type definitions */ 28 29 #ifndef FLEXINT_H 30 #define FLEXINT_H 31 32 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ 33 34 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 35 36 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, 37 * if you want the limit (max/min) macros for int types. 38 */ 39 #ifndef __STDC_LIMIT_MACROS 40 #define __STDC_LIMIT_MACROS 1 41 #endif 42 43 #include <inttypes.h> 44 typedef int8_t flex_int8_t; 45 typedef uint8_t flex_uint8_t; 46 typedef int16_t flex_int16_t; 47 typedef uint16_t flex_uint16_t; 48 typedef int32_t flex_int32_t; 49 typedef uint32_t flex_uint32_t; 50 #else 51 typedef signed char flex_int8_t; 52 typedef short int flex_int16_t; 53 typedef int flex_int32_t; 54 typedef unsigned char flex_uint8_t; 55 typedef unsigned short int flex_uint16_t; 56 typedef unsigned int flex_uint32_t; 57 58 /* Limits of integral types. */ 59 #ifndef INT8_MIN 60 #define INT8_MIN (-128) 61 #endif 62 #ifndef INT16_MIN 63 #define INT16_MIN (-32767-1) 64 #endif 65 #ifndef INT32_MIN 66 #define INT32_MIN (-2147483647-1) 67 #endif 68 #ifndef INT8_MAX 69 #define INT8_MAX (127) 70 #endif 71 #ifndef INT16_MAX 72 #define INT16_MAX (32767) 73 #endif 74 #ifndef INT32_MAX 75 #define INT32_MAX (2147483647) 76 #endif 77 #ifndef UINT8_MAX 78 #define UINT8_MAX (255U) 79 #endif 80 #ifndef UINT16_MAX 81 #define UINT16_MAX (65535U) 82 #endif 83 #ifndef UINT32_MAX 84 #define UINT32_MAX (4294967295U) 85 #endif 86 87 #ifndef SIZE_MAX 88 #define SIZE_MAX (~(size_t)0) 89 #endif 90 91 #endif /* ! C99 */ 92 93 #endif /* ! FLEXINT_H */ 94 95 /* begin standard C++ headers. */ 96 97 /* TODO: this is always defined, so inline it */ 98 #define yyconst const 99 100 #if defined(__GNUC__) && __GNUC__ >= 3 101 #define yynoreturn __attribute__((__noreturn__)) 102 #else 103 #define yynoreturn 104 #endif 105 106 /* Returned upon end-of-file. */ 107 #define YY_NULL 0 108 109 /* Promotes a possibly negative, possibly signed char to an 110 * integer in range [0..255] for use as an array index. 111 */ 112 #define YY_SC_TO_UI(c) ((YY_CHAR) (c)) 113 114 /* Enter a start condition. This macro really ought to take a parameter, 115 * but we do it the disgusting crufty way forced on us by the ()-less 116 * definition of BEGIN. 117 */ 118 #define BEGIN (yy_start) = 1 + 2 * 119 /* Translate the current start state into a value that can be later handed 120 * to BEGIN to return to the state. The YYSTATE alias is for lex 121 * compatibility. 122 */ 123 #define YY_START (((yy_start) - 1) / 2) 124 #define YYSTATE YY_START 125 /* Action number for EOF rule of a given start state. */ 126 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) 127 /* Special action meaning "start processing a new file". */ 128 #define YY_NEW_FILE yyrestart( yyin ) 129 #define YY_END_OF_BUFFER_CHAR 0 130 131 /* Size of default input buffer. */ 132 #ifndef YY_BUF_SIZE 133 #ifdef __ia64__ 134 /* On IA-64, the buffer size is 16k, not 8k. 135 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. 136 * Ditto for the __ia64__ case accordingly. 137 */ 138 #define YY_BUF_SIZE 32768 139 #else 140 #define YY_BUF_SIZE 16384 141 #endif /* __ia64__ */ 142 #endif 143 144 /* The state buf must be large enough to hold one state per character in the main buffer. 145 */ 146 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) 147 148 #ifndef YY_TYPEDEF_YY_BUFFER_STATE 149 #define YY_TYPEDEF_YY_BUFFER_STATE 150 typedef struct yy_buffer_state *YY_BUFFER_STATE; 151 #endif 152 153 #ifndef YY_TYPEDEF_YY_SIZE_T 154 #define YY_TYPEDEF_YY_SIZE_T 155 typedef size_t yy_size_t; 156 #endif 157 158 extern int yyleng; 159 160 extern FILE *yyin, *yyout; 161 162 #define EOB_ACT_CONTINUE_SCAN 0 163 #define EOB_ACT_END_OF_FILE 1 164 #define EOB_ACT_LAST_MATCH 2 165 166 #define YY_LESS_LINENO(n) 167 #define YY_LINENO_REWIND_TO(ptr) 168 169 /* Return all but the first "n" matched characters back to the input stream. */ 170 #define yyless(n) \ 171 do \ 172 { \ 173 /* Undo effects of setting up yytext. */ \ 174 int yyless_macro_arg = (n); \ 175 YY_LESS_LINENO(yyless_macro_arg);\ 176 *yy_cp = (yy_hold_char); \ 177 YY_RESTORE_YY_MORE_OFFSET \ 178 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ 179 YY_DO_BEFORE_ACTION; /* set up yytext again */ \ 180 } \ 181 while ( 0 ) 182 #define unput(c) yyunput( c, (yytext_ptr) ) 183 184 #ifndef YY_STRUCT_YY_BUFFER_STATE 185 #define YY_STRUCT_YY_BUFFER_STATE 186 struct yy_buffer_state 187 { 188 FILE *yy_input_file; 189 190 char *yy_ch_buf; /* input buffer */ 191 char *yy_buf_pos; /* current position in input buffer */ 192 193 /* Size of input buffer in bytes, not including room for EOB 194 * characters. 195 */ 196 int yy_buf_size; 197 198 /* Number of characters read into yy_ch_buf, not including EOB 199 * characters. 200 */ 201 int yy_n_chars; 202 203 /* Whether we "own" the buffer - i.e., we know we created it, 204 * and can realloc() it to grow it, and should free() it to 205 * delete it. 206 */ 207 int yy_is_our_buffer; 208 209 /* Whether this is an "interactive" input source; if so, and 210 * if we're using stdio for input, then we want to use getc() 211 * instead of fread(), to make sure we stop fetching input after 212 * each newline. 213 */ 214 int yy_is_interactive; 215 216 /* Whether we're considered to be at the beginning of a line. 217 * If so, '^' rules will be active on the next match, otherwise 218 * not. 219 */ 220 int yy_at_bol; 221 222 int yy_bs_lineno; /**< The line count. */ 223 int yy_bs_column; /**< The column count. */ 224 225 /* Whether to try to fill the input buffer when we reach the 226 * end of it. 227 */ 228 int yy_fill_buffer; 229 230 int yy_buffer_status; 231 232 #define YY_BUFFER_NEW 0 233 #define YY_BUFFER_NORMAL 1 234 /* When an EOF's been seen but there's still some text to process 235 * then we mark the buffer as YY_EOF_PENDING, to indicate that we 236 * shouldn't try reading from the input source any more. We might 237 * still have a bunch of tokens to match, though, because of 238 * possible backing-up. 239 * 240 * When we actually see the EOF, we change the status to "new" 241 * (via yyrestart()), so that the user can continue scanning by 242 * just pointing yyin at a new input file. 243 */ 244 #define YY_BUFFER_EOF_PENDING 2 245 246 }; 247 #endif /* !YY_STRUCT_YY_BUFFER_STATE */ 248 249 /* Stack of input buffers. */ 250 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ 251 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ 252 static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ 253 254 /* We provide macros for accessing buffer states in case in the 255 * future we want to put the buffer states in a more general 256 * "scanner state". 257 * 258 * Returns the top of the stack, or NULL. 259 */ 260 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ 261 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ 262 : NULL) 263 /* Same as previous macro, but useful when we know that the buffer stack is not 264 * NULL or when we need an lvalue. For internal use only. 265 */ 266 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] 267 268 /* yy_hold_char holds the character lost when yytext is formed. */ 269 static char yy_hold_char; 270 static int yy_n_chars; /* number of characters read into yy_ch_buf */ 271 int yyleng; 272 273 /* Points to current character in buffer. */ 274 static char *yy_c_buf_p = NULL; 275 static int yy_init = 0; /* whether we need to initialize */ 276 static int yy_start = 0; /* start state number */ 277 278 /* Flag which is used to allow yywrap()'s to do buffer switches 279 * instead of setting up a fresh yyin. A bit of a hack ... 280 */ 281 static int yy_did_buffer_switch_on_eof; 282 283 void yyrestart ( FILE *input_file ); 284 void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); 285 YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); 286 void yy_delete_buffer ( YY_BUFFER_STATE b ); 287 void yy_flush_buffer ( YY_BUFFER_STATE b ); 288 void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); 289 void yypop_buffer_state ( void ); 290 291 static void yyensure_buffer_stack ( void ); 292 static void yy_load_buffer_state ( void ); 293 static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); 294 #define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) 295 296 YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); 297 YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); 298 YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); 299 300 void *yyalloc ( yy_size_t ); 301 void *yyrealloc ( void *, yy_size_t ); 302 void yyfree ( void * ); 303 304 #define yy_new_buffer yy_create_buffer 305 #define yy_set_interactive(is_interactive) \ 306 { \ 307 if ( ! YY_CURRENT_BUFFER ){ \ 308 yyensure_buffer_stack (); \ 309 YY_CURRENT_BUFFER_LVALUE = \ 310 yy_create_buffer( yyin, YY_BUF_SIZE ); \ 311 } \ 312 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ 313 } 314 #define yy_set_bol(at_bol) \ 315 { \ 316 if ( ! YY_CURRENT_BUFFER ){\ 317 yyensure_buffer_stack (); \ 318 YY_CURRENT_BUFFER_LVALUE = \ 319 yy_create_buffer( yyin, YY_BUF_SIZE ); \ 320 } \ 321 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ 322 } 323 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) 324 325 /* Begin user sect3 */ 326 typedef flex_uint8_t YY_CHAR; 327 328 FILE *yyin = NULL, *yyout = NULL; 329 330 typedef int yy_state_type; 331 332 extern int yylineno; 333 int yylineno = 1; 334 335 extern char *yytext; 336 #ifdef yytext_ptr 337 #undef yytext_ptr 338 #endif 339 #define yytext_ptr yytext 340 341 static yy_state_type yy_get_previous_state ( void ); 342 static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); 343 static int yy_get_next_buffer ( void ); 344 static void yynoreturn yy_fatal_error ( const char* msg ); 345 346 /* Done after the current pattern has been matched and before the 347 * corresponding action - sets up yytext. 348 */ 349 #define YY_DO_BEFORE_ACTION \ 350 (yytext_ptr) = yy_bp; \ 351 (yytext_ptr) -= (yy_more_len); \ 352 yyleng = (int) (yy_cp - (yytext_ptr)); \ 353 (yy_hold_char) = *yy_cp; \ 354 *yy_cp = '\0'; \ 355 (yy_c_buf_p) = yy_cp; 356 #define YY_NUM_RULES 26 357 #define YY_END_OF_BUFFER 27 358 /* This struct is not used in this scanner, 359 but its presence is necessary. */ 360 struct yy_trans_info 361 { 362 flex_int32_t yy_verify; 363 flex_int32_t yy_nxt; 364 }; 365 static const flex_int16_t yy_accept[74] = 366 { 0, 367 0, 0, 0, 0, 16, 16, 20, 20, 27, 24, 368 14, 11, 11, 19, 25, 12, 13, 8, 1, 9, 369 24, 25, 6, 5, 16, 17, 16, 18, 20, 21, 370 23, 26, 24, 24, 14, 1, 1, 24, 24, 10, 371 15, 24, 7, 7, 7, 7, 6, 16, 16, 16, 372 16, 20, 0, 22, 0, 24, 24, 7, 7, 7, 373 22, 0, 7, 7, 2, 7, 7, 7, 7, 7, 374 3, 4, 0 375 } ; 376 377 static const YY_CHAR yy_ec[256] = 378 { 0, 379 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 380 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 381 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 382 1, 2, 1, 5, 6, 7, 1, 1, 1, 8, 383 9, 1, 1, 1, 1, 10, 1, 1, 1, 1, 384 1, 1, 1, 1, 1, 1, 1, 1, 11, 1, 385 1, 1, 1, 12, 13, 13, 14, 15, 16, 13, 386 17, 13, 18, 13, 13, 19, 13, 20, 21, 13, 387 13, 22, 13, 23, 24, 13, 13, 13, 13, 13, 388 25, 26, 27, 1, 1, 1, 13, 13, 28, 29, 389 390 30, 13, 31, 13, 32, 13, 13, 33, 13, 34, 391 35, 13, 13, 36, 13, 37, 38, 13, 13, 13, 392 13, 13, 1, 1, 1, 1, 1, 1, 1, 1, 393 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 394 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 395 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 396 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 397 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 398 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 399 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 400 401 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 402 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 403 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 405 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 406 1, 1, 1, 1, 1 407 } ; 408 409 static const YY_CHAR yy_meta[39] = 410 { 0, 411 1, 2, 3, 4, 5, 1, 1, 4, 4, 4, 412 4, 1, 6, 6, 6, 6, 6, 6, 6, 6, 413 6, 6, 6, 6, 1, 1, 7, 6, 6, 6, 414 6, 6, 6, 6, 6, 6, 6, 6 415 } ; 416 417 static const flex_int16_t yy_base[89] = 418 { 0, 419 0, 25, 124, 123, 12, 14, 16, 17, 125, 94, 420 12, 244, 244, 244, 244, 244, 244, 244, 0, 93, 421 50, 59, 0, 244, 92, 244, 18, 244, 91, 244, 422 87, 107, 85, 95, 14, 0, 0, 84, 82, 81, 423 66, 120, 0, 28, 27, 27, 0, 64, 20, 63, 424 39, 59, 79, 57, 65, 42, 0, 41, 39, 53, 425 5, 76, 54, 57, 0, 55, 77, 85, 81, 86, 426 0, 0, 244, 146, 153, 160, 167, 174, 181, 188, 427 0, 195, 202, 208, 215, 222, 229, 236 428 } ; 429 430 static const flex_int16_t yy_def[89] = 431 { 0, 432 74, 74, 75, 75, 76, 76, 77, 77, 73, 78, 433 73, 73, 73, 73, 73, 73, 73, 73, 79, 78, 434 80, 81, 82, 73, 83, 73, 84, 73, 85, 73, 435 86, 85, 78, 87, 73, 79, 79, 78, 78, 78, 436 78, 87, 81, 81, 81, 81, 82, 83, 84, 83, 437 84, 85, 85, 88, 86, 78, 42, 81, 81, 81, 438 88, 88, 81, 81, 81, 81, 81, 81, 81, 81, 439 81, 81, 0, 73, 73, 73, 73, 73, 73, 73, 440 73, 73, 73, 73, 73, 73, 73, 73 441 } ; 442 443 static const flex_int16_t yy_nxt[283] = 444 { 0, 445 73, 11, 12, 13, 14, 43, 15, 16, 17, 18, 446 19, 20, 73, 35, 26, 35, 26, 73, 30, 30, 447 31, 31, 36, 73, 36, 21, 11, 12, 13, 14, 448 62, 22, 16, 17, 18, 19, 20, 27, 28, 27, 449 28, 32, 32, 51, 48, 51, 48, 58, 59, 60, 450 21, 39, 39, 39, 63, 40, 64, 39, 39, 39, 451 39, 58, 59, 60, 51, 48, 54, 34, 63, 54, 452 64, 65, 66, 67, 41, 42, 44, 61, 68, 45, 453 61, 46, 62, 52, 53, 65, 66, 67, 49, 49, 454 44, 34, 68, 45, 69, 46, 33, 33, 33, 70, 455 456 71, 72, 33, 33, 33, 33, 34, 34, 69, 34, 457 34, 52, 55, 70, 71, 72, 53, 49, 34, 34, 458 57, 33, 33, 33, 73, 24, 24, 33, 33, 33, 459 33, 73, 73, 73, 73, 73, 73, 73, 73, 73, 460 73, 73, 73, 73, 73, 57, 10, 10, 10, 10, 461 10, 10, 10, 23, 23, 23, 23, 23, 23, 23, 462 25, 25, 25, 25, 25, 25, 25, 29, 29, 29, 463 29, 29, 29, 29, 33, 73, 73, 73, 33, 33, 464 33, 37, 37, 73, 37, 37, 37, 37, 38, 38, 465 38, 38, 38, 38, 38, 47, 47, 73, 47, 47, 466 467 47, 47, 48, 48, 73, 48, 48, 48, 50, 50, 468 73, 50, 50, 50, 50, 52, 52, 73, 52, 73, 469 52, 52, 54, 73, 73, 54, 73, 54, 54, 56, 470 56, 56, 56, 56, 56, 56, 61, 73, 73, 61, 471 73, 61, 61, 9, 73, 73, 73, 73, 73, 73, 472 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 473 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 474 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 475 73, 73 476 } ; 477 478 static const flex_int16_t yy_chk[283] = 479 { 0, 480 0, 1, 1, 1, 1, 81, 1, 1, 1, 1, 481 1, 1, 0, 11, 5, 35, 6, 0, 7, 8, 482 7, 8, 11, 0, 35, 1, 2, 2, 2, 2, 483 61, 2, 2, 2, 2, 2, 2, 5, 5, 6, 484 6, 7, 8, 27, 27, 49, 49, 44, 45, 46, 485 2, 21, 21, 21, 58, 21, 59, 21, 21, 21, 486 21, 44, 45, 46, 51, 51, 55, 56, 58, 55, 487 59, 60, 63, 64, 21, 21, 22, 62, 66, 22, 488 62, 22, 54, 53, 52, 60, 63, 64, 50, 48, 489 22, 41, 66, 22, 67, 22, 34, 34, 34, 68, 490 491 69, 70, 34, 34, 34, 34, 40, 39, 67, 38, 492 33, 32, 31, 68, 69, 70, 29, 25, 20, 10, 493 34, 42, 42, 42, 9, 4, 3, 42, 42, 42, 494 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 495 0, 0, 0, 0, 0, 42, 74, 74, 74, 74, 496 74, 74, 74, 75, 75, 75, 75, 75, 75, 75, 497 76, 76, 76, 76, 76, 76, 76, 77, 77, 77, 498 77, 77, 77, 77, 78, 0, 0, 0, 78, 78, 499 78, 79, 79, 0, 79, 79, 79, 79, 80, 80, 500 80, 80, 80, 80, 80, 82, 82, 0, 82, 82, 501 502 82, 82, 83, 83, 0, 83, 83, 83, 84, 84, 503 0, 84, 84, 84, 84, 85, 85, 0, 85, 0, 504 85, 85, 86, 0, 0, 86, 0, 86, 86, 87, 505 87, 87, 87, 87, 87, 87, 88, 0, 0, 88, 506 0, 88, 88, 73, 73, 73, 73, 73, 73, 73, 507 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 508 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 509 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 510 73, 73 511 } ; 512 513 static yy_state_type yy_last_accepting_state; 514 static char *yy_last_accepting_cpos; 515 516 extern int yy_flex_debug; 517 int yy_flex_debug = 0; 518 519 /* The intent behind this definition is that it'll catch 520 * any uses of REJECT which flex missed. 521 */ 522 #define REJECT reject_used_but_not_detected 523 static int yy_more_flag = 0; 524 static int yy_more_len = 0; 525 #define yymore() ((yy_more_flag) = 1) 526 #define YY_MORE_ADJ (yy_more_len) 527 #define YY_RESTORE_YY_MORE_OFFSET 528 char *yytext; 529 #line 1 "zlexer.lex" 530 #line 2 "zlexer.lex" 531 /* 532 * zlexer.lex - lexical analyzer for (DNS) zone files 533 * 534 * Copyright (c) 2001-2006, NLnet Labs. All rights reserved 535 * 536 * See LICENSE for the license. 537 * 538 */ 539 /* because flex keeps having sign-unsigned compare problems that are unfixed*/ 540 #if defined(__clang__)||(defined(__GNUC__)&&((__GNUC__ >4)||(defined(__GNUC_MINOR__)&&(__GNUC__ ==4)&&(__GNUC_MINOR__ >=2)))) 541 #pragma GCC diagnostic ignored "-Wsign-compare" 542 #endif 543 /* ignore fallthrough warnings in the generated parse code case statements */ 544 #if defined(__clang__)||(defined(__GNUC__)&&(__GNUC__ >=7)) 545 #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" 546 #endif 547 548 #include "config.h" 549 550 #include <ctype.h> 551 #include <errno.h> 552 #include <string.h> 553 #include <strings.h> 554 555 #include "zonec.h" 556 #include "dname.h" 557 #include "zparser.h" 558 559 #if 0 560 #define LEXOUT(s) printf s /* used ONLY when debugging */ 561 #else 562 #define LEXOUT(s) 563 #endif 564 565 enum lexer_state { 566 EXPECT_OWNER, 567 PARSING_OWNER, 568 PARSING_TTL_CLASS_TYPE, 569 PARSING_RDATA 570 }; 571 572 static int parse_token(int token, char *yytext, enum lexer_state *lexer_state); 573 574 static YY_BUFFER_STATE include_stack[MAXINCLUDES]; 575 static zparser_type zparser_stack[MAXINCLUDES]; 576 static int include_stack_ptr = 0; 577 578 /* 579 * Saves the file specific variables on the include stack. 580 */ 581 static void 582 push_parser_state(FILE *input) 583 { 584 zparser_stack[include_stack_ptr].filename = parser->filename; 585 zparser_stack[include_stack_ptr].line = parser->line; 586 zparser_stack[include_stack_ptr].origin = parser->origin; 587 include_stack[include_stack_ptr] = YY_CURRENT_BUFFER; 588 yy_switch_to_buffer(yy_create_buffer(input, YY_BUF_SIZE)); 589 ++include_stack_ptr; 590 } 591 592 /* 593 * Restores the file specific variables from the include stack. 594 */ 595 static void 596 pop_parser_state(void) 597 { 598 if (parser->filename) 599 region_recycle(parser->region, (void *)parser->filename, 600 strlen(parser->filename)+1); 601 602 --include_stack_ptr; 603 parser->filename = zparser_stack[include_stack_ptr].filename; 604 parser->line = zparser_stack[include_stack_ptr].line; 605 parser->origin = zparser_stack[include_stack_ptr].origin; 606 yy_delete_buffer(YY_CURRENT_BUFFER); 607 yy_switch_to_buffer(include_stack[include_stack_ptr]); 608 } 609 610 static YY_BUFFER_STATE oldstate; 611 /* Start string scan */ 612 void 613 parser_push_stringbuf(char* str) 614 { 615 oldstate = YY_CURRENT_BUFFER; 616 yy_switch_to_buffer(yy_scan_string(str)); 617 } 618 619 void 620 parser_pop_stringbuf(void) 621 { 622 yy_delete_buffer(YY_CURRENT_BUFFER); 623 yy_switch_to_buffer(oldstate); 624 oldstate = NULL; 625 } 626 627 static int paren_open = 0; 628 static enum lexer_state lexer_state = EXPECT_OWNER; 629 void 630 parser_flush(void) 631 { 632 YY_FLUSH_BUFFER; 633 paren_open = 0; 634 lexer_state = EXPECT_OWNER; 635 } 636 637 #ifndef yy_set_bol /* compat definition, for flex 2.4.6 */ 638 #define yy_set_bol(at_bol) \ 639 { \ 640 if ( ! yy_current_buffer ) \ 641 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ 642 yy_current_buffer->yy_ch_buf[0] = ((at_bol)?'\n':' '); \ 643 } 644 #endif 645 646 #line 645 "<stdout>" 647 #define YY_NO_INPUT 1 648 #line 121 "zlexer.lex" 649 #ifndef YY_NO_UNPUT 650 #define YY_NO_UNPUT 1 651 #endif 652 #ifndef YY_NO_INPUT 653 #define YY_NO_INPUT 1 654 #endif 655 #line 654 "<stdout>" 656 657 #line 656 "<stdout>" 658 659 #define INITIAL 0 660 #define incl 1 661 #define bitlabel 2 662 #define quotedstring 3 663 664 #ifndef YY_NO_UNISTD_H 665 /* Special case for "unistd.h", since it is non-ANSI. We include it way 666 * down here because we want the user's section 1 to have been scanned first. 667 * The user has a chance to override it with an option. 668 */ 669 #include <unistd.h> 670 #endif 671 672 #ifndef YY_EXTRA_TYPE 673 #define YY_EXTRA_TYPE void * 674 #endif 675 676 static int yy_init_globals ( void ); 677 678 /* Accessor methods to globals. 679 These are made visible to non-reentrant scanners for convenience. */ 680 681 int yylex_destroy ( void ); 682 683 int yyget_debug ( void ); 684 685 void yyset_debug ( int debug_flag ); 686 687 YY_EXTRA_TYPE yyget_extra ( void ); 688 689 void yyset_extra ( YY_EXTRA_TYPE user_defined ); 690 691 FILE *yyget_in ( void ); 692 693 void yyset_in ( FILE * _in_str ); 694 695 FILE *yyget_out ( void ); 696 697 void yyset_out ( FILE * _out_str ); 698 699 int yyget_leng ( void ); 700 701 char *yyget_text ( void ); 702 703 int yyget_lineno ( void ); 704 705 void yyset_lineno ( int _line_number ); 706 707 /* Macros after this point can all be overridden by user definitions in 708 * section 1. 709 */ 710 711 #ifndef YY_SKIP_YYWRAP 712 #ifdef __cplusplus 713 extern "C" int yywrap ( void ); 714 #else 715 extern int yywrap ( void ); 716 #endif 717 #endif 718 719 #ifndef YY_NO_UNPUT 720 721 #endif 722 723 #ifndef yytext_ptr 724 static void yy_flex_strncpy ( char *, const char *, int ); 725 #endif 726 727 #ifdef YY_NEED_STRLEN 728 static int yy_flex_strlen ( const char * ); 729 #endif 730 731 #ifndef YY_NO_INPUT 732 #ifdef __cplusplus 733 static int yyinput ( void ); 734 #else 735 static int input ( void ); 736 #endif 737 738 #endif 739 740 /* Amount of stuff to slurp up with each read. */ 741 #ifndef YY_READ_BUF_SIZE 742 #ifdef __ia64__ 743 /* On IA-64, the buffer size is 16k, not 8k */ 744 #define YY_READ_BUF_SIZE 16384 745 #else 746 #define YY_READ_BUF_SIZE 8192 747 #endif /* __ia64__ */ 748 #endif 749 750 /* Copy whatever the last rule matched to the standard output. */ 751 #ifndef ECHO 752 /* This used to be an fputs(), but since the string might contain NUL's, 753 * we now use fwrite(). 754 */ 755 #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) 756 #endif 757 758 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, 759 * is returned in "result". 760 */ 761 #ifndef YY_INPUT 762 #define YY_INPUT(buf,result,max_size) \ 763 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ 764 { \ 765 int c = '*'; \ 766 int n; \ 767 for ( n = 0; n < max_size && \ 768 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ 769 buf[n] = (char) c; \ 770 if ( c == '\n' ) \ 771 buf[n++] = (char) c; \ 772 if ( c == EOF && ferror( yyin ) ) \ 773 YY_FATAL_ERROR( "input in flex scanner failed" ); \ 774 result = n; \ 775 } \ 776 else \ 777 { \ 778 errno=0; \ 779 while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ 780 { \ 781 if( errno != EINTR) \ 782 { \ 783 YY_FATAL_ERROR( "input in flex scanner failed" ); \ 784 break; \ 785 } \ 786 errno=0; \ 787 clearerr(yyin); \ 788 } \ 789 }\ 790 \ 791 792 #endif 793 794 /* No semi-colon after return; correct usage is to write "yyterminate();" - 795 * we don't want an extra ';' after the "return" because that will cause 796 * some compilers to complain about unreachable statements. 797 */ 798 #ifndef yyterminate 799 #define yyterminate() return YY_NULL 800 #endif 801 802 /* Number of entries by which start-condition stack grows. */ 803 #ifndef YY_START_STACK_INCR 804 #define YY_START_STACK_INCR 25 805 #endif 806 807 /* Report a fatal error. */ 808 #ifndef YY_FATAL_ERROR 809 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) 810 #endif 811 812 /* end tables serialization structures and prototypes */ 813 814 /* Default declaration of generated scanner - a define so the user can 815 * easily add parameters. 816 */ 817 #ifndef YY_DECL 818 #define YY_DECL_IS_OURS 1 819 820 extern int yylex (void); 821 822 #define YY_DECL int yylex (void) 823 #endif /* !YY_DECL */ 824 825 /* Code executed at the beginning of each rule, after yytext and yyleng 826 * have been set up. 827 */ 828 #ifndef YY_USER_ACTION 829 #define YY_USER_ACTION 830 #endif 831 832 /* Code executed at the end of each rule. */ 833 #ifndef YY_BREAK 834 #define YY_BREAK /*LINTED*/break; 835 #endif 836 837 #define YY_RULE_SETUP \ 838 if ( yyleng > 0 ) \ 839 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ 840 (yytext[yyleng - 1] == '\n'); \ 841 YY_USER_ACTION 842 843 /** The main scanner function which does all the work. 844 */ 845 YY_DECL 846 { 847 yy_state_type yy_current_state; 848 char *yy_cp, *yy_bp; 849 int yy_act; 850 851 if ( !(yy_init) ) 852 { 853 (yy_init) = 1; 854 855 #ifdef YY_USER_INIT 856 YY_USER_INIT; 857 #endif 858 859 if ( ! (yy_start) ) 860 (yy_start) = 1; /* first start state */ 861 862 if ( ! yyin ) 863 yyin = stdin; 864 865 if ( ! yyout ) 866 yyout = stdout; 867 868 if ( ! YY_CURRENT_BUFFER ) { 869 yyensure_buffer_stack (); 870 YY_CURRENT_BUFFER_LVALUE = 871 yy_create_buffer( yyin, YY_BUF_SIZE ); 872 } 873 874 yy_load_buffer_state( ); 875 } 876 877 { 878 #line 144 "zlexer.lex" 879 880 #line 879 "<stdout>" 881 882 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ 883 { 884 (yy_more_len) = 0; 885 if ( (yy_more_flag) ) 886 { 887 (yy_more_len) = (int) ((yy_c_buf_p) - (yytext_ptr)); 888 (yy_more_flag) = 0; 889 } 890 yy_cp = (yy_c_buf_p); 891 892 /* Support of yytext. */ 893 *yy_cp = (yy_hold_char); 894 895 /* yy_bp points to the position in yy_ch_buf of the start of 896 * the current run. 897 */ 898 yy_bp = yy_cp; 899 900 yy_current_state = (yy_start); 901 yy_current_state += YY_AT_BOL(); 902 yy_match: 903 do 904 { 905 YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; 906 if ( yy_accept[yy_current_state] ) 907 { 908 (yy_last_accepting_state) = yy_current_state; 909 (yy_last_accepting_cpos) = yy_cp; 910 } 911 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 912 { 913 yy_current_state = (int) yy_def[yy_current_state]; 914 if ( yy_current_state >= 74 ) 915 yy_c = yy_meta[yy_c]; 916 } 917 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; 918 ++yy_cp; 919 } 920 while ( yy_base[yy_current_state] != 244 ); 921 922 yy_find_action: 923 yy_act = yy_accept[yy_current_state]; 924 if ( yy_act == 0 ) 925 { /* have to back up */ 926 yy_cp = (yy_last_accepting_cpos); 927 yy_current_state = (yy_last_accepting_state); 928 yy_act = yy_accept[yy_current_state]; 929 } 930 931 YY_DO_BEFORE_ACTION; 932 933 do_action: /* This label is used only to access EOF actions. */ 934 935 switch ( yy_act ) 936 { /* beginning of action switch */ 937 case 0: /* must back up */ 938 /* undo the effects of YY_DO_BEFORE_ACTION */ 939 *yy_cp = (yy_hold_char); 940 yy_cp = (yy_last_accepting_cpos); 941 yy_current_state = (yy_last_accepting_state); 942 goto yy_find_action; 943 944 case 1: 945 YY_RULE_SETUP 946 #line 145 "zlexer.lex" 947 /* ignore */ 948 YY_BREAK 949 case 2: 950 YY_RULE_SETUP 951 #line 146 "zlexer.lex" 952 { lexer_state = PARSING_RDATA; return DOLLAR_TTL; } 953 YY_BREAK 954 case 3: 955 YY_RULE_SETUP 956 #line 147 "zlexer.lex" 957 { lexer_state = PARSING_RDATA; return DOLLAR_ORIGIN; } 958 YY_BREAK 959 /* 960 * Handle $INCLUDE directives. See 961 * http://dinosaur.compilertools.net/flex/flex_12.html#SEC12. 962 */ 963 case 4: 964 YY_RULE_SETUP 965 #line 153 "zlexer.lex" 966 { 967 BEGIN(incl); 968 /* ignore case statement fallthrough on incl<EOF> flex rule */ 969 } 970 YY_BREAK 971 case 5: 972 /* rule 5 can match eol */ 973 #line 158 "zlexer.lex" 974 YY_RULE_SETUP 975 case YY_STATE_EOF(incl): 976 #line 158 "zlexer.lex" 977 { 978 int error_occurred = parser->error_occurred; 979 BEGIN(INITIAL); 980 zc_error("missing file name in $INCLUDE directive"); 981 yy_set_bol(1); /* Set beginning of line, so "^" rules match. */ 982 ++parser->line; 983 parser->error_occurred = error_occurred; 984 } 985 YY_BREAK 986 case 6: 987 YY_RULE_SETUP 988 #line 166 "zlexer.lex" 989 { 990 char *tmp; 991 domain_type *origin = parser->origin; 992 int error_occurred = parser->error_occurred; 993 994 BEGIN(INITIAL); 995 if (include_stack_ptr >= MAXINCLUDES ) { 996 zc_error("includes nested too deeply, skipped (>%d)", 997 MAXINCLUDES); 998 } else { 999 FILE *input; 1000 1001 /* Remove trailing comment. */ 1002 tmp = strrchr(yytext, ';'); 1003 if (tmp) { 1004 *tmp = '\0'; 1005 } 1006 strip_string(yytext); 1007 1008 /* Parse origin for include file. */ 1009 tmp = strrchr(yytext, ' '); 1010 if (!tmp) { 1011 tmp = strrchr(yytext, '\t'); 1012 } 1013 if (tmp) { 1014 const dname_type *dname; 1015 1016 /* split the original yytext */ 1017 *tmp = '\0'; 1018 strip_string(yytext); 1019 1020 dname = dname_parse(parser->region, tmp + 1); 1021 if (!dname) { 1022 zc_error("incorrect include origin '%s'", 1023 tmp + 1); 1024 } else if (*(tmp + strlen(tmp + 1)) != '.') { 1025 zc_error("$INCLUDE directive requires absolute domain name"); 1026 } else { 1027 origin = domain_table_insert( 1028 parser->db->domains, dname); 1029 } 1030 } 1031 1032 if (strlen(yytext) == 0) { 1033 zc_error("missing file name in $INCLUDE directive"); 1034 } else if (!(input = fopen(yytext, "r"))) { 1035 zc_error("cannot open include file '%s': %s", 1036 yytext, strerror(errno)); 1037 } else { 1038 /* Initialize parser for include file. */ 1039 char *filename = region_strdup(parser->region, yytext); 1040 push_parser_state(input); /* Destroys yytext. */ 1041 parser->filename = filename; 1042 parser->line = 1; 1043 parser->origin = origin; 1044 lexer_state = EXPECT_OWNER; 1045 } 1046 } 1047 1048 parser->error_occurred = error_occurred; 1049 } 1050 YY_BREAK 1051 case YY_STATE_EOF(INITIAL): 1052 #line 227 "zlexer.lex" 1053 { 1054 yy_set_bol(1); /* Set beginning of line, so "^" rules match. */ 1055 if (include_stack_ptr == 0) { 1056 yyterminate(); 1057 } else { 1058 fclose(yyin); 1059 pop_parser_state(); 1060 } 1061 } 1062 YY_BREAK 1063 case 7: 1064 YY_RULE_SETUP 1065 #line 236 "zlexer.lex" 1066 { zc_warning("Unknown directive: %s", yytext); } 1067 YY_BREAK 1068 case 8: 1069 YY_RULE_SETUP 1070 #line 237 "zlexer.lex" 1071 { 1072 LEXOUT((". ")); 1073 return parse_token('.', yytext, &lexer_state); 1074 } 1075 YY_BREAK 1076 case 9: 1077 YY_RULE_SETUP 1078 #line 241 "zlexer.lex" 1079 { 1080 LEXOUT(("@ ")); 1081 return parse_token('@', yytext, &lexer_state); 1082 } 1083 YY_BREAK 1084 case 10: 1085 YY_RULE_SETUP 1086 #line 245 "zlexer.lex" 1087 { 1088 LEXOUT(("\\# ")); 1089 return parse_token(URR, yytext, &lexer_state); 1090 } 1091 YY_BREAK 1092 case 11: 1093 /* rule 11 can match eol */ 1094 YY_RULE_SETUP 1095 #line 249 "zlexer.lex" 1096 { 1097 ++parser->line; 1098 if (!paren_open) { 1099 lexer_state = EXPECT_OWNER; 1100 LEXOUT(("NL\n")); 1101 return NL; 1102 } else { 1103 LEXOUT(("SP ")); 1104 return SP; 1105 } 1106 } 1107 YY_BREAK 1108 case 12: 1109 YY_RULE_SETUP 1110 #line 260 "zlexer.lex" 1111 { 1112 if (paren_open) { 1113 zc_error("nested parentheses"); 1114 yyterminate(); 1115 } 1116 LEXOUT(("( ")); 1117 paren_open = 1; 1118 return SP; 1119 } 1120 YY_BREAK 1121 case 13: 1122 YY_RULE_SETUP 1123 #line 269 "zlexer.lex" 1124 { 1125 if (!paren_open) { 1126 zc_error("closing parentheses without opening parentheses"); 1127 yyterminate(); 1128 } 1129 LEXOUT((") ")); 1130 paren_open = 0; 1131 return SP; 1132 } 1133 YY_BREAK 1134 case 14: 1135 YY_RULE_SETUP 1136 #line 278 "zlexer.lex" 1137 { 1138 if (!paren_open && lexer_state == EXPECT_OWNER) { 1139 lexer_state = PARSING_TTL_CLASS_TYPE; 1140 LEXOUT(("PREV ")); 1141 return PREV; 1142 } 1143 if (lexer_state == PARSING_OWNER) { 1144 lexer_state = PARSING_TTL_CLASS_TYPE; 1145 } 1146 LEXOUT(("SP ")); 1147 return SP; 1148 } 1149 YY_BREAK 1150 /* Bitlabels. Strip leading and ending brackets. */ 1151 case 15: 1152 YY_RULE_SETUP 1153 #line 292 "zlexer.lex" 1154 { BEGIN(bitlabel); } 1155 YY_BREAK 1156 case YY_STATE_EOF(bitlabel): 1157 #line 293 "zlexer.lex" 1158 { 1159 zc_error("EOF inside bitlabel"); 1160 BEGIN(INITIAL); 1161 yyrestart(yyin); /* this is so that lex does not give an internal err */ 1162 yyterminate(); 1163 } 1164 YY_BREAK 1165 case 16: 1166 YY_RULE_SETUP 1167 #line 299 "zlexer.lex" 1168 { yymore(); } 1169 YY_BREAK 1170 case 17: 1171 /* rule 17 can match eol */ 1172 YY_RULE_SETUP 1173 #line 300 "zlexer.lex" 1174 { ++parser->line; yymore(); } 1175 YY_BREAK 1176 case 18: 1177 YY_RULE_SETUP 1178 #line 301 "zlexer.lex" 1179 { 1180 BEGIN(INITIAL); 1181 yytext[yyleng - 1] = '\0'; 1182 return parse_token(BITLAB, yytext, &lexer_state); 1183 } 1184 YY_BREAK 1185 /* Quoted strings. Strip leading and ending quotes. */ 1186 case 19: 1187 YY_RULE_SETUP 1188 #line 308 "zlexer.lex" 1189 { BEGIN(quotedstring); LEXOUT(("\" ")); } 1190 YY_BREAK 1191 case YY_STATE_EOF(quotedstring): 1192 #line 309 "zlexer.lex" 1193 { 1194 zc_error("EOF inside quoted string"); 1195 BEGIN(INITIAL); 1196 yyrestart(yyin); /* this is so that lex does not give an internal err */ 1197 yyterminate(); 1198 } 1199 YY_BREAK 1200 case 20: 1201 YY_RULE_SETUP 1202 #line 315 "zlexer.lex" 1203 { LEXOUT(("STR ")); yymore(); } 1204 YY_BREAK 1205 case 21: 1206 /* rule 21 can match eol */ 1207 YY_RULE_SETUP 1208 #line 316 "zlexer.lex" 1209 { ++parser->line; yymore(); } 1210 YY_BREAK 1211 case 22: 1212 YY_RULE_SETUP 1213 #line 317 "zlexer.lex" 1214 { 1215 /* for strings like "abc"def */ 1216 char* qt; 1217 LEXOUT(("\" ")); 1218 BEGIN(INITIAL); 1219 for(qt=yytext; *qt!=0; qt++) { 1220 if(qt[0]=='"') { 1221 /* (unescaped) character is quote */ 1222 break; 1223 } 1224 if(qt[0] == '\\' && qt[1] == '\\') { 1225 /* escaped backslash, skip that backslash */ 1226 qt+=1; 1227 continue; 1228 } 1229 if(qt[0] == '\\' && qt[1] == '"') { 1230 /* escaped quote, skip that quote */ 1231 qt+=1; 1232 continue; 1233 } 1234 } 1235 assert(qt); 1236 assert(*qt=='"'); 1237 /* remove middle quote */ 1238 if(qt[1] != 0) 1239 memmove(qt, qt+1, strlen(qt+1)); 1240 yytext[yyleng - 1] = '\0'; 1241 return parse_token(STR, yytext, &lexer_state); 1242 } 1243 YY_BREAK 1244 case 23: 1245 YY_RULE_SETUP 1246 #line 346 "zlexer.lex" 1247 { 1248 LEXOUT(("\" ")); 1249 BEGIN(INITIAL); 1250 yytext[yyleng - 1] = '\0'; 1251 return parse_token(STR, yytext, &lexer_state); 1252 } 1253 YY_BREAK 1254 case 24: 1255 /* rule 24 can match eol */ 1256 YY_RULE_SETUP 1257 #line 353 "zlexer.lex" 1258 { 1259 /* Any allowed word. */ 1260 return parse_token(STR, yytext, &lexer_state); 1261 } 1262 YY_BREAK 1263 case 25: 1264 YY_RULE_SETUP 1265 #line 357 "zlexer.lex" 1266 { 1267 zc_error("unknown character '%c' (\\%03d) seen - is this a zonefile?", 1268 (int) yytext[0], (int) yytext[0]); 1269 } 1270 YY_BREAK 1271 case 26: 1272 YY_RULE_SETUP 1273 #line 361 "zlexer.lex" 1274 ECHO; 1275 YY_BREAK 1276 #line 1275 "<stdout>" 1277 1278 case YY_END_OF_BUFFER: 1279 { 1280 /* Amount of text matched not including the EOB char. */ 1281 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; 1282 1283 /* Undo the effects of YY_DO_BEFORE_ACTION. */ 1284 *yy_cp = (yy_hold_char); 1285 YY_RESTORE_YY_MORE_OFFSET 1286 1287 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) 1288 { 1289 /* We're scanning a new file or input source. It's 1290 * possible that this happened because the user 1291 * just pointed yyin at a new source and called 1292 * yylex(). If so, then we have to assure 1293 * consistency between YY_CURRENT_BUFFER and our 1294 * globals. Here is the right place to do so, because 1295 * this is the first action (other than possibly a 1296 * back-up) that will match for the new input source. 1297 */ 1298 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 1299 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; 1300 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; 1301 } 1302 1303 /* Note that here we test for yy_c_buf_p "<=" to the position 1304 * of the first EOB in the buffer, since yy_c_buf_p will 1305 * already have been incremented past the NUL character 1306 * (since all states make transitions on EOB to the 1307 * end-of-buffer state). Contrast this with the test 1308 * in input(). 1309 */ 1310 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) 1311 { /* This was really a NUL. */ 1312 yy_state_type yy_next_state; 1313 1314 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; 1315 1316 yy_current_state = yy_get_previous_state( ); 1317 1318 /* Okay, we're now positioned to make the NUL 1319 * transition. We couldn't have 1320 * yy_get_previous_state() go ahead and do it 1321 * for us because it doesn't know how to deal 1322 * with the possibility of jamming (and we don't 1323 * want to build jamming into it because then it 1324 * will run more slowly). 1325 */ 1326 1327 yy_next_state = yy_try_NUL_trans( yy_current_state ); 1328 1329 yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1330 1331 if ( yy_next_state ) 1332 { 1333 /* Consume the NUL. */ 1334 yy_cp = ++(yy_c_buf_p); 1335 yy_current_state = yy_next_state; 1336 goto yy_match; 1337 } 1338 1339 else 1340 { 1341 yy_cp = (yy_c_buf_p); 1342 goto yy_find_action; 1343 } 1344 } 1345 1346 else switch ( yy_get_next_buffer( ) ) 1347 { 1348 case EOB_ACT_END_OF_FILE: 1349 { 1350 (yy_did_buffer_switch_on_eof) = 0; 1351 1352 if ( yywrap( ) ) 1353 { 1354 /* Note: because we've taken care in 1355 * yy_get_next_buffer() to have set up 1356 * yytext, we can now set up 1357 * yy_c_buf_p so that if some total 1358 * hoser (like flex itself) wants to 1359 * call the scanner after we return the 1360 * YY_NULL, it'll still work - another 1361 * YY_NULL will get returned. 1362 */ 1363 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; 1364 1365 yy_act = YY_STATE_EOF(YY_START); 1366 goto do_action; 1367 } 1368 1369 else 1370 { 1371 if ( ! (yy_did_buffer_switch_on_eof) ) 1372 YY_NEW_FILE; 1373 } 1374 break; 1375 } 1376 1377 case EOB_ACT_CONTINUE_SCAN: 1378 (yy_c_buf_p) = 1379 (yytext_ptr) + yy_amount_of_matched_text; 1380 1381 yy_current_state = yy_get_previous_state( ); 1382 1383 yy_cp = (yy_c_buf_p); 1384 yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1385 goto yy_match; 1386 1387 case EOB_ACT_LAST_MATCH: 1388 (yy_c_buf_p) = 1389 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; 1390 1391 yy_current_state = yy_get_previous_state( ); 1392 1393 yy_cp = (yy_c_buf_p); 1394 yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1395 goto yy_find_action; 1396 } 1397 break; 1398 } 1399 1400 default: 1401 YY_FATAL_ERROR( 1402 "fatal flex scanner internal error--no action found" ); 1403 } /* end of action switch */ 1404 } /* end of scanning one token */ 1405 } /* end of user's declarations */ 1406 } /* end of yylex */ 1407 1408 /* yy_get_next_buffer - try to read in a new buffer 1409 * 1410 * Returns a code representing an action: 1411 * EOB_ACT_LAST_MATCH - 1412 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position 1413 * EOB_ACT_END_OF_FILE - end of file 1414 */ 1415 static int yy_get_next_buffer (void) 1416 { 1417 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; 1418 char *source = (yytext_ptr); 1419 int number_to_move, i; 1420 int ret_val; 1421 1422 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) 1423 YY_FATAL_ERROR( 1424 "fatal flex scanner internal error--end of buffer missed" ); 1425 1426 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) 1427 { /* Don't try to fill the buffer, so this is an EOF. */ 1428 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) 1429 { 1430 /* We matched a single character, the EOB, so 1431 * treat this as a final EOF. 1432 */ 1433 return EOB_ACT_END_OF_FILE; 1434 } 1435 1436 else 1437 { 1438 /* We matched some text prior to the EOB, first 1439 * process it. 1440 */ 1441 return EOB_ACT_LAST_MATCH; 1442 } 1443 } 1444 1445 /* Try to read more data. */ 1446 1447 /* First move last chars to start of buffer. */ 1448 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); 1449 1450 for ( i = 0; i < number_to_move; ++i ) 1451 *(dest++) = *(source++); 1452 1453 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) 1454 /* don't do the read, it's not guaranteed to return an EOF, 1455 * just force an EOF 1456 */ 1457 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; 1458 1459 else 1460 { 1461 int num_to_read = 1462 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; 1463 1464 while ( num_to_read <= 0 ) 1465 { /* Not enough room in the buffer - grow it. */ 1466 1467 /* just a shorter name for the current buffer */ 1468 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; 1469 1470 int yy_c_buf_p_offset = 1471 (int) ((yy_c_buf_p) - b->yy_ch_buf); 1472 1473 if ( b->yy_is_our_buffer ) 1474 { 1475 int new_size = b->yy_buf_size * 2; 1476 1477 if ( new_size <= 0 ) 1478 b->yy_buf_size += b->yy_buf_size / 8; 1479 else 1480 b->yy_buf_size *= 2; 1481 1482 b->yy_ch_buf = (char *) 1483 /* Include room in for 2 EOB chars. */ 1484 yyrealloc( (void *) b->yy_ch_buf, 1485 (yy_size_t) (b->yy_buf_size + 2) ); 1486 } 1487 else 1488 /* Can't grow it, we don't own it. */ 1489 b->yy_ch_buf = NULL; 1490 1491 if ( ! b->yy_ch_buf ) 1492 YY_FATAL_ERROR( 1493 "fatal error - scanner input buffer overflow" ); 1494 1495 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; 1496 1497 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - 1498 number_to_move - 1; 1499 1500 } 1501 1502 if ( num_to_read > YY_READ_BUF_SIZE ) 1503 num_to_read = YY_READ_BUF_SIZE; 1504 1505 /* Read in more data. */ 1506 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), 1507 (yy_n_chars), num_to_read ); 1508 1509 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 1510 } 1511 1512 if ( (yy_n_chars) == 0 ) 1513 { 1514 if ( number_to_move == YY_MORE_ADJ ) 1515 { 1516 ret_val = EOB_ACT_END_OF_FILE; 1517 yyrestart( yyin ); 1518 } 1519 1520 else 1521 { 1522 ret_val = EOB_ACT_LAST_MATCH; 1523 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = 1524 YY_BUFFER_EOF_PENDING; 1525 } 1526 } 1527 1528 else 1529 ret_val = EOB_ACT_CONTINUE_SCAN; 1530 1531 if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { 1532 /* Extend the array by 50%, plus the number we really need. */ 1533 int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); 1534 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( 1535 (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); 1536 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) 1537 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); 1538 /* "- 2" to take care of EOB's */ 1539 YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); 1540 } 1541 1542 (yy_n_chars) += number_to_move; 1543 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; 1544 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; 1545 1546 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; 1547 1548 return ret_val; 1549 } 1550 1551 /* yy_get_previous_state - get the state just before the EOB char was reached */ 1552 1553 static yy_state_type yy_get_previous_state (void) 1554 { 1555 yy_state_type yy_current_state; 1556 char *yy_cp; 1557 1558 yy_current_state = (yy_start); 1559 yy_current_state += YY_AT_BOL(); 1560 1561 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) 1562 { 1563 YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); 1564 if ( yy_accept[yy_current_state] ) 1565 { 1566 (yy_last_accepting_state) = yy_current_state; 1567 (yy_last_accepting_cpos) = yy_cp; 1568 } 1569 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1570 { 1571 yy_current_state = (int) yy_def[yy_current_state]; 1572 if ( yy_current_state >= 74 ) 1573 yy_c = yy_meta[yy_c]; 1574 } 1575 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; 1576 } 1577 1578 return yy_current_state; 1579 } 1580 1581 /* yy_try_NUL_trans - try to make a transition on the NUL character 1582 * 1583 * synopsis 1584 * next_state = yy_try_NUL_trans( current_state ); 1585 */ 1586 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) 1587 { 1588 int yy_is_jam; 1589 char *yy_cp = (yy_c_buf_p); 1590 1591 YY_CHAR yy_c = 1; 1592 if ( yy_accept[yy_current_state] ) 1593 { 1594 (yy_last_accepting_state) = yy_current_state; 1595 (yy_last_accepting_cpos) = yy_cp; 1596 } 1597 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1598 { 1599 yy_current_state = (int) yy_def[yy_current_state]; 1600 if ( yy_current_state >= 74 ) 1601 yy_c = yy_meta[yy_c]; 1602 } 1603 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; 1604 yy_is_jam = (yy_current_state == 73); 1605 1606 return yy_is_jam ? 0 : yy_current_state; 1607 } 1608 1609 #ifndef YY_NO_UNPUT 1610 1611 #endif 1612 1613 #ifndef YY_NO_INPUT 1614 #ifdef __cplusplus 1615 static int yyinput (void) 1616 #else 1617 static int input (void) 1618 #endif 1619 1620 { 1621 int c; 1622 1623 *(yy_c_buf_p) = (yy_hold_char); 1624 1625 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) 1626 { 1627 /* yy_c_buf_p now points to the character we want to return. 1628 * If this occurs *before* the EOB characters, then it's a 1629 * valid NUL; if not, then we've hit the end of the buffer. 1630 */ 1631 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) 1632 /* This was really a NUL. */ 1633 *(yy_c_buf_p) = '\0'; 1634 1635 else 1636 { /* need more input */ 1637 int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); 1638 ++(yy_c_buf_p); 1639 1640 switch ( yy_get_next_buffer( ) ) 1641 { 1642 case EOB_ACT_LAST_MATCH: 1643 /* This happens because yy_g_n_b() 1644 * sees that we've accumulated a 1645 * token and flags that we need to 1646 * try matching the token before 1647 * proceeding. But for input(), 1648 * there's no matching to consider. 1649 * So convert the EOB_ACT_LAST_MATCH 1650 * to EOB_ACT_END_OF_FILE. 1651 */ 1652 1653 /* Reset buffer status. */ 1654 yyrestart( yyin ); 1655 1656 /*FALLTHROUGH*/ 1657 1658 case EOB_ACT_END_OF_FILE: 1659 { 1660 if ( yywrap( ) ) 1661 return 0; 1662 1663 if ( ! (yy_did_buffer_switch_on_eof) ) 1664 YY_NEW_FILE; 1665 #ifdef __cplusplus 1666 return yyinput(); 1667 #else 1668 return input(); 1669 #endif 1670 } 1671 1672 case EOB_ACT_CONTINUE_SCAN: 1673 (yy_c_buf_p) = (yytext_ptr) + offset; 1674 break; 1675 } 1676 } 1677 } 1678 1679 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ 1680 *(yy_c_buf_p) = '\0'; /* preserve yytext */ 1681 (yy_hold_char) = *++(yy_c_buf_p); 1682 1683 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); 1684 1685 return c; 1686 } 1687 #endif /* ifndef YY_NO_INPUT */ 1688 1689 /** Immediately switch to a different input stream. 1690 * @param input_file A readable stream. 1691 * 1692 * @note This function does not reset the start condition to @c INITIAL . 1693 */ 1694 void yyrestart (FILE * input_file ) 1695 { 1696 1697 if ( ! YY_CURRENT_BUFFER ){ 1698 yyensure_buffer_stack (); 1699 YY_CURRENT_BUFFER_LVALUE = 1700 yy_create_buffer( yyin, YY_BUF_SIZE ); 1701 } 1702 1703 yy_init_buffer( YY_CURRENT_BUFFER, input_file ); 1704 yy_load_buffer_state( ); 1705 } 1706 1707 /** Switch to a different input buffer. 1708 * @param new_buffer The new input buffer. 1709 * 1710 */ 1711 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) 1712 { 1713 1714 /* TODO. We should be able to replace this entire function body 1715 * with 1716 * yypop_buffer_state(); 1717 * yypush_buffer_state(new_buffer); 1718 */ 1719 yyensure_buffer_stack (); 1720 if ( YY_CURRENT_BUFFER == new_buffer ) 1721 return; 1722 1723 if ( YY_CURRENT_BUFFER ) 1724 { 1725 /* Flush out information for old buffer. */ 1726 *(yy_c_buf_p) = (yy_hold_char); 1727 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); 1728 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 1729 } 1730 1731 YY_CURRENT_BUFFER_LVALUE = new_buffer; 1732 yy_load_buffer_state( ); 1733 1734 /* We don't actually know whether we did this switch during 1735 * EOF (yywrap()) processing, but the only time this flag 1736 * is looked at is after yywrap() is called, so it's safe 1737 * to go ahead and always set it. 1738 */ 1739 (yy_did_buffer_switch_on_eof) = 1; 1740 } 1741 1742 static void yy_load_buffer_state (void) 1743 { 1744 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 1745 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; 1746 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; 1747 (yy_hold_char) = *(yy_c_buf_p); 1748 } 1749 1750 /** Allocate and initialize an input buffer state. 1751 * @param file A readable stream. 1752 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. 1753 * 1754 * @return the allocated buffer state. 1755 */ 1756 YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) 1757 { 1758 YY_BUFFER_STATE b; 1759 1760 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); 1761 if ( ! b ) 1762 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 1763 1764 b->yy_buf_size = size; 1765 1766 /* yy_ch_buf has to be 2 characters longer than the size given because 1767 * we need to put in 2 end-of-buffer characters. 1768 */ 1769 b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); 1770 if ( ! b->yy_ch_buf ) 1771 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 1772 1773 b->yy_is_our_buffer = 1; 1774 1775 yy_init_buffer( b, file ); 1776 1777 return b; 1778 } 1779 1780 /** Destroy the buffer. 1781 * @param b a buffer created with yy_create_buffer() 1782 * 1783 */ 1784 void yy_delete_buffer (YY_BUFFER_STATE b ) 1785 { 1786 1787 if ( ! b ) 1788 return; 1789 1790 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ 1791 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; 1792 1793 if ( b->yy_is_our_buffer ) 1794 yyfree( (void *) b->yy_ch_buf ); 1795 1796 yyfree( (void *) b ); 1797 } 1798 1799 /* Initializes or reinitializes a buffer. 1800 * This function is sometimes called more than once on the same buffer, 1801 * such as during a yyrestart() or at EOF. 1802 */ 1803 static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) 1804 1805 { 1806 int oerrno = errno; 1807 1808 yy_flush_buffer( b ); 1809 1810 b->yy_input_file = file; 1811 b->yy_fill_buffer = 1; 1812 1813 /* If b is the current buffer, then yy_init_buffer was _probably_ 1814 * called from yyrestart() or through yy_get_next_buffer. 1815 * In that case, we don't want to reset the lineno or column. 1816 */ 1817 if (b != YY_CURRENT_BUFFER){ 1818 b->yy_bs_lineno = 1; 1819 b->yy_bs_column = 0; 1820 } 1821 1822 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; 1823 1824 errno = oerrno; 1825 } 1826 1827 /** Discard all buffered characters. On the next scan, YY_INPUT will be called. 1828 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. 1829 * 1830 */ 1831 void yy_flush_buffer (YY_BUFFER_STATE b ) 1832 { 1833 if ( ! b ) 1834 return; 1835 1836 b->yy_n_chars = 0; 1837 1838 /* We always need two end-of-buffer characters. The first causes 1839 * a transition to the end-of-buffer state. The second causes 1840 * a jam in that state. 1841 */ 1842 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; 1843 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; 1844 1845 b->yy_buf_pos = &b->yy_ch_buf[0]; 1846 1847 b->yy_at_bol = 1; 1848 b->yy_buffer_status = YY_BUFFER_NEW; 1849 1850 if ( b == YY_CURRENT_BUFFER ) 1851 yy_load_buffer_state( ); 1852 } 1853 1854 /** Pushes the new state onto the stack. The new state becomes 1855 * the current state. This function will allocate the stack 1856 * if necessary. 1857 * @param new_buffer The new state. 1858 * 1859 */ 1860 void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) 1861 { 1862 if (new_buffer == NULL) 1863 return; 1864 1865 yyensure_buffer_stack(); 1866 1867 /* This block is copied from yy_switch_to_buffer. */ 1868 if ( YY_CURRENT_BUFFER ) 1869 { 1870 /* Flush out information for old buffer. */ 1871 *(yy_c_buf_p) = (yy_hold_char); 1872 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); 1873 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 1874 } 1875 1876 /* Only push if top exists. Otherwise, replace top. */ 1877 if (YY_CURRENT_BUFFER) 1878 (yy_buffer_stack_top)++; 1879 YY_CURRENT_BUFFER_LVALUE = new_buffer; 1880 1881 /* copied from yy_switch_to_buffer. */ 1882 yy_load_buffer_state( ); 1883 (yy_did_buffer_switch_on_eof) = 1; 1884 } 1885 1886 /** Removes and deletes the top of the stack, if present. 1887 * The next element becomes the new top. 1888 * 1889 */ 1890 void yypop_buffer_state (void) 1891 { 1892 if (!YY_CURRENT_BUFFER) 1893 return; 1894 1895 yy_delete_buffer(YY_CURRENT_BUFFER ); 1896 YY_CURRENT_BUFFER_LVALUE = NULL; 1897 if ((yy_buffer_stack_top) > 0) 1898 --(yy_buffer_stack_top); 1899 1900 if (YY_CURRENT_BUFFER) { 1901 yy_load_buffer_state( ); 1902 (yy_did_buffer_switch_on_eof) = 1; 1903 } 1904 } 1905 1906 /* Allocates the stack if it does not exist. 1907 * Guarantees space for at least one push. 1908 */ 1909 static void yyensure_buffer_stack (void) 1910 { 1911 yy_size_t num_to_alloc; 1912 1913 if (!(yy_buffer_stack)) { 1914 1915 /* First allocation is just for 2 elements, since we don't know if this 1916 * scanner will even need a stack. We use 2 instead of 1 to avoid an 1917 * immediate realloc on the next call. 1918 */ 1919 num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ 1920 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc 1921 (num_to_alloc * sizeof(struct yy_buffer_state*) 1922 ); 1923 if ( ! (yy_buffer_stack) ) 1924 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); 1925 1926 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); 1927 1928 (yy_buffer_stack_max) = num_to_alloc; 1929 (yy_buffer_stack_top) = 0; 1930 return; 1931 } 1932 1933 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ 1934 1935 /* Increase the buffer to prepare for a possible push. */ 1936 yy_size_t grow_size = 8 /* arbitrary grow size */; 1937 1938 num_to_alloc = (yy_buffer_stack_max) + grow_size; 1939 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc 1940 ((yy_buffer_stack), 1941 num_to_alloc * sizeof(struct yy_buffer_state*) 1942 ); 1943 if ( ! (yy_buffer_stack) ) 1944 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); 1945 1946 /* zero only the new slots.*/ 1947 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); 1948 (yy_buffer_stack_max) = num_to_alloc; 1949 } 1950 } 1951 1952 /** Setup the input buffer state to scan directly from a user-specified character buffer. 1953 * @param base the character buffer 1954 * @param size the size in bytes of the character buffer 1955 * 1956 * @return the newly allocated buffer state object. 1957 */ 1958 YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) 1959 { 1960 YY_BUFFER_STATE b; 1961 1962 if ( size < 2 || 1963 base[size-2] != YY_END_OF_BUFFER_CHAR || 1964 base[size-1] != YY_END_OF_BUFFER_CHAR ) 1965 /* They forgot to leave room for the EOB's. */ 1966 return NULL; 1967 1968 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); 1969 if ( ! b ) 1970 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); 1971 1972 b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ 1973 b->yy_buf_pos = b->yy_ch_buf = base; 1974 b->yy_is_our_buffer = 0; 1975 b->yy_input_file = NULL; 1976 b->yy_n_chars = b->yy_buf_size; 1977 b->yy_is_interactive = 0; 1978 b->yy_at_bol = 1; 1979 b->yy_fill_buffer = 0; 1980 b->yy_buffer_status = YY_BUFFER_NEW; 1981 1982 yy_switch_to_buffer( b ); 1983 1984 return b; 1985 } 1986 1987 /** Setup the input buffer state to scan a string. The next call to yylex() will 1988 * scan from a @e copy of @a str. 1989 * @param yystr a NUL-terminated string to scan 1990 * 1991 * @return the newly allocated buffer state object. 1992 * @note If you want to scan bytes that may contain NUL values, then use 1993 * yy_scan_bytes() instead. 1994 */ 1995 YY_BUFFER_STATE yy_scan_string (const char * yystr ) 1996 { 1997 1998 return yy_scan_bytes( yystr, (int) strlen(yystr) ); 1999 } 2000 2001 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will 2002 * scan from a @e copy of @a bytes. 2003 * @param yybytes the byte buffer to scan 2004 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. 2005 * 2006 * @return the newly allocated buffer state object. 2007 */ 2008 YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) 2009 { 2010 YY_BUFFER_STATE b; 2011 char *buf; 2012 yy_size_t n; 2013 int i; 2014 2015 /* Get memory for full buffer, including space for trailing EOB's. */ 2016 n = (yy_size_t) (_yybytes_len + 2); 2017 buf = (char *) yyalloc( n ); 2018 if ( ! buf ) 2019 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); 2020 2021 for ( i = 0; i < _yybytes_len; ++i ) 2022 buf[i] = yybytes[i]; 2023 2024 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; 2025 2026 b = yy_scan_buffer( buf, n ); 2027 if ( ! b ) 2028 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); 2029 2030 /* It's okay to grow etc. this buffer, and we should throw it 2031 * away when we're done. 2032 */ 2033 b->yy_is_our_buffer = 1; 2034 2035 return b; 2036 } 2037 2038 #ifndef YY_EXIT_FAILURE 2039 #define YY_EXIT_FAILURE 2 2040 #endif 2041 2042 static void yynoreturn yy_fatal_error (const char* msg ) 2043 { 2044 fprintf( stderr, "%s\n", msg ); 2045 exit( YY_EXIT_FAILURE ); 2046 } 2047 2048 /* Redefine yyless() so it works in section 3 code. */ 2049 2050 #undef yyless 2051 #define yyless(n) \ 2052 do \ 2053 { \ 2054 /* Undo effects of setting up yytext. */ \ 2055 int yyless_macro_arg = (n); \ 2056 YY_LESS_LINENO(yyless_macro_arg);\ 2057 yytext[yyleng] = (yy_hold_char); \ 2058 (yy_c_buf_p) = yytext + yyless_macro_arg; \ 2059 (yy_hold_char) = *(yy_c_buf_p); \ 2060 *(yy_c_buf_p) = '\0'; \ 2061 yyleng = yyless_macro_arg; \ 2062 } \ 2063 while ( 0 ) 2064 2065 /* Accessor methods (get/set functions) to struct members. */ 2066 2067 /** Get the current line number. 2068 * 2069 */ 2070 int yyget_lineno (void) 2071 { 2072 2073 return yylineno; 2074 } 2075 2076 /** Get the input stream. 2077 * 2078 */ 2079 FILE *yyget_in (void) 2080 { 2081 return yyin; 2082 } 2083 2084 /** Get the output stream. 2085 * 2086 */ 2087 FILE *yyget_out (void) 2088 { 2089 return yyout; 2090 } 2091 2092 /** Get the length of the current token. 2093 * 2094 */ 2095 int yyget_leng (void) 2096 { 2097 return yyleng; 2098 } 2099 2100 /** Get the current token. 2101 * 2102 */ 2103 2104 char *yyget_text (void) 2105 { 2106 return yytext; 2107 } 2108 2109 /** Set the current line number. 2110 * @param _line_number line number 2111 * 2112 */ 2113 void yyset_lineno (int _line_number ) 2114 { 2115 2116 yylineno = _line_number; 2117 } 2118 2119 /** Set the input stream. This does not discard the current 2120 * input buffer. 2121 * @param _in_str A readable stream. 2122 * 2123 * @see yy_switch_to_buffer 2124 */ 2125 void yyset_in (FILE * _in_str ) 2126 { 2127 yyin = _in_str ; 2128 } 2129 2130 void yyset_out (FILE * _out_str ) 2131 { 2132 yyout = _out_str ; 2133 } 2134 2135 int yyget_debug (void) 2136 { 2137 return yy_flex_debug; 2138 } 2139 2140 void yyset_debug (int _bdebug ) 2141 { 2142 yy_flex_debug = _bdebug ; 2143 } 2144 2145 static int yy_init_globals (void) 2146 { 2147 /* Initialization is the same as for the non-reentrant scanner. 2148 * This function is called from yylex_destroy(), so don't allocate here. 2149 */ 2150 2151 (yy_buffer_stack) = NULL; 2152 (yy_buffer_stack_top) = 0; 2153 (yy_buffer_stack_max) = 0; 2154 (yy_c_buf_p) = NULL; 2155 (yy_init) = 0; 2156 (yy_start) = 0; 2157 2158 /* Defined in main.c */ 2159 #ifdef YY_STDINIT 2160 yyin = stdin; 2161 yyout = stdout; 2162 #else 2163 yyin = NULL; 2164 yyout = NULL; 2165 #endif 2166 2167 /* For future reference: Set errno on error, since we are called by 2168 * yylex_init() 2169 */ 2170 return 0; 2171 } 2172 2173 /* yylex_destroy is for both reentrant and non-reentrant scanners. */ 2174 int yylex_destroy (void) 2175 { 2176 2177 /* Pop the buffer stack, destroying each element. */ 2178 while(YY_CURRENT_BUFFER){ 2179 yy_delete_buffer( YY_CURRENT_BUFFER ); 2180 YY_CURRENT_BUFFER_LVALUE = NULL; 2181 yypop_buffer_state(); 2182 } 2183 2184 /* Destroy the stack itself. */ 2185 yyfree((yy_buffer_stack) ); 2186 (yy_buffer_stack) = NULL; 2187 2188 /* Reset the globals. This is important in a non-reentrant scanner so the next time 2189 * yylex() is called, initialization will occur. */ 2190 yy_init_globals( ); 2191 2192 return 0; 2193 } 2194 2195 /* 2196 * Internal utility routines. 2197 */ 2198 2199 #ifndef yytext_ptr 2200 static void yy_flex_strncpy (char* s1, const char * s2, int n ) 2201 { 2202 2203 int i; 2204 for ( i = 0; i < n; ++i ) 2205 s1[i] = s2[i]; 2206 } 2207 #endif 2208 2209 #ifdef YY_NEED_STRLEN 2210 static int yy_flex_strlen (const char * s ) 2211 { 2212 int n; 2213 for ( n = 0; s[n]; ++n ) 2214 ; 2215 2216 return n; 2217 } 2218 #endif 2219 2220 void *yyalloc (yy_size_t size ) 2221 { 2222 return malloc(size); 2223 } 2224 2225 void *yyrealloc (void * ptr, yy_size_t size ) 2226 { 2227 2228 /* The cast to (char *) in the following accommodates both 2229 * implementations that use char* generic pointers, and those 2230 * that use void* generic pointers. It works with the latter 2231 * because both ANSI C and C++ allow castless assignment from 2232 * any pointer type to void*, and deal with argument conversions 2233 * as though doing an assignment. 2234 */ 2235 return realloc(ptr, size); 2236 } 2237 2238 void yyfree (void * ptr ) 2239 { 2240 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ 2241 } 2242 2243 #define YYTABLES_NAME "yytables" 2244 2245 #line 361 "zlexer.lex" 2246 2247 2248 /* 2249 * Analyze "word" to see if it matches an RR type, possibly by using 2250 * the "TYPExxx" notation. If it matches, the corresponding token is 2251 * returned and the TYPE parameter is set to the RR type value. 2252 */ 2253 static int 2254 rrtype_to_token(const char *word, uint16_t *type) 2255 { 2256 uint16_t t = rrtype_from_string(word); 2257 if (t != 0) { 2258 rrtype_descriptor_type *entry = rrtype_descriptor_by_type(t); 2259 *type = t; 2260 return entry->token; 2261 } 2262 2263 return 0; 2264 } 2265 2266 2267 /* 2268 * Remove \DDD constructs from the input. See RFC 1035, section 5.1. 2269 */ 2270 static size_t 2271 zoctet(char *text) 2272 { 2273 /* 2274 * s follows the string, p lags behind and rebuilds the new 2275 * string 2276 */ 2277 char *s; 2278 char *p; 2279 2280 for (s = p = text; *s; ++s, ++p) { 2281 assert(p <= s); 2282 if (s[0] != '\\') { 2283 /* Ordinary character. */ 2284 *p = *s; 2285 } else if (isdigit((unsigned char)s[1]) && isdigit((unsigned char)s[2]) && isdigit((unsigned char)s[3])) { 2286 /* \DDD escape. */ 2287 int val = (hexdigit_to_int(s[1]) * 100 + 2288 hexdigit_to_int(s[2]) * 10 + 2289 hexdigit_to_int(s[3])); 2290 if (0 <= val && val <= 255) { 2291 s += 3; 2292 *p = val; 2293 } else { 2294 zc_warning("text escape \\DDD overflow"); 2295 *p = *++s; 2296 } 2297 } else if (s[1] != '\0') { 2298 /* \X where X is any character, keep X. */ 2299 *p = *++s; 2300 } else { 2301 /* Trailing backslash, ignore it. */ 2302 zc_warning("trailing backslash ignored"); 2303 --p; 2304 } 2305 } 2306 *p = '\0'; 2307 return p - text; 2308 } 2309 2310 static int 2311 parse_token(int token, char *yytext, enum lexer_state *lexer_state) 2312 { 2313 size_t len; 2314 char *str; 2315 2316 if (*lexer_state == EXPECT_OWNER) { 2317 *lexer_state = PARSING_OWNER; 2318 } else if (*lexer_state == PARSING_TTL_CLASS_TYPE) { 2319 const char *t; 2320 int token; 2321 uint16_t rrclass; 2322 2323 /* type */ 2324 token = rrtype_to_token(yytext, &yylval.type); 2325 if (token != 0) { 2326 *lexer_state = PARSING_RDATA; 2327 LEXOUT(("%d[%s] ", token, yytext)); 2328 return token; 2329 } 2330 2331 /* class */ 2332 rrclass = rrclass_from_string(yytext); 2333 if (rrclass != 0) { 2334 yylval.klass = rrclass; 2335 LEXOUT(("CLASS ")); 2336 return T_RRCLASS; 2337 } 2338 2339 /* ttl */ 2340 yylval.ttl = strtottl(yytext, &t); 2341 if (*t == '\0') { 2342 LEXOUT(("TTL ")); 2343 return T_TTL; 2344 } 2345 } 2346 2347 str = region_strdup(parser->rr_region, yytext); 2348 len = zoctet(str); 2349 2350 yylval.data.str = str; 2351 yylval.data.len = len; 2352 2353 LEXOUT(("%d[%s] ", token, yytext)); 2354 return token; 2355 } 2356 2357