Hello,

be aware that return 0 means exit.

Then I guess the grammar for switch is like:

switch(expression) and the expression is evaluated internally. The $rc is intended to give the last returned value. Expressions are evaluated different than people would expect (e.g., based on other programming languages), like:

- negative values are considered FALSE
- positive values are considered TRUE

You can look at the code, starting with action.c for more details on it.

Cheers,
Daniel

On 09/12/13 00:04, Seudin Kasumovic wrote:
Hi,

Let route[FOO]{...} returns -1, 0, or 1 value.

Next example never print message in case -1:

switch (route(FOO)) {
  case -1:
xlog("L_INFO", "FOO = -1\n");
  break;
  case 0:
    xlog("L_INFO", "FOO = zero\n");
    break;
  case 1:
    xlog("L_INFO", "FOO = +1\n");
  break;
}

Result from route(FOO) less then to zero converted to 0, so never get label -1,
but next example works properly (when use $rc):

route(FOO);
switch ($rc) {
  case -1:
xlog("L_INFO", "FOO = -1\n");
  break;
  case 0:
    xlog("L_INFO", "FOO = zero\n");
    break;
  case 1:
    xlog("L_INFO", "FOO = +1\n");
  break;
} 

Is this bug, or regular behavior ?

Regards,
Seudin



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda