Hello,
On 04/10/06 20:23, JF wrote:
Hi,
You *can* tell the recursive call to properly return the retcode. Instead of "return(route(2))", enumerate all possible return codes after the recursive call (inside route[2]) and call return with the same retcode:
route[2] { if(lookup("location")) return(2); if(!uri =~ "^sip:[0-9]{6}[0-9]*@") return(3); strip_tail(1); route(2); if (retcode==1) { return(1); } else if (retcode==2) { return(2); } }
instead of all these if-else statements you can use the 'switch' statement. http://openser.org/dokuwiki/doku.php?id=openser_core_cookbook#switch
It was designed for such cases.
However, return(statement) will be taken in consideration for further enhancements of the configuration language.
Cheers, Daniel
Hope this helps.
JF
On 4/10/06, Andreas Granig andreas.granig@inode.info wrote:
Hi,
I'd like to recursively strip off digits from the tail of a username (a numeric number in fact) and do a lookup in usrloc until an aor is found or the number underruns a lower bound, like:
route[2] { if(lookup("location")) return(2); if(!uri =~ "^sip:[0-9]{6}[0-9]*@") return(3); strip_tail(1); route(2); }
route[3] { # check if numeric, then: route(2); if(retcode==1) {...} else if(retcode==2) {...} else if(retcode == 3) {...} # ... }
The thing is that it obviously doesn't work (retcode is 1 as soon as one recursion happens) because I can't tell the recursive call to properly return the retcode like "return(route(2))" or "return($?)" or something like that. Any other ideas except using flags or is that the only way to go?
Thanks, Andy
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users