[sr-dev] question about module function arguments

Juha Heinanen jh at tutpro.com
Mon Oct 11 13:47:31 CEST 2010


andrei,

thanks for your explanation regarding module function params.  this
looks to be the way to go when there is variable number of args and some
of them are strings and some are pvars:

> I you want variable number of parameters, the module function
> declaration should look like:
>     {"foov", (cmd_function)foo_var, VAR_PARAM_NO, 0, 0,  REQUEST_ROUTE}
> 
> static int foo_var(struct sip_msg* msg, int argc, action_u_t argv[])
> {
>     int i;
>     for (i = 0; i < argc; i++)
>         do_something(argv[i].u.string);
>     return 1;
> }

since there is no way to specify max number of params, argc value needs
to be tested in the function.  also, if some params are integers, int
values need to be obtained by converting them from digit strings.

-- juha



More information about the sr-dev mailing list