Browse code

New module interface.

Jan Janak authored on 03/04/2002 21:55:31
Showing 3 changed files
... ...
@@ -666,8 +666,8 @@ int main(int argc, char** argv)
666 666
 		goto error;
667 667
 	}
668 668
 
669
-	/*init builtin  modules*/
670
-	init_builtin_modules();
669
+	/*register builtin  modules*/
670
+	register_builtin_modules();
671 671
 
672 672
 	yyin=cfg_stream;
673 673
 	if ((yyparse()!=0)||(cfg_errors)){
... ...
@@ -675,7 +675,11 @@ int main(int argc, char** argv)
675 675
 		goto error;
676 676
 	}
677 677
 	
678
-	
678
+	if (init_modules() != 0) {
679
+		fprintf(stderr, "ERROR: error while initializing modules\n");
680
+		goto error;
681
+	}
682
+
679 683
 	print_rl();
680 684
 	/* fix routing lists */
681 685
 	if ( (r=fix_rls())!=0){
682 686
new file mode 100644
... ...
@@ -0,0 +1,37 @@
0
+#include "modparam.h"
1
+#include "dprint.h"
2
+#include <string.h>
3
+
4
+
5
+int set_mod_param(char* _mod, char* _name, modparam_t _type, void* _val)
6
+{
7
+	void* ptr;
8
+	
9
+	if (!_mod) {
10
+		LOG(L_ERR, "set_mod_param(): Invalid _mod parameter value\n");
11
+		return -1;
12
+	}
13
+
14
+	if (!_name) {
15
+		LOG(L_ERR, "set_mod_param(): Invalid _name parameter value\n");
16
+		return -2;
17
+	}
18
+
19
+	ptr = find_param_export(_mod, _name, _type);
20
+	if (!ptr) {
21
+		LOG(L_ERR, "set_mod_param(): Parameter not found\n");
22
+		return -3;
23
+	}
24
+
25
+	switch(_type) {
26
+	case STR_PARAM:
27
+		*((char**)ptr) = strdup((char*)_val);
28
+		break;
29
+
30
+	case INT_PARAM:
31
+		*((int*)ptr) = (int)_val;
32
+		break;
33
+	}
34
+
35
+	return 0;
36
+}
0 37
new file mode 100644
... ...
@@ -0,0 +1,8 @@
0
+#ifndef modparam_h
1
+#define modparam_h
2
+
3
+#include "sr_module.h"
4
+
5
+int set_mod_param(char* _mod, char* _name, modparam_t _type, void* _val);
6
+
7
+#endif