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