Hi, I want to improve the regex module by allowing that the function
pcre_match_group() accepts a pseudo variable as second argument, to
get something like this:
$avp(i:11) = 111;
if pcre_match_group("$rU","$avp(i:11)")
...
So I'm modifying regex_mod.c:
- Before:
{ "pcre_match_group", (cmd_function)w_pcre_match_group, 2, fixup_spve_uint,
0,
REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE }
- Now:
{ "pcre_match_group", (cmd_function)w_pcre_match_group, 2, fixup_spve_spve,
0,
REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE }
Then in the function code I do (just the additions):
-------------------------------------------------------------------------
static int w_pcre_match_group(struct sip_msg* _msg, char* _s1, char* _s2)
{
str group;
if (_s2 == NULL) {
num_pcre = 0;
} else {
if (fixup_get_svalue(_msg, (gparam_p)_s2, &group))
{
LM_ERR("cannot print the format for second param\n");
return -5;
}
num_pcre = (int)(long)group.s;
LM_INFO("***debugging*** group.s = <%s> - group.len = <%i> -
num_pcre = <%i>\n", group.s, group.len, num_pcre);
}
------------------------------------------------------------------------
With the above example:
$avp(i:11) = 111;
if pcre_match_group("$rU","$avp(i:11)")
I get the following wrong outpu (num_pcre should be 111):
INFO:regex:w_pcre_match_group: ***debugging*** group.s = <111> -
group.len = <3> - num_pcre = <7198368>
So, how to convert group.s into an integer? Thanks a lot for any help.
PS: I'm coding it in Kamailio 1.5.
--
Iñaki Baz Castillo
<ibc(a)aliax.net>