[OpenSER-Users] 'while' statement in config file

Klaus Darilion klaus.mailinglists at pernau.at
Wed Sep 12 08:13:37 CEST 2007


Hi Daniel!

IMO a while loop is a good idea. But I think a maximum loop counter 
should be added too (maybe as parameter at top of openser.cfg) which 
stops the loop and discards the message e.g. after 100 iterations to 
prevent an endless loop.

regards
klaus

Daniel-Constantin Mierla schrieb:
> Hello,
> 
> although is more part of devel, the decision will affect users of future 
> stable releases, so I posted on both lists.
> 
> Maybe some of you noticed that in the ongoing process of improving the 
> pseudo-variables system, the AVPs and HDRs can be accessed with dynamic 
> index. That means next lines are correct in the config file.
> 
> $var(i) = 1;
> xlog("$(avp(i:20)[$var(i)])");
> 
> if($(avp(i:20)[$var(i)]) == 3) {
> }
> 
> In the past, the index was static, as a number.
> 
> The question I want to address is whether makes sense to add 'while' 
> statements to iterate through avps or hdrs. More or less, the cycles can 
> be done via recursive routes.
> 
> The block:
> 
> $var(i) = 0;
> while($(avp(i:20)[$var(i)]) != null) {
> .....
> $var(i) = $var(i) +1;
> }
> 
> is equivalent with:
> 
> $var(i) = 0;
> route(1);
> ....
> route[1] {
> if(($(avp(i:20)[$var(i)]) == null)
>   return;
> ...
> $var(i) = $var(i) +1;
> route(1);
> }
> 
> 'while' may look more attractive, but could open the pandora box, people 
> asking for more and more, that will turn config language is something 
> very complex (not saying that is simple now :-) ).
> 
> The drawback with recursive routes is the fixed number of routes that 
> can be defined with the standard openser: 40 (number can be increased if 
> openser is recompiled), because for each cycle another route has to be 
> used.
> 
> Waiting for your opinions...
> 
> Cheers,
> Daniel
> 
> _______________________________________________
> Users mailing list
> Users at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/users




More information about the sr-users mailing list