[SR-Users] has_tran_tmcbs function

Timo Reimann timo.reimann at 1und1.de
Wed Jun 1 17:12:37 CEST 2011


Hey Bruno,


On 01.06.2011 16:48, Bruno Bresciani wrote:
> I can't understand the has_tran_tmcbs function... Can someone tell me
> how it works?

The function checks if, for a given transaction T and a bitfield of
callbacks, any of the callbacks are registered for T.

It does so my logically ANDing the transaction bitfield (which
represents the set of registered callbacks) with the bitfield of
callbacks you would like to be checked. For each callback actually
registered, the corresponding pair of bits will yield one w.r.t. to the
AND operation. Therefore, if at least one of the given callbacks is
registered, the entire AND operation will result in a value greater
zero, thereby indicating that the transaction does have at least one of
the given callbacks registered.

For instance, if the bitfield of registered callbacks for T is 1011, and
it is to be checked whether the callback bitfield 0110 matches, the
outcome of 1011 & 0110 = 0010 > 0, meaning that at least one of the
given callbacks is registered (which, in this example, happens to be the
second transaction callback defined in t_hooks.h).


HTH,

--Timo



More information about the sr-users mailing list