[OpenSIPS-Users] Evaluate script variable before calling module function

Liviu Chircu liviu at opensips.org
Mon Jan 21 14:41:04 CET 2013


Hello Douglas,

If you want the parameter to be a pseudo-variable only, you should:
- parse the '$...' string in the fixup phase with pv_parse_spec(...)
- get the spec value at runtime with pv_get_spec_value(...)

If you want the parameter to be either string or pv, you should:
- parse the string at fixup with the generic fixup_sgp(...) function
- get the generic parameter value at runtime with fixup_get_svalue(...) 
function

Regards,

Liviu Chircu
OpenSIPS dev
http://www.opensips-solutions.com

On 01/21/2013 03:30 PM, Douglas Lopes Pereira wrote:
> Hi all,
>
> I've been using opensips for a while now and trying to modify a module 
> function to receive a string contained in the script variable.
>
> Unfortunatelly when I try to print the variable content from inside 
> the module it prints the variable name.
>
> This is the call from opensips.cfg:
> myFunction("anyString", "anyOtherString", "$var(server_name)");
>
> This is myFunction signature and export (I believe I don't need a fixup):
> static int myFunction(struct sip_msg *msg, char *str1, char *str2, 
> char *component);
> ...
> {"myFunction",  (cmd_function)myFunction, 3, 0, 0,
> REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE|STARTUP_ROUTE|TIMER_ROUTE},
> ...
>
> That is the function:
>
> static int
> dns_resolvemyFunctiondomain(struct sip_msg *msg, char *str1, char 
> *str2, char *component)
> {
> ...
>     LM_ERR("D5S1 %s", component);
> ...
> }
>
> And the output:
>
> D5S1 $var(server_name)
>
> I've tried to remove the double quote but opensips won't start.
>
> Can you please help me? I've already searched the webpage and watched 
> some of the Devel Course Videos but wasn't able to find an answer.
>
> Thanks in advance.
>
> Regards,
> Douglas
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20130121/ebda8b2b/attachment.htm>


More information about the Users mailing list