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