mailmap: add mail alias
[transsip-mirror.git] / src / call_notifier.c
blobcddc6fd7e0e79e2b639328827fc6a2d309488d09
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 #include "notifier.h"
9 #include "locking.h"
10 #include "call_notifier.h"
12 static struct event_head call_notifier;
14 void init_call_notifier(void)
16 call_notifier.head = NULL;
17 mutexlock_init(&call_notifier.lock);
20 int register_call_notifier(struct event_block *block)
22 int ret;
24 mutexlock_lock(&call_notifier.lock);
25 ret = register_event_hook(&call_notifier.head, block);
26 mutexlock_unlock(&call_notifier.lock);
28 return ret;
31 int register_call_notifier_once(struct event_block *block)
33 int ret;
35 mutexlock_lock(&call_notifier.lock);
36 ret = register_event_hook_once(&call_notifier.head, block);
37 mutexlock_unlock(&call_notifier.lock);
39 return ret;
42 int unregister_call_notifier(struct event_block *block)
44 int ret;
46 mutexlock_lock(&call_notifier.lock);
47 ret = unregister_event_hook(&call_notifier.head, block);
48 mutexlock_unlock(&call_notifier.lock);
50 return ret;
53 int call_notifier_exec(unsigned long event, const void *arg)
55 int ret;
57 mutexlock_lock(&call_notifier.lock);
58 ret = call_event_hooks(&call_notifier.head, event, arg, NULL);
59 mutexlock_unlock(&call_notifier.lock);
61 return ret;