]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/c-apps/oils_utils.c
adding first round of stage one display template
[working/Evergreen.git] / Open-ILS / src / c-apps / oils_utils.c
1 #include "oils_utils.h"
2
3 char* oilsFMGetString( jsonObject* object, char* field ) {
4         return jsonObjectToSimpleString(oilsFMGetObject( object, field ));
5 }
6
7
8 jsonObject* oilsFMGetObject( jsonObject* object, char* field ) {
9         if(!(object && field)) return NULL;
10         if( object->type != JSON_ARRAY || !object->classname ) return NULL;
11         int pos = fm_ntop(object->classname, field);
12         if( pos > -1 ) return jsonObjectGetIndex( object, pos );
13         return NULL;
14 }
15
16
17 int oilsFMSetString( jsonObject* object, char* field, char* string ) {
18         if(!(object && field && string)) return -1;
19         int pos = fm_ntop(object->classname, field);
20         if( pos > -1 ) {
21                 jsonObjectSetIndex( object, pos, jsonNewObject(string) );
22                 return 0;
23         }
24         return -1;
25 }