Browse code

textops: Fix typos

Akash Gupta authored on 24/06/2022 13:13:20 • Daniel-Constantin Mierla committed on 24/06/2022 13:49:50
Showing 1 changed files
... ...
@@ -1711,7 +1711,7 @@ if(is_privacy("id"))
1711 1711
 		Function can be used from all kinds of routes.
1712 1712
 		</para>
1713 1713
 		<example>
1714
-			<title><function>in_list()</function> usage</title>
1714
+			<title><function>in_list</function> usage</title>
1715 1715
 			<programlisting format="linespecific">
1716 1716
 ...
1717 1717
 $var(subject) = "fi";
... ...
@@ -1735,7 +1735,7 @@ if (in_list("$var(subject)", "$var(list)", ",")) {
1735 1735
 		Function can be used from all kinds of routes.
1736 1736
 		</para>
1737 1737
 		<example>
1738
-			<title><function>in_list()</function> usage</title>
1738
+			<title><function>in_list_prefix</function> usage</title>
1739 1739
 			<programlisting format="linespecific">
1740 1740
 ...
1741 1741
 $var(subject) = "final";
Browse code

textops: docs for remove_hf_match()

Daniel-Constantin Mierla authored on 11/03/2022 12:20:48
Showing 1 changed files
... ...
@@ -1541,6 +1541,50 @@ remove_hf_idx("X-My-Header", "-1");
1541 1541
 		</example>
1542 1542
 	</section>
1543 1543
 
1544
+	<section id="textops.f.remove_hf_match">
1545
+		<title>
1546
+		<function moreinfo="none">remove_hf_match(hname, op, expr)</function>
1547
+		</title>
1548
+		<para>
1549
+			Remove from message all headers with name 'hname' matching the body
1550
+			with expression <quote>expr</quote>, based on operator
1551
+			<quote>op</quote>.
1552
+		</para>
1553
+		<para>
1554
+		Returns true if at least one header is found and removed.
1555
+		</para>
1556
+		<para>Meaning of the parameters is as follows:</para>
1557
+		<itemizedlist>
1558
+		<listitem>
1559
+			<para><emphasis>hanem</emphasis> - name of the header.
1560
+			</para>
1561
+		</listitem>
1562
+		<listitem>
1563
+			<para><emphasis>op</emphasis> - operator - it can be: 'eq' - equal;
1564
+			'ne' - not equal; 'in' - include; 're' - regular expression match.
1565
+			</para>
1566
+		</listitem>
1567
+		<listitem>
1568
+			<para><emphasis>expr</emphasis> - expression to match.
1569
+			</para>
1570
+		</listitem>
1571
+		</itemizedlist>
1572
+		<para>
1573
+		This function can be used from ANY_ROUTE.
1574
+		</para>
1575
+		<example>
1576
+		<title><function>remove_hf_match</function> usage</title>
1577
+		<programlisting format="linespecific">
1578
+...
1579
+if(remove_hf_match("X-Info", "in", "^data")) {
1580
+    # all headers with name "X-Info" that have the body matching regular
1581
+    # expression "^data" are removed
1582
+}
1583
+...
1584
+</programlisting>
1585
+		</example>
1586
+	</section>
1587
+
1544 1588
 	<section id="textops.f.has_body">
1545 1589
 		<title>
1546 1590
 		<function moreinfo="none">has_body()</function>,
Browse code

textops: fix broken example for filter_body

Sven Uhlig authored on 20/10/2021 12:23:38 • Henning Westerholt committed on 20/10/2021 12:32:05
Showing 1 changed files
... ...
@@ -901,7 +901,7 @@ set_reply_body("test", "text/plain");
901 901
 		<programlisting format="linespecific">
902 902
 ...
903 903
 if (has_body("multipart/mixed")) {
904
-    if (filter_body("application/sdp") {
904
+    if (filter_body("application/sdp")) {
905 905
         remove_hf("Content-Type");
906 906
         append_hf("Content-Type: application/sdp\r\n");
907 907
     } else {
Browse code

textops: docs update to state regex params expect posix format

Daniel-Constantin Mierla authored on 05/10/2021 07:56:33
Showing 1 changed files
... ...
@@ -19,9 +19,15 @@
19 19
 		The module implements text based operations over the SIP message
20 20
 		processed by &kamailio;. SIP is a text based protocol and the module
21 21
 		provides a large set of very useful functions to manipulate the
22
-		message at text level, e.g., regular expression search and replace,
23
-		Perl-like substitutions, checks for method type, header presence,
24
-		insert of new header and date, etc.
22
+		message at text level, e.g., regular expression search, replace
23
+		or substitutions, checks for method type, header presence,
24
+		insert of new header and date, string comparisons, multi-part body
25
+		operations, etc.
26
+	</para>
27
+	<para>
28
+		If not stated otherwise, the regular expressions parameters for search,
29
+		replace or substitute have to be in POSIX format. For PCRE regular
30
+		expression matching, see the pcre or dialplan modules.
25 31
 	</para>
26 32
 	</section>
27 33
 	<section>
... ...
@@ -591,7 +597,7 @@ replace_hdrs_str("&kamailio;", "&kamailio; SIP Proxy", "a");
591 597
 		<function moreinfo="none">subst('/re/repl/flags')</function>
592 598
 		</title>
593 599
 		<para>
594
-		Replaces re with repl (sed or perl like).
600
+		Replaces re with repl.
595 601
 		</para>
596 602
 		<para>Meaning of the parameters is as follows:</para>
597 603
 		<itemizedlist>
... ...
@@ -728,7 +734,7 @@ if (subst_user('/(.*)3642$/$avp(user_prefix)\13642/')){$
728 734
 		<function moreinfo="none">subst_body('/re/repl/flags')</function>
729 735
 		</title>
730 736
 		<para>
731
-		Replaces re with repl (sed or perl like) in the body of the message.
737
+		Replaces re with repl in the body of the message.
732 738
 		</para>
733 739
 		<para>Meaning of the parameters is as follows:</para>
734 740
 		<itemizedlist>
... ...
@@ -768,7 +774,7 @@ if ( subst_body('/^o=(.*) /o=$fU /') ) {};
768 774
 		<function moreinfo="none">subst_hf(hf, subexp, flags)</function>
769 775
 		</title>
770 776
 		<para>
771
-		Perl-like substitutions in the body of a header field.
777
+		Substitutions in the body of a header field.
772 778
 		</para>
773 779
 		<para>Meaning of the parameters is as follows:</para>
774 780
 		<itemizedlist>
Browse code

textops: docs for remove_hf_idx() function

Daniel-Constantin Mierla authored on 26/05/2021 13:43:50
Showing 1 changed files
... ...
@@ -1497,6 +1497,44 @@ if(remove_hf_exp_pv("^$var(match)", "^$var(keep)"))
1497 1497
 		</example>
1498 1498
 	</section>
1499 1499
 
1500
+	<section id="textops.f.remove_hf_idx">
1501
+		<title>
1502
+		<function moreinfo="none">remove_hf_idx(hname, idx)</function>
1503
+		</title>
1504
+		<para>
1505
+			Remove from message the headers matching by name 'hname' with
1506
+			the index 'idx'.
1507
+		</para>
1508
+		<para>
1509
+		Returns true if the header is removed.
1510
+		</para>
1511
+		<para>Meaning of the parameters is as follows:</para>
1512
+		<itemizedlist>
1513
+		<listitem>
1514
+			<para><emphasis>hname</emphasis> - header name.</para>
1515
+		</listitem>
1516
+		<listitem>
1517
+			<para><emphasis>idx</emphasis> - index of the header, starting
1518
+			from 0 with first header; negative values count from the end of
1519
+			the headers, -1 being the last header matching the name.</para>
1520
+		</listitem>
1521
+		</itemizedlist>
1522
+		<para>
1523
+			The parameters can be config variables.
1524
+		</para>
1525
+		<para>
1526
+		This function can be used from ANY_ROUTE.
1527
+		</para>
1528
+		<example>
1529
+		<title><function>remove_hf_idx</function> usage</title>
1530
+		<programlisting format="linespecific">
1531
+...
1532
+remove_hf_idx("X-My-Header", "-1");
1533
+...
1534
+</programlisting>
1535
+		</example>
1536
+	</section>
1537
+
1500 1538
 	<section id="textops.f.has_body">
1501 1539
 		<title>
1502 1540
 		<function moreinfo="none">has_body()</function>,
Browse code

textops: docs for str_find() and str_ifind()

Daniel-Constantin Mierla authored on 30/03/2021 07:25:36
Showing 1 changed files
... ...
@@ -1760,6 +1760,52 @@ if (ends_with("$rU", "8800"))
1760 1760
 		</example>
1761 1761
 	</section>
1762 1762
 
1763
+	<section id="textops.f.str_find">
1764
+		<title>
1765
+		<function moreinfo="none">str_find(str1, str2)</function>
1766
+		</title>
1767
+		<para>
1768
+			The function returns <emphasis>true</emphasis> (greater than 0) if
1769
+			the str2 string is found in str1, case sensitive comparison.
1770
+		</para>
1771
+		<para>
1772
+		This function can be used from ANY_ROUTE.
1773
+		</para>
1774
+		<example>
1775
+		<title><function>str_find</function> usage</title>
1776
+		<programlisting format="linespecific">
1777
+...
1778
+if (str_find("$rU", "8800")) {
1779
+    # do interesting stuff here
1780
+}
1781
+...
1782
+</programlisting>
1783
+		</example>
1784
+	</section>
1785
+
1786
+	<section id="textops.f.str_ifind">
1787
+		<title>
1788
+		<function moreinfo="none">str_ifind(str1, str2)</function>
1789
+		</title>
1790
+		<para>
1791
+			The function returns <emphasis>true</emphasis> (greater than 0) if
1792
+			the str2 string is found in str1, case insensitive comparison.
1793
+		</para>
1794
+		<para>
1795
+		This function can be used from ANY_ROUTE.
1796
+		</para>
1797
+		<example>
1798
+		<title><function>str_ifind</function> usage</title>
1799
+		<programlisting format="linespecific">
1800
+...
1801
+if (str_ifind("$rU", "Alice")) {
1802
+    # do interesting stuff here
1803
+}
1804
+...
1805
+</programlisting>
1806
+		</example>
1807
+	</section>
1808
+
1763 1809
 	<section id="textops.f.set_body_multipart">
1764 1810
 		<title>
1765 1811
 		<function moreinfo="none">set_body_multipart([txt,content_type][,boundary])</function>
Browse code

textops: docs - replaced old project name [skip ci]

Daniel-Constantin Mierla authored on 25/03/2021 10:08:48
Showing 1 changed files
... ...
@@ -302,7 +302,7 @@ search_append_body("[Oo]pen[Ss]er", " SIP Proxy");
302 302
 		<title><function>replace</function> usage</title>
303 303
 		<programlisting format="linespecific">
304 304
 ...
305
-replace("openser", "&kamailio; SIP Proxy");
305
+replace("server", "&kamailio; SIP Proxy");
306 306
 ...
307 307
 </programlisting>
308 308
 		</example>
... ...
@@ -335,7 +335,7 @@ replace("openser", "&kamailio; SIP Proxy");
335 335
 		<title><function>replace_body</function> usage</title>
336 336
 		<programlisting format="linespecific">
337 337
 ...
338
-replace_body("openser", "&kamailio; SIP Proxy");
338
+replace_body("server", "&kamailio; SIP Proxy");
339 339
 ...
340 340
 </programlisting>
341 341
 		</example>
... ...
@@ -399,7 +399,7 @@ replace_hdrs("&kamailio;", "&kamailio; SIP Proxy");
399 399
 		<title><function>replace_all</function> usage</title>
400 400
 		<programlisting format="linespecific">
401 401
 ...
402
-replace_all("openser", "&kamailio; SIP Proxy");
402
+replace_all("server", "&kamailio; SIP Proxy");
403 403
 ...
404 404
 </programlisting>
405 405
 		</example>
... ...
@@ -432,7 +432,7 @@ replace_all("openser", "&kamailio; SIP Proxy");
432 432
 		<title><function>replace_body_all</function> usage</title>
433 433
 		<programlisting format="linespecific">
434 434
 ...
435
-replace_body_all("openser", "&kamailio; SIP Proxy");
435
+replace_body_all("server", "&kamailio; SIP Proxy");
436 436
 ...
437 437
 </programlisting>
438 438
 		</example>
Browse code

textops: docs - note about search() doing posix regex matching

Daniel-Constantin Mierla authored on 03/03/2021 16:49:32
Showing 1 changed files
... ...
@@ -90,6 +90,10 @@ From: medabeda
90 90
 			</para>
91 91
 		</listitem>
92 92
 		</itemizedlist>
93
+		<para>
94
+			Note: it performs Posix regex matching and the 're' parameter
95
+			is compiled with the flags REG_EXTENDED|REG_ICASE|REG_NEWLINE.
96
+		</para>
93 97
 		<para>
94 98
 		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
95 99
 		FAILURE_ROUTE, BRANCH_ROUTE.
Browse code

topos: docs for search_str() function

Daniel-Constantin Mierla authored on 03/03/2021 16:44:46
Showing 1 changed files
... ...
@@ -128,6 +128,42 @@ if ( search("[Ss][Ii][Pp]") ) { /*....*/ };
128 128
 ...
129 129
 if ( search_body("[Ss][Ii][Pp]") ) { /*....*/ };
130 130
 ...
131
+</programlisting>
132
+		</example>
133
+	</section>
134
+
135
+	<section id="textops.f.search_str">
136
+		<title>
137
+		<function moreinfo="none">search_str(text. re)</function>
138
+		</title>
139
+		<para>
140
+		Searches for the re in the body of the message.
141
+		</para>
142
+		<para>Meaning of the parameters is as follows:</para>
143
+		<itemizedlist>
144
+		<listitem>
145
+			<para><emphasis>text</emphasis> - text to perform regex searching
146
+			over it.
147
+			</para>
148
+		</listitem>
149
+		<listitem>
150
+			<para><emphasis>re</emphasis> - regular expression to match over
151
+			the 'text' parameter.
152
+			</para>
153
+		</listitem>
154
+		</itemizedlist>
155
+		<para>
156
+			Both parameters can contain variables.
157
+		</para>
158
+		<para>
159
+		This function can be used from ANY_ROUTE.
160
+		</para>
161
+		<example>
162
+		<title><function>search_str</function> usage</title>
163
+		<programlisting format="linespecific">
164
+...
165
+if ( search_str("$ru", ";transport=tcp") ) { /*....*/ };
166
+...
131 167
 </programlisting>
132 168
 		</example>
133 169
 	</section>
Browse code

textops: docs for ends_with() function

Daniel-Constantin Mierla authored on 06/01/2021 14:34:02
Showing 1 changed files
... ...
@@ -1695,6 +1695,31 @@ if (starts_with("$rU", "+358"))
1695 1695
 		</example>
1696 1696
 	</section>
1697 1697
 
1698
+	<section id="textops.f.ends_with">
1699
+		<title>
1700
+		<function moreinfo="none">ends_with(str1, str2)</function>
1701
+		</title>
1702
+		<para>
1703
+		The function returns <emphasis>true</emphasis> if the first string ends
1704
+		with the second string. The parameters can contain variables.
1705
+		</para>
1706
+		<para>
1707
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
1708
+		FAILURE_ROUTE and BRANCH_ROUTE.
1709
+		</para>
1710
+		<example>
1711
+		<title><function>ends_with</function> usage</title>
1712
+		<programlisting format="linespecific">
1713
+...
1714
+if (ends_with("$rU", "8800"))
1715
+{
1716
+    # do interesting stuff here
1717
+}
1718
+...
1719
+</programlisting>
1720
+		</example>
1721
+	</section>
1722
+
1698 1723
 	<section id="textops.f.set_body_multipart">
1699 1724
 		<title>
1700 1725
 		<function moreinfo="none">set_body_multipart([txt,content_type][,boundary])</function>
Browse code

textops: docs - some enhancements to basic header operations functions

Daniel-Constantin Mierla authored on 26/10/2020 09:53:24
Showing 1 changed files
... ...
@@ -872,13 +872,15 @@ if (has_body("multipart/mixed")) {
872 872
 		<function moreinfo="none">append_to_reply(txt)</function>
873 873
 		</title>
874 874
 		<para>
875
-		Append txt as header to the reply.
875
+		Append txt as header to the reply that is going to be generated by
876
+		&kamailio; (e.g., via sl_send_reply(...)).
876 877
 		</para>
877 878
 		<para>Meaning of the parameters is as follows:</para>
878 879
 		<itemizedlist>
879 880
 		<listitem>
880 881
 			<para><emphasis>txt</emphasis> - String which may contains
881
-			pseudo-variables.
882
+			pseudo-variables. Note that the value has to be ended with "\r\n"
883
+			(end of header characters sequence).
882 884
 			</para>
883 885
 		</listitem>
884 886
 		</itemizedlist>
... ...
@@ -902,15 +904,16 @@ append_to_reply("Foo: $rm at $Ts\r\n");
902 904
 		<function moreinfo="none">append_hf(txt[, hdr])</function>
903 905
 		</title>
904 906
 		<para>
905
-		Appends 'txt' as header after first header field or after
906
-		last 'hdr' header field.
907
+		Appends 'txt' as header at the end of the all headers, or after
908
+		last header named 'hdr' if the second parameter is provided.
907 909
 		</para>
908 910
 		<para>Meaning of the parameters is as follows:</para>
909 911
 		<itemizedlist>
910 912
 		<listitem>
911 913
 			<para><emphasis>txt</emphasis> - Header field to be appended. The
912 914
 			value can contain pseudo-variables which will be replaced at run
913
-			time.
915
+			time. Note that the value has to be ended with "\r\n" (end of header
916
+			characters sequence).
914 917
 			</para>
915 918
 		</listitem>
916 919
 		<listitem>
... ...
@@ -939,15 +942,16 @@ append_hf("From-username: $fU\r\n", "Call-ID");
939 942
 		<function moreinfo="none">insert_hf(txt[, hdr])</function>
940 943
 		</title>
941 944
 		<para>
942
-		Inserts 'txt' as header before the first header field or before
943
-		first 'hdr' header field if 'hdr' is given.
945
+		Inserts 'txt' as header before the first header field, or before
946
+		first header named 'hdr'if the second parameter is provided.
944 947
 		</para>
945 948
 		<para>Meaning of the parameters is as follows:</para>
946 949
 		<itemizedlist>
947 950
 		<listitem>
948 951
 			<para><emphasis>txt</emphasis> - Header field to be inserted. The
949 952
 			value can contain pseudo-variables which will be replaced at run
950
-			time.
953
+			time. Note that the value has to be ended with "\r\n" (end of header
954
+			characters sequence).
951 955
 			</para>
952 956
 		</listitem>
953 957
 		<listitem>
Browse code

textops: docs for functions to remove or test headers with variables

Daniel-Constantin Mierla authored on 28/05/2020 07:46:09
Showing 1 changed files
... ...
@@ -1024,8 +1024,8 @@ append_urihf("CC-Diversion: ", "\r\n");
1024 1024
 		<para>Meaning of the parameters is as follows:</para>
1025 1025
 		<itemizedlist>
1026 1026
 		<listitem>
1027
-			<para><emphasis>hf_name</emphasis> - Header field name.(long or
1028
-			compact form)
1027
+			<para><emphasis>hf_name</emphasis> - Header field name (long or
1028
+			compact form). It can be only a static string value.
1029 1029
 			</para>
1030 1030
 		</listitem>
1031 1031
 		</itemizedlist>
... ...
@@ -1037,7 +1037,25 @@ append_urihf("CC-Diversion: ", "\r\n");
1037 1037
 		<title><function>is_present_hf</function> usage</title>
1038 1038
 		<programlisting format="linespecific">
1039 1039
 ...
1040
-if (is_present_hf("From")) log(1, "From HF Present");
1040
+if (is_present_hf("From")) xlog("From HF Present");
1041
+...
1042
+</programlisting>
1043
+		</example>
1044
+	</section>
1045
+
1046
+	<section id="textops.f.is_present_hf_pv">
1047
+		<title>
1048
+		<function moreinfo="none">is_present_hf_pv(hf_name)</function>
1049
+		</title>
1050
+		<para>
1051
+		Same as is_present_hf() function, but the parameter can contain
1052
+		variables.
1053
+		</para>
1054
+		<example>
1055
+		<title><function>is_present_hf_pv</function> usage</title>
1056
+		<programlisting format="linespecific">
1057
+...
1058
+if (is_present_hf_pv("$var(hname)")) xinfo("Header $var(hname) is present\n");
1041 1059
 ...
1042 1060
 </programlisting>
1043 1061
 		</example>
... ...
@@ -1055,7 +1073,7 @@ if (is_present_hf("From")) log(1, "From HF Present");
1055 1073
 		<itemizedlist>
1056 1074
 		<listitem>
1057 1075
 			<para><emphasis>hf_name_re</emphasis> - Regular expression to
1058
-				match header field name.
1076
+				match header field name. It can be only a static string value.
1059 1077
 			</para>
1060 1078
 		</listitem>
1061 1079
 		</itemizedlist>
... ...
@@ -1067,7 +1085,27 @@ if (is_present_hf("From")) log(1, "From HF Present");
1067 1085
 		<title><function>is_present_hf_re</function> usage</title>
1068 1086
 		<programlisting format="linespecific">
1069 1087
 ...
1070
-if (is_present_hf_re("^P-")) log(1, "There are headers starting with P-\n");
1088
+if (is_present_hf_re("^P-"))
1089
+    xlog("There are headers starting with P-\n");
1090
+...
1091
+</programlisting>
1092
+		</example>
1093
+	</section>
1094
+
1095
+	<section id="textops.f.is_present_hf_re_pv">
1096
+		<title>
1097
+		<function moreinfo="none">is_present_hf_re_pv(hf_name_re)</function>
1098
+		</title>
1099
+		<para>
1100
+		Same as is_present_hf_re() function, but the parameter can contain
1101
+		variables.
1102
+		</para>
1103
+		<example>
1104
+		<title><function>is_present_hf_re_pv</function> usage</title>
1105
+		<programlisting format="linespecific">
1106
+...
1107
+if (is_present_hf_re_pv_("^$var(prefix)"))
1108
+    xlog("There are headers starting with $var(prefix)\n");
1071 1109
 ...
1072 1110
 </programlisting>
1073 1111
 		</example>
... ...
@@ -1255,7 +1293,8 @@ if(is_method("OPTION|UPDATE"))
1255 1293
 		<itemizedlist>
1256 1294
 		<listitem>
1257 1295
 			<para><emphasis>hname</emphasis> - header name to be removed.
1258
-			</para>
1296
+			It can be only a static string (because of the optimizations
1297
+			done at startup to speed up execution at runtime).</para>
1259 1298
 		</listitem>
1260 1299
 		</itemizedlist>
1261 1300
 		<para>
... ...
@@ -1271,9 +1310,26 @@ if(remove_hf("User-Agent"))
1271 1310
     # User Agent header removed
1272 1311
 }
1273 1312
 # compact form: remove "Contact" or "m" header
1274
-remove_hf("Contact")
1313
+remove_hf("Contact");
1275 1314
 # compact form: remove "Contact" or "m" header
1276
-remove_hf("m")
1315
+remove_hf("m");
1316
+...
1317
+</programlisting>
1318
+		</example>
1319
+	</section>
1320
+
1321
+	<section id="textops.f.remove_hf_pv">
1322
+		<title>
1323
+		<function moreinfo="none">remove_hf_pv(hname)</function>
1324
+		</title>
1325
+		<para>
1326
+		Same as remove_hf() function, but the parameter can contain variables.
1327
+		</para>
1328
+		<example>
1329
+		<title><function>remove_hf_pv</function> usage</title>
1330
+		<programlisting format="linespecific">
1331
+...
1332
+remove_hf_pv("$var(hname)");
1277 1333
 ...
1278 1334
 </programlisting>
1279 1335
 		</example>
... ...
@@ -1314,6 +1370,26 @@ if(remove_hf_re("^P-"))
1314 1370
 		</example>
1315 1371
 	</section>
1316 1372
 
1373
+	<section id="textops.f.remove_hf_re_pv">
1374
+		<title>
1375
+		<function moreinfo="none">remove_hf_re_pv(re)</function>
1376
+		</title>
1377
+		<para>
1378
+		Same as remove_hf_re() function, but the parameter can contain variables.
1379
+		</para>
1380
+		<example>
1381
+		<title><function>remove_hf_re_pv</function> usage</title>
1382
+		<programlisting format="linespecific">
1383
+...
1384
+if(remove_hf_re_pv("^$var(prefix)"))
1385
+{
1386
+    # All headers starting with $var(prefix) value removed
1387
+}
1388
+...
1389
+</programlisting>
1390
+		</example>
1391
+	</section>
1392
+
1317 1393
 	<section id="textops.f.remove_hf_exp">
1318 1394
 		<title>
1319 1395
 		<function moreinfo="none">remove_hf_exp(expmatch, expskip)</function>
... ...
@@ -1356,6 +1432,27 @@ if(remove_hf_exp("^P-", "^P-Keep-"))
1356 1432
 		</example>
1357 1433
 	</section>
1358 1434
 
1435
+	<section id="textops.f.remove_hf_exp_pv">
1436
+		<title>
1437
+		<function moreinfo="none">remove_hf_exp_pv(expmatch, expskip)</function>
1438
+		</title>
1439
+		<para>
1440
+		Same as remove_hf_exp() function, but the parameters can contain variabes.
1441
+		</para>
1442
+		<example>
1443
+		<title><function>remove_hf_exp_pv</function> usage</title>
1444
+		<programlisting format="linespecific">
1445
+...
1446
+if(remove_hf_exp_pv("^$var(match)", "^$var(keep)"))
1447
+{
1448
+    # All headers starting with $var(match) value removed,
1449
+    # except the ones starting with $var(keep) value
1450
+}
1451
+...
1452
+</programlisting>
1453
+		</example>
1454
+	</section>
1455
+
1359 1456
 	<section id="textops.f.has_body">
1360 1457
 		<title>
1361 1458
 		<function moreinfo="none">has_body()</function>,
Browse code

textops: docs - proper example for append_body_part() with headers

Daniel-Constantin Mierla authored on 23/01/2020 09:04:23
Showing 1 changed files
... ...
@@ -1725,8 +1725,8 @@ Content-Disposition: signal;handling=required
1725 1725
 		<title><function>append_body_part</function> with headers</title>
1726 1726
 		<programlisting format="linespecific">
1727 1727
 ...
1728
-$var(b) = "<info>active</info>";
1729
-append_body_part("$var(b)", "application/xml\r\nX-Header: xyz");
1728
+$var(b) = "7e Od 04 55 75 69 20 4d 61 6b 65 43 61 6c 6c";
1729
+append_body_part("$var(b)", "application/vnd.cirpack.isdn-ext\r\nX-Header: xyz", "signal;handling=required");
1730 1730
 msg_apply_changes();
1731 1731
 ...
1732 1732
 
... ...
@@ -1734,6 +1734,7 @@ msg_apply_changes();
1734 1734
 
1735 1735
 ...
1736 1736
 Content-Type: application/vnd.cirpack.isdn-ext
1737
+X-Header: xyz
1737 1738
 Content-Disposition: signal;handling=required
1738 1739
 
1739 1740
 7e Od 04 55 75 69 20 4d 61 6b 65 43 61 6c 6c
Browse code

textops: docs for regex_substring()

Daniel-Constantin Mierla authored on 30/11/2018 09:20:23
Showing 1 changed files
... ...
@@ -60,7 +60,7 @@ From: medabeda
60 60
 	<section>
61 61
 		<title>External Libraries or Applications</title>
62 62
 		<para>
63
-		The following libraries or applications must be installed before 
63
+		The following libraries or applications must be installed before
64 64
 		running &kamailio; with this module loaded:
65 65
 			<itemizedlist>
66 66
 			<listitem>
... ...
@@ -91,7 +91,7 @@ From: medabeda
91 91
 		</listitem>
92 92
 		</itemizedlist>
93 93
 		<para>
94
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
94
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
95 95
 		FAILURE_ROUTE, BRANCH_ROUTE.
96 96
 		</para>
97 97
 		<example>
... ...
@@ -119,7 +119,7 @@ if ( search("[Ss][Ii][Pp]") ) { /*....*/ };
119 119
 		</listitem>
120 120
 		</itemizedlist>
121 121
 		<para>
122
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
122
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
123 123
 		FAILURE_ROUTE, BRANCH_ROUTE.
124 124
 		</para>
125 125
 		<example>
... ...
@@ -158,7 +158,7 @@ if ( search_body("[Ss][Ii][Pp]") ) { /*....*/ };
158 158
 		</listitem>
159 159
 		</itemizedlist>
160 160
 		<para>
161
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
161
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
162 162
 		FAILURE_ROUTE, BRANCH_ROUTE.
163 163
 		</para>
164 164
 		<example>
... ...
@@ -190,7 +190,7 @@ if ( search_hf("From", ":test@", "a") ) { /*....*/ };
190 190
 		</listitem>
191 191
 		</itemizedlist>
192 192
 		<para>
193
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
193
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
194 194
 		FAILURE_ROUTE, BRANCH_ROUTE.
195 195
 		</para>
196 196
 		<example>
... ...
@@ -223,7 +223,7 @@ search_append("[Oo]pen[Ss]er", " SIP Proxy");
223 223
 		</listitem>
224 224
 		</itemizedlist>
225 225
 		<para>
226
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
226
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
227 227
 		FAILURE_ROUTE, BRANCH_ROUTE.
228 228
 		</para>
229 229
 		<example>
... ...
@@ -255,7 +255,7 @@ search_append_body("[Oo]pen[Ss]er", " SIP Proxy");
255 255
 		</listitem>
256 256
 		</itemizedlist>
257 257
 		<para>
258
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
258
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
259 259
 		FAILURE_ROUTE, BRANCH_ROUTE.
260 260
 		</para>
261 261
 		<example>
... ...
@@ -288,7 +288,7 @@ replace("openser", "&kamailio; SIP Proxy");
288 288
 		</listitem>
289 289
 		</itemizedlist>
290 290
 		<para>
291
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
291
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
292 292
 		FAILURE_ROUTE, BRANCH_ROUTE.
293 293
 		</para>
294 294
 		<example>
... ...
@@ -352,7 +352,7 @@ replace_hdrs("&kamailio;", "&kamailio; SIP Proxy");
352 352
 		</listitem>
353 353
 		</itemizedlist>
354 354
 		<para>
355
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
355
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
356 356
 		FAILURE_ROUTE, BRANCH_ROUTE.
357 357
 		</para>
358 358
 		<example>
... ...
@@ -385,7 +385,7 @@ replace_all("openser", "&kamailio; SIP Proxy");
385 385
 		</listitem>
386 386
 		</itemizedlist>
387 387
 		<para>
388
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
388
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
389 389
 		FAILURE_ROUTE, BRANCH_ROUTE.
390 390
 		</para>
391 391
 		<example>
... ...
@@ -418,7 +418,7 @@ replace_body_all("openser", "&kamailio; SIP Proxy");
418 418
 		</listitem>
419 419
 		</itemizedlist>
420 420
 		<para>
421
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
421
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
422 422
 		FAILURE_ROUTE, BRANCH_ROUTE.
423 423
 		</para>
424 424
 		<example>
... ...
@@ -556,7 +556,7 @@ replace_hdrs_str("&kamailio;", "&kamailio; SIP Proxy", "a");
556 556
 		<para>Meaning of the parameters is as follows:</para>
557 557
 		<itemizedlist>
558 558
 		<listitem>
559
-			<para><emphasis>'/re/repl/flags'</emphasis> - sed like regular 
559
+			<para><emphasis>'/re/repl/flags'</emphasis> - sed like regular
560 560
 				expression. flags can be a combination of i (case insensitive),
561 561
 				g (global) or s (match newline don't treat it as end of line).
562 562
 			</para>
... ...
@@ -572,7 +572,7 @@ replace_hdrs_str("&kamailio;", "&kamailio; SIP Proxy", "a");
572 572
 		</listitem>
573 573
 		</itemizedlist>
574 574
 		<para>
575
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
575
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
576 576
 		FAILURE_ROUTE, BRANCH_ROUTE.
577 577
 		</para>
578 578
 		<example>
... ...
@@ -601,7 +601,7 @@ if ( subst('/^To:(.*)sip:[^@]*@[a-zA-Z0-9.]+(.*)$/t:\1$avp(sip_address)\2/ig') )
601 601
 		<para>Meaning of the parameters is as follows:</para>
602 602
 		<itemizedlist>
603 603
 		<listitem>
604
-			<para><emphasis>'/re/repl/flags'</emphasis> - sed like regular 
604
+			<para><emphasis>'/re/repl/flags'</emphasis> - sed like regular
605 605
 				expression. flags can be a combination of i (case insensitive),
606 606
 				g (global) or s (match newline don't treat it as end of line).
607 607
 			</para>
... ...
@@ -617,7 +617,7 @@ if ( subst('/^To:(.*)sip:[^@]*@[a-zA-Z0-9.]+(.*)$/t:\1$avp(sip_address)\2/ig') )
617 617
 		</listitem>
618 618
 		</itemizedlist>
619 619
 		<para>
620
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
620
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
621 621
 		FAILURE_ROUTE, BRANCH_ROUTE.
622 622
 		</para>
623 623
 		<example>
... ...
@@ -664,7 +664,7 @@ if (subst_uri('/^sip:([0-9]+)@(.*)$/sip:$avp(uri_prefix)\1@\2;orig_uri=\0/i')){$
664 664
 		</listitem>
665 665
 		</itemizedlist>
666 666
 		<para>
667
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
667
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
668 668
 		FAILURE_ROUTE, BRANCH_ROUTE.
669 669
 		</para>
670 670
 		<example>
... ...
@@ -693,7 +693,7 @@ if (subst_user('/(.*)3642$/$avp(user_prefix)\13642/')){$
693 693
 		<para>Meaning of the parameters is as follows:</para>
694 694
 		<itemizedlist>
695 695
 		<listitem>
696
-			<para><emphasis>'/re/repl/flags'</emphasis> - sed like regular 
696
+			<para><emphasis>'/re/repl/flags'</emphasis> - sed like regular
697 697
 				expression. flags can be a combination of i (case insensitive),
698 698
 				g (global) or s (match newline don't treat it as end of line).
699 699
 			</para>
... ...
@@ -709,7 +709,7 @@ if (subst_user('/(.*)3642$/$avp(user_prefix)\13642/')){$
709 709
 		</listitem>
710 710
 		</itemizedlist>
711 711
 		<para>
712
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
712
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
713 713
 		FAILURE_ROUTE, BRANCH_ROUTE.
714 714
 		</para>
715 715
 		<example>
... ...
@@ -750,7 +750,7 @@ if ( subst_body('/^o=(.*) /o=$fU /') ) {};
750 750
 		</listitem>
751 751
 		</itemizedlist>
752 752
 		<para>
753
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
753
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
754 754
 		FAILURE_ROUTE, BRANCH_ROUTE.
755 755
 		</para>
756 756
 		<example>
... ...
@@ -784,7 +784,7 @@ if ( subst_hf("From", "/:test@/:best@/", "a") ) { /*....*/ };
784 784
 		</listitem>
785 785
 		</itemizedlist>
786 786
 		<para>
787
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
787
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
788 788
 		FAILURE_ROUTE, BRANCH_ROUTE.
789 789
 		</para>
790 790
 		<example>
... ...
@@ -847,7 +847,7 @@ set_reply_body("test", "text/plain");
847 847
 		</listitem>
848 848
 		</itemizedlist>
849 849
 		<para>
850
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
850
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
851 851
 		FAILURE_ROUTE, BRANCH_ROUTE.
852 852
 		</para>
853 853
 		<example>
... ...
@@ -920,7 +920,7 @@ append_to_reply("Foo: $rm at $Ts\r\n");
920 920
 		</listitem>
921 921
 		</itemizedlist>
922 922
 		<para>
923
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
923
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
924 924
 		FAILURE_ROUTE, BRANCH_ROUTE.
925 925
 		</para>
926 926
 		<example>
... ...
@@ -957,7 +957,7 @@ append_hf("From-username: $fU\r\n", "Call-ID");
957 957
 		</listitem>
958 958
 		</itemizedlist>
959 959
 		<para>
960
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
960
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
961 961
 		FAILURE_ROUTE, BRANCH_ROUTE.
962 962
 		</para>
963 963
 		<example>
... ...
@@ -978,24 +978,24 @@ insert_hf("To-username: $tU\r\n", "Call-ID");
978 978
 		<function moreinfo="none">append_urihf(prefix, suffix)</function>
979 979
 		</title>
980 980
 		<para>
981
-		Append header field name with original <acronym>Request-URI</acronym> 
981
+		Append header field name with original <acronym>Request-URI</acronym>
982 982
 		in middle.
983 983
 		</para>
984 984
 		<para>Meaning of the parameters is as follows:</para>
985 985
 		<itemizedlist>
986 986
 		<listitem>
987
-			<para><emphasis>prefix</emphasis> - string (usually at least 
987
+			<para><emphasis>prefix</emphasis> - string (usually at least
988 988
 			header field name).
989 989
 			</para>
990 990
 		</listitem>
991 991
 		<listitem>
992
-			<para><emphasis>suffix</emphasis> - string (usually at least 
992
+			<para><emphasis>suffix</emphasis> - string (usually at least
993 993
 			line terminator).
994 994
 			</para>
995 995
 		</listitem>
996 996
 		</itemizedlist>
997 997
 		<para>
998
-		This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, 
998
+		This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
999 999
 		BRANCH_ROUTE.
1000 1000
 		</para>
1001 1001
 		<example>
... ...
@@ -1024,13 +1024,13 @@ append_urihf("CC-Diversion: ", "\r\n");
1024 1024
 		<para>Meaning of the parameters is as follows:</para>
1025 1025
 		<itemizedlist>
1026 1026
 		<listitem>
1027
-			<para><emphasis>hf_name</emphasis> - Header field name.(long or 
1027
+			<para><emphasis>hf_name</emphasis> - Header field name.(long or
1028 1028
 			compact form)
1029 1029
 			</para>
1030 1030
 		</listitem>
1031 1031
 		</itemizedlist>
1032 1032
 		<para>
1033
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
1033
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
1034 1034
 		FAILURE_ROUTE, BRANCH_ROUTE.
1035 1035
 		</para>
1036 1036
 		<example>
... ...
@@ -1060,7 +1060,7 @@ if (is_present_hf("From")) log(1, "From HF Present");
1060 1060
 		</listitem>
1061 1061
 		</itemizedlist>
1062 1062
 		<para>
1063
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
1063
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
1064 1064
 		FAILURE_ROUTE, BRANCH_ROUTE.
1065 1065
 		</para>
1066 1066
 		<example>
... ...
@@ -1080,7 +1080,7 @@ if (is_present_hf_re("^P-")) log(1, "There are headers starting with P-\n");
1080 1080
 		<para>
1081 1081
 		Adds a time header to the reply of the request. You must use it
1082 1082
 		before functions that are likely to send a reply, e.g., save()
1083
-		from 'registrar' module. Header format is: 
1083
+		from 'registrar' module. Header format is:
1084 1084
 		<quote>Date: %a, %d %b %Y %H:%M:%S GMT</quote>, with the legend:
1085 1085
 		<itemizedlist>
1086 1086
 		<listitem>
... ...
@@ -1117,7 +1117,7 @@ if (is_present_hf_re("^P-")) log(1, "There are headers starting with P-\n");
1117 1117
 		Return true if a header was successfully appended.
1118 1118
 		</para>
1119 1119
 		<para>
1120
-		This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, 
1120
+		This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
1121 1121
 		BRANCH_ROUTE.
1122 1122
 		</para>
1123 1123
 		<example>
... ...
@@ -1135,7 +1135,7 @@ append_time();
1135 1135
 		<function moreinfo="none">append_time_to_request()</function>
1136 1136
 		</title>
1137 1137
 		<para>
1138
-		Adds a time header to the request. Header format is: 
1138
+		Adds a time header to the request. Header format is:
1139 1139
 		<quote>Date: %a, %d %b %Y %H:%M:%S GMT</quote>, with the legend:
1140 1140
 		<itemizedlist>
1141 1141
 		<listitem>
... ...
@@ -1219,7 +1219,7 @@ if(!is_present_hf("Date"))
1219 1219
 		</listitem>
1220 1220
 		</itemizedlist>
1221 1221
 		<para>
1222
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, 
1222
+		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
1223 1223
 		FAILURE_ROUTE, and BRANCH_ROUTE.
1224 1224
 		</para>
1225 1225
 		<example>
... ...
@@ -1244,7 +1244,7 @@ if(is_method("OPTION|UPDATE"))
1244 1244
 		<function moreinfo="none">remove_hf(hname)</function>
1245 1245
 		</title>
1246 1246
 		<para>
1247
-		Remove from message all headers with name <quote>hname</quote>. 
1247
+		Remove from message all headers with name <quote>hname</quote>.
1248 1248
 		Header matching is case-insensitive. Matches and removes also
1249 1249
 		the compact header forms.
1250 1250
 		</para>
... ...
@@ -1259,7 +1259,7 @@ if(is_method("OPTION|UPDATE"))
1259 1259
 		</listitem>
1260 1260
 		</itemizedlist>
1261 1261
 		<para>
1262
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,