I added two functions to master branch that should provide this
functionality, with the commit:
*
Thanks guys for your inputs, indeed get_def works fine
for a define with a value, but for a define like:
#!define WITH_PRESENCE
these python kemi calls:
KSR.kx.get_def(“ WITH_PRESENCE”)
KSR.kx.get_def(“NOT_DEFINED”)
return the same output (empty string), so I can’t distinguish if a define is present or
not (the same happens if I use get_defn).
Looking at the code it seems it’s not too difficult to add a get_defined kemi function
that return a boolean value to get if a define is present or not.
What do you think? I could send a patch it if you think it’s useful.
Best,
Riccardo
Il giorno 13 lug 2021, alle ore 09:21,
Daniel-Constantin Mierla <miconda(a)gmail.com> ha scritto:
Thanks for correcting my answer, I failed to notice it was about kemi scripts.
For kemi there is the option of KSR.kx.get_def("ID") to get the value of a
define, like:
#!define ID ABC
then KSR.kx.get_def("ID") return "ABC".
To see if a module is loaded, at least in lua you can check if KSR.modname (e.g.,:
KSR.tm) is set or not.
Cheers,
Daniel
On 13.07.21 09:09, Yuriy Gorlichenko wrote:
#define is a directive for the cfg scripting. So
you won't be able to reach this definition from Lua/python/etc AFAIK.
But there are at least 2 possibilities how to achieve this:
1 - define global variables/constants in your script instead of #define.
It will be visible across all namespace of your script.
2 - use pv modparap setvar. Once you done #define put it into variable on a modparam
stage via this param. Then you can access those vars via kemi.
On Tue, 13 Jul 2021, 08:55 Daniel-Constantin Mierla, <miconda(a)gmail.com> wrote:
Hello,
if you have:
#!define X
then you can have conditional blocks like:
#!ifdef X
#endif
or:
#!ifndef X
#endif
Or, are you looking for something else?
Cheers,
Daniel
On 12.07.21 14:17, Riccardo Villa wrote:
Hello guys,
do you know if it’s possible for a kemi script to know if a name is defined (with
#!define) in kamailio.cfg? It would be useful to modify kemi script logic depending on
feature/module presence.
Thanks in advance for your help.
Regards,
Riccardo
--
--
NOTICE: This electronic mail transmission may contain confidential
information and is intended only for the person(s) named. Any use, copying,
or disclosure by any other person is strictly prohibited. If you have
received this transmission in error, please notify the sender via e-mail.
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
* sr-users(a)lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
*
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users --
Daniel-Constantin Mierla --
www.asipto.com
www.twitter.com/miconda --
www.linkedin.com/in/miconda
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
* sr-users(a)lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
*
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users --
Daniel-Constantin Mierla --
www.asipto.com
www.twitter.com/miconda --
www.linkedin.com/in/miconda
--
--
NOTICE: This electronic mail transmission may contain confidential
information and is intended only for the person(s) named. Any use, copying,
or disclosure by any other person is strictly prohibited. If you have
received this transmission in error, please notify the sender via e-mail.