Browse code

rtjson: add clang-format directives to skip format on kemi_exports

format is important for generating docs by our python tool

Victor Seva authored on 09/12/2019 17:38:32
Showing 1 changed files
... ...
@@ -228,6 +228,7 @@ static int ki_rtjson_update_branch(sip_msg_t *msg)
228 228
 /**
229 229
  *
230 230
  */
231
+/* clang-format off */
231 232
 static sr_kemi_t sr_kemi_rtjson_exports[] = {
232 233
 	{ str_init("rtjson"), str_init("init_routes"),
233 234
 		SR_KEMIP_INT, ki_rtjson_init_routes,
... ...
@@ -252,6 +253,7 @@ static sr_kemi_t sr_kemi_rtjson_exports[] = {
252 253
 
253 254
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
254 255
 };
256
+/* clang-format on */
255 257
 
256 258
 /**
257 259
  *
Browse code

rtjson: user wrapper functions for kemi exports

Daniel-Constantin Mierla authored on 04/03/2019 19:30:25
Showing 1 changed files
... ...
@@ -168,27 +168,84 @@ static int w_rtjson_update_branch(sip_msg_t *msg, char *p1, char *p2)
168 168
 	return 1;
169 169
 }
170 170
 
171
+/**
172
+ *
173
+ */
174
+static int ki_rtjson_init_routes(sip_msg_t *msg, str *srdoc)
175
+{
176
+	if(msg==NULL)
177
+		return -1;
178
+
179
+	if(rtjson_init_routes(msg, srdoc)<0)
180
+		return -1;
181
+
182
+	return 1;
183
+}
184
+
185
+/**
186
+ *
187
+ */
188
+static int ki_rtjson_push_routes(sip_msg_t *msg)
189
+{
190
+	if(msg==NULL)
191
+		return -1;
192
+
193
+	if(rtjson_push_routes(msg)<0)
194
+		return -1;
195
+
196
+	return 1;
197
+}
198
+
199
+/**
200
+ *
201
+ */
202
+static int ki_rtjson_next_route(sip_msg_t *msg)
203
+{
204
+	if(msg==NULL)
205
+		return -1;
206
+
207
+	if(rtjson_next_route(msg)<0)
208
+		return -1;
209
+
210
+	return 1;
211
+}
212
+
213
+/**
214
+ *
215
+ */
216
+static int ki_rtjson_update_branch(sip_msg_t *msg)
217
+{
218
+	if(msg==NULL)
219
+		return -1;
220
+
221
+	if(rtjson_update_branch(msg)<0)
222
+		return -1;
223
+
224
+	return 1;
225
+}
226
+
227
+
171 228
 /**
172 229
  *
173 230
  */
174 231
 static sr_kemi_t sr_kemi_rtjson_exports[] = {
175 232
 	{ str_init("rtjson"), str_init("init_routes"),
176
-		SR_KEMIP_INT, rtjson_init_routes,
233
+		SR_KEMIP_INT, ki_rtjson_init_routes,
177 234
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
178 235
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
179 236
 	},
180 237
 	{ str_init("rtjson"), str_init("push_routes"),
181
-		SR_KEMIP_INT, rtjson_push_routes,
238
+		SR_KEMIP_INT, ki_rtjson_push_routes,
182 239
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
183 240
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
184 241
 	},
185 242
 	{ str_init("rtjson"), str_init("next_route"),
186
-		SR_KEMIP_INT, rtjson_next_route,
243
+		SR_KEMIP_INT, ki_rtjson_next_route,
187 244
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
188 245
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
189 246
 	},
190 247
 	{ str_init("rtjson"), str_init("update_branch"),
191
-		SR_KEMIP_INT, rtjson_update_branch,
248
+		SR_KEMIP_INT, ki_rtjson_update_branch,
192 249
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
193 250
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
194 251
 	},
Browse code

rtjson: converted to the new module interface

Federico Cabiddu authored on 28/09/2018 08:55:36 • Victor Seva committed on 28/09/2018 11:03:26
Showing 1 changed files
... ...
@@ -68,14 +68,12 @@ struct module_exports exports = {
68 68
 	DEFAULT_DLFLAGS, /* dlopen flags */
69 69
 	cmds,
70 70
 	params,
71
-	0,
72
-	0,              /* exported MI functions */
71
+	0,              /* exported RPC methods */
73 72
 	0,              /* exported pseudo-variables */
74
-	0,              /* extra processes */
75
-	mod_init,       /* module initialization function */
76 73
 	0,              /* response function */
77
-	mod_destroy,    /* destroy function */
78
-	child_init      /* per child init function */
74
+	mod_init,       /* module initialization function */
75
+	child_init,     /* per child init function */
76
+	mod_destroy     /* destroy function */
79 77
 };
80 78
 
81 79
 /**
Browse code

core, lib, modules: updated include paths for header files

Daniel-Constantin Mierla authored on 07/12/2016 11:07:22
Showing 1 changed files
... ...
@@ -25,10 +25,10 @@
25 25
 #include <stdlib.h>
26 26
 #include <string.h>
27 27
 
28
-#include "../../sr_module.h"
29
-#include "../../dprint.h"
30
-#include "../../mod_fix.h"
31
-#include "../../kemi.h"
28
+#include "../../core/sr_module.h"
29
+#include "../../core/dprint.h"
30
+#include "../../core/mod_fix.h"
31
+#include "../../core/kemi.h"
32 32
 
33 33
 #include "rtjson_routing.h"
34 34
 
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,208 @@
1
+/**
2
+ * Copyright (C) 2015 Daniel-Constantin Mierla (asipto.com)
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
+#include <stdio.h>
24
+#include <unistd.h>
25
+#include <stdlib.h>
26
+#include <string.h>
27
+
28
+#include "../../sr_module.h"
29
+#include "../../dprint.h"
30
+#include "../../mod_fix.h"
31
+#include "../../kemi.h"
32
+
33
+#include "rtjson_routing.h"
34
+
35
+MODULE_VERSION
36
+
37
+
38
+str _rtjson_xavp_name = str_init("rtjson");
39
+
40
+static int  mod_init(void);
41
+static int  child_init(int);
42
+static void mod_destroy(void);
43
+
44
+static int w_rtjson_init_routes(sip_msg_t *msg, char *rdoc, char *rflags);
45
+static int w_rtjson_push_routes(sip_msg_t *msg, char *p1, char *p2);
46
+static int w_rtjson_next_route(sip_msg_t *msg, char *p1, char *p2);
47
+static int w_rtjson_update_branch(sip_msg_t *msg, char *p1, char *p2);
48
+
49
+static cmd_export_t cmds[]={
50
+	{"rtjson_init_routes", (cmd_function)w_rtjson_init_routes, 1, fixup_spve_null,
51
+		0, REQUEST_ROUTE},
52
+	{"rtjson_push_routes", (cmd_function)w_rtjson_push_routes,     0, 0,
53
+		0, REQUEST_ROUTE},
54
+	{"rtjson_next_route", (cmd_function)w_rtjson_next_route,       0, 0,
55
+		0, REQUEST_ROUTE|FAILURE_ROUTE},
56
+	{"rtjson_update_branch", (cmd_function)w_rtjson_update_branch, 0, 0,
57
+		0, BRANCH_ROUTE},
58
+	{0, 0, 0, 0, 0, 0}
59
+};
60
+
61
+static param_export_t params[]={
62
+	{"xavp_cfg", PARAM_STR, &_rtjson_xavp_name},
63
+	{0, 0, 0}
64
+};
65
+
66
+struct module_exports exports = {
67
+	"rtjson",
68
+	DEFAULT_DLFLAGS, /* dlopen flags */
69
+	cmds,
70
+	params,
71
+	0,
72
+	0,              /* exported MI functions */
73
+	0,              /* exported pseudo-variables */
74
+	0,              /* extra processes */
75
+	mod_init,       /* module initialization function */
76
+	0,              /* response function */
77
+	mod_destroy,    /* destroy function */
78
+	child_init      /* per child init function */
79
+};
80
+
81
+/**
82
+ * init module function
83
+ */
84
+static int mod_init(void)
85
+{
86
+	if(_rtjson_xavp_name.s==NULL || _rtjson_xavp_name.len<=0) {
87
+		LM_ERR("invalid xavp name\n");
88
+		return -1;
89
+	}
90
+	if(rtjson_init()<0) {
91
+		LM_ERR("failed to initialize\n");
92
+		return -1;
93
+	}
94
+	return 0;
95
+}
96
+
97
+/**
98
+ * @brief Initialize async module children
99
+ */
100
+static int child_init(int rank)
101
+{
102
+	return 0;
103
+}
104
+/**
105
+ * destroy module function
106
+ */
107
+static void mod_destroy(void)
108
+{
109
+}
110
+
111
+/**
112
+ *
113
+ */
114
+static int w_rtjson_init_routes(sip_msg_t *msg, char *rdoc, char *rflags)
115
+{
116
+	str srdoc = {0};
117
+
118
+	if(msg==NULL)
119
+		return -1;
120
+
121
+	if(fixup_get_svalue(msg, (gparam_t*)rdoc, &srdoc)!=0 || srdoc.len<=0) {
122
+		LM_ERR("no routing information\n");
123
+		return -1;
124
+	}
125
+	if(rtjson_init_routes(msg, &srdoc)<0)
126
+		return -1;
127
+
128
+	return 1;
129
+}
130
+
131
+/**
132
+ *
133
+ */
134
+static int w_rtjson_push_routes(sip_msg_t *msg, char *p1, char *p2)
135
+{
136
+	if(msg==NULL)
137
+		return -1;
138
+
139
+	if(rtjson_push_routes(msg)<0)
140
+		return -1;
141
+
142
+	return 1;
143
+}
144
+
145
+/**
146
+ *
147
+ */
148
+static int w_rtjson_next_route(sip_msg_t *msg, char *p1, char *p2)
149
+{
150
+	if(msg==NULL)
151
+		return -1;
152
+
153
+	if(rtjson_next_route(msg)<0)
154
+		return -1;
155
+
156
+	return 1;
157
+}
158
+
159
+/**
160
+ *
161
+ */
162
+static int w_rtjson_update_branch(sip_msg_t *msg, char *p1, char *p2)
163
+{
164
+	if(msg==NULL)
165
+		return -1;
166
+
167
+	if(rtjson_update_branch(msg)<0)
168
+		return -1;
169
+
170
+	return 1;
171
+}
172
+
173
+/**
174
+ *
175
+ */
176
+static sr_kemi_t sr_kemi_rtjson_exports[] = {
177
+	{ str_init("rtjson"), str_init("init_routes"),
178
+		SR_KEMIP_INT, rtjson_init_routes,
179
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
180
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
181
+	},
182
+	{ str_init("rtjson"), str_init("push_routes"),
183
+		SR_KEMIP_INT, rtjson_push_routes,
184
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
185
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
186
+	},
187
+	{ str_init("rtjson"), str_init("next_route"),
188
+		SR_KEMIP_INT, rtjson_next_route,
189
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
190
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
191
+	},
192
+	{ str_init("rtjson"), str_init("update_branch"),
193
+		SR_KEMIP_INT, rtjson_update_branch,
194
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
195
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
196
+	},
197
+
198
+	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
199
+};
200
+
201
+/**
202
+ *
203
+ */
204
+int mod_register(char *path, int *dlflags, void *p1, void *p2)
205
+{
206
+	sr_kemi_modules_add(sr_kemi_rtjson_exports);
207
+	return 0;
208
+}