summaryrefslogtreecommitdiffstats
path: root/dispatcher/elapi_dispatcher.h
diff options
context:
space:
mode:
Diffstat (limited to 'dispatcher/elapi_dispatcher.h')
-rw-r--r--dispatcher/elapi_dispatcher.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/dispatcher/elapi_dispatcher.h b/dispatcher/elapi_dispatcher.h
new file mode 100644
index 0000000..909505a
--- /dev/null
+++ b/dispatcher/elapi_dispatcher.h
@@ -0,0 +1,68 @@
+/* Copyright */
+
+#ifndef ELAPI_DISPATCHER_H
+#define ELAPI_DISPATCHER_H
+
+#include "elapi_collection.h"
+#include "elapi_sink.h"
+
+/* Status values returned by the routing function */
+#define ELAPI_DISPATCHER_SKIP 0
+#define ELAPI_DISPATCHER_DONE 1
+#define ELAPI_DISPATCHER_NEXT 2
+#define ELAPI_DISPATCHER_ERROR 3
+
+
+/* Actions that can be taken against a sink */
+#define ELAPI_SINK_ACTION_ADD 0 /* Add a new sink */
+#define ELAPI_SINK_ACTION_DELETE 1 /* Delete a sink */
+#define ELAPI_SINK_ACTION_DISABLE 2 /* Disable a sink */
+#define ELAPI_SINK_ACTION_PULSE 3 /* Disable a sink temporarily for one call */
+#define ELAPI_SINK_ACTION_ENABLE 4 /* Enable sink */
+
+
+/* Event routing function */
+typedef int (*event_router_fn)(char *sink,
+ char *previous_sink,
+ int previous_status,
+ struct collection_item *event,
+ struct sink_descriptor *sink_data,
+ void *custom_data,
+ int *error);
+
+struct dispatcher_handle {
+ char **sinks;
+ char *appname;
+ event_router_fn router;
+ struct collection_item *sink_list;
+ int sink_counter;
+ void *custom_data;
+};
+
+/* Function to create a dispatcher */
+int create_audit_dispatcher(struct dispatcher_handle **dispatcher, /* Handle of the dispatcher will be stored in this variable */
+ const char *appname, /* Application name. Passed to the sinks to do initialization */
+ char **desired_sinks, /* List of names of the sinks to use. If NULL the default will be used */
+ event_router_fn desired_router, /* The rounting function. If NULL the default will be used */
+ void *custom_data); /* Custom data that can be used in the router function. */
+
+
+/* Function to clean memory associated with the audit dispatcher */
+void destroy_audit_dispatcher(struct dispatcher_handle *dispatcher);
+
+/* Function to log an event */
+void log_audit_event(struct dispatcher_handle *dispatcher, struct collection_item *event);
+
+/* Advanced functions */
+/* Managing the sink collection */
+int alter_audit_dispatcher(struct dispatcher_handle *dispatcher, /* Dispatcher */
+ char *sink, /* Sink to change */
+ int action); /* Action to perform for sink */
+
+/* This function is exposed in case you are providing your own routing callback */
+int log_event_to_sink(struct sink_descriptor *sink_data,
+ struct collection_item *event,
+ void *custom_data);
+
+
+#endif