]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/include/openils/oils_utils.h
Merge remote branch 'working/user/shadowspar/ttopac-altcleanup' into template-toolkit...
[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 const char* oilsFMGetStringConst( const jsonObject* object, const char* field );
30
31 char* oilsFMGetString( const jsonObject* object, const char* field );
32
33 const jsonObject* oilsFMGetObject( const jsonObject* object, const char* field );
34
35 /**
36   Sets the given field in the given object to the given string
37   @param object The object to update
38   @param field The field to change
39   @param string The new data
40   @return 0 if the field was updated successfully, -1 on error
41   */
42 int oilsFMSetString( jsonObject* object, const char* field, const char* string );
43
44 /**
45  * Returns the data stored in the id field of the object if it exists
46  * returns -1 if the id field or the id value is not found
47  */
48 long oilsFMGetObjectId( const jsonObject* obj );
49
50
51 /**
52  * Checks if the user has each permission at the given org unit
53  * Passing in a -1 for the orgid means to use the top level org unit
54  * The first permission that fails causes the corresponding permission
55  * failure event to be returned
56  * returns NULL if all permissions succeed
57  */
58 oilsEvent* oilsUtilsCheckPerms( int userid, int orgid, char* permissions[], int size );
59
60
61 /**
62  * Performs a single request and returns the resulting data
63  * Caller is responsible for freeing the returned response object
64  */
65 jsonObject* oilsUtilsQuickReq( const char* service, const char* method,
66                 const jsonObject* params );
67
68 jsonObject* oilsUtilsStorageReq( const char* method, const jsonObject* params );
69
70 jsonObject* oilsUtilsCStoreReq( const char* method, const jsonObject* params );
71
72 /**
73  * Searches the storage server for a user with the given username 
74  * Caller is responsible for freeing the returned object
75  */
76 jsonObject* oilsUtilsFetchUserByUsername( const char* name );
77
78
79 /**
80  * Returns the setting value
81  * Caller must free the returned string
82  */
83 char* oilsUtilsFetchOrgSetting( int orgid, const char* setting );
84
85
86 /**
87  * Logs into the auth server with the given username and password
88  * @return The authtoken string which must be de-allocated by the caller
89  */
90 char* oilsUtilsLogin( const char* uname, const char* passwd, const char* type, int orgId );
91
92
93 /**
94  * Fetches the requested workstation object by id
95  */
96 jsonObject* oilsUtilsFetchWorkstation( long id );
97
98 jsonObject* oilsUtilsFetchUserByBarcode(const char* barcode);
99
100 jsonObject* oilsUtilsFetchWorkstationByName( const char* name );
101
102
103 int oilsUtilsIsDBTrue( const char* val );
104
105 long oilsUtilsIntervalToSeconds( const char* interval );
106
107 #ifdef __cplusplus
108 }
109 #endif
110
111 #endif