i tried to embed a PV in regex transformation, but didn't get desired result. is it possible or must regex only contain strings.
here is an example, where the idea is to strip string "456" from the end of string "123456":
$var(test) = "123456"; $var(rest) = "456"; $var(test) = $(var(test){re.subst,/^(.*)$var(rest)$/\1/}); xlog("result is $var(test)\n");
unfortunately, the result is 0 rather than "123".
i also tried
$var(test) = $(var(test){re.subst,/^(.*)$var(rest)$/\1/});
and
$var(test) = $(var(test){re.subst,/^(.*)$(var(rest))$/\1/});
but still 0.
-- juha
Hello,
On 4/12/10 6:14 PM, Juha Heinanen wrote:
i tried to embed a PV in regex transformation, but didn't get desired result. is it possible or must regex only contain strings.
it supports only strings. The subst expression is pre-compiled at startup.
Some development is required to extend for what you want.
Cheers, Daniel
here is an example, where the idea is to strip string "456" from the end of string "123456":
$var(test) = "123456"; $var(rest) = "456"; $var(test) = $(var(test){re.subst,/^(.*)$var(rest)$/\1/}); xlog("result is $var(test)\n");
unfortunately, the result is 0 rather than "123".
i also tried
$var(test) = $(var(test){re.subst,/^(.*)$var(rest)$/\1/});
and
$var(test) = $(var(test){re.subst,/^(.*)$(var(rest))$/\1/});
but still 0.
-- juha
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On 4/12/10 7:59 PM, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
it supports only strings. The subst expression is pre-compiled at startup.
Some development is required to extend for what you want.
daniel,
no problem, i was able to achieve what i want using s.len and s.substr transformations.
ok, which reminds me that I wanted to add transformations for strip and strip_tail for the sake of cfg easiness...
Cheers, Daniel
-- juha
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Daniel-Constantin Mierla writes:
ok, which reminds me that I wanted to add transformations for strip and strip_tail for the sake of cfg easiness...
those would would make my expression much simpler. there is now some core functions like those that operate on $tu and once the functions you mention are available, we could remove the corresponding core functions.
-- juha
On 4/12/10 8:09 PM, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
ok, which reminds me that I wanted to add transformations for strip and strip_tail for the sake of cfg easiness...
those would would make my expression much simpler.
yes, i want them for same reason.
there is now some core functions like those that operate on $tu and once the functions you mention are available, we could remove the corresponding core functions.
i guess you wanted to say operate on $ru - strip() and strip_tail() functions - indeed there are some core functions, removing might not be easy since some people may want them for backward compatibility or simplicity, but moving several "no-longer-often-used" core functions to a module would be good.
Cheers, Daniel
Daniel-Constantin Mierla writes:
i guess you wanted to say operate on $ru - strip() and strip_tail() functions - indeed there are some core functions, removing might not be easy since some people may want them for backward compatibility or simplicity, but moving several "no-longer-often-used" core functions to a module would be good.
in my opinion, we should remove old $ru specific functions, when more general solutions become available. it is not a big deal to make the changes in the script.
-- juha
On 4/12/10 8:37 PM, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
i guess you wanted to say operate on $ru - strip() and strip_tail() functions - indeed there are some core functions, removing might not be easy since some people may want them for backward compatibility or simplicity, but moving several "no-longer-often-used" core functions to a module would be good.
in my opinion, we should remove old $ru specific functions, when more general solutions become available. it is not a big deal to make the changes in the script.
for me won't be a big deal, but there are people not using PVs yet. Also, many docs refer to them (i am not saying strictly about this one), would need be cleaned up.
Cheers, Daniel
On 4/12/10 8:04 PM, Daniel-Constantin Mierla wrote:
On 4/12/10 7:59 PM, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
it supports only strings. The subst expression is pre-compiled at
startup.
Some development is required to extend for what you want.
daniel,
no problem, i was able to achieve what i want using s.len and s.substr transformations.
ok, which reminds me that I wanted to add transformations for strip and strip_tail for the sake of cfg easiness...
I just committed s.strip and s.striptail transformations: http://sip-router.org/wiki/cookbooks/transformations/devel#sstrip_len
Testing and feedback is appreciated.
Thanks, Daniel
Cheers, Daniel
-- juha
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Daniel-Constantin Mierla writes:
I just committed s.strip and s.striptail transformations: http://sip-router.org/wiki/cookbooks/transformations/devel#sstrip_len
Testing and feedback is appreciated.
daniel,
i got core dump. most like from this statement:
$rU = $(var(unescaped_user){s.strip,4});
-- juha
Program terminated with signal 11, Segmentation fault. #0 pv_set_ruri_user (msg=0x8449dd0, param=0x82e5528, op=254, val=0xbfc03590) at pv_core.c:1740 1740 val->rs.s[val->rs.len] = '\0'; (gdb) where #0 pv_set_ruri_user (msg=0x8449dd0, param=0x82e5528, op=254, val=0xbfc03590) at pv_core.c:1740 #1 0x0808370a in lval_pvar_assign (h=0xbfc04a68, msg=0x8449dd0, lv=0x82e5518, rve=0x82e5630) at lvalue.c:353 #2 lval_assign (h=0xbfc04a68, msg=0x8449dd0, lv=0x82e5518, rve=0x82e5630) at lvalue.c:400 #3 0x08058e08 in do_action (h=0xbfc04a68, a=0x82e59c0, msg=0x8449dd0) at action.c:1253 #4 0x0805cb90 in run_actions (h=0xbfc04a68, a=0x82e59c0, msg=0x8449dd0) at action.c:1336 #5 0x08059e16 in do_action (h=0xbfc04a68, a=0x82e5fe0, msg=0x8449dd0) at action.c:892 #6 0x0805cb90 in run_actions (h=0xbfc04a68, a=0x82e4e68, msg=0x8449dd0) at action.c:1336 #7 0x0805a066 in do_action (h=0xbfc04a68, a=0x82c4d90, msg=0x8449dd0) at action.c:522 #8 0x0805cb90 in run_actions (h=0xbfc04a68, a=0x82c4c88, msg=0x8449dd0) at action.c:1336 #9 0x08059e16 in do_action (h=0xbfc04a68, a=0x82c9c20, msg=0x8449dd0) at action.c:892 #10 0x0805cb90 in run_actions (h=0xbfc04a68, a=0x82c9c20, msg=0x8449dd0) at action.c:1336 #11 0x08059e16 in do_action (h=0xbfc04a68, a=0x82c9ca0, msg=0x8449dd0) at action.c:892 #12 0x0805cb90 in run_actions (h=0xbfc04a68, a=0x82c3dd8, msg=0x8449dd0) at action.c:1336 #13 0x08059e16 in do_action (h=0xbfc04a68, a=0x82c9ea8, msg=0x8449dd0) at action.c:892 #14 0x0805cb90 in run_actions (h=0xbfc04a68, a=0x82c3728, msg=0x8449dd0) at action.c:1336 #15 0x0805a066 in do_action (h=0xbfc04a68, a=0x82925c0, msg=0x8449dd0) at action.c:522 #16 0x0805cb90 in run_actions (h=0xbfc04a68, a=0x8248820, msg=0x8449dd0) at action.c:1336 #17 0x0805a066 in do_action (h=0xbfc04a68, a=0x82468e8, msg=0x8449dd0) at action.c:522 #18 0x0805cb90 in run_actions (h=0xbfc04a68, a=0x8241eb8, msg=0x8449dd0) at action.c:1336 #19 0x0805cef4 in run_top_route (a=0x8241eb8, msg=0x8449dd0, c=0x0) at action.c:1384 #20 0x080a6c85 in receive_msg ( buf=0x82178a0 "INVITE sip:*31%23@test.fi SIP/2.0\r\nVia: SIP/2.0/UDP 192.98.102.10:5074;rport;branch=z9hG4bKhjemnplb\r\nMax-Forwards: 69\r\nProxy-Authorization: Digest username="test",realm="test.fi",nonce="4bcdc5a0000000"..., len=1047, rcv_info=0xbfc04c68) at receive.c:204 #21 0x0811546e in udp_rcv_loop () at udp_server.c:527 #22 0x08088028 in main_loop () at main.c:1455 #23 0x08089c67 in main (argc=15, argv=0xbfc04ec4) at main.c:2259
Juha Heinanen writes:
i got core dump. most like from this statement:
$rU = $(var(unescaped_user){s.strip,4});
it turned out that in this test $var(unescaped_user) only had 4 chars, i.e., they all got stripped. then this empty string is supposed to be assigned to $rU.
the test may not make much sense, but sr should definitely not dump core!
-- juha
Hello,
On 4/20/10 5:36 PM, Juha Heinanen wrote:
Juha Heinanen writes:
i got core dump. most like from this statement:
$rU = $(var(unescaped_user){s.strip,4});
it turned out that in this test $var(unescaped_user) only had 4 chars, i.e., they all got stripped. then this empty string is supposed to be assigned to $rU.
the test may not make much sense, but sr should definitely not dump core!
yes, I saw it is related to a different part of code. I will fix that.
Thanks, Daniel
-- juha
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On 4/20/10 5:36 PM, Juha Heinanen wrote:
Juha Heinanen writes:
i got core dump. most like from this statement:
$rU = $(var(unescaped_user){s.strip,4});
it turned out that in this test $var(unescaped_user) only had 4 chars, i.e., they all got stripped. then this empty string is supposed to be assigned to $rU.
the test may not make much sense, but sr should definitely not dump core!
should be fixed now. Let me know if works fine for you.
Thanks, Daniel
On 4/20/10 6:30 PM, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
should be fixed now. Let me know if works fine for you.
the same test now worked ok. i'll make more tests later.
now that you have implemented strips, how about the opposite, i.e., head and tail?
Does not make lot of sense in my opinion since it is very easy to do with substr:
head: {s.substr, 0, len} tail: {s.substr, -len, 0}
striptail requied computation of the length and use of that in substr, making it a bit too complex.
Cheers, Daniel
Daniel-Constantin Mierla writes:
Does not make lot of sense in my opinion since it is very easy to do with substr:
head: {s.substr, 0, len} tail: {s.substr, -len, 0}
striptail requied computation of the length and use of that in substr, making it a bit too complex.
yes, striptail did, but strip is just {s.substr, len, 0}.
-- juha
On 4/20/10 7:16 PM, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
Does not make lot of sense in my opinion since it is very easy to do with substr:
head: {s.substr, 0, len} tail: {s.substr, -len, 0}
striptail requied computation of the length and use of that in substr, making it a bit too complex.
yes, striptail did, but strip is just {s.substr, len, 0}.
right, the discussion started about existing core functions with static parameters, so I added both.
Daniel