[Devel] test return code in config file

Daniel-Constantin Mierla daniel at voice-system.ro
Wed Jun 29 15:23:44 CEST 2005


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







More information about the Devel mailing list