[Users] Re: [Devel] test return code in config file

Klaus Darilion klaus.mailinglists at pernau.at
Wed Jun 29 15:44:55 CEST 2005


Can this be used to exit from a route block to avoid the workaround 
using flags, e.g.:

route {
  route(1);
  if (retcode == 99) break;
  ...
}

route[1] {
   if (security check fails) {
	return(99);
   }
   ... do some things;
}


Is there a differnce between
   return(0);
and
   break;
?

regards,
klaus
Daniel-Constantin Mierla wrote:
> Hello,
> 
> there is a new variable in configuration file 'retcode' that can be used 
> to test against an integer the value returned by last invoked function 
> or route. In the case of routes that uses return, it is the returned 
> value. The changes were done yesterday, so the pserver CVS head is now 
> synchronized.
> 
> It is similar to $? from bash ($? can be used also in configuration 
> file, having the same meaning as 'retcode'). Take care when you are 
> testing this value, it can be easily misleading. For example:
> 
> 
> route[1] {
>     if(method=="INVITE")
>         return(1);
>     return(2);
> }
> 
> route {
> 
>     route(1);
>     if(retcode==2)
>     {
>         log("The request is a REGISTER\n");
>     };
>     if(retcode==1)
>     {
>         ...
>     };
> 
> }
> 
> In case of REGISTER, the 'log' function is executed and the value of 
> retcode is changed. The proper scripting is:
> route {
> 
>     route(1);
>     if(retcode==2)
>     {
>         log("The request is a REGISTER\n");
>     } else if(retcode==1)
>     {
>         ...
>     };
> }
> 
> I have updated the docuwiki for 'return()' and added 'retcode' there, too.
> 
> http://www.openser.org/dokuwiki/doku.php?id=openser_core_cookbook#return_int 
> 
> http://www.openser.org/dokuwiki/doku.php?id=openser_core_cookbook#retcode
> 
> Regards,
> Daniel
> 
> 
> 
> 
> 
> _______________________________________________
> Devel mailing list
> Devel at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/devel
> 
> 





More information about the Users mailing list