From 8682bc2657f1c67cf03b653214987002d53a7157 Mon Sep 17 00:00:00 2001 From: scottmk Date: Wed, 25 Nov 2009 16:49:13 +0000 Subject: [PATCH] Replace all calls to the old JSON parser with calls to the new one. M Open-ILS/src/c-apps/oils_cstore.c M Open-ILS/src/c-apps/oils_dataloader.c M Open-ILS/src/c-apps/oils_utils.c M Open-ILS/src/c-apps/oils_auth.c M Open-ILS/src/extras/oils_requestor.c git-svn-id: svn://svn.open-ils.org/ILS/trunk@15025 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/c-apps/oils_auth.c | 6 +++--- Open-ILS/src/c-apps/oils_cstore.c | 4 ++-- Open-ILS/src/c-apps/oils_dataloader.c | 4 ++-- Open-ILS/src/c-apps/oils_utils.c | 20 ++++++++++---------- Open-ILS/src/extras/oils_requestor.c | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Open-ILS/src/c-apps/oils_auth.c b/Open-ILS/src/c-apps/oils_auth.c index 2621d6bc0..5f75c3b1e 100644 --- a/Open-ILS/src/c-apps/oils_auth.c +++ b/Open-ILS/src/c-apps/oils_auth.c @@ -299,13 +299,13 @@ static oilsEvent* oilsAuthHandleLoginOK( jsonObject* userObj, const char* uname, "successful login: username=%s, authtoken=%s, workstation=%s", uname, authToken, ws ); oilsFMSetString( userObj, "passwd", "" ); - jsonObject* cacheObj = jsonParseStringFmt("{\"authtime\": %f}", timeout); + jsonObject* cacheObj = jsonParseFmt("{\"authtime\": %f}", timeout); jsonObjectSetKey( cacheObj, "userobj", jsonObjectClone(userObj)); osrfCachePutObject( authKey, cacheObj, timeout ); jsonObjectFree(cacheObj); osrfLogInternal(OSRF_LOG_MARK, "oilsAuthHandleLoginOK(): Placed user object into cache"); - jsonObject* payload = jsonParseStringFmt( + jsonObject* payload = jsonParseFmt( "{ \"authtoken\": \"%s\", \"authtime\": %f }", authToken, timeout ); response = oilsNewEvent2( OSRF_LOG_MARK, OILS_EVENT_SUCCESS, payload ); @@ -340,7 +340,7 @@ static oilsEvent* oilsAuthCheckCard( const char* barcode ) { if(!barcode) return NULL; osrfLogDebug(OSRF_LOG_MARK, "Checking to see if barcode %s is active", barcode); - jsonObject* params = jsonParseStringFmt("{\"barcode\":\"%s\"}", barcode); + jsonObject* params = jsonParseFmt("{\"barcode\":\"%s\"}", barcode); jsonObject* card = oilsUtilsQuickReq( "open-ils.cstore", "open-ils.cstore.direct.actor.card.search", params ); jsonObjectFree(params); diff --git a/Open-ILS/src/c-apps/oils_cstore.c b/Open-ILS/src/c-apps/oils_cstore.c index c3a93938a..6c332e7a0 100644 --- a/Open-ILS/src/c-apps/oils_cstore.c +++ b/Open-ILS/src/c-apps/oils_cstore.c @@ -1393,11 +1393,11 @@ static char* org_tree_root( osrfMethodContext* ctx ) { Utility function: create a JSON_HASH with a single key/value pair. This function is equivalent to: - jsonParseStringFmt( "{\"%s\":\"%s\"}", key, value ) + jsonParseFmt( "{\"%s\":\"%s\"}", key, value ) or, if value is NULL: - jsonParseStringFmt( "{\"%s\":null}", key ) + jsonParseFmt( "{\"%s\":null}", key ) ...but faster because it doesn't create and parse a JSON string. */ diff --git a/Open-ILS/src/c-apps/oils_dataloader.c b/Open-ILS/src/c-apps/oils_dataloader.c index f7713d526..139619140 100644 --- a/Open-ILS/src/c-apps/oils_dataloader.c +++ b/Open-ILS/src/c-apps/oils_dataloader.c @@ -211,7 +211,7 @@ static int startTransaction () { static int sendCommand ( const char* json ) { int ret = 1; - jsonObject* item = jsonParseString(json); + jsonObject* item = jsonParse(json); if (!item->classname) { osrfLogError(OSRF_LOG_MARK, "Data loader cannot handle unclassed objects. Skipping [%s]!", json); @@ -226,7 +226,7 @@ static int sendCommand ( const char* json ) { // make the param array jsonObject* params = jsonNewObjectType( JSON_ARRAY ); jsonObjectSetIndex( params, 0, item ); - jsonObjectSetIndex( params, 1, jsonParseString("{\"quiet\":\"true\"}") ); + jsonObjectSetIndex( params, 1, jsonParse("{\"quiet\":\"true\"}") ); jsonObject* data; int req_id = osrfAppSessionMakeRequest( session, params, method_name, 1, NULL ); diff --git a/Open-ILS/src/c-apps/oils_utils.c b/Open-ILS/src/c-apps/oils_utils.c index 4519b2a38..ac88d8ecd 100644 --- a/Open-ILS/src/c-apps/oils_utils.c +++ b/Open-ILS/src/c-apps/oils_utils.c @@ -79,7 +79,7 @@ oilsEvent* oilsUtilsCheckPerms( int userid, int orgid, char* permissions[], int oilsEvent* evt = NULL; if (orgid == -1) { - jsonObject* where_clause = jsonParseString( "{\"parent_ou\":null}" ); + jsonObject* where_clause = jsonParse( "{\"parent_ou\":null}" ); jsonObject* org = oilsUtilsQuickReq( "open-ils.cstore", "open-ils.cstore.direct.actor.org_unit.search", @@ -95,7 +95,7 @@ oilsEvent* oilsUtilsCheckPerms( int userid, int orgid, char* permissions[], int for( i = 0; i < size && permissions[i]; i++ ) { char* perm = permissions[i]; - jsonObject* params = jsonParseStringFmt("[%d, \"%s\", %d]", userid, perm, orgid); + jsonObject* params = jsonParseFmt("[%d, \"%s\", %d]", userid, perm, orgid); jsonObject* o = oilsUtilsQuickReq( "open-ils.storage", "open-ils.storage.permission.user_has_perm", params ); @@ -139,7 +139,7 @@ jsonObject* oilsUtilsCStoreReq( const char* method, const jsonObject* params ) { jsonObject* oilsUtilsFetchUserByUsername( const char* name ) { if(!name) return NULL; - jsonObject* params = jsonParseStringFmt("{\"usrname\":\"%s\"}", name); + jsonObject* params = jsonParseFmt("{\"usrname\":\"%s\"}", name); jsonObject* user = oilsUtilsQuickReq( "open-ils.cstore", "open-ils.cstore.direct.actor.user.search", params ); @@ -154,7 +154,7 @@ jsonObject* oilsUtilsFetchUserByBarcode(const char* barcode) { osrfLogInfo(OSRF_LOG_MARK, "Fetching user by barcode %s", barcode); - jsonObject* params = jsonParseStringFmt("{\"barcode\":\"%s\"}", barcode); + jsonObject* params = jsonParseFmt("{\"barcode\":\"%s\"}", barcode); jsonObject* card = oilsUtilsQuickReq( "open-ils.cstore", "open-ils.cstore.direct.actor.card.search", params ); jsonObjectFree(params); @@ -167,7 +167,7 @@ jsonObject* oilsUtilsFetchUserByBarcode(const char* barcode) { double iusr = strtod(usr, NULL); free(usr); - params = jsonParseStringFmt("[%f]", iusr); + params = jsonParseFmt("[%f]", iusr); jsonObject* user = oilsUtilsQuickReq( "open-ils.cstore", "open-ils.cstore.direct.actor.user.retrieve", params); @@ -178,7 +178,7 @@ jsonObject* oilsUtilsFetchUserByBarcode(const char* barcode) { char* oilsUtilsFetchOrgSetting( int orgid, const char* setting ) { if(!setting) return NULL; - jsonObject* params = jsonParseStringFmt("[%d, \"%s\"]", orgid, setting ); + jsonObject* params = jsonParseFmt("[%d, \"%s\"]", orgid, setting ); jsonObject* set = oilsUtilsQuickReq( "open-ils.actor", @@ -199,7 +199,7 @@ char* oilsUtilsLogin( const char* uname, const char* passwd, const char* type, i osrfLogDebug(OSRF_LOG_MARK, "Logging in with username %s", uname ); char* token = NULL; - jsonObject* params = jsonParseStringFmt("[\"%s\"]", uname); + jsonObject* params = jsonParseFmt("[\"%s\"]", uname); jsonObject* o = oilsUtilsQuickReq( "open-ils.auth", "open-ils.auth.authenticate.init", params ); @@ -214,7 +214,7 @@ char* oilsUtilsLogin( const char* uname, const char* passwd, const char* type, i jsonObjectFree(params); free(passhash); - params = jsonParseStringFmt( "[\"%s\", \"%s\", \"%s\", \"%d\"]", uname, fullhash, type, orgId ); + params = jsonParseFmt( "[\"%s\", \"%s\", \"%s\", \"%d\"]", uname, fullhash, type, orgId ); o = oilsUtilsQuickReq( "open-ils.auth", "open-ils.auth.authenticate.complete", params ); @@ -233,7 +233,7 @@ char* oilsUtilsLogin( const char* uname, const char* passwd, const char* type, i jsonObject* oilsUtilsFetchWorkstation( long id ) { - jsonObject* p = jsonParseStringFmt("[%ld]", id); + jsonObject* p = jsonParseFmt("[%ld]", id); jsonObject* r = oilsUtilsQuickReq( "open-ils.storage", "open-ils.storage.direct.actor.workstation.retrieve", p ); @@ -242,7 +242,7 @@ jsonObject* oilsUtilsFetchWorkstation( long id ) { } jsonObject* oilsUtilsFetchWorkstationByName( const char* name ) { - jsonObject* p = jsonParseStringFmt("{\"name\":\"%s\"}", name); + jsonObject* p = jsonParseFmt("{\"name\":\"%s\"}", name); jsonObject* r = oilsUtilsCStoreReq( "open-ils.cstore.direct.actor.workstation.search", p); jsonObjectFree(p); diff --git a/Open-ILS/src/extras/oils_requestor.c b/Open-ILS/src/extras/oils_requestor.c index ad052e4dd..cb674a345 100644 --- a/Open-ILS/src/extras/oils_requestor.c +++ b/Open-ILS/src/extras/oils_requestor.c @@ -107,7 +107,7 @@ static int do_request( char* request ) { if( *tmp ) { growing_buffer* buffer = buffer_init(256); buffer_fadd( buffer, "[%s]", tmp ); - params = jsonParseString( buffer->buf ); + params = jsonParse( buffer->buf ); buffer_free(buffer); } -- 2.11.0