[SR-Users] How to check a bit (1/0) of a pseudo-variable?
Daniel-Constantin Mierla
miconda at gmail.com
Thu Jun 16 13:50:11 CEST 2011
Hello,
that function is probably for ser-like AVPs.
back to your original need, you can use directly if conditions like:
if($var(x) & 2) { ... }
will be true if the second bit is set. You have to use the power of two
for the appropriate integer value to match the bit position. The master
branch has bitwise left/right shift operations as well -- I was thinking
of backporting since they were in 1.x but lost in integration of the
core interpreter for 3.0, reported by Juha, so it is not really a new
feature:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=508ad1c0011352e6d24234dbef70a3f6abbdc276
Cheers,
Daniel
On 6/16/11 1:15 PM, Iñaki Baz Castillo wrote:
> 2011/6/16 Iñaki Baz Castillo<ibc at aliax.net>:
>> I've found isavpflagset() right now:
>>
>> http://sip-router.org/wiki/cookbooks/core-cookbook/devel#isavpflagset
>>
>> But it has no description. How is it supposed to work?
> The Changelog file says:
>
> -----------------------------------
> Every AVP may by flaged from script via setavpflag(avpid, flag)
> (it's similar like message flags setflags,resetflags,isflagset).
> AVP flags must be declared using avpflags statement. Flags may be
> tested via isavpflagset(avpid, flag). Both the setting and
> testing may also be processed in a module. It's currently used in
> the "rr" module for dialog_cookies. Such module should register
> flag using register_avpflag(flag_id).
>
> Example: avpflags myflag, dialog_cookie;
>
> $a = 123; setavpflag($a, "myflag");
>
> if (isavpflagset($a, "myflag")) { ....
>
> $dlg_foo = "foo"; $dlg_bar = "bar"; setavpflag("$f./^dlg_",
> "dialog_cookie");
> ----------------------------------------------
>
> But is says that I must use setavpflag() to set flags in the AVP. In
> my case, I retrieve the AVP value from a database (an integer field).
> Could it work?
>
>
--
Daniel-Constantin Mierla -- http://www.asipto.com
http://linkedin.com/in/miconda -- http://twitter.com/miconda
More information about the sr-users
mailing list