Browse code

modules_k/*: moved k modules in directory modules/

Daniel-Constantin Mierla authored on 20/01/2013 11:57:52
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,282 +0,0 @@
1
-/**
2
- * $Id$
3
- *
4
- * Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com)
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
-/*! \file
24
- * \ingroup sqlops
25
- * \brief SIP-router SQL-operations :: Variables
26
- *
27
- * - Module: \ref sqlops
28
- */
29
-
30
-
31
-#include "../../mem/mem.h"
32
-#include "../../dprint.h"
33
-#include "../../mod_fix.h"
34
-
35
-#include "sql_api.h"
36
-#include "sql_var.h"
37
-
38
-typedef struct _sql_pv {
39
-	str resname;
40
-	sql_result_t *res;
41
-	int type;
42
-	gparam_t row;
43
-	gparam_t col;
44
-} sql_pv_t;
45
-
46
-int pv_get_dbr(struct sip_msg *msg,  pv_param_t *param,
47
-		pv_value_t *res)
48
-{
49
-	sql_pv_t *spv;
50
-	int row;
51
-	int col;
52
-
53
-	spv = (sql_pv_t*)param->pvn.u.dname;
54
-
55
-	if(spv->res==NULL)
56
-	{
57
-		spv->res = sql_get_result(&spv->resname);
58
-		if(spv->res==NULL)
59
-			return pv_get_null(msg, param, res);
60
-	}
61
-
62
-	switch(spv->type)
63
-	{
64
-		case 1:
65
-			return pv_get_sintval(msg, param, res, spv->res->nrows);
66
-		break;
67
-		case 2:
68
-			return pv_get_sintval(msg, param, res, spv->res->ncols);
69
-		break;
70
-		case 3:
71
-			if(fixup_get_ivalue(msg, &spv->row, &row)!=0)
72
-				return pv_get_null(msg, param, res);
73
-			if(fixup_get_ivalue(msg, &spv->col, &col)!=0)
74
-				return pv_get_null(msg, param, res);
75
-			if(row>=spv->res->nrows)
76
-				return pv_get_null(msg, param, res);
77
-			if(col>=spv->res->ncols)
78
-				return pv_get_null(msg, param, res);
79
-			if(spv->res->vals[row][col].flags&PV_VAL_NULL)
80
-				return pv_get_null(msg, param, res);
81
-			if(spv->res->vals[row][col].flags&PV_VAL_INT)
82
-				return pv_get_sintval(msg, param, res, 
83
-						spv->res->vals[row][col].value.n);
84
-			return pv_get_strval(msg, param, res, 
85
-						&spv->res->vals[row][col].value.s);
86
-		break;
87
-		case 4:
88
-			if(fixup_get_ivalue(msg, &spv->col, &col)!=0)
89
-				return pv_get_null(msg, param, res);
90
-			if(col>=spv->res->ncols)
91
-				return pv_get_null(msg, param, res);
92
-			return pv_get_strval(msg, param, res, 
93
-						&spv->res->cols[col].name);
94
-		break;
95
-	}
96
-	return 0;
97
-}
98
-
99
-
100
-int sql_parse_index(str *in, gparam_t *gp)
101
-{
102
-	if(in->s[0]==PV_MARKER)
103
-	{
104
-		gp->type = GPARAM_TYPE_PVS;
105
-		gp->v.pvs = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
106
-		if (gp->v.pvs == NULL)
107
-		{
108
-			LM_ERR("no pkg memory left for pv_spec_t\n");
109
-		    pkg_free(gp);
110
-		    return -1;
111
-		}
112
-
113
-		if(pv_parse_spec(in, gp->v.pvs)==NULL)
114
-		{
115
-			LM_ERR("invalid PV identifier\n");
116
-		    pkg_free(gp->v.pvs);
117
-		    pkg_free(gp);
118
-			return -1;
119
-		}
120
-	} else {
121
-		gp->type = GPARAM_TYPE_INT;
122
-		if(str2sint(in, &gp->v.i) != 0)
123
-		{
124
-			LM_ERR("bad number <%.*s>\n", in->len, in->s);
125
-			return -1;
126
-		}
127
-	}
128
-	return 0;
129
-}
130
-
131
-int pv_parse_dbr_name(pv_spec_p sp, str *in)
132
-{
133
-	sql_pv_t *spv=NULL;
134
-	char *p;
135
-	str pvs;
136
-	str tok;
137
-
138
-	spv = (sql_pv_t*)pkg_malloc(sizeof(sql_pv_t));
139
-	if(spv==NULL)
140
-		return -1;
141
-
142
-	memset(spv, 0, sizeof(sql_pv_t));
143
-
144
-	p = in->s;
145
-
146
-	while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
147
-		p++;
148
-	if(p>in->s+in->len || *p=='\0')
149
-		goto error;
150
-	spv->resname.s = p;
151
-	while(p < in->s + in->len)
152
-	{
153
-		if(*p=='=' || *p==' ' || *p=='\t' || *p=='\n' || *p=='\r')
154
-			break;
155
-		p++;
156
-	}
157
-	if(p>in->s+in->len || *p=='\0')
158
-		goto error;
159
-	spv->resname.len = p - spv->resname.s;
160
-	spv->res = sql_get_result(&spv->resname);
161
-
162
-	if(*p!='=')
163
-	{
164
-		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
165
-			p++;
166
-		if(p>in->s+in->len || *p=='\0' || *p!='=')
167
-			goto error;
168
-	}
169
-	p++;
170
-	if(*p!='>')
171
-		goto error;
172
-	p++;
173
-
174
-	pvs.len = in->len - (int)(p - in->s);
175
-	pvs.s = p;
176
-	p = pvs.s+pvs.len-1;
177
-	while(p>pvs.s && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
178
-			p--;
179
-	if(p==pvs.s)
180
-	{
181
-		LM_ERR("invalid key in [%.*s]\n", in->len, in->s);
182
-		goto error;
183
-	}
184
-	pvs.len = p - pvs.s + 1;
185
-
186
-	LM_DBG("res [%.*s] - key [%.*s]\n", spv->resname.len, spv->resname.s,
187
-			pvs.len, pvs.s);
188
-	if(pvs.len==4 && strncmp(pvs.s, "rows", 4)==0)
189
-	{
190
-		spv->type = 1;
191
-	} else if(pvs.len==4 && strncmp(pvs.s, "cols", 4)==0) {
192
-		spv->type = 2;
193
-	} else if(pvs.s[0]=='[') {
194
-		spv->type = 3;
195
-		p = pvs.s+1;
196
-		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
197
-			p++;
198
-		if(p>in->s+in->len || *p=='\0')
199
-			goto error_index;
200
-		tok.s = p;
201
-		while(p < in->s + in->len)
202
-		{
203
-			if(*p==',' || *p==' ' || *p=='\t' || *p=='\n' || *p=='\r')
204
-				break;
205
-			p++;
206
-		}
207
-		if(p>in->s+in->len || *p=='\0')
208
-			goto error_index;
209
-		tok.len = p - tok.s;
210
-		if(sql_parse_index(&tok, &spv->row)!=0)
211
-			goto error_index;
212
-		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
213
-			p++;
214
-		if(p>in->s+in->len || *p=='\0' || *p!=',')
215
-			goto error_index;
216
-		p++;
217
-		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
218
-			p++;
219
-		if(p>in->s+in->len || *p=='\0')
220
-			goto error_index;
221
-		tok.s = p;
222
-		while(p < in->s + in->len)
223
-		{
224
-			if(*p==']' || *p==' ' || *p=='\t' || *p=='\n' || *p=='\r')
225
-				break;
226
-			p++;
227
-		}
228
-		if(p>in->s+in->len || *p=='\0')
229
-			goto error_index;
230
-		tok.len = p - tok.s;
231
-		if(sql_parse_index(&tok, &spv->col)!=0)
232
-			goto error_index;
233
-		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
234
-			p++;
235
-		if(p>in->s+in->len || *p=='\0' || *p!=']')
236
-			goto error_index;
237
-	} else if(pvs.len>9 && strncmp(pvs.s, "colname", 7)==0) {
238
-		spv->type = 4;
239
-		p = pvs.s+7;
240
-		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
241
-			p++;
242
-		if(p>in->s+in->len || *p=='\0' || *p!='[')
243
-			goto error_index;
244
-		p++;
245
-		tok.s = p;
246
-		while(p < in->s + in->len)
247
-		{
248
-			if(*p==']' || *p==' ' || *p=='\t' || *p=='\n' || *p=='\r')
249
-				break;
250
-			p++;
251
-		}
252
-		if(p>in->s+in->len || *p=='\0')
253
-			goto error_index;
254
-		tok.len = p - tok.s;
255
-		if(sql_parse_index(&tok, &spv->col)!=0)
256
-			goto error_index;
257
-		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
258
-			p++;
259
-		if(p>in->s+in->len || *p=='\0' || *p!=']')
260
-			goto error_index;
261
-	} else {
262
-		LM_ERR("unknow key [%.*s]\n", pvs.len, pvs.s);
263
-		return -1;
264
-	}
265
-	sp->pvp.pvn.u.dname = (void*)spv;
266
-	sp->pvp.pvn.type = PV_NAME_PVAR;
267
-
268
-	return 0;
269
-
270
-error:
271
-	LM_ERR("invalid pv name [%.*s]\n", in->len, in->s);
272
-	if(spv!=NULL)
273
-		pkg_free(spv);
274
-	return -1;
275
-
276
-error_index:
277
-	LM_ERR("invalid index in [%.*s]\n", pvs.len, pvs.s);
278
-	if(spv!=NULL)
279
-		pkg_free(spv);
280
-	return -1;
281
-}
282
-
Browse code

all: replaced openser with kamailio in license and comments

- some files were forgotten during renaming

Daniel-Constantin Mierla authored on 18/10/2012 12:18:19
Showing 1 changed files
... ...
@@ -5,12 +5,12 @@
5 5
  *
6 6
  * This file is part of kamailio, a free SIP server.
7 7
  *
8
- * openser is free software; you can redistribute it and/or modify
8
+ * Kamailio is free software; you can redistribute it and/or modify
9 9
  * it under the terms of the GNU General Public License as published by
10 10
  * the Free Software Foundation; either version 2 of the License, or
11 11
  * (at your option) any later version
12 12
  *
13
- * openser is distributed in the hope that it will be useful,
13
+ * Kamailio is distributed in the hope that it will be useful,
14 14
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 16
  * GNU General Public License for more details.
Browse code

sqlops: return $null pv if the value in result is null

Daniel-Constantin Mierla authored on 15/11/2010 20:47:51
Showing 1 changed files
... ...
@@ -76,6 +76,8 @@ int pv_get_dbr(struct sip_msg *msg,  pv_param_t *param,
76 76
 				return pv_get_null(msg, param, res);
77 77
 			if(col>=spv->res->ncols)
78 78
 				return pv_get_null(msg, param, res);
79
+			if(spv->res->vals[row][col].flags&PV_VAL_NULL)
80
+				return pv_get_null(msg, param, res);
79 81
 			if(spv->res->vals[row][col].flags&PV_VAL_INT)
80 82
 				return pv_get_sintval(msg, param, res, 
81 83
 						spv->res->vals[row][col].value.n);
Browse code

Doxygen updates

oej authored on 18/10/2009 22:15:27
Showing 1 changed files
... ...
@@ -20,6 +20,14 @@
20 20
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 21
  */
22 22
 
23
+/*! \file
24
+ * \ingroup sqlops
25
+ * \brief SIP-router SQL-operations :: Variables
26
+ *
27
+ * - Module: \ref sqlops
28
+ */
29
+
30
+
23 31
 #include "../../mem/mem.h"
24 32
 #include "../../dprint.h"
25 33
 #include "../../mod_fix.h"
Browse code

Rename ival attribute in gparam structure to just 'i'

Jan Janak authored on 03/03/2009 16:43:32
Showing 1 changed files
... ...
@@ -109,7 +109,7 @@ int sql_parse_index(str *in, gparam_t *gp)
109 109
 		}
110 110
 	} else {
111 111
 		gp->type = GPARAM_TYPE_INT;
112
-		if(str2sint(in, &gp->v.ival) != 0)
112
+		if(str2sint(in, &gp->v.i) != 0)
113 113
 		{
114 114
 			LM_ERR("bad number <%.*s>\n", in->len, in->s);
115 115
 			return -1;
Browse code

- new module sqlops - SQL operations - execute raw sql queries and play with the results in config file - ability to use many DB servers/connections at same time - ability to keep many DB results at same time - access to result fields via pseudo-variable $dbr(res=>key) - see README file for more

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5307 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla authored on 06/12/2008 09:04:38
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,272 @@
1
+/**
2
+ * $Id$
3
+ *
4
+ * Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com)
5
+ *
6
+ * This file is part of kamailio, a free SIP server.
7
+ *
8
+ * openser 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
+ * openser 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
+#include "../../mem/mem.h"
24
+#include "../../dprint.h"
25
+#include "../../mod_fix.h"
26
+
27
+#include "sql_api.h"
28
+#include "sql_var.h"
29
+
30
+typedef struct _sql_pv {
31
+	str resname;
32
+	sql_result_t *res;
33
+	int type;
34
+	gparam_t row;
35
+	gparam_t col;
36
+} sql_pv_t;
37
+
38
+int pv_get_dbr(struct sip_msg *msg,  pv_param_t *param,
39
+		pv_value_t *res)
40
+{
41
+	sql_pv_t *spv;
42
+	int row;
43
+	int col;
44
+
45
+	spv = (sql_pv_t*)param->pvn.u.dname;
46
+
47
+	if(spv->res==NULL)
48
+	{
49
+		spv->res = sql_get_result(&spv->resname);
50
+		if(spv->res==NULL)
51
+			return pv_get_null(msg, param, res);
52
+	}
53
+
54
+	switch(spv->type)
55
+	{
56
+		case 1:
57
+			return pv_get_sintval(msg, param, res, spv->res->nrows);
58
+		break;
59
+		case 2:
60
+			return pv_get_sintval(msg, param, res, spv->res->ncols);
61
+		break;
62
+		case 3:
63
+			if(fixup_get_ivalue(msg, &spv->row, &row)!=0)
64
+				return pv_get_null(msg, param, res);
65
+			if(fixup_get_ivalue(msg, &spv->col, &col)!=0)
66
+				return pv_get_null(msg, param, res);
67
+			if(row>=spv->res->nrows)
68
+				return pv_get_null(msg, param, res);
69
+			if(col>=spv->res->ncols)
70
+				return pv_get_null(msg, param, res);
71
+			if(spv->res->vals[row][col].flags&PV_VAL_INT)
72
+				return pv_get_sintval(msg, param, res, 
73
+						spv->res->vals[row][col].value.n);
74
+			return pv_get_strval(msg, param, res, 
75
+						&spv->res->vals[row][col].value.s);
76
+		break;
77
+		case 4:
78
+			if(fixup_get_ivalue(msg, &spv->col, &col)!=0)
79
+				return pv_get_null(msg, param, res);
80
+			if(col>=spv->res->ncols)
81
+				return pv_get_null(msg, param, res);
82
+			return pv_get_strval(msg, param, res, 
83
+						&spv->res->cols[col].name);
84
+		break;
85
+	}
86
+	return 0;
87
+}
88
+
89
+
90
+int sql_parse_index(str *in, gparam_t *gp)
91
+{
92
+	if(in->s[0]==PV_MARKER)
93
+	{
94
+		gp->type = GPARAM_TYPE_PVS;
95
+		gp->v.pvs = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
96
+		if (gp->v.pvs == NULL)
97
+		{
98
+			LM_ERR("no pkg memory left for pv_spec_t\n");
99
+		    pkg_free(gp);
100
+		    return -1;
101
+		}
102
+
103
+		if(pv_parse_spec(in, gp->v.pvs)==NULL)
104
+		{
105
+			LM_ERR("invalid PV identifier\n");
106
+		    pkg_free(gp->v.pvs);
107
+		    pkg_free(gp);
108
+			return -1;
109
+		}
110
+	} else {
111
+		gp->type = GPARAM_TYPE_INT;
112
+		if(str2sint(in, &gp->v.ival) != 0)
113
+		{
114
+			LM_ERR("bad number <%.*s>\n", in->len, in->s);
115
+			return -1;
116
+		}
117
+	}
118
+	return 0;
119
+}
120
+
121
+int pv_parse_dbr_name(pv_spec_p sp, str *in)
122
+{
123
+	sql_pv_t *spv=NULL;
124
+	char *p;
125
+	str pvs;
126
+	str tok;
127
+
128
+	spv = (sql_pv_t*)pkg_malloc(sizeof(sql_pv_t));
129
+	if(spv==NULL)
130
+		return -1;
131
+
132
+	memset(spv, 0, sizeof(sql_pv_t));
133
+
134
+	p = in->s;
135
+
136
+	while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
137
+		p++;
138
+	if(p>in->s+in->len || *p=='\0')
139
+		goto error;
140
+	spv->resname.s = p;
141
+	while(p < in->s + in->len)
142
+	{
143
+		if(*p=='=' || *p==' ' || *p=='\t' || *p=='\n' || *p=='\r')
144
+			break;
145
+		p++;
146
+	}
147
+	if(p>in->s+in->len || *p=='\0')
148
+		goto error;
149
+	spv->resname.len = p - spv->resname.s;
150
+	spv->res = sql_get_result(&spv->resname);
151
+
152
+	if(*p!='=')
153
+	{
154
+		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
155
+			p++;
156
+		if(p>in->s+in->len || *p=='\0' || *p!='=')
157
+			goto error;
158
+	}
159
+	p++;
160
+	if(*p!='>')
161
+		goto error;
162
+	p++;
163
+
164
+	pvs.len = in->len - (int)(p - in->s);
165
+	pvs.s = p;
166
+	p = pvs.s+pvs.len-1;
167
+	while(p>pvs.s && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
168
+			p--;
169
+	if(p==pvs.s)
170
+	{
171
+		LM_ERR("invalid key in [%.*s]\n", in->len, in->s);
172
+		goto error;
173
+	}
174
+	pvs.len = p - pvs.s + 1;
175
+
176
+	LM_DBG("res [%.*s] - key [%.*s]\n", spv->resname.len, spv->resname.s,
177
+			pvs.len, pvs.s);
178
+	if(pvs.len==4 && strncmp(pvs.s, "rows", 4)==0)
179
+	{
180
+		spv->type = 1;
181
+	} else if(pvs.len==4 && strncmp(pvs.s, "cols", 4)==0) {
182
+		spv->type = 2;
183
+	} else if(pvs.s[0]=='[') {
184
+		spv->type = 3;
185
+		p = pvs.s+1;
186
+		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
187
+			p++;
188
+		if(p>in->s+in->len || *p=='\0')
189
+			goto error_index;
190
+		tok.s = p;
191
+		while(p < in->s + in->len)
192
+		{
193
+			if(*p==',' || *p==' ' || *p=='\t' || *p=='\n' || *p=='\r')
194
+				break;
195
+			p++;
196
+		}
197
+		if(p>in->s+in->len || *p=='\0')
198
+			goto error_index;
199
+		tok.len = p - tok.s;
200
+		if(sql_parse_index(&tok, &spv->row)!=0)
201
+			goto error_index;
202
+		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
203
+			p++;
204
+		if(p>in->s+in->len || *p=='\0' || *p!=',')
205
+			goto error_index;
206
+		p++;
207
+		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
208
+			p++;
209
+		if(p>in->s+in->len || *p=='\0')
210
+			goto error_index;
211
+		tok.s = p;
212
+		while(p < in->s + in->len)
213
+		{
214
+			if(*p==']' || *p==' ' || *p=='\t' || *p=='\n' || *p=='\r')
215
+				break;
216
+			p++;
217
+		}
218
+		if(p>in->s+in->len || *p=='\0')
219
+			goto error_index;
220
+		tok.len = p - tok.s;
221
+		if(sql_parse_index(&tok, &spv->col)!=0)
222
+			goto error_index;
223
+		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
224
+			p++;
225
+		if(p>in->s+in->len || *p=='\0' || *p!=']')
226
+			goto error_index;
227
+	} else if(pvs.len>9 && strncmp(pvs.s, "colname", 7)==0) {
228
+		spv->type = 4;
229
+		p = pvs.s+7;
230
+		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
231
+			p++;
232
+		if(p>in->s+in->len || *p=='\0' || *p!='[')
233
+			goto error_index;
234
+		p++;
235
+		tok.s = p;
236
+		while(p < in->s + in->len)
237
+		{
238
+			if(*p==']' || *p==' ' || *p=='\t' || *p=='\n' || *p=='\r')
239
+				break;
240
+			p++;
241
+		}
242
+		if(p>in->s+in->len || *p=='\0')
243
+			goto error_index;
244
+		tok.len = p - tok.s;
245
+		if(sql_parse_index(&tok, &spv->col)!=0)
246
+			goto error_index;
247
+		while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
248
+			p++;
249
+		if(p>in->s+in->len || *p=='\0' || *p!=']')
250
+			goto error_index;
251
+	} else {
252
+		LM_ERR("unknow key [%.*s]\n", pvs.len, pvs.s);
253
+		return -1;
254
+	}
255
+	sp->pvp.pvn.u.dname = (void*)spv;
256
+	sp->pvp.pvn.type = PV_NAME_PVAR;
257
+
258
+	return 0;
259
+
260
+error:
261
+	LM_ERR("invalid pv name [%.*s]\n", in->len, in->s);
262
+	if(spv!=NULL)
263
+		pkg_free(spv);
264
+	return -1;
265
+
266
+error_index:
267
+	LM_ERR("invalid index in [%.*s]\n", pvs.len, pvs.s);
268
+	if(spv!=NULL)
269
+		pkg_free(spv);
270
+	return -1;
271
+}
272
+