Re: [SR-Users] Printing xavp
Glad to see that pv_isset can be used, I will use this one more, it seems more consistent than some other alternatives ! On Tue, Jan 21, 2020 at 7:35 AM Ovidiu Sas wrote: > 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:
Re: [SR-Users] Printing xavp
Based on that function you can add a simplified one to print the format you like. Daniel On 21.01.20 16:08, Ovidiu Sas wrote: > This is to verbose and hard to read. > I was looking for something more configurable from the script. > > -ovidiu > > On Tue, Jan 21, 2020 at 7:34 AM Daniel-Constantin Mierla > wrote: >> Hello, >> >> if you are looking to print the content to syslog for troubleshooting, >> then there is pv_xapv_print(). >> >> Cheers, >> Daniel >> >> On 20.01.20 23:07, Ovidiu Sas 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@lists.kamailio.org >>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users >> -- >> Daniel-Constantin Mierla -- www.asipto.com >> www.twitter.com/miconda -- www.linkedin.com/in/miconda >> Kamailio Advanced Training - March 9-11, 2020, Berlin - www.asipto.com >> Kamailio World Conference - April 27-29, 2020, in Berlin -- >> www.kamailioworld.com >> > -- Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio Advanced Training - March 9-11, 2020, Berlin - www.asipto.com Kamailio World Conference - April 27-29, 2020, in Berlin -- www.kamailioworld.com ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Printing xavp
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:
Re: [SR-Users] Printing xavp
This is to verbose and hard to read. I was looking for something more configurable from the script. -ovidiu On Tue, Jan 21, 2020 at 7:34 AM Daniel-Constantin Mierla wrote: > > Hello, > > if you are looking to print the content to syslog for troubleshooting, > then there is pv_xapv_print(). > > Cheers, > Daniel > > On 20.01.20 23:07, Ovidiu Sas 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@lists.kamailio.org > > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > > -- > Daniel-Constantin Mierla -- www.asipto.com > www.twitter.com/miconda -- www.linkedin.com/in/miconda > Kamailio Advanced Training - March 9-11, 2020, Berlin - www.asipto.com > Kamailio World Conference - April 27-29, 2020, in Berlin -- > www.kamailioworld.com > -- 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
Re: [SR-Users] Printing xavp
Hello, if you are looking to print the content to syslog for troubleshooting, then there is pv_xapv_print(). Cheers, Daniel On 20.01.20 23:07, Ovidiu Sas 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@lists.kamailio.org > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users -- Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio Advanced Training - March 9-11, 2020, Berlin - www.asipto.com Kamailio World Conference - April 27-29, 2020, in Berlin -- www.kamailioworld.com ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Printing xavp
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
Re: [SR-Users] Printing xavp
Only available in dev yes ... you could cherry-pick the 2 commits. I think this code should work to copy an full stack of xavps without knowing how many there is. if (defined $xavp(x[0])) $avp_copy("x", 0, "y"); while (pv_unset("$xavp(x)")) { if(!defined $xavp(x)) { break; } $avp_copy("x",0,"y"); } On Mon, Jan 20, 2020 at 4:48 PM Ovidiu Sas 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 > 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 > 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@lists.kamailio.org > >> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > > > > ___ > > 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 > ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Printing xavp
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 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 > 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 > 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@lists.kamailio.org > >> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > > > > ___ > > 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 > ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Re: [SR-Users] Printing xavp
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 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 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@lists.kamailio.org >> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > > ___ > 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
Re: [SR-Users] Printing xavp
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 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@lists.kamailio.org > https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users > ___ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
[SR-Users] Printing xavp
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@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users