]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/c-apps/oils_utils.c
added some log statements, fixed some typos
[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         osrfLogInternal("oilsFMSetString(): Collecing position for field %s", field);
20         int pos = fm_ntop(object->classname, field);
21         if( pos > -1 ) {
22                 osrfLogInternal("oilsFMSetString(): Setting string "
23                                 "%s at field %s [position %d]", string, field, pos );
24                 jsonObjectSetIndex( object, pos, jsonNewObject(string) );
25                 return 0;
26         }
27         return -1;
28 }