2 * transsip - the telephony toolkit
3 * By Daniel Borkmann <daniel@transsip.org>
4 * Copyright 2011, 2012 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
5 * Swiss federal institute of technology (ETH Zurich)
6 * Subject to the GPL, version 2.
15 int register_event_hook(struct event_block
**head
,
16 struct event_block
*block
)
23 while ((*head
) != NULL
) {
24 if (block
->prio
> (*head
)->prio
)
27 head
= &((*head
)->next
);
30 block
->next
= (*head
);
36 int register_event_hook_once(struct event_block
**head
,
37 struct event_block
*block
)
44 while ((*head
) != NULL
) {
45 if (unlikely(block
== (*head
)))
48 if (block
->prio
> (*head
)->prio
)
51 head
= &((*head
)->next
);
54 block
->next
= (*head
);
60 int unregister_event_hook(struct event_block
**head
,
61 struct event_block
*block
)
66 while ((*head
) != NULL
) {
67 if (unlikely(block
== (*head
))) {
68 (*head
) = block
->next
;
72 head
= &((*head
)->next
);
78 int call_event_hooks(struct event_block
**head
, unsigned long event
,
79 const void *arg
, int *called
)
81 int ret
= BLOCK_SUCC_DONE
;
82 struct event_block
*block
= *head
, *next_block
;
90 next_block
= block
->next
;
92 ret
= block
->hook(block
, event
, arg
);
93 if (ret
& BLOCK_STOP_CHAIN
)