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