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 */
17 typedef struct _oilsEventStruct oilsEvent;
20 /** Creates a new event. User is responsible for freeing event with oilsEventFree */
21 oilsEvent* oilsNewEvent( char* event );
23 /** Creates a new event with payload.
24 * User is responsible for freeing event with oilsEventFree */
25 oilsEvent* oilsNewEvent2( char* event, jsonObject* payload );
27 /** Creates a new event with permission and permission location.
28 * User is responsible for freeing event with oilsEventFree */
29 oilsEvent* oilsNewEvent3( char* event, char* perm, int permloc );
31 /** Creates a new event with permission, permission location, and payload.
32 * User is responsible for freeing event with oilsEventFree */
33 oilsEvent* oilsNewEvent4( char* event, char* perm, int permloc, jsonObject* payload );
35 /** Sets the permission info for the event */
36 void oilsEventSetPermission( oilsEvent* event, char* perm, int permloc );
38 /* Sets the payload for the event
39 * This clones the payload, so the user is responsible
40 * for handling the payload object's memory
42 void oilsEventSetPayload( oilsEvent* event, jsonObject* payload );
44 /** Creates the JSON associated with an event. The JSON should NOT be
45 * freed by the user. It will be freed by oilsEventFree */
46 jsonObject* oilsEventToJSON( oilsEvent* event );
48 /* Parses the events file */
49 void _oilsEventParseEvents();
51 /* Frees an event object */
52 void oilsEventFree( oilsEvent* event );