xref: /freebsd/contrib/unbound/util/configlexer.lex (revision a812392203d7c4c3f0db9d8a0f3391374c49c71f)
1 %{
2 /*
3  * configlexer.lex - lexical analyzer for unbound config file
4  *
5  * Copyright (c) 2001-2006, NLnet Labs. All rights reserved
6  *
7  * See LICENSE for the license.
8  *
9  */
10 #include "config.h"
11 
12 #include <ctype.h>
13 #include <string.h>
14 #include <strings.h>
15 #ifdef HAVE_GLOB_H
16 # include <glob.h>
17 #endif
18 
19 #include "util/config_file.h"
20 #include "configparser.h"
21 void ub_c_error(const char *message);
22 
23 #if 0
24 #define LEXOUT(s)  printf s /* used ONLY when debugging */
25 #else
26 #define LEXOUT(s)
27 #endif
28 
29 /** avoid warning in about fwrite return value */
30 #define ECHO ub_c_error_msg("syntax error at text: %s", ub_c_text)
31 
32 /** A parser variable, this is a statement in the config file which is
33  * of the form variable: value1 value2 ...  nargs is the number of values. */
34 #define YDVAR(nargs, var) \
35 	num_args=(nargs); \
36 	LEXOUT(("v(%s%d) ", ub_c_text, num_args)); \
37 	if(num_args > 0) { BEGIN(val); } \
38 	return (var);
39 
40 struct inc_state {
41 	char* filename;
42 	int line;
43 	YY_BUFFER_STATE buffer;
44 	struct inc_state* next;
45 };
46 static struct inc_state* config_include_stack = NULL;
47 static int inc_depth = 0;
48 static int inc_prev = 0;
49 static int num_args = 0;
50 
51 void init_cfg_parse(void)
52 {
53 	config_include_stack = NULL;
54 	inc_depth = 0;
55 	inc_prev = 0;
56 	num_args = 0;
57 }
58 
59 static void config_start_include(const char* filename)
60 {
61 	FILE *input;
62 	struct inc_state* s;
63 	char* nm;
64 	if(inc_depth++ > 100000) {
65 		ub_c_error_msg("too many include files");
66 		return;
67 	}
68 	if(strlen(filename) == 0) {
69 		ub_c_error_msg("empty include file name");
70 		return;
71 	}
72 	s = (struct inc_state*)malloc(sizeof(*s));
73 	if(!s) {
74 		ub_c_error_msg("include %s: malloc failure", filename);
75 		return;
76 	}
77 	if(cfg_parser->chroot && strncmp(filename, cfg_parser->chroot,
78 		strlen(cfg_parser->chroot)) == 0) {
79 		filename += strlen(cfg_parser->chroot);
80 	}
81 	nm = strdup(filename);
82 	if(!nm) {
83 		ub_c_error_msg("include %s: strdup failure", filename);
84 		free(s);
85 		return;
86 	}
87 	input = fopen(filename, "r");
88 	if(!input) {
89 		ub_c_error_msg("cannot open include file '%s': %s",
90 			filename, strerror(errno));
91 		free(s);
92 		free(nm);
93 		return;
94 	}
95 	LEXOUT(("switch_to_include_file(%s)\n", filename));
96 	s->filename = cfg_parser->filename;
97 	s->line = cfg_parser->line;
98 	s->buffer = YY_CURRENT_BUFFER;
99 	s->next = config_include_stack;
100 	config_include_stack = s;
101 	cfg_parser->filename = nm;
102 	cfg_parser->line = 1;
103 	yy_switch_to_buffer(yy_create_buffer(input, YY_BUF_SIZE));
104 }
105 
106 static void config_start_include_glob(const char* filename)
107 {
108 
109 	/* check for wildcards */
110 #ifdef HAVE_GLOB
111 	glob_t g;
112 	size_t i;
113 	int r, flags;
114 	if(!(!strchr(filename, '*') && !strchr(filename, '?') && !strchr(filename, '[') &&
115 		!strchr(filename, '{') && !strchr(filename, '~'))) {
116 		flags = 0
117 #ifdef GLOB_ERR
118 			| GLOB_ERR
119 #endif
120 #ifdef GLOB_NOSORT
121 			| GLOB_NOSORT
122 #endif
123 #ifdef GLOB_BRACE
124 			| GLOB_BRACE
125 #endif
126 #ifdef GLOB_TILDE
127 			| GLOB_TILDE
128 #endif
129 		;
130 		memset(&g, 0, sizeof(g));
131 		r = glob(filename, flags, NULL, &g);
132 		if(r) {
133 			/* some error */
134 			globfree(&g);
135 			if(r == GLOB_NOMATCH)
136 				return; /* no matches for pattern */
137 			config_start_include(filename); /* let original deal with it */
138 			return;
139 		}
140 		/* process files found, if any */
141 		for(i=0; i<(size_t)g.gl_pathc; i++) {
142 			config_start_include(g.gl_pathv[i]);
143 		}
144 		globfree(&g);
145 		return;
146 	}
147 #endif /* HAVE_GLOB */
148 
149 	config_start_include(filename);
150 }
151 
152 static void config_end_include(void)
153 {
154 	struct inc_state* s = config_include_stack;
155 	--inc_depth;
156 	if(!s) return;
157 	free(cfg_parser->filename);
158 	cfg_parser->filename = s->filename;
159 	cfg_parser->line = s->line;
160 	yy_delete_buffer(YY_CURRENT_BUFFER);
161 	yy_switch_to_buffer(s->buffer);
162 	config_include_stack = s->next;
163 	free(s);
164 }
165 
166 #ifndef yy_set_bol /* compat definition, for flex 2.4.6 */
167 #define yy_set_bol(at_bol) \
168         { \
169 	        if ( ! yy_current_buffer ) \
170 	                yy_current_buffer = yy_create_buffer( ub_c_in, YY_BUF_SIZE ); \
171 	        yy_current_buffer->yy_ch_buf[0] = ((at_bol)?'\n':' '); \
172         }
173 #endif
174 
175 %}
176 %option noinput
177 %option nounput
178 %{
179 #ifndef YY_NO_UNPUT
180 #define YY_NO_UNPUT 1
181 #endif
182 #ifndef YY_NO_INPUT
183 #define YY_NO_INPUT 1
184 #endif
185 %}
186 
187 SPACE   [ \t]
188 LETTER  [a-zA-Z]
189 UNQUOTEDLETTER [^\'\"\n\r \t\\]|\\.
190 UNQUOTEDLETTER_NOCOLON [^\:\'\"\n\r \t\\]|\\.
191 NEWLINE [\r\n]
192 COMMENT \#
193 COLON 	\:
194 DQANY     [^\"\n\r\\]|\\.
195 SQANY     [^\'\n\r\\]|\\.
196 
197 %x	quotedstring singlequotedstr include include_quoted val
198 
199 %%
200 <INITIAL,val>{SPACE}*	{
201 	LEXOUT(("SP ")); /* ignore */ }
202 <INITIAL,val>{SPACE}*{COMMENT}.*	{
203 	/* note that flex makes the longest match and '.' is any but not nl */
204 	LEXOUT(("comment(%s) ", ub_c_text)); /* ignore */ }
205 server{COLON}			{ YDVAR(0, VAR_SERVER) }
206 num-threads{COLON}		{ YDVAR(1, VAR_NUM_THREADS) }
207 verbosity{COLON}		{ YDVAR(1, VAR_VERBOSITY) }
208 port{COLON}			{ YDVAR(1, VAR_PORT) }
209 outgoing-range{COLON}		{ YDVAR(1, VAR_OUTGOING_RANGE) }
210 outgoing-port-permit{COLON}	{ YDVAR(1, VAR_OUTGOING_PORT_PERMIT) }
211 outgoing-port-avoid{COLON}	{ YDVAR(1, VAR_OUTGOING_PORT_AVOID) }
212 outgoing-num-tcp{COLON}		{ YDVAR(1, VAR_OUTGOING_NUM_TCP) }
213 incoming-num-tcp{COLON}		{ YDVAR(1, VAR_INCOMING_NUM_TCP) }
214 do-ip4{COLON}			{ YDVAR(1, VAR_DO_IP4) }
215 do-ip6{COLON}			{ YDVAR(1, VAR_DO_IP6) }
216 do-udp{COLON}			{ YDVAR(1, VAR_DO_UDP) }
217 do-tcp{COLON}			{ YDVAR(1, VAR_DO_TCP) }
218 tcp-upstream{COLON}		{ YDVAR(1, VAR_TCP_UPSTREAM) }
219 ssl-upstream{COLON}		{ YDVAR(1, VAR_SSL_UPSTREAM) }
220 ssl-service-key{COLON}		{ YDVAR(1, VAR_SSL_SERVICE_KEY) }
221 ssl-service-pem{COLON}		{ YDVAR(1, VAR_SSL_SERVICE_PEM) }
222 ssl-port{COLON}			{ YDVAR(1, VAR_SSL_PORT) }
223 do-daemonize{COLON}		{ YDVAR(1, VAR_DO_DAEMONIZE) }
224 interface{COLON}		{ YDVAR(1, VAR_INTERFACE) }
225 ip-address{COLON}		{ YDVAR(1, VAR_INTERFACE) }
226 outgoing-interface{COLON}	{ YDVAR(1, VAR_OUTGOING_INTERFACE) }
227 interface-automatic{COLON}	{ YDVAR(1, VAR_INTERFACE_AUTOMATIC) }
228 so-rcvbuf{COLON}		{ YDVAR(1, VAR_SO_RCVBUF) }
229 so-sndbuf{COLON}		{ YDVAR(1, VAR_SO_SNDBUF) }
230 so-reuseport{COLON}		{ YDVAR(1, VAR_SO_REUSEPORT) }
231 chroot{COLON}			{ YDVAR(1, VAR_CHROOT) }
232 username{COLON}			{ YDVAR(1, VAR_USERNAME) }
233 directory{COLON}		{ YDVAR(1, VAR_DIRECTORY) }
234 logfile{COLON}			{ YDVAR(1, VAR_LOGFILE) }
235 pidfile{COLON}			{ YDVAR(1, VAR_PIDFILE) }
236 root-hints{COLON}		{ YDVAR(1, VAR_ROOT_HINTS) }
237 edns-buffer-size{COLON}		{ YDVAR(1, VAR_EDNS_BUFFER_SIZE) }
238 msg-buffer-size{COLON}		{ YDVAR(1, VAR_MSG_BUFFER_SIZE) }
239 msg-cache-size{COLON}		{ YDVAR(1, VAR_MSG_CACHE_SIZE) }
240 msg-cache-slabs{COLON}		{ YDVAR(1, VAR_MSG_CACHE_SLABS) }
241 rrset-cache-size{COLON}		{ YDVAR(1, VAR_RRSET_CACHE_SIZE) }
242 rrset-cache-slabs{COLON}	{ YDVAR(1, VAR_RRSET_CACHE_SLABS) }
243 cache-max-ttl{COLON}     	{ YDVAR(1, VAR_CACHE_MAX_TTL) }
244 cache-min-ttl{COLON}     	{ YDVAR(1, VAR_CACHE_MIN_TTL) }
245 infra-host-ttl{COLON}		{ YDVAR(1, VAR_INFRA_HOST_TTL) }
246 infra-lame-ttl{COLON}		{ YDVAR(1, VAR_INFRA_LAME_TTL) }
247 infra-cache-slabs{COLON}	{ YDVAR(1, VAR_INFRA_CACHE_SLABS) }
248 infra-cache-numhosts{COLON}	{ YDVAR(1, VAR_INFRA_CACHE_NUMHOSTS) }
249 infra-cache-lame-size{COLON}	{ YDVAR(1, VAR_INFRA_CACHE_LAME_SIZE) }
250 num-queries-per-thread{COLON}	{ YDVAR(1, VAR_NUM_QUERIES_PER_THREAD) }
251 jostle-timeout{COLON}		{ YDVAR(1, VAR_JOSTLE_TIMEOUT) }
252 delay-close{COLON}		{ YDVAR(1, VAR_DELAY_CLOSE) }
253 target-fetch-policy{COLON}	{ YDVAR(1, VAR_TARGET_FETCH_POLICY) }
254 harden-short-bufsize{COLON}	{ YDVAR(1, VAR_HARDEN_SHORT_BUFSIZE) }
255 harden-large-queries{COLON}	{ YDVAR(1, VAR_HARDEN_LARGE_QUERIES) }
256 harden-glue{COLON}		{ YDVAR(1, VAR_HARDEN_GLUE) }
257 harden-dnssec-stripped{COLON}	{ YDVAR(1, VAR_HARDEN_DNSSEC_STRIPPED) }
258 harden-below-nxdomain{COLON}	{ YDVAR(1, VAR_HARDEN_BELOW_NXDOMAIN) }
259 harden-referral-path{COLON}	{ YDVAR(1, VAR_HARDEN_REFERRAL_PATH) }
260 use-caps-for-id{COLON}		{ YDVAR(1, VAR_USE_CAPS_FOR_ID) }
261 unwanted-reply-threshold{COLON}	{ YDVAR(1, VAR_UNWANTED_REPLY_THRESHOLD) }
262 private-address{COLON}		{ YDVAR(1, VAR_PRIVATE_ADDRESS) }
263 private-domain{COLON}		{ YDVAR(1, VAR_PRIVATE_DOMAIN) }
264 prefetch-key{COLON}		{ YDVAR(1, VAR_PREFETCH_KEY) }
265 prefetch{COLON}			{ YDVAR(1, VAR_PREFETCH) }
266 stub-zone{COLON}		{ YDVAR(0, VAR_STUB_ZONE) }
267 name{COLON}			{ YDVAR(1, VAR_NAME) }
268 stub-addr{COLON}		{ YDVAR(1, VAR_STUB_ADDR) }
269 stub-host{COLON}		{ YDVAR(1, VAR_STUB_HOST) }
270 stub-prime{COLON}		{ YDVAR(1, VAR_STUB_PRIME) }
271 stub-first{COLON}		{ YDVAR(1, VAR_STUB_FIRST) }
272 forward-zone{COLON}		{ YDVAR(0, VAR_FORWARD_ZONE) }
273 forward-addr{COLON}		{ YDVAR(1, VAR_FORWARD_ADDR) }
274 forward-host{COLON}		{ YDVAR(1, VAR_FORWARD_HOST) }
275 forward-first{COLON}		{ YDVAR(1, VAR_FORWARD_FIRST) }
276 do-not-query-address{COLON}	{ YDVAR(1, VAR_DO_NOT_QUERY_ADDRESS) }
277 do-not-query-localhost{COLON}	{ YDVAR(1, VAR_DO_NOT_QUERY_LOCALHOST) }
278 access-control{COLON}		{ YDVAR(2, VAR_ACCESS_CONTROL) }
279 hide-identity{COLON}		{ YDVAR(1, VAR_HIDE_IDENTITY) }
280 hide-version{COLON}		{ YDVAR(1, VAR_HIDE_VERSION) }
281 identity{COLON}			{ YDVAR(1, VAR_IDENTITY) }
282 version{COLON}			{ YDVAR(1, VAR_VERSION) }
283 module-config{COLON}     	{ YDVAR(1, VAR_MODULE_CONF) }
284 dlv-anchor{COLON}		{ YDVAR(1, VAR_DLV_ANCHOR) }
285 dlv-anchor-file{COLON}		{ YDVAR(1, VAR_DLV_ANCHOR_FILE) }
286 trust-anchor-file{COLON}	{ YDVAR(1, VAR_TRUST_ANCHOR_FILE) }
287 auto-trust-anchor-file{COLON}	{ YDVAR(1, VAR_AUTO_TRUST_ANCHOR_FILE) }
288 trusted-keys-file{COLON}	{ YDVAR(1, VAR_TRUSTED_KEYS_FILE) }
289 trust-anchor{COLON}		{ YDVAR(1, VAR_TRUST_ANCHOR) }
290 val-override-date{COLON}	{ YDVAR(1, VAR_VAL_OVERRIDE_DATE) }
291 val-sig-skew-min{COLON}		{ YDVAR(1, VAR_VAL_SIG_SKEW_MIN) }
292 val-sig-skew-max{COLON}		{ YDVAR(1, VAR_VAL_SIG_SKEW_MAX) }
293 val-bogus-ttl{COLON}		{ YDVAR(1, VAR_BOGUS_TTL) }
294 val-clean-additional{COLON}	{ YDVAR(1, VAR_VAL_CLEAN_ADDITIONAL) }
295 val-permissive-mode{COLON}	{ YDVAR(1, VAR_VAL_PERMISSIVE_MODE) }
296 ignore-cd-flag{COLON}		{ YDVAR(1, VAR_IGNORE_CD_FLAG) }
297 val-log-level{COLON}		{ YDVAR(1, VAR_VAL_LOG_LEVEL) }
298 key-cache-size{COLON}		{ YDVAR(1, VAR_KEY_CACHE_SIZE) }
299 key-cache-slabs{COLON}		{ YDVAR(1, VAR_KEY_CACHE_SLABS) }
300 neg-cache-size{COLON}		{ YDVAR(1, VAR_NEG_CACHE_SIZE) }
301 val-nsec3-keysize-iterations{COLON}	{
302 				  YDVAR(1, VAR_VAL_NSEC3_KEYSIZE_ITERATIONS) }
303 add-holddown{COLON}		{ YDVAR(1, VAR_ADD_HOLDDOWN) }
304 del-holddown{COLON}		{ YDVAR(1, VAR_DEL_HOLDDOWN) }
305 keep-missing{COLON}		{ YDVAR(1, VAR_KEEP_MISSING) }
306 use-syslog{COLON}		{ YDVAR(1, VAR_USE_SYSLOG) }
307 log-time-ascii{COLON}		{ YDVAR(1, VAR_LOG_TIME_ASCII) }
308 log-queries{COLON}		{ YDVAR(1, VAR_LOG_QUERIES) }
309 local-zone{COLON}		{ YDVAR(2, VAR_LOCAL_ZONE) }
310 local-data{COLON}		{ YDVAR(1, VAR_LOCAL_DATA) }
311 local-data-ptr{COLON}		{ YDVAR(1, VAR_LOCAL_DATA_PTR) }
312 unblock-lan-zones{COLON}	{ YDVAR(1, VAR_UNBLOCK_LAN_ZONES) }
313 statistics-interval{COLON}	{ YDVAR(1, VAR_STATISTICS_INTERVAL) }
314 statistics-cumulative{COLON}	{ YDVAR(1, VAR_STATISTICS_CUMULATIVE) }
315 extended-statistics{COLON}	{ YDVAR(1, VAR_EXTENDED_STATISTICS) }
316 remote-control{COLON}		{ YDVAR(0, VAR_REMOTE_CONTROL) }
317 control-enable{COLON}		{ YDVAR(1, VAR_CONTROL_ENABLE) }
318 control-interface{COLON}	{ YDVAR(1, VAR_CONTROL_INTERFACE) }
319 control-port{COLON}		{ YDVAR(1, VAR_CONTROL_PORT) }
320 server-key-file{COLON}		{ YDVAR(1, VAR_SERVER_KEY_FILE) }
321 server-cert-file{COLON}		{ YDVAR(1, VAR_SERVER_CERT_FILE) }
322 control-key-file{COLON}		{ YDVAR(1, VAR_CONTROL_KEY_FILE) }
323 control-cert-file{COLON}	{ YDVAR(1, VAR_CONTROL_CERT_FILE) }
324 python-script{COLON}		{ YDVAR(1, VAR_PYTHON_SCRIPT) }
325 python{COLON}			{ YDVAR(0, VAR_PYTHON) }
326 domain-insecure{COLON}		{ YDVAR(1, VAR_DOMAIN_INSECURE) }
327 minimal-responses{COLON}	{ YDVAR(1, VAR_MINIMAL_RESPONSES) }
328 rrset-roundrobin{COLON}		{ YDVAR(1, VAR_RRSET_ROUNDROBIN) }
329 max-udp-size{COLON}		{ YDVAR(1, VAR_MAX_UDP_SIZE) }
330 dns64-prefix{COLON}		{ YDVAR(1, VAR_DNS64_PREFIX) }
331 dns64-synthall{COLON}		{ YDVAR(1, VAR_DNS64_SYNTHALL) }
332 dnstap{COLON}			{ YDVAR(0, VAR_DNSTAP) }
333 dnstap-enable{COLON}		{ YDVAR(1, VAR_DNSTAP_ENABLE) }
334 dnstap-socket-path{COLON}	{ YDVAR(1, VAR_DNSTAP_SOCKET_PATH) }
335 dnstap-send-identity{COLON}	{ YDVAR(1, VAR_DNSTAP_SEND_IDENTITY) }
336 dnstap-send-version{COLON}	{ YDVAR(1, VAR_DNSTAP_SEND_VERSION) }
337 dnstap-identity{COLON}		{ YDVAR(1, VAR_DNSTAP_IDENTITY) }
338 dnstap-version{COLON}		{ YDVAR(1, VAR_DNSTAP_VERSION) }
339 dnstap-log-resolver-query-messages{COLON}	{
340 		YDVAR(1, VAR_DNSTAP_LOG_RESOLVER_QUERY_MESSAGES) }
341 dnstap-log-resolver-response-messages{COLON}	{
342 		YDVAR(1, VAR_DNSTAP_LOG_RESOLVER_RESPONSE_MESSAGES) }
343 dnstap-log-client-query-messages{COLON}		{
344 		YDVAR(1, VAR_DNSTAP_LOG_CLIENT_QUERY_MESSAGES) }
345 dnstap-log-client-response-messages{COLON}	{
346 		YDVAR(1, VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES) }
347 dnstap-log-forwarder-query-messages{COLON}	{
348 		YDVAR(1, VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES) }
349 dnstap-log-forwarder-response-messages{COLON}	{
350 		YDVAR(1, VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES) }
351 <INITIAL,val>{NEWLINE}		{ LEXOUT(("NL\n")); cfg_parser->line++; }
352 
353 	/* Quoted strings. Strip leading and ending quotes */
354 <val>\"			{ BEGIN(quotedstring); LEXOUT(("QS ")); }
355 <quotedstring><<EOF>>   {
356         ub_c_error("EOF inside quoted string");
357 	if(--num_args == 0) { BEGIN(INITIAL); }
358 	else		    { BEGIN(val); }
359 }
360 <quotedstring>{DQANY}*  { LEXOUT(("STR(%s) ", ub_c_text)); yymore(); }
361 <quotedstring>{NEWLINE} { ub_c_error("newline inside quoted string, no end \"");
362 			  cfg_parser->line++; BEGIN(INITIAL); }
363 <quotedstring>\" {
364         LEXOUT(("QE "));
365 	if(--num_args == 0) { BEGIN(INITIAL); }
366 	else		    { BEGIN(val); }
367         ub_c_text[ub_c_leng - 1] = '\0';
368 	ub_c_lval.str = strdup(ub_c_text);
369 	if(!ub_c_lval.str)
370 		ub_c_error("out of memory");
371         return STRING_ARG;
372 }
373 
374 	/* Single Quoted strings. Strip leading and ending quotes */
375 <val>\'			{ BEGIN(singlequotedstr); LEXOUT(("SQS ")); }
376 <singlequotedstr><<EOF>>   {
377         ub_c_error("EOF inside quoted string");
378 	if(--num_args == 0) { BEGIN(INITIAL); }
379 	else		    { BEGIN(val); }
380 }
381 <singlequotedstr>{SQANY}*  { LEXOUT(("STR(%s) ", ub_c_text)); yymore(); }
382 <singlequotedstr>{NEWLINE} { ub_c_error("newline inside quoted string, no end '");
383 			     cfg_parser->line++; BEGIN(INITIAL); }
384 <singlequotedstr>\' {
385         LEXOUT(("SQE "));
386 	if(--num_args == 0) { BEGIN(INITIAL); }
387 	else		    { BEGIN(val); }
388         ub_c_text[ub_c_leng - 1] = '\0';
389 	ub_c_lval.str = strdup(ub_c_text);
390 	if(!ub_c_lval.str)
391 		ub_c_error("out of memory");
392         return STRING_ARG;
393 }
394 
395 	/* include: directive */
396 <INITIAL,val>include{COLON}	{
397 	LEXOUT(("v(%s) ", ub_c_text)); inc_prev = YYSTATE; BEGIN(include); }
398 <include><<EOF>>	{
399         ub_c_error("EOF inside include directive");
400         BEGIN(inc_prev);
401 }
402 <include>{SPACE}*	{ LEXOUT(("ISP ")); /* ignore */ }
403 <include>{NEWLINE}	{ LEXOUT(("NL\n")); cfg_parser->line++;}
404 <include>\"		{ LEXOUT(("IQS ")); BEGIN(include_quoted); }
405 <include>{UNQUOTEDLETTER}*	{
406 	LEXOUT(("Iunquotedstr(%s) ", ub_c_text));
407 	config_start_include_glob(ub_c_text);
408 	BEGIN(inc_prev);
409 }
410 <include_quoted><<EOF>>	{
411         ub_c_error("EOF inside quoted string");
412         BEGIN(inc_prev);
413 }
414 <include_quoted>{DQANY}*	{ LEXOUT(("ISTR(%s) ", ub_c_text)); yymore(); }
415 <include_quoted>{NEWLINE}	{ ub_c_error("newline before \" in include name");
416 				  cfg_parser->line++; BEGIN(inc_prev); }
417 <include_quoted>\"	{
418 	LEXOUT(("IQE "));
419 	ub_c_text[ub_c_leng - 1] = '\0';
420 	config_start_include_glob(ub_c_text);
421 	BEGIN(inc_prev);
422 }
423 <INITIAL,val><<EOF>>	{
424 	LEXOUT(("LEXEOF "));
425 	yy_set_bol(1); /* Set beginning of line, so "^" rules match.  */
426 	if (!config_include_stack) {
427 		yyterminate();
428 	} else {
429 		fclose(ub_c_in);
430 		config_end_include();
431 	}
432 }
433 
434 <val>{UNQUOTEDLETTER}*	{ LEXOUT(("unquotedstr(%s) ", ub_c_text));
435 			if(--num_args == 0) { BEGIN(INITIAL); }
436 			ub_c_lval.str = strdup(ub_c_text); return STRING_ARG; }
437 
438 {UNQUOTEDLETTER_NOCOLON}*	{
439 	ub_c_error_msg("unknown keyword '%s'", ub_c_text);
440 	}
441 
442 <*>.	{
443 	ub_c_error_msg("stray '%s'", ub_c_text);
444 	}
445 
446 %%
447