Hello,
following the recent new feature of #!ifexp based on snexpr (https://www.kamailio.org/w/2022/09/ifexp-conditional-preprocessor-blocks/), another preprocessor directive was added which allows defining IDs with a value computed from the evaluation of an expression, respectively:
#!defexp ID EXP
The EXP can be any expression supported by snexpr, including the previously defined IDs. For example:
#!define IPADDR 1.2.3.4 #!define PORT 5060 #!defexp SIPURI "sip:" + IPADDR + ":" + PORT
The result is that SIPURI is defined to sip:1.2.3.4:5060.
Another variant is available as #!defexps, which encloses the result of the expression in double quotes, making it suitable to be used further as string value:
#!defexps SIPURI "sip:" + IPADDR + ":" + PORT
The result is that SIPURI is defined to “sip:1.2.3.4:5060”.
More details at:
- https://www.kamailio.org/wikidocs/cookbooks/devel/core/#defexp - https://www.kamailio.org/wikidocs/cookbooks/devel/core/#defexps
Testing would be appreciated, feedback can be addressed to sr-users mailing list!
Cheers, Daniel