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