Hello dear developers! I'm developing a module that can have several sets of similar connections. I see that some modules allow specifying a sequence of settings in one parameter through the symbol ";", as sample:
modparam("htable", "htable", "customer=>size=8;dbtable=customer;cols='dids,description';coldelim=';'")
or my example:
modparam("module", "module", "connection=>alice;id=aliceid;password=alicepwd;timeout=60;param=123") modparam("module", "module", "connection=>bob;id=bobid;password=bobpwd;timeout=90;param=456")
I don't find it user friendly. Can I offer users blocks with settings that should start with some parameter, for example "connection", as in the example:
modparam("module", "connection", "alice") # first block of settings modparam("module", "id", "aliceid") modparam("module", "password", "alicepwd") modparam("module", "timeout", 60) modparam("module", "param", 123)
modparam("module", "connection", "bob") # second block of settings modparam("module", "id", "bobid") modparam("module", "password", "bobpwd") modparam("module", "timeout", 90) modparam("module", "param", 456)
modparam("module", "connection", "john") # third block of settings ...
If you think that this is not compatible with the kamailio configuration ideology, I will give up my idea :)
Hello,
of course, everything is possible to program somehow given enough effort. But your format would be difficult to support in Kamailio and in my opinion also quite sensitive to user failures.
Usually, Kamailio modules use the simple way of one assigning cfg parameter, or using a parsing helper symbol as shown in the htable example.
If there is a need for a more complex configuration, usually modules support a dedicated configuration file that provides more flexibility, like tls or dispatcher modules.
Cheers,
Henning
-- Henning Westerholt – https://skalatan.de/blog/ Kamailio services – https://gilawa.comhttps://gilawa.com/
From: Вадим С via sr-dev sr-dev@lists.kamailio.org Sent: Montag, 29. Januar 2024 17:35 To: sr-dev@lists.kamailio.org Cc: Вадим С vadim.saranov@gmail.com Subject: [sr-dev] Format of settings sets in config.
Hello dear developers! I'm developing a module that can have several sets of similar connections. I see that some modules allow specifying a sequence of settings in one parameter through the symbol ";", as sample: modparam("htable", "htable", "customer=>size=8;dbtable=customer;cols='dids,description';coldelim=';'") or my example:
modparam("module", "module", "connection=>alice;id=aliceid;password=alicepwd;timeout=60;param=123") modparam("module", "module", "connection=>bob;id=bobid;password=bobpwd;timeout=90;param=456") I don't find it user friendly. Can I offer users blocks with settings that should start with some parameter, for example "connection", as in the example: modparam("module", "connection", "alice") # first block of settings modparam("module", "id", "aliceid") modparam("module", "password", "alicepwd") modparam("module", "timeout", 60) modparam("module", "param", 123)
modparam("module", "connection", "bob") # second block of settings modparam("module", "id", "bobid") modparam("module", "password", "bobpwd") modparam("module", "timeout", 90) modparam("module", "param", 456)
modparam("module", "connection", "john") # third block of settings ...
If you think that this is not compatible with the kamailio configuration ideology, I will give up my idea :)
Hello,
On 29.01.24 17:35, Вадим С via sr-dev wrote:
Hello dear developers! I'm developing a module that can have several sets of similar connections. I see that some modules allow specifying a sequence of settings in one parameter through the symbol ";", as sample:
modparam("htable", "htable", "customer=>size=8;dbtable=customer;cols='dids,description';coldelim=';'")
or my example:
modparam("module", "module", "connection=>alice;id=aliceid;password=alicepwd;timeout=60;param=123") modparam("module", "module", "connection=>bob;id=bobid;password=bobpwd;timeout=90;param=456")
I don't find it user friendly. Can I offer users blocks with settings that should start with some parameter, for example "connection", as in the example:
modparam("module", "connection", "alice") # first block of settings modparam("module", "id", "aliceid") modparam("module", "password", "alicepwd") modparam("module", "timeout", 60) modparam("module", "param", 123)
modparam("module", "connection", "bob") # second block of settings modparam("module", "id", "bobid") modparam("module", "password", "bobpwd") modparam("module", "timeout", 90) modparam("module", "param", 456)
modparam("module", "connection", "john") # third block of settings ...
If you think that this is not compatible with the kamailio configuration ideology, I will give up my idea :)
it is feasible and not that complex, imo.
You have to define each of these parameters to be handled via functions (like done for htable param of htable module) and when a "connection" param function handler is executed you create a new structure (in a list or so) where to store its value in a specific field and follow up handlers executions for "id", "password", ... store in the same structure.
Afterwards, you can do further sanity checks in mod init function to see if some fields are missing (at least for last structure, previous ones can be also checked when a new is created).
Cheers, Daniel
I did so, but there was a doubt that you might not approve such a format when checking PR.