[SR-Users] New feature: #defexp -preprocessor define with expression

Daniel-Constantin Mierla miconda at gmail.com
Thu Sep 29 11:04:22 CEST 2022


following the recent new feature of #!ifexp based on snexpr
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
#!define PORT 5060
#!defexp SIPURI "sip:" + IPADDR + ":" + PORT

The result is that SIPURI is defined to sip:

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:”.

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!


Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - Online
  Nov 7-10, 2022 (Europe Timezone)
  * https://www.asipto.com/sw/kamailio-advanced-training-online/

More information about the sr-users mailing list