[OpenSIPS-Users] when does a var goes out of scope.

Parkistler _ parkistler at gmail.com
Fri Sep 4 04:00:44 EST 2020


johan <johan at democon.be>于2020年9月2日 周三18:37写道:

> As you can see I use dialpan to strip 0,00 or + from fU result is $var(fU).
>
> I seem to get strange and incomprehensible results :
>
> Sep  1 09:41:58 hendrix /data/opensips/sbin/opensips[6327]:
> callid=7ocl48d3Gi: Route[normalizeforoutbound]: we change rU +3315 to
> E.164; as the call is outbound, base is fU 33757935187
> Sep  1 09:41:58 hendrix /data/opensips/sbin/opensips[6327]:
> callid=7ocl48d3Gi: Route[normalizeforoutbound]: we drop 0,00,+ from
> 33757935187, result is var(fU)
> Sep  1 09:41:58 hendrix /data/opensips/sbin/opensips[6327]:
> callid=7ocl48d3Gi: Route[normalizeforoutbound]: result dp_translate
> var(fU) +32460200570
>
> As you can see in the script snippet, $var(fU) is not initialized.
>
>
> So : would initialization of var(fU) to '' solve my issue.
>
> As a more general question : when does a variable goes excatly out of
> scope ?
>
>
>
> dialplan:
>
> *************************** 1. row ***************************
>           id: 4
>         dpid: 1
>           pr: 1
>     match_op: 1
>    match_exp: ^(00|\+|0).*
> match_flags: 0
>    subst_exp: ^(00|\+|0)(.*)
>     repl_exp: \2
>      timerec: NULL
>     disabled: 0
>        attrs:
>
> script :
>
> route[normalizeforoutbound]
> {
>      xlog("callid=$ci: Route[normalizeforoutbound]: we change rU $rU to
> E.164; as the call is outbound, base is fU $fU");
>      xlog("callid=$ci: Route[normalizeforoutbound]: we drop 0,00,+ from
> $fU, result is var(fU)");
>      $var(i)=1;
>      dp_translate($(var(i){s.int}),"$fU",$var(fU));
>      if ($var(fU)==NULL or $var(fU)=='' or $var(fU)=='<null>')
>      {
>          xlog("callid=$ci: Route[normalizeforoutbound]: result
> dp_translate var(fU) $var(fU) == NULL -> from header fU $fU has correct
> format, we use fU $fU in query");
>          avp_db_query("SELECT country,channels FROM subscriber where
> username like '%$fU'","$avp(countryoutbound);$avp(channels)");
>          xlog("callid=$ci: Route[normalizeforoutbound]: SELECT
> country,channels FROM subscriber where username like '%$fU'  ->
> avp(countryoutbound) $avp(countryoutbound), avp(channels) $avp(channels)
> ");
>      }
>      else
>      {
>          xlog("callid=$ci: Route[normalizeforoutbound]: result
> dp_translate var(fU) $var(fU) -> from header fu $fU has incorrect
> format, we use var(fU) $var(fU) in query");
>          avp_db_query("SELECT country,channels FROM subscriber where
> username like '%$var(fU)'","$avp(countryoutbound);$avp(channels)");
>          xlog("callid=$ci: Route[normalizeforoutbound]: SELECT
> country,channels FROM subscriber where username like '%$var(fU)' ->
> avp(countryoutbound) $avp(countryoutbound), avp(channels) $avp(channels)
> ");
>      }
>
>
> output:
>
> Sep  1 09:41:58 hendrix /data/opensips/sbin/opensips[6327]:
> callid=7ocl48d3Gi: Route[normalizeforoutbound]: we change rU +3315 to
> E.164; as the call is outbound, base is fU 33757935187
> Sep  1 09:41:58 hendrix /data/opensips/sbin/opensips[6327]:
> callid=7ocl48d3Gi: Route[normalizeforoutbound]: we drop 0,00,+ from
> 33757935187, result is var(fU)
> Sep  1 09:41:58 hendrix /data/opensips/sbin/opensips[6327]:
> callid=7ocl48d3Gi: Route[normalizeforoutbound]: result dp_translate
> var(fU) +32460200570 -> from header fu 33757935187 has incorrect format,
> we use var(fU) +32460200570 in query
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20200904/01e426fd/attachment.html>


More information about the Users mailing list