[SR-Users] New feature: #!ifexp - conditional preprocessor blocks

Daniel-Constantin Mierla miconda at gmail.com
Thu Sep 15 11:37:15 CEST 2022


Hello,

a new feature has landed to Kamailio devel version, bringing in more
flexibility for preprocessing of the kamailio.cfg file.

It is about #!ifexp, which allows to evaluate an expression created with
defined IDs, string and number values. Based on evaluation result, being
true or false, parts of the config file can be enabled or disabled.

An extensive number of operators can be used in expressions, such as: +,
-, *, /, ==, !=, <, >, <=, >=, ||, &&, etc. The evaluation is done using
snexpr (https://github.com/miconda/snexpr), which was embedded inside
Kamailio code.

Here are some simple kamailio.cfg examples:

#!ifexp KAMAILIO_VERSION >= 5006000
loadmodule "tlsa.so"
#!else
loadmodule "tls.so"
#!endif

#!ifexp MOD_xlog && (OS_NAME == "darwin")
xlog("running on MacOS\n");
#!endif

Documentation and more examples can be found on the wiki portal at:

  - https://www.kamailio.org/wikidocs/cookbooks/devel/core/#ifexp

Testing would be appreciated, feedback can be addressed to sr-users
mailing list!

Cheers,
Daniel

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda




More information about the sr-users mailing list