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
deleted file mode 100644
... ...
@@ -1,458 +0,0 @@
1
-/*
2
- * Copyright (C) 2005-2006 iptelorg GmbH
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
-/*!
23
- * \file
24
- * \brief Kamailio core :: The Select framework
25
- * \ingroup core
26
- * Module: \ref core
27
- */
28
-
29
-#include <stdio.h>
30
-#include <stdlib.h>
31
-#include <string.h>
32
-#include <unistd.h>
33
-#include <ctype.h>
34
-
35
-#include "select.h"
36
-#include "dprint.h"
37
-#include "select_core.h"
38
-#include "mem/mem.h"
39
-#include "mem/shm_mem.h"
40
-
41
-/**
42
- * The main parser table list placeholder
43
- * at startup use core table, modules can
44
- * add their own via register_select_table call
45
- */
46
-static select_table_t *select_list = &select_core_table;
47
-
48
-/** the level of the select call that is beeing evaluated
49
- * by the child process
50
- */
51
-int select_level = 0;
52
-
53
-/** pointer to the SIP uri beeing processed.
54
- * Nested function calls can pass information to each
55
- * other using this pointer. Only for performace reasons.
56
- * (Miklos)
57
- */
58
-struct sip_uri	*select_uri_p = NULL;
59
-
60
-/** parse a select identifier (internal version)
61
- * Parse select string into select structure s
62
- * moves pointer p to the first unused char.
63
- *
64
- * The select identifier must be of the form:
65
-\verbatim
66
- *   [@] <sel_id> [ '.' <sel_id> ...]
67
- *   
68
- * Where 
69
- *       <sel_id> = <id> |
70
- *                  <id> '[' <idx> ']'
71
- *       <id> = [a-zA-Z0-9_]+
72
- *       <idx> = <number> | <string>
73
- *       <string> = '"' <ascii> '"' | 
74
- *                  '\"' <ascii> '\"'
75
- *
76
- * Examples:
77
- *     @to.tag
78
- *     @hf_value["contact"]
79
- *     @msg.header["SER-Server-ID"]
80
- *     @eval.pop[-1]
81
- *     contact.uri.params.maddr
82
- *     cfg_get.rtp_proxy.enabled 
83
-\endverbatim
84
- *
85
- * @return -1 error
86
- *			  p points to the first unconsumed char
87
- *          0 success
88
- *			  p points to the first unconsumed char
89
- *			  s points to the select structure
90
- */
91
-
92
-int w_parse_select(char**p, select_t* sel)
93
-{
94
-	str name;
95
-	char* select_name;
96
-	
97
-	if (**p=='@') (*p)++;
98
-	select_name=*p;
99
-	sel->n=0;
100
-	while (isalpha((unsigned char)*(*p))) {
101
-		if (sel->n > MAX_SELECT_PARAMS -2) {
102
-			LM_ERR("select depth exceeds max\n");
103
-			goto error;
104
-		}
105
-		name.s=(*p);
106
-		while (isalpha((unsigned char)*(*p)) || 
107
-				isdigit((unsigned char)*(*p)) || (*(*p)=='_')) (*p)++;
108
-		name.len=(*p)-name.s;
109
-		sel->params[sel->n].type=SEL_PARAM_STR;
110
-		sel->params[sel->n].v.s=name;
111
-		LM_DBG("part %d: %.*s\n", sel->n, sel->params[sel->n].v.s.len, sel->params[sel->n].v.s.s);
112
-		sel->n++;
113
-		if (*(*p)=='[') {
114
-			(*p)++; 
115
-			if (*(*p)=='\\') (*p)++;
116
-			if (*(*p)=='"') {
117
-				(*p)++;	
118
-				name.s=(*p);
119
-				while ((*(*p)!='\0') && (*(*p)!='"')) (*p)++;
120
-				if (*(*p)!='"') {
121
-					LM_ERR("end of string is missing\n");
122
-					goto error;
123
-				}
124
-				name.len=(*p)-name.s;
125
-				if (*((*p)-1)=='\\') name.len--;
126
-				(*p)++;
127
-				if (*(*p)!=']') {
128
-					LM_ERR("invalid string index, no closing ]\n");
129
-					goto error;
130
-				};
131
-				(*p)++;
132
-				sel->params[sel->n].type=SEL_PARAM_STR;
133
-				sel->params[sel->n].v.s=name;
134
-				LM_DBG("part %d: [\"%.*s\"]\n", sel->n, sel->params[sel->n].v.s.len, sel->params[sel->n].v.s.s);
135
-			} else {
136
-				name.s=(*p);
137
-				if (*(*p)=='-') (*p)++;
138
-				while (isdigit((unsigned char)*(*p))) (*p)++;
139
-				name.len=(*p)-name.s;
140
-				if (*(*p)!=']') {
141
-					LM_ERR("invalid index, no closing ]\n");
142
-					goto error;
143
-				};
144
-				(*p)++;
145
-				sel->params[sel->n].type=SEL_PARAM_INT;
146
-				sel->params[sel->n].v.i=atoi(name.s);
147
-				LM_DBG("part %d: [%d]\n", sel->n, sel->params[sel->n].v.i);
148
-			}
149
-			sel->n++;
150
-		}
151
-		if (*(*p)!='.') break;
152
-		(*p)++;
153
-	};
154
-	if (sel->n==0) {
155
-		LM_ERR("invalid select '%.*s'\n", (int)(*p - select_name), select_name);
156
-		goto error;
157
-	};
158
-	LM_DBG("end, total elements: %d, calling resolve_select\n", sel->n);
159
-	if (resolve_select(sel)<0) {
160
-		LM_ERR("error while resolve_select '%.*s'\n", (int)(*p - select_name), select_name);
161
-		goto error;
162
-	}
163
-	return 0;
164
-	
165
-error:
166
-	return -1;
167
-}
168
-
169
-
170
-/** parse a select identifier.
171
- * Parse select string into select structure s and
172
- * moves pointer p to the first unused char.
173
- * 
174
-\verbatim
175
- * The select identifier must be of the form:
176
- *   [@] <sel_id> [ '.' <sel_id> ...]
177
- *   
178
- * Where 
179
- *       <sel_id> = <id> |
180
- *                  <id> '[' <idx> ']'
181
- *       <id> = [a-zA-Z0-9_]+
182
- *       <idx> = <number>  | '-' <number> | <string>
183
- *       <string> = '"' <ascii> '"' | 
184
- *                  '\"' <ascii> '\"'
185
- *
186
- * Examples:
187
- *     @to.tag
188
- *     @hf_value["contact"]
189
- *     @msg.header["SER-Server-ID"]
190
- *     @eval.pop[-1]
191
- *     contact.uri.params.maddr
192
- *     cfg_get.rtp_proxy.enabled 
193
-\endverbatim
194
-  *
195
-  * @param p - double string (asciiz) pointer, *p is moved to the first char
196
-  *            after the select identifier
197
-  * @param s - the result will be stored here
198
-  * @return  < 0 on error, 0 on success
199
-  */
200
-int parse_select (char** p, select_t** s)
201
-{
202
-	select_t* sel;
203
-	
204
-	sel=(select_t*)pkg_malloc(sizeof(select_t));
205
-	if (!sel) {
206
-		LM_ERR("no free memory\n");
207
-		return -1;
208
-	}
209
-	memset(sel, 0, sizeof(select_t));
210
-	if (w_parse_select(p, sel)<0) {
211
-		pkg_free(sel);
212
-		return -2;
213
-	}
214
-	*s=sel;
215
-	return 0;
216
-}
217
-
218
-void free_select(select_t *s)
219
-{
220
-	if (s)
221
-		pkg_free(s);
222
-}
223
-
224
-void shm_free_select(select_t *s)
225
-{
226
-	if (s)
227
-		shm_free(s);
228
-}
229
-
230
-int shm_parse_select (char** p, select_t** s)
231
-{
232
-	select_t* sel;
233
-	
234
-	sel=(select_t*)shm_malloc(sizeof(select_t));
235
-	if (!sel) {
236
-		LM_ERR("no free shared memory\n");
237
-		return -1;
238
-	}
239
-	if (w_parse_select(p, sel)<0) {
240
-		shm_free(sel);
241
-		return -2;
242
-	}
243
-	*s=sel;
244
-	return 0;
245
-}
246
-
247
-int resolve_select(select_t* s)
248
-{
249
-	select_f f;
250
-	int nested;
251
-	int param_idx = 0;
252
-	int table_idx = 0;
253
-	select_table_t* t = NULL;
254
-	int accept = 0;
255
-
256
-	f = NULL;
257
-	nested = 0;
258
-	memset (s->f, 0, sizeof(s->f));
259
-	while (param_idx<s->n) {
260
-		accept = 0;
261
-		switch (s->params[param_idx].type) {
262
-		case SEL_PARAM_STR:
263
-			LM_DBG("'%.*s'\n", s->params[param_idx].v.s.len, s->params[param_idx].v.s.s);
264
-			break;
265
-		case SEL_PARAM_INT:
266
-			LM_DBG("[%d]\n", s->params[param_idx].v.i);
267
-			break;
268
-		default:
269
-			/* just to avoid the warning */
270
-			break;
271
-		}
272
-		for (t=select_list; t; t=t->next) {
273
-			table_idx = 0;
274
-			if (!t->table) continue;
275
-			while (t->table[table_idx].curr_f || t->table[table_idx].new_f) {
276
-				if (t->table[table_idx].curr_f == f) {
277
-					if ((t->table[table_idx].flags & (NESTED | CONSUME_NEXT_INT | CONSUME_NEXT_STR)) == NESTED) {
278
-						accept = 1;
279
-					} else if (t->table[table_idx].type == s->params[param_idx].type) {
280
-						switch (t->table[table_idx].type) {
281
-						case SEL_PARAM_INT:
282
-							accept = 1;
283
-							break;
284
-						case SEL_PARAM_STR:
285
-							accept = (((t->table[table_idx].name.len == s->params[param_idx].v.s.len) || !t->table[table_idx].name.len)
286
-								   && (!t->table[table_idx].name.s || !strncasecmp(t->table[table_idx].name.s, s->params[param_idx].v.s.s, s->params[param_idx].v.s.len)));
287
-							break;
288
-						default:
289
-							break;
290
-						}
291
-					};
292
-				}
293
-				if (accept) goto accepted;
294
-				table_idx++;
295
-			}
296
-		}
297
-		switch (s->params[param_idx].type) {
298
-			case SEL_PARAM_STR:
299
-				LM_ERR("Unable to resolve select '%.*s' at level %d\n", s->params[param_idx].v.s.len, s->params[param_idx].v.s.s, param_idx);
300
-				break;
301
-			case SEL_PARAM_INT:
302
-				LM_ERR("Unable to resolve select [%d] at level %d\n", s->params[param_idx].v.i, param_idx);
303
-				break;
304
-			default:
305
-				BUG ("Unable to resolve select at level %d\n", param_idx);
306
-				break;
307
-			break;
308
-		}
309
-		goto not_found;
310
-
311
-		accepted:
312
-		if (t->table[table_idx].flags & DIVERSION) {
313
-			/* if (s->params[param_idx].type == SEL_PARAM_STR) pkg_free(s->params[param_idx].v.s.s); */
314
-			/* don't free it (the mem can leak only once at startup)
315
-			 * the parsed string can live inside larger string block
316
-			 * e.g. when xlog's select is parsed
317
-			 */
318
-			s->params[param_idx].type = SEL_PARAM_DIV;
319
-			s->params[param_idx].v.i = t->table[table_idx].flags & DIVERSION_MASK;
320
-
321
-		}
322
-		if (t->table[table_idx].flags & CONSUME_NEXT_STR) {
323
-			if ((param_idx<s->n-1) && (s->params[param_idx+1].type == SEL_PARAM_STR)) {
324
-				param_idx++;
325
-			} else if (!(t->table[table_idx].flags & OPTIONAL)) {
326
-				BUG ("Mandatory STR parameter not found\n");
327
-				goto not_found;
328
-			}
329
-		}
330
-		if (t->table[table_idx].flags & CONSUME_NEXT_INT) {
331
-			if ((param_idx<s->n-1) && (s->params[param_idx+1].type == SEL_PARAM_INT)) {
332
-				param_idx++;
333
-			} else if (!(t->table[table_idx].flags & OPTIONAL)) {
334
-				BUG ("Mandatory INT parameter not found\n");
335
-				goto not_found;
336
-			}
337
-		}
338
-
339
-		if (t->table[table_idx].flags & NESTED) {
340
-			if (nested < MAX_NESTED_CALLS-1) { /* need space for final function */
341
-				s->f[nested++] = f;
342
-				s->param_offset[nested] = param_idx;
343
-			} else {
344
-				BUG("MAX_NESTED_CALLS too small to resolve select\n");
345
-				goto not_found;
346
-			}
347
-		} else {
348
-			param_idx++;
349
-		}
350
-
351
-		if (t->table[table_idx].flags & FIXUP_CALL) {
352
-			select_level = nested;
353
-			s->param_offset[nested+1] = param_idx;
354
-			if (t->table[table_idx].new_f(NULL, s, NULL)<0) goto not_found;
355
-		}
356
-
357
-		f = t->table[table_idx].new_f;
358
-
359
-		if (t->table[table_idx].flags & CONSUME_ALL) {
360
-			/* sanity checks */
361
-			if (t->table[table_idx].flags & NESTED)
362
-				WARN("resolve_select: CONSUME_ALL should not be set "
363
-					"together with NESTED flag!\n");
364
-			if ((t->table[table_idx].flags & FIXUP_CALL) == 0)
365
-				WARN("resolve_select: FIXUP_CALL should be defined "
366
-					"if CONSUME_ALL flag is set!\n");
367
-			break;
368
-		}
369
-	}
370
-
371
-	if (t==NULL) {
372
-		BUG ("final node not found\n");
373
-		goto not_found;
374
-	}
375
-	if (t->table[table_idx].flags & SEL_PARAM_EXPECTED) {
376
-		BUG ("final node has SEL_PARAM_EXPECTED set (no more parameters available)\n");
377
-		goto not_found;
378
-	}
379
-	if (nested >= MAX_NESTED_CALLS) {
380
-		BUG("MAX_NESTED_CALLS too small, no space for finally resolved function\n");
381
-		goto not_found;
382
-	}
383
-	if ((nested>0) && (s->f[nested-1] == f)) {
384
-		BUG("Topmost nested function equals to final function, won't call it twice\n");
385
-	} else {
386
-		s->f[nested++] = f;
387
-	}
388
-	s->param_offset[nested] = s->n;
389
-
390
-	return 0;
391
-
392
-not_found:
393
-	return -1;
394
-}
395
-
396
-int run_select(str* res, select_t* s, struct sip_msg* msg)
397
-{
398
-	int ret, orig_level;
399
-
400
-	if (res == NULL) {
401
-		BUG("Select unprepared result space\n");
402
-		return -1;
403
-	}
404
-	if (s == 0) {
405
-		BUG("Select structure is NULL\n");
406
-		return -1;
407
-	}
408
-	if (s->f[0] == 0) {
409
-		BUG("Select structure has not been resolved\n");
410
-		return -1;
411
-	}
412
-	LM_DBG("Calling SELECT %p\n", s->f);
413
-
414
-	/* reset the uri pointer */
415
-	select_uri_p = NULL;
416
-
417
-	/* save and restore the original select_level
418
-	 * because of the nested selects */
419
-	orig_level = select_level;
420
-	ret = 0;
421
-	for (	select_level=0;
422
-		(ret == 0) && (select_level<MAX_NESTED_CALLS) && (s->f[select_level] !=0 );
423
-		select_level++
424
-	) {
425
-		ret = s->f[select_level](res, s, msg);
426
-	}
427
-	select_level = orig_level;
428
-	return ret;
429
-}
430
-
431
-void print_select(select_t* s)
432
-{
433
-	int i;
434
-	DBG("select(");
435
-	for(i = 0; i < s->n; i++) {
436
-		if (s->params[i].type == SEL_PARAM_INT) {
437
-			DBG("%d,", s->params[i].v.i);
438
-		} else {
439
-			DBG("%.*s,", s->params[i].v.s.len, s->params[i].v.s.s);
440
-		}
441
-	}
442
-	DBG(")\n");
443
-}
444
-
445
-int register_select_table(select_row_t* mod_tab)
446
-{
447
-	select_table_t* t;
448
-	t=(select_table_t*)pkg_malloc(sizeof(select_table_t));
449
-	if (!t) {
450
-		LM_ERR("No memory for new select_table structure\n");
451
-		return -1;
452
-	}
453
-
454
-	t->table=mod_tab;
455
-	t->next=select_list;
456
-	select_list=t;
457
-	return 0;
458
-}
Browse code

select.c: logging: DBG->LM_DBG, ERR -> LM_ERR

Ovidiu Sas authored on 13/01/2015 15:26:55
Showing 1 changed files
... ...
@@ -99,7 +99,7 @@ int w_parse_select(char**p, select_t* sel)
99 99
 	sel->n=0;
100 100
 	while (isalpha((unsigned char)*(*p))) {
101 101
 		if (sel->n > MAX_SELECT_PARAMS -2) {
102
-			ERR("parse_select: select depth exceeds max\n");
102
+			LM_ERR("select depth exceeds max\n");
103 103
 			goto error;
104 104
 		}
105 105
 		name.s=(*p);
... ...
@@ -108,7 +108,7 @@ int w_parse_select(char**p, select_t* sel)
108 108
 		name.len=(*p)-name.s;
109 109
 		sel->params[sel->n].type=SEL_PARAM_STR;
110 110
 		sel->params[sel->n].v.s=name;
111
-		DBG("parse_select: part %d: %.*s\n", sel->n, sel->params[sel->n].v.s.len, sel->params[sel->n].v.s.s);
111
+		LM_DBG("part %d: %.*s\n", sel->n, sel->params[sel->n].v.s.len, sel->params[sel->n].v.s.s);
112 112
 		sel->n++;
113 113
 		if (*(*p)=='[') {
114 114
 			(*p)++; 
... ...
@@ -118,33 +118,33 @@ int w_parse_select(char**p, select_t* sel)
118 118
 				name.s=(*p);
119 119
 				while ((*(*p)!='\0') && (*(*p)!='"')) (*p)++;
120 120
 				if (*(*p)!='"') {
121
-					ERR("parse_select: end of string is missing\n");
121
+					LM_ERR("end of string is missing\n");
122 122
 					goto error;
123 123
 				}
124 124
 				name.len=(*p)-name.s;
125 125
 				if (*((*p)-1)=='\\') name.len--;
126 126
 				(*p)++;
127 127
 				if (*(*p)!=']') {
128
-					ERR("parse_select: invalid string index, no closing ]\n");
128
+					LM_ERR("invalid string index, no closing ]\n");
129 129
 					goto error;
130 130
 				};
131 131
 				(*p)++;
132 132
 				sel->params[sel->n].type=SEL_PARAM_STR;
133 133
 				sel->params[sel->n].v.s=name;
134
-				DBG("parse_select: part %d: [\"%.*s\"]\n", sel->n, sel->params[sel->n].v.s.len, sel->params[sel->n].v.s.s);
134
+				LM_DBG("part %d: [\"%.*s\"]\n", sel->n, sel->params[sel->n].v.s.len, sel->params[sel->n].v.s.s);
135 135
 			} else {
136 136
 				name.s=(*p);
137 137
 				if (*(*p)=='-') (*p)++;
138 138
 				while (isdigit((unsigned char)*(*p))) (*p)++;
139 139
 				name.len=(*p)-name.s;
140 140
 				if (*(*p)!=']') {
141
-					ERR("parse_select: invalid index, no closing ]\n");
141
+					LM_ERR("invalid index, no closing ]\n");
142 142
 					goto error;
143 143
 				};
144 144
 				(*p)++;
145 145
 				sel->params[sel->n].type=SEL_PARAM_INT;
146 146
 				sel->params[sel->n].v.i=atoi(name.s);
147
-				DBG("parse_select: part %d: [%d]\n", sel->n, sel->params[sel->n].v.i);
147
+				LM_DBG("part %d: [%d]\n", sel->n, sel->params[sel->n].v.i);
148 148
 			}
149 149
 			sel->n++;
150 150
 		}
... ...
@@ -152,12 +152,12 @@ int w_parse_select(char**p, select_t* sel)
152 152
 		(*p)++;
153 153
 	};
154 154
 	if (sel->n==0) {
155
-		ERR("parse_select: invalid select '%.*s'\n", (int)(*p - select_name), select_name);
155
+		LM_ERR("invalid select '%.*s'\n", (int)(*p - select_name), select_name);
156 156
 		goto error;
157 157
 	};
158
-	DBG("parse_select: end, total elements: %d, calling resolve_select\n", sel->n);
158
+	LM_DBG("end, total elements: %d, calling resolve_select\n", sel->n);
159 159
 	if (resolve_select(sel)<0) {
160
-		ERR("parse_select: error while resolve_select '%.*s'\n", (int)(*p - select_name), select_name);
160
+		LM_ERR("error while resolve_select '%.*s'\n", (int)(*p - select_name), select_name);
161 161
 		goto error;
162 162
 	}
163 163
 	return 0;
... ...
@@ -203,7 +203,7 @@ int parse_select (char** p, select_t** s)
203 203
 	
204 204
 	sel=(select_t*)pkg_malloc(sizeof(select_t));
205 205
 	if (!sel) {
206
-		ERR("parse_select: no free memory\n");
206
+		LM_ERR("no free memory\n");
207 207
 		return -1;
208 208
 	}
209 209
 	memset(sel, 0, sizeof(select_t));
... ...
@@ -233,7 +233,7 @@ int shm_parse_select (char** p, select_t** s)
233 233
 	
234 234
 	sel=(select_t*)shm_malloc(sizeof(select_t));
235 235
 	if (!sel) {
236
-		ERR("parse_select: no free shared memory\n");
236
+		LM_ERR("no free shared memory\n");
237 237
 		return -1;
238 238
 	}
239 239
 	if (w_parse_select(p, sel)<0) {
... ...
@@ -260,10 +260,10 @@ int resolve_select(select_t* s)
260 260
 		accept = 0;
261 261
 		switch (s->params[param_idx].type) {
262 262
 		case SEL_PARAM_STR:
263
-			DBG("resolve_select: '%.*s'\n", s->params[param_idx].v.s.len, s->params[param_idx].v.s.s);
263
+			LM_DBG("'%.*s'\n", s->params[param_idx].v.s.len, s->params[param_idx].v.s.s);
264 264
 			break;
265 265
 		case SEL_PARAM_INT:
266
-			DBG("resolve_select: [%d]\n", s->params[param_idx].v.i);
266
+			LM_DBG("[%d]\n", s->params[param_idx].v.i);
267 267
 			break;
268 268
 		default:
269 269
 			/* just to avoid the warning */
... ...
@@ -409,7 +409,7 @@ int run_select(str* res, select_t* s, struct sip_msg* msg)
409 409
 		BUG("Select structure has not been resolved\n");
410 410
 		return -1;
411 411
 	}
412
-	DBG("Calling SELECT %p \n", s->f);
412
+	LM_DBG("Calling SELECT %p\n", s->f);
413 413
 
414 414
 	/* reset the uri pointer */
415 415
 	select_uri_p = NULL;
... ...
@@ -447,7 +447,7 @@ int register_select_table(select_row_t* mod_tab)
447 447
 	select_table_t* t;
448 448
 	t=(select_table_t*)pkg_malloc(sizeof(select_table_t));
449 449
 	if (!t) {
450
-		ERR("No memory for new select_table structure\n");
450
+		LM_ERR("No memory for new select_table structure\n");
451 451
 		return -1;
452 452
 	}
453 453
 
Browse code

core Update headers, change "SIP-router" to "Kamailio", update doxygen file headers

Olle E. Johansson authored on 03/01/2015 14:15:58
Showing 1 changed files
... ...
@@ -8,11 +8,6 @@
8 8
  * the Free Software Foundation; either version 2 of the License, or
9 9
  * (at your option) any later version
10 10
  *
11
- * For a license to use the ser software under conditions
12
- * other than those described here, or to purchase support for this
13
- * software, please contact iptel.org by e-mail at the following addresses:
14
- *    info@iptel.org
15
- *
16 11
  * Kamailio is distributed in the hope that it will be useful,
17 12
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Browse code

Core Removed history, svn $id$ and doxygen udpates on the .c files

Olle E. Johansson authored on 03/01/2015 09:53:17
Showing 1 changed files
... ...
@@ -1,11 +1,9 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * Copyright (C) 2005-2006 iptelorg GmbH
5 3
  *
6
- * This file is part of ser, a free SIP server.
4
+ * This file is part of Kamailio, a free SIP server.
7 5
  *
8
- * ser is free software; you can redistribute it and/or modify
6
+ * Kamailio is free software; you can redistribute it and/or modify
9 7
  * it under the terms of the GNU General Public License as published by
10 8
  * the Free Software Foundation; either version 2 of the License, or
11 9
  * (at your option) any later version
... ...
@@ -15,7 +13,7 @@
15 13
  * software, please contact iptel.org by e-mail at the following addresses:
16 14
  *    info@iptel.org
17 15
  *
18
- * ser is distributed in the hope that it will be useful,
16
+ * Kamailio is distributed in the hope that it will be useful,
19 17
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 18
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 19
  * GNU General Public License for more details.
... ...
@@ -24,21 +22,11 @@
24 22
  * along with this program; if not, write to the Free Software
25 23
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
26 24
  *
27
- * History:
28
- * --------
29
- *  2005-12-19  select framework (mma)
30
- *  2006-01-19  multiple nested calls, IS_ALIAS -> NESTED flag renamed (mma)
31
- *              DIVERSION flag checked
32
- *  2006-02-26  don't free str when changing type STR -> DIVERSION (mma)
33
- *				it can't be freeable sometimes (e.g. xlog's select)
34
- *	2006-05-30  parse_select (mma)
35
- *	2006-06-02  shm_parse_select (mma)
36
- *
37 25
  */
38 26
 
39 27
 /*!
40 28
  * \file
41
- * \brief SIP-router core :: 
29
+ * \brief Kamailio core :: The Select framework
42 30
  * \ingroup core
43 31
  * Module: \ref core
44 32
  */
... ...
@@ -55,19 +43,19 @@
55 43
 #include "mem/mem.h"
56 44
 #include "mem/shm_mem.h"
57 45
 
58
-/*
46
+/**
59 47
  * The main parser table list placeholder
60 48
  * at startup use core table, modules can
61 49
  * add their own via register_select_table call
62 50
  */
63 51
 static select_table_t *select_list = &select_core_table;
64 52
 
65
-/* the level of the select call that is beeing evaluated
53
+/** the level of the select call that is beeing evaluated
66 54
  * by the child process
67 55
  */
68 56
 int select_level = 0;
69 57
 
70
-/* pointer to the SIP uri beeing processed.
58
+/** pointer to the SIP uri beeing processed.
71 59
  * Nested function calls can pass information to each
72 60
  * other using this pointer. Only for performace reasons.
73 61
  * (Miklos)
Browse code

select.c: logging: convert LOG to LM_*

Ovidiu Sas authored on 04/10/2014 01:25:37
Showing 1 changed files
... ...
@@ -313,10 +313,10 @@ int resolve_select(select_t* s)
313 313
 		}
314 314
 		switch (s->params[param_idx].type) {
315 315
 			case SEL_PARAM_STR:
316
-				LOG(L_ERR, "Unable to resolve select '%.*s' at level %d\n", s->params[param_idx].v.s.len, s->params[param_idx].v.s.s, param_idx);
316
+				LM_ERR("Unable to resolve select '%.*s' at level %d\n", s->params[param_idx].v.s.len, s->params[param_idx].v.s.s, param_idx);
317 317
 				break;
318 318
 			case SEL_PARAM_INT:
319
-				LOG(L_ERR, "Unable to resolve select [%d] at level %d\n", s->params[param_idx].v.i, param_idx);
319
+				LM_ERR("Unable to resolve select [%d] at level %d\n", s->params[param_idx].v.i, param_idx);
320 320
 				break;
321 321
 			default:
322 322
 				BUG ("Unable to resolve select at level %d\n", param_idx);
Browse code

all: updated FSF address in GPL text

Anthony Messina authored on 04/07/2014 09:36:37 • Daniel-Constantin Mierla committed on 04/07/2014 09:37:36
Showing 1 changed files
... ...
@@ -22,7 +22,7 @@
22 22
  *
23 23
  * You should have received a copy of the GNU General Public License
24 24
  * along with this program; if not, write to the Free Software
25
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
26 26
  *
27 27
  * History:
28 28
  * --------
Browse code

core: safety check for finding select final node

Daniel-Constantin Mierla authored on 18/04/2014 22:21:09
Showing 1 changed files
... ...
@@ -385,6 +385,10 @@ int resolve_select(select_t* s)
385 385
 		}
386 386
 	}
387 387
 
388
+	if (t==NULL) {
389
+		BUG ("final node not found\n");
390
+		goto not_found;
391
+	}
388 392
 	if (t->table[table_idx].flags & SEL_PARAM_EXPECTED) {
389 393
 		BUG ("final node has SEL_PARAM_EXPECTED set (no more parameters available)\n");
390 394
 		goto not_found;
Browse code

core: test the limits of nested select level before accessing array value

Daniel-Constantin Mierla authored on 30/01/2014 11:14:48
Showing 1 changed files
... ...
@@ -432,7 +432,7 @@ int run_select(str* res, select_t* s, struct sip_msg* msg)
432 432
 	orig_level = select_level;
433 433
 	ret = 0;
434 434
 	for (	select_level=0;
435
-		(ret == 0) && (s->f[select_level] !=0 ) && (select_level<MAX_NESTED_CALLS);
435
+		(ret == 0) && (select_level<MAX_NESTED_CALLS) && (s->f[select_level] !=0 );
436 436
 		select_level++
437 437
 	) {
438 438
 		ret = s->f[select_level](res, s, msg);
Browse code

core/select: fixed @via... without header index

- reported by IƱaki Baz Castillo, fixes FS#138

Daniel-Constantin Mierla authored on 31/05/2012 12:44:19
Showing 1 changed files
... ...
@@ -223,6 +223,7 @@ int parse_select (char** p, select_t** s)
223 223
 		ERR("parse_select: no free memory\n");
224 224
 		return -1;
225 225
 	}
226
+	memset(sel, 0, sizeof(select_t));
226 227
 	if (w_parse_select(p, sel)<0) {
227 228
 		pkg_free(sel);
228 229
 		return -2;
Browse code

selects: shm_free_select wrapper added

shm_free_select() function is added that frees the select
parsed by shm_parse_select().

Miklos Tirpak authored on 09/11/2009 16:08:08
Showing 1 changed files
... ...
@@ -237,6 +237,12 @@ void free_select(select_t *s)
237 237
 		pkg_free(s);
238 238
 }
239 239
 
240
+void shm_free_select(select_t *s)
241
+{
242
+	if (s)
243
+		shm_free(s);
244
+}
245
+
240 246
 int shm_parse_select (char** p, select_t** s)
241 247
 {
242 248
 	select_t* sel;
Browse code

Doxygen updates

oej authored on 25/10/2009 19:11:28
Showing 1 changed files
... ...
@@ -79,6 +79,7 @@ struct sip_uri	*select_uri_p = NULL;
79 79
  * moves pointer p to the first unused char.
80 80
  *
81 81
  * The select identifier must be of the form:
82
+\verbatim
82 83
  *   [@] <sel_id> [ '.' <sel_id> ...]
83 84
  *   
84 85
  * Where 
... ...
@@ -96,6 +97,7 @@ struct sip_uri	*select_uri_p = NULL;
96 97
  *     @eval.pop[-1]
97 98
  *     contact.uri.params.maddr
98 99
  *     cfg_get.rtp_proxy.enabled 
100
+\endverbatim
99 101
  *
100 102
  * @return -1 error
101 103
  *			  p points to the first unconsumed char
... ...
@@ -186,6 +188,7 @@ error:
186 188
  * Parse select string into select structure s and
187 189
  * moves pointer p to the first unused char.
188 190
  * 
191
+\verbatim
189 192
  * The select identifier must be of the form:
190 193
  *   [@] <sel_id> [ '.' <sel_id> ...]
191 194
  *   
... ...
@@ -204,6 +207,7 @@ error:
204 207
  *     @eval.pop[-1]
205 208
  *     contact.uri.params.maddr
206 209
  *     cfg_get.rtp_proxy.enabled 
210
+\endverbatim
207 211
   *
208 212
   * @param p - double string (asciiz) pointer, *p is moved to the first char
209 213
   *            after the select identifier
Browse code

Adding doxygen template to all core .c files

Please fill in after the :: to explain the function of this file.

oej authored on 10/10/2009 13:54:13
Showing 1 changed files
... ...
@@ -36,6 +36,13 @@
36 36
  *
37 37
  */
38 38
 
39
+/*!
40
+ * \file
41
+ * \brief SIP-router core :: 
42
+ * \ingroup core
43
+ * Module: \ref core
44
+ */
45
+
39 46
 #include <stdio.h>
40 47
 #include <stdlib.h>
41 48
 #include <string.h>
Browse code

Avoid parsing the Request URI when it is not necessary.

When @ruri.user was executed, the first select call set
the value of the URI in str format regardless of whether
or not it had already been parsed. The second function call
took the str value, and parsed the URI to get its user part.

This patch introduces a global pointer variable that can be set
to the already parsed URI being processed. Any nested select
function can check this pointer and access the parsed URI if
possible.

Miklos Tirpak authored on 15/05/2009 07:42:29
Showing 1 changed files
... ...
@@ -60,6 +60,13 @@ static select_table_t *select_list = &select_core_table;
60 60
  */
61 61
 int select_level = 0;
62 62
 
63
+/* pointer to the SIP uri beeing processed.
64
+ * Nested function calls can pass information to each
65
+ * other using this pointer. Only for performace reasons.
66
+ * (Miklos)
67
+ */
68
+struct sip_uri	*select_uri_p = NULL;
69
+
63 70
 /** parse a select identifier (internal version)
64 71
  * Parse select string into select structure s
65 72
  * moves pointer p to the first unused char.
... ...
@@ -399,6 +406,9 @@ int run_select(str* res, select_t* s, struct sip_msg* msg)
399 406
 	}
400 407
 	DBG("Calling SELECT %p \n", s->f);
401 408
 
409
+	/* reset the uri pointer */
410
+	select_uri_p = NULL;
411
+
402 412
 	/* save and restore the original select_level
403 413
 	 * because of the nested selects */
404 414
 	orig_level = select_level;
Browse code

select: comments for parse_select()

Andrei Pelinescu-Onciul authored on 27/11/2008 00:25:42
Showing 1 changed files
... ...
@@ -60,11 +60,30 @@ static select_table_t *select_list = &select_core_table;
60 60
  */
61 61
 int select_level = 0;
62 62
 
63
-/*
63
+/** parse a select identifier (internal version)
64 64
  * Parse select string into select structure s
65
- * moves pointer p to the first unused char
65
+ * moves pointer p to the first unused char.
66
+ *
67
+ * The select identifier must be of the form:
68
+ *   [@] <sel_id> [ '.' <sel_id> ...]
69
+ *   
70
+ * Where 
71
+ *       <sel_id> = <id> |
72
+ *                  <id> '[' <idx> ']'
73
+ *       <id> = [a-zA-Z0-9_]+
74
+ *       <idx> = <number> | <string>
75
+ *       <string> = '"' <ascii> '"' | 
76
+ *                  '\"' <ascii> '\"'
77
+ *
78
+ * Examples:
79
+ *     @to.tag
80
+ *     @hf_value["contact"]
81
+ *     @msg.header["SER-Server-ID"]
82
+ *     @eval.pop[-1]
83
+ *     contact.uri.params.maddr
84
+ *     cfg_get.rtp_proxy.enabled 
66 85
  *
67
- * Returns -1 error
86
+ * @return -1 error
68 87
  *			  p points to the first unconsumed char
69 88
  *          0 success
70 89
  *			  p points to the first unconsumed char
... ...
@@ -148,6 +167,35 @@ error:
148 167
 	return -1;
149 168
 }
150 169
 
170
+
171
+/** parse a select identifier.
172
+ * Parse select string into select structure s and
173
+ * moves pointer p to the first unused char.
174
+ * 
175
+ * The select identifier must be of the form:
176
+ *   [@] <sel_id> [ '.' <sel_id> ...]
177
+ *   
178
+ * Where 
179
+ *       <sel_id> = <id> |
180
+ *                  <id> '[' <idx> ']'
181
+ *       <id> = [a-zA-Z0-9_]+
182
+ *       <idx> = <number>  | '-' <number> | <string>
183
+ *       <string> = '"' <ascii> '"' | 
184
+ *                  '\"' <ascii> '\"'
185
+ *
186
+ * Examples:
187
+ *     @to.tag
188
+ *     @hf_value["contact"]
189
+ *     @msg.header["SER-Server-ID"]
190
+ *     @eval.pop[-1]
191
+ *     contact.uri.params.maddr
192
+ *     cfg_get.rtp_proxy.enabled 
193
+  *
194
+  * @param p - double string (asciiz) pointer, *p is moved to the first char
195
+  *            after the select identifier
196
+  * @param s - the result will be stored here
197
+  * @return  < 0 on error, 0 on success
198
+  */
151 199
 int parse_select (char** p, select_t** s)
152 200
 {
153 201
 	select_t* sel;
Browse code

- comment typos fixed

Jan Janak authored on 23/06/2008 17:12:04
Showing 1 changed files
... ...
@@ -351,8 +351,8 @@ int run_select(str* res, select_t* s, struct sip_msg* msg)
351 351
 	}
352 352
 	DBG("Calling SELECT %p \n", s->f);
353 353
 
354
-	/* save and resore the original select_level
355
-	 * because of the nested selets */
354
+	/* save and restore the original select_level
355
+	 * because of the nested selects */
356 356
 	orig_level = select_level;
357 357
 	ret = 0;
358 358
 	for (	select_level=0;
Browse code

Various warnings fixed (mostly appearing with 64b compiles).

Closes issue SER-343.

Bogdan Pintea authored on 31/03/2008 18:57:54
Showing 1 changed files
... ...
@@ -134,12 +134,12 @@ int w_parse_select(char**p, select_t* sel)
134 134
 		(*p)++;
135 135
 	};
136 136
 	if (sel->n==0) {
137
-		ERR("parse_select: invalid select '%.*s'\n", *p - select_name, select_name);
137
+		ERR("parse_select: invalid select '%.*s'\n", (int)(*p - select_name), select_name);
138 138
 		goto error;
139 139
 	};
140 140
 	DBG("parse_select: end, total elements: %d, calling resolve_select\n", sel->n);
141 141
 	if (resolve_select(sel)<0) {
142
-		ERR("parse_select: error while resolve_select '%.*s'\n", *p - select_name, select_name);
142
+		ERR("parse_select: error while resolve_select '%.*s'\n", (int)(*p - select_name), select_name);
143 143
 		goto error;
144 144
 	}
145 145
 	return 0;
Browse code

Introducing CONSUME_ALL flag: all the subsequent parameters are accepted without resolving or checking them Can be used to implement selects with more than one parameter

Miklos Tirpak authored on 11/01/2008 16:30:30
Showing 1 changed files
... ...
@@ -299,6 +299,17 @@ int resolve_select(select_t* s)
299 299
 		}
300 300