chiark
/
gitweb
/
~ian
/
secnet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
logging: provide vslilog as well as slilog
[secnet.git]
/
conffile.fl
diff --git
a/conffile.fl
b/conffile.fl
index d191ffca017d3014f341fe4023b7c260529bfe7a..1747be26fb321407edeb44ed124c644c13d80ee7 100644
(file)
--- a/
conffile.fl
+++ b/
conffile.fl
@@
-1,6
+1,10
@@
/* the "incl" state is used for picking up the name of an include file */
%x incl
/* the "incl" state is used for picking up the name of an include file */
%x incl
+%option nounput
+%option noinput
+%option never-interactive
+
%{
#include <stdio.h>
#include <stdlib.h>
%{
#include <stdio.h>
#include <stdlib.h>
@@
-10,12
+14,27
@@
#include "conffile.tab.h"
#include "util.h"
#include "conffile.tab.h"
#include "util.h"
+#define YY_NO_UNPUT
+
+#define YY_INPUT(buf,result,max_size) \
+do{ \
+ (result)= fread((buf),1,(max_size),yyin); \
+ if (ferror(yyin)) \
+ fatal_perror("Error reading configuration file (%s)", \
+ config_file); \
+}while(0)
+
#define MAX_INCLUDE_DEPTH 10
#define MAX_INCLUDE_DEPTH 10
-YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
+struct include_stack_item {
+ YY_BUFFER_STATE bst;
+ uint32_t lineno;
+ cstring_t file;
+};
+struct include_stack_item include_stack[MAX_INCLUDE_DEPTH];
int include_stack_ptr=0;
uint32_t config_lineno=0;
int include_stack_ptr=0;
uint32_t config_lineno=0;
-string_t config_file="xxx";
+
c
string_t config_file="xxx";
static struct p_node *leafnode(uint32_t type)
{
static struct p_node *leafnode(uint32_t type)
{
@@
-64,15
+83,27
@@
include BEGIN(incl);
if (include_stack_ptr >= MAX_INCLUDE_DEPTH) {
fatal("Configuration file includes nested too deeply");
}
if (include_stack_ptr >= MAX_INCLUDE_DEPTH) {
fatal("Configuration file includes nested too deeply");
}
- include_stack[include_stack_ptr++]=
- YY_CURRENT_BUFFER;
+ include_stack[include_stack_ptr].bst=YY_CURRENT_BUFFER;
+ include_stack[include_stack_ptr].lineno=config_lineno;
+ include_stack[include_stack_ptr].file=config_file;
+ include_stack_ptr++;
yyin=fopen(yytext,"r");
if (!yyin) {
fatal("Can't open included file %s",yytext);
}
yyin=fopen(yytext,"r");
if (!yyin) {
fatal("Can't open included file %s",yytext);
}
+ config_lineno=1;
+ config_file=safe_strdup(yytext,"conffile.fl/include");
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
BEGIN(INITIAL);
}
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
BEGIN(INITIAL);
}
+<incl>\n { /* include with no filename */
+ Message(M_FATAL,"config file %s line %d: %s\n",config_file,
+ config_lineno,"``include'' requires a filename");
+ BEGIN(INITIAL);
+ ++config_lineno;
+ ++yynerrs;
+}
+
<<EOF>> {
if (--include_stack_ptr < 0) {
yyterminate();
<<EOF>> {
if (--include_stack_ptr < 0) {
yyterminate();
@@
-80,7
+111,9
@@
include BEGIN(incl);
else {
fclose(yyin);
yy_delete_buffer(YY_CURRENT_BUFFER);
else {
fclose(yyin);
yy_delete_buffer(YY_CURRENT_BUFFER);
- yy_switch_to_buffer(include_stack[include_stack_ptr]);
+ yy_switch_to_buffer(include_stack[include_stack_ptr].bst);
+ config_lineno=include_stack[include_stack_ptr].lineno;
+ config_file=include_stack[include_stack_ptr].file;
}
}
\"[^\"]*\" yylval=stringnode(yytext); return TOK_STRING;
}
}
\"[^\"]*\" yylval=stringnode(yytext); return TOK_STRING;