cfg.y
3c1a8ef8
 /*
  * $Id$
  *
  *  cfg grammar
  */
 
 %{
 
3e429f5c
 #include <stdlib.h>
63fa628f
 #include <stdio.h>
c75aa645
 #include <sys/types.h>
7268726e
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
f20a56a2
 #include <string.h>
c07508e2
 #include "route_struct.h"
3e429f5c
 #include "globals.h"
 #include "route.h"
7268726e
 #include "dprint.h"
3bf76e49
 #include "sr_module.h"
3e429f5c
 
f571aa35
 
03150098
 #ifdef DEBUG_DMALLOC
 #include <dmalloc.h>
 #endif
 
3e429f5c
 void yyerror(char* s);
7268726e
 char* tmp;
3bf76e49
 void* f_tmp;
c07508e2
 
3c1a8ef8
 %}
 
 %union {
 	int intval;
09e52ebb
 	unsigned uval;
3c1a8ef8
 	char* strval;
c07508e2
 	struct expr* expr;
 	struct action* action;
09e52ebb
 	struct net* net;
3c1a8ef8
 }
 
 /* terminals */
 
 
3e429f5c
 /* keywords */
3c1a8ef8
 %token FORWARD
 %token SEND
 %token DROP
7268726e
 %token LOG_TOK
3c1a8ef8
 %token ERROR
 %token ROUTE
09e52ebb
 %token EXEC
7268726e
 %token SET_HOST
 %token SET_HOSTPORT
 %token SET_USER
 %token SET_USERPASS
 %token SET_PORT
 %token SET_URI
f20a56a2
 %token IF
 %token ELSE
5ada8f8a
 %token URIHOST
 %token URIPORT
09e52ebb
 
3c1a8ef8
 %token METHOD
 %token URI
 %token SRCIP
 %token DSTIP
 
 /* config vars. */
 %token DEBUG
 %token FORK
 %token LOGSTDERROR
 %token LISTEN
 %token DNS
 %token REV_DNS
7268726e
 %token PORT
f571aa35
 %token STAT
7268726e
 %token CHILDREN
 %token CHECK_VIA
676eb608
 %token LOOP_CHECKS
3bf76e49
 %token LOADMODULE
c3ce2841
 %token MAXBUFFER
7268726e
 
3c1a8ef8
 
 
 /* operators */
 %nonassoc EQUAL
 %nonassoc EQUAL_T
 %nonassoc MATCH
 %left OR
09e52ebb
 %left AND
 %left NOT
3c1a8ef8
 
 /* values */
c07508e2
 %token <intval> NUMBER
 %token <strval> ID
 %token <strval> STRING
3c1a8ef8
 
 /* other */
 %token COMMA
 %token SEMICOLON
 %token RPAREN
 %token LPAREN
 %token LBRACE
 %token RBRACE
 %token LBRACK
 %token RBRACK
 %token SLASH
 %token DOT
 %token CR
 
 
 /*non-terminals */
f20a56a2
 %type <expr> exp, exp_elem /*, condition*/
 %type <action> action, actions, cmd, if_cmd, stm
09e52ebb
 %type <uval> ipv4
 %type <net> net4
 %type <strval> host
f20a56a2
 /*%type <route_el> rules;
   %type <route_el> rule;
 */
3c1a8ef8
 
 
 
 %%
 
 
 cfg:	statements
 	;
 
3e429f5c
 statements:	statements statement {}
 		| statement {}
 		| statements error { yyerror(""); YYABORT;}
3c1a8ef8
 	;
 
7268726e
 statement:	assign_stm 
3bf76e49
 		| module_stm
7268726e
 		| route_stm 
c07508e2
 		| CR	/* null statement*/
3c1a8ef8
 	;
 
7268726e
 assign_stm:	DEBUG EQUAL NUMBER { debug=$3; }
c07508e2
 		| DEBUG EQUAL error  { yyerror("number  expected"); }
7268726e
 		| FORK  EQUAL NUMBER { dont_fork= ! $3; }
c07508e2
 		| FORK  EQUAL error  { yyerror("boolean value expected"); }
7268726e
 		| LOGSTDERROR EQUAL NUMBER { log_stderr=$3; }
c07508e2
 		| LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
7268726e
 		| DNS EQUAL NUMBER   { received_dns|= ($3)?DO_DNS:0; }
c07508e2
 		| DNS EQUAL error { yyerror("boolean value expected"); }
7268726e
 		| REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
c07508e2
 		| REV_DNS EQUAL error { yyerror("boolean value expected"); }
7268726e
 		| PORT EQUAL NUMBER   { port_no=$3; }
e4067ffb
 		| STAT EQUAL STRING {
 					#ifdef STATS
 							stat_file=$3;
 					#endif
 							}
c3ce2841
 		| MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
 		| MAXBUFFER EQUAL error { yyerror("number expected"); }
7268726e
 		| PORT EQUAL error    { yyerror("number expected"); } 
 		| CHILDREN EQUAL NUMBER { children_no=$3; }
 		| CHILDREN EQUAL error { yyerror("number expected"); } 
 		| CHECK_VIA EQUAL NUMBER { check_via=$3; }
 		| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
676eb608
 		| LOOP_CHECKS EQUAL NUMBER { loop_checks=$3; }
 		| LOOP_CHECKS EQUAL error { yyerror("boolean value expected"); }
7268726e
 		| LISTEN EQUAL ipv4  {
 								if (addresses_no < MAX_LISTEN){
 									tmp=inet_ntoa(*(struct in_addr*)&$3);
f20a56a2
 									names[addresses_no]=
 												(char*)malloc(strlen(tmp)+1);
7268726e
 									if (names[addresses_no]==0){
f20a56a2
 										LOG(L_CRIT, "ERROR: cfg. parser: "
 														"out of memory.\n");
7268726e
 									}else{
f20a56a2
 										strncpy(names[addresses_no], tmp,
 												strlen(tmp)+1);
7268726e
 										addresses_no++;
 									}
 								}else{
f20a56a2
 									LOG(L_CRIT, "ERROR: cfg. parser:"
 												" too many listen addresses"
7268726e
 												"(max. %d).\n", MAX_LISTEN);
 								}
 							  }
 		| LISTEN EQUAL ID	 {
 								if (addresses_no < MAX_LISTEN){
f20a56a2
 									names[addresses_no]=
 												(char*)malloc(strlen($3)+1);
7268726e
 									if (names[addresses_no]==0){
f20a56a2
 										LOG(L_CRIT, "ERROR: cfg. parser:"
 														" out of memory.\n");
7268726e
 									}else{
f20a56a2
 										strncpy(names[addresses_no], $3,
 													strlen($3)+1);
7268726e
 										addresses_no++;
 									}
 								}else{
f20a56a2
 									LOG(L_CRIT, "ERROR: cfg. parser: "
 												"too many listen addresses"
7268726e
 												"(max. %d).\n", MAX_LISTEN);
 								}
 							  }
 		| LISTEN EQUAL STRING {
 								if (addresses_no < MAX_LISTEN){
f20a56a2
 									names[addresses_no]=
 										(char*)malloc(strlen($3)+1);
7268726e
 									if (names[addresses_no]==0){
f20a56a2
 										LOG(L_CRIT, "ERROR: cfg. parser:"
 													" out of memory.\n");
7268726e
 									}else{
f20a56a2
 										strncpy(names[addresses_no], $3,
 												strlen($3)+1);
7268726e
 										addresses_no++;
 									}
 								}else{
f20a56a2
 									LOG(L_CRIT, "ERROR: cfg. parser: "
 												"too many listen addresses"
7268726e
 												"(max. %d).\n", MAX_LISTEN);
 								}
 							  }
c07508e2
 		| LISTEN EQUAL  error { yyerror("ip address or hostname"
 						"expected"); }
 		| error EQUAL { yyerror("unknown config variable"); }
3c1a8ef8
 	;
 
96001c50
 module_stm:	LOADMODULE STRING	{ DBG("loading module %s\n", $2);
3bf76e49
 		  						  if (load_module($2)!=0){
 								  		yyerror("failed to load module");
 								  }
 								}
 		 |	LOADMODULE error	{ yyerror("string expected");  }
 		 ;
 
3c1a8ef8
 
09e52ebb
 ipv4:	NUMBER DOT NUMBER DOT NUMBER DOT NUMBER { 
 											if (($1>255) || ($1<0) ||
 												($3>255) || ($3<0) ||
 												($5>255) || ($5<0) ||
 												($7>255) || ($7<0)){
 												yyerror("invalid ipv4"
 														"address");
 												$$=0;
 											}else{
3e429f5c
 												$$=htonl( ($1<<24)|
 													($3<<16)| ($5<<8)|$7 );
09e52ebb
 											}
 												}
3c1a8ef8
 	;
 
f20a56a2
 route_stm:	ROUTE LBRACE actions RBRACE { push($3, &rlist[DEFAULT_RT]); }
3e429f5c
 
f20a56a2
 		| ROUTE LBRACK NUMBER RBRACK LBRACE actions RBRACE { 
3e429f5c
 										if (($3<RT_NO) && ($3>=0)){
 											push($6, &rlist[$3]);
 										}else{
 											yyerror("invalid routing"
 													"table number");
 											YYABORT; }
 										}
c07508e2
 		| ROUTE error { yyerror("invalid  route  statement"); }
3c1a8ef8
 	;
f20a56a2
 /*
7268726e
 rules:	rules rule { push($2, &$1); $$=$1; }
 	| rule {$$=$1; }
3e429f5c
 	| rules error { $$=0; yyerror("invalid rule"); }
3c1a8ef8
 	 ;
 
09e52ebb
 rule:	condition	actions CR {
3e429f5c
 								$$=0;
 								if (add_rule($1, $2, &$$)<0) {
 									yyerror("error calling add_rule");
 									YYABORT;
 								}
 							  }
f20a56a2
 	| CR		{ $$=0;}
3e429f5c
 	| condition error { $$=0; yyerror("bad actions in rule"); }
3c1a8ef8
 	;
 
09e52ebb
 condition:	exp {$$=$1;}
f20a56a2
 */
3c1a8ef8
 
09e52ebb
 exp:	exp AND exp 	{ $$=mk_exp(AND_OP, $1, $3); }
 	| exp OR  exp		{ $$=mk_exp(OR_OP, $1, $3);  }
 	| NOT exp 			{ $$=mk_exp(NOT_OP, $2, 0);  }
 	| LPAREN exp RPAREN	{ $$=$2; }
 	| exp_elem			{ $$=$1; }
3c1a8ef8
 	;
 
09e52ebb
 exp_elem:	METHOD EQUAL_T STRING	{$$= mk_elem(	EQUAL_OP, STRING_ST, 
 													METHOD_O, $3);
 									}
 		| METHOD EQUAL_T ID	{$$ = mk_elem(	EQUAL_OP, STRING_ST,
 											METHOD_O, $3); 
 				 			}
c07508e2
 		| METHOD EQUAL_T error { $$=0; yyerror("string expected"); }
09e52ebb
 		| METHOD MATCH STRING	{$$ = mk_elem(	MATCH_OP, STRING_ST,
 												METHOD_O, $3); 
 				 				}
 		| METHOD MATCH ID	{$$ = mk_elem(	MATCH_OP, STRING_ST,
 											METHOD_O, $3); 
 				 			}
c07508e2
 		| METHOD MATCH error { $$=0; yyerror("string expected"); }
09e52ebb
 		| METHOD error	{ $$=0; yyerror("invalid operator,"
7268726e
 										"== or =~ expected");
09e52ebb
 						}
 		| URI EQUAL_T STRING 	{$$ = mk_elem(	EQUAL_OP, STRING_ST,
 												URI_O, $3); 
 				 				}
 		| URI EQUAL_T ID 	{$$ = mk_elem(	EQUAL_OP, STRING_ST,
 											URI_O, $3); 
 				 			}
c07508e2
 		| URI EQUAL_T error { $$=0; yyerror("string expected"); }
09e52ebb
 		| URI MATCH STRING	{ $$=mk_elem(	MATCH_OP, STRING_ST,
 											URI_O, $3);
 							}
 		| URI MATCH ID		{ $$=mk_elem(	MATCH_OP, STRING_ST,
 											URI_O, $3);
 							}
c07508e2
 		| URI MATCH error {  $$=0; yyerror("string expected"); }
09e52ebb
 		| URI error	{ $$=0; yyerror("invalid operator,"
7268726e
 				  					" == or =~ expected");
09e52ebb
 					}
 		| SRCIP EQUAL_T net4	{ $$=mk_elem(	EQUAL_OP, NET_ST,
 												SRCIP_O, $3);
 								}
 		| SRCIP EQUAL_T STRING	{ $$=mk_elem(	EQUAL_OP, STRING_ST,
 												SRCIP_O, $3);
 								}
 		| SRCIP EQUAL_T host	{ $$=mk_elem(	EQUAL_OP, STRING_ST,
 												SRCIP_O, $3);
 								}
 		| SRCIP EQUAL_T error { $$=0; yyerror( "ip address or hostname"
c07508e2
 						 "expected" ); }
09e52ebb
 		| SRCIP MATCH STRING	{ $$=mk_elem(	MATCH_OP, STRING_ST,
 												SRCIP_O, $3);
 								}
 		| SRCIP MATCH ID		{ $$=mk_elem(	MATCH_OP, STRING_ST,
 												SRCIP_O, $3);
 								}
 		| SRCIP MATCH error  { $$=0; yyerror( "hostname expected"); }
 		| SRCIP error  { $$=0; 
7268726e
 						 yyerror("invalid operator, == or =~ expected");}
09e52ebb
 		| DSTIP EQUAL_T net4	{ $$=mk_elem(	EQUAL_OP, NET_ST,
 												DSTIP_O, $3);
 								}
 		| DSTIP EQUAL_T STRING	{ $$=mk_elem(	EQUAL_OP, STRING_ST,
 												DSTIP_O, $3);
 								}
 		| DSTIP EQUAL_T host	{ $$=mk_elem(	EQUAL_OP, STRING_ST,
 												DSTIP_O, $3);
 								}
 		| DSTIP EQUAL_T error { $$=0; yyerror( "ip address or hostname"
 						 			"expected" ); }
 		| DSTIP MATCH STRING	{ $$=mk_elem(	MATCH_OP, STRING_ST,
 												DSTIP_O, $3);
 								}
 		| DSTIP MATCH ID	{ $$=mk_elem(	MATCH_OP, STRING_ST,
 											DSTIP_O, $3);
 							}
 		| DSTIP MATCH error  { $$=0; yyerror ( "hostname  expected" ); }
 		| DSTIP error { $$=0; 
7268726e
 						yyerror("invalid operator, == or =~ expected");}
f20a56a2
 		| stm				{ $$=mk_elem( NO_OP, ACTIONS_ST, ACTION_O, $1 ); }
 		| NUMBER		{$$=mk_elem( NO_OP, NUMBER_ST, NUMBER_O, (void*)$1 ); }
3c1a8ef8
 	;
 
09e52ebb
 net4:	ipv4 SLASH ipv4	{ $$=mk_net($1, $3); } 
a15c363f
 	| ipv4 SLASH NUMBER {	if (($3>32)|($3<0)){
09e52ebb
 								yyerror("invalid bit number in netmask");
 								$$=0;
 							}else{
f20a56a2
 								$$=mk_net($1, 
 										htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
09e52ebb
 							}
 						}
 	| ipv4				{ $$=mk_net($1, 0xffffffff); }
 	| ipv4 SLASH error { $$=0;
 						 yyerror("netmask (eg:255.0.0.0 or 8) expected");}
3c1a8ef8
 	;
 
09e52ebb
 host:	ID				{ $$=$1; }
 	| host DOT ID		{ $$=(char*)malloc(strlen($1)+1+strlen($3)+1);
 						  if ($$==0){
f20a56a2
 						  	LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
 										" failure while parsing host\n");
09e52ebb
 						  }else{
 						  	memcpy($$, $1, strlen($1));
 						  	$$[strlen($1)]='.';
 						  	memcpy($$+strlen($1)+1, $3, strlen($3));
 						  	$$[strlen($1)+1+strlen($3)]=0;
 						  }
 						  free($1); free($3);
 						};
 	| host DOT error { $$=0; free($1); yyerror("invalid hostname"); }
3c1a8ef8
 	;
 
 
f20a56a2
 stm:		cmd						{ $$=$1; }
 		|	LBRACE actions RBRACE	{ $$=$2; }
 	;
 
09e52ebb
 actions:	actions action	{$$=append_action($1, $2); }
 		| action			{$$=$1;}
 		| actions error { $$=0; yyerror("bad command"); }
c07508e2
 	;
 
09e52ebb
 action:		cmd SEMICOLON {$$=$1;}
 		| SEMICOLON /* null action */ {$$=0;}
 		| cmd error { $$=0; yyerror("bad command: missing ';'?"); }
3c1a8ef8
 	;
 
f20a56a2
 if_cmd:		IF exp stm				{ $$=mk_action3( IF_T,
 													 EXPR_ST,
 													 ACTIONS_ST,
 													 NOSUBTYPE,
 													 $2,
 													 $3,
 													 0);
 									}
 		|	IF exp stm ELSE stm		{ $$=mk_action3( IF_T,
 													 EXPR_ST,
 													 ACTIONS_ST,
 													 ACTIONS_ST,
 													 $2,
 													 $3,
 													 $5);
 									}
 	;
 
09e52ebb
 cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 														STRING_ST,
 														NUMBER_ST,
 														$3,
 														0);
 										}
 		| FORWARD LPAREN STRING RPAREN	{ $$=mk_action(	FORWARD_T,
 														STRING_ST,
 														NUMBER_ST,
 														$3,
 														0);
 										}
 		| FORWARD LPAREN ipv4 RPAREN	{ $$=mk_action(	FORWARD_T,
 														IP_ST,
 														NUMBER_ST,
 														(void*)$3,
 														0);
 										}
 		| FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T,
 																 STRING_ST,
 																 NUMBER_ST,
 																$3,
 																(void*)$5);
 												 }
 		| FORWARD LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T,
 																 STRING_ST,
 																 NUMBER_ST,
 																$3,
 																(void*)$5);
 													}
 		| FORWARD LPAREN ipv4 COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T,
 																 IP_ST,
 																 NUMBER_ST,
 																 (void*)$3,
 																(void*)$5);
 												  }
5ada8f8a
 		| FORWARD LPAREN URIHOST COMMA URIPORT RPAREN {
 													$$=mk_action(FORWARD_T,
 																 URIHOST_ST,
 																 URIPORT_ST,
 																0,
 																0);
 													}
 													
 									
 		| FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {
 													$$=mk_action(FORWARD_T,
 																 URIHOST_ST,
 																 NUMBER_ST,
 																0,
 																(void*)$5);
 													}
 		| FORWARD LPAREN URIHOST RPAREN {
 													$$=mk_action(FORWARD_T,
 																 URIHOST_ST,
 																 NUMBER_ST,
 																0,
 																0);
 										}
09e52ebb
 		| FORWARD error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| FORWARD LPAREN error RPAREN { $$=0; yyerror("bad forward"
 										"argument"); }
 		| SEND LPAREN host RPAREN	{ $$=mk_action(	SEND_T,
 													STRING_ST,
 													NUMBER_ST,
 													$3,
 													0);
 									}
 		| SEND LPAREN STRING RPAREN { $$=mk_action(	SEND_T,
 													STRING_ST,
 													NUMBER_ST,
 													$3,
 													0);
 									}
 		| SEND LPAREN ipv4 RPAREN	{ $$=mk_action(	SEND_T,
 													IP_ST,
 													NUMBER_ST,
 													(void*)$3,
 													0);
 									}
 		| SEND LPAREN host COMMA NUMBER RPAREN	{ $$=mk_action(	SEND_T,
 																STRING_ST,
 																NUMBER_ST,
 																$3,
 																(void*)$5);
 												}
 		| SEND LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(	SEND_T,
 																STRING_ST,
 																NUMBER_ST,
 																$3,
 																(void*)$5);
 												}
 		| SEND LPAREN ipv4 COMMA NUMBER RPAREN { $$=mk_action(	SEND_T,
 																IP_ST,
 																NUMBER_ST,
 																(void*)$3,
 																(void*)$5);
 											   }
 		| SEND error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| SEND LPAREN error RPAREN { $$=0; yyerror("bad send"
 													"argument"); }
 		| DROP LPAREN RPAREN	{$$=mk_action(DROP_T,0, 0, 0, 0); }
 		| DROP					{$$=mk_action(DROP_T,0, 0, 0, 0); }
7268726e
 		| LOG_TOK LPAREN STRING RPAREN	{$$=mk_action(	LOG_T, NUMBER_ST, 
09e52ebb
 													STRING_ST,(void*)4,$3);
 									}
7268726e
 		| LOG_TOK LPAREN NUMBER COMMA STRING RPAREN	{$$=mk_action(	LOG_T,
09e52ebb
 																NUMBER_ST, 
 																STRING_ST,
 																(void*)$3,
 																$5);
 												}
7268726e
 		| LOG_TOK error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| LOG_TOK LPAREN error RPAREN { $$=0; yyerror("bad log"
09e52ebb
 									"argument"); }
 		| ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T,
 																STRING_ST, 
 																STRING_ST,
 																$3,
 																$5);
 												  }
 												
 		| ERROR error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| ERROR LPAREN error RPAREN { $$=0; yyerror("bad error"
 														"argument"); }
 		| ROUTE LPAREN NUMBER RPAREN	{ $$=mk_action(ROUTE_T, NUMBER_ST,
 														0, (void*)$3, 0);
 										}
 		| ROUTE error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| ROUTE LPAREN error RPAREN { $$=0; yyerror("bad route"
c07508e2
 						"argument"); }
09e52ebb
 		| EXEC LPAREN STRING RPAREN	{ $$=mk_action(	EXEC_T, STRING_ST, 0,
 													$3, 0);
 									}
f20a56a2
 		| SET_HOST LPAREN STRING RPAREN { $$=mk_action(SET_HOST_T, STRING_ST,
 														0, $3, 0); }
7268726e
 		| SET_HOST error { $$=0; yyerror("missing '(' or ')' ?"); }
f20a56a2
 		| SET_HOST LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"string expected"); }
 		| SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action( SET_HOSTPORT_T, 
 														STRING_ST, 0, $3, 0); }
7268726e
 		| SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); }
f20a56a2
 		| SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument,"
 												" string expected"); }
 		| SET_PORT LPAREN STRING RPAREN { $$=mk_action( SET_PORT_T, STRING_ST,
 														0, $3, 0); }
7268726e
 		| SET_PORT error { $$=0; yyerror("missing '(' or ')' ?"); }
f20a56a2
 		| SET_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"string expected"); }
 		| SET_USER LPAREN STRING RPAREN { $$=mk_action( SET_USER_T, STRING_ST,
 														0, $3, 0); }
7268726e
 		| SET_USER error { $$=0; yyerror("missing '(' or ')' ?"); }
f20a56a2
 		| SET_USER LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"string expected"); }
 		| SET_USERPASS LPAREN STRING RPAREN { $$=mk_action( SET_USERPASS_T, 
 														STRING_ST, 0, $3, 0); }
7268726e
 		| SET_USERPASS error { $$=0; yyerror("missing '(' or ')' ?"); }
f20a56a2
 		| SET_USERPASS LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"string expected"); }
 		| SET_URI LPAREN STRING RPAREN { $$=mk_action( SET_URI_T, STRING_ST, 
 														0, $3, 0); }
7268726e
 		| SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); }
f20a56a2
 		| SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 										"string expected"); }
34fd2612
 		| ID LPAREN RPAREN			{ f_tmp=find_export($1, 0);
 									   if (f_tmp==0){
2bd748c6
 										yyerror("unknown command, missing"
34fd2612
 										" loadmodule?\n");
 										$$=0;
 									   }else{
 										$$=mk_action(	MODULE_T,
 														CMDF_ST,
 														0,
 														f_tmp,
 														0
 													);
 									   }
 									}
 		| ID LPAREN STRING RPAREN { f_tmp=find_export($1, 1);
3bf76e49
 									if (f_tmp==0){
2bd748c6
 										yyerror("unknown command, missing"
3bf76e49
 										" loadmodule?\n");
 										$$=0;
 									}else{
 										$$=mk_action(	MODULE_T,
 														CMDF_ST,
 														STRING_ST,
 														f_tmp,
 														$3
 													);
 									}
 								  }
34fd2612
 		| ID LPAREN STRING  COMMA STRING RPAREN 
 								  { f_tmp=find_export($1, 2);
 									if (f_tmp==0){
2bd748c6
 										yyerror("unknown command, missing"
34fd2612
 										" loadmodule?\n");
 										$$=0;
 									}else{
 										$$=mk_action3(	MODULE_T,
 														CMDF_ST,
 														STRING_ST,
 														STRING_ST,
 														f_tmp,
 														$3,
 														$5
 													);
 									}
 								  }
3bf76e49
 		| ID LPAREN error RPAREN { $$=0; yyerror("bad arguments"); }
f20a56a2
 		| if_cmd		{ $$=$1; }
3c1a8ef8
 	;
 
 
 %%
 
 extern int line;
 extern int column;
09e52ebb
 extern int startcolumn;
3e429f5c
 void yyerror(char* s)
3c1a8ef8
 {
7268726e
 	LOG(L_CRIT, "parse error (%d,%d-%d): %s\n", line, startcolumn, 
09e52ebb
 			column, s);
63fa628f
 	cfg_errors++;
3c1a8ef8
 }
 
a15c363f
 /*
3c1a8ef8
 int main(int argc, char ** argv)
 {
 	if (yyparse()!=0)
 		fprintf(stderr, "parsing error\n");
 }
a15c363f
 */