1 #ifndef OILS_EVENT_HEADER
2 #define OILS_EVENT_HEADER
3 #include "opensrf/osrf_json.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( const char* file, int line, const char* event );
25 /** Creates a new event with payload.
26 * User is responsible for freeing event with oilsEventFree */
27 oilsEvent* oilsNewEvent2( const char* file, int line, const char* event,
28 const jsonObject* payload );
30 /** Creates a new event with permission and permission location.
31 * User is responsible for freeing event with oilsEventFree */
32 oilsEvent* oilsNewEvent3( const char* file, int line, const char* event,
33 const char* perm, int permloc );
35 /** Creates a new event with permission, permission location, and payload.
36 * User is responsible for freeing event with oilsEventFree */
37 oilsEvent* oilsNewEvent4( const char* file, int line, const char* event,
38 const char* perm, int permloc, const jsonObject* payload );
40 /** Sets the permission info for the event */
41 void oilsEventSetPermission( oilsEvent* event, const char* perm, int permloc );
43 /* Sets the payload for the event
44 * This clones the payload, so the user is responsible
45 * for handling the payload object's memory
47 void oilsEventSetPayload( oilsEvent* event, const jsonObject* payload );
49 /** Creates the JSON associated with an event. The JSON should NOT be
50 * freed by the user. It will be freed by oilsEventFree */
51 jsonObject* oilsEventToJSON( oilsEvent* event );
53 /* Frees an event object */
54 void oilsEventFree( oilsEvent* event );