Hi, in order to minimize the SQL queries for functions "is_uri_host_local()" and "is_from_local()" I want to exec they just one time and store the result in a variable, but the result is unexpected:
$var(is_uri_host_local) = is_uri_host_local(); xlog("------------is_uri_host_local = $var(is_uri_host_local)\n");
So if the URI is local then the result is 1. But if the URI is not local then result is 4294967295. ¿?¿?¿?¿
Obviously it makes me difficult for me to do:
if ($var(is_uri_host_local))
because always is true and I need to convert the values and so.
Why "is_uri_host_local()" doesn't return -1 in case of being not local domain?
Or maybe the issue is when I store the result in a variable? but why?
Thanks.
El Monday 03 September 2007 12:36:52 Iñaki Baz Castillo escribió:
Or maybe the issue is when I store the result in a variable? but why?
Humm, I think so, I think the problem is when I do:
$var(is_uri_host_local)=is_uri_host_local();
It literaly is the same as if I do:
$var(is_uri_host_local)= -1;
Then if I show the variable it gives me 4294967295.
I can solve it by doing:
$var(is_uri_host_local)=is_uri_host_local(); if ($var(is_uri_host_local) != 1) { $var(is_uri_host_local) = ""; }
Any other better way? Thanks.
Hello,
On 09/03/07 13:36, Iñaki Baz Castillo wrote:
Hi, in order to minimize the SQL queries for functions "is_uri_host_local()" and "is_from_local()" I want to exec they just one time and store the result in a variable, but the result is unexpected:
$var(is_uri_host_local) = is_uri_host_local(); xlog("------------is_uri_host_local = $var(is_uri_host_local)\n");
a better way to do it is:
is_uri_host_local(); $var(is_uri_host_local) = $retcode;
Some times, because of OpenSER return code schema, negative values are converted to -1, positive to 1 (0 is used to signal an exit from config script interpretation). In this case might work, but not in all. The 4294967295 is actually the unsigned int of -1 (or similar). The printing function should be changed to use signed int to have it clear and correct here.
However, with the above code I gave, you can do:
if ($var(is_uri_host_local)<0) to check if was a false response or: if ($var(is_uri_host_local)>0) to check if was a true response.
Cheers, Daniel
So if the URI is local then the result is 1. But if the URI is not local then result is 4294967295. ¿?¿?¿?¿
Obviously it makes me difficult for me to do:
if ($var(is_uri_host_local))
because always is true and I need to convert the values and so.
Why "is_uri_host_local()" doesn't return -1 in case of being not local domain?
Or maybe the issue is when I store the result in a variable? but why?
Thanks.
El Monday 03 September 2007 12:55:34 Daniel-Constantin Mierla escribió:
Hello,
On 09/03/07 13:36, Iñaki Baz Castillo wrote:
Hi, in order to minimize the SQL queries for functions "is_uri_host_local()" and "is_from_local()" I want to exec they just one time and store the result in a variable, but the result is unexpected:
$var(is_uri_host_local) = is_uri_host_local(); xlog("------------is_uri_host_local = $var(is_uri_host_local)\n");
a better way to do it is:
is_uri_host_local(); $var(is_uri_host_local) = $retcode;
Some times, because of OpenSER return code schema, negative values are converted to -1, positive to 1 (0 is used to signal an exit from config script interpretation). In this case might work, but not in all. The 4294967295 is actually the unsigned int of -1 (or similar). The printing function should be changed to use signed int to have it clear and correct here.
However, with the above code I gave, you can do:
if ($var(is_uri_host_local)<0) to check if was a false response or: if ($var(is_uri_host_local)>0) to check if was a true response.
Thanks for the explanation. ;)
El Monday 03 September 2007 12:55:34 Daniel-Constantin Mierla escribió:
is_uri_host_local(); $var(is_uri_host_local) = $retcode;
Some times, because of OpenSER return code schema, negative values are converted to -1, positive to 1 (0 is used to signal an exit from config script interpretation). In this case might work, but not in all.
In my case it doesn't work:
is_uri_host_local(); $var(kk)=$retcode; xlog("---- var(kk) = $var(kk)\n");
And it occurs the same, $var(kk) is 1 or 4294967295, so the real problem is that "is_uri_host_local()" just return these two values. :(
Maybe I should report it.
Hello,
On 09/03/07 14:35, Iñaki Baz Castillo wrote:
El Monday 03 September 2007 12:55:34 Daniel-Constantin Mierla escribió:
is_uri_host_local(); $var(is_uri_host_local) = $retcode;
Some times, because of OpenSER return code schema, negative values are converted to -1, positive to 1 (0 is used to signal an exit from config script interpretation). In this case might work, but not in all.
In my case it doesn't work:
is_uri_host_local(); $var(kk)=$retcode; xlog("---- var(kk) = $var(kk)\n");
And it occurs the same, $var(kk) is 1 or 4294967295, so the real problem is that "is_uri_host_local()" just return these two values. :(
have you tried the if() conditions? Don't look at printed value, just try to use if() conditions.
Cheers, Daniel
Maybe I should report it.
El Monday 03 September 2007 13:48:24 Daniel-Constantin Mierla escribió:
Hello,
On 09/03/07 14:35, Iñaki Baz Castillo wrote:
El Monday 03 September 2007 12:55:34 Daniel-Constantin Mierla escribió:
is_uri_host_local(); $var(is_uri_host_local) = $retcode;
Some times, because of OpenSER return code schema, negative values are converted to -1, positive to 1 (0 is used to signal an exit from config script interpretation). In this case might work, but not in all.
In my case it doesn't work:
is_uri_host_local(); $var(kk)=$retcode; xlog("---- var(kk) = $var(kk)\n");
And it occurs the same, $var(kk) is 1 or 4294967295, so the real problem is that "is_uri_host_local()" just return these two values. :(
have you tried the if() conditions? Don't look at printed value, just try to use if() conditions.
I've tryed that you mean:
is_uri_host_local(); $var(kk)=$retcode; if($var(kk)) { xlog("-------------------- POSITIVE ------------------\n"); } if(!$var(kk)) { xlog("------------------- NEGATIVE------------------\n"); }
and it ALWAYS shows "POSITIVE", so it's managing values 1 or 4294967295 :(
Hello,
On 09/04/07 10:37, Iñaki Baz Castillo wrote:
El Monday 03 September 2007 13:48:24 Daniel-Constantin Mierla escribió:
Hello,
On 09/03/07 14:35, Iñaki Baz Castillo wrote:
El Monday 03 September 2007 12:55:34 Daniel-Constantin Mierla escribió:
is_uri_host_local(); $var(is_uri_host_local) = $retcode;
Some times, because of OpenSER return code schema, negative values are converted to -1, positive to 1 (0 is used to signal an exit from config script interpretation). In this case might work, but not in all.
In my case it doesn't work:
is_uri_host_local(); $var(kk)=$retcode; xlog("---- var(kk) = $var(kk)\n");
And it occurs the same, $var(kk) is 1 or 4294967295, so the real problem is that "is_uri_host_local()" just return these two values. :(
have you tried the if() conditions? Don't look at printed value, just try to use if() conditions.
I've tryed that you mean:
is_uri_host_local(); $var(kk)=$retcode; if($var(kk)) { xlog("-------------------- POSITIVE ------------------\n"); } if(!$var(kk)) { xlog("------------------- NEGATIVE------------------\n"); }
and it ALWAYS shows "POSITIVE", so it's managing values 1 or 4294967295 :(
your conditions are wrong. I said: if ($var(is_uri_host_local)<0) to check if was a false response or: if ($var(is_uri_host_local)>0) to check if was a true response.
To clarify a bit: - when a function or route returns, the code is interpreted as: negative value is false; 0 is exit interpreting configuration file; positive is true - when an integer value is tested, the test is as in C: 0 is false, otherwise is true
In your case, you test an integer.
Cheers, Daniel
El Wednesday 05 September 2007 17:10:23 Daniel-Constantin Mierla escribió:
your conditions are wrong. I said: if ($var(is_uri_host_local)<0) to check if was a false response or: if ($var(is_uri_host_local)>0) to check if was a true response.
To clarify a bit:
- when a function or route returns, the code is interpreted as: negative
value is false; 0 is exit interpreting configuration file; positive is true
- when an integer value is tested, the test is as in C: 0 is false,
otherwise is true
In your case, you test an integer.
Ok, understood. And it works at you say (doing the test > or <).
Anyway I don't like that test so I prefer to do at the start:
$var(is_uri_host_local)=is_uri_host_local(); if ($var(is_uri_host_local) != 1) { $var(is_uri_host_local) = ""; }
And later do a "normal" test:
if ($var(is_uri_host_local)) ... if (!$var(is_uri_host_local)) ...
IMHO is clearer in this way, just my opinion.
Thanks a lot for your good explanation and regards.
On 09/06/07 11:05, Iñaki Baz Castillo wrote:
El Wednesday 05 September 2007 17:10:23 Daniel-Constantin Mierla escribió:
your conditions are wrong. I said: if ($var(is_uri_host_local)<0) to check if was a false response or: if ($var(is_uri_host_local)>0) to check if was a true response.
To clarify a bit:
- when a function or route returns, the code is interpreted as: negative
value is false; 0 is exit interpreting configuration file; positive is true
- when an integer value is tested, the test is as in C: 0 is false,
otherwise is true
In your case, you test an integer.
Ok, understood. And it works at you say (doing the test > or <).
Anyway I don't like that test so I prefer to do at the start:
$var(is_uri_host_local)=is_uri_host_local(); if ($var(is_uri_host_local) != 1) { $var(is_uri_host_local) = ""; }
maybe not in this case, but yu should test for >0 to set it true or false. 1 is not the only return code representing true, any number which is positive.
Daniel
And later do a "normal" test:
if ($var(is_uri_host_local)) ... if (!$var(is_uri_host_local)) ...
IMHO is clearer in this way, just my opinion.
Thanks a lot for your good explanation and regards.
El Thursday 06 September 2007 19:36:20 Daniel-Constantin Mierla escribió:
On 09/06/07 11:05, Iñaki Baz Castillo wrote:
El Wednesday 05 September 2007 17:10:23 Daniel-Constantin Mierla escribió:
your conditions are wrong. I said: if ($var(is_uri_host_local)<0) to check if was a false response or: if ($var(is_uri_host_local)>0) to check if was a true response.
To clarify a bit:
- when a function or route returns, the code is interpreted as: negative
value is false; 0 is exit interpreting configuration file; positive is true - when an integer value is tested, the test is as in C: 0 is false, otherwise is true
In your case, you test an integer.
Ok, understood. And it works at you say (doing the test > or <).
Anyway I don't like that test so I prefer to do at the start:
$var(is_uri_host_local)=is_uri_host_local(); if ($var(is_uri_host_local) != 1) { $var(is_uri_host_local) = ""; }
maybe not in this case, but yu should test for >0 to set it true or false. 1 is not the only return code representing true, any number which is positive.
Yes, ok, thanks for the advice.
Anyway I did some test and **this** function just returns "1" when true.
Thanks a lot for all you help.