1 /* the "incl" state is used for picking up the name of an include file */
9 #include "conffile_internal.h"
10 #include "conffile.tab.h"
13 #define MAX_INCLUDE_DEPTH 10
14 YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
15 int include_stack_ptr=0;
17 uint32_t config_lineno=0;
18 string_t config_file="xxx";
20 static struct p_node *leafnode(uint32_t type)
24 r=safe_malloc(sizeof(*r),"leafnode");
26 r->loc.file=config_file;
27 r->loc.line=config_lineno;
32 static struct p_node *keynode(atom_t key)
36 r->data.key=intern(key);
40 static struct p_node *stringnode(string_t string)
45 string[strlen(string)-1]=0;
46 r->data.string=safe_strdup(string,"stringnode");
50 static struct p_node *numnode(string_t number)
54 r->data.number=atoi(number);
62 <incl>[ \t]* /* eat the whitespace */
63 <incl>[^ \t\n]+ { /* got the include filename */
64 if (include_stack_ptr >= MAX_INCLUDE_DEPTH) {
65 fatal("Configuration file includes nested too deeply");
67 include_stack[include_stack_ptr++]=
69 yyin=fopen(yytext,"r");
71 fatal("Can't open included file %s",yytext);
73 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
77 if (--include_stack_ptr < 0) {
82 yy_delete_buffer(YY_CURRENT_BUFFER);
83 yy_switch_to_buffer(include_stack[include_stack_ptr]);
86 \"[^\"]*\" yylval=stringnode(yytext); return TOK_STRING;
88 [[:alpha:]_][[:alnum:]\-_]* yylval=keynode(yytext); return TOK_KEY;
90 [[:digit:]]+ yylval=numnode(yytext); return TOK_NUMBER;
93 \#.*\n config_lineno++;
99 /* Return all unclaimed single characters to the parser */