User Tools

Site Tools


cookbooks:devel:transformations

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
cookbooks:devel:transformations [2021/02/15 09:32]
miconda [{s.count,c}]
cookbooks:devel:transformations [2021/06/25 11:05]
miconda [{s.rbefore,x}]
Line 1: Line 1:
 ====== Transformations ====== ====== Transformations ======
  
-Version: Kamailio SIP Server v5.5.x (devel)+Version: Kamailio SIP Server v5.6.x (devel)
  
 <code> <code>
Line 381: Line 381:
 ==== {s.after,x} ==== ==== {s.after,x} ====
  
-Return the part of the string after the character **x**. If the character **x** is not found, it returns empty string.+Return the part of the string after the character **x** searched from the start of the value. If the character **x** is not found, it returns empty string.
  
 <code c> <code c>
Line 388: Line 388:
 </code> </code>
  
 +==== {s.rafter,x} ====
 +
 +Return the part of the string after the character **x** searched from the end of the value. If the character **x** is not found, it returns empty string.
 +
 +<code c>
 +"abcdefcgh"{s.rafter,c}
 +# will return "gh"
 +</code>
 ==== {s.before,x} ==== ==== {s.before,x} ====
  
-Return the part of the string before the character **x**. If the character **x** is not found, it returns the entire input string.+Return the part of the string before the character **x** searched from the start of the value. If the character **x** is not found, it returns the entire input string.
  
 <code c> <code c>
 "abcdef"{s.before,c} "abcdef"{s.before,c}
 # will return "ab" # will return "ab"
 +</code>
 +
 +==== {s.rbefore,x} ====
 +
 +Return the part of the string before the character **x** searched from the end of the value. If the character **x** is not found, it returns the entire input string.
 +
 +<code c>
 +"abcdefcgh"{s.rbefore,c}
 +# will return "abcdef"
 +</code>
 +
 +==== {s.fmtlines,n,m} ====
 +
 +Format the value in lines of n characters, adding m spaces to the start of each new line (not to first line). Each line is ended with "\r\n" apart of last line.
 +
 +<code c>
 +"abcdefgh"{s.fmtlines,4,2}
 +</code>
 +
 +==== {s.fmtlinet,n,m} ====
 +
 +Format the value in lines of n characters, adding m tabs to the start of each new line (not to first line). Each line is ended with "\r\n" apart of last line.
 +
 +<code c>
 +"abcdefgh"{s.fmtlinet,4,2}
 </code> </code>
 ==== {s.urlencode.param} ==== ==== {s.urlencode.param} ====
Line 530: Line 563:
 <code> <code>
 "a=1;b=2;c=3"{param.value,c} = "3" "a=1;b=2;c=3"{param.value,c} = "3"
 +</code>
 +
 +'name' can be a pseudo-variable
 +
 +'delimiter' allows you to specify a single character to use as the parameter delimiter. For example, when parsing HTTP URL query strings use '&'.
 +
 +==== {param.in,name[,delimiter]} ====
 +
 +Return 1 if the parameter 'name' is found in parameters list, 0 if not found.
 +
 +Example:
 +<code>
 +"a=1;b=2;c=3"{param.in,c} = 1
 </code> </code>
  
Line 648: Line 694:
 ==== {line.at,pos} ==== ==== {line.at,pos} ====
  
-Return the line at position 'pos'. The index start from 0. Negative position can be used to count from last line (which is -1).+Return the line at position 'pos'. The index start from 0. Negative position can be used to count from last line (which is -1). The pos can be also a variable holding the index value.
  
 Example: Example:
Line 830: Line 876:
 $var(Custom-Data) = $(rb{json.parse,Custom-Data}); $var(Custom-Data) = $(rb{json.parse,Custom-Data});
  
 +</code>
 +
 +===== URI Alias Transformations =====
 +
 +Transformations related to URI alias values (**addr~port~protoid**).
 +
 +==== {urialias.encode} ====
 +
 +Encode SIP URI to alias value.
 +
 +<code c>
 +"sip:127.0.0.1:5060;transport=udp"{urialias.encode} => "127.0.0.1~5060~1"
 +</code>
 +
 +==== {urialias.decode} ====
 +
 +Decode from alias value to SIP URI.
 +
 +<code c>
 +"127.0.0.1~5060~1"{urialias.decode} => "sip:127.0.0.1:5060;transport=udp"
 </code> </code>
  
cookbooks/devel/transformations.txt ยท Last modified: 2022/04/08 18:08 by miconda