Browse Source

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 15 years ago
parent
commit
2ac66302b0
2 changed files with 16 additions and 0 deletions
  1. 15 0
      events.c
  2. 1 0
      events.h

+ 15 - 0
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;
+}
+

+ 1 - 0
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