Index: l.l =================================================================== RCS file: /cvsroot/monit/monit/l.l,v retrieving revision 1.66 diff -u -r1.66 l.l --- l.l 25 Oct 2003 19:17:10 -0000 1.66 +++ l.l 23 Jan 2004 21:16:51 -0000 @@ -40,6 +40,10 @@ #include #endif +#ifdef HAVE_GLOB_H +#include +#endif + #ifdef HAVE_STRINGS_H #include #endif @@ -53,7 +57,8 @@ void yyerror(const char*); static char *handle_quoted_string(char *); void steplinenobycr(char *); - + static void include_file(char *); + %} ws [ \t]+ @@ -78,7 +83,7 @@ megabyte ("megabyte"|"mb") gigabyte ("gigabyte"|"gb") -%x ARGUMENT_COND DEPEND_COND SERVICE_COND +%x ARGUMENT_COND DEPEND_COND SERVICE_COND INCLUDE %% @@ -204,7 +209,7 @@ cleartext { return CLEARTEXT; } md5 { return MD5TOKEN; } crypt { return CRYPT; } - +include { BEGIN(INCLUDE); } {byte} { return BYTE; } {kilobyte} { return KILOBYTE; } @@ -427,8 +432,42 @@ } -%% +[ \t]* /* eat the whitespace */ + +\"[^\"\n]+\" { /* got the include file name with double quotes */ + char *temp=xstrdup(yytext); + trim_quotes(temp); + include_file(temp); + free(temp); + BEGIN(INITIAL); + } + +\'[^\'\n]+\' { /* got the include file name with single quotes*/ + char *temp=xstrdup(yytext); + trim_quotes(temp); + include_file(temp); + free(temp); + BEGIN(INITIAL); + } + +[^ \t\n]+ { /* got the include file name without quotes*/ + char *temp=xstrdup(yytext); + include_file(temp); + free(temp); + BEGIN(INITIAL); + } + + +<> { + yypop_buffer_state(); + + if ( !YY_CURRENT_BUFFER ) + { + yyterminate(); + } + } +%% /* * Do lineno++ for every occurrence of '\n' in a string. This is @@ -456,4 +495,44 @@ return buf; +} + + +static void include_file(char *pattern) { + + glob_t globbuf; + int i; + + if ( glob(pattern, GLOB_MARK, NULL, &globbuf) != 0 ) { + + yyerror("include files not found"); + + return; + + } + + for(i=0; i