2 * transsip - the telephony toolkit
3 * By Daniel Borkmann <daniel@transsip.org>
4 * Copyright 2011, 2012 Daniel Borkmann <dborkma@tik.ee.ethz.ch>
5 * Subject to the GPL, version 2.
14 int register_event_hook(struct event_block
**head
,
15 struct event_block
*block
)
22 while ((*head
) != NULL
) {
23 if (block
->prio
> (*head
)->prio
)
26 head
= &((*head
)->next
);
29 block
->next
= (*head
);
35 int register_event_hook_once(struct event_block
**head
,
36 struct event_block
*block
)
43 while ((*head
) != NULL
) {
44 if (unlikely(block
== (*head
)))
47 if (block
->prio
> (*head
)->prio
)
50 head
= &((*head
)->next
);
53 block
->next
= (*head
);
59 int unregister_event_hook(struct event_block
**head
,
60 struct event_block
*block
)
65 while ((*head
) != NULL
) {
66 if (unlikely(block
== (*head
))) {
67 (*head
) = block
->next
;
71 head
= &((*head
)->next
);
77 int call_event_hooks(struct event_block
**head
, unsigned long event
,
78 const void *arg
, int *called
)
80 int ret
= BLOCK_SUCC_DONE
;
81 struct event_block
*block
= *head
, *next_block
;
89 next_block
= block
->next
;
91 ret
= block
->hook(block
, event
, arg
);
92 if (ret
& BLOCK_STOP_CHAIN
)