Browse code

core: events: new function to test event enabled

- sr_event_enabled(type) returns true if a callback has been registered
for respective event type

Daniel-Constantin Mierla authored on 04/02/2010 11:26:30
Showing 2 changed files
... ...
@@ -126,3 +126,18 @@ int sr_event_exec(int type, void *data)
126 126
 	}
127 127
 }
128 128
 
129
+int sr_event_enabled(int type)
130
+{
131
+	switch(type) {
132
+		case SREV_NET_DATA_IN:
133
+				return (_sr_events_list.net_data_in!=0)?1:0;
134
+		case SREV_NET_DATA_OUT:
135
+				return (_sr_events_list.net_data_out!=0)?1:0;
136
+		case SREV_CORE_STATS:
137
+				return (_sr_events_list.core_stats!=0)?1:0;
138
+		case SREV_CFG_RUN_ACTION:
139
+				return (_sr_events_list.run_action!=0)?1:0;
140
+	}
141
+	return 0;
142
+}
143
+
... ...
@@ -40,5 +40,6 @@ typedef struct sr_event_cb {
40 40
 void sr_event_cb_init(void);
41 41
 int sr_event_register_cb(int type, sr_event_cb_f f);
42 42
 int sr_event_exec(int type, void *data);
43
+int sr_event_enabled(int type);
43 44
 
44 45
 #endif