cookbooks:devel:transformations
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
cookbooks:devel:transformations [2020/08/31 10:17] – [{uri.suri}] miconda | cookbooks:devel:transformations [2022/04/08 16:08] (current) – [URI Alias Transformations] miconda | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Transformations ====== | ====== Transformations ====== | ||
- | Version: Kamailio SIP Server v5.5.x (devel) | + | Version: Kamailio SIP Server v5.6.x (devel) |
< | < | ||
Line 375: | Line 375: | ||
<code c> | <code c> | ||
- | abababa" | + | "abababa" |
# will return 4 | # will return 4 | ||
</ | </ | ||
+ | ==== {s.after,x} ==== | ||
+ | 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> | ||
+ | " | ||
+ | # will return " | ||
+ | </ | ||
+ | |||
+ | ==== {s.rafter, | ||
+ | |||
+ | 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> | ||
+ | " | ||
+ | # will return " | ||
+ | </ | ||
+ | ==== {s.before, | ||
+ | |||
+ | 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> | ||
+ | " | ||
+ | # will return " | ||
+ | </ | ||
+ | |||
+ | ==== {s.rbefore, | ||
+ | |||
+ | 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> | ||
+ | " | ||
+ | # will return " | ||
+ | </ | ||
+ | |||
+ | ==== {s.fmtlines, | ||
+ | |||
+ | 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 " | ||
+ | |||
+ | <code c> | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | ==== {s.fmtlinet, | ||
+ | |||
+ | 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 " | ||
+ | |||
+ | <code c> | ||
+ | " | ||
+ | </ | ||
==== {s.urlencode.param} ==== | ==== {s.urlencode.param} ==== | ||
Line 514: | Line 563: | ||
< | < | ||
" | " | ||
+ | </ | ||
+ | |||
+ | ' | ||
+ | |||
+ | ' | ||
+ | |||
+ | ==== {param.in, | ||
+ | |||
+ | Return 1 if the parameter ' | ||
+ | |||
+ | Example: | ||
+ | < | ||
+ | " | ||
</ | </ | ||
Line 632: | Line 694: | ||
==== {line.at, | ==== {line.at, | ||
- | Return the line at position ' | + | Return the line at position ' |
Example: | Example: | ||
Line 816: | Line 878: | ||
</ | </ | ||
+ | ===== Socket Address Transformations ===== | ||
+ | |||
+ | Transformations related to socket address values (**proto: | ||
+ | |||
+ | ==== {sock.host} ==== | ||
+ | |||
+ | Return the host part. | ||
+ | |||
+ | ==== {sock.port} ==== | ||
+ | |||
+ | Return the port part. | ||
+ | |||
+ | ==== {sock.proto} ==== | ||
+ | |||
+ | Return the proto part. | ||
+ | |||
+ | ==== {sock.touri} ==== | ||
+ | |||
+ | Return the socket address converted to SIP URI: **sip: | ||
+ | |||
+ | ===== URI Alias Transformations ===== | ||
+ | |||
+ | Transformations related to URI alias values (**addr~port~protoid**). | ||
+ | |||
+ | ==== {urialias.encode} ==== | ||
+ | |||
+ | Encode SIP URI to alias value. | ||
+ | |||
+ | <code c> | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | ==== {urialias.decode} ==== | ||
+ | |||
+ | Decode from alias value to SIP URI. | ||
+ | |||
+ | <code c> | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | ===== Value Transformations | ||
+ | |||
+ | Exported by **pv** module. | ||
+ | |||
+ | ==== {val.json} ==== | ||
+ | |||
+ | If value is $null, return empty string; if value is string, then it is escaped for use as json value (without surrounding quotes. | ||
+ | |||
+ | <code c> | ||
+ | $var(x) = '" | ||
+ | $(var(x){val.json}) => \" | ||
+ | </ | ||
+ | |||
+ | ==== {val.n0} ==== | ||
+ | |||
+ | Return integer 0 for values that are $null. | ||
+ | |||
+ | <code c> | ||
+ | $sht(a=> | ||
+ | $(sht(a=> | ||
+ | </ | ||
+ | |||
+ | ==== {val.ne} ==== | ||
+ | |||
+ | Return empty string for values that are $null. | ||
+ | |||
+ | <code c> | ||
+ | $sht(a=> | ||
+ | # $(sht(a=> | ||
+ | </ | ||
+ | |||
+ | ==== {val.jsonqe} ==== | ||
+ | |||
+ | If value is $null, return quoted empty string; if value is string, then it is escaped for use as json value already with surrounding quotes; if the value is int, then it is preserved as it is. | ||
+ | |||
+ | <code c> | ||
+ | $var(x) = '" | ||
+ | $(var(x){val.jsonqe}) => " | ||
+ | </ |
cookbooks/devel/transformations.1598869064.txt.gz · Last modified: 2020/08/31 10:17 by miconda