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