there is an example in group module - get_user_group() function.

However, you can do a new pseudo-variable:

$rr_count or so, where get function counts the number of routes.

The you do not need to use a function to set a variable, you can do:
$var(x) = $rr_count;

Cheers,
Daniel


On 10.11.2009 4:47 Uhr, Juha Heinanen wrote:
it was easy to write the code that counts the number of record routes in
a message.  first i though that i can return the count as result of the
script function, but that didn't work out because if script function
returns 0, it will terminate execution of the script.

so i though to give the function a pvar argument to which the count
is stored, e.g.,

rr_count("$var(count)");

so far i have not been able to assign the count to the pvar argument and
have already spent three hours on such a simple assignment statement.  in
pvar.h there is function
int pv_set_spec_value(struct sip_msg* msg, pv_spec_p sp, int op,
                pv_value_t *value);

that sounds like it might do the trick, but there is no documentation on
op argument and i have not yet found in sr sources any place there that
function is really used.  also i have not found in any of sr modules any
script function that would assign something to a pvar argument?  is
there one so that i could take a look or it that an impossible thing to
do?
i have tried various versions, such as

    pv_val.ri = count;
    pv_val.flags = PV_VAL_INT;
    if (_count) {
        if (pv_set_spec_value(msg, (pv_spec_t *)_count, EQ_T, &pv_val) == 0) {

where _count is pvar fixed up argument of rr_count function, but no luck
so far.  i just get

Nov 10 05:42:51 localhost /usr/sbin/sip-proxy[27707]: ERROR: pv 
[pv_svar.c:117]: out of pkg mem!
Nov 10 05:42:51 localhost /usr/sbin/sip-proxy[27707]: ERROR: pv [pv_core.c:1620]: error - cannot set svar [tmp]
can anyone help here?  if not, i'll have to make rr_count to return the
actual count + 1 so that i can return it as result of the rr_count
function.

-- juha

_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev


--
Daniel-Constantin Mierla
* http://www.asipto.com/


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to