Browse code

core: add route name to action struct

Victor Seva authored on 07/06/2014 07:19:03
Showing 3 changed files
... ...
@@ -135,6 +135,9 @@
135 135
 	int startcolumn=1;
136 136
 	int startline=1;
137 137
 	char *finame = 0;
138
+	char *routename = 0;
139
+	char *default_routename = 0;
140
+
138 141
 	static int ign_lines=0;
139 142
 	static int ign_columns=0;
140 143
 	char* yy_number_str=0; /* str correspondent for the current NUMBER token */
... ...
@@ -155,6 +158,7 @@
155 155
 		int startcolumn;
156 156
 		int startline;
157 157
 		char *finame;
158
+		char *routename;
158 159
 	} include_stack[MAX_INCLUDE_DEPTH];
159 160
 	static int include_stack_ptr = 0;
160 161
 
... ...
@@ -596,16 +600,24 @@ IMPORTFILE      "import_file"
596 596
 <INITIAL>{ISAVPFLAGSET}	{ count(); yylval.strval=yytext; return ISAVPFLAGSET; }
597 597
 <INITIAL>{AVPFLAGS_DECL}	{ count(); yylval.strval=yytext; return AVPFLAGS_DECL; }
598 598
 <INITIAL>{MSGLEN}	{ count(); yylval.strval=yytext; return MSGLEN; }
599
-<INITIAL>{ROUTE}	{ count(); yylval.strval=yytext; return ROUTE; }
600
-<INITIAL>{ROUTE_REQUEST}	{ count(); yylval.strval=yytext; return ROUTE_REQUEST; }
601
-<INITIAL>{ROUTE_ONREPLY}	{ count(); yylval.strval=yytext;
599
+<INITIAL>{ROUTE}	{ count(); default_routename="DEFAULT_ROUTE";
600
+						yylval.strval=yytext; return ROUTE; }
601
+<INITIAL>{ROUTE_REQUEST}	{ count(); default_routename="DEFAULT_ROUTE";
602
+								yylval.strval=yytext; return ROUTE_REQUEST; }
603
+<INITIAL>{ROUTE_ONREPLY}	{ count(); default_routename="DEFAULT_ONREPLY";
604
+								yylval.strval=yytext;
602 605
 								return ROUTE_ONREPLY; }
603
-<INITIAL>{ROUTE_REPLY}	{ count(); yylval.strval=yytext; return ROUTE_REPLY; }
604
-<INITIAL>{ROUTE_FAILURE}	{ count(); yylval.strval=yytext;
606
+<INITIAL>{ROUTE_REPLY}	{ count(); default_routename="DEFAULT_ONREPLY";
607
+							yylval.strval=yytext; return ROUTE_REPLY; }
608
+<INITIAL>{ROUTE_FAILURE}	{ count(); default_routename="DEFAULT_FAILURE";
609
+								yylval.strval=yytext;
605 610
 								return ROUTE_FAILURE; }
606
-<INITIAL>{ROUTE_BRANCH} { count(); yylval.strval=yytext; return ROUTE_BRANCH; }
607
-<INITIAL>{ROUTE_SEND} { count(); yylval.strval=yytext; return ROUTE_SEND; }
608
-<INITIAL>{ROUTE_EVENT} { count(); yylval.strval=yytext; return ROUTE_EVENT; }
611
+<INITIAL>{ROUTE_BRANCH} { count(); default_routename="DEFAULT_BRANCH";
612
+							yylval.strval=yytext; return ROUTE_BRANCH; }
613
+<INITIAL>{ROUTE_SEND} { count(); default_routename="DEFAULT_SEND";
614
+							yylval.strval=yytext; return ROUTE_SEND; }
615
+<INITIAL>{ROUTE_EVENT} { count(); default_routename="DEFAULT_EVENT";
616
+							yylval.strval=yytext; return ROUTE_EVENT; }
609 617
 <INITIAL>{EXEC}	{ count(); yylval.strval=yytext; return EXEC; }
610 618
 <INITIAL>{SET_HOST}	{ count(); yylval.strval=yytext; return SET_HOST; }
611 619
 <INITIAL>{SET_HOSTPORT}	{ count(); yylval.strval=yytext; return SET_HOSTPORT; }
... ...
@@ -1593,6 +1605,7 @@ static int sr_push_yy_state(char *fin, int mode)
1593 1593
 	include_stack[include_stack_ptr].startline = startline;
1594 1594
 	include_stack[include_stack_ptr].startcolumn = startcolumn;
1595 1595
 	include_stack[include_stack_ptr].finame = finame;
1596
+	include_stack[include_stack_ptr].routename = routename;
1596 1597
 	include_stack_ptr++;
1597 1598
 
1598 1599
 	line=1;
... ...
@@ -256,12 +256,15 @@ extern int column;
256 256
 extern int startcolumn;
257 257
 extern int startline;
258 258
 extern char *finame;
259
+extern char *routename;
260
+extern char *default_routename;
259 261
 
260 262
 #define set_cfg_pos(x) \
261 263
 	do{\
262 264
 		if(x) {\
263 265
 		(x)->cline = line;\
264 266
 		(x)->cfile = (finame!=0)?finame:((cfg_file!=0)?cfg_file:"default");\
267
+		(x)->rname = (routename!=0)?routename:((default_routename!=0)?default_routename:"DEFAULT");\
265 268
 		}\
266 269
 	}while(0)
267 270
 
... ...
@@ -1743,9 +1746,10 @@ route_name:		NUMBER	{
1743 1743
 						memcpy($$, tmp, i_tmp);
1744 1744
 						$$[i_tmp]=0;
1745 1745
 					}
1746
+					routename = tmp;
1746 1747
 						}
1747
-			|	ID		{ $$=$1; }
1748
-			|	STRING	{ $$=$1; }
1748
+			|	ID		{ routename = $1; $$=$1; }
1749
+			|	STRING	{ routename = $1; $$=$1; }
1749 1750
 ;
1750 1751
 
1751 1752
 
... ...
@@ -3372,6 +3376,7 @@ static void get_cpos(struct cfg_pos* pos)
3372 3372
 	if(finame==0)
3373 3373
 		finame = (cfg_file!=0)?cfg_file:"default";
3374 3374
 	pos->fname=finame;
3375
+	pos->rname=(routename!=0)?routename:default_routename;
3375 3376
 }
3376 3377
 
3377 3378
 
... ...
@@ -156,6 +156,7 @@ struct cfg_pos{
156 156
 	unsigned short s_col;
157 157
 	unsigned short e_col;
158 158
 	char *fname;
159
+	char *rname;
159 160
 };
160 161
 
161 162
 
... ...
@@ -202,6 +203,7 @@ typedef struct {
202 202
 struct action{
203 203
 	int cline;
204 204
 	char *cfile;
205
+	char *rname;
205 206
 	enum action_type type;  /* forward, drop, log, send ...*/
206 207
 	int count;
207 208
 	struct action* next;