1 #ifndef OILS_EVENT_HEADER
2 #define OILS_EVENT_HEADER
3 #include "objson/object.h"
4 #include "opensrf/utils.h"
5 #include "opensrf/log.h"
6 #include "opensrf/osrf_hash.h"
9 /* OILS Event structure */
10 struct _oilsEventStruct {
11 char* event; /* the event name */
12 char* perm; /* the permission error name */
13 int permloc; /* the permission location id */
14 jsonObject* payload; /* the payload */
15 jsonObject* json; /* the event as a jsonObject */
19 typedef struct _oilsEventStruct oilsEvent;
22 /** Creates a new event. User is responsible for freeing event with oilsEventFree */
23 oilsEvent* oilsNewEvent( char* file, int line, char* event );
25 /** Creates a new event with payload.
26 * User is responsible for freeing event with oilsEventFree */
27 oilsEvent* oilsNewEvent2( char* file, int line, char* event, jsonObject* payload );
29 /** Creates a new event with permission and permission location.
30 * User is responsible for freeing event with oilsEventFree */
31 oilsEvent* oilsNewEvent3( char* file, int line, char* event, char* perm, int permloc );
33 /** Creates a new event with permission, permission location, and payload.
34 * User is responsible for freeing event with oilsEventFree */
35 oilsEvent* oilsNewEvent4( char* file, int line,
36 char* event, char* perm, int permloc, jsonObject* payload );
38 /** Sets the permission info for the event */
39 void oilsEventSetPermission( oilsEvent* event, char* perm, int permloc );
41 /* Sets the payload for the event
42 * This clones the payload, so the user is responsible
43 * for handling the payload object's memory
45 void oilsEventSetPayload( oilsEvent* event, jsonObject* payload );
47 /** Creates the JSON associated with an event. The JSON should NOT be
48 * freed by the user. It will be freed by oilsEventFree */
49 jsonObject* oilsEventToJSON( oilsEvent* event );
51 /* Parses the events file */
52 void _oilsEventParseEvents();
54 /* Frees an event object */
55 void oilsEventFree( oilsEvent* event );