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"
12 /* OILS Event structure */
13 struct _oilsEventStruct {
14 char* event; /* the event name */
15 char* perm; /* the permission error name */
16 int permloc; /* the permission location id */
17 jsonObject* payload; /* the payload */
18 jsonObject* json; /* the event as a jsonObject */
22 typedef struct _oilsEventStruct oilsEvent;
25 /** Creates a new event. User is responsible for freeing event with oilsEventFree */
26 oilsEvent* oilsNewEvent( const char* file, int line, const char* event );
28 /** Creates a new event with payload.
29 * User is responsible for freeing event with oilsEventFree */
30 oilsEvent* oilsNewEvent2( const char* file, int line, const char* event,
31 const jsonObject* payload );
33 /** Creates a new event with permission and permission location.
34 * User is responsible for freeing event with oilsEventFree */
35 oilsEvent* oilsNewEvent3( const char* file, int line, const char* event,
36 const char* perm, int permloc );
38 /** Creates a new event with permission, permission location, and payload.
39 * User is responsible for freeing event with oilsEventFree */
40 oilsEvent* oilsNewEvent4( const char* file, int line, const char* event,
41 const char* perm, int permloc, const jsonObject* payload );
43 /** Sets the permission info for the event */
44 void oilsEventSetPermission( oilsEvent* event, const char* perm, int permloc );
46 /* Sets the payload for the event
47 * This clones the payload, so the user is responsible
48 * for handling the payload object's memory
50 void oilsEventSetPayload( oilsEvent* event, const jsonObject* payload );
52 /** Creates the JSON associated with an event. The JSON should NOT be
53 * freed by the user. It will be freed by oilsEventFree */
54 jsonObject* oilsEventToJSON( oilsEvent* event );
56 /* Frees an event object */
57 void oilsEventFree( oilsEvent* event );