[Users] Recursive routes and retcode
JF
jfkavaka at gmail.com
Mon Apr 10 19:23:57 CEST 2006
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);
}
}
Hope this helps.
JF
On 4/10/06, Andreas Granig <andreas.granig at 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 at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/users
>
More information about the Users
mailing list