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
+}