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

-- 
Daniel-Constantin Mierla (@ asipto.com)
twitter.com/miconda -- linkedin.com/in/miconda
Kamailio Consultancy, Training and Development Services -- asipto.com
Kamailio Advanced Training, February 20-22, 2024 -- asipto.com
Kamailio World Conference, April 18-19, 2024, Berlin -- kamailioworld.com
_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to