chiark / gitweb /
logging: provide vslilog as well as slilog
[secnet.git] / conffile.fl
index c1b4b04..1747be2 100644 (file)
@@ -1,6 +1,10 @@
 /* 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>
 
 #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
 struct include_stack_item {
        YY_BUFFER_STATE bst;
        uint32_t lineno;
-       string_t file;
+       cstring_t file;
 };
 struct include_stack_item include_stack[MAX_INCLUDE_DEPTH];
 int include_stack_ptr=0;
 
 uint32_t config_lineno=0;
-string_t config_file="xxx";
+cstring_t config_file="xxx";
 
 static struct p_node *leafnode(uint32_t type)
 {
@@ -84,6 +96,14 @@ include                      BEGIN(incl);
        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();