core: events: new function to test event enabled
authorDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 4 Feb 2010 11:26:30 +0000 (12:26 +0100)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 4 Feb 2010 12:02:43 +0000 (13:02 +0100)
- sr_event_enabled(type) returns true if a callback has been registered
  for respective event type

events.c
events.h

index f2be3ad..61abc5f 100644 (file)
--- 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;
+}
+
index 5c7238a..6f79070 100644 (file)
--- 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