Module: sip-router
Branch: master
Commit: 2ac66302b0d4dd02d03c17ce89d2dc3a880c928d
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2ac6630…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Feb 4 12:26:30 2010 +0100
core: events: new function to test event enabled
- sr_event_enabled(type) returns true if a callback has been registered
for respective event type
---
events.c | 15 +++++++++++++++
events.h | 1 +
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/events.c b/events.c
index f2be3ad..61abc5f 100644
--- a/events.c
+++ b/events.c
@@ -126,3 +126,18 @@ int sr_event_exec(int type, void *data)
}
}
+int sr_event_enabled(int type)
+{
+ switch(type) {
+ case SREV_NET_DATA_IN:
+ return (_sr_events_list.net_data_in!=0)?1:0;
+ case SREV_NET_DATA_OUT:
+ return (_sr_events_list.net_data_out!=0)?1:0;
+ case SREV_CORE_STATS:
+ return (_sr_events_list.core_stats!=0)?1:0;
+ case SREV_CFG_RUN_ACTION:
+ return (_sr_events_list.run_action!=0)?1:0;
+ }
+ return 0;
+}
+
diff --git a/events.h b/events.h
index 5c7238a..6f79070 100644
--- a/events.h
+++ b/events.h
@@ -40,5 +40,6 @@ typedef struct sr_event_cb {
void sr_event_cb_init(void);
int sr_event_register_cb(int type, sr_event_cb_f f);
int sr_event_exec(int type, void *data);
+int sr_event_enabled(int type);
#endif