Browse code

app_lua_sr: new module split from app_lua to export old Lua sr lib

Daniel-Constantin Mierla authored on 29/05/2019 11:55:26
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,100 @@
1
+/**
2
+ * Copyright (C) 2010-2019 Daniel-Constantin Mierla (asipto.com)
3
+ *
4
+ * This file is part of Kamailio, a free SIP server.
5
+ *
6
+ * Kamailio is free software; you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation; either version 2 of the License, or
9
+ * (at your option) any later version
10
+ *
11
+ * Kamailio is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
+ *
20
+ */
21
+
22
+#include <stdio.h>
23
+#include <unistd.h>
24
+#include <stdlib.h>
25
+
26
+#include "../../core/sr_module.h"
27
+#include "../../core/dprint.h"
28
+#include "../../core/ut.h"
29
+#include "../../core/mod_fix.h"
30
+
31
+#include "../../modules/app_lua/modapi.h"
32
+
33
+#include "app_lua_sr_api.h"
34
+#include "app_lua_sr_exp.h"
35
+
36
+MODULE_VERSION
37
+
38
+/** parameters */
39
+static int mod_init(void);
40
+
41
+static int app_lua_register_param(modparam_t type, void *val);
42
+
43
+static int app_lua_sr_openlibs(lua_State *L);
44
+
45
+int _ksr_app_lua_log_mode = 0;
46
+
47
+app_lua_api_t _app_lua_api = {0};
48
+
49
+static param_export_t params[]={
50
+	{"register", PARAM_STRING|USE_FUNC_PARAM, (void*)app_lua_register_param},
51
+	{0, 0, 0}
52
+};
53
+
54
+
55
+struct module_exports exports = {
56
+	"app_lua_sr",
57
+	DEFAULT_DLFLAGS, /* dlopen flags */
58
+	0,			/*·exported·functions·*/
59
+	params,		/*·exported·params·*/
60
+	0,			/*·exported·RPC·methods·*/
61
+	0,			/* exported pseudo-variables */
62
+	0,			/*·response·function·*/
63
+	mod_init,	/* initialization module */
64
+	0,			/* per child init function */
65
+	0			/* destroy function */
66
+};
67
+
68
+/**
69
+ * init module function
70
+ */
71
+static int mod_init(void)
72
+{
73
+	if(app_lua_load_api(&_app_lua_api)<0) {
74
+		return -1;
75
+	}
76
+	if(lua_sr_exp_init_mod()<0) {
77
+		return -1;
78
+	}
79
+
80
+	_app_lua_api.openlibs_register_f(app_lua_sr_openlibs);
81
+	return 0;
82
+}
83
+
84
+static int app_lua_register_param(modparam_t type, void *val)
85
+{
86
+	if(val==NULL) {
87
+		return -1;
88
+	}
89
+
90
+	if(lua_sr_exp_register_mod((char*)val)==0)
91
+		return 0;
92
+	return -1;
93
+}
94
+
95
+static int app_lua_sr_openlibs(lua_State *L)
96
+{
97
+	lua_sr_core_openlibs(L);
98
+	lua_sr_exp_openlibs(L);
99
+	return 0;
100
+}
0 101
\ No newline at end of file