Browse code

posops: docs - updated pos_set_char() section

- note that the change is done directly inside the sip message buffer

Daniel-Constantin Mierla authored on 08/09/2022 08:09:14
Showing 1 changed files
... ...
@@ -168,6 +168,10 @@ pos_insert("100", "10");
168 168
 			Set the char at position index to first character in val.
169 169
 			</para>
170 170
 			<para>
171
+			Important: it changes the character directly in the SIP message
172
+			buffer, the update being immediately visible.
173
+			</para>
174
+			<para>
171 175
 			The idx can be an integer value or a variable holding an integer. If
172 176
 			the value is negative, the position is counted from the end of the buffer.
173 177
 			</para>
Browse code

posops: docs for pos_set_char()

Daniel-Constantin Mierla authored on 08/11/2021 11:46:53
Showing 1 changed files
... ...
@@ -156,6 +156,32 @@ pos_insert("100", "kamailio-$si");
156 156
 				<programlisting format="linespecific">
157 157
 ...
158 158
 pos_insert("100", "10");
159
+...
160
+				</programlisting>
161
+			</example>
162
+		</section>
163
+		<section id="posops.f.pos_set_char">
164
+			<title>
165
+				<function moreinfo="none">pos_set_char(idx, val)</function>
166
+			</title>
167
+			<para>
168
+			Set the char at position index to first character in val.
169
+			</para>
170
+			<para>
171
+			The idx can be an integer value or a variable holding an integer. If
172
+			the value is negative, the position is counted from the end of the buffer.
173
+			</para>
174
+			<para>
175
+			The val can be a static string or variables.
176
+			</para>
177
+			<para>
178
+			This function can be used from ANY_ROUTE.
179
+			</para>
180
+			<example>
181
+				<title><function>pos_set_char()</function> usage</title>
182
+				<programlisting format="linespecific">
183
+...
184
+pos_set_char("100", "x");
159 185
 ...
160 186
 				</programlisting>
161 187
 			</example>
Browse code

posops: pos_rsearch() - search last occurence of a regex

Daniel-Constantin Mierla authored on 30/09/2021 06:43:08
Showing 1 changed files
... ...
@@ -376,6 +376,35 @@ $var(idx) = pos_rfindi_str("100", "kamailio");
376 376
 				<programlisting format="linespecific">
377 377
 ...
378 378
 $var(idx) = pos_search("100", "[0-9]+");
379
+...
380
+				</programlisting>
381
+			</example>
382
+		</section>
383
+		<section id="posops.f.pos_rsearch">
384
+			<title>
385
+				<function moreinfo="none">pos_rsearch(idx, re)</function>
386
+			</title>
387
+			<para>
388
+			Return the position of last match that starts matching the regular
389
+			expression re in message buffer starting at idx. In case of not
390
+			finding it or error, the return code is negative. If val is at
391
+			index 0, it returns the value specified by modparam idx0.
392
+			</para>
393
+			<para>
394
+			The idx can be an integer value or a variable holding an integer. If
395
+			the value is negative, the position is counted from the end of the buffer.
396
+			</para>
397
+			<para>
398
+			The re can be a static regular expression string.
399
+			</para>
400
+			<para>
401
+			This function can be used from ANY_ROUTE.
402
+			</para>
403
+			<example>
404
+				<title><function>pos_rsearch()</function> usage</title>
405
+				<programlisting format="linespecific">
406
+...
407
+$var(idx) = pos_rsearch("100", "[0-9]+");
379 408
 ...
380 409
 				</programlisting>
381 410
 			</example>
Browse code

posops: docs - section with notes about exported variables

Daniel-Constantin Mierla authored on 29/09/2021 07:40:06
Showing 1 changed files
... ...
@@ -382,5 +382,17 @@ $var(idx) = pos_search("100", "[0-9]+");
382 382
 		</section>
383 383
 	</section>
384 384
 
385
+	<section id="posops.pvs">
386
+		<title>Pseudo Variables</title>
387
+		<para>
388
+			The module exports a pseudo-variable class, $pos(key), to access
389
+			attributes upon specific function execution.
390
+		</para>
391
+		<para>
392
+			These are documented in the appropriate Wiki pages hosted on the
393
+			project web site.
394
+		</para>
395
+	</section>
396
+
385 397
 </chapter>
386 398
 
Browse code

posops: function to get the position of a regexp match

Daniel-Constantin Mierla authored on 27/09/2021 10:35:47
Showing 1 changed files
... ...
@@ -347,6 +347,35 @@ $var(idx) = pos_rfind_str("100", "kamailio");
347 347
 				<programlisting format="linespecific">
348 348
 ...
349 349
 $var(idx) = pos_rfindi_str("100", "kamailio");
350
+...
351
+				</programlisting>
352
+			</example>
353
+		</section>
354
+		<section id="posops.f.pos_search">
355
+			<title>
356
+				<function moreinfo="none">pos_search(idx, re)</function>
357
+			</title>
358
+			<para>
359
+			Return the position that starts matching the regular expression re
360
+			in message buffer starting at idx. In case of not finding it or error,
361
+			the return code is negative. If val is at index 0, it returns the
362
+			value specified by modparam idx0.
363
+			</para>
364
+			<para>
365
+			The idx can be an integer value or a variable holding an integer. If
366
+			the value is negative, the position is counted from the end of the buffer.
367
+			</para>
368
+			<para>
369
+			The re can be a static regular expression string.
370
+			</para>
371
+			<para>
372
+			This function can be used from ANY_ROUTE.
373
+			</para>
374
+			<example>
375
+				<title><function>pos_search()</function> usage</title>
376
+				<programlisting format="linespecific">
377
+...
378
+$var(idx) = pos_search("100", "[0-9]+");
350 379
 ...
351 380
 				</programlisting>
352 381
 			</example>
Browse code

posops: functions for getting the position by reverse search

Daniel-Constantin Mierla authored on 23/09/2021 07:25:43
Showing 1 changed files
... ...
@@ -264,7 +264,7 @@ $var(idx) = pos_find_str("100", "kamailio");
264 264
 				</programlisting>
265 265
 			</example>
266 266
 		</section>
267
-		<section id="posops.f.pos_find_str">
267
+		<section id="posops.f.pos_findi_str">
268 268
 			<title>
269 269
 				<function moreinfo="none">pos_findi_str(idx, val)</function>
270 270
 			</title>
... ...
@@ -289,6 +289,64 @@ $var(idx) = pos_find_str("100", "kamailio");
289 289
 				<programlisting format="linespecific">
290 290
 ...
291 291
 $var(idx) = pos_findi_str("100", "kamailio");
292
+...
293
+				</programlisting>
294
+			</example>
295
+		</section>
296
+		<section id="posops.f.pos_rfind_str">
297
+			<title>
298
+				<function moreinfo="none">pos_rfind_str(idx, val)</function>
299
+			</title>
300
+			<para>
301
+			Return the last position of the val in message buffer starting at idx
302
+			(reverse search). In case of not finding it or error, the return code
303
+			is negative. If val is at index 0, it returns the value specified
304
+			by modparam idx0.
305
+			</para>
306
+			<para>
307
+			The idx can be an integer value or a variable holding an integer. If
308
+			the value is negative, the position is counted from the end of the buffer.
309
+			</para>
310
+			<para>
311
+			The val can be a static string or variables.
312
+			</para>
313
+			<para>
314
+			This function can be used from ANY_ROUTE.
315
+			</para>
316
+			<example>
317
+				<title><function>pos_find_str()</function> usage</title>
318
+				<programlisting format="linespecific">
319
+...
320
+$var(idx) = pos_rfind_str("100", "kamailio");
321
+...
322
+				</programlisting>
323
+			</example>
324
+		</section>
325
+		<section id="posops.f.pos_rfindi_str">
326
+			<title>
327
+				<function moreinfo="none">pos_rfindi_str(idx, val)</function>
328
+			</title>
329
+			<para>
330
+			Return the last position of the val (matching case insensitive) in message
331
+			buffer starting at idx (reverse search). In case of not finding it
332
+			or error, the return code is negative. If val is at index 0, it
333
+			returns the value specified by modparam idx0.
334
+			</para>
335
+			<para>
336
+			The idx can be an integer value or a variable holding an integer. If
337
+			the value is negative, the position is counted from the end of the buffer.
338
+			</para>
339
+			<para>
340
+			The val can be a static string or variables.
341
+			</para>
342
+			<para>
343
+			This function can be used from ANY_ROUTE.
344
+			</para>
345
+			<example>
346
+				<title><function>pos_rfindi_str()</function> usage</title>
347
+				<programlisting format="linespecific">
348
+...
349
+$var(idx) = pos_rfindi_str("100", "kamailio");
292 350
 ...
293 351
 				</programlisting>
294 352
 			</example>
Browse code

posops: handle negative index parameter for find functions

Daniel-Constantin Mierla authored on 23/09/2021 07:06:51
Showing 1 changed files
... ...
@@ -246,7 +246,8 @@ $var(pos) = pos_body_end();
246 246
 			val is at index 0, it returns the value specified by modparam idx0.
247 247
 			</para>
248 248
 			<para>
249
-			The idx can be an integer value or a variable holding an integer.
249
+			The idx can be an integer value or a variable holding an integer. If
250
+			the value is negative, the position is counted from the end of the buffer.
250 251
 			</para>
251 252
 			<para>
252 253
 			The val can be a static string or variables.
... ...
@@ -274,7 +275,8 @@ $var(idx) = pos_find_str("100", "kamailio");
274 275
 			by modparam idx0.
275 276
 			</para>
276 277
 			<para>
277
-			The idx can be an integer value or a variable holding an integer.
278
+			The idx can be an integer value or a variable holding an integer. If
279
+			the value is negative, the position is counted from the end of the buffer.
278 280
 			</para>
279 281
 			<para>
280 282
 			The val can be a static string or variables.
Browse code

posops: functions to get the position of a string in message buffer

Daniel-Constantin Mierla authored on 21/09/2021 13:50:33
Showing 1 changed files
... ...
@@ -232,6 +232,61 @@ $var(pos) = pos_body_start();
232 232
 				<programlisting format="linespecific">
233 233
 ...
234 234
 $var(pos) = pos_body_end();
235
+...
236
+				</programlisting>
237
+			</example>
238
+		</section>
239
+		<section id="posops.f.pos_find_str">
240
+			<title>
241
+				<function moreinfo="none">pos_find_str(idx, val)</function>
242
+			</title>
243
+			<para>
244
+			Return the position of the val in message buffer starting at idx. In
245
+			case of not finding it or error, the return code is negative. If
246
+			val is at index 0, it returns the value specified by modparam idx0.
247
+			</para>
248
+			<para>
249
+			The idx can be an integer value or a variable holding an integer.
250
+			</para>
251
+			<para>
252
+			The val can be a static string or variables.
253
+			</para>
254
+			<para>
255
+			This function can be used from ANY_ROUTE.
256
+			</para>
257
+			<example>
258
+				<title><function>pos_find_str()</function> usage</title>
259
+				<programlisting format="linespecific">
260
+...
261
+$var(idx) = pos_find_str("100", "kamailio");
262
+...
263
+				</programlisting>
264
+			</example>
265
+		</section>
266
+		<section id="posops.f.pos_find_str">
267
+			<title>
268
+				<function moreinfo="none">pos_findi_str(idx, val)</function>
269
+			</title>
270
+			<para>
271
+			Return the position of the val (matching case insensitive) in message
272
+			buffer starting at idx. In case of not finding it or error, the return
273
+			code is negative. If val is at index 0, it returns the value specified
274
+			by modparam idx0.
275
+			</para>
276
+			<para>
277
+			The idx can be an integer value or a variable holding an integer.
278
+			</para>
279
+			<para>
280
+			The val can be a static string or variables.
281
+			</para>
282
+			<para>
283
+			This function can be used from ANY_ROUTE.
284
+			</para>
285
+			<example>
286
+				<title><function>pos_findi_str()</function> usage</title>
287
+				<programlisting format="linespecific">
288
+...
289
+$var(idx) = pos_findi_str("100", "kamailio");
235 290
 ...
236 291
 				</programlisting>
237 292
 			</example>
Browse code

posops: added idx0 mod param

- set the value to return by function when position is at index 0
- default -255

Daniel-Constantin Mierla authored on 21/09/2021 08:23:53
Showing 1 changed files
... ...
@@ -54,6 +54,31 @@
54 54
 	</section>
55 55
 	</section>
56 56
 
57
+	<section>
58
+	<title>Parameters</title>
59
+	<section id="posops.p.idx0">
60
+		<title><varname>idx0</varname> (int)</title>
61
+		<para>
62
+			The value to return by functions seeking a position when the index
63
+			is 0 (note: returning 0 is stopping the execution of configuration
64
+			file like 'exit', but for KEMI usage it is ok).
65
+		</para>
66
+		<para>
67
+		<emphasis>
68
+			Default value is -255.
69
+		</emphasis>
70
+		</para>
71
+		<example>
72
+		<title>Set <varname>idx0</varname> parameter</title>
73
+		<programlisting format="linespecific">
74
+...
75
+modparam("posops", "idx0", -200)
76
+...
77
+</programlisting>
78
+		</example>
79
+	</section>
80
+	</section>
81
+
57 82
 	<section>
58 83
 	<title>Functions</title>
59 84
 		<section id="posops.f.pos_append">
Browse code

posops: added functions to get where the headers and body start or end

Daniel-Constantin Mierla authored on 17/09/2021 10:58:28
Showing 1 changed files
... ...
@@ -131,6 +131,82 @@ pos_insert("100", "kamailio-$si");
131 131
 				<programlisting format="linespecific">
132 132
 ...
133 133
 pos_insert("100", "10");
134
+...
135
+				</programlisting>
136
+			</example>
137
+		</section>
138
+		<section id="posops.f.pos_headers_start">
139
+			<title>
140
+				<function moreinfo="none">pos_headers_start()</function>
141
+			</title>
142
+			<para>
143
+			Return the position in the message buffer where headers start.
144
+			</para>
145
+			<para>
146
+			This function can be used from ANY_ROUTE.
147
+			</para>
148
+			<example>
149
+				<title><function>pos_headers_start()</function> usage</title>
150
+				<programlisting format="linespecific">
151
+...
152
+$var(pos) = pos_headers_start();
153
+...
154
+				</programlisting>
155
+			</example>
156
+		</section>
157
+		<section id="posops.f.pos_headers_end">
158
+			<title>
159
+				<function moreinfo="none">pos_headers_end()</function>
160
+			</title>
161
+			<para>
162
+			Return the position in the message buffer where headers end.
163
+			</para>
164
+			<para>
165
+			This function can be used from ANY_ROUTE.
166
+			</para>
167
+			<example>
168
+				<title><function>pos_headers_end()</function> usage</title>
169
+				<programlisting format="linespecific">
170
+...
171
+$var(pos) = pos_headers_end();
172
+...
173
+				</programlisting>
174
+			</example>
175
+		</section>
176
+		<section id="posops.f.pos_body_start">
177
+			<title>
178
+				<function moreinfo="none">pos_body_start()</function>
179
+			</title>
180
+			<para>
181
+			Return the position in the message buffer where body starts.
182
+			</para>
183
+			<para>
184
+			This function can be used from ANY_ROUTE.
185
+			</para>
186
+			<example>
187
+				<title><function>pos_body_start()</function> usage</title>
188
+				<programlisting format="linespecific">
189
+...
190
+$var(pos) = pos_body_start();
191
+...
192
+				</programlisting>
193
+			</example>
194
+		</section>
195
+		<section id="posops.f.pos_body_end">
196
+			<title>
197
+				<function moreinfo="none">pos_body_end()</function>
198
+			</title>
199
+			<para>
200
+			Return the position in the message buffer where body ends.
201
+			</para>
202
+			<para>
203
+			This function can be used from ANY_ROUTE.
204
+			</para>
205
+			<example>
206
+				<title><function>pos_body_end()</function> usage</title>
207
+				<programlisting format="linespecific">
208
+...
209
+$var(pos) = pos_body_end();
134 210
 ...
135 211
 				</programlisting>
136 212
 			</example>
Browse code

posops: new module with functions working with the position in message buffer

- add/remove content at a specific position in the sip message buffer

Daniel-Constantin Mierla authored on 15/09/2021 12:54:59
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,141 @@
1
+<?xml version="1.0" encoding='ISO-8859-1'?>
2
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3
+"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
4
+
5
+<!-- Include general documentation entities -->
6
+<!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
7
+%docentities;
8
+
9
+]>
10
+<!-- Module User's Guide -->
11
+
12
+<chapter>
13
+
14
+	<title>&adminguide;</title>
15
+
16
+	<section>
17
+	<title>Overview</title>
18
+	<para>
19
+		The module exports utility functions to work with position inside the
20
+		SIP message buffer.
21
+	</para>
22
+	<para>
23
+		Among them are function to add or remove content at a specific position.
24
+	</para>
25
+	</section>
26
+	<section>
27
+	<title>Dependencies</title>
28
+	<section>
29
+		<title>&kamailio; Modules</title>
30
+		<para>
31
+		The following modules must be installed (but not loaded) to use this module:
32
+			<itemizedlist>
33
+			<listitem>
34
+			<para>
35
+				<emphasis>none</emphasis>.
36
+			</para>
37
+			</listitem>
38
+			</itemizedlist>
39
+		</para>
40
+	</section>
41
+	<section>
42
+		<title>External Libraries or Applications</title>
43
+		<para>
44
+		The following libraries or applications must be installed before running
45
+		&kamailio; with this module loaded:
46
+			<itemizedlist>
47
+			<listitem>
48
+			<para>
49
+				<emphasis>none</emphasis>.
50
+			</para>
51
+			</listitem>
52
+			</itemizedlist>
53
+		</para>
54
+	</section>
55
+	</section>
56
+
57
+	<section>
58
+	<title>Functions</title>
59
+		<section id="posops.f.pos_append">
60
+			<title>
61
+				<function moreinfo="none">pos_append(idx, val)</function>
62
+			</title>
63
+			<para>
64
+			Append the value val after the position idx in the SIP message buffer.
65
+			</para>
66
+			<para>
67
+			The idx can be an integer value or a variable holding an integer. If
68
+			the value is negative, the position is counted from the end of the buffer.
69
+			</para>
70
+			<para>
71
+			The val can be a static string or variables.
72
+			</para>
73
+			<para>
74
+			This function can be used from ANY_ROUTE.
75
+			</para>
76
+			<example>
77
+				<title><function>pos_append()</function> usage</title>
78
+				<programlisting format="linespecific">
79
+...
80
+pos_append("100", "kamailio-$si");
81
+...
82
+				</programlisting>
83
+			</example>
84
+		</section>
85
+		<section id="posops.f.pos_insert">
86
+			<title>
87
+				<function moreinfo="none">pos_insert(idx, val)</function>
88
+			</title>
89
+			<para>
90
+			Insert the value val at the position idx in the SIP message buffer.
91
+			</para>
92
+			<para>
93
+			The idx can be an integer value or a variable holding an integer. If
94
+			the value is negative, the position is counted from the end of the buffer.
95
+			</para>
96
+			<para>
97
+			The val can be a static string or variables.
98
+			</para>
99
+			<para>
100
+			This function can be used from ANY_ROUTE.
101
+			</para>
102
+			<example>
103
+				<title><function>pos_insert()</function> usage</title>
104
+				<programlisting format="linespecific">
105
+...
106
+pos_insert("100", "kamailio-$si");
107
+...
108
+				</programlisting>
109
+			</example>
110
+		</section>
111
+		<section id="posops.f.pos_rm">
112
+			<title>
113
+				<function moreinfo="none">pos_rm(idx, len)</function>
114
+			</title>
115
+			<para>
116
+			Remove len characters starting at the position idx in the SIP message buffer.
117
+			</para>
118
+			<para>
119
+			The idx can be an integer value or a variable holding an integer. If
120
+			the value is negative, the position is counted from the end of the buffer.
121
+			</para>
122
+			<para>
123
+			The idx can be a positive integer value or a variable holding a positive
124
+			integer.
125
+			</para>
126
+			<para>
127
+			This function can be used from ANY_ROUTE.
128
+			</para>
129
+			<example>
130
+				<title><function>pos_rm()</function> usage</title>
131
+				<programlisting format="linespecific">
132
+...
133
+pos_insert("100", "10");
134
+...
135
+				</programlisting>
136
+			</example>
137
+		</section>
138
+	</section>
139
+
140
+</chapter>
141
+