Browse code

- support for str param type (xxx_PARAM->PARAM_xxx, PARAM_STRING)

Tomas Mandys authored on 07/01/2006 23:24:58
Showing 7 changed files
... ...
@@ -22,8 +22,8 @@
22 22
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 23
  * GNU General Public License for more details.
24 24
  *
25
- * You should have received a copy of the GNU General Public License 
26
- * along with this program; if not, write to the Free Software 
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program; if not, write to the Free Software
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 28
  */
29 29
  /*
... ...
@@ -39,7 +39,7 @@
39 39
  * 2003-04-12  added force_rport, chroot and wdir (andrei)
40 40
  * 2003-04-15  added tcp_children, disable_tcp (andrei)
41 41
  * 2003-04-22  strip_tail added (jiri)
42
- * 2003-07-03  tls* (disable, certificate, private_key, ca_list, verify, 
42
+ * 2003-07-03  tls* (disable, certificate, private_key, ca_list, verify,
43 43
  *              require_certificate added (andrei)
44 44
  * 2003-07-06  more tls config. vars added: tls_method, tls_port_no (andrei)
45 45
  * 2003-10-02  added {,set_}advertised_{address,port} (andrei)
... ...
@@ -68,7 +68,7 @@
68 68
  *             snd_{ip,port,proto,af}, to_{ip,proto} (andrei)
69 69
  * 2005-12-19  select framework (mma)
70 70
  * 2006-01-06  AVP index support (mma)
71
- *
71
+ * 2005-01-07  optional semicolon in statement, PARAM_STR&PARAM_STRING
72 72
  */
73 73
 
74 74
 %{
... ...
@@ -157,7 +157,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
157 157
 %token SEND
158 158
 %token SEND_TCP
159 159
 %token DROP
160
-%token RETURN 
160
+%token RETURN
161 161
 %token BREAK
162 162
 %token LOG_TOK
163 163
 %token ERROR
... ...
@@ -208,8 +208,8 @@ static struct socket_id* mk_listen_id(char*, int, int);
208 208
 %token PROTO
209 209
 %token AF
210 210
 %token MYSELF
211
-%token MSGLEN 
212
-%token RETCODE 
211
+%token MSGLEN
212
+%token RETCODE
213 213
 %token UDP
214 214
 %token TCP
215 215
 %token TLS
... ...
@@ -297,7 +297,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
297 297
 %left LOG_OR
298 298
 %left LOG_AND
299 299
 %left BIN_OR
300
-%left BIN_AND 
300
+%left BIN_AND
301 301
 %left PLUS MINUS
302 302
 %right NOT
303 303
 
... ...
@@ -362,13 +362,14 @@ statements:	statements statement {}
362 362
 		| statements error { yyerror(""); YYABORT;}
363 363
 	;
364 364
 
365
-statement:	assign_stm 
365
+statement:	assign_stm
366 366
 		| module_stm
367
-		| {rt=REQUEST_ROUTE;} route_stm 
367
+		| {rt=REQUEST_ROUTE;} route_stm
368 368
 		| {rt=FAILURE_ROUTE;} failure_route_stm
369 369
 		| {rt=ONREPLY_ROUTE;} onreply_route_stm
370 370
 		| {rt=BRANCH_ROUTE;} branch_route_stm
371 371
 		| {rt=ONSEND_ROUTE;}   send_route_stm
372
+		| SEMICOLON	/* null statement */
372 373
 		| CR	/* null statement*/
373 374
 	;
374 375
 
... ...
@@ -462,9 +463,9 @@ assign_stm:	DEBUG_V EQUAL NUMBER { debug=$3; }
462 462
 							}
463 463
 		| MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
464 464
 		| MAXBUFFER EQUAL error { yyerror("number expected"); }
465
-		| PORT EQUAL error    { yyerror("number expected"); } 
465
+		| PORT EQUAL error    { yyerror("number expected"); }
466 466
 		| CHILDREN EQUAL NUMBER { children_no=$3; }
467
-		| CHILDREN EQUAL error { yyerror("number expected"); } 
467
+		| CHILDREN EQUAL error { yyerror("number expected"); }
468 468
 		| CHECK_VIA EQUAL NUMBER { check_via=$3; }
469 469
 		| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
470 470
 		| SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
... ...
@@ -580,7 +581,7 @@ assign_stm:	DEBUG_V EQUAL NUMBER { debug=$3; }
580 580
 									#endif
581 581
 									}
582 582
 		| DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
583
-		| TLSLOG EQUAL NUMBER 		{ 
583
+		| TLSLOG EQUAL NUMBER 		{
584 584
 									#ifdef USE_TLS
585 585
 										tls_log=$3;
586 586
 									#else
... ...
@@ -632,7 +633,7 @@ assign_stm:	DEBUG_V EQUAL NUMBER { debug=$3; }
632 632
 										warn("tls support not compiled in");
633 633
 									#endif
634 634
 									}
635
-										
635
+
636 636
 		| TLS_VERIFY EQUAL NUMBER {
637 637
 									#ifdef USE_TLS
638 638
 										tls_verify_cert=$3;
... ...
@@ -650,7 +651,7 @@ assign_stm:	DEBUG_V EQUAL NUMBER { debug=$3; }
650 650
 									}
651 651
 		| TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value"
652 652
 																" expected"); }
653
-		| TLS_CERTIFICATE EQUAL STRING { 
653
+		| TLS_CERTIFICATE EQUAL STRING {
654 654
 									#ifdef USE_TLS
655 655
 											tls_cert_file=$3;
656 656
 									#else
... ...
@@ -658,7 +659,7 @@ assign_stm:	DEBUG_V EQUAL NUMBER { debug=$3; }
658 658
 									#endif
659 659
 									}
660 660
 		| TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
661
-		| TLS_PRIVATE_KEY EQUAL STRING { 
661
+		| TLS_PRIVATE_KEY EQUAL STRING {
662 662
 									#ifdef USE_TLS
663 663
 											tls_pkey_file=$3;
664 664
 									#else
... ...
@@ -666,7 +667,7 @@ assign_stm:	DEBUG_V EQUAL NUMBER { debug=$3; }
666 666
 									#endif
667 667
 									}
668 668
 		| TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
669
-		| TLS_CA_LIST EQUAL STRING { 
669
+		| TLS_CA_LIST EQUAL STRING {
670 670
 									#ifdef USE_TLS
671 671
 											tls_ca_file=$3;
672 672
 									#else
... ...
@@ -709,7 +710,7 @@ assign_stm:	DEBUG_V EQUAL NUMBER { debug=$3; }
709 709
 							 }
710 710
 		| LISTEN EQUAL  error { yyerror("ip address or hostname"
711 711
 						"expected"); }
712
-		| ALIAS EQUAL  id_lst { 
712
+		| ALIAS EQUAL  id_lst {
713 713
 							for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next)
714 714
 								add_alias(lst_tmp->name, strlen(lst_tmp->name),
715 715
 											lst_tmp->port, lst_tmp->proto);
... ...
@@ -772,12 +773,12 @@ module_stm:	LOADMODULE STRING	{ DBG("loading module %s\n", $2);
772 772
 								}
773 773
 		 | LOADMODULE error	{ yyerror("string expected");  }
774 774
                  | MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
775
-			 if (set_mod_param_regex($3, $5, STR_PARAM, $7) != 0) {
775
+			 if (set_mod_param_regex($3, $5, PARAM_STR|PARAM_STRING, $7) != 0) {
776 776
 				 yyerror("Can't set module parameter");
777 777
 			 }
778 778
 		   }
779 779
                  | MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN {
780
-			 if (set_mod_param_regex($3, $5, INT_PARAM, (void*)$7) != 0) {
780
+			 if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) {
781 781
 				 yyerror("Can't set module parameter");
782 782
 			 }
783 783
 		   }
... ...
@@ -789,7 +790,7 @@ ip:		 ipv4  { $$=$1; }
789 789
 		|ipv6  { $$=$1; }
790 790
 		;
791 791
 
792
-ipv4:	NUMBER DOT NUMBER DOT NUMBER DOT NUMBER { 
792
+ipv4:	NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
793 793
 											$$=pkg_malloc(
794 794
 													sizeof(struct ip_addr));
795 795
 											if ($$==0){
... ...
@@ -797,7 +798,7 @@ ipv4:	NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
797 797
 													"parser: out of memory.\n"
798 798
 													);
799 799
 											}else{
800
-												memset($$, 0, 
800
+												memset($$, 0,
801 801
 													sizeof(struct ip_addr));
802 802
 												$$->af=AF_INET;
803 803
 												$$->len=4;
... ...
@@ -850,7 +851,7 @@ ipv6:	ipv6addr { $$=$1; }
850 850
 
851 851
 route_stm:  ROUTE LBRACE actions RBRACE { push($3, &rlist[DEFAULT_RT]); }
852 852
 
853
-	    | ROUTE LBRACK NUMBER RBRACK LBRACE actions RBRACE { 
853
+	    | ROUTE LBRACK NUMBER RBRACK LBRACE actions RBRACE {
854 854
 										if (($3<RT_NO) && ($3>=0)){
855 855
 											push($6, &rlist[$3]);
856 856
 										}else{
... ...
@@ -941,7 +942,7 @@ exp:	exp LOG_AND exp 	{ $$=mk_exp(LOGAND_OP, $1, $3); }
941 941
 equalop:	  EQUAL_T {$$=EQUAL_OP; }
942 942
 			| DIFF	{$$=DIFF_OP; }
943 943
 		;
944
-		
944
+
945 945
 intop:	equalop	{$$=$1; }
946 946
 		|  GT	{$$=GT_OP; }
947 947
 		| LT	{$$=LT_OP; }
... ...
@@ -952,7 +953,7 @@ intop:	equalop	{$$=$1; }
952 952
 binop : BIN_OR { $$= BINOR_OP; }
953 953
       | BIN_AND { $$ = BINAND_OP; }
954 954
 ;
955
-		
955
+
956 956
 strop:	equalop	{$$=$1; }
957 957
 		| MATCH	{$$=MATCH_OP; }
958 958
 		;
... ...
@@ -1060,7 +1061,7 @@ exp_elem:	METHOD strop STRING	{$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1060 1060
 										ip_tmp=str2ip6(&s_tmp);
1061 1061
 									if (ip_tmp){
1062 1062
 										$$=mk_elem(	$2, SRCIP_O, 0, NET_ST,
1063
-												mk_net_bitlen(ip_tmp, 
1063
+												mk_net_bitlen(ip_tmp,
1064 1064
 														ip_tmp->len*8) );
1065 1065
 									}else{
1066 1066
 										$$=mk_elem(	$2, SRCIP_O, 0, STRING_ST,
... ...
@@ -1073,7 +1074,7 @@ exp_elem:	METHOD strop STRING	{$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1073 1073
 								}
1074 1074
 		| SRCIP strop error { $$=0; yyerror( "ip address or hostname"
1075 1075
 						 "expected" ); }
1076
-		| SRCIP error  { $$=0; 
1076
+		| SRCIP error  { $$=0;
1077 1077
 						 yyerror("invalid operator, ==, != or =~ expected");}
1078 1078
 		| DSTIP equalop ipnet	{ $$=mk_elem(	$2, DSTIP_O, 0, NET_ST,
1079 1079
 												(void*)$3);
... ...
@@ -1085,7 +1086,7 @@ exp_elem:	METHOD strop STRING	{$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1085 1085
 										ip_tmp=str2ip6(&s_tmp);
1086 1086
 									if (ip_tmp){
1087 1087
 										$$=mk_elem(	$2, DSTIP_O, 0, NET_ST,
1088
-												mk_net_bitlen(ip_tmp, 
1088
+												mk_net_bitlen(ip_tmp,
1089 1089
 														ip_tmp->len*8) );
1090 1090
 									}else{
1091 1091
 										$$=mk_elem(	$2, DSTIP_O, 0, STRING_ST,
... ...
@@ -1100,7 +1101,7 @@ exp_elem:	METHOD strop STRING	{$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1100 1100
 								}
1101 1101
 		| DSTIP strop error { $$=0; yyerror( "ip address or hostname"
1102 1102
 						 			"expected" ); }
1103
-		| DSTIP error { $$=0; 
1103
+		| DSTIP error { $$=0;
1104 1104
 						yyerror("invalid operator, ==, != or =~ expected");}
1105 1105
 		| SNDIP equalop ipnet	{ onsend_check("snd_ip");
1106 1106
 									$$=mk_elem($2, SNDIP_O, 0, NET_ST, $3); }
... ...
@@ -1112,7 +1113,7 @@ exp_elem:	METHOD strop STRING	{$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1112 1112
 										ip_tmp=str2ip6(&s_tmp);
1113 1113
 									if (ip_tmp){
1114 1114
 										$$=mk_elem(	$2, SNDIP_O, 0, NET_ST,
1115
-												mk_net_bitlen(ip_tmp, 
1115
+												mk_net_bitlen(ip_tmp,
1116 1116
 														ip_tmp->len*8) );
1117 1117
 									}else{
1118 1118
 										$$=mk_elem(	$2, SNDIP_O, 0, STRING_ST,
... ...
@@ -1126,7 +1127,7 @@ exp_elem:	METHOD strop STRING	{$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1126 1126
 								}
1127 1127
 		| SNDIP strop error { $$=0; yyerror( "ip address or hostname"
1128 1128
 						 "expected" ); }
1129
-		| SNDIP error  { $$=0; 
1129
+		| SNDIP error  { $$=0;
1130 1130
 						 yyerror("invalid operator, ==, != or =~ expected");}
1131 1131
 		| TOIP equalop ipnet	{ onsend_check("to_ip");
1132 1132
 									$$=mk_elem($2, TOIP_O, 0, NET_ST, $3); }
... ...
@@ -1138,7 +1139,7 @@ exp_elem:	METHOD strop STRING	{$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1138 1138
 										ip_tmp=str2ip6(&s_tmp);
1139 1139
 									if (ip_tmp){
1140 1140
 										$$=mk_elem(	$2, TOIP_O, 0, NET_ST,
1141
-												mk_net_bitlen(ip_tmp, 
1141
+												mk_net_bitlen(ip_tmp,
1142 1142
 														ip_tmp->len*8) );
1143 1143
 									}else{
1144 1144
 										$$=mk_elem(	$2, TOIP_O, 0, STRING_ST,
... ...
@@ -1152,7 +1153,7 @@ exp_elem:	METHOD strop STRING	{$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1152 1152
 								}
1153 1153
 		| TOIP strop error { $$=0; yyerror( "ip address or hostname"
1154 1154
 						 "expected" ); }
1155
-		| TOIP error  { $$=0; 
1155
+		| TOIP error  { $$=0;
1156 1156
 						 yyerror("invalid operator, ==, != or =~ expected");}
1157 1157
 
1158 1158
 		| MYSELF equalop uri_type	{ $$=mk_elem(	$2, $3, 0, MYSELF_ST,
... ...
@@ -1170,9 +1171,9 @@ exp_elem:	METHOD strop STRING	{$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1170 1170
 		| MYSELF equalop TOIP  {	onsend_check("to_ip");
1171 1171
 									$$=mk_elem(	$2, TOIP_O, 0, MYSELF_ST, 0);
1172 1172
 								}
1173
-		| MYSELF equalop error {	$$=0; 
1173
+		| MYSELF equalop error {	$$=0;
1174 1174
 									yyerror(" URI, SRCIP or DSTIP expected"); }
1175
-		| MYSELF error	{ $$=0; 
1175
+		| MYSELF error	{ $$=0;
1176 1176
 							yyerror ("invalid operator, == or != expected");
1177 1177
 						}
1178 1178
 		| exp_stm			{ $$=mk_elem( NO_OP, ACTION_O, 0, ACTIONS_ST, $1);  }
... ...
@@ -1192,14 +1193,14 @@ exp_elem:	METHOD strop STRING	{$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1192 1192
 ;
1193 1193
 
1194 1194
 
1195
-ipnet:	ip SLASH ip	{ $$=mk_net($1, $3); } 
1195
+ipnet:	ip SLASH ip	{ $$=mk_net($1, $3); }
1196 1196
 	| ip SLASH NUMBER 	{	if (($3<0) || ($3>$1->len*8)){
1197 1197
 								yyerror("invalid bit number in netmask");
1198 1198
 								$$=0;
1199 1199
 							}else{
1200 1200
 								$$=mk_net_bitlen($1, $3);
1201 1201
 							/*
1202
-								$$=mk_net($1, 
1202
+								$$=mk_net($1,
1203 1203
 										htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
1204 1204
 							*/
1205 1205
 							}
... ...
@@ -1303,11 +1304,11 @@ if_cmd:		IF exp stm				{ $$=mk_action3( IF_T,
1303 1303
 //         | LBRACK ATTR_GLOBAL RBRACK { $$ = AVP_CLASS_GLOBAL; }
1304 1304
 //;
1305 1305
 
1306
-select_param : ID { 
1306
+select_param : ID {
1307 1307
 		    if (sel.n >= MAX_SELECT_PARAMS-1) {
1308 1308
 			    yyerror("Select identifier too long\n");
1309 1309
 		    }
1310
-		    sel.params[sel.n].type = SEL_PARAM_STR; 
1310
+		    sel.params[sel.n].type = SEL_PARAM_STR;
1311 1311
 		    sel.params[sel.n].v.s.s = $1;
1312 1312
 		    sel.params[sel.n].v.s.len = strlen($1);
1313 1313
 		    sel.n++;
... ...
@@ -1340,40 +1341,40 @@ select_id : SELECT_MARK { sel.n = 0; sel.f = 0; } select_params {
1340 1340
 }
1341 1341
 ;
1342 1342
 
1343
-attr_class_spec: ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; } 
1344
-		|ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; } 
1345
-		|ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; } 
1346
-		|ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; } 
1347
-		|ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; } 
1343
+attr_class_spec: ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
1344
+		|ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; }
1345
+		|ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; }
1346
+		|ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; }
1347
+		|ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; }
1348 1348
 
1349 1349
 attr_name_spec : ID { s_attr->type |= AVP_NAME_STR; s_attr->name.s.s = $1; s_attr->name.s.len = strlen ($1); }
1350 1350
 ;
1351
-	       
1351
+
1352 1352
 attr_spec : attr_name_spec |
1353 1353
 	    attr_class_spec DOT attr_name_spec
1354 1354
 ;
1355 1355
 
1356
-attr_mark : ATTR_MARK 
1356
+attr_mark : ATTR_MARK
1357 1357
 	{	s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec));
1358 1358
                 if (!s_attr) { yyerror("No memory left"); }
1359
-                s_attr->type = 0;  
1359
+                s_attr->type = 0;
1360 1360
 	}
1361 1361
 ;
1362 1362
 
1363
-attr_id : attr_mark attr_spec { $$ = s_attr; }	  
1363
+attr_id : attr_mark attr_spec { $$ = s_attr; }
1364 1364
 ;
1365 1365
 
1366 1366
 attr_id_num_idx : attr_mark attr_spec LBRACK NUMBER RBRACK
1367
-	       	{	s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD)); 
1367
+	       	{	s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD));
1368 1368
 			s_attr->index = ($4<0?-$4:$4);
1369
-	       		$$ = s_attr; 
1370
-	       	}	  
1369
+	       		$$ = s_attr;
1370
+	       	}
1371 1371
 ;
1372 1372
 
1373 1373
 attr_id_no_idx : attr_mark attr_spec LBRACK RBRACK
1374
-	       	{	s_attr->type|= AVP_INDEX_ALL; 
1374
+	       	{	s_attr->type|= AVP_INDEX_ALL;
1375 1375
 	       		$$ = s_attr;
1376
-		}	  
1376
+		}
1377 1377
 ;
1378 1378
 
1379 1379
 attr_id_ass : attr_id | attr_id_no_idx
... ...
@@ -1441,8 +1442,8 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1441 1441
 																0,
1442 1442
 																0);
1443 1443
 													}
1444
-													
1445
-									
1444
+
1445
+
1446 1446
 		| FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {
1447 1447
 													$$=mk_action(FORWARD_T,
1448 1448
 																 URIHOST_ST,
... ...
@@ -1506,8 +1507,8 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1506 1506
 																0,
1507 1507
 																0);
1508 1508
 													}
1509
-													
1510
-									
1509
+
1510
+
1511 1511
 		| FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN {
1512 1512
 													$$=mk_action(FORWARD_UDP_T,
1513 1513
 																 URIHOST_ST,
... ...
@@ -1570,8 +1571,8 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1570 1570
 																0,
1571 1571
 																0);
1572 1572
 													}
1573
-													
1574
-									
1573
+
1574
+
1575 1575
 		| FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN {
1576 1576
 													$$=mk_action(FORWARD_TCP_T,
1577 1577
 																 URIHOST_ST,
... ...
@@ -1615,7 +1616,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1615 1615
 													"compiled in");
1616 1616
 										#endif
1617 1617
 										}
1618
-		| FORWARD_TLS LPAREN ip RPAREN	{ 
1618
+		| FORWARD_TLS LPAREN ip RPAREN	{
1619 1619
 										#ifdef USE_TLS
1620 1620
 											$$=mk_action(	FORWARD_TLS_T,
1621 1621
 															IP_ST,
... ...
@@ -1628,7 +1629,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1628 1628
 													"compiled in");
1629 1629
 										#endif
1630 1630
 										}
1631
-		| FORWARD_TLS LPAREN host COMMA NUMBER RPAREN { 
1631
+		| FORWARD_TLS LPAREN host COMMA NUMBER RPAREN {
1632 1632
 										#ifdef USE_TLS
1633 1633
 											$$=mk_action(	FORWARD_TLS_T,
1634 1634
 															 STRING_ST,
... ...
@@ -1680,8 +1681,8 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1680 1680
 													"compiled in");
1681 1681
 										#endif
1682 1682
 													}
1683
-													
1684
-									
1683
+
1684
+
1685 1685
 		| FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN {
1686 1686
 										#ifdef USE_TLS
1687 1687
 											$$=mk_action(	FORWARD_TLS_T,
... ...
@@ -1711,7 +1712,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1711 1711
 		| FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); }
1712 1712
 		| FORWARD_TLS LPAREN error RPAREN { $$=0; yyerror("bad forward_tls"
1713 1713
 										"argument"); }
1714
-		
1714
+
1715 1715
 		| SEND LPAREN host RPAREN	{ $$=mk_action(	SEND_T,
1716 1716
 													STRING_ST,
1717 1717
 													NUMBER_ST,
... ...
@@ -1802,17 +1803,17 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1802 1802
 												0, (void*)EXIT_R_F); }
1803 1803
 		| RETURN				{$$=mk_action(DROP_T,0, 0,
1804 1804
 												(void*)1, (void*)RETURN_R_F); }
1805
-		| RETURN NUMBER			{$$=mk_action(DROP_T,0, 0, 
1805
+		| RETURN NUMBER			{$$=mk_action(DROP_T,0, 0,
1806 1806
 												(void*)$2, (void*)RETURN_R_F);}
1807
-		| RETURN RETCODE		{$$=mk_action(DROP_T, RETCODE_ST, 0, 
1807
+		| RETURN RETCODE		{$$=mk_action(DROP_T, RETCODE_ST, 0,
1808 1808
 														0, (void*)RETURN_R_F);}
1809 1809
 		| BREAK					{$$=mk_action(DROP_T,0, 0,
1810 1810
 												0, (void*)RETURN_R_F); }
1811
-		| LOG_TOK LPAREN STRING RPAREN	{$$=mk_action(	LOG_T, NUMBER_ST, 
1811
+		| LOG_TOK LPAREN STRING RPAREN	{$$=mk_action(	LOG_T, NUMBER_ST,
1812 1812
 													STRING_ST,(void*)4,$3);
1813 1813
 									}
1814 1814
 		| LOG_TOK LPAREN NUMBER COMMA STRING RPAREN	{$$=mk_action(	LOG_T,
1815
-																NUMBER_ST, 
1815
+																NUMBER_ST,
1816 1816
 																STRING_ST,
1817 1817
 																(void*)$3,
1818 1818
 																$5);
... ...
@@ -1830,7 +1831,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1830 1830
 													(void *)$3, 0 ); }
1831 1831
 		| ISFLAGSET error { $$=0; yyerror("missing '(' or ')'?"); }
1832 1832
 		| ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T,
1833
-																STRING_ST, 
1833
+																STRING_ST,
1834 1834
 																STRING_ST,
1835 1835
 																$3,
1836 1836
 																$5);
... ...
@@ -1858,7 +1859,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1858 1858
 		| PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); }
1859 1859
 		| PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, "
1860 1860
 														"string expected"); }
1861
-		| STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, 
1861
+		| STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T,
1862 1862
 									NUMBER_ST, 0, (void *) $3, 0); }
1863 1863
 		| STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); }
1864 1864
 		| STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, "
... ...
@@ -1869,22 +1870,22 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1869 1869
 		| STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
1870 1870
 		| STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, "
1871 1871
 														"number expected"); }
1872
-                | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN { 
1872
+                | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN {
1873 1873
 		    {   qvalue_t q;
1874 1874
 			if (str2q(&q, $5, strlen($5)) < 0) {
1875 1875
 				yyerror("bad argument, q value expected");
1876 1876
 			}
1877
-			$$=mk_action(APPEND_BRANCH_T, STRING_ST, NUMBER_ST, $3, 
1878
-							(void *)(long)q); } 
1877
+			$$=mk_action(APPEND_BRANCH_T, STRING_ST, NUMBER_ST, $3,
1878
+							(void *)(long)q); }
1879 1879
 		}
1880
-	
1880
+
1881 1881
 		| APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action( APPEND_BRANCH_T,
1882 1882
 													STRING_ST, NUMBER_ST, $3, (void *)Q_UNSPECIFIED) ; }
1883 1883
 		| APPEND_BRANCH LPAREN RPAREN { $$=mk_action( APPEND_BRANCH_T,
1884 1884
 													STRING_ST, NUMBER_ST, 0, (void *)Q_UNSPECIFIED ) ; }
1885 1885
 		| APPEND_BRANCH {  $$=mk_action( APPEND_BRANCH_T, STRING_ST, 0, 0, 0 ) ; }
1886 1886
 
1887
-		| SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action( SET_HOSTPORT_T, 
1887
+		| SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action( SET_HOSTPORT_T,
1888 1888
 														STRING_ST, 0, $3, 0); }
1889 1889
 		| SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); }
1890 1890
 		| SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument,"
... ...
@@ -1899,12 +1900,12 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1899 1899
 		| SET_USER error { $$=0; yyerror("missing '(' or ')' ?"); }
1900 1900
 		| SET_USER LPAREN error RPAREN { $$=0; yyerror("bad argument, "
1901 1901
 														"string expected"); }
1902
-		| SET_USERPASS LPAREN STRING RPAREN { $$=mk_action( SET_USERPASS_T, 
1902
+		| SET_USERPASS LPAREN STRING RPAREN { $$=mk_action( SET_USERPASS_T,
1903 1903
 														STRING_ST, 0, $3, 0); }
1904 1904
 		| SET_USERPASS error { $$=0; yyerror("missing '(' or ')' ?"); }
1905 1905
 		| SET_USERPASS LPAREN error RPAREN { $$=0; yyerror("bad argument, "
1906 1906
 														"string expected"); }
1907
-		| SET_URI LPAREN STRING RPAREN { $$=mk_action( SET_URI_T, STRING_ST, 
1907
+		| SET_URI LPAREN STRING RPAREN { $$=mk_action( SET_URI_T, STRING_ST,
1908 1908
 														0, $3, 0); }
1909 1909
 		| SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); }
1910 1910
 		| SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, "
... ...
@@ -1923,7 +1924,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1923 1923
 												}
1924 1924
 		| FORCE_TCP_ALIAS LPAREN RPAREN	{
1925 1925
 					#ifdef USE_TCP
1926
-						$$=mk_action(FORCE_TCP_ALIAS_T,0, 0, 0, 0); 
1926
+						$$=mk_action(FORCE_TCP_ALIAS_T,0, 0, 0, 0);
1927 1927
 					#else
1928 1928
 						yyerror("tcp support not compiled in");
1929 1929
 					#endif
... ...
@@ -1935,7 +1936,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1935 1935
 						yyerror("tcp support not compiled in");
1936 1936
 					#endif
1937 1937
 										}
1938
-		| FORCE_TCP_ALIAS LPAREN error RPAREN	{$$=0; 
1938
+		| FORCE_TCP_ALIAS LPAREN error RPAREN	{$$=0;
1939 1939
 					yyerror("bad argument, number expected");
1940 1940
 					}
1941 1941
 		| SET_ADV_ADDRESS LPAREN listen_id RPAREN {
... ...
@@ -2017,7 +2018,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
2017 2017
 													);
2018 2018
 									}
2019 2019
 								  }
2020
-		| ID LPAREN STRING  COMMA STRING RPAREN 
2020
+		| ID LPAREN STRING  COMMA STRING RPAREN
2021 2021
 								  { f_tmp=(void*)find_export($1, 2, rt);
2022 2022
 									if (f_tmp==0){
2023 2023
 										if (find_export($1, 2, 0)) {
... ...
@@ -2049,14 +2050,14 @@ extern int column;
2049 2049
 extern int startcolumn;
2050 2050
 static void warn(char* s)
2051 2051
 {
2052
-	LOG(L_WARN, "cfg. warning: (%d,%d-%d): %s\n", line, startcolumn, 
2052
+	LOG(L_WARN, "cfg. warning: (%d,%d-%d): %s\n", line, startcolumn,
2053 2053
 			column, s);
2054 2054
 	cfg_errors++;
2055 2055
 }
2056 2056
 
2057 2057
 static void yyerror(char* s)
2058 2058
 {
2059
-	LOG(L_CRIT, "parse error (%d,%d-%d): %s\n", line, startcolumn, 
2059
+	LOG(L_CRIT, "parse error (%d,%d-%d): %s\n", line, startcolumn,
2060 2060
 			column, s);
2061 2061
 	cfg_errors++;
2062 2062
 }
... ...
@@ -272,9 +272,10 @@ typedef struct param_export_ param_export_t;
272 272
 		<simpara><varname>modparam_t type</varname></simpara>
273 273
 		<simpara>
274 274
 		    Type of the parameter. Currently only two types are
275
-		    defined. INT_PARAM for integer parameters (corresponding
276
-		    variable must be of type int) and STR_PARAM for string
277
-		    parameters (corresponding variable must be of type char*).
275
+		    defined. PARAM_INT for integer parameters (corresponding
276
+		    variable must be of type int), PARAM_STR for str parameters
277
+		    (corresponding variable must be of type char*)  and PARAM_STRING 
278
+		    for string parameters (corresponding variable must be of type char*).
278 279
 		</simpara>
279 280
 	    </listitem>
280 281
 	    <listitem>
... ...
@@ -436,10 +437,12 @@ static cmd_export cmds[] = {
436 436
 	<programlisting>
437 437
 int foo_bar = 0;
438 438
 char* bar_foo = "default value";
439
+str bar_bar = STR_STATIC_INIT("default");
439 440
 
440 441
 static param_export params[] = {
441
-    {"foo_bar", INT_PARAM, &amp;foo_bar},
442
-    {"bar_foo", STR_PARAM, bar_foo     },
442
+    {"foo_bar", PARAM_INT, &amp;foo_bar},
443
+    {"bar_foo", PARAM_STRING, &bar_foo},
444
+    {"bar_bar", PARAM_STR, &bar_bar.s},
443 445
     {0, 0, 0}
444 446
 }; 
445 447
 	</programlisting>
... ...
@@ -172,8 +172,8 @@ struct module_exports{
172 172
 	<listitem>
173 173
 	    <para>
174 174
 		<structfield>param_types</structfield> - Array of types of
175
-		parameters, each field of the array can be either STR_PARAM or
176
-		INT_PARAM (currently only two parameter types are defined).
175
+		parameters, each field of the array can be either PARAM_STR/PARAM_STRING or
176
+		PARAM_INT (currently only three parameter types are defined).
177 177
 	    </para>
178 178
 	</listitem>
179 179
 	<listitem>
... ...
@@ -444,14 +444,14 @@ module_stm = "loadmodule" STRING
444 444
 | "loadmodule" error	 { yyerror("string expected");  }
445 445
 | "modparam" "(" STRING "," STRING "," STRING ")" 
446 446
 {
447
-    if (set_mod_param($3, $5, STR_PARAM, $7) != 0) {
447
+    if (set_mod_param($3, $5, PARAM_STR|PARAM_STRING, $7) != 0) {
448 448
         yyerror("Can't set module parameter");
449 449
     }
450 450
 }
451 451
 
452 452
 | "modparam" "(" STRING "," STRING "," NUMBER ")" 
453 453
 {
454
-    if (set_mod_param($3, $5, INT_PARAM, (void*)$7) != 0) {
454
+    if (set_mod_param($3, $5, PARAM_INT, (void*)$7) != 0) {
455 455
         yyerror("Can't set module parameter");
456 456
     }
457 457
 }
... ...
@@ -21,8 +21,8 @@
21 21
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 22
  * GNU General Public License for more details.
23 23
  *
24
- * You should have received a copy of the GNU General Public License 
25
- * along with this program; if not, write to the Free Software 
24
+ * You should have received a copy of the GNU General Public License
25
+ * along with this program; if not, write to the Free Software
26 26
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27 27
  *
28 28
  * History:
... ...
@@ -30,6 +30,7 @@
30 30
  * 2003-03-20  regex support in modparam (janakj)
31 31
  * 2004-03-12  extra flag USE_FUNC_PARAM added to modparam type -
32 32
  *             instead of copying the param value, a func is called (bogdan)
33
+ * 2005-07-01  PARAM_STRING & PARAM_STR support
33 34
  */
34 35
 
35 36
 
... ...
@@ -44,7 +45,8 @@
44 44
 int set_mod_param(char* _mod, char* _name, modparam_t _type, void* _val)
45 45
 {
46 46
 	void* ptr;
47
-	
47
+	modparam_t param_type;
48
+
48 49
 	if (!_mod) {
49 50
 		LOG(L_ERR, "set_mod_param(): Invalid _mod parameter value\n");
50 51
 		return -1;
... ...
@@ -55,22 +57,34 @@ int set_mod_param(char* _mod, char* _name, modparam_t _type, void* _val)
55 55
 		return -2;
56 56
 	}
57 57
 
58
-	ptr = find_param_export(_mod, _name, _type);
58
+
59
+	ptr = find_param_export(find_module_by_name(_mod), _name, _type, &param_type);
59 60
 	if (!ptr) {
60 61
 		LOG(L_ERR, "set_mod_param(): Parameter not found\n");
61 62
 		return -3;
62 63
 	}
63 64
 
64
-	switch(_type) {
65
-	case STR_PARAM:
66
-		*((char**)ptr) = strdup((char*)_val);
67
-		break;
68
-
69
-	case INT_PARAM:
70
-		*((int*)ptr) = (int)(long)_val;
71
-		break;
65
+	if (param_type & PARAM_USE_FUNC) {
66
+		if ( ((param_func_t)(ptr))(param_type, _val) < 0) {
67
+			return -4;
68
+		}
69
+	}
70
+	else {
71
+		switch(PARAM_TYPE_MASK(param_type)) {
72
+			case PARAM_STRING:
73
+				*((char**)ptr) = strdup((char*)_val);
74
+				break;
75
+
76
+			case PARAM_STR:
77
+				((str*)ptr)->s = strdup((char*)_val);
78
+				((str*)ptr)->len = strlen(((str*)ptr)->s);
79
+				break;
80
+
81
+			case PARAM_INT:
82
+				*((int*)ptr) = (int)(long)_val;
83
+				break;
84
+		}
72 85
 	}
73
-
74 86
 	return 0;
75 87
 }
76 88
 
... ...
@@ -78,11 +92,11 @@ int set_mod_param(char* _mod, char* _name, modparam_t _type, void* _val)
78 78
 int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
79 79
 {
80 80
 	struct sr_module* t;
81
-	param_export_t* param;
82 81
 	regex_t preg;
83 82
 	int mod_found, len;
84 83
 	char* reg;
85
-	int n;
84
+	void *ptr;
85
+	modparam_t param_type;
86 86
 
87 87
 	len = strlen(regex);
88 88
 	reg = pkg_malloc(len + 2 + 1);
... ...
@@ -94,47 +108,46 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
94 94
 	memcpy(reg + 1, regex, len);
95 95
 	reg[len + 1] = '$';
96 96
 	reg[len + 2] = '\0';
97
-	
97
+
98 98
 	if (regcomp(&preg, reg, REG_EXTENDED | REG_NOSUB | REG_ICASE)) {
99 99
 		LOG(L_ERR, "set_mod_param_regex(): Error while compiling regular expression\n");
100 100
 		pkg_free(reg);
101 101
 		return -2;
102 102
 	}
103
-	
104
-	mod_found = 0;
105 103
 
104
+	mod_found = 0;
106 105
 	for(t = modules; t; t = t->next) {
107 106
 		if (regexec(&preg, t->exports->name, 0, 0, 0) == 0) {
108
-			DBG("set_mod_param_regex: %s matches module %s\n",
109
-					regex, t->exports->name);
107
+			DBG("set_mod_param_regex: '%s' matches module '%s'\n", regex, t->exports->name);
110 108
 			mod_found = 1;
111
-			for(param=t->exports->params;param && param->name ; param++) {
112
-				if ((strcmp(name, param->name) == 0) &&
113
-				( PARAM_TYPE_MASK(param->type) == type)) {
114
-					DBG("set_mod_param_regex: found <%s> in module %s [%s]\n",
115
-						name, t->exports->name, t->path);
116
-
117
-					if (param->type&USE_FUNC_PARAM) {
118
-						n = ((param_func_t)(param->param_pointer))(type, val );
119
-						if (n<0)
120
-							return -4;
121
-					} else {
122
-						switch(type) {
123
-							case STR_PARAM:
124
-								*((char**)(param->param_pointer)) =
125
-									strdup((char*)val);
126
-								break;
127
-							case INT_PARAM:
128
-								*((int*)(param->param_pointer)) =
129
-									(int)(long)val;
130
-								break;
131
-						}
109
+			ptr = find_param_export(t, name, type, &param_type);
110
+			if (ptr) {
111
+				DBG("set_mod_param_regex: found <%s> in module %s [%s]\n", name, t->exports->name, t->path);
112
+				if (param_type & PARAM_USE_FUNC) {
113
+					if ( ((param_func_t)(ptr))(param_type, val) < 0) {
114
+						regfree(&preg);
115
+						pkg_free(reg);
116
+						return -4;
117
+					}
118
+				}
119
+				else {
120
+					switch(PARAM_TYPE_MASK(param_type)) {
121
+						case PARAM_STRING:
122
+							*((char**)ptr) = strdup((char*)val);
123
+							break;
124
+
125
+						case PARAM_STR:
126
+							((str*)ptr)->s = strdup((char*)val);
127
+							((str*)ptr)->len = strlen(((str*)ptr)->s);
128
+							break;
129
+
130
+						case PARAM_INT:
131
+							*((int*)ptr) = (int)(long)val;
132
+							break;
132 133
 					}
133
-
134
-					break;
135 134
 				}
136 135
 			}
137
-			if (!param || !param->name) {
136
+			else {
138 137
 				LOG(L_ERR, "set_mod_param_regex: parameter <%s> not found in module <%s>\n",
139 138
 				    name, t->exports->name);
140 139
 				regfree(&preg);
... ...
@@ -145,12 +158,10 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
145 145
 	}
146 146
 
147 147
 	regfree(&preg);
148
+	pkg_free(reg);
148 149
 	if (!mod_found) {
149
-		LOG(L_ERR, "set_mod_param_regex: No module matching %s found\n|", regex);
150
-		pkg_free(reg);
150
+		LOG(L_ERR, "set_mod_param_regex: No module matching <%s> found\n", regex);
151 151
 		return -4;
152 152
 	}
153
-
154
-	pkg_free(reg);
155 153
 	return 0;
156 154
 }
... ...
@@ -19,8 +19,8 @@
19 19
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 20
  * GNU General Public License for more details.
21 21
  *
22
- * You should have received a copy of the GNU General Public License 
23
- * along with this program; if not, write to the Free Software 
22
+ * You should have received a copy of the GNU General Public License
23
+ * along with this program; if not, write to the Free Software
24 24
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25 25
  */
26 26
 /*
... ...
@@ -87,12 +87,12 @@ int register_builtin_modules()
87 87
 
88 88
 	ret=0;
89 89
 #ifdef STATIC_TM
90
-	ret=register_module(tm_exports,"built-in", 0); 
90
+	ret=register_module(tm_exports,"built-in", 0);
91 91
 	if (ret<0) return ret;
92 92
 #endif
93 93
 
94 94
 #ifdef STATIC_EXEC
95
-	ret=register_module(exec_exports,"built-in", 0); 
95
+	ret=register_module(exec_exports,"built-in", 0);
96 96
 	if (ret<0) return ret;
97 97
 #endif
98 98
 
... ...
@@ -102,15 +102,15 @@ int register_builtin_modules()
102 102
 #endif
103 103
 
104 104
 #ifdef STATIC_AUTH
105
-	ret=register_module(auth_exports, "built-in", 0); 
105
+	ret=register_module(auth_exports, "built-in", 0);
106 106
 	if (ret<0) return ret;
107 107
 #endif
108
-	
108
+
109 109
 #ifdef STATIC_RR
110 110
 	ret=register_module(rr_exports, "built-in", 0);
111 111
 	if (ret<0) return ret;
112 112
 #endif
113
-	
113
+
114 114
 #ifdef STATIC_USRLOC
115 115
 	ret=register_module(usrloc_exports, "built-in", 0);
116 116
 	if (ret<0) return ret;
... ...
@@ -120,7 +120,7 @@ int register_builtin_modules()
120 120
 	ret=register_module(sl_exports, "built-in", 0);
121 121
 	if (ret<0) return ret;
122 122
 #endif
123
-	
123
+
124 124
 	return ret;
125 125
 }
126 126
 
... ...
@@ -132,7 +132,7 @@ int register_module(struct module_exports* e, char* path, void* handle)
132 132
 {
133 133
 	int ret;
134 134
 	struct sr_module* mod;
135
-	
135
+
136 136
 	ret=-1;
137 137
 
138 138
 	/* add module to the list */
... ...
@@ -183,7 +183,7 @@ static inline int version_control(void *handle, char *path)
183 183
 		LOG(L_ERR, "ERROR: no compile flags in module <%s>\n", path );
184 184
 		return 0;
185 185
 	}
186
-	
186
+
187 187
 	if (strcmp(SER_FULL_VERSION, *m_ver)==0){
188 188
 		if (strcmp(SER_COMPILE_FLAGS, *m_flags)==0)
189 189
 			return 1;
... ...
@@ -206,7 +206,7 @@ int load_module(char* path)
206 206
 	char* error;
207 207
 	struct module_exports* exp;
208 208
 	struct sr_module* t;
209
-	
209
+
210 210
 #ifndef RTLD_NOW
211 211
 /* for openbsd */
212 212
 #define RTLD_NOW DL_LAZY
... ...
@@ -217,7 +217,7 @@ int load_module(char* path)
217 217
 					path, dlerror() );
218 218
 		goto error;
219 219
 	}
220
-	
220
+
221 221
 	for(t=modules;t; t=t->next){
222 222
 		if (t->handle==handle){
223 223
 			LOG(L_WARN, "WARNING: load_module: attempting to load the same"
... ...
@@ -248,7 +248,7 @@ skip:
248 248
 
249 249
 
250 250
 /* searches the module list and returns pointer to the "name" function or
251
- * 0 if not found 
251
+ * 0 if not found
252 252
  * flags parameter is OR value of all flags that must match
253 253
  */
254 254
 cmd_function find_export(char* name, int param_no, int flags)
... ...
@@ -327,32 +327,41 @@ cmd_function find_mod_export(char* mod, char* name, int param_no, int flags)
327 327
 		}
328 328
 	}
329 329
 
330
-	DBG("find_mod_export: <%s> in module %s not found\n", name, mod);
330
+	DBG("find_mod_export: <%s> in module <%s> not found\n", name, mod);
331 331
 	return 0;
332 332
 }
333 333
 
334 334
 
335
+struct sr_module* find_module_by_name(char* mod) {
336
+	struct sr_module* t;
337
+
338
+	for(t = modules; t; t = t->next) {
339
+		if (strcmp(mod, t->exports->name) == 0) {
340
+			return t;
341
+		}
342
+	}
343
+	DBG("find_module_by_name: module <%s> not found\n", mod);
344
+	return 0;
345
+}
335 346
 
336 347
 
337
-void* find_param_export(char* mod, char* name, modparam_t type)
348
+void* find_param_export(struct sr_module* mod, char* name, modparam_t type_mask, modparam_t *param_type)
338 349
 {
339
-	struct sr_module* t;
340 350
 	param_export_t* param;
341 351
 
342
-	for(t = modules; t; t = t->next) {
343
-		if (strcmp(mod, t->exports->name) == 0) {
344
-			for(param=t->exports->params;param && param->name ; param++) {
345
-				if ((strcmp(name, param->name) == 0) &&
346
-				    (param->type == type)) {
347
-					DBG("find_param_export: found <%s> in module %s [%s]\n",
348
-					    name, t->exports->name, t->path);
349
-					return param->param_pointer;
350
-				}
351
-			}
352
+	if (!mod)
353
+		return 0;
354
+	for(param=mod->exports->params;param && param->name ; param++) {
355
+		if ((strcmp(name, param->name) == 0) &&
356
+			((param->type & PARAM_TYPE_MASK(type_mask)) != 0)) {
357
+			DBG("find_param_export: found <%s> in module %s [%s]\n",
358
+				name, mod->exports->name, mod->path);
359
+			*param_type = param->type;
360
+			return param->param_pointer;
352 361
 		}
353 362
 	}
354
-	DBG("find_param_export: parameter <%s> or module <%s> not found\n",
355
-			name, mod);
363
+	DBG("find_param_export: parameter <%s> not found in module <%s>\n",
364
+			name, mod->exports->name);
356 365
 	return 0;
357 366
 }
358 367
 
... ...
@@ -364,9 +373,9 @@ struct sr_module* find_module(void* f, cmd_export_t  **c)
364 364
 {
365 365
 	struct sr_module* t;
366 366
 	cmd_export_t* cmd;
367
-	
367
+
368 368
 	for (t=modules;t;t=t->next){
369
-		for(cmd=t->exports->cmds; cmd && cmd->name; cmd++) 
369
+		for(cmd=t->exports->cmds; cmd && cmd->name; cmd++)
370 370
 			if (f==(void*)cmd->function) {
371 371
 				if (c) *c=cmd;
372 372
 				return t;
... ...
@@ -400,7 +409,7 @@ void destroy_modules()
400 400
 int init_modules(void)
401 401
 {
402 402
 	struct sr_module* t;
403
-	
403
+
404 404
 	for(t = modules; t; t = t->next) {
405 405
 		if ((t->exports) && (t->exports->init_f))
406 406
 			if (t->exports->init_f() != 0) {
... ...
@@ -428,7 +437,7 @@ int init_child(int rank)
428 428
 	default:            type = "CHILD";         break;
429 429
 	}
430 430
 	DBG("init_child: initializing %s with rank %d\n", type, rank);
431
-	
431
+
432 432
 
433 433
 	for(t = modules; t; t = t->next) {
434 434
 		if (t->exports->init_child_f) {
... ...
@@ -458,7 +467,7 @@ static int init_mod_child( struct sr_module* m, int rank )
458 458
 		 */
459 459
 		if (init_mod_child(m->next, rank)!=0) return -1;
460 460
 		if (m->exports && m->exports->init_child_f) {
461
-			DBG("DEBUG: init_mod_child (%d): %s\n", 
461
+			DBG("DEBUG: init_mod_child (%d): %s\n",
462 462
 					rank, m->exports->name);
463 463
 			if (m->exports->init_child_f(rank)<0) {
464 464
 				LOG(L_ERR, "init_mod_child(): Error while initializing"
... ...
@@ -538,13 +547,13 @@ int init_modules(void)
538 538
 int fixup_str_12(void** param, int param_no)
539 539
 {
540 540
 	str* s;
541
-	
541
+
542 542
 	s = (str*)pkg_malloc(sizeof(str));
543 543
 	if (!s) {
544 544
 		LOG(L_ERR, "fixup_str_12: No memory left\n");
545 545
 		return E_UNSPEC;
546 546
 	}
547
-	
547
+
548 548
 	s->s = (char*)*param;
549 549
 	s->len = strlen(s->s);
550 550
 	*param = (void*)s;
... ...
@@ -578,7 +587,7 @@ int fixup_int_12(void** param, int param_no)
578 578
 	int err;
579 579
 
580 580
 	num = str2s(*param, strlen(*param), &err);
581
-	
581
+
582 582
 	if (err == 0) {
583 583
 		pkg_free(*param);
584 584
 		*param=(void*)num;
... ...
@@ -607,7 +616,7 @@ int fixup_int_2(void** param, int param_no)
607 607
 	if (param_no == 2) {
608 608
 		return fixup_int_12(param, param_no);
609 609
 	}
610
-	
610
+
611 611
 	return 0;
612 612
 }
613 613
 
... ...
@@ -22,8 +22,8 @@
22 22
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 23
  * GNU General Public License for more details.
24 24
  *
25
- * You should have received a copy of the GNU General Public License 
26
- * along with this program; if not, write to the Free Software 
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program; if not, write to the Free Software
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 28
  */
29 29
 /*
... ...
@@ -58,10 +58,16 @@ typedef int (*init_function)(void);
58 58
 typedef int (*child_init_function)(int rank);
59 59
 
60 60
 
61
-#define STR_PARAM        (1U<<0)  /* String parameter type */
62
-#define INT_PARAM        (1U<<1)  /* Integer parameter type */
63
-#define USE_FUNC_PARAM   (1U<<(8*sizeof(int)-1))
64
-#define PARAM_TYPE_MASK(_x)   ((_x)&(~USE_FUNC_PARAM))
61
+#define PARAM_STRING     (1U<<0)  /* String (char *) parameter type */
62
+#define PARAM_INT        (1U<<1)  /* Integer parameter type */
63
+#define PARAM_STR        (1U<<2)  /* struct str parameter type */
64
+#define PARAM_USE_FUNC   (1U<<(8*sizeof(int)-1))
65
+#define PARAM_TYPE_MASK(_x)   ((_x)&(~PARAM_USE_FUNC))
66
+
67
+/* temporary, for backward compatibility only until all modules adjust it */
68
+#define STR_PARAM PARAM_STRING
69
+#define INT_PARAM PARAM_INT
70
+#define USE_FUNC_PARAM PARAM_USE_FUNC
65 71
 
66 72
 typedef unsigned int modparam_t;
67 73
 
... ...
@@ -108,7 +114,7 @@ typedef struct param_export_ param_export_t;
108 108
 
109 109
 struct module_exports{
110 110
 	char* name;                     /* null terminated module name */
111
-	
111
+
112 112
 	cmd_export_t* cmds;             /* null terminated array of the exported
113 113
 									   commands */
114 114
 	rpc_export_t* rpc_methods;      /* null terminated array of exported rpc methods */
... ...
@@ -150,13 +156,14 @@ struct sr_module* find_module(void *f, cmd_export_t** cmd);
150 150
 void destroy_modules();
151 151
 int init_child(int rank);
152 152
 int init_modules(void);
153
+struct sr_module* find_module_by_name(char* mod);
153 154
 
154 155
 /*
155 156
  * Find a parameter with given type and return it's
156 157
  * address in memory
157 158
  * If there is no such parameter, NULL is returned
158 159
  */
159
-void* find_param_export(char* mod, char* name, modparam_t type);
160
+void* find_param_export(struct sr_module* mod, char* name, modparam_t type_mask, modparam_t *param_type);
160 161
 
161 162
 /* modules function prototypes:
162 163
  * struct module_exports* mod_register(); (type module_register)