[sr-dev] [kamailio/kamailio] Using undefined environmental variables with #!defenv (Issue #2967)

Ben Kaufman notifications at github.com
Wed Dec 8 17:28:53 CET 2021


### Description

Currently, an undefined environmental variable with `#!defenv` results in Kamailio failing to start.  The proposal  here that if the environmental variable is not defined, then the macro value would be undefined as well.  For example:

```
!#KAMAILIO
loadmodule "xlog"
loadmodule "pv"

#!defenv FOO

request_route {
    #!ifdef FOO
        xlog("L_INFO","Environmental variable $$FOO is set\n");
    #!else
        xlog("L_WARN","Environmental variable $$FOO is NOT set\n");
    #!endif
    forward();
}
```

Currently this configuration will fail to load if environmental variable is not set.  My proposal is to either allow `#!envdef` to accept an undefined environmental variable and have the preprocessor macro undefined, or to add a new keyword (`#!envdefn` perhaps?) to allow this behavior.


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2967
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20211208/81e09f7e/attachment.htm>


More information about the sr-dev mailing list