[Kamailio-Users] more type conversion wonders

Daniel-Constantin Mierla miconda at gmail.com
Wed Mar 31 11:41:29 CEST 2010



On 3/31/10 8:40 AM, Juha Heinanen wrote:
> i played a bit more with selects and found that statement
>
> if ($sht(auth=>foo::count)>  @cfg_get.local.gw_timeout) {
>     xlog("foo");
> }
>    

I guess selects have types, while pseudo-variables are kind of type 
agnostic. Any PV has a string representation of the value, comparison is 
done as integer if both PVs are integers, otherwise is done as string.

The safe side is to use PV representation of selects when comparing with 
another PV.

PV and selects is another point for the future coherence.

Cheers,
Daniel
> produces error
>
>   0(9213) :<core>  [cfg.y:3379]: parse error in config file /etc/sip-proxy/sip-proxy.cfg, line 507, column 28-55: bad expression: type mismatch: str instead of int at (507,55)
>
> but the error goes away if i either make explicit conversion
>
> if ($sht(auth=>foo::count)>  (int)@cfg_get.local.gw_timeout) {
>     xlog("foo");
> }
>
> or use $sel
>
> if ($sht(auth=>foo::count)>  $sel(cfg_get.local.gw_timeout)) {
>     xlog("foo");
> }
>
> this is thus exactly opposite than in my t_set_fr ordeal where i got
> conversion error when i used $sel instead of @.
>
> in my opinion, no (int) conversion should be needed in the firs case,
> because the value of the cfg variable is int.
>
> in summary, writing statements that include selects is very difficult
> and error prone.
>
> -- juha
>
> _______________________________________________
> Kamailio (OpenSER) - Users mailing list
> Users at lists.kamailio.org
> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
> http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
>
>    

-- 
Daniel-Constantin Mierla * http://www.asipto.com/ * 
http://twitter.com/miconda * 
http://www.linkedin.com/in/danielconstantinmierla



More information about the Users mailing list