Hello,
On 10/9/12 3:59 PM, Andreas Granig
wrote:
Hi,
I'm playing around with xavp, but there are some things I can't wrap my
head around.
What basically works is this:
$xavp(a=>foo) = 'foo';
$xavp(a[0]=>bar) = 'bar';
Getting the value like this:
xlog("L_INFO", "a-foo='$xavp(a=>foo)' and a-bar='$xavp(a=>bar)'");
as well as
xlog("L_INFO", "a-foo='$xavp(a[0]=>foo)' and a-bar='$xavp(a[0]=>bar)'");
... works, because when omitting the index, it assumes [0]. I really
like to avoid such implicit assumptions though, to make the config
really clear, so I prefer the second approach.
What doesn't work for me then is explicit assignment of the very first
value, like this:
$xavp(a[0]=>foo) = 'foo';
$xavp(a[0]=>bar) = 'bar';
If I do this, the "a" xavp is never created. Wouldn't it be good
practice to create the xavp on first assignment? That way, I don't have
to take care in the config file whether the xavp is used for the first
time, where I have to omit the index.
xavps are reusing the avps architecture in regards of working as a
stack. So last added is first in the list.
The problem of creating the structure when providing the index is
also related to it. What should happen if one does:
$xavp(a[5]=>foo) = 'foo';
Create other 5 xavps named 'a' (indexes 0 to 4)?
It seemed the right approach not to create new structures at invalid
position, by simply not providing the position. For overwriting a
value, the index has to be provided.
The xavps system was under rfc at some point:
http://lists.sip-router.org/pipermail/users/2009-July/024180.html
Of course, it can be adjusted when something can be better, for the
moment I don't see a solution to this case, unless a new operator is
introduced.
What I'm also wondering is whether it's possible to directly access
nested xavps, like this:
$xavp(a=>foo) = 'afoo';
$xavp(b=>foo) = 'bfoo';
$xavp(c=>a) = $xavp(a);
$xavp(c=>b) = $xavp(b);
xlog("L_INFO", "a-foo='$xavp(c=>a[0]=>foo)'");
or
xlog("L_INFO", "a-foo='$xavp(c=>a=>foo)'");
Both ways give me "a-foo='<<xavp:0x7f0d387fe178>>'". Is this even
intended? Would be really cool if that's possible!
Internally it is possible to have as many nested xavps (the value
for an xavp can be a list of xavps). At this moment, the config file
syntax has support only for two levels, your example is returning
the value of c=>a, which is a pointer to another xavp list.
Cheers,
Daniel
Thanks,
Andreas
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda