mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 20:04:50 +00:00
Merged revisions 84133 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r84133 | murf | 2007-09-29 15:47:53 -0600 (Sat, 29 Sep 2007) | 1 line This issue sort of closes 10786; All config files support #include with globbing (you know, *,[chars],?,{list,list},etc), so I've updated the AEL system to support this also. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@84137 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
190
res/ael/ael.flex
190
res/ael/ael.flex
@@ -62,6 +62,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#if defined(__Darwin__) || defined(__CYGWIN__)
|
||||||
|
#define GLOB_ABORTED GLOB_ABEND
|
||||||
|
#endif
|
||||||
|
# include <glob.h>
|
||||||
|
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
#include "ael/ael.tab.h"
|
#include "ael/ael.tab.h"
|
||||||
@@ -107,11 +112,14 @@ struct stackelement {
|
|||||||
char *fname;
|
char *fname;
|
||||||
int lineno;
|
int lineno;
|
||||||
int colno;
|
int colno;
|
||||||
|
glob_t globbuf; /* the current globbuf */
|
||||||
|
int globbuf_pos; /* where we are in the current globbuf */
|
||||||
YY_BUFFER_STATE bufstate;
|
YY_BUFFER_STATE bufstate;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct stackelement include_stack[MAX_INCLUDE_DEPTH];
|
static struct stackelement include_stack[MAX_INCLUDE_DEPTH];
|
||||||
static int include_stack_index = 0;
|
static int include_stack_index = 0;
|
||||||
|
static void setup_filestack(char *fnamebuf, int fnamebuf_siz, glob_t *globbuf, int globpos, yyscan_t xscan, int create);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if we use the @n feature of bison, we must supply the start/end
|
* if we use the @n feature of bison, we must supply the start/end
|
||||||
@@ -383,9 +391,12 @@ includes { STORE_POS; return KW_INCLUDES;}
|
|||||||
}
|
}
|
||||||
|
|
||||||
\#include[ \t]+\"[^\"]+\" {
|
\#include[ \t]+\"[^\"]+\" {
|
||||||
FILE *in1;
|
|
||||||
char fnamebuf[1024],*p1,*p2;
|
char fnamebuf[1024],*p1,*p2;
|
||||||
int error = 1; /* don't use the file if set */
|
int glob_ret;
|
||||||
|
glob_t globbuf; /* the current globbuf */
|
||||||
|
int globbuf_pos = -1; /* where we are in the current globbuf */
|
||||||
|
globbuf.gl_offs = 0; /* initialize it to silence gcc */
|
||||||
|
|
||||||
p1 = strchr(yytext,'"');
|
p1 = strchr(yytext,'"');
|
||||||
p2 = strrchr(yytext,'"');
|
p2 = strrchr(yytext,'"');
|
||||||
if ( include_stack_index >= MAX_INCLUDE_DEPTH ) {
|
if ( include_stack_index >= MAX_INCLUDE_DEPTH ) {
|
||||||
@@ -393,68 +404,64 @@ includes { STORE_POS; return KW_INCLUDES;}
|
|||||||
} else if ( (int)(p2-p1) > sizeof(fnamebuf) - 1 ) {
|
} else if ( (int)(p2-p1) > sizeof(fnamebuf) - 1 ) {
|
||||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Filename is incredibly way too long (%d chars!). Inclusion ignored!\n", my_file, my_lineno, my_col, yyleng - 10);
|
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Filename is incredibly way too long (%d chars!). Inclusion ignored!\n", my_file, my_lineno, my_col, yyleng - 10);
|
||||||
} else {
|
} else {
|
||||||
int i;
|
strncpy(fnamebuf, p1+1, p2-p1-1);
|
||||||
strncpy(fnamebuf, p1, p2-p1);
|
fnamebuf[p2-p1-1] = 0;
|
||||||
fnamebuf[p2-p1] = 0;
|
|
||||||
for (i=0; i<include_stack_index; i++) {
|
#ifdef SOLARIS
|
||||||
if ( !strcmp(fnamebuf,include_stack[i].fname )) {
|
glob_ret = glob(fnamebuf, GLOB_NOCHECK, NULL, &globbuf);
|
||||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Nice Try!!! But %s has already been included (perhaps by another file), and would cause an infinite loop of file inclusions!!! Include directive ignored\n",
|
|
||||||
my_file, my_lineno, my_col, fnamebuf);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i == include_stack_index)
|
|
||||||
error = 0; /* we can use this file */
|
|
||||||
}
|
|
||||||
if ( !error ) { /* valid file name */
|
|
||||||
*p2 = 0;
|
|
||||||
/* relative vs. absolute */
|
|
||||||
if (*(p1+1) != '/')
|
|
||||||
snprintf(fnamebuf, sizeof(fnamebuf), "%s/%s", ast_config_AST_CONFIG_DIR, p1 + 1);
|
|
||||||
else
|
|
||||||
#if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL)
|
|
||||||
strncpy(fnamebuf, p1 + 1, sizeof(fnamebuf) - 1);
|
|
||||||
#else
|
#else
|
||||||
ast_copy_string(fnamebuf, p1 + 1, sizeof(fnamebuf));
|
glob_ret = glob(fnamebuf, GLOB_NOMAGIC|GLOB_BRACE, NULL, &globbuf);
|
||||||
#endif
|
#endif
|
||||||
in1 = fopen( fnamebuf, "r" );
|
if (glob_ret == GLOB_NOSPACE) {
|
||||||
if ( ! in1 ) {
|
ast_log(LOG_WARNING,
|
||||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Couldn't find the include file: %s; ignoring the Include directive!\n", my_file, my_lineno, my_col, fnamebuf);
|
"Glob Expansion of pattern '%s' failed: Not enough memory\n", fnamebuf);
|
||||||
|
} else if (glob_ret == GLOB_ABORTED) {
|
||||||
|
ast_log(LOG_WARNING,
|
||||||
|
"Glob Expansion of pattern '%s' failed: Read error\n", fnamebuf);
|
||||||
|
} else if (glob_ret == GLOB_NOMATCH) {
|
||||||
|
ast_log(LOG_WARNING,
|
||||||
|
"Glob Expansion of pattern '%s' failed: No matches!\n", fnamebuf);
|
||||||
} else {
|
} else {
|
||||||
char *buffer;
|
globbuf_pos = 0;
|
||||||
struct stat stats;
|
|
||||||
stat(fnamebuf, &stats);
|
|
||||||
buffer = (char*)malloc(stats.st_size+1);
|
|
||||||
fread(buffer, 1, stats.st_size, in1);
|
|
||||||
buffer[stats.st_size] = 0;
|
|
||||||
ast_log(LOG_NOTICE," --Read in included file %s, %d chars\n",fnamebuf, (int)stats.st_size);
|
|
||||||
fclose(in1);
|
|
||||||
|
|
||||||
include_stack[include_stack_index].fname = my_file;
|
|
||||||
my_file = strdup(fnamebuf);
|
|
||||||
include_stack[include_stack_index].lineno = my_lineno;
|
|
||||||
include_stack[include_stack_index].colno = my_col+yyleng;
|
|
||||||
include_stack[include_stack_index++].bufstate = YY_CURRENT_BUFFER;
|
|
||||||
|
|
||||||
yy_switch_to_buffer(ael_yy_scan_string (buffer ,yyscanner),yyscanner);
|
|
||||||
free(buffer);
|
|
||||||
my_lineno = 1;
|
|
||||||
my_col = 1;
|
|
||||||
BEGIN(INITIAL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (globbuf_pos > -1) {
|
||||||
|
setup_filestack(fnamebuf, sizeof(fnamebuf), &globbuf, 0, yyscanner, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<<EOF>> {
|
<<EOF>> {
|
||||||
if ( --include_stack_index < 0 ) {
|
char fnamebuf[2048];
|
||||||
yyterminate();
|
if (include_stack_index > 0 && include_stack[include_stack_index-1].globbuf_pos < include_stack[include_stack_index-1].globbuf.gl_pathc-1) {
|
||||||
} else {
|
|
||||||
free(my_file);
|
free(my_file);
|
||||||
|
my_file = 0;
|
||||||
yy_delete_buffer( YY_CURRENT_BUFFER, yyscanner );
|
yy_delete_buffer( YY_CURRENT_BUFFER, yyscanner );
|
||||||
yy_switch_to_buffer(include_stack[include_stack_index].bufstate, yyscanner );
|
include_stack[include_stack_index-1].globbuf_pos++;
|
||||||
my_lineno = include_stack[include_stack_index].lineno;
|
setup_filestack(fnamebuf, sizeof(fnamebuf), &include_stack[include_stack_index-1].globbuf, include_stack[include_stack_index-1].globbuf_pos, yyscanner, 0);
|
||||||
my_col = include_stack[include_stack_index].colno;
|
/* finish this */
|
||||||
my_file = include_stack[include_stack_index].fname;
|
|
||||||
|
} else {
|
||||||
|
if (include_stack[include_stack_index].fname) {
|
||||||
|
free(include_stack[include_stack_index].fname);
|
||||||
|
include_stack[include_stack_index].fname = 0;
|
||||||
|
}
|
||||||
|
if ( --include_stack_index < 0 ) {
|
||||||
|
yyterminate();
|
||||||
|
} else {
|
||||||
|
if (my_file) {
|
||||||
|
free(my_file);
|
||||||
|
my_file = 0;
|
||||||
|
}
|
||||||
|
globfree(&include_stack[include_stack_index].globbuf);
|
||||||
|
include_stack[include_stack_index].globbuf_pos = -1;
|
||||||
|
|
||||||
|
yy_delete_buffer( YY_CURRENT_BUFFER, yyscanner );
|
||||||
|
yy_switch_to_buffer(include_stack[include_stack_index].bufstate, yyscanner );
|
||||||
|
my_lineno = include_stack[include_stack_index].lineno;
|
||||||
|
my_col = include_stack[include_stack_index].colno;
|
||||||
|
my_file = strdup(include_stack[include_stack_index].fname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,6 +576,8 @@ struct pval *ael2_parse(char *filename, int *errors)
|
|||||||
*errors = 1;
|
*errors = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (my_file)
|
||||||
|
free(my_file);
|
||||||
my_file = strdup(filename);
|
my_file = strdup(filename);
|
||||||
stat(filename, &stats);
|
stat(filename, &stats);
|
||||||
buffer = (char*)malloc(stats.st_size+2);
|
buffer = (char*)malloc(stats.st_size+2);
|
||||||
@@ -593,3 +602,76 @@ struct pval *ael2_parse(char *filename, int *errors)
|
|||||||
|
|
||||||
return pval;
|
return pval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf, int globpos, yyscan_t yyscanner, int create)
|
||||||
|
{
|
||||||
|
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
|
||||||
|
int error, i;
|
||||||
|
FILE *in1;
|
||||||
|
char fnamebuf[2048];
|
||||||
|
|
||||||
|
if (globbuf && globbuf->gl_pathv && globbuf->gl_pathc > 0)
|
||||||
|
#if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL)
|
||||||
|
strncpy(fnamebuf, globbuf->gl_pathv[globpos], fnamebuf_siz);
|
||||||
|
#else
|
||||||
|
ast_copy_string(fnamebuf, globbuf->gl_pathv[globpos], fnamebuf_siz);
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
ast_log(LOG_ERROR,"Include file name not present!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (i=0; i<include_stack_index; i++) {
|
||||||
|
if ( !strcmp(fnamebuf,include_stack[i].fname )) {
|
||||||
|
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Nice Try!!! But %s has already been included (perhaps by another file), and would cause an infinite loop of file inclusions!!! Include directive ignored\n",
|
||||||
|
my_file, my_lineno, my_col, fnamebuf);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
error = 1;
|
||||||
|
if (i == include_stack_index)
|
||||||
|
error = 0; /* we can use this file */
|
||||||
|
if ( !error ) { /* valid file name */
|
||||||
|
/* relative vs. absolute */
|
||||||
|
if (fnamebuf[0] != '/')
|
||||||
|
snprintf(fnamebuf2, fnamebuf_siz, "%s/%s", ast_config_AST_CONFIG_DIR, fnamebuf);
|
||||||
|
else
|
||||||
|
#if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL)
|
||||||
|
strncpy(fnamebuf2, fnamebuf, fnamebuf_siz);
|
||||||
|
#else
|
||||||
|
ast_copy_string(fnamebuf2, fnamebuf, fnamebuf_siz);
|
||||||
|
#endif
|
||||||
|
in1 = fopen( fnamebuf2, "r" );
|
||||||
|
|
||||||
|
if ( ! in1 ) {
|
||||||
|
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Couldn't find the include file: %s; ignoring the Include directive!\n", my_file, my_lineno, my_col, fnamebuf2);
|
||||||
|
} else {
|
||||||
|
char *buffer;
|
||||||
|
struct stat stats;
|
||||||
|
stat(fnamebuf2, &stats);
|
||||||
|
buffer = (char*)malloc(stats.st_size+1);
|
||||||
|
fread(buffer, 1, stats.st_size, in1);
|
||||||
|
buffer[stats.st_size] = 0;
|
||||||
|
ast_log(LOG_NOTICE," --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size);
|
||||||
|
fclose(in1);
|
||||||
|
if (my_file)
|
||||||
|
free(my_file);
|
||||||
|
my_file = strdup(fnamebuf2);
|
||||||
|
include_stack[include_stack_index].fname = strdup(my_file);
|
||||||
|
include_stack[include_stack_index].lineno = my_lineno;
|
||||||
|
include_stack[include_stack_index].colno = my_col+yyleng;
|
||||||
|
if (create)
|
||||||
|
include_stack[include_stack_index].globbuf = *globbuf;
|
||||||
|
|
||||||
|
include_stack[include_stack_index].globbuf_pos = 0;
|
||||||
|
|
||||||
|
include_stack[include_stack_index].bufstate = YY_CURRENT_BUFFER;
|
||||||
|
if (create)
|
||||||
|
include_stack_index++;
|
||||||
|
yy_switch_to_buffer(ael_yy_scan_string (buffer ,yyscanner),yyscanner);
|
||||||
|
free(buffer);
|
||||||
|
my_lineno = 1;
|
||||||
|
my_col = 1;
|
||||||
|
BEGIN(INITIAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -784,6 +784,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#if defined(__Darwin__) || defined(__CYGWIN__)
|
||||||
|
#define GLOB_ABORTED GLOB_ABEND
|
||||||
|
#endif
|
||||||
|
# include <glob.h>
|
||||||
|
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
#include "ael/ael.tab.h"
|
#include "ael/ael.tab.h"
|
||||||
@@ -829,11 +834,15 @@ struct stackelement {
|
|||||||
char *fname;
|
char *fname;
|
||||||
int lineno;
|
int lineno;
|
||||||
int colno;
|
int colno;
|
||||||
|
glob_t globbuf; /* the current globbuf */
|
||||||
|
int globbuf_pos; /* where we are in the current globbuf */
|
||||||
YY_BUFFER_STATE bufstate;
|
YY_BUFFER_STATE bufstate;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct stackelement include_stack[MAX_INCLUDE_DEPTH];
|
static struct stackelement include_stack[MAX_INCLUDE_DEPTH];
|
||||||
static int include_stack_index = 0;
|
static int include_stack_index = 0;
|
||||||
|
static void setup_filestack(char *fnamebuf, int fnamebuf_siz, glob_t *globbuf, int globpos, yyscan_t xscan, int create);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if we use the @n feature of bison, we must supply the start/end
|
* if we use the @n feature of bison, we must supply the start/end
|
||||||
@@ -883,7 +892,7 @@ static void pbcwhere(const char *text, int *line, int *col )
|
|||||||
#define STORE_POS
|
#define STORE_POS
|
||||||
#define STORE_LOC
|
#define STORE_LOC
|
||||||
#endif
|
#endif
|
||||||
#line 886 "ael_lex.c"
|
#line 895 "ael_lex.c"
|
||||||
|
|
||||||
#define INITIAL 0
|
#define INITIAL 0
|
||||||
#define paren 1
|
#define paren 1
|
||||||
@@ -891,11 +900,13 @@ static void pbcwhere(const char *text, int *line, int *col )
|
|||||||
#define argg 3
|
#define argg 3
|
||||||
#define comment 4
|
#define comment 4
|
||||||
|
|
||||||
|
#ifndef YY_NO_UNISTD_H
|
||||||
/* Special case for "unistd.h", since it is non-ANSI. We include it way
|
/* Special case for "unistd.h", since it is non-ANSI. We include it way
|
||||||
* down here because we want the user's section 1 to have been scanned first.
|
* down here because we want the user's section 1 to have been scanned first.
|
||||||
* The user has a chance to override it with an option.
|
* The user has a chance to override it with an option.
|
||||||
*/
|
*/
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef YY_EXTRA_TYPE
|
#ifndef YY_EXTRA_TYPE
|
||||||
#define YY_EXTRA_TYPE void *
|
#define YY_EXTRA_TYPE void *
|
||||||
@@ -939,6 +950,8 @@ struct yyguts_t
|
|||||||
|
|
||||||
}; /* end struct yyguts_t */
|
}; /* end struct yyguts_t */
|
||||||
|
|
||||||
|
static int yy_init_globals (yyscan_t yyscanner );
|
||||||
|
|
||||||
/* This must go here because YYSTYPE and YYLTYPE are included
|
/* This must go here because YYSTYPE and YYLTYPE are included
|
||||||
* from bison output in section 1.*/
|
* from bison output in section 1.*/
|
||||||
# define yylval yyg->yylval_r
|
# define yylval yyg->yylval_r
|
||||||
@@ -1089,9 +1102,11 @@ static int input (yyscan_t yyscanner );
|
|||||||
#ifndef YY_DECL
|
#ifndef YY_DECL
|
||||||
#define YY_DECL_IS_OURS 1
|
#define YY_DECL_IS_OURS 1
|
||||||
|
|
||||||
extern int ael_yylex (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
|
extern int ael_yylex \
|
||||||
|
(YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
|
||||||
|
|
||||||
#define YY_DECL int ael_yylex (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
|
#define YY_DECL int ael_yylex \
|
||||||
|
(YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
|
||||||
#endif /* !YY_DECL */
|
#endif /* !YY_DECL */
|
||||||
|
|
||||||
/* Code executed at the beginning of each rule, after yytext and yyleng
|
/* Code executed at the beginning of each rule, after yytext and yyleng
|
||||||
@@ -1118,10 +1133,10 @@ YY_DECL
|
|||||||
register int yy_act;
|
register int yy_act;
|
||||||
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
|
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
|
||||||
|
|
||||||
#line 173 "ael.flex"
|
#line 182 "ael.flex"
|
||||||
|
|
||||||
|
|
||||||
#line 1124 "ael_lex.c"
|
#line 1139 "ael_lex.c"
|
||||||
|
|
||||||
yylval = yylval_param;
|
yylval = yylval_param;
|
||||||
|
|
||||||
@@ -1212,255 +1227,255 @@ do_action: /* This label is used only to access EOF actions. */
|
|||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 175 "ael.flex"
|
#line 184 "ael.flex"
|
||||||
{ STORE_POS; return LC;}
|
{ STORE_POS; return LC;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 2:
|
case 2:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 176 "ael.flex"
|
#line 185 "ael.flex"
|
||||||
{ STORE_POS; return RC;}
|
{ STORE_POS; return RC;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 3:
|
case 3:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 177 "ael.flex"
|
#line 186 "ael.flex"
|
||||||
{ STORE_POS; return LP;}
|
{ STORE_POS; return LP;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 4:
|
case 4:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 178 "ael.flex"
|
#line 187 "ael.flex"
|
||||||
{ STORE_POS; return RP;}
|
{ STORE_POS; return RP;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 5:
|
case 5:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 179 "ael.flex"
|
#line 188 "ael.flex"
|
||||||
{ STORE_POS; return SEMI;}
|
{ STORE_POS; return SEMI;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 6:
|
case 6:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 180 "ael.flex"
|
#line 189 "ael.flex"
|
||||||
{ STORE_POS; return EQ;}
|
{ STORE_POS; return EQ;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 7:
|
case 7:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 181 "ael.flex"
|
#line 190 "ael.flex"
|
||||||
{ STORE_POS; return COMMA;}
|
{ STORE_POS; return COMMA;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 8:
|
case 8:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 182 "ael.flex"
|
#line 191 "ael.flex"
|
||||||
{ STORE_POS; return COLON;}
|
{ STORE_POS; return COLON;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 9:
|
case 9:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 183 "ael.flex"
|
#line 192 "ael.flex"
|
||||||
{ STORE_POS; return AMPER;}
|
{ STORE_POS; return AMPER;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 10:
|
case 10:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 184 "ael.flex"
|
#line 193 "ael.flex"
|
||||||
{ STORE_POS; return BAR;}
|
{ STORE_POS; return BAR;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 11:
|
case 11:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 185 "ael.flex"
|
#line 194 "ael.flex"
|
||||||
{ STORE_POS; return EXTENMARK;}
|
{ STORE_POS; return EXTENMARK;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 12:
|
case 12:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 186 "ael.flex"
|
#line 195 "ael.flex"
|
||||||
{ STORE_POS; return AT;}
|
{ STORE_POS; return AT;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 13:
|
case 13:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 187 "ael.flex"
|
#line 196 "ael.flex"
|
||||||
{/*comment*/}
|
{/*comment*/}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 14:
|
case 14:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 188 "ael.flex"
|
#line 197 "ael.flex"
|
||||||
{ STORE_POS; return KW_CONTEXT;}
|
{ STORE_POS; return KW_CONTEXT;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 15:
|
case 15:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 189 "ael.flex"
|
#line 198 "ael.flex"
|
||||||
{ STORE_POS; return KW_ABSTRACT;}
|
{ STORE_POS; return KW_ABSTRACT;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 16:
|
case 16:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 190 "ael.flex"
|
#line 199 "ael.flex"
|
||||||
{ STORE_POS; return KW_MACRO;};
|
{ STORE_POS; return KW_MACRO;};
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 17:
|
case 17:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 191 "ael.flex"
|
#line 200 "ael.flex"
|
||||||
{ STORE_POS; return KW_GLOBALS;}
|
{ STORE_POS; return KW_GLOBALS;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 18:
|
case 18:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 192 "ael.flex"
|
#line 201 "ael.flex"
|
||||||
{ STORE_POS; return KW_LOCAL;}
|
{ STORE_POS; return KW_LOCAL;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 19:
|
case 19:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 193 "ael.flex"
|
#line 202 "ael.flex"
|
||||||
{ STORE_POS; return KW_IGNOREPAT;}
|
{ STORE_POS; return KW_IGNOREPAT;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 20:
|
case 20:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 194 "ael.flex"
|
#line 203 "ael.flex"
|
||||||
{ STORE_POS; return KW_SWITCH;}
|
{ STORE_POS; return KW_SWITCH;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 21:
|
case 21:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 195 "ael.flex"
|
#line 204 "ael.flex"
|
||||||
{ STORE_POS; return KW_IF;}
|
{ STORE_POS; return KW_IF;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 22:
|
case 22:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 196 "ael.flex"
|
#line 205 "ael.flex"
|
||||||
{ STORE_POS; return KW_IFTIME;}
|
{ STORE_POS; return KW_IFTIME;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 23:
|
case 23:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 197 "ael.flex"
|
#line 206 "ael.flex"
|
||||||
{ STORE_POS; return KW_RANDOM;}
|
{ STORE_POS; return KW_RANDOM;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 24:
|
case 24:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 198 "ael.flex"
|
#line 207 "ael.flex"
|
||||||
{ STORE_POS; return KW_REGEXTEN;}
|
{ STORE_POS; return KW_REGEXTEN;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 25:
|
case 25:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 199 "ael.flex"
|
#line 208 "ael.flex"
|
||||||
{ STORE_POS; return KW_HINT;}
|
{ STORE_POS; return KW_HINT;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 26:
|
case 26:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 200 "ael.flex"
|
#line 209 "ael.flex"
|
||||||
{ STORE_POS; return KW_ELSE;}
|
{ STORE_POS; return KW_ELSE;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 27:
|
case 27:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 201 "ael.flex"
|
#line 210 "ael.flex"
|
||||||
{ STORE_POS; return KW_GOTO;}
|
{ STORE_POS; return KW_GOTO;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 28:
|
case 28:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 202 "ael.flex"
|
#line 211 "ael.flex"
|
||||||
{ STORE_POS; return KW_JUMP;}
|
{ STORE_POS; return KW_JUMP;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 29:
|
case 29:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 203 "ael.flex"
|
#line 212 "ael.flex"
|
||||||
{ STORE_POS; return KW_RETURN;}
|
{ STORE_POS; return KW_RETURN;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 30:
|
case 30:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 204 "ael.flex"
|
#line 213 "ael.flex"
|
||||||
{ STORE_POS; return KW_BREAK;}
|
{ STORE_POS; return KW_BREAK;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 31:
|
case 31:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 205 "ael.flex"
|
#line 214 "ael.flex"
|
||||||
{ STORE_POS; return KW_CONTINUE;}
|
{ STORE_POS; return KW_CONTINUE;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 32:
|
case 32:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 206 "ael.flex"
|
#line 215 "ael.flex"
|
||||||
{ STORE_POS; return KW_FOR;}
|
{ STORE_POS; return KW_FOR;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 33:
|
case 33:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 207 "ael.flex"
|
#line 216 "ael.flex"
|
||||||
{ STORE_POS; return KW_WHILE;}
|
{ STORE_POS; return KW_WHILE;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 34:
|
case 34:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 208 "ael.flex"
|
#line 217 "ael.flex"
|
||||||
{ STORE_POS; return KW_CASE;}
|
{ STORE_POS; return KW_CASE;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 35:
|
case 35:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 209 "ael.flex"
|
#line 218 "ael.flex"
|
||||||
{ STORE_POS; return KW_DEFAULT;}
|
{ STORE_POS; return KW_DEFAULT;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 36:
|
case 36:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 210 "ael.flex"
|
#line 219 "ael.flex"
|
||||||
{ STORE_POS; return KW_PATTERN;}
|
{ STORE_POS; return KW_PATTERN;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 37:
|
case 37:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 211 "ael.flex"
|
#line 220 "ael.flex"
|
||||||
{ STORE_POS; return KW_CATCH;}
|
{ STORE_POS; return KW_CATCH;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 38:
|
case 38:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 212 "ael.flex"
|
#line 221 "ael.flex"
|
||||||
{ STORE_POS; return KW_SWITCHES;}
|
{ STORE_POS; return KW_SWITCHES;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 39:
|
case 39:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 213 "ael.flex"
|
#line 222 "ael.flex"
|
||||||
{ STORE_POS; return KW_ESWITCHES;}
|
{ STORE_POS; return KW_ESWITCHES;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 40:
|
case 40:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 214 "ael.flex"
|
#line 223 "ael.flex"
|
||||||
{ STORE_POS; return KW_INCLUDES;}
|
{ STORE_POS; return KW_INCLUDES;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 41:
|
case 41:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 215 "ael.flex"
|
#line 224 "ael.flex"
|
||||||
{ BEGIN(comment); my_col += 2; }
|
{ BEGIN(comment); my_col += 2; }
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 42:
|
case 42:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 217 "ael.flex"
|
#line 226 "ael.flex"
|
||||||
{ my_col += yyleng; }
|
{ my_col += yyleng; }
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 43:
|
case 43:
|
||||||
/* rule 43 can match eol */
|
/* rule 43 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 218 "ael.flex"
|
#line 227 "ael.flex"
|
||||||
{ ++my_lineno; my_col=1;}
|
{ ++my_lineno; my_col=1;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 44:
|
case 44:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 219 "ael.flex"
|
#line 228 "ael.flex"
|
||||||
{ my_col += yyleng; }
|
{ my_col += yyleng; }
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 45:
|
case 45:
|
||||||
/* rule 45 can match eol */
|
/* rule 45 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 220 "ael.flex"
|
#line 229 "ael.flex"
|
||||||
{ ++my_lineno; my_col=1;}
|
{ ++my_lineno; my_col=1;}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 46:
|
case 46:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 221 "ael.flex"
|
#line 230 "ael.flex"
|
||||||
{ my_col += 2; BEGIN(INITIAL); }
|
{ my_col += 2; BEGIN(INITIAL); }
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 47:
|
case 47:
|
||||||
/* rule 47 can match eol */
|
/* rule 47 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 223 "ael.flex"
|
#line 232 "ael.flex"
|
||||||
{ my_lineno++; my_col = 1; }
|
{ my_lineno++; my_col = 1; }
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 48:
|
case 48:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 224 "ael.flex"
|
#line 233 "ael.flex"
|
||||||
{ my_col += yyleng; }
|
{ my_col += yyleng; }
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 49:
|
case 49:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 225 "ael.flex"
|
#line 234 "ael.flex"
|
||||||
{ my_col += (yyleng*8)-(my_col%8); }
|
{ my_col += (yyleng*8)-(my_col%8); }
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 50:
|
case 50:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 227 "ael.flex"
|
#line 236 "ael.flex"
|
||||||
{
|
{
|
||||||
STORE_POS;
|
STORE_POS;
|
||||||
yylval->str = strdup(yytext);
|
yylval->str = strdup(yytext);
|
||||||
@@ -1478,7 +1493,7 @@ YY_RULE_SETUP
|
|||||||
case 51:
|
case 51:
|
||||||
/* rule 51 can match eol */
|
/* rule 51 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 243 "ael.flex"
|
#line 252 "ael.flex"
|
||||||
{
|
{
|
||||||
if ( pbcpop(')') ) { /* error */
|
if ( pbcpop(')') ) { /* error */
|
||||||
STORE_LOC;
|
STORE_LOC;
|
||||||
@@ -1504,7 +1519,7 @@ YY_RULE_SETUP
|
|||||||
case 52:
|
case 52:
|
||||||
/* rule 52 can match eol */
|
/* rule 52 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 265 "ael.flex"
|
#line 274 "ael.flex"
|
||||||
{
|
{
|
||||||
char c = yytext[yyleng-1];
|
char c = yytext[yyleng-1];
|
||||||
if (c == '(')
|
if (c == '(')
|
||||||
@@ -1516,7 +1531,7 @@ YY_RULE_SETUP
|
|||||||
case 53:
|
case 53:
|
||||||
/* rule 53 can match eol */
|
/* rule 53 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 273 "ael.flex"
|
#line 282 "ael.flex"
|
||||||
{
|
{
|
||||||
char c = yytext[yyleng-1];
|
char c = yytext[yyleng-1];
|
||||||
if ( pbcpop(c)) { /* error */
|
if ( pbcpop(c)) { /* error */
|
||||||
@@ -1541,7 +1556,7 @@ YY_RULE_SETUP
|
|||||||
case 54:
|
case 54:
|
||||||
/* rule 54 can match eol */
|
/* rule 54 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 295 "ael.flex"
|
#line 304 "ael.flex"
|
||||||
{
|
{
|
||||||
char c = yytext[yyleng-1];
|
char c = yytext[yyleng-1];
|
||||||
if (c == '(')
|
if (c == '(')
|
||||||
@@ -1553,7 +1568,7 @@ YY_RULE_SETUP
|
|||||||
case 55:
|
case 55:
|
||||||
/* rule 55 can match eol */
|
/* rule 55 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 303 "ael.flex"
|
#line 312 "ael.flex"
|
||||||
{
|
{
|
||||||
if ( pbcpop(')') ) { /* error */
|
if ( pbcpop(')') ) { /* error */
|
||||||
STORE_LOC;
|
STORE_LOC;
|
||||||
@@ -1581,7 +1596,7 @@ YY_RULE_SETUP
|
|||||||
case 56:
|
case 56:
|
||||||
/* rule 56 can match eol */
|
/* rule 56 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 327 "ael.flex"
|
#line 336 "ael.flex"
|
||||||
{
|
{
|
||||||
if( parencount != 0) { /* printf("Folding in a comma!\n"); */
|
if( parencount != 0) { /* printf("Folding in a comma!\n"); */
|
||||||
yymore();
|
yymore();
|
||||||
@@ -1599,7 +1614,7 @@ YY_RULE_SETUP
|
|||||||
case 57:
|
case 57:
|
||||||
/* rule 57 can match eol */
|
/* rule 57 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 341 "ael.flex"
|
#line 350 "ael.flex"
|
||||||
{
|
{
|
||||||
char c = yytext[yyleng-1];
|
char c = yytext[yyleng-1];
|
||||||
if ( pbcpop(c) ) { /* error */
|
if ( pbcpop(c) ) { /* error */
|
||||||
@@ -1620,7 +1635,7 @@ YY_RULE_SETUP
|
|||||||
case 58:
|
case 58:
|
||||||
/* rule 58 can match eol */
|
/* rule 58 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 358 "ael.flex"
|
#line 367 "ael.flex"
|
||||||
{
|
{
|
||||||
char c = yytext[yyleng-1];
|
char c = yytext[yyleng-1];
|
||||||
yymore();
|
yymore();
|
||||||
@@ -1630,7 +1645,7 @@ YY_RULE_SETUP
|
|||||||
case 59:
|
case 59:
|
||||||
/* rule 59 can match eol */
|
/* rule 59 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 364 "ael.flex"
|
#line 373 "ael.flex"
|
||||||
{
|
{
|
||||||
char c = yytext[yyleng-1];
|
char c = yytext[yyleng-1];
|
||||||
if ( pbcpop(c) ) { /* error */
|
if ( pbcpop(c) ) { /* error */
|
||||||
@@ -1646,7 +1661,7 @@ YY_RULE_SETUP
|
|||||||
case 60:
|
case 60:
|
||||||
/* rule 60 can match eol */
|
/* rule 60 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 376 "ael.flex"
|
#line 385 "ael.flex"
|
||||||
{
|
{
|
||||||
STORE_LOC;
|
STORE_LOC;
|
||||||
yylval->str = strdup(yytext);
|
yylval->str = strdup(yytext);
|
||||||
@@ -1659,11 +1674,14 @@ YY_RULE_SETUP
|
|||||||
case 61:
|
case 61:
|
||||||
/* rule 61 can match eol */
|
/* rule 61 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 385 "ael.flex"
|
#line 394 "ael.flex"
|
||||||
{
|
{
|
||||||
FILE *in1;
|
|
||||||
char fnamebuf[1024],*p1,*p2;
|
char fnamebuf[1024],*p1,*p2;
|
||||||
int error = 1; /* don't use the file if set */
|
int glob_ret;
|
||||||
|
glob_t globbuf; /* the current globbuf */
|
||||||
|
int globbuf_pos = -1; /* where we are in the current globbuf */
|
||||||
|
globbuf.gl_offs = 0; /* initialize it to silence gcc */
|
||||||
|
|
||||||
p1 = strchr(yytext,'"');
|
p1 = strchr(yytext,'"');
|
||||||
p2 = strrchr(yytext,'"');
|
p2 = strrchr(yytext,'"');
|
||||||
if ( include_stack_index >= MAX_INCLUDE_DEPTH ) {
|
if ( include_stack_index >= MAX_INCLUDE_DEPTH ) {
|
||||||
@@ -1671,56 +1689,30 @@ YY_RULE_SETUP
|
|||||||
} else if ( (int)(p2-p1) > sizeof(fnamebuf) - 1 ) {
|
} else if ( (int)(p2-p1) > sizeof(fnamebuf) - 1 ) {
|
||||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Filename is incredibly way too long (%d chars!). Inclusion ignored!\n", my_file, my_lineno, my_col, yyleng - 10);
|
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Filename is incredibly way too long (%d chars!). Inclusion ignored!\n", my_file, my_lineno, my_col, yyleng - 10);
|
||||||
} else {
|
} else {
|
||||||
int i;
|
strncpy(fnamebuf, p1+1, p2-p1-1);
|
||||||
strncpy(fnamebuf, p1, p2-p1);
|
fnamebuf[p2-p1-1] = 0;
|
||||||
fnamebuf[p2-p1] = 0;
|
|
||||||
for (i=0; i<include_stack_index; i++) {
|
#ifdef SOLARIS
|
||||||
if ( !strcmp(fnamebuf,include_stack[i].fname )) {
|
glob_ret = glob(fnamebuf, GLOB_NOCHECK, NULL, &globbuf);
|
||||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Nice Try!!! But %s has already been included (perhaps by another file), and would cause an infinite loop of file inclusions!!! Include directive ignored\n",
|
|
||||||
my_file, my_lineno, my_col, fnamebuf);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i == include_stack_index)
|
|
||||||
error = 0; /* we can use this file */
|
|
||||||
}
|
|
||||||
if ( !error ) { /* valid file name */
|
|
||||||
*p2 = 0;
|
|
||||||
/* relative vs. absolute */
|
|
||||||
if (*(p1+1) != '/')
|
|
||||||
snprintf(fnamebuf, sizeof(fnamebuf), "%s/%s", ast_config_AST_CONFIG_DIR, p1 + 1);
|
|
||||||
else
|
|
||||||
#if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL)
|
|
||||||
strncpy(fnamebuf, p1 + 1, sizeof(fnamebuf) - 1);
|
|
||||||
#else
|
#else
|
||||||
ast_copy_string(fnamebuf, p1 + 1, sizeof(fnamebuf));
|
glob_ret = glob(fnamebuf, GLOB_NOMAGIC|GLOB_BRACE, NULL, &globbuf);
|
||||||
#endif
|
#endif
|
||||||
in1 = fopen( fnamebuf, "r" );
|
if (glob_ret == GLOB_NOSPACE) {
|
||||||
if ( ! in1 ) {
|
ast_log(LOG_WARNING,
|
||||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Couldn't find the include file: %s; ignoring the Include directive!\n", my_file, my_lineno, my_col, fnamebuf);
|
"Glob Expansion of pattern '%s' failed: Not enough memory\n", fnamebuf);
|
||||||
|
} else if (glob_ret == GLOB_ABORTED) {
|
||||||
|
ast_log(LOG_WARNING,
|
||||||
|
"Glob Expansion of pattern '%s' failed: Read error\n", fnamebuf);
|
||||||
|
} else if (glob_ret == GLOB_NOMATCH) {
|
||||||
|
ast_log(LOG_WARNING,
|
||||||
|
"Glob Expansion of pattern '%s' failed: No matches!\n", fnamebuf);
|
||||||
} else {
|
} else {
|
||||||
char *buffer;
|
globbuf_pos = 0;
|
||||||
struct stat stats;
|
|
||||||
stat(fnamebuf, &stats);
|
|
||||||
buffer = (char*)malloc(stats.st_size+1);
|
|
||||||
fread(buffer, 1, stats.st_size, in1);
|
|
||||||
buffer[stats.st_size] = 0;
|
|
||||||
ast_log(LOG_NOTICE," --Read in included file %s, %d chars\n",fnamebuf, (int)stats.st_size);
|
|
||||||
fclose(in1);
|
|
||||||
|
|
||||||
include_stack[include_stack_index].fname = my_file;
|
|
||||||
my_file = strdup(fnamebuf);
|
|
||||||
include_stack[include_stack_index].lineno = my_lineno;
|
|
||||||
include_stack[include_stack_index].colno = my_col+yyleng;
|
|
||||||
include_stack[include_stack_index++].bufstate = YY_CURRENT_BUFFER;
|
|
||||||
|
|
||||||
ael_yy_switch_to_buffer(ael_yy_scan_string (buffer ,yyscanner),yyscanner);
|
|
||||||
free(buffer);
|
|
||||||
my_lineno = 1;
|
|
||||||
my_col = 1;
|
|
||||||
BEGIN(INITIAL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (globbuf_pos > -1) {
|
||||||
|
setup_filestack(fnamebuf, sizeof(fnamebuf), &globbuf, 0, yyscanner, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case YY_STATE_EOF(INITIAL):
|
case YY_STATE_EOF(INITIAL):
|
||||||
@@ -1728,26 +1720,47 @@ case YY_STATE_EOF(paren):
|
|||||||
case YY_STATE_EOF(semic):
|
case YY_STATE_EOF(semic):
|
||||||
case YY_STATE_EOF(argg):
|
case YY_STATE_EOF(argg):
|
||||||
case YY_STATE_EOF(comment):
|
case YY_STATE_EOF(comment):
|
||||||
#line 448 "ael.flex"
|
#line 435 "ael.flex"
|
||||||
{
|
{
|
||||||
if ( --include_stack_index < 0 ) {
|
char fnamebuf[2048];
|
||||||
yyterminate();
|
if (include_stack_index > 0 && include_stack[include_stack_index-1].globbuf_pos < include_stack[include_stack_index-1].globbuf.gl_pathc-1) {
|
||||||
} else {
|
|
||||||
free(my_file);
|
free(my_file);
|
||||||
|
my_file = 0;
|
||||||
ael_yy_delete_buffer(YY_CURRENT_BUFFER,yyscanner );
|
ael_yy_delete_buffer(YY_CURRENT_BUFFER,yyscanner );
|
||||||
ael_yy_switch_to_buffer(include_stack[include_stack_index].bufstate,yyscanner );
|
include_stack[include_stack_index-1].globbuf_pos++;
|
||||||
my_lineno = include_stack[include_stack_index].lineno;
|
setup_filestack(fnamebuf, sizeof(fnamebuf), &include_stack[include_stack_index-1].globbuf, include_stack[include_stack_index-1].globbuf_pos, yyscanner, 0);
|
||||||
my_col = include_stack[include_stack_index].colno;
|
/* finish this */
|
||||||
my_file = include_stack[include_stack_index].fname;
|
|
||||||
|
} else {
|
||||||
|
if (include_stack[include_stack_index].fname) {
|
||||||
|
free(include_stack[include_stack_index].fname);
|
||||||
|
include_stack[include_stack_index].fname = 0;
|
||||||
|
}
|
||||||
|
if ( --include_stack_index < 0 ) {
|
||||||
|
yyterminate();
|
||||||
|
} else {
|
||||||
|
if (my_file) {
|
||||||
|
free(my_file);
|
||||||
|
my_file = 0;
|
||||||
|
}
|
||||||
|
globfree(&include_stack[include_stack_index].globbuf);
|
||||||
|
include_stack[include_stack_index].globbuf_pos = -1;
|
||||||
|
|
||||||
|
ael_yy_delete_buffer(YY_CURRENT_BUFFER,yyscanner );
|
||||||
|
ael_yy_switch_to_buffer(include_stack[include_stack_index].bufstate,yyscanner );
|
||||||
|
my_lineno = include_stack[include_stack_index].lineno;
|
||||||
|
my_col = include_stack[include_stack_index].colno;
|
||||||
|
my_file = strdup(include_stack[include_stack_index].fname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 62:
|
case 62:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 461 "ael.flex"
|
#line 469 "ael.flex"
|
||||||
ECHO;
|
ECHO;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
#line 1750 "ael_lex.c"
|
#line 1763 "ael_lex.c"
|
||||||
|
|
||||||
case YY_END_OF_BUFFER:
|
case YY_END_OF_BUFFER:
|
||||||
{
|
{
|
||||||
@@ -1933,7 +1946,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t num_to_read =
|
int num_to_read =
|
||||||
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
|
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
|
||||||
|
|
||||||
while ( num_to_read <= 0 )
|
while ( num_to_read <= 0 )
|
||||||
@@ -2498,10 +2511,10 @@ YY_BUFFER_STATE ael_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yys
|
|||||||
* @note If you want to scan bytes that may contain NUL values, then use
|
* @note If you want to scan bytes that may contain NUL values, then use
|
||||||
* ael_yy_scan_bytes() instead.
|
* ael_yy_scan_bytes() instead.
|
||||||
*/
|
*/
|
||||||
YY_BUFFER_STATE ael_yy_scan_string (yyconst char * str , yyscan_t yyscanner)
|
YY_BUFFER_STATE ael_yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner)
|
||||||
{
|
{
|
||||||
|
|
||||||
return ael_yy_scan_bytes(str,strlen(str) ,yyscanner);
|
return ael_yy_scan_bytes(yy_str,strlen(yy_str) ,yyscanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Setup the input buffer state to scan the given bytes. The next call to ael_yylex() will
|
/** Setup the input buffer state to scan the given bytes. The next call to ael_yylex() will
|
||||||
@@ -2883,7 +2896,7 @@ void ael_yyfree (void * ptr , yyscan_t yyscanner)
|
|||||||
#undef YY_DECL_IS_OURS
|
#undef YY_DECL_IS_OURS
|
||||||
#undef YY_DECL
|
#undef YY_DECL
|
||||||
#endif
|
#endif
|
||||||
#line 461 "ael.flex"
|
#line 469 "ael.flex"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -2996,6 +3009,8 @@ struct pval *ael2_parse(char *filename, int *errors)
|
|||||||
*errors = 1;
|
*errors = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (my_file)
|
||||||
|
free(my_file);
|
||||||
my_file = strdup(filename);
|
my_file = strdup(filename);
|
||||||
stat(filename, &stats);
|
stat(filename, &stats);
|
||||||
buffer = (char*)malloc(stats.st_size+2);
|
buffer = (char*)malloc(stats.st_size+2);
|
||||||
@@ -3021,3 +3036,76 @@ struct pval *ael2_parse(char *filename, int *errors)
|
|||||||
return pval;
|
return pval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf, int globpos, yyscan_t yyscanner, int create)
|
||||||
|
{
|
||||||
|
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
|
||||||
|
int error, i;
|
||||||
|
FILE *in1;
|
||||||
|
char fnamebuf[2048];
|
||||||
|
|
||||||
|
if (globbuf && globbuf->gl_pathv && globbuf->gl_pathc > 0)
|
||||||
|
#if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL)
|
||||||
|
strncpy(fnamebuf, globbuf->gl_pathv[globpos], fnamebuf_siz);
|
||||||
|
#else
|
||||||
|
ast_copy_string(fnamebuf, globbuf->gl_pathv[globpos], fnamebuf_siz);
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
ast_log(LOG_ERROR,"Include file name not present!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (i=0; i<include_stack_index; i++) {
|
||||||
|
if ( !strcmp(fnamebuf,include_stack[i].fname )) {
|
||||||
|
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Nice Try!!! But %s has already been included (perhaps by another file), and would cause an infinite loop of file inclusions!!! Include directive ignored\n",
|
||||||
|
my_file, my_lineno, my_col, fnamebuf);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
error = 1;
|
||||||
|
if (i == include_stack_index)
|
||||||
|
error = 0; /* we can use this file */
|
||||||
|
if ( !error ) { /* valid file name */
|
||||||
|
/* relative vs. absolute */
|
||||||
|
if (fnamebuf[0] != '/')
|
||||||
|
snprintf(fnamebuf2, fnamebuf_siz, "%s/%s", ast_config_AST_CONFIG_DIR, fnamebuf);
|
||||||
|
else
|
||||||
|
#if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL)
|
||||||
|
strncpy(fnamebuf2, fnamebuf, fnamebuf_siz);
|
||||||
|
#else
|
||||||
|
ast_copy_string(fnamebuf2, fnamebuf, fnamebuf_siz);
|
||||||
|
#endif
|
||||||
|
in1 = fopen( fnamebuf2, "r" );
|
||||||
|
|
||||||
|
if ( ! in1 ) {
|
||||||
|
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Couldn't find the include file: %s; ignoring the Include directive!\n", my_file, my_lineno, my_col, fnamebuf2);
|
||||||
|
} else {
|
||||||
|
char *buffer;
|
||||||
|
struct stat stats;
|
||||||
|
stat(fnamebuf2, &stats);
|
||||||
|
buffer = (char*)malloc(stats.st_size+1);
|
||||||
|
fread(buffer, 1, stats.st_size, in1);
|
||||||
|
buffer[stats.st_size] = 0;
|
||||||
|
ast_log(LOG_NOTICE," --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size);
|
||||||
|
fclose(in1);
|
||||||
|
if (my_file)
|
||||||
|
free(my_file);
|
||||||
|
my_file = strdup(fnamebuf2);
|
||||||
|
include_stack[include_stack_index].fname = strdup(my_file);
|
||||||
|
include_stack[include_stack_index].lineno = my_lineno;
|
||||||
|
include_stack[include_stack_index].colno = my_col+yyleng;
|
||||||
|
if (create)
|
||||||
|
include_stack[include_stack_index].globbuf = *globbuf;
|
||||||
|
|
||||||
|
include_stack[include_stack_index].globbuf_pos = 0;
|
||||||
|
|
||||||
|
include_stack[include_stack_index].bufstate = YY_CURRENT_BUFFER;
|
||||||
|
if (create)
|
||||||
|
include_stack_index++;
|
||||||
|
ael_yy_switch_to_buffer(ael_yy_scan_string (buffer ,yyscanner),yyscanner);
|
||||||
|
free(buffer);
|
||||||
|
my_lineno = 1;
|
||||||
|
my_col = 1;
|
||||||
|
BEGIN(INITIAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user