[OpenSIPS-Devel] How to pass a pseudo-variable, AVP or string to a function

Iñaki Baz Castillo ibc at aliax.net
Sat Dec 27 13:59:30 CET 2008


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;
}


-- 
Iñaki Baz Castillo
<ibc at aliax.net>


More information about the Devel mailing list