<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
be aware that return 0 means exit.<br>
<br>
Then I guess the grammar for switch is like:<br>
<br>
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:<br>
<br>
- negative values are considered FALSE<br>
- positive values are considered TRUE<br>
<br>
You can look at the code, starting with action.c for more details on
it.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<div class="moz-cite-prefix">On 09/12/13 00:04, Seudin Kasumovic
wrote:<br>
</div>
<blockquote
cite="mid:CAHbz3+3ZqLJFjvM3OiWNGWamjdxqY6P_n4gP5_4btEtheO_VrA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>Hi,</div>
<div><br>
</div>
<div>Let route[FOO]{...} returns -1, 0, or 1 value.</div>
<div><br>
</div>
<div>Next example never print message in case -1:</div>
<div><br>
</div>
<div>
<div><font face="courier new, monospace">switch (route(FOO)) {</font></div>
<div><font face="courier new, monospace"><span
style="white-space:pre"> </span>case -1:</font></div>
<div><span class="" style="white-space:pre"><font
face="courier new, monospace"> xlog("L_INFO", "FOO =
-1\n");</font></span></div>
<div><font face="courier new, monospace"><span
style="white-space:pre"> </span>break;</font></div>
<div><span style="font-family:'courier
new',monospace;white-space:pre"> </span><font
face="courier new, monospace">case 0:</font></div>
<div><span class="" style="white-space:pre"><span
style="font-family:'courier new',monospace"> </span></span><span
style="font-family:'courier
new',monospace;white-space:pre"> </span><span
style="font-family:'courier
new',monospace;white-space:pre">xlog("L_INFO", "FOO =
zero\n");</span></div>
<div><span style="font-family:'courier
new',monospace;white-space:pre"> </span><span
style="font-family:'courier
new',monospace;white-space:pre"> </span><span
style="font-family:'courier new',monospace">break;</span></div>
<div><span style="font-family:'courier
new',monospace;white-space:pre"> </span><font
face="courier new, monospace">case 1:</font></div>
<div><span style="font-family:'courier
new',monospace;white-space:pre"> </span><span
style="font-family:'courier
new',monospace;white-space:pre"> </span><span
style="font-family:'courier new',monospace">xlog("L_INFO",
"FOO = +1\n");</span></div>
<div><span style="font-family:'courier
new',monospace;white-space:pre"> </span><font
face="courier new, monospace">break;</font></div>
<div><font face="courier new, monospace">}</font></div>
</div>
<div><br>
</div>
<div>
Result from route(FOO) less then to zero converted to 0, so
never get label -1,</div>
<div>but next example works properly (when use $rc):</div>
<div><br>
</div>
<div><span style="font-family:'courier new',monospace">route(FOO);</span><br>
</div>
<div><font face="courier new, monospace">switch ($rc) {</font></div>
<div><font face="courier new, monospace"><span
style="white-space:pre"> </span>case -1:</font></div>
<div><span class="" style="white-space:pre"><font face="courier
new, monospace"> xlog("L_INFO", "FOO = -1\n");</font></span></div>
<div><font face="courier new, monospace"><span
style="white-space:pre"> </span>break;</font></div>
<div><span style="font-family:'courier
new',monospace;white-space:pre"> </span><font
face="courier new, monospace">case 0:</font></div>
<div><span class="" style="white-space:pre"><span
style="font-family:'courier new',monospace"> </span></span><span
style="font-family:'courier new',monospace;white-space:pre">
</span><span style="font-family:'courier
new',monospace;white-space:pre">xlog("L_INFO", "FOO =
zero\n");</span></div>
<div><span style="font-family:'courier
new',monospace;white-space:pre"> </span><span
style="font-family:'courier new',monospace;white-space:pre">
</span><span style="font-family:'courier new',monospace">break;</span></div>
<div><span style="font-family:'courier
new',monospace;white-space:pre"> </span><font
face="courier new, monospace">case 1:</font></div>
<div><span style="font-family:'courier
new',monospace;white-space:pre"> </span><span
style="font-family:'courier new',monospace;white-space:pre">
</span><span style="font-family:'courier new',monospace">xlog("L_INFO",
"FOO = +1\n");</span></div>
<div><span style="font-family:'courier
new',monospace;white-space:pre"> </span><font
face="courier new, monospace">break;</font></div>
<div><span style="font-family:'courier new',monospace">}</span> </div>
<div><br>
</div>
<div>Is this bug, or regular behavior ?</div>
<div><br>
</div>
<div>Regards,</div>
<div>Seudin</div>
<div><br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a></pre>
</body>
</html>