[sr-dev] git:master: core: Allow SUBST in include_file and import_file.

Alex Hermann alex at speakup.nl
Fri Jul 22 18:38:11 CEST 2011


Module: sip-router
Branch: master
Commit: 4c5120b7925eae1d9b5e1215c7fc579441201e41
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4c5120b7925eae1d9b5e1215c7fc579441201e41

Author: Alex Hermann <alex at speakup.nl>
Committer: Alex Hermann <alex at speakup.nl>
Date:   Thu Jun 16 16:01:33 2011 +0200

core: Allow SUBST in include_file and import_file.

---

 cfg.lex |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/cfg.lex b/cfg.lex
index 7b984f1..82b4cdc 100644
--- a/cfg.lex
+++ b/cfg.lex
@@ -1298,21 +1298,29 @@ IMPORTFILE      "import_file"
 
 <INCLF>[ \t]*      /* eat the whitespace */
 <INCLF>[^ \t\n]+   { /* get the include file name */
-				if(sr_push_yy_state(yytext, 0)<0)
+				memset(&s_buf, 0, sizeof(s_buf));
+				addstr(&s_buf, yytext, yyleng);
+				r = pp_subst_run(&s_buf.s);
+				if(sr_push_yy_state(s_buf.s, 0)<0)
 				{
 					LOG(L_CRIT, "error at %s line %d\n", (finame)?finame:"cfg", line);
 					exit(-1);
 				}
+				memset(&s_buf, 0, sizeof(s_buf));
 				BEGIN(INITIAL);
 }
 
 <IMPTF>[ \t]*      /* eat the whitespace */
 <IMPTF>[^ \t\n]+   { /* get the import file name */
-				if(sr_push_yy_state(yytext, 1)<0)
+				memset(&s_buf, 0, sizeof(s_buf));
+				addstr(&s_buf, yytext, yyleng);
+				r = pp_subst_run(&s_buf.s);
+				if(sr_push_yy_state(s_buf.s, 1)<0)
 				{
 					LOG(L_CRIT, "error at %s line %d\n", (finame)?finame:"cfg", line);
 					exit(-1);
 				}
+				memset(&s_buf, 0, sizeof(s_buf));
 				BEGIN(INITIAL);
 }
 
@@ -1496,12 +1504,12 @@ static int sr_push_yy_state(char *fin, int mode)
 	l = strlen(fin);
 	if(l>=MAX_INCLUDE_FNAME)
 	{
-		LOG(L_CRIT, "included file name too long\n");
+		LOG(L_CRIT, "included file name too long: %s\n", fin);
 		return -1;
 	}
 	if(fin[0]!='"' || fin[l-1]!='"')
 	{
-		LOG(L_CRIT, "included file name must be between quotes\n");
+		LOG(L_CRIT, "included file name must be between quotes: %s\n", fin);
 		return -1;
 	}
 	j = 0;
@@ -1511,7 +1519,7 @@ static int sr_push_yy_state(char *fin, int mode)
 			case '\\':
 				if(i+1==l-1)
 				{
-					LOG(L_CRIT, "invalid escape in included file name\n");
+					LOG(L_CRIT, "invalid escape at %d in included file name: %s\n", i, fin);
 					return -1;
 				}
 				i++;
@@ -1535,7 +1543,7 @@ static int sr_push_yy_state(char *fin, int mode)
 	}
 	if(j==0)
 	{
-		LOG(L_CRIT, "invalid included file name\n");
+		LOG(L_CRIT, "invalid included file name: %s\n", fin);
 		return -1;
 	}
 	fbuf[j] = '\0';




More information about the sr-dev mailing list