1 #line 4 "dhcpd-lex.l"
2 #ifdef HAVE_CONFIG_H
3 # include <config.h>
4 #endif
5
6
7
8 #line 9 "dhcpd-lex.c"
9
10 #define YY_INT_ALIGNED short int
11
12 /* A lexical scanner generated by flex */
13
14 /* %not-for-header */
15
16 /* %if-c-only */
17 /* %if-not-reentrant */
18
19 /* %endif */
20 /* %endif */
21 /* %ok-for-header */
22
23 #define FLEX_SCANNER
24 #define YY_FLEX_MAJOR_VERSION 2
25 #define YY_FLEX_MINOR_VERSION 6
26 #define YY_FLEX_SUBMINOR_VERSION 0
27 #if YY_FLEX_SUBMINOR_VERSION > 0
28 #define FLEX_BETA
29 #endif
30
31 /* %if-c++-only */
32 /* %endif */
33
34 /* %if-c-only */
35
36 /* %endif */
37
38 /* %if-c-only */
39
40 /* %endif */
41
42 /* First, we deal with platform-specific or compiler-specific issues. */
43
44 /* begin standard C headers. */
45 /* %if-c-only */
46 #include <stdio.h>
47 #include <string.h>
48 #include <errno.h>
49 #include <stdlib.h>
50 /* %endif */
51
52 /* %if-tables-serialization */
53 /* %endif */
54 /* end standard C headers. */
55
56 /* %if-c-or-c++ */
57 /* flex integer type definitions */
58
59 #ifndef FLEXINT_H
60 #define FLEXINT_H
61
62 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
63
64 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
65
66 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
67 * if you want the limit (max/min) macros for int types.
68 */
69 #ifndef __STDC_LIMIT_MACROS
70 #define __STDC_LIMIT_MACROS 1
71 #endif
72
73 #include <inttypes.h>
74 typedef int8_t flex_int8_t;
75 typedef uint8_t flex_uint8_t;
76 typedef int16_t flex_int16_t;
77 typedef uint16_t flex_uint16_t;
78 typedef int32_t flex_int32_t;
79 typedef uint32_t flex_uint32_t;
80 #else
81 typedef signed char flex_int8_t;
82 typedef short int flex_int16_t;
83 typedef int flex_int32_t;
84 typedef unsigned char flex_uint8_t;
85 typedef unsigned short int flex_uint16_t;
86 typedef unsigned int flex_uint32_t;
87
88 /* Limits of integral types. */
89 #ifndef INT8_MIN
90 #define INT8_MIN (-128)
91 #endif
92 #ifndef INT16_MIN
93 #define INT16_MIN (-32767-1)
94 #endif
95 #ifndef INT32_MIN
96 #define INT32_MIN (-2147483647-1)
97 #endif
98 #ifndef INT8_MAX
99 #define INT8_MAX (127)
100 #endif
101 #ifndef INT16_MAX
102 #define INT16_MAX (32767)
103 #endif
104 #ifndef INT32_MAX
105 #define INT32_MAX (2147483647)
106 #endif
107 #ifndef UINT8_MAX
108 #define UINT8_MAX (255U)
109 #endif
110 #ifndef UINT16_MAX
111 #define UINT16_MAX (65535U)
112 #endif
113 #ifndef UINT32_MAX
114 #define UINT32_MAX (4294967295U)
115 #endif
116
117 #endif /* ! C99 */
118
119 #endif /* ! FLEXINT_H */
120
121 /* %endif */
122
123 /* %if-c++-only */
124 /* %endif */
125
126 #ifdef __cplusplus
127
128 /* The "const" storage-class-modifier is valid. */
129 #define YY_USE_CONST
130
131 #else /* ! __cplusplus */
132
133 /* C99 requires __STDC__ to be defined as 1. */
134 #if defined (__STDC__)
135
136 #define YY_USE_CONST
137
138 #endif /* defined (__STDC__) */
139 #endif /* ! __cplusplus */
140
141 #ifdef YY_USE_CONST
142 #define grecs_dhcpdconst const
143 #else
144 #define grecs_dhcpdconst
145 #endif
146
147 /* %not-for-header */
148
149 /* Returned upon end-of-file. */
150 #define YY_NULL 0
151 /* %ok-for-header */
152
153 /* %not-for-header */
154
155 /* Promotes a possibly negative, possibly signed char to an unsigned
156 * integer for use as an array index. If the signed char is negative,
157 * we want to instead treat it as an 8-bit unsigned char, hence the
158 * double cast.
159 */
160 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
161 /* %ok-for-header */
162
163 /* %if-reentrant */
164 /* %endif */
165
166 /* %if-not-reentrant */
167
168 /* %endif */
169
170 /* Enter a start condition. This macro really ought to take a parameter,
171 * but we do it the disgusting crufty way forced on us by the ()-less
172 * definition of BEGIN.
173 */
174 #define BEGIN (grecs_dhcpd_start) = 1 + 2 *
175
176 /* Translate the current start state into a value that can be later handed
177 * to BEGIN to return to the state. The YYSTATE alias is for lex
178 * compatibility.
179 */
180 #define YY_START (((grecs_dhcpd_start) - 1) / 2)
181 #define YYSTATE YY_START
182
183 /* Action number for EOF rule of a given start state. */
184 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
185
186 /* Special action meaning "start processing a new file". */
187 #define YY_NEW_FILE grecs_dhcpdrestart(grecs_dhcpdin )
188
189 #define YY_END_OF_BUFFER_CHAR 0
190
191 /* Size of default input buffer. */
192 #ifndef YY_BUF_SIZE
193 #ifdef __ia64__
194 /* On IA-64, the buffer size is 16k, not 8k.
195 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
196 * Ditto for the __ia64__ case accordingly.
197 */
198 #define YY_BUF_SIZE 32768
199 #else
200 #define YY_BUF_SIZE 16384
201 #endif /* __ia64__ */
202 #endif
203
204 /* The state buf must be large enough to hold one state per character in the main buffer.
205 */
206 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(grecs_dhcpd_state_type))
207
208 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
209 #define YY_TYPEDEF_YY_BUFFER_STATE
210 typedef struct grecs_dhcpd_buffer_state *YY_BUFFER_STATE;
211 #endif
212
213 #ifndef YY_TYPEDEF_YY_SIZE_T
214 #define YY_TYPEDEF_YY_SIZE_T
215 typedef size_t grecs_dhcpd_size_t;
216 #endif
217
218 /* %if-not-reentrant */
219 extern grecs_dhcpd_size_t grecs_dhcpdleng;
220 /* %endif */
221
222 /* %if-c-only */
223 /* %if-not-reentrant */
224 extern FILE *grecs_dhcpdin, *grecs_dhcpdout;
225 /* %endif */
226 /* %endif */
227
228 #define EOB_ACT_CONTINUE_SCAN 0
229 #define EOB_ACT_END_OF_FILE 1
230 #define EOB_ACT_LAST_MATCH 2
231
232 #define YY_LESS_LINENO(n)
233 #define YY_LINENO_REWIND_TO(ptr)
234
235 /* Return all but the first "n" matched characters back to the input stream. */
236 #define grecs_dhcpdless(n) \
237 do \
238 { \
239 /* Undo effects of setting up grecs_dhcpdtext. */ \
240 int grecs_dhcpdless_macro_arg = (n); \
241 YY_LESS_LINENO(grecs_dhcpdless_macro_arg);\
242 *grecs_dhcpd_cp = (grecs_dhcpd_hold_char); \
243 YY_RESTORE_YY_MORE_OFFSET \
244 (grecs_dhcpd_c_buf_p) = grecs_dhcpd_cp = grecs_dhcpd_bp + grecs_dhcpdless_macro_arg - YY_MORE_ADJ; \
245 YY_DO_BEFORE_ACTION; /* set up grecs_dhcpdtext again */ \
246 } \
247 while ( 0 )
248
249 #define unput(c) grecs_dhcpdunput( c, (grecs_dhcpdtext_ptr) )
250
251 #ifndef YY_STRUCT_YY_BUFFER_STATE
252 #define YY_STRUCT_YY_BUFFER_STATE
253 struct grecs_dhcpd_buffer_state
254 {
255 /* %if-c-only */
256 FILE *grecs_dhcpd_input_file;
257 /* %endif */
258
259 /* %if-c++-only */
260 /* %endif */
261
262 char *grecs_dhcpd_ch_buf; /* input buffer */
263 char *grecs_dhcpd_buf_pos; /* current position in input buffer */
264
265 /* Size of input buffer in bytes, not including room for EOB
266 * characters.
267 */
268 grecs_dhcpd_size_t grecs_dhcpd_buf_size;
269
270 /* Number of characters read into grecs_dhcpd_ch_buf, not including EOB
271 * characters.
272 */
273 grecs_dhcpd_size_t grecs_dhcpd_n_chars;
274
275 /* Whether we "own" the buffer - i.e., we know we created it,
276 * and can realloc() it to grow it, and should free() it to
277 * delete it.
278 */
279 int grecs_dhcpd_is_our_buffer;
280
281 /* Whether this is an "interactive" input source; if so, and
282 * if we're using stdio for input, then we want to use getc()
283 * instead of fread(), to make sure we stop fetching input after
284 * each newline.
285 */
286 int grecs_dhcpd_is_interactive;
287
288 /* Whether we're considered to be at the beginning of a line.
289 * If so, '^' rules will be active on the next match, otherwise
290 * not.
291 */
292 int grecs_dhcpd_at_bol;
293
294 int grecs_dhcpd_bs_lineno; /**< The line count. */
295 int grecs_dhcpd_bs_column; /**< The column count. */
296
297 /* Whether to try to fill the input buffer when we reach the
298 * end of it.
299 */
300 int grecs_dhcpd_fill_buffer;
301
302 int grecs_dhcpd_buffer_status;
303
304 #define YY_BUFFER_NEW 0
305 #define YY_BUFFER_NORMAL 1
306 /* When an EOF's been seen but there's still some text to process
307 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
308 * shouldn't try reading from the input source any more. We might
309 * still have a bunch of tokens to match, though, because of
310 * possible backing-up.
311 *
312 * When we actually see the EOF, we change the status to "new"
313 * (via grecs_dhcpdrestart()), so that the user can continue scanning by
314 * just pointing grecs_dhcpdin at a new input file.
315 */
316 #define YY_BUFFER_EOF_PENDING 2
317
318 };
319 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
320
321 /* %if-c-only Standard (non-C++) definition */
322 /* %not-for-header */
323
324 /* %if-not-reentrant */
325
326 /* Stack of input buffers. */
327 static size_t grecs_dhcpd_buffer_stack_top = 0; /**< index of top of stack. */
328 static size_t grecs_dhcpd_buffer_stack_max = 0; /**< capacity of stack. */
329 static YY_BUFFER_STATE * grecs_dhcpd_buffer_stack = 0; /**< Stack as an array. */
330 /* %endif */
331 /* %ok-for-header */
332
333 /* %endif */
334
335 /* We provide macros for accessing buffer states in case in the
336 * future we want to put the buffer states in a more general
337 * "scanner state".
338 *
339 * Returns the top of the stack, or NULL.
340 */
341 #define YY_CURRENT_BUFFER ( (grecs_dhcpd_buffer_stack) \
342 ? (grecs_dhcpd_buffer_stack)[(grecs_dhcpd_buffer_stack_top)] \
343 : NULL)
344
345 /* Same as previous macro, but useful when we know that the buffer stack is not
346 * NULL or when we need an lvalue. For internal use only.
347 */
348 #define YY_CURRENT_BUFFER_LVALUE (grecs_dhcpd_buffer_stack)[(grecs_dhcpd_buffer_stack_top)]
349
350 /* %if-c-only Standard (non-C++) definition */
351
352 /* %if-not-reentrant */
353 /* %not-for-header */
354
355 /* grecs_dhcpd_hold_char holds the character lost when grecs_dhcpdtext is formed. */
356 static char grecs_dhcpd_hold_char;
357 static grecs_dhcpd_size_t grecs_dhcpd_n_chars; /* number of characters read into grecs_dhcpd_ch_buf */
358 grecs_dhcpd_size_t grecs_dhcpdleng;
359
360 /* Points to current character in buffer. */
361 static char *grecs_dhcpd_c_buf_p = (char *) 0;
362 static int grecs_dhcpd_init = 0; /* whether we need to initialize */
363 static int grecs_dhcpd_start = 0; /* start state number */
364
365 /* Flag which is used to allow grecs_dhcpdwrap()'s to do buffer switches
366 * instead of setting up a fresh grecs_dhcpdin. A bit of a hack ...
367 */
368 static int grecs_dhcpd_did_buffer_switch_on_eof;
369 /* %ok-for-header */
370
371 /* %endif */
372
373 void grecs_dhcpdrestart (FILE *input_file );
374 void grecs_dhcpd_switch_to_buffer (YY_BUFFER_STATE new_buffer );
375 YY_BUFFER_STATE grecs_dhcpd_create_buffer (FILE *file,int size );
376 void grecs_dhcpd_delete_buffer (YY_BUFFER_STATE b );
377 void grecs_dhcpd_flush_buffer (YY_BUFFER_STATE b );
378 void grecs_dhcpdpush_buffer_state (YY_BUFFER_STATE new_buffer );
379 void grecs_dhcpdpop_buffer_state (void );
380
381 static void grecs_dhcpdensure_buffer_stack (void );
382 static void grecs_dhcpd_load_buffer_state (void );
383 static void grecs_dhcpd_init_buffer (YY_BUFFER_STATE b,FILE *file );
384
385 #define YY_FLUSH_BUFFER grecs_dhcpd_flush_buffer(YY_CURRENT_BUFFER )
386
387 YY_BUFFER_STATE grecs_dhcpd_scan_buffer (char *base,grecs_dhcpd_size_t size );
388 YY_BUFFER_STATE grecs_dhcpd_scan_string (grecs_dhcpdconst char *grecs_dhcpd_str );
389 YY_BUFFER_STATE grecs_dhcpd_scan_bytes (grecs_dhcpdconst char *bytes,grecs_dhcpd_size_t len );
390
391 /* %endif */
392
393 void *grecs_dhcpdalloc (grecs_dhcpd_size_t );
394 void *grecs_dhcpdrealloc (void *,grecs_dhcpd_size_t );
395 void grecs_dhcpdfree (void * );
396
397 #define grecs_dhcpd_new_buffer grecs_dhcpd_create_buffer
398
399 #define grecs_dhcpd_set_interactive(is_interactive) \
400 { \
401 if ( ! YY_CURRENT_BUFFER ){ \
402 grecs_dhcpdensure_buffer_stack (); \
403 YY_CURRENT_BUFFER_LVALUE = \
404 grecs_dhcpd_create_buffer(grecs_dhcpdin,YY_BUF_SIZE ); \
405 } \
406 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_is_interactive = is_interactive; \
407 }
408
409 #define grecs_dhcpd_set_bol(at_bol) \
410 { \
411 if ( ! YY_CURRENT_BUFFER ){\
412 grecs_dhcpdensure_buffer_stack (); \
413 YY_CURRENT_BUFFER_LVALUE = \
414 grecs_dhcpd_create_buffer(grecs_dhcpdin,YY_BUF_SIZE ); \
415 } \
416 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_at_bol = at_bol; \
417 }
418
419 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_at_bol)
420
421 /* %% [1.0] grecs_dhcpdtext/grecs_dhcpdin/grecs_dhcpdout/grecs_dhcpd_state_type/grecs_dhcpdlineno etc. def's & init go here */
422 /* Begin user sect3 */
423
424 #define FLEX_DEBUG
425
426 typedef unsigned char YY_CHAR;
427
428 FILE *grecs_dhcpdin = (FILE *) 0, *grecs_dhcpdout = (FILE *) 0;
429
430 typedef int grecs_dhcpd_state_type;
431
432 extern int grecs_dhcpdlineno;
433
434 int grecs_dhcpdlineno = 1;
435
436 extern char *grecs_dhcpdtext;
437 #ifdef grecs_dhcpdtext_ptr
438 #undef grecs_dhcpdtext_ptr
439 #endif
440 #define grecs_dhcpdtext_ptr grecs_dhcpdtext
441
442 /* %% [1.5] DFA */
443
444 /* %if-c-only Standard (non-C++) definition */
445
446 static grecs_dhcpd_state_type grecs_dhcpd_get_previous_state (void );
447 static grecs_dhcpd_state_type grecs_dhcpd_try_NUL_trans (grecs_dhcpd_state_type current_state );
448 static int grecs_dhcpd_get_next_buffer (void );
449 #if defined(__GNUC__) && __GNUC__ >= 3
450 __attribute__((__noreturn__))
451 #endif
452 static void grecs_dhcpd_fatal_error (grecs_dhcpdconst char msg[] );
453
454 /* %endif */
455
456 /* Done after the current pattern has been matched and before the
457 * corresponding action - sets up grecs_dhcpdtext.
458 */
459 #define YY_DO_BEFORE_ACTION \
460 (grecs_dhcpdtext_ptr) = grecs_dhcpd_bp; \
461 /* %% [2.0] code to fiddle grecs_dhcpdtext and grecs_dhcpdleng for grecs_dhcpdmore() goes here \ */\
462 grecs_dhcpdleng = (size_t) (grecs_dhcpd_cp - grecs_dhcpd_bp); \
463 (grecs_dhcpd_hold_char) = *grecs_dhcpd_cp; \
464 *grecs_dhcpd_cp = '\0'; \
465 /* %% [3.0] code to copy grecs_dhcpdtext_ptr to grecs_dhcpdtext[] goes here, if %array \ */\
466 (grecs_dhcpd_c_buf_p) = grecs_dhcpd_cp;
467
468 /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
469 #define YY_NUM_RULES 29
470 #define YY_END_OF_BUFFER 30
471 /* This struct is not used in this scanner,
472 but its presence is necessary. */
473 struct grecs_dhcpd_trans_info
474 {
475 flex_int32_t grecs_dhcpd_verify;
476 flex_int32_t grecs_dhcpd_nxt;
477 };
478 static grecs_dhcpdconst flex_int16_t grecs_dhcpd_accept[111] =
479 { 0,
480 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
481 30, 28, 25, 26, 27, 28, 4, 15, 15, 14,
482 14, 14, 25, 4, 29, 29, 22, 24, 29, 29,
483 10, 11, 29, 12, 13, 25, 0, 19, 16, 0,
484 4, 3, 15, 6, 14, 14, 7, 25, 0, 4,
485 4, 4, 0, 22, 24, 0, 0, 23, 0, 20,
486 0, 10, 11, 0, 12, 13, 17, 18, 15, 6,
487 5, 6, 14, 14, 0, 0, 0, 4, 4, 4,
488 21, 9, 14, 0, 0, 0, 4, 4, 8, 0,
489 0, 4, 4, 4, 0, 0, 0, 4, 1, 4,
490
491 4, 0, 1, 0, 0, 4, 2, 0, 2, 0
492 } ;
493
494 static grecs_dhcpdconst YY_CHAR grecs_dhcpd_ec[256] =
495 { 0,
496 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
497 1, 4, 1, 1, 1, 1, 1, 1, 1, 1,
498 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
499 1, 2, 5, 6, 7, 1, 1, 1, 1, 5,
500 5, 8, 1, 5, 9, 10, 11, 12, 13, 13,
501 13, 13, 13, 13, 13, 13, 13, 10, 14, 1,
502 5, 1, 1, 10, 15, 15, 15, 15, 15, 15,
503 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
504 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
505 1, 16, 1, 1, 15, 1, 15, 15, 15, 15,
506
507 17, 18, 15, 15, 19, 15, 15, 20, 15, 21,
508 15, 15, 15, 15, 22, 15, 15, 15, 15, 15,
509 15, 15, 23, 1, 5, 1, 1, 1, 1, 1,
510 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
511 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
512 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
513 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
514 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
515 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
516 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
517
518 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
519 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
520 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
521 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
522 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
523 1, 1, 1, 1, 1
524 } ;
525
526 static grecs_dhcpdconst YY_CHAR grecs_dhcpd_meta[24] =
527 { 0,
528 1, 1, 2, 1, 1, 3, 1, 4, 5, 5,
529 5, 5, 5, 1, 5, 1, 5, 5, 5, 5,
530 5, 5, 1
531 } ;
532
533 static grecs_dhcpdconst flex_uint16_t grecs_dhcpd_base[134] =
534 { 0,
535 0, 22, 0, 0, 22, 24, 23, 28, 29, 30,
536 291, 292, 32, 292, 292, 36, 287, 0, 278, 37,
537 39, 17, 51, 58, 292, 51, 292, 53, 0, 42,
538 292, 292, 59, 292, 292, 62, 69, 292, 292, 285,
539 284, 292, 0, 85, 66, 101, 264, 77, 108, 127,
540 146, 112, 110, 292, 292, 0, 67, 292, 282, 292,
541 111, 292, 292, 119, 292, 292, 292, 292, 0, 281,
542 292, 0, 238, 119, 122, 141, 207, 149, 158, 116,
543 292, 200, 128, 160, 155, 144, 114, 65, 142, 157,
544 139, 166, 170, 142, 133, 171, 130, 172, 292, 176,
545
546 124, 177, 292, 178, 122, 115, 292, 77, 292, 292,
547 184, 189, 194, 199, 204, 209, 58, 36, 214, 219,
548 224, 229, 234, 239, 241, 243, 248, 253, 258, 263,
549 268, 273, 278
550 } ;
551
552 static grecs_dhcpdconst flex_int16_t grecs_dhcpd_def[134] =
553 { 0,
554 110, 1, 111, 111, 112, 112, 113, 113, 114, 114,
555 110, 110, 110, 110, 110, 115, 116, 117, 117, 118,
556 118, 21, 110, 116, 110, 119, 110, 120, 121, 122,
557 110, 110, 123, 110, 110, 110, 115, 110, 110, 124,
558 116, 110, 125, 110, 126, 126, 46, 110, 110, 116,
559 116, 116, 119, 110, 110, 121, 120, 110, 110, 110,
560 122, 110, 110, 123, 110, 110, 110, 110, 125, 127,
561 110, 44, 46, 46, 110, 110, 110, 116, 116, 116,
562 110, 46, 46, 110, 110, 110, 128, 116, 46, 129,
563 110, 128, 130, 116, 129, 131, 110, 130, 110, 130,
564
565 132, 131, 110, 131, 133, 132, 110, 133, 110, 0,
566 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
567 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
568 110, 110, 110
569 } ;
570
571 static grecs_dhcpdconst flex_uint16_t grecs_dhcpd_nxt[316] =
572 { 0,
573 12, 13, 14, 13, 15, 16, 17, 18, 18, 18,
574 19, 18, 18, 15, 20, 12, 21, 20, 22, 20,
575 20, 20, 15, 23, 27, 31, 27, 28, 24, 28,
576 31, 34, 34, 36, 47, 36, 45, 29, 38, 29,
577 45, 39, 35, 35, 62, 32, 43, 43, 43, 43,
578 32, 40, 48, 54, 36, 58, 55, 49, 46, 50,
579 42, 65, 43, 36, 63, 36, 56, 42, 59, 58,
580 51, 38, 66, 69, 39, 69, 69, 52, 48, 109,
581 36, 94, 59, 49, 40, 70, 70, 71, 70, 70,
582 70, 70, 72, 72, 72, 72, 72, 72, 70, 72,
583
584 70, 72, 72, 72, 72, 72, 72, 70, 69, 75,
585 69, 69, 54, 62, 42, 55, 42, 107, 42, 93,
586 76, 65, 74, 75, 109, 56, 107, 77, 50, 42,
587 80, 105, 66, 63, 76, 82, 88, 83, 96, 51,
588 73, 77, 84, 101, 42, 89, 52, 78, 42, 73,
589 78, 42, 85, 85, 87, 97, 84, 79, 79, 78,
590 42, 84, 96, 73, 91, 90, 85, 85, 42, 79,
591 79, 93, 99, 103, 99, 100, 104, 100, 99, 103,
592 103, 100, 104, 104, 25, 25, 25, 25, 25, 26,
593 26, 26, 26, 26, 30, 30, 30, 30, 30, 33,
594
595 33, 33, 33, 33, 37, 37, 37, 37, 37, 41,
596 41, 41, 41, 41, 53, 53, 53, 53, 53, 57,
597 57, 73, 57, 57, 60, 86, 60, 60, 60, 61,
598 61, 61, 61, 61, 64, 64, 64, 64, 64, 67,
599 67, 67, 67, 67, 69, 69, 73, 73, 70, 70,
600 70, 70, 70, 92, 92, 92, 92, 92, 95, 73,
601 95, 95, 95, 98, 98, 98, 98, 98, 102, 102,
602 102, 102, 102, 106, 106, 106, 106, 106, 108, 108,
603 108, 108, 108, 71, 81, 73, 42, 68, 44, 42,
604 110, 11, 110, 110, 110, 110, 110, 110, 110, 110,
605
606 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
607 110, 110, 110, 110, 110
608 } ;
609
610 static grecs_dhcpdconst flex_int16_t grecs_dhcpd_chk[316] =
611 { 0,
612 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
613 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
614 1, 1, 1, 2, 5, 7, 6, 5, 2, 6,
615 8, 9, 10, 13, 22, 13, 22, 5, 16, 6,
616 118, 16, 9, 10, 30, 7, 20, 20, 21, 21,
617 8, 16, 23, 26, 23, 28, 26, 23, 21, 24,
618 24, 33, 117, 36, 30, 36, 26, 88, 28, 57,
619 24, 37, 33, 45, 37, 45, 45, 24, 48, 108,
620 48, 88, 57, 48, 37, 44, 44, 44, 44, 44,
621 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
622
623 44, 44, 44, 44, 44, 44, 44, 44, 46, 49,
624 46, 46, 53, 61, 52, 53, 87, 106, 80, 87,
625 49, 64, 46, 75, 105, 53, 101, 49, 50, 50,
626 52, 97, 64, 61, 75, 74, 80, 74, 95, 50,
627 74, 75, 76, 94, 94, 83, 50, 51, 51, 83,
628 78, 78, 76, 76, 78, 91, 85, 51, 51, 79,
629 79, 84, 90, 89, 86, 84, 85, 85, 92, 79,
630 79, 92, 93, 96, 98, 93, 96, 98, 100, 102,
631 104, 100, 102, 104, 111, 111, 111, 111, 111, 112,
632 112, 112, 112, 112, 113, 113, 113, 113, 113, 114,
633
634 114, 114, 114, 114, 115, 115, 115, 115, 115, 116,
635 116, 116, 116, 116, 119, 119, 119, 119, 119, 120,
636 120, 82, 120, 120, 121, 77, 121, 121, 121, 122,
637 122, 122, 122, 122, 123, 123, 123, 123, 123, 124,
638 124, 124, 124, 124, 125, 125, 126, 126, 127, 127,
639 127, 127, 127, 128, 128, 128, 128, 128, 129, 73,
640 129, 129, 129, 130, 130, 130, 130, 130, 131, 131,
641 131, 131, 131, 132, 132, 132, 132, 132, 133, 133,
642 133, 133, 133, 70, 59, 47, 41, 40, 19, 17,
643 11, 110, 110, 110, 110, 110, 110, 110, 110, 110,
644
645 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
646 110, 110, 110, 110, 110
647 } ;
648
649 static grecs_dhcpd_state_type grecs_dhcpd_last_accepting_state;
650 static char *grecs_dhcpd_last_accepting_cpos;
651
652 extern int grecs_dhcpd_flex_debug;
653 int grecs_dhcpd_flex_debug = 1;
654
655 static grecs_dhcpdconst flex_int16_t grecs_dhcpd_rule_linenum[29] =
656 { 0,
657 57, 61, 66, 67, 68, 69, 70, 71, 72, 74,
658 85, 100, 111, 126, 132, 138, 142, 143, 148, 151,
659 152, 154, 155, 156, 161, 163, 164, 165
660 } ;
661
662 /* The intent behind this definition is that it'll catch
663 * any uses of REJECT which flex missed.
664 */
665 #define REJECT reject_used_but_not_detected
666 #define grecs_dhcpdmore() grecs_dhcpdmore_used_but_not_detected
667 #define YY_MORE_ADJ 0
668 #define YY_RESTORE_YY_MORE_OFFSET
669 char *grecs_dhcpdtext;
670 #line 1 "dhcpd-lex.l"
671 /* grecs - Gray's Extensible Configuration System -*- c -*- */
672 #define YY_NO_INPUT 1
673
674 #line 9 "dhcpd-lex.l"
675 /* grecs - Gray's Extensible Configuration System
676 Copyright (C) 2007-2016 Sergey Poznyakoff
677
678 Grecs is free software; you can redistribute it and/or modify it
679 under the terms of the GNU General Public License as published by the
680 Free Software Foundation; either version 3 of the License, or (at your
681 option) any later version.
682
683 Grecs is distributed in the hope that it will be useful,
684 but WITHOUT ANY WARRANTY; without even the implied warranty of
685 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
686 GNU General Public License for more details.
687
688 You should have received a copy of the GNU General Public License along
689 with Grecs. If not, see <http://www.gnu.org/licenses/>. */
690
691 #include <grecs.h>
692 #include <dhcpd-gram.h>
693 #include <unistd.h>
694 #include <fcntl.h>
695 #include <ctype.h>
696 #include <stdlib.h>
697 #include <errno.h>
698 #include <sys/stat.h>
699
700 #include <wordsplit.h>
701
702 #define YY_USER_ACTION do { \
703 if (YYSTATE == 0) { \
704 grecs_dhcpdlloc.beg = grecs_current_locus_point; \
705 grecs_dhcpdlloc.beg.col++; \
706 } \
707 grecs_current_locus_point.col += grecs_dhcpdleng; \
708 grecs_dhcpdlloc.end = grecs_current_locus_point; \
709 } while (0);
710
711 #define ISWS(c) ((c)==' '||(c)=='\t')
712
713 #line 714 "dhcpd-lex.c"
714
715 #define INITIAL 0
716 #define COMMENT 1
717 #define STR 2
718 #define BOOL 3
719 #define EXPR 4
720
721 #ifndef YY_NO_UNISTD_H
722 /* Special case for "unistd.h", since it is non-ANSI. We include it way
723 * down here because we want the user's section 1 to have been scanned first.
724 * The user has a chance to override it with an option.
725 */
726 /* %if-c-only */
727 #include <unistd.h>
728 /* %endif */
729 /* %if-c++-only */
730 /* %endif */
731 #endif
732
733 #ifndef YY_EXTRA_TYPE
734 #define YY_EXTRA_TYPE void *
735 #endif
736
737 /* %if-c-only Reentrant structure and macros (non-C++). */
738 /* %if-reentrant */
739 /* %if-c-only */
740
741 static int grecs_dhcpd_init_globals (void );
742
743 /* %endif */
744 /* %if-reentrant */
745 /* %endif */
746 /* %endif End reentrant structures and macros. */
747
748 /* Accessor methods to globals.
749 These are made visible to non-reentrant scanners for convenience. */
750
751 int grecs_dhcpdlex_destroy (void );
752
753 int grecs_dhcpdget_debug (void );
754
755 void grecs_dhcpdset_debug (int debug_flag );
756
757 YY_EXTRA_TYPE grecs_dhcpdget_extra (void );
758
759 void grecs_dhcpdset_extra (YY_EXTRA_TYPE user_defined );
760
761 FILE *grecs_dhcpdget_in (void );
762
763 void grecs_dhcpdset_in (FILE * _in_str );
764
765 FILE *grecs_dhcpdget_out (void );
766
767 void grecs_dhcpdset_out (FILE * _out_str );
768
769 grecs_dhcpd_size_t grecs_dhcpdget_leng (void );
770
771 char *grecs_dhcpdget_text (void );
772
773 int grecs_dhcpdget_lineno (void );
774
775 void grecs_dhcpdset_lineno (int _line_number );
776
777 /* %if-bison-bridge */
778 /* %endif */
779
780 /* Macros after this point can all be overridden by user definitions in
781 * section 1.
782 */
783
784 #ifndef YY_SKIP_YYWRAP
785 #ifdef __cplusplus
786 extern "C" int grecs_dhcpdwrap (void );
787 #else
788 extern int grecs_dhcpdwrap (void );
789 #endif
790 #endif
791
792 /* %not-for-header */
793
794 #ifndef YY_NO_UNPUT
795
796 static void grecs_dhcpdunput (int c,char *buf_ptr );
797
798 #endif
799 /* %ok-for-header */
800
801 /* %endif */
802
803 #ifndef grecs_dhcpdtext_ptr
804 static void grecs_dhcpd_flex_strncpy (char *,grecs_dhcpdconst char *,int );
805 #endif
806
807 #ifdef YY_NEED_STRLEN
808 static int grecs_dhcpd_flex_strlen (grecs_dhcpdconst char * );
809 #endif
810
811 #ifndef YY_NO_INPUT
812 /* %if-c-only Standard (non-C++) definition */
813 /* %not-for-header */
814
815 #ifdef __cplusplus
816 static int grecs_dhcpdinput (void );
817 #else
818 static int input (void );
819 #endif
820 /* %ok-for-header */
821
822 /* %endif */
823 #endif
824
825 /* %if-c-only */
826
827 /* %endif */
828
829 /* Amount of stuff to slurp up with each read. */
830 #ifndef YY_READ_BUF_SIZE
831 #ifdef __ia64__
832 /* On IA-64, the buffer size is 16k, not 8k */
833 #define YY_READ_BUF_SIZE 16384
834 #else
835 #define YY_READ_BUF_SIZE 8192
836 #endif /* __ia64__ */
837 #endif
838
839 /* Copy whatever the last rule matched to the standard output. */
840 #ifndef ECHO
841 /* %if-c-only Standard (non-C++) definition */
842 /* This used to be an fputs(), but since the string might contain NUL's,
843 * we now use fwrite().
844 */
845 #define ECHO do { if (fwrite( grecs_dhcpdtext, grecs_dhcpdleng, 1, grecs_dhcpdout )) {} } while (0)
846 /* %endif */
847 /* %if-c++-only C++ definition */
848 /* %endif */
849 #endif
850
851 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
852 * is returned in "result".
853 */
854 #ifndef YY_INPUT
855 #define YY_INPUT(buf,result,max_size) \
856 /* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
857 if ( YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_is_interactive ) \
858 { \
859 int c = '*'; \
860 size_t n; \
861 for ( n = 0; n < max_size && \
862 (c = getc( grecs_dhcpdin )) != EOF && c != '\n'; ++n ) \
863 buf[n] = (char) c; \
864 if ( c == '\n' ) \
865 buf[n++] = (char) c; \
866 if ( c == EOF && ferror( grecs_dhcpdin ) ) \
867 YY_FATAL_ERROR( "input in flex scanner failed" ); \
868 result = n; \
869 } \
870 else \
871 { \
872 errno=0; \
873 while ( (result = fread(buf, 1, max_size, grecs_dhcpdin))==0 && ferror(grecs_dhcpdin)) \
874 { \
875 if( errno != EINTR) \
876 { \
877 YY_FATAL_ERROR( "input in flex scanner failed" ); \
878 break; \
879 } \
880 errno=0; \
881 clearerr(grecs_dhcpdin); \
882 } \
883 }\
884 \
885 /* %if-c++-only C++ definition \ */\
886 /* %endif */
887
888 #endif
889
890 /* No semi-colon after return; correct usage is to write "grecs_dhcpdterminate();" -
891 * we don't want an extra ';' after the "return" because that will cause
892 * some compilers to complain about unreachable statements.
893 */
894 #ifndef grecs_dhcpdterminate
895 #define grecs_dhcpdterminate() return YY_NULL
896 #endif
897
898 /* Number of entries by which start-condition stack grows. */
899 #ifndef YY_START_STACK_INCR
900 #define YY_START_STACK_INCR 25
901 #endif
902
903 /* Report a fatal error. */
904 #ifndef YY_FATAL_ERROR
905 /* %if-c-only */
906 #define YY_FATAL_ERROR(msg) grecs_dhcpd_fatal_error( msg )
907 /* %endif */
908 /* %if-c++-only */
909 /* %endif */
910 #endif
911
912 /* %if-tables-serialization structures and prototypes */
913 /* %not-for-header */
914
915 /* %ok-for-header */
916
917 /* %not-for-header */
918
919 /* %tables-grecs_dhcpddmap generated elements */
920 /* %endif */
921 /* end tables serialization structures and prototypes */
922
923 /* %ok-for-header */
924
925 /* Default declaration of generated scanner - a define so the user can
926 * easily add parameters.
927 */
928 #ifndef YY_DECL
929 #define YY_DECL_IS_OURS 1
930 /* %if-c-only Standard (non-C++) definition */
931
932 extern int grecs_dhcpdlex (void);
933
934 #define YY_DECL int grecs_dhcpdlex (void)
935 /* %endif */
936 /* %if-c++-only C++ definition */
937 /* %endif */
938 #endif /* !YY_DECL */
939
940 /* Code executed at the beginning of each rule, after grecs_dhcpdtext and grecs_dhcpdleng
941 * have been set up.
942 */
943 #ifndef YY_USER_ACTION
944 #define YY_USER_ACTION
945 #endif
946
947 /* Code executed at the end of each rule. */
948 #ifndef YY_BREAK
949 #define YY_BREAK /*LINTED*/break;
950 #endif
951
952 /* %% [6.0] YY_RULE_SETUP definition goes here */
953 #define YY_RULE_SETUP \
954 if ( grecs_dhcpdleng > 0 ) \
955 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_at_bol = \
956 (grecs_dhcpdtext[grecs_dhcpdleng - 1] == '\n'); \
957 YY_USER_ACTION
958
959 /* %not-for-header */
960
961 /** The main scanner function which does all the work.
962 */
963 YY_DECL
964 {
965 grecs_dhcpd_state_type grecs_dhcpd_current_state;
966 char *grecs_dhcpd_cp, *grecs_dhcpd_bp;
967 int grecs_dhcpd_act;
968
969 if ( !(grecs_dhcpd_init) )
970 {
971 (grecs_dhcpd_init) = 1;
972
973 #ifdef YY_USER_INIT
974 YY_USER_INIT;
975 #endif
976
977 if ( ! (grecs_dhcpd_start) )
978 (grecs_dhcpd_start) = 1; /* first start state */
979
980 if ( ! grecs_dhcpdin )
981 /* %if-c-only */
982 grecs_dhcpdin = stdin;
983 /* %endif */
984 /* %if-c++-only */
985 /* %endif */
986
987 if ( ! grecs_dhcpdout )
988 /* %if-c-only */
989 grecs_dhcpdout = stdout;
990 /* %endif */
991 /* %if-c++-only */
992 /* %endif */
993
994 if ( ! YY_CURRENT_BUFFER ) {
995 grecs_dhcpdensure_buffer_stack ();
996 YY_CURRENT_BUFFER_LVALUE =
997 grecs_dhcpd_create_buffer(grecs_dhcpdin,YY_BUF_SIZE );
998 }
999
1000 grecs_dhcpd_load_buffer_state( );
1001 }
1002
1003 {
1004 /* %% [7.0] user's declarations go here */
1005 #line 55 "dhcpd-lex.l"
1006
1007 /* Line directive */
1008 #line 1009 "dhcpd-lex.c"
1009
1010 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
1011 {
1012 /* %% [8.0] grecs_dhcpdmore()-related code goes here */
1013 grecs_dhcpd_cp = (grecs_dhcpd_c_buf_p);
1014
1015 /* Support of grecs_dhcpdtext. */
1016 *grecs_dhcpd_cp = (grecs_dhcpd_hold_char);
1017
1018 /* grecs_dhcpd_bp points to the position in grecs_dhcpd_ch_buf of the start of
1019 * the current run.
1020 */
1021 grecs_dhcpd_bp = grecs_dhcpd_cp;
1022
1023 /* %% [9.0] code to set up and find next match goes here */
1024 grecs_dhcpd_current_state = (grecs_dhcpd_start);
1025 grecs_dhcpd_current_state += YY_AT_BOL();
1026 grecs_dhcpd_match:
1027 do
1028 {
1029 YY_CHAR grecs_dhcpd_c = grecs_dhcpd_ec[YY_SC_TO_UI(*grecs_dhcpd_cp)] ;
1030 if ( grecs_dhcpd_accept[grecs_dhcpd_current_state] )
1031 {
1032 (grecs_dhcpd_last_accepting_state) = grecs_dhcpd_current_state;
1033 (grecs_dhcpd_last_accepting_cpos) = grecs_dhcpd_cp;
1034 }
1035 while ( grecs_dhcpd_chk[grecs_dhcpd_base[grecs_dhcpd_current_state] + grecs_dhcpd_c] != grecs_dhcpd_current_state )
1036 {
1037 grecs_dhcpd_current_state = (int) grecs_dhcpd_def[grecs_dhcpd_current_state];
1038 if ( grecs_dhcpd_current_state >= 111 )
1039 grecs_dhcpd_c = grecs_dhcpd_meta[(unsigned int) grecs_dhcpd_c];
1040 }
1041 grecs_dhcpd_current_state = grecs_dhcpd_nxt[grecs_dhcpd_base[grecs_dhcpd_current_state] + (unsigned int) grecs_dhcpd_c];
1042 ++grecs_dhcpd_cp;
1043 }
1044 while ( grecs_dhcpd_base[grecs_dhcpd_current_state] != 292 );
1045
1046 grecs_dhcpd_find_action:
1047 /* %% [10.0] code to find the action number goes here */
1048 grecs_dhcpd_act = grecs_dhcpd_accept[grecs_dhcpd_current_state];
1049 if ( grecs_dhcpd_act == 0 )
1050 { /* have to back up */
1051 grecs_dhcpd_cp = (grecs_dhcpd_last_accepting_cpos);
1052 grecs_dhcpd_current_state = (grecs_dhcpd_last_accepting_state);
1053 grecs_dhcpd_act = grecs_dhcpd_accept[grecs_dhcpd_current_state];
1054 }
1055
1056 YY_DO_BEFORE_ACTION;
1057
1058 /* %% [11.0] code for grecs_dhcpdlineno update goes here */
1059
1060 do_action: /* This label is used only to access EOF actions. */
1061
1062 /* %% [12.0] debug code goes here */
1063 if ( grecs_dhcpd_flex_debug )
1064 {
1065 if ( grecs_dhcpd_act == 0 )
1066 fprintf( stderr, "--scanner backing up\n" );
1067 else if ( grecs_dhcpd_act < 29 )
1068 fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
1069 (long)grecs_dhcpd_rule_linenum[grecs_dhcpd_act], grecs_dhcpdtext );
1070 else if ( grecs_dhcpd_act == 29 )
1071 fprintf( stderr, "--accepting default rule (\"%s\")\n",
1072 grecs_dhcpdtext );
1073 else if ( grecs_dhcpd_act == 30 )
1074 fprintf( stderr, "--(end of buffer or a NUL)\n" );
1075 else
1076 fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
1077 }
1078
1079 switch ( grecs_dhcpd_act )
1080 { /* beginning of action switch */
1081 /* %% [13.0] actions go here */
1082 case 0: /* must back up */
1083 /* undo the effects of YY_DO_BEFORE_ACTION */
1084 *grecs_dhcpd_cp = (grecs_dhcpd_hold_char);
1085 grecs_dhcpd_cp = (grecs_dhcpd_last_accepting_cpos);
1086 grecs_dhcpd_current_state = (grecs_dhcpd_last_accepting_state);
1087 goto grecs_dhcpd_find_action;
1088
1089 case 1:
1090 /* rule 1 can match eol */
1091 YY_RULE_SETUP
1092 #line 57 "dhcpd-lex.l"
1093 { grecs_parse_line_directive_cpp(grecs_dhcpdtext,
1094 &grecs_dhcpdlloc,
1095 &grecs_current_locus_point,
1096 NULL); }
1097 YY_BREAK
1098 case 2:
1099 /* rule 2 can match eol */
1100 YY_RULE_SETUP
1101 #line 61 "dhcpd-lex.l"
1102 { grecs_parse_line_directive(grecs_dhcpdtext,
1103 &grecs_dhcpdlloc,
1104 &grecs_current_locus_point,
1105 NULL); }
1106 YY_BREAK
1107 /* End-of-line comments */
1108 case 3:
1109 /* rule 3 can match eol */
1110 YY_RULE_SETUP
1111 #line 66 "dhcpd-lex.l"
1112 { grecs_locus_point_advance_line(grecs_current_locus_point); }
1113 YY_BREAK
1114 case 4:
1115 YY_RULE_SETUP
1116 #line 67 "dhcpd-lex.l"
1117 /* end-of-file comment */;
1118 YY_BREAK
1119 case 5:
1120 /* rule 5 can match eol */
1121 YY_RULE_SETUP
1122 #line 68 "dhcpd-lex.l"
1123 { grecs_locus_point_advance_line(grecs_current_locus_point); }
1124 YY_BREAK
1125 case 6:
1126 YY_RULE_SETUP
1127 #line 69 "dhcpd-lex.l"
1128 /* end-of-file comment */;
1129 YY_BREAK
1130 case 7:
1131 YY_RULE_SETUP
1132 #line 70 "dhcpd-lex.l"
1133 return DHCPD_IF;
1134 YY_BREAK
1135 case 8:
1136 YY_RULE_SETUP
1137 #line 71 "dhcpd-lex.l"
1138 return DHCPD_ELSIF;
1139 YY_BREAK
1140 case 9:
1141 YY_RULE_SETUP
1142 #line 72 "dhcpd-lex.l"
1143 return DHCPD_ELSE;
1144 YY_BREAK
1145 case 10:
1146 /* rule 10 can match eol */
1147 YY_RULE_SETUP
1148 #line 74 "dhcpd-lex.l"
1149 {
1150 char *p;
1151 size_t len;
1152 for (p = grecs_dhcpdtext, len = grecs_dhcpdleng - 1; ISWS(*p) && len > 0; p++, len--)
1153 ;
1154 if (len) {
1155 grecs_line_add(p, len);
1156 grecs_line_add(" ", 1);
1157 }
1158 grecs_locus_point_advance_line(grecs_current_locus_point);
1159 }
1160 YY_BREAK
1161 case 11:
1162 YY_RULE_SETUP
1163 #line 85 "dhcpd-lex.l"
1164 {
1165 char *p;
1166 size_t len;
1167
1168 unput('{');
1169 for (p = grecs_dhcpdtext, len = grecs_dhcpdleng - 1; ISWS(*p) && len > 0; p++, len--)
1170 ;
1171 for (; len > 0 && ISWS(p[len-1]); len--)
1172 ;
1173 grecs_line_add(p, len);
1174 BEGIN(INITIAL);
1175 grecs_dhcpdlval.string = grecs_line_finish();
1176 return DHCPD_EXPR;
1177 }
1178 YY_BREAK
1179 case 12:
1180 /* rule 12 can match eol */
1181 YY_RULE_SETUP
1182 #line 100 "dhcpd-lex.l"
1183 {
1184 char *p;
1185 size_t len;
1186 for (p = grecs_dhcpdtext, len = grecs_dhcpdleng - 1; ISWS(*p) && len > 0; p++, len--)
1187 ;
1188 if (len) {
1189 grecs_line_add(p, len);
1190 grecs_line_add(" ", 1);
1191 }
1192 grecs_locus_point_advance_line(grecs_current_locus_point);
1193 }
1194 YY_BREAK
1195 case 13:
1196 YY_RULE_SETUP
1197 #line 111 "dhcpd-lex.l"
1198 {
1199 char *p;
1200 size_t len;
1201
1202 unput(';');
1203 for (p = grecs_dhcpdtext, len = grecs_dhcpdleng - 1; ISWS(*p) && len > 0; p++, len--)
1204 ;
1205 for (; len > 0 && ISWS(p[len-1]); len--)
1206 ;
1207 grecs_line_add(p, len);
1208 BEGIN(INITIAL);
1209 grecs_dhcpdlval.string = grecs_line_finish();
1210 return DHCPD_EXPR;
1211 }
1212 YY_BREAK
1213 /* Identifiers */
1214 case 14:
1215 YY_RULE_SETUP
1216 #line 126 "dhcpd-lex.l"
1217 { grecs_line_begin();
1218 grecs_line_add(grecs_dhcpdtext, grecs_dhcpdleng);
1219 grecs_dhcpdlval.string = grecs_line_finish();
1220 return DHCPD_IDENT;
1221 }
1222 YY_BREAK
1223 /* Strings */
1224 case 15:
1225 YY_RULE_SETUP
1226 #line 132 "dhcpd-lex.l"
1227 {
1228 grecs_line_begin();
1229 grecs_line_add(grecs_dhcpdtext, grecs_dhcpdleng);
1230 grecs_dhcpdlval.string = grecs_line_finish();
1231 return DHCPD_STRING; }
1232 YY_BREAK
1233 /* Quoted strings */
1234 case 16:
1235 YY_RULE_SETUP
1236 #line 138 "dhcpd-lex.l"
1237 { grecs_line_begin();
1238 grecs_line_add(grecs_dhcpdtext + 1, grecs_dhcpdleng - 2);
1239 grecs_dhcpdlval.string = grecs_line_finish();
1240 return DHCPD_STRING; }
1241 YY_BREAK
1242 case 17:
1243 #line 143 "dhcpd-lex.l"
1244 case 18:
1245 /* rule 18 can match eol */
1246 YY_RULE_SETUP
1247 #line 143 "dhcpd-lex.l"
1248 { BEGIN(STR);
1249 grecs_line_begin();
1250 grecs_line_acc_grow_unescape_last(grecs_dhcpdtext + 1,
1251 grecs_dhcpdleng - 1,
1252 &grecs_dhcpdlloc); }
1253 YY_BREAK
1254 case 19:
1255 /* rule 19 can match eol */
1256 YY_RULE_SETUP
1257 #line 148 "dhcpd-lex.l"
1258 { BEGIN(STR);
1259 grecs_line_begin();
1260 grecs_line_acc_grow(grecs_dhcpdtext + 1, grecs_dhcpdleng - 1); }
1261 YY_BREAK
1262 case 20:
1263 #line 152 "dhcpd-lex.l"
1264 case 21:
1265 /* rule 21 can match eol */
1266 YY_RULE_SETUP
1267 #line 152 "dhcpd-lex.l"
1268 { grecs_line_acc_grow_unescape_last(grecs_dhcpdtext, grecs_dhcpdleng,
1269 &grecs_dhcpdlloc); }
1270 YY_BREAK
1271 case 22:
1272 /* rule 22 can match eol */
1273 #line 155 "dhcpd-lex.l"
1274 case 23:
1275 /* rule 23 can match eol */
1276 YY_RULE_SETUP
1277 #line 155 "dhcpd-lex.l"
1278 { grecs_line_acc_grow(grecs_dhcpdtext, grecs_dhcpdleng); }
1279 YY_BREAK
1280 case 24:
1281 YY_RULE_SETUP
1282 #line 156 "dhcpd-lex.l"
1283 { BEGIN(INITIAL);
1284 if (grecs_dhcpdleng > 1)
1285 grecs_line_add(grecs_dhcpdtext, grecs_dhcpdleng - 1);
1286 grecs_dhcpdlval.string = grecs_line_finish();
1287 return DHCPD_STRING; }
1288 YY_BREAK
1289 case 25:
1290 YY_RULE_SETUP
1291 #line 161 "dhcpd-lex.l"
1292 ;
1293 YY_BREAK
1294 /* Other tokens */
1295 case 26:
1296 /* rule 26 can match eol */
1297 YY_RULE_SETUP
1298 #line 163 "dhcpd-lex.l"
1299 { grecs_locus_point_advance_line(grecs_current_locus_point); }
1300 YY_BREAK
1301 case 27:
1302 YY_RULE_SETUP
1303 #line 164 "dhcpd-lex.l"
1304 return grecs_dhcpdtext[0];
1305 YY_BREAK
1306 case 28:
1307 YY_RULE_SETUP
1308 #line 165 "dhcpd-lex.l"
1309 { if (isascii(grecs_dhcpdtext[0]) && isprint(grecs_dhcpdtext[0]))
1310 grecs_error(&grecs_dhcpdlloc, 0,
1311 _("stray character %c"), grecs_dhcpdtext[0]);
1312 else
1313 grecs_error(&grecs_dhcpdlloc, 0, _("stray character \\%03o"),
1314 (unsigned char) grecs_dhcpdtext[0]); }
1315 YY_BREAK
1316 case 29:
1317 YY_RULE_SETUP
1318 #line 171 "dhcpd-lex.l"
1319 ECHO;
1320 YY_BREAK
1321 #line 1322 "dhcpd-lex.c"
1322 case YY_STATE_EOF(INITIAL):
1323 case YY_STATE_EOF(COMMENT):
1324 case YY_STATE_EOF(STR):
1325 case YY_STATE_EOF(BOOL):
1326 case YY_STATE_EOF(EXPR):
1327 grecs_dhcpdterminate();
1328
1329 case YY_END_OF_BUFFER:
1330 {
1331 /* Amount of text matched not including the EOB char. */
1332 int grecs_dhcpd_amount_of_matched_text = (int) (grecs_dhcpd_cp - (grecs_dhcpdtext_ptr)) - 1;
1333
1334 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1335 *grecs_dhcpd_cp = (grecs_dhcpd_hold_char);
1336 YY_RESTORE_YY_MORE_OFFSET
1337
1338 if ( YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_buffer_status == YY_BUFFER_NEW )
1339 {
1340 /* We're scanning a new file or input source. It's
1341 * possible that this happened because the user
1342 * just pointed grecs_dhcpdin at a new source and called
1343 * grecs_dhcpdlex(). If so, then we have to assure
1344 * consistency between YY_CURRENT_BUFFER and our
1345 * globals. Here is the right place to do so, because
1346 * this is the first action (other than possibly a
1347 * back-up) that will match for the new input source.
1348 */
1349 (grecs_dhcpd_n_chars) = YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_n_chars;
1350 /* %if-c-only */
1351 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_input_file = grecs_dhcpdin;
1352 /* %endif */
1353 /* %if-c++-only */
1354 /* %endif */
1355 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_buffer_status = YY_BUFFER_NORMAL;
1356 }
1357
1358 /* Note that here we test for grecs_dhcpd_c_buf_p "<=" to the position
1359 * of the first EOB in the buffer, since grecs_dhcpd_c_buf_p will
1360 * already have been incremented past the NUL character
1361 * (since all states make transitions on EOB to the
1362 * end-of-buffer state). Contrast this with the test
1363 * in input().
1364 */
1365 if ( (grecs_dhcpd_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf[(grecs_dhcpd_n_chars)] )
1366 { /* This was really a NUL. */
1367 grecs_dhcpd_state_type grecs_dhcpd_next_state;
1368
1369 (grecs_dhcpd_c_buf_p) = (grecs_dhcpdtext_ptr) + grecs_dhcpd_amount_of_matched_text;
1370
1371 grecs_dhcpd_current_state = grecs_dhcpd_get_previous_state( );
1372
1373 /* Okay, we're now positioned to make the NUL
1374 * transition. We couldn't have
1375 * grecs_dhcpd_get_previous_state() go ahead and do it
1376 * for us because it doesn't know how to deal
1377 * with the possibility of jamming (and we don't
1378 * want to build jamming into it because then it
1379 * will run more slowly).
1380 */
1381
1382 grecs_dhcpd_next_state = grecs_dhcpd_try_NUL_trans( grecs_dhcpd_current_state );
1383
1384 grecs_dhcpd_bp = (grecs_dhcpdtext_ptr) + YY_MORE_ADJ;
1385
1386 if ( grecs_dhcpd_next_state )
1387 {
1388 /* Consume the NUL. */
1389 grecs_dhcpd_cp = ++(grecs_dhcpd_c_buf_p);
1390 grecs_dhcpd_current_state = grecs_dhcpd_next_state;
1391 goto grecs_dhcpd_match;
1392 }
1393
1394 else
1395 {
1396 /* %% [14.0] code to do back-up for compressed tables and set up grecs_dhcpd_cp goes here */
1397 grecs_dhcpd_cp = (grecs_dhcpd_c_buf_p);
1398 goto grecs_dhcpd_find_action;
1399 }
1400 }
1401
1402 else switch ( grecs_dhcpd_get_next_buffer( ) )
1403 {
1404 case EOB_ACT_END_OF_FILE:
1405 {
1406 (grecs_dhcpd_did_buffer_switch_on_eof) = 0;
1407
1408 if ( grecs_dhcpdwrap( ) )
1409 {
1410 /* Note: because we've taken care in
1411 * grecs_dhcpd_get_next_buffer() to have set up
1412 * grecs_dhcpdtext, we can now set up
1413 * grecs_dhcpd_c_buf_p so that if some total
1414 * hoser (like flex itself) wants to
1415 * call the scanner after we return the
1416 * YY_NULL, it'll still work - another
1417 * YY_NULL will get returned.
1418 */
1419 (grecs_dhcpd_c_buf_p) = (grecs_dhcpdtext_ptr) + YY_MORE_ADJ;
1420
1421 grecs_dhcpd_act = YY_STATE_EOF(YY_START);
1422 goto do_action;
1423 }
1424
1425 else
1426 {
1427 if ( ! (grecs_dhcpd_did_buffer_switch_on_eof) )
1428 YY_NEW_FILE;
1429 }
1430 break;
1431 }
1432
1433 case EOB_ACT_CONTINUE_SCAN:
1434 (grecs_dhcpd_c_buf_p) =
1435 (grecs_dhcpdtext_ptr) + grecs_dhcpd_amount_of_matched_text;
1436
1437 grecs_dhcpd_current_state = grecs_dhcpd_get_previous_state( );
1438
1439 grecs_dhcpd_cp = (grecs_dhcpd_c_buf_p);
1440 grecs_dhcpd_bp = (grecs_dhcpdtext_ptr) + YY_MORE_ADJ;
1441 goto grecs_dhcpd_match;
1442
1443 case EOB_ACT_LAST_MATCH:
1444 (grecs_dhcpd_c_buf_p) =
1445 &YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf[(grecs_dhcpd_n_chars)];
1446
1447 grecs_dhcpd_current_state = grecs_dhcpd_get_previous_state( );
1448
1449 grecs_dhcpd_cp = (grecs_dhcpd_c_buf_p);
1450 grecs_dhcpd_bp = (grecs_dhcpdtext_ptr) + YY_MORE_ADJ;
1451 goto grecs_dhcpd_find_action;
1452 }
1453 break;
1454 }
1455
1456 default:
1457 YY_FATAL_ERROR(
1458 "fatal flex scanner internal error--no action found" );
1459 } /* end of action switch */
1460 } /* end of scanning one token */
1461 } /* end of user's declarations */
1462 } /* end of grecs_dhcpdlex */
1463 /* %ok-for-header */
1464
1465 /* %if-c++-only */
1466 /* %not-for-header */
1467
1468 /* %ok-for-header */
1469
1470 /* %endif */
1471
1472 /* grecs_dhcpd_get_next_buffer - try to read in a new buffer
1473 *
1474 * Returns a code representing an action:
1475 * EOB_ACT_LAST_MATCH -
1476 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1477 * EOB_ACT_END_OF_FILE - end of file
1478 */
1479 /* %if-c-only */
grecs_dhcpd_get_next_buffer(void)1480 static int grecs_dhcpd_get_next_buffer (void)
1481 /* %endif */
1482 /* %if-c++-only */
1483 /* %endif */
1484 {
1485 char *dest = YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf;
1486 char *source = (grecs_dhcpdtext_ptr);
1487 grecs_dhcpd_size_t number_to_move, i;
1488 int ret_val;
1489
1490 if ( (grecs_dhcpd_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf[(grecs_dhcpd_n_chars) + 1] )
1491 YY_FATAL_ERROR(
1492 "fatal flex scanner internal error--end of buffer missed" );
1493
1494 if ( YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_fill_buffer == 0 )
1495 { /* Don't try to fill the buffer, so this is an EOF. */
1496 if ( (grecs_dhcpd_c_buf_p) - (grecs_dhcpdtext_ptr) - YY_MORE_ADJ == 1 )
1497 {
1498 /* We matched a single character, the EOB, so
1499 * treat this as a final EOF.
1500 */
1501 return EOB_ACT_END_OF_FILE;
1502 }
1503
1504 else
1505 {
1506 /* We matched some text prior to the EOB, first
1507 * process it.
1508 */
1509 return EOB_ACT_LAST_MATCH;
1510 }
1511 }
1512
1513 /* Try to read more data. */
1514
1515 /* First move last chars to start of buffer. */
1516 number_to_move = (grecs_dhcpd_size_t) ((grecs_dhcpd_c_buf_p) - (grecs_dhcpdtext_ptr)) - 1;
1517
1518 for ( i = 0; i < number_to_move; ++i )
1519 *(dest++) = *(source++);
1520
1521 if ( YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_buffer_status == YY_BUFFER_EOF_PENDING )
1522 /* don't do the read, it's not guaranteed to return an EOF,
1523 * just force an EOF
1524 */
1525 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_n_chars = (grecs_dhcpd_n_chars) = 0;
1526
1527 else
1528 {
1529 grecs_dhcpd_size_t num_to_read =
1530 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_buf_size - number_to_move - 1;
1531
1532 while ( num_to_read <= 0 )
1533 { /* Not enough room in the buffer - grow it. */
1534
1535 /* just a shorter name for the current buffer */
1536 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1537
1538 int grecs_dhcpd_c_buf_p_offset =
1539 (int) ((grecs_dhcpd_c_buf_p) - b->grecs_dhcpd_ch_buf);
1540
1541 if ( b->grecs_dhcpd_is_our_buffer )
1542 {
1543 grecs_dhcpd_size_t new_size = b->grecs_dhcpd_buf_size * 2;
1544
1545 if ( new_size <= 0 )
1546 b->grecs_dhcpd_buf_size += b->grecs_dhcpd_buf_size / 8;
1547 else
1548 b->grecs_dhcpd_buf_size *= 2;
1549
1550 b->grecs_dhcpd_ch_buf = (char *)
1551 /* Include room in for 2 EOB chars. */
1552 grecs_dhcpdrealloc((void *) b->grecs_dhcpd_ch_buf,b->grecs_dhcpd_buf_size + 2 );
1553 }
1554 else
1555 /* Can't grow it, we don't own it. */
1556 b->grecs_dhcpd_ch_buf = 0;
1557
1558 if ( ! b->grecs_dhcpd_ch_buf )
1559 YY_FATAL_ERROR(
1560 "fatal error - scanner input buffer overflow" );
1561
1562 (grecs_dhcpd_c_buf_p) = &b->grecs_dhcpd_ch_buf[grecs_dhcpd_c_buf_p_offset];
1563
1564 num_to_read = YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_buf_size -
1565 number_to_move - 1;
1566
1567 }
1568
1569 if ( num_to_read > YY_READ_BUF_SIZE )
1570 num_to_read = YY_READ_BUF_SIZE;
1571
1572 /* Read in more data. */
1573 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf[number_to_move]),
1574 (grecs_dhcpd_n_chars), num_to_read );
1575
1576 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_n_chars = (grecs_dhcpd_n_chars);
1577 }
1578
1579 if ( (grecs_dhcpd_n_chars) == 0 )
1580 {
1581 if ( number_to_move == YY_MORE_ADJ )
1582 {
1583 ret_val = EOB_ACT_END_OF_FILE;
1584 grecs_dhcpdrestart(grecs_dhcpdin );
1585 }
1586
1587 else
1588 {
1589 ret_val = EOB_ACT_LAST_MATCH;
1590 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_buffer_status =
1591 YY_BUFFER_EOF_PENDING;
1592 }
1593 }
1594
1595 else
1596 ret_val = EOB_ACT_CONTINUE_SCAN;
1597
1598 if ((grecs_dhcpd_size_t) ((grecs_dhcpd_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_buf_size) {
1599 /* Extend the array by 50%, plus the number we really need. */
1600 grecs_dhcpd_size_t new_size = (grecs_dhcpd_n_chars) + number_to_move + ((grecs_dhcpd_n_chars) >> 1);
1601 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf = (char *) grecs_dhcpdrealloc((void *) YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf,new_size );
1602 if ( ! YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf )
1603 YY_FATAL_ERROR( "out of dynamic memory in grecs_dhcpd_get_next_buffer()" );
1604 }
1605
1606 (grecs_dhcpd_n_chars) += number_to_move;
1607 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf[(grecs_dhcpd_n_chars)] = YY_END_OF_BUFFER_CHAR;
1608 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf[(grecs_dhcpd_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1609
1610 (grecs_dhcpdtext_ptr) = &YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf[0];
1611
1612 return ret_val;
1613 }
1614
1615 /* grecs_dhcpd_get_previous_state - get the state just before the EOB char was reached */
1616
1617 /* %if-c-only */
1618 /* %not-for-header */
1619
grecs_dhcpd_get_previous_state(void)1620 static grecs_dhcpd_state_type grecs_dhcpd_get_previous_state (void)
1621 /* %endif */
1622 /* %if-c++-only */
1623 /* %endif */
1624 {
1625 grecs_dhcpd_state_type grecs_dhcpd_current_state;
1626 char *grecs_dhcpd_cp;
1627
1628 /* %% [15.0] code to get the start state into grecs_dhcpd_current_state goes here */
1629 grecs_dhcpd_current_state = (grecs_dhcpd_start);
1630 grecs_dhcpd_current_state += YY_AT_BOL();
1631
1632 for ( grecs_dhcpd_cp = (grecs_dhcpdtext_ptr) + YY_MORE_ADJ; grecs_dhcpd_cp < (grecs_dhcpd_c_buf_p); ++grecs_dhcpd_cp )
1633 {
1634 /* %% [16.0] code to find the next state goes here */
1635 YY_CHAR grecs_dhcpd_c = (*grecs_dhcpd_cp ? grecs_dhcpd_ec[YY_SC_TO_UI(*grecs_dhcpd_cp)] : 1);
1636 if ( grecs_dhcpd_accept[grecs_dhcpd_current_state] )
1637 {
1638 (grecs_dhcpd_last_accepting_state) = grecs_dhcpd_current_state;
1639 (grecs_dhcpd_last_accepting_cpos) = grecs_dhcpd_cp;
1640 }
1641 while ( grecs_dhcpd_chk[grecs_dhcpd_base[grecs_dhcpd_current_state] + grecs_dhcpd_c] != grecs_dhcpd_current_state )
1642 {
1643 grecs_dhcpd_current_state = (int) grecs_dhcpd_def[grecs_dhcpd_current_state];
1644 if ( grecs_dhcpd_current_state >= 111 )
1645 grecs_dhcpd_c = grecs_dhcpd_meta[(unsigned int) grecs_dhcpd_c];
1646 }
1647 grecs_dhcpd_current_state = grecs_dhcpd_nxt[grecs_dhcpd_base[grecs_dhcpd_current_state] + (unsigned int) grecs_dhcpd_c];
1648 }
1649
1650 return grecs_dhcpd_current_state;
1651 }
1652
1653 /* grecs_dhcpd_try_NUL_trans - try to make a transition on the NUL character
1654 *
1655 * synopsis
1656 * next_state = grecs_dhcpd_try_NUL_trans( current_state );
1657 */
1658 /* %if-c-only */
grecs_dhcpd_try_NUL_trans(grecs_dhcpd_state_type grecs_dhcpd_current_state)1659 static grecs_dhcpd_state_type grecs_dhcpd_try_NUL_trans (grecs_dhcpd_state_type grecs_dhcpd_current_state )
1660 /* %endif */
1661 /* %if-c++-only */
1662 /* %endif */
1663 {
1664 int grecs_dhcpd_is_jam;
1665 /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
1666 char *grecs_dhcpd_cp = (grecs_dhcpd_c_buf_p);
1667
1668 YY_CHAR grecs_dhcpd_c = 1;
1669 if ( grecs_dhcpd_accept[grecs_dhcpd_current_state] )
1670 {
1671 (grecs_dhcpd_last_accepting_state) = grecs_dhcpd_current_state;
1672 (grecs_dhcpd_last_accepting_cpos) = grecs_dhcpd_cp;
1673 }
1674 while ( grecs_dhcpd_chk[grecs_dhcpd_base[grecs_dhcpd_current_state] + grecs_dhcpd_c] != grecs_dhcpd_current_state )
1675 {
1676 grecs_dhcpd_current_state = (int) grecs_dhcpd_def[grecs_dhcpd_current_state];
1677 if ( grecs_dhcpd_current_state >= 111 )
1678 grecs_dhcpd_c = grecs_dhcpd_meta[(unsigned int) grecs_dhcpd_c];
1679 }
1680 grecs_dhcpd_current_state = grecs_dhcpd_nxt[grecs_dhcpd_base[grecs_dhcpd_current_state] + (unsigned int) grecs_dhcpd_c];
1681 grecs_dhcpd_is_jam = (grecs_dhcpd_current_state == 110);
1682
1683 return grecs_dhcpd_is_jam ? 0 : grecs_dhcpd_current_state;
1684 }
1685
1686 #ifndef YY_NO_UNPUT
1687 /* %if-c-only */
1688
grecs_dhcpdunput(int c,char * grecs_dhcpd_bp)1689 static void grecs_dhcpdunput (int c, char * grecs_dhcpd_bp )
1690 /* %endif */
1691 /* %if-c++-only */
1692 /* %endif */
1693 {
1694 char *grecs_dhcpd_cp;
1695
1696 grecs_dhcpd_cp = (grecs_dhcpd_c_buf_p);
1697
1698 /* undo effects of setting up grecs_dhcpdtext */
1699 *grecs_dhcpd_cp = (grecs_dhcpd_hold_char);
1700
1701 if ( grecs_dhcpd_cp < YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf + 2 )
1702 { /* need to shift things up to make room */
1703 /* +2 for EOB chars. */
1704 grecs_dhcpd_size_t number_to_move = (grecs_dhcpd_n_chars) + 2;
1705 char *dest = &YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf[
1706 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_buf_size + 2];
1707 char *source =
1708 &YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf[number_to_move];
1709
1710 while ( source > YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf )
1711 *--dest = *--source;
1712
1713 grecs_dhcpd_cp += (int) (dest - source);
1714 grecs_dhcpd_bp += (int) (dest - source);
1715 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_n_chars =
1716 (grecs_dhcpd_n_chars) = YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_buf_size;
1717
1718 if ( grecs_dhcpd_cp < YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf + 2 )
1719 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1720 }
1721
1722 *--grecs_dhcpd_cp = (char) c;
1723
1724 /* %% [18.0] update grecs_dhcpdlineno here */
1725
1726 (grecs_dhcpdtext_ptr) = grecs_dhcpd_bp;
1727 (grecs_dhcpd_hold_char) = *grecs_dhcpd_cp;
1728 (grecs_dhcpd_c_buf_p) = grecs_dhcpd_cp;
1729 }
1730 /* %if-c-only */
1731
1732 /* %endif */
1733 #endif
1734
1735 /* %if-c-only */
1736 #ifndef YY_NO_INPUT
1737 #ifdef __cplusplus
grecs_dhcpdinput(void)1738 static int grecs_dhcpdinput (void)
1739 #else
1740 static int input (void)
1741 #endif
1742
1743 /* %endif */
1744 /* %if-c++-only */
1745 /* %endif */
1746 {
1747 int c;
1748
1749 *(grecs_dhcpd_c_buf_p) = (grecs_dhcpd_hold_char);
1750
1751 if ( *(grecs_dhcpd_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1752 {
1753 /* grecs_dhcpd_c_buf_p now points to the character we want to return.
1754 * If this occurs *before* the EOB characters, then it's a
1755 * valid NUL; if not, then we've hit the end of the buffer.
1756 */
1757 if ( (grecs_dhcpd_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_ch_buf[(grecs_dhcpd_n_chars)] )
1758 /* This was really a NUL. */
1759 *(grecs_dhcpd_c_buf_p) = '\0';
1760
1761 else
1762 { /* need more input */
1763 grecs_dhcpd_size_t offset = (grecs_dhcpd_c_buf_p) - (grecs_dhcpdtext_ptr);
1764 ++(grecs_dhcpd_c_buf_p);
1765
1766 switch ( grecs_dhcpd_get_next_buffer( ) )
1767 {
1768 case EOB_ACT_LAST_MATCH:
1769 /* This happens because grecs_dhcpd_g_n_b()
1770 * sees that we've accumulated a
1771 * token and flags that we need to
1772 * try matching the token before
1773 * proceeding. But for input(),
1774 * there's no matching to consider.
1775 * So convert the EOB_ACT_LAST_MATCH
1776 * to EOB_ACT_END_OF_FILE.
1777 */
1778
1779 /* Reset buffer status. */
1780 grecs_dhcpdrestart(grecs_dhcpdin );
1781
1782 /*FALLTHROUGH*/
1783
1784 case EOB_ACT_END_OF_FILE:
1785 {
1786 if ( grecs_dhcpdwrap( ) )
1787 return EOF;
1788
1789 if ( ! (grecs_dhcpd_did_buffer_switch_on_eof) )
1790 YY_NEW_FILE;
1791 #ifdef __cplusplus
1792 return grecs_dhcpdinput();
1793 #else
1794 return input();
1795 #endif
1796 }
1797
1798 case EOB_ACT_CONTINUE_SCAN:
1799 (grecs_dhcpd_c_buf_p) = (grecs_dhcpdtext_ptr) + offset;
1800 break;
1801 }
1802 }
1803 }
1804
1805 c = *(unsigned char *) (grecs_dhcpd_c_buf_p); /* cast for 8-bit char's */
1806 *(grecs_dhcpd_c_buf_p) = '\0'; /* preserve grecs_dhcpdtext */
1807 (grecs_dhcpd_hold_char) = *++(grecs_dhcpd_c_buf_p);
1808
1809 /* %% [19.0] update BOL and grecs_dhcpdlineno */
1810 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_at_bol = (c == '\n');
1811
1812 return c;
1813 }
1814 /* %if-c-only */
1815 #endif /* ifndef YY_NO_INPUT */
1816 /* %endif */
1817
1818 /** Immediately switch to a different input stream.
1819 * @param input_file A readable stream.
1820 *
1821 * @note This function does not reset the start condition to @c INITIAL .
1822 */
1823 /* %if-c-only */
grecs_dhcpdrestart(FILE * input_file)1824 void grecs_dhcpdrestart (FILE * input_file )
1825 /* %endif */
1826 /* %if-c++-only */
1827 /* %endif */
1828 {
1829
1830 if ( ! YY_CURRENT_BUFFER ){
1831 grecs_dhcpdensure_buffer_stack ();
1832 YY_CURRENT_BUFFER_LVALUE =
1833 grecs_dhcpd_create_buffer(grecs_dhcpdin,YY_BUF_SIZE );
1834 }
1835
1836 grecs_dhcpd_init_buffer(YY_CURRENT_BUFFER,input_file );
1837 grecs_dhcpd_load_buffer_state( );
1838 }
1839
1840 /* %if-c++-only */
1841 /* %endif */
1842
1843 /** Switch to a different input buffer.
1844 * @param new_buffer The new input buffer.
1845 *
1846 */
1847 /* %if-c-only */
grecs_dhcpd_switch_to_buffer(YY_BUFFER_STATE new_buffer)1848 void grecs_dhcpd_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1849 /* %endif */
1850 /* %if-c++-only */
1851 /* %endif */
1852 {
1853
1854 /* TODO. We should be able to replace this entire function body
1855 * with
1856 * grecs_dhcpdpop_buffer_state();
1857 * grecs_dhcpdpush_buffer_state(new_buffer);
1858 */
1859 grecs_dhcpdensure_buffer_stack ();
1860 if ( YY_CURRENT_BUFFER == new_buffer )
1861 return;
1862
1863 if ( YY_CURRENT_BUFFER )
1864 {
1865 /* Flush out information for old buffer. */
1866 *(grecs_dhcpd_c_buf_p) = (grecs_dhcpd_hold_char);
1867 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_buf_pos = (grecs_dhcpd_c_buf_p);
1868 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_n_chars = (grecs_dhcpd_n_chars);
1869 }
1870
1871 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1872 grecs_dhcpd_load_buffer_state( );
1873
1874 /* We don't actually know whether we did this switch during
1875 * EOF (grecs_dhcpdwrap()) processing, but the only time this flag
1876 * is looked at is after grecs_dhcpdwrap() is called, so it's safe
1877 * to go ahead and always set it.
1878 */
1879 (grecs_dhcpd_did_buffer_switch_on_eof) = 1;
1880 }
1881
1882 /* %if-c-only */
grecs_dhcpd_load_buffer_state(void)1883 static void grecs_dhcpd_load_buffer_state (void)
1884 /* %endif */
1885 /* %if-c++-only */
1886 /* %endif */
1887 {
1888 (grecs_dhcpd_n_chars) = YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_n_chars;
1889 (grecs_dhcpdtext_ptr) = (grecs_dhcpd_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_buf_pos;
1890 /* %if-c-only */
1891 grecs_dhcpdin = YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_input_file;
1892 /* %endif */
1893 /* %if-c++-only */
1894 /* %endif */
1895 (grecs_dhcpd_hold_char) = *(grecs_dhcpd_c_buf_p);
1896 }
1897
1898 /** Allocate and initialize an input buffer state.
1899 * @param file A readable stream.
1900 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1901 *
1902 * @return the allocated buffer state.
1903 */
1904 /* %if-c-only */
grecs_dhcpd_create_buffer(FILE * file,int size)1905 YY_BUFFER_STATE grecs_dhcpd_create_buffer (FILE * file, int size )
1906 /* %endif */
1907 /* %if-c++-only */
1908 /* %endif */
1909 {
1910 YY_BUFFER_STATE b;
1911
1912 b = (YY_BUFFER_STATE) grecs_dhcpdalloc(sizeof( struct grecs_dhcpd_buffer_state ) );
1913 if ( ! b )
1914 YY_FATAL_ERROR( "out of dynamic memory in grecs_dhcpd_create_buffer()" );
1915
1916 b->grecs_dhcpd_buf_size = (grecs_dhcpd_size_t)size;
1917
1918 /* grecs_dhcpd_ch_buf has to be 2 characters longer than the size given because
1919 * we need to put in 2 end-of-buffer characters.
1920 */
1921 b->grecs_dhcpd_ch_buf = (char *) grecs_dhcpdalloc(b->grecs_dhcpd_buf_size + 2 );
1922 if ( ! b->grecs_dhcpd_ch_buf )
1923 YY_FATAL_ERROR( "out of dynamic memory in grecs_dhcpd_create_buffer()" );
1924
1925 b->grecs_dhcpd_is_our_buffer = 1;
1926
1927 grecs_dhcpd_init_buffer(b,file );
1928
1929 return b;
1930 }
1931
1932 /* %if-c++-only */
1933 /* %endif */
1934
1935 /** Destroy the buffer.
1936 * @param b a buffer created with grecs_dhcpd_create_buffer()
1937 *
1938 */
1939 /* %if-c-only */
grecs_dhcpd_delete_buffer(YY_BUFFER_STATE b)1940 void grecs_dhcpd_delete_buffer (YY_BUFFER_STATE b )
1941 /* %endif */
1942 /* %if-c++-only */
1943 /* %endif */
1944 {
1945
1946 if ( ! b )
1947 return;
1948
1949 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1950 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1951
1952 if ( b->grecs_dhcpd_is_our_buffer )
1953 grecs_dhcpdfree((void *) b->grecs_dhcpd_ch_buf );
1954
1955 grecs_dhcpdfree((void *) b );
1956 }
1957
1958 /* Initializes or reinitializes a buffer.
1959 * This function is sometimes called more than once on the same buffer,
1960 * such as during a grecs_dhcpdrestart() or at EOF.
1961 */
1962 /* %if-c-only */
grecs_dhcpd_init_buffer(YY_BUFFER_STATE b,FILE * file)1963 static void grecs_dhcpd_init_buffer (YY_BUFFER_STATE b, FILE * file )
1964 /* %endif */
1965 /* %if-c++-only */
1966 /* %endif */
1967
1968 {
1969 int oerrno = errno;
1970
1971 grecs_dhcpd_flush_buffer(b );
1972
1973 /* %if-c-only */
1974 b->grecs_dhcpd_input_file = file;
1975 /* %endif */
1976 /* %if-c++-only */
1977 /* %endif */
1978 b->grecs_dhcpd_fill_buffer = 1;
1979
1980 /* If b is the current buffer, then grecs_dhcpd_init_buffer was _probably_
1981 * called from grecs_dhcpdrestart() or through grecs_dhcpd_get_next_buffer.
1982 * In that case, we don't want to reset the lineno or column.
1983 */
1984 if (b != YY_CURRENT_BUFFER){
1985 b->grecs_dhcpd_bs_lineno = 1;
1986 b->grecs_dhcpd_bs_column = 0;
1987 }
1988
1989 /* %if-c-only */
1990
1991 b->grecs_dhcpd_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1992
1993 /* %endif */
1994 /* %if-c++-only */
1995 /* %endif */
1996 errno = oerrno;
1997 }
1998
1999 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2000 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2001 *
2002 */
2003 /* %if-c-only */
grecs_dhcpd_flush_buffer(YY_BUFFER_STATE b)2004 void grecs_dhcpd_flush_buffer (YY_BUFFER_STATE b )
2005 /* %endif */
2006 /* %if-c++-only */
2007 /* %endif */
2008 {
2009 if ( ! b )
2010 return;
2011
2012 b->grecs_dhcpd_n_chars = 0;
2013
2014 /* We always need two end-of-buffer characters. The first causes
2015 * a transition to the end-of-buffer state. The second causes
2016 * a jam in that state.
2017 */
2018 b->grecs_dhcpd_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2019 b->grecs_dhcpd_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2020
2021 b->grecs_dhcpd_buf_pos = &b->grecs_dhcpd_ch_buf[0];
2022
2023 b->grecs_dhcpd_at_bol = 1;
2024 b->grecs_dhcpd_buffer_status = YY_BUFFER_NEW;
2025
2026 if ( b == YY_CURRENT_BUFFER )
2027 grecs_dhcpd_load_buffer_state( );
2028 }
2029
2030 /* %if-c-or-c++ */
2031 /** Pushes the new state onto the stack. The new state becomes
2032 * the current state. This function will allocate the stack
2033 * if necessary.
2034 * @param new_buffer The new state.
2035 *
2036 */
2037 /* %if-c-only */
grecs_dhcpdpush_buffer_state(YY_BUFFER_STATE new_buffer)2038 void grecs_dhcpdpush_buffer_state (YY_BUFFER_STATE new_buffer )
2039 /* %endif */
2040 /* %if-c++-only */
2041 /* %endif */
2042 {
2043 if (new_buffer == NULL)
2044 return;
2045
2046 grecs_dhcpdensure_buffer_stack();
2047
2048 /* This block is copied from grecs_dhcpd_switch_to_buffer. */
2049 if ( YY_CURRENT_BUFFER )
2050 {
2051 /* Flush out information for old buffer. */
2052 *(grecs_dhcpd_c_buf_p) = (grecs_dhcpd_hold_char);
2053 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_buf_pos = (grecs_dhcpd_c_buf_p);
2054 YY_CURRENT_BUFFER_LVALUE->grecs_dhcpd_n_chars = (grecs_dhcpd_n_chars);
2055 }
2056
2057 /* Only push if top exists. Otherwise, replace top. */
2058 if (YY_CURRENT_BUFFER)
2059 (grecs_dhcpd_buffer_stack_top)++;
2060 YY_CURRENT_BUFFER_LVALUE = new_buffer;
2061
2062 /* copied from grecs_dhcpd_switch_to_buffer. */
2063 grecs_dhcpd_load_buffer_state( );
2064 (grecs_dhcpd_did_buffer_switch_on_eof) = 1;
2065 }
2066 /* %endif */
2067
2068 /* %if-c-or-c++ */
2069 /** Removes and deletes the top of the stack, if present.
2070 * The next element becomes the new top.
2071 *
2072 */
2073 /* %if-c-only */
grecs_dhcpdpop_buffer_state(void)2074 void grecs_dhcpdpop_buffer_state (void)
2075 /* %endif */
2076 /* %if-c++-only */
2077 /* %endif */
2078 {
2079 if (!YY_CURRENT_BUFFER)
2080 return;
2081
2082 grecs_dhcpd_delete_buffer(YY_CURRENT_BUFFER );
2083 YY_CURRENT_BUFFER_LVALUE = NULL;
2084 if ((grecs_dhcpd_buffer_stack_top) > 0)
2085 --(grecs_dhcpd_buffer_stack_top);
2086
2087 if (YY_CURRENT_BUFFER) {
2088 grecs_dhcpd_load_buffer_state( );
2089 (grecs_dhcpd_did_buffer_switch_on_eof) = 1;
2090 }
2091 }
2092 /* %endif */
2093
2094 /* %if-c-or-c++ */
2095 /* Allocates the stack if it does not exist.
2096 * Guarantees space for at least one push.
2097 */
2098 /* %if-c-only */
grecs_dhcpdensure_buffer_stack(void)2099 static void grecs_dhcpdensure_buffer_stack (void)
2100 /* %endif */
2101 /* %if-c++-only */
2102 /* %endif */
2103 {
2104 grecs_dhcpd_size_t num_to_alloc;
2105
2106 if (!(grecs_dhcpd_buffer_stack)) {
2107
2108 /* First allocation is just for 2 elements, since we don't know if this
2109 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2110 * immediate realloc on the next call.
2111 */
2112 num_to_alloc = 1; // After all that talk, this was set to 1 anyways...
2113 (grecs_dhcpd_buffer_stack) = (struct grecs_dhcpd_buffer_state**)grecs_dhcpdalloc
2114 (num_to_alloc * sizeof(struct grecs_dhcpd_buffer_state*)
2115 );
2116 if ( ! (grecs_dhcpd_buffer_stack) )
2117 YY_FATAL_ERROR( "out of dynamic memory in grecs_dhcpdensure_buffer_stack()" );
2118
2119 memset((grecs_dhcpd_buffer_stack), 0, num_to_alloc * sizeof(struct grecs_dhcpd_buffer_state*));
2120
2121 (grecs_dhcpd_buffer_stack_max) = num_to_alloc;
2122 (grecs_dhcpd_buffer_stack_top) = 0;
2123 return;
2124 }
2125
2126 if ((grecs_dhcpd_buffer_stack_top) >= ((grecs_dhcpd_buffer_stack_max)) - 1){
2127
2128 /* Increase the buffer to prepare for a possible push. */
2129 grecs_dhcpd_size_t grow_size = 8 /* arbitrary grow size */;
2130
2131 num_to_alloc = (grecs_dhcpd_buffer_stack_max) + grow_size;
2132 (grecs_dhcpd_buffer_stack) = (struct grecs_dhcpd_buffer_state**)grecs_dhcpdrealloc
2133 ((grecs_dhcpd_buffer_stack),
2134 num_to_alloc * sizeof(struct grecs_dhcpd_buffer_state*)
2135 );
2136 if ( ! (grecs_dhcpd_buffer_stack) )
2137 YY_FATAL_ERROR( "out of dynamic memory in grecs_dhcpdensure_buffer_stack()" );
2138
2139 /* zero only the new slots.*/
2140 memset((grecs_dhcpd_buffer_stack) + (grecs_dhcpd_buffer_stack_max), 0, grow_size * sizeof(struct grecs_dhcpd_buffer_state*));
2141 (grecs_dhcpd_buffer_stack_max) = num_to_alloc;
2142 }
2143 }
2144 /* %endif */
2145
2146 /* %if-c-only */
2147 /** Setup the input buffer state to scan directly from a user-specified character buffer.
2148 * @param base the character buffer
2149 * @param size the size in bytes of the character buffer
2150 *
2151 * @return the newly allocated buffer state object.
2152 */
grecs_dhcpd_scan_buffer(char * base,grecs_dhcpd_size_t size)2153 YY_BUFFER_STATE grecs_dhcpd_scan_buffer (char * base, grecs_dhcpd_size_t size )
2154 {
2155 YY_BUFFER_STATE b;
2156
2157 if ( size < 2 ||
2158 base[size-2] != YY_END_OF_BUFFER_CHAR ||
2159 base[size-1] != YY_END_OF_BUFFER_CHAR )
2160 /* They forgot to leave room for the EOB's. */
2161 return 0;
2162
2163 b = (YY_BUFFER_STATE) grecs_dhcpdalloc(sizeof( struct grecs_dhcpd_buffer_state ) );
2164 if ( ! b )
2165 YY_FATAL_ERROR( "out of dynamic memory in grecs_dhcpd_scan_buffer()" );
2166
2167 b->grecs_dhcpd_buf_size = size - 2; /* "- 2" to take care of EOB's */
2168 b->grecs_dhcpd_buf_pos = b->grecs_dhcpd_ch_buf = base;
2169 b->grecs_dhcpd_is_our_buffer = 0;
2170 b->grecs_dhcpd_input_file = 0;
2171 b->grecs_dhcpd_n_chars = b->grecs_dhcpd_buf_size;
2172 b->grecs_dhcpd_is_interactive = 0;
2173 b->grecs_dhcpd_at_bol = 1;
2174 b->grecs_dhcpd_fill_buffer = 0;
2175 b->grecs_dhcpd_buffer_status = YY_BUFFER_NEW;
2176
2177 grecs_dhcpd_switch_to_buffer(b );
2178
2179 return b;
2180 }
2181 /* %endif */
2182
2183 /* %if-c-only */
2184 /** Setup the input buffer state to scan a string. The next call to grecs_dhcpdlex() will
2185 * scan from a @e copy of @a str.
2186 * @param grecs_dhcpdstr a NUL-terminated string to scan
2187 *
2188 * @return the newly allocated buffer state object.
2189 * @note If you want to scan bytes that may contain NUL values, then use
2190 * grecs_dhcpd_scan_bytes() instead.
2191 */
grecs_dhcpd_scan_string(grecs_dhcpdconst char * grecs_dhcpdstr)2192 YY_BUFFER_STATE grecs_dhcpd_scan_string (grecs_dhcpdconst char * grecs_dhcpdstr )
2193 {
2194
2195 return grecs_dhcpd_scan_bytes(grecs_dhcpdstr,strlen(grecs_dhcpdstr) );
2196 }
2197 /* %endif */
2198
2199 /* %if-c-only */
2200 /** Setup the input buffer state to scan the given bytes. The next call to grecs_dhcpdlex() will
2201 * scan from a @e copy of @a bytes.
2202 * @param grecs_dhcpdbytes the byte buffer to scan
2203 * @param _grecs_dhcpdbytes_len the number of bytes in the buffer pointed to by @a bytes.
2204 *
2205 * @return the newly allocated buffer state object.
2206 */
grecs_dhcpd_scan_bytes(grecs_dhcpdconst char * grecs_dhcpdbytes,grecs_dhcpd_size_t _grecs_dhcpdbytes_len)2207 YY_BUFFER_STATE grecs_dhcpd_scan_bytes (grecs_dhcpdconst char * grecs_dhcpdbytes, grecs_dhcpd_size_t _grecs_dhcpdbytes_len )
2208 {
2209 YY_BUFFER_STATE b;
2210 char *buf;
2211 grecs_dhcpd_size_t n;
2212 grecs_dhcpd_size_t i;
2213
2214 /* Get memory for full buffer, including space for trailing EOB's. */
2215 n = _grecs_dhcpdbytes_len + 2;
2216 buf = (char *) grecs_dhcpdalloc(n );
2217 if ( ! buf )
2218 YY_FATAL_ERROR( "out of dynamic memory in grecs_dhcpd_scan_bytes()" );
2219
2220 for ( i = 0; i < _grecs_dhcpdbytes_len; ++i )
2221 buf[i] = grecs_dhcpdbytes[i];
2222
2223 buf[_grecs_dhcpdbytes_len] = buf[_grecs_dhcpdbytes_len+1] = YY_END_OF_BUFFER_CHAR;
2224
2225 b = grecs_dhcpd_scan_buffer(buf,n );
2226 if ( ! b )
2227 YY_FATAL_ERROR( "bad buffer in grecs_dhcpd_scan_bytes()" );
2228
2229 /* It's okay to grow etc. this buffer, and we should throw it
2230 * away when we're done.
2231 */
2232 b->grecs_dhcpd_is_our_buffer = 1;
2233
2234 return b;
2235 }
2236 /* %endif */
2237
2238 #ifndef YY_EXIT_FAILURE
2239 #define YY_EXIT_FAILURE 2
2240 #endif
2241
2242 /* %if-c-only */
grecs_dhcpd_fatal_error(grecs_dhcpdconst char * msg)2243 static void grecs_dhcpd_fatal_error (grecs_dhcpdconst char* msg )
2244 {
2245 (void) fprintf( stderr, "%s\n", msg );
2246 exit( YY_EXIT_FAILURE );
2247 }
2248 /* %endif */
2249 /* %if-c++-only */
2250 /* %endif */
2251
2252 /* Redefine grecs_dhcpdless() so it works in section 3 code. */
2253
2254 #undef grecs_dhcpdless
2255 #define grecs_dhcpdless(n) \
2256 do \
2257 { \
2258 /* Undo effects of setting up grecs_dhcpdtext. */ \
2259 int grecs_dhcpdless_macro_arg = (n); \
2260 YY_LESS_LINENO(grecs_dhcpdless_macro_arg);\
2261 grecs_dhcpdtext[grecs_dhcpdleng] = (grecs_dhcpd_hold_char); \
2262 (grecs_dhcpd_c_buf_p) = grecs_dhcpdtext + grecs_dhcpdless_macro_arg; \
2263 (grecs_dhcpd_hold_char) = *(grecs_dhcpd_c_buf_p); \
2264 *(grecs_dhcpd_c_buf_p) = '\0'; \
2265 grecs_dhcpdleng = grecs_dhcpdless_macro_arg; \
2266 } \
2267 while ( 0 )
2268
2269 /* Accessor methods (get/set functions) to struct members. */
2270
2271 /* %if-c-only */
2272 /* %if-reentrant */
2273 /* %endif */
2274
2275 /** Get the current line number.
2276 *
2277 */
grecs_dhcpdget_lineno(void)2278 int grecs_dhcpdget_lineno (void)
2279 {
2280
2281 return grecs_dhcpdlineno;
2282 }
2283
2284 /** Get the input stream.
2285 *
2286 */
grecs_dhcpdget_in(void)2287 FILE *grecs_dhcpdget_in (void)
2288 {
2289 return grecs_dhcpdin;
2290 }
2291
2292 /** Get the output stream.
2293 *
2294 */
grecs_dhcpdget_out(void)2295 FILE *grecs_dhcpdget_out (void)
2296 {
2297 return grecs_dhcpdout;
2298 }
2299
2300 /** Get the length of the current token.
2301 *
2302 */
grecs_dhcpdget_leng(void)2303 grecs_dhcpd_size_t grecs_dhcpdget_leng (void)
2304 {
2305 return grecs_dhcpdleng;
2306 }
2307
2308 /** Get the current token.
2309 *
2310 */
2311
grecs_dhcpdget_text(void)2312 char *grecs_dhcpdget_text (void)
2313 {
2314 return grecs_dhcpdtext;
2315 }
2316
2317 /* %if-reentrant */
2318 /* %endif */
2319
2320 /** Set the current line number.
2321 * @param _line_number line number
2322 *
2323 */
grecs_dhcpdset_lineno(int _line_number)2324 void grecs_dhcpdset_lineno (int _line_number )
2325 {
2326
2327 grecs_dhcpdlineno = _line_number;
2328 }
2329
2330 /** Set the input stream. This does not discard the current
2331 * input buffer.
2332 * @param _in_str A readable stream.
2333 *
2334 * @see grecs_dhcpd_switch_to_buffer
2335 */
grecs_dhcpdset_in(FILE * _in_str)2336 void grecs_dhcpdset_in (FILE * _in_str )
2337 {
2338 grecs_dhcpdin = _in_str ;
2339 }
2340
grecs_dhcpdset_out(FILE * _out_str)2341 void grecs_dhcpdset_out (FILE * _out_str )
2342 {
2343 grecs_dhcpdout = _out_str ;
2344 }
2345
grecs_dhcpdget_debug(void)2346 int grecs_dhcpdget_debug (void)
2347 {
2348 return grecs_dhcpd_flex_debug;
2349 }
2350
grecs_dhcpdset_debug(int _bdebug)2351 void grecs_dhcpdset_debug (int _bdebug )
2352 {
2353 grecs_dhcpd_flex_debug = _bdebug ;
2354 }
2355
2356 /* %endif */
2357
2358 /* %if-reentrant */
2359 /* %if-bison-bridge */
2360 /* %endif */
2361 /* %endif if-c-only */
2362
2363 /* %if-c-only */
grecs_dhcpd_init_globals(void)2364 static int grecs_dhcpd_init_globals (void)
2365 {
2366 /* Initialization is the same as for the non-reentrant scanner.
2367 * This function is called from grecs_dhcpdlex_destroy(), so don't allocate here.
2368 */
2369
2370 (grecs_dhcpd_buffer_stack) = 0;
2371 (grecs_dhcpd_buffer_stack_top) = 0;
2372 (grecs_dhcpd_buffer_stack_max) = 0;
2373 (grecs_dhcpd_c_buf_p) = (char *) 0;
2374 (grecs_dhcpd_init) = 0;
2375 (grecs_dhcpd_start) = 0;
2376
2377 /* Defined in main.c */
2378 #ifdef YY_STDINIT
2379 grecs_dhcpdin = stdin;
2380 grecs_dhcpdout = stdout;
2381 #else
2382 grecs_dhcpdin = (FILE *) 0;
2383 grecs_dhcpdout = (FILE *) 0;
2384 #endif
2385
2386 /* For future reference: Set errno on error, since we are called by
2387 * grecs_dhcpdlex_init()
2388 */
2389 return 0;
2390 }
2391 /* %endif */
2392
2393 /* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */
2394 /* grecs_dhcpdlex_destroy is for both reentrant and non-reentrant scanners. */
grecs_dhcpdlex_destroy(void)2395 int grecs_dhcpdlex_destroy (void)
2396 {
2397
2398 /* Pop the buffer stack, destroying each element. */
2399 while(YY_CURRENT_BUFFER){
2400 grecs_dhcpd_delete_buffer(YY_CURRENT_BUFFER );
2401 YY_CURRENT_BUFFER_LVALUE = NULL;
2402 grecs_dhcpdpop_buffer_state();
2403 }
2404
2405 /* Destroy the stack itself. */
2406 grecs_dhcpdfree((grecs_dhcpd_buffer_stack) );
2407 (grecs_dhcpd_buffer_stack) = NULL;
2408
2409 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2410 * grecs_dhcpdlex() is called, initialization will occur. */
2411 grecs_dhcpd_init_globals( );
2412
2413 /* %if-reentrant */
2414 /* %endif */
2415 return 0;
2416 }
2417 /* %endif */
2418
2419 /*
2420 * Internal utility routines.
2421 */
2422
2423 #ifndef grecs_dhcpdtext_ptr
grecs_dhcpd_flex_strncpy(char * s1,grecs_dhcpdconst char * s2,int n)2424 static void grecs_dhcpd_flex_strncpy (char* s1, grecs_dhcpdconst char * s2, int n )
2425 {
2426
2427 int i;
2428 for ( i = 0; i < n; ++i )
2429 s1[i] = s2[i];
2430 }
2431 #endif
2432
2433 #ifdef YY_NEED_STRLEN
grecs_dhcpd_flex_strlen(grecs_dhcpdconst char * s)2434 static int grecs_dhcpd_flex_strlen (grecs_dhcpdconst char * s )
2435 {
2436 int n;
2437 for ( n = 0; s[n]; ++n )
2438 ;
2439
2440 return n;
2441 }
2442 #endif
2443
grecs_dhcpdalloc(grecs_dhcpd_size_t size)2444 void *grecs_dhcpdalloc (grecs_dhcpd_size_t size )
2445 {
2446 return (void *) malloc( size );
2447 }
2448
grecs_dhcpdrealloc(void * ptr,grecs_dhcpd_size_t size)2449 void *grecs_dhcpdrealloc (void * ptr, grecs_dhcpd_size_t size )
2450 {
2451
2452 /* The cast to (char *) in the following accommodates both
2453 * implementations that use char* generic pointers, and those
2454 * that use void* generic pointers. It works with the latter
2455 * because both ANSI C and C++ allow castless assignment from
2456 * any pointer type to void*, and deal with argument conversions
2457 * as though doing an assignment.
2458 */
2459 return (void *) realloc( (char *) ptr, size );
2460 }
2461
grecs_dhcpdfree(void * ptr)2462 void grecs_dhcpdfree (void * ptr )
2463 {
2464 free( (char *) ptr ); /* see grecs_dhcpdrealloc() for (char *) cast */
2465 }
2466
2467 /* %if-tables-serialization definitions */
2468 /* %define-grecs_dhcpdtables The name for this specific scanner's tables. */
2469 #define YYTABLES_NAME "grecs_dhcpdtables"
2470 /* %endif */
2471
2472 /* %ok-for-header */
2473
2474 #line 171 "dhcpd-lex.l"
2475
2476
2477
2478 void
grecs_dhcpd_begin_bool(void)2479 grecs_dhcpd_begin_bool(void)
2480 {
2481 BEGIN(BOOL);
2482 }
2483
2484 void
grecs_dhcpd_begin_expr(void)2485 grecs_dhcpd_begin_expr(void)
2486 {
2487 BEGIN(EXPR);
2488 }
2489
2490 struct dhcpd_input_context {
2491 ino_t i_node;
2492 dev_t i_dev;
2493 struct grecs_locus_point point;
2494 grecs_locus_t locus; /* Current input location */
2495 YY_BUFFER_STATE state;
2496 FILE *input;
2497 };
2498
2499 static struct grecs_list *input_stack;
2500 static ino_t i_node;
2501 static dev_t i_dev;
2502
2503 static void
free_context(void * ptr)2504 free_context(void *ptr)
2505 {
2506 free(ptr);
2507 }
2508
2509 static int
cmp_context(const void * a,const void * b)2510 cmp_context(const void *a, const void *b)
2511 {
2512 struct dhcpd_input_context const *ac = a;
2513 struct dhcpd_input_context const *bc = b;
2514
2515 return !(ac->i_node == bc->i_node && ac->i_dev == bc->i_dev);
2516 }
2517
2518 static int
_push_context(const char * name,ino_t i_node,dev_t i_dev,grecs_locus_t * loc)2519 _push_context(const char *name, ino_t i_node, dev_t i_dev, grecs_locus_t *loc)
2520 {
2521 struct dhcpd_input_context ctx, *pctx;
2522
2523 if (!input_stack) {
2524 input_stack = grecs_list_create();
2525 input_stack->free_entry = free_context;
2526 input_stack->cmp = cmp_context;
2527 } else {
2528 ctx.i_dev = i_dev;
2529 ctx.i_node = i_node;
2530 pctx = grecs_list_locate(input_stack, &ctx);
2531 if (pctx) {
2532 grecs_error(&grecs_dhcpdlloc, 0,
2533 _("%s has already been included"), name);
2534 grecs_error(&pctx->locus, 0,
2535 _("this is where the previous inclusion occurred"));
2536 return 1;
2537 }
2538
2539 pctx = grecs_malloc(sizeof(*pctx));
2540 pctx->i_node = i_node;
2541 pctx->i_dev = i_dev;
2542 if (loc)
2543 pctx->locus = *loc;
2544 else
2545 memset(&pctx->locus, 0, sizeof(pctx->locus)); /* FIXME */
2546 pctx->point = grecs_current_locus_point;
2547 pctx->state = YY_CURRENT_BUFFER;
2548 pctx->input = grecs_dhcpdin;
2549 grecs_list_push(input_stack, pctx);
2550 }
2551 return 0;
2552 }
2553
2554 static int
_pop_context()2555 _pop_context()
2556 {
2557 struct dhcpd_input_context *pctx;
2558
2559 if (!grecs_dhcpdin)
2560 return 1;
2561 if (grecs_preprocessor)
2562 pclose(grecs_dhcpdin);
2563 else
2564 fclose(grecs_dhcpdin);
2565 pctx = grecs_list_pop(input_stack);
2566 if (!pctx) {
2567 grecs_dhcpdin = NULL;
2568 return 1;
2569 }
2570 i_node = pctx->i_node;
2571 i_dev = pctx->i_dev;
2572 grecs_current_locus_point = pctx->point;
2573 grecs_dhcpdin = pctx->input;
2574 grecs_dhcpd_delete_buffer(YY_CURRENT_BUFFER);
2575 grecs_dhcpd_switch_to_buffer(pctx->state);
2576 grecs_free(pctx);
2577 return 0;
2578 }
2579
2580 int
grecs_dhcpdwrap()2581 grecs_dhcpdwrap()
2582 {
2583 return _pop_context();
2584 }
2585
2586 int
grecs_dhcpd_new_source(const char * name,grecs_locus_t * loc)2587 grecs_dhcpd_new_source(const char *name, grecs_locus_t *loc)
2588 {
2589 struct stat st;
2590 FILE *fp;
2591
2592 if (access(name, F_OK)) {
2593 int ec = errno;
2594 char *tmp = grecs_find_include_file(name, 0);
2595 if (!tmp) {
2596 grecs_error(loc, ec, _("cannot open `%s'"), name);
2597 return 1;
2598 }
2599 name = grecs_install_text(tmp);
2600 free(tmp);
2601 }
2602
2603 fp = fopen(name, "r");
2604 if (!fp) {
2605 grecs_error(loc, errno, _("cannot open `%s'"), name);
2606 return 1;
2607 }
2608 if (fstat(fileno(fp), &st)) {
2609 grecs_error(loc, errno, _("can't state %s"), name);
2610 fclose(fp);
2611 return 1;
2612 }
2613 if (grecs_preprocessor) {
2614 char *cmd = NULL;
2615 size_t size = 0;
2616
2617 fclose(fp);
2618 if (grecs_asprintf(&cmd, &size, "%s \"%s\"",
2619 grecs_preprocessor, name))
2620 grecs_alloc_die();
2621
2622 fp = popen(cmd, "r");
2623 if (!fp) {
2624 grecs_error(loc, errno, _("cannot open `%s'"), cmd);
2625 grecs_free(cmd);
2626 return 1;
2627 }
2628 grecs_free(cmd);
2629 }
2630
2631 if (_push_context(name, st.st_ino, st.st_dev, loc)) {
2632 return 1;
2633 }
2634 i_node = st.st_ino;
2635 i_dev = st.st_dev;
2636 grecs_dhcpdin = fp;
2637 grecs_dhcpd_switch_to_buffer(grecs_dhcpd_create_buffer(grecs_dhcpdin,YY_BUF_SIZE));
2638 grecs_current_locus_point.file = grecs_install_text(name);
2639 grecs_current_locus_point.line = 1;
2640 grecs_current_locus_point.col = 0;
2641 return 0;
2642 }
2643
2644 void
grecs_dhcpd_close_sources()2645 grecs_dhcpd_close_sources()
2646 {
2647 while (!_pop_context())
2648 ;
2649 grecs_list_free(input_stack);
2650 input_stack = NULL;
2651 }
2652
2653