Glad to see that pv_isset can be used, I will use this one more, it seems more consistent than some other alternatives !
Here's something that works:
$xavp(x=>a) = "1";
$xavp(x[0]=>b) = "2";
$xavp(x=>a) = "10";
$xavp(x[0]=>b) = "20";
$xavp(x=>a) = "100";
$xavp(x[0]=>b) = "200";
$var(i) = 0;
while (pv_isset("$xavp(x[$var(i)])")) {
xlog("L_INFO", "[$mi] xavp_copy $var(i)\n");
xavp_copy("x", "$var(i)", "y");
$var(i) = $var(i) + 1;
}
xlog("L_INFO", "[$mi] x is duplicated to y\n");
$var(i) = 0;
while (pv_isset("$xavp(y[0])")) {
xavp_params_implode("y", "$var(out)");
xlog("L_INFO", "[$mi] xavp(y[$var(i)])=$var(out)\n");
pv_unset("$xavp(y[0)");
$var(i) = $var(i) + 1;
}
The output:
Jan 21 10:18:12 asrock k[29060]: INFO: <script>: [1258] xavp_copy 0
Jan 21 10:18:12 asrock k[29060]: INFO: <script>: [1258] xavp_copy 1
Jan 21 10:18:12 asrock k[29060]: INFO: <script>: [1258] xavp_copy 2
Jan 21 10:18:12 asrock k[29060]: INFO: <script>: [1258] x is duplicated to y
Jan 21 10:18:12 asrock k[29060]: INFO: <script>: [1258] xavp(y[0])=b=200;a=100;
Jan 21 10:18:12 asrock k[29060]: INFO: <script>: [1258] xavp(y[1])=b=20;a=10;
Jan 21 10:18:12 asrock k[29060]: INFO: <script>: [1258] xavp(y[2])=b=2;a=1;
-ovidiu
On Tue, Jan 21, 2020 at 12:54 AM Julien Chavanton <jchavanton@gmail.com> wrote:
>
> This code as it is is useless, unless we print the content or do something before making the copy but can provide a way to to duplicate/reorder stacks.
>
> Maybe looping over
>
> if (defined $xavp(x[$var(i)]))
>
> Is sufficient, no need to pv_unset
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users@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@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users