[SR-Dev] git:sip-router: mod if: more prototypes and defines

Andrei Pelinescu-Onciul andrei at iptel.org
Thu Nov 20 17:46:33 CET 2008


On Nov 19, 2008 at 00:26, Andrei Pelinescu-Onciul <andrei at iptel.org> wrote:
[...]
> 
> mod if: more prototypes and defines
> 
> - prototypes for module (cmd_function) with 3, 4, 5, 6 and
>   variable number of parameters added. The 3-6 versions just extend the
>   old version with more char* parameters and are kamailio compatible.
>   The variable number of parameters function is something new and
>   experimental. It takes the sip_msg, the number of extra parameters
>   and an array of action_u_t values (the internal routing engine
>   parameters representation).
> 
> - added a magic value for the parameters numbers, to be used by
>   variable parameter functions (VAR_PARAM_NO)
> 
> - moved/added the NO_SCRIPT macro (parameters number magic value for
>   functions that should not be called from the script) from tm.

Example for a variable number of parameters function:

static cmd_export_t cmds[]={
    {"print", print_f_0, 0, 0, REQUEST_ROUTE},   // overload test
    {"print", print_f_1, 1, print_fixup_f_1, REQUEST_ROUTE},
    {"print", print_f_2, 2, print_fixup_f_2, REQUEST_ROUTE},
    {"print", (cmd_function)print_f_var, VAR_PARAM_NO, 0,  REQUEST_ROUTE},
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    {0, 0, 0, 0, 0}
};

...

static int print_f_var(struct sip_msg* msg, int no, action_u_t* vals)
{
    int r;
    for (r=0; r<no; r++)
        printf("%s", vals[r].u.string);
    printf("\n");
    return 1;
}

You can have fixups too, I omitted them for simplicity.

Andrei



More information about the sr-dev mailing list