Browse code

pua_json: exported KSR.pua_json.publish() to kemi

- corresponding to config pua_json_publish()
- use fixup_spve_null() and fixup_free_spve_null() for
pua_json_publish() config export

Daniel-Constantin Mierla authored on 16/06/2021 10:26:23
Showing 1 changed files
... ...
@@ -27,31 +27,41 @@
27 27
 
28 28
 #include "../json/api.h"
29 29
 #include "../presence/bind_presence.h"
30
+#include "../../core/mod_fix.h"
31
+#include "../../core/kemi.h"
32
+
30 33
 #include "pua_json_mod.h"
31 34
 
32 35
 MODULE_VERSION
33 36
 
37
+static int w_pua_json_publish(sip_msg_t *msg, char *p1pjson, char *p2);
38
+
39
+/* clang-format off */
34 40
 static param_export_t params[] = {
35
-		{"pua_include_entity", INT_PARAM, &pua_include_entity},
36
-		{0, 0, 0}};
41
+	{"pua_include_entity", PARAM_INT, &pua_include_entity},
42
+	{0, 0, 0}
43
+};
37 44
 
38 45
 static cmd_export_t cmds[] = {
39
-		{"pua_json_publish", (cmd_function)pua_json_publish, 1, 0, 0,
40
-				ANY_ROUTE},
41
-		{0, 0, 0, 0, 0, 0}};
46
+	{"pua_json_publish", (cmd_function)w_pua_json_publish, 1,
47
+		fixup_spve_null, fixup_free_spve_null, ANY_ROUTE},
48
+
49
+	{0, 0, 0, 0, 0, 0}
50
+};
42 51
 
43 52
 struct module_exports exports = {
44
-		"pua_json",			/* module name */
45
-		DEFAULT_DLFLAGS,	/* dlopen flags */
46
-		cmds,				/* exported functions */
47
-		params,				/* exported parameters */
48
-		0,					/* RPC method exports */
49
-		0,					/* exported pseudo-variables */
50
-		0,					/* response handling function */
51
-		mod_init,			/* module initialization function */
52
-		0,					/* per-child init function */
53
-		0					/* module destroy function */
53
+	"pua_json",			/* module name */
54
+	DEFAULT_DLFLAGS,	/* dlopen flags */
55
+	cmds,				/* exported functions */
56
+	params,				/* exported parameters */
57
+	0,					/* RPC method exports */
58
+	0,					/* exported pseudo-variables */
59
+	0,					/* response handling function */
60
+	mod_init,			/* module initialization function */
61
+	0,					/* per-child init function */
62
+	0					/* module destroy function */
54 63
 };
64
+/* clang-format on */
55 65
 
56 66
 static int mod_init(void)
57 67
 {
... ...
@@ -66,3 +76,50 @@ static int mod_init(void)
66 76
 
67 77
 	return 0;
68 78
 }
79
+
80
+/**
81
+ *
82
+ */
83
+static int ki_pua_json_publish(sip_msg_t* msg, str* pjson)
84
+{
85
+	return pua_json_publish(msg, pjson->s);
86
+}
87
+
88
+/**
89
+ *
90
+ */
91
+static int w_pua_json_publish(sip_msg_t *msg, char *p1pjson, char *p2)
92
+{
93
+	str pjson = STR_NULL;
94
+
95
+	if(fixup_get_svalue(msg, (gparam_t*)p1pjson, &pjson)<0) {
96
+		LM_ERR("failed to get p1 value\n");
97
+		return -1;
98
+	}
99
+
100
+	return pua_json_publish(msg, pjson.s);
101
+}
102
+
103
+/**
104
+ *
105
+ */
106
+/* clang-format off */
107
+static sr_kemi_t sr_kemi_pua_json_exports[] = {
108
+	{ str_init("pua_json"), str_init("publish"),
109
+		SR_KEMIP_INT, ki_pua_json_publish,
110
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
111
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
112
+	},
113
+
114
+	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
115
+};
116
+/* clang-format on */
117
+
118
+/**
119
+ *
120
+ */
121
+int mod_register(char *path, int *dlflags, void *p1, void *p2)
122
+{
123
+	sr_kemi_modules_add(sr_kemi_pua_json_exports);
124
+	return 0;
125
+}
Browse code

pua_json: updated to new module interface format

Charles Chance authored on 28/09/2018 08:38:02 • Victor Seva committed on 28/09/2018 11:03:26
Showing 1 changed files
... ...
@@ -41,16 +41,16 @@ static cmd_export_t cmds[] = {
41 41
 		{0, 0, 0, 0, 0, 0}};
42 42
 
43 43
 struct module_exports exports = {
44
-		"pua_json", DEFAULT_DLFLAGS, /* dlopen flags */
45
-		cmds,						 /* Exported functions */
46
-		params,						 /* Exported parameters */
47
-		0,							 /* exported statistics */
48
-		0,							 /* exported MI functions */
49
-		0, 0,						 /* extra processes */
50
-		mod_init,					 /* module initialization function */
51
-		0,							 /* response function*/
52
-		0,							 /* destroy function */
53
-		0							 /* per-child init function */
44
+		"pua_json",			/* module name */
45
+		DEFAULT_DLFLAGS,	/* dlopen flags */
46
+		cmds,				/* exported functions */
47
+		params,				/* exported parameters */
48
+		0,					/* RPC method exports */
49
+		0,					/* exported pseudo-variables */
50
+		0,					/* response handling function */
51
+		mod_init,			/* module initialization function */
52
+		0,					/* per-child init function */
53
+		0					/* module destroy function */
54 54
 };
55 55
 
56 56
 static int mod_init(void)
Browse code

pua_json: new module to update presence using JSON data objects

Emmanuel Schmidbauer authored on 01/02/2018 17:14:21
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,68 @@
1
+/*
2
+ * PUA_JSON module interface
3
+ *
4
+ * Copyright (C) 2018 VoIPxSWITCH
5
+ *
6
+ * This file is part of Kamailio, a free SIP server.
7
+ *
8
+ * Kamailio is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation; either version 2 of the License, or
11
+ * (at your option) any later version
12
+ *
13
+ * Kamailio is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
20
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
+ *
22
+ *
23
+ */
24
+
25
+#include <stdio.h>
26
+#include <string.h>
27
+
28
+#include "../json/api.h"
29
+#include "../presence/bind_presence.h"
30
+#include "pua_json_mod.h"
31
+
32
+MODULE_VERSION
33
+
34
+static param_export_t params[] = {
35
+		{"pua_include_entity", INT_PARAM, &pua_include_entity},
36
+		{0, 0, 0}};
37
+
38
+static cmd_export_t cmds[] = {
39
+		{"pua_json_publish", (cmd_function)pua_json_publish, 1, 0, 0,
40
+				ANY_ROUTE},
41
+		{0, 0, 0, 0, 0, 0}};
42
+
43
+struct module_exports exports = {
44
+		"pua_json", DEFAULT_DLFLAGS, /* dlopen flags */
45
+		cmds,						 /* Exported functions */
46
+		params,						 /* Exported parameters */
47
+		0,							 /* exported statistics */
48
+		0,							 /* exported MI functions */
49
+		0, 0,						 /* extra processes */
50
+		mod_init,					 /* module initialization function */
51
+		0,							 /* response function*/
52
+		0,							 /* destroy function */
53
+		0							 /* per-child init function */
54
+};
55
+
56
+static int mod_init(void)
57
+{
58
+	if(json_load_api(&json_api) < 0) {
59
+		LM_ERR("cannot bind to JSON API\n");
60
+		return -1;
61
+	}
62
+	if(presence_load_api(&presence_api) < 0) {
63
+		LM_ERR("cannot bind to PRESENCE API\n");
64
+		return -1;
65
+	}
66
+
67
+	return 0;
68
+}