]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/include/openils/oils_utils.h
Support IS NULL and IS NOT NULL expressions.
[working/Evergreen.git] / Open-ILS / include / openils / oils_utils.h
1 #include "opensrf/osrf_json.h"
2 #include "opensrf/log.h"
3
4 #ifndef OILS_UTILS_H
5 #define OILS_UTILS_H
6
7 // XXX replacing this with liboils_idl implementation
8 // #include "openils/fieldmapper_lookup.h"
9
10 #include "openils/idl_fieldmapper.h"
11
12 #include "oils_event.h"
13 #include "oils_constants.h"
14 #include "opensrf/osrf_app_session.h"
15 #include "opensrf/osrf_settings.h"
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 /**
22   Loads the IDL. Returns NULL on failure
23   or a pointer to the IDL data structure on success.
24   @param idl_filename If not provided, we'll fetch the 
25   filename from the settings server
26  */
27 osrfHash* oilsInitIDL( const char* idl_filename );
28
29 /**
30   Returns the string value for field 'field' in the given object.
31   This method calls jsonObjectToSimpleString so numbers will be
32   returned as strings.
33   @param object The object to inspect
34   @param field The field whose value is requsted
35   @return The string at the given position, if none exists, 
36   then NULL is returned.  The caller must free the returned string
37   */
38 char* oilsFMGetString( const jsonObject* object, const char* field );
39
40
41 /**
42   Returns the jsonObject found at the specified field in the
43   given object.
44   @param object The object to inspect
45   @param field The field whose value is requsted
46   @return The found object or NULL if none exists.  Do NOT free the 
47   returned object.
48   */
49 const jsonObject* oilsFMGetObject( const jsonObject* object, const char* field );
50
51 /**
52   Sets the given field in the given object to the given string
53   @param object The object to update
54   @param field The field to change
55   @param string The new data
56   @return 0 if the field was updated successfully, -1 on error
57   */
58 int oilsFMSetString( jsonObject* object, const char* field, const char* string );
59
60 /**
61  * Returns the data stored in the id field of the object if it exists
62  * returns -1 if the id field or the id value is not found
63  */
64 long oilsFMGetObjectId( const jsonObject* obj );
65
66
67 /**
68  * Checks if the user has each permission at the given org unit
69  * Passing in a -1 for the orgid means to use the top level org unit
70  * The first permission that fails causes the corresponding permission
71  * failure event to be returned
72  * returns NULL if all permissions succeed
73  */
74 oilsEvent* oilsUtilsCheckPerms( int userid, int orgid, char* permissions[], int size );
75
76
77 /**
78  * Performs a single request and returns the resulting data
79  * Caller is responsible for freeing the returned response object
80  */
81 jsonObject* oilsUtilsQuickReq( const char* service, const char* method,
82                 const jsonObject* params );
83
84 jsonObject* oilsUtilsStorageReq( const char* method, const jsonObject* params );
85
86 jsonObject* oilsUtilsCStoreReq( const char* method, const jsonObject* params );
87
88 /**
89  * Searches the storage server for a user with the given username 
90  * Caller is responsible for freeing the returned object
91  */
92 jsonObject* oilsUtilsFetchUserByUsername( const char* name );
93
94
95 /**
96  * Returns the setting value
97  * Caller must free the returned string
98  */
99 char* oilsUtilsFetchOrgSetting( int orgid, const char* setting );
100
101
102 /**
103  * Logs into the auth server with the given username and password
104  * @return The authtoken string which must be de-allocated by the caller
105  */
106 char* oilsUtilsLogin( const char* uname, const char* passwd, const char* type, int orgId );
107
108
109 /**
110  * Fetches the requested workstation object by id
111  */
112 jsonObject* oilsUtilsFetchWorkstation( long id );
113
114 jsonObject* oilsUtilsFetchUserByBarcode(const char* barcode);
115
116 jsonObject* oilsUtilsFetchWorkstationByName( const char* name );
117
118
119 int oilsUtilsIsDBTrue( const char* val );
120
121 #ifdef __cplusplus
122 }
123 #endif
124
125 #endif