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

Daniel-Constantin Mierla daniel at voice-system.ro
Tue Sep 11 23:22:23 CEST 2007


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



More information about the Devel mailing list