[OpenSIPS-Devel] How to pass a pseudo-variable, AVP or string to a function
Bogdan-Andrei Iancu
bogdan at voice-system.ro
Fri Jan 9 11:09:32 CET 2009
Hi Iñaki,
Everything is clear, or do you still need some help :) ?
Regards,
Bogdan
Iñaki Baz Castillo wrote:
> 2008/12/27 Iñaki Baz Castillo <ibc at aliax.net>:
>
>> Hi, could some developer show me how to use a pseudo-variable, AVP or
>> string as a parameter for a module function?
>> I'm reading the code of many functions receiving one parameter
>> (string, pv or AVP) and all of them are different.
>>
>> I just want to get the string value (so ended in '\0') passed as
>> parameter to the function in the opensips config file. Any tip
>> please? Thanks.
>>
>
> Well, I think I've already got it by copying some functions of "rr" module:
>
> int my_function(struct sip_msg *msg, char *key, char *foo)
> {
> str s;
>
> if (pv_printf_s(msg, (pv_elem_t*)key, &s)<0) {
> LM_ERR("failed to print the format\n");
> return -1;
> }
>
> # do something with s.s
> }
>
> static int it_list_fixup(void** param, int param_no)
> {
> pv_elem_t *model;
> str s;
> if(*param)
> {
> s.s = (char*)(*param); s.len = strlen(s.s);
> if(pv_parse_format(&s, &model)<0)
> {
> LM_ERR("wrong format[%s]\n",(char*)(*param));
> return E_UNSPEC;
> }
> *param = (void*)model;
> }
> return 0;
> }
>
>
>
More information about the Devel
mailing list