docs: add Emmanuel as contributor
[transsip-mirror.git] / src / notifier.h
blob269fe5893f4bba392ea924b68e1af41a675697b7
1 /*
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.
6 */
8 #ifndef NOTIFIER_H
9 #define NOTIFIER_H
11 #include <stdint.h>
12 #include <stdio.h>
14 #include "locking.h"
16 #define BLOCK_SUCC_DONE 0
17 #define BLOCK_STOP_CHAIN 1
19 enum event_prio {
20 PRIO_VERYLOW,
21 PRIO_LOW,
22 PRIO_MEDIUM,
23 PRIO_HIGH,
24 PRIO_EXTRA,
27 struct event_block {
28 enum event_prio prio;
29 int (*hook)(const struct event_block *self, unsigned long event,
30 const void *arg);
31 struct event_block *next;
34 struct event_head {
35 struct event_block *head;
36 struct mutexlock lock;
39 static inline void init_event_head(struct event_head *head)
41 head->head = NULL;
42 mutexlock_init(&head->lock);
45 extern int register_event_hook(struct event_block **head,
46 struct event_block *block);
47 extern int register_event_hook_once(struct event_block **head,
48 struct event_block *block);
49 extern int unregister_event_hook(struct event_block **head,
50 struct event_block *block);
51 extern int call_event_hooks(struct event_block **head, unsigned long event,
52 const void *arg, int *called);
54 #endif /* NOTIFIER_H */