[SR-Users] Printing xavp

Julien Chavanton jchavanton at gmail.com
Tue Jan 21 06:28:38 CET 2020


My previous answer was not very helpful, lets try again (not tested)

Your example :

The following code produces "c=d;e=f;"
    $xavp(x=>e) = "f";
    $xavp(x[0]=>c) = "d";
    $xavp(x[1]=>e) = "z";
    $xavp(x[1]=>c) = "y";
    xavp_params_implode("x", "$var(out)");


Since you know what are the sub-elements, you could do :

   $var(i) = 0;
   while ($var(i) < 2) {
      xinfo("$xavp(x[$var(i)]=>c) \n");
      xinfo("$xavp(x[$var(i)]=>e) \n");
      $var(i) = $var(i) + 1;
   }


I am quite sure you can not pass an index to xavp_params_implode, so one
way to use xavp_params_implode would be to xavp_copy to a new xavp to have
default index.

   $var(i) = 0;
   while ($var(i) < 2) {
      xavp_copy("x", $var(i), "y");
      xavp_params_implode("y", "$var(out)");
      xinfo("$var(out)\n");
      $var(i) = $var(i) + 1;
   }

On Mon, Jan 20, 2020 at 4:48 PM Ovidiu Sas <osas at voipembedded.com> wrote:

> xavp_copy() is available only in dev.
> How can you copy an entire xavp, not just an element, without knowing
> the size of the stack?
> This doesn't work:
>     $var(i) = 0;
>     while (pv_isset("$xavp(x[$var(i)])")) {
>         xavp_copy("x", "$var(i)", "y");
>         $var(i) = $var(i) + 1;
>     }
>
>
> -ovidiu
>
> On Mon, Jan 20, 2020 at 6:34 PM Julien Chavanton <jchavanton at gmail.com>
> wrote:
> >
> > Hi,
> >
> > To print all the elements in the stack, you will have to do a while loop.
> > (You can make a copy using xavp_copy, it may come in handy in some cases)
> > while (pv_unset("$xavp(name)")) {
> >          // xavp_params_implode
> >         if(!defined $xavp(name)) {
> >                 break;
> >         }
> > }
> >
> >
> > Or if you know how many elements are present in the stack or you could
> use
> > while ($var(i) < x) {
> >     xavp_params_implode($xavp(route_set[$var(i)]....))
> >     $var(i) = $var(i) + 1;
> > }
> >
> > Quick answer ...
> >
> >
> > On Mon, Jan 20, 2020 at 2:08 PM Ovidiu Sas <osas at voipembedded.com>
> wrote:
> >>
> >> What's the best way to print the entire content of an xavp?
> >> The xavp_params_implode() doesn't print the entire stack of an xavp,
> >> only the top layer:
> >>
> >> The following code produces "c=d;e=f;"
> >>     $xavp(x=>e) = "f";
> >>     $xavp(x[0]=>c) = "d";
> >>     $xavp(x[1]=>e) = "z";
> >>     $xavp(x[1]=>c) = "y";
> >>     xavp_params_implode("x", "$var(out)");
> >>
> >> Is there a way to print everything inside $xavp(x)?
> >>
> >> Thanks,
> >> Ovidiu
> >>
> >> _______________________________________________
> >> Kamailio (SER) - Users Mailing List
> >> sr-users at lists.kamailio.org
> >> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
> >
> > _______________________________________________
> > Kamailio (SER) - Users Mailing List
> > sr-users at lists.kamailio.org
> > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
>
>
> --
> VoIP Embedded, Inc.
> http://www.voipembedded.com
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20200120/bd8e84c1/attachment.html>


More information about the sr-users mailing list