Browse code

app_python3: renamed main files to match module name

Daniel-Constantin Mierla authored on 10/03/2018 11:18:28
Showing 1 changed files
... ...
@@ -33,7 +33,7 @@
33 33
 
34 34
 // local includes
35 35
 #include "python_exec.h"
36
-#include "app_python_mod.h"
36
+#include "app_python3_mod.h"
37 37
 #include "python_iface.h"
38 38
 #include "python_msgobj.h"
39 39
 #include "python_support.h"
Browse code

app_python3: first release

- use same symbols names as app_python so these two modules cannot be used together
- use GIL for thread management

AnthonyA authored on 16/02/2018 13:37:33 • Daniel-Constantin Mierla committed on 20/02/2018 09:11:48
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,109 @@
1
+/**
2
+ * Copyright (C) 2012 Konstantin Mosesov
3
+ *
4
+ * This file is part of Kamailio, a free SIP server.
5
+ *
6
+ * This file 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
+ *
12
+ * This file is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
+ *
21
+ */
22
+
23
+// Python includes
24
+#include <Python.h>
25
+#include "structmember.h"
26
+
27
+// Other/system includes
28
+#include <libgen.h>
29
+
30
+// router includes
31
+#include "../../core/str.h"
32
+#include "../../core/sr_module.h"
33
+
34
+// local includes
35
+#include "python_exec.h"
36
+#include "app_python_mod.h"
37
+#include "python_iface.h"
38
+#include "python_msgobj.h"
39
+#include "python_support.h"
40
+
41
+#include "mod_Router.h"
42
+#include "mod_Ranks.h"
43
+
44
+PyObject *_sr_apy_ranks_module = NULL;
45
+
46
+PyMethodDef RanksMethods[] = {
47
+	{NULL, NULL, 0, NULL}
48
+};
49
+
50
+static struct PyModuleDef Router_Ranks_moduledef = {
51
+        PyModuleDef_HEAD_INIT,
52
+        "Router.Ranks",
53
+        NULL,
54
+        -1,
55
+        RanksMethods,
56
+        NULL,
57
+        NULL,
58
+        NULL,
59
+        NULL
60
+};
61
+
62
+PyObject* get_ranks_module(void)
63
+{
64
+	_sr_apy_ranks_module = PyModule_Create(&Router_Ranks_moduledef);
65
+
66
+	PyModule_AddObject(_sr_apy_ranks_module, "PROC_MAIN",
67
+			PyLong_FromLong((long)PROC_MAIN));
68
+	PyModule_AddObject(_sr_apy_ranks_module, "PROC_TIMER",
69
+			PyLong_FromLong((long)PROC_TIMER));
70
+	PyModule_AddObject(_sr_apy_ranks_module, "PROC_RPC",
71
+			PyLong_FromLong((long)PROC_RPC));
72
+	PyModule_AddObject(_sr_apy_ranks_module, "PROC_FIFO",
73
+			PyLong_FromLong((long)PROC_FIFO));
74
+	PyModule_AddObject(_sr_apy_ranks_module, "PROC_TCP_MAIN",
75
+			PyLong_FromLong((long)PROC_TCP_MAIN));
76
+	PyModule_AddObject(_sr_apy_ranks_module, "PROC_UNIXSOCK",
77
+			PyLong_FromLong((long)PROC_UNIXSOCK));
78
+	PyModule_AddObject(_sr_apy_ranks_module, "PROC_ATTENDANT",
79
+			PyLong_FromLong((long)PROC_ATTENDANT));
80
+	PyModule_AddObject(_sr_apy_ranks_module, "PROC_INIT",
81
+			PyLong_FromLong((long)PROC_INIT));
82
+	PyModule_AddObject(_sr_apy_ranks_module, "PROC_NOCHLDINIT",
83
+			PyLong_FromLong((long)PROC_NOCHLDINIT));
84
+	PyModule_AddObject(_sr_apy_ranks_module, "PROC_SIPINIT",
85
+			PyLong_FromLong((long)PROC_SIPINIT));
86
+	PyModule_AddObject(_sr_apy_ranks_module, "PROC_SIPRPC",
87
+			PyLong_FromLong((long)PROC_SIPRPC));
88
+	PyModule_AddObject(_sr_apy_ranks_module, "PROC_MIN",
89
+			PyLong_FromLong((long)PROC_MIN));
90
+
91
+	Py_INCREF(_sr_apy_ranks_module);
92
+
93
+#ifdef WITH_EXTRA_DEBUG
94
+	LM_ERR("Module 'Router.Ranks' has been initialized\n");
95
+#endif
96
+
97
+	return _sr_apy_ranks_module;
98
+}
99
+
100
+void destroy_mod_Ranks(void)
101
+{
102
+	Py_XDECREF(_sr_apy_ranks_module);
103
+
104
+#ifdef WITH_EXTRA_DEBUG
105
+	LM_ERR("Module 'Router.Ranks' has been destroyed\n");
106
+#endif
107
+
108
+}
109
+