[open-ils-commits] r8113 - in trunk/Open-ILS/src/c-apps: . openils
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Nov 25 16:30:16 EST 2007
Author: miker
Date: 2007-11-25 16:11:57 -0500 (Sun, 25 Nov 2007)
New Revision: 8113
Modified:
trunk/Open-ILS/src/c-apps/oils_utils.c
trunk/Open-ILS/src/c-apps/openils/oils_utils.h
Log:
Patch from Scott McKellar to inject more tasty const correctness
Modified: trunk/Open-ILS/src/c-apps/oils_utils.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_utils.c 2007-11-21 18:28:04 UTC (rev 8112)
+++ trunk/Open-ILS/src/c-apps/oils_utils.c 2007-11-25 21:11:57 UTC (rev 8113)
@@ -25,12 +25,12 @@
return oilsIDL();
}
-char* oilsFMGetString( jsonObject* object, char* field ) {
+char* oilsFMGetString( const jsonObject* object, const char* field ) {
return jsonObjectToSimpleString(oilsFMGetObject( object, field ));
}
-jsonObject* oilsFMGetObject( jsonObject* object, char* field ) {
+const jsonObject* oilsFMGetObject( const jsonObject* object, const char* field ) {
if(!(object && field)) return NULL;
if( object->type != JSON_ARRAY || !object->classname ) return NULL;
int pos = fm_ntop(object->classname, field);
@@ -39,7 +39,7 @@
}
-int oilsFMSetString( jsonObject* object, char* field, char* string ) {
+int oilsFMSetString( jsonObject* object, const char* field, const char* string ) {
if(!(object && field && string)) return -1;
osrfLogInternal(OSRF_LOG_MARK, "oilsFMSetString(): Collecing position for field %s", field);
int pos = fm_ntop(object->classname, field);
@@ -53,13 +53,13 @@
}
-int oilsUtilsIsDBTrue( char* val ) {
+int oilsUtilsIsDBTrue( const char* val ) {
if( val && strcasecmp(val, "f") && strcmp(val, "0") ) return 1;
return 0;
}
-long oilsFMGetObjectId( jsonObject* obj ) {
+long oilsFMGetObjectId( const jsonObject* obj ) {
long id = -1;
if(!obj) return id;
char* ids = oilsFMGetString( obj, "id" );
@@ -96,7 +96,8 @@
return evt;
}
-jsonObject* oilsUtilsQuickReq( char* service, char* method, jsonObject* params ) {
+jsonObject* oilsUtilsQuickReq( const char* service, const char* method,
+ const jsonObject* params ) {
if(!(service && method)) return NULL;
osrfLogDebug(OSRF_LOG_MARK, "oilsUtilsQuickReq(): %s - %s", service, method );
osrfAppSession* session = osrfAppSessionClientInit( service );
@@ -108,17 +109,17 @@
return result;
}
-jsonObject* oilsUtilsStorageReq( char* method, jsonObject* params ) {
+jsonObject* oilsUtilsStorageReq( const char* method, const jsonObject* params ) {
return oilsUtilsQuickReq( "open-ils.storage", method, params );
}
-jsonObject* oilsUtilsCStoreReq( char* method, jsonObject* params ) {
+jsonObject* oilsUtilsCStoreReq( const char* method, const jsonObject* params ) {
return oilsUtilsQuickReq("open-ils.cstore", method, params);
}
-jsonObject* oilsUtilsFetchUserByUsername( char* name ) {
+jsonObject* oilsUtilsFetchUserByUsername( const char* name ) {
if(!name) return NULL;
jsonObject* params = jsonParseStringFmt("{\"usrname\":\"%s\"}", name);
jsonObject* user = oilsUtilsQuickReq(
@@ -130,7 +131,7 @@
return user;
}
-jsonObject* oilsUtilsFetchUserByBarcode(char* barcode) {
+jsonObject* oilsUtilsFetchUserByBarcode(const char* barcode) {
if(!barcode) return NULL;
osrfLogInfo(OSRF_LOG_MARK, "Fetching user by barcode %s", barcode);
@@ -155,7 +156,7 @@
return user;
}
-char* oilsUtilsFetchOrgSetting( int orgid, char* setting ) {
+char* oilsUtilsFetchOrgSetting( int orgid, const char* setting ) {
if(!setting) return NULL;
jsonObject* params = jsonParseStringFmt(
@@ -175,7 +176,7 @@
-char* oilsUtilsLogin( char* uname, char* passwd, char* type, int orgId ) {
+char* oilsUtilsLogin( const char* uname, const char* passwd, const char* type, int orgId ) {
if(!(uname && passwd)) return NULL;
osrfLogDebug(OSRF_LOG_MARK, "Logging in with username %s", uname );
@@ -186,7 +187,7 @@
jsonObject* o = oilsUtilsQuickReq(
"open-ils.auth", "open-ils.auth.authenticate.init", params );
- char* seed = jsonObjectGetString(o);
+ const char* seed = jsonObjectGetString(o);
char* passhash = md5sum(passwd);
char buf[256];
snprintf(buf, sizeof(buf), "%s%s", seed, passhash);
@@ -201,7 +202,7 @@
"open-ils.auth.authenticate.complete", params );
if(o) {
- char* tok = jsonObjectGetString(
+ const char* tok = jsonObjectGetString(
jsonObjectGetKey(jsonObjectGetKey(o,"payload"), "authtoken"));
if(tok) token = strdup(tok);
}
@@ -223,7 +224,7 @@
return r;
}
-jsonObject* oilsUtilsFetchWorkstationByName( char* name ) {
+jsonObject* oilsUtilsFetchWorkstationByName( const char* name ) {
jsonObject* p = jsonParseStringFmt("[\"%s\"]", name);
jsonObject* r = oilsUtilsStorageReq(
"open-ils.storage.direct.actor.workstation.search.name", p );
Modified: trunk/Open-ILS/src/c-apps/openils/oils_utils.h
===================================================================
--- trunk/Open-ILS/src/c-apps/openils/oils_utils.h 2007-11-21 18:28:04 UTC (rev 8112)
+++ trunk/Open-ILS/src/c-apps/openils/oils_utils.h 2007-11-25 21:11:57 UTC (rev 8113)
@@ -28,7 +28,7 @@
@return The string at the given position, if none exists,
then NULL is returned. The caller must free the returned string
*/
-char* oilsFMGetString( jsonObject* object, char* field );
+char* oilsFMGetString( const jsonObject* object, const char* field );
/**
@@ -39,7 +39,7 @@
@return The found object or NULL if none exists. Do NOT free the
returned object.
*/
-jsonObject* oilsFMGetObject( jsonObject* object, char* field );
+const jsonObject* oilsFMGetObject( const jsonObject* object, const char* field );
/**
Sets the given field in the given object to the given string
@@ -48,13 +48,13 @@
@param string The new data
@return 0 if the field was updated successfully, -1 on error
*/
-int oilsFMSetString( jsonObject* object, char* field, char* string );
+int oilsFMSetString( jsonObject* object, const char* field, const char* string );
/**
* Returns the data stored in the id field of the object if it exists
* returns -1 if the id field or the id value is not found
*/
-long oilsFMGetObjectId( jsonObject* obj );
+long oilsFMGetObjectId( const jsonObject* obj );
/**
@@ -71,31 +71,32 @@
* Performs a single request and returns the resulting data
* Caller is responsible for freeing the returned response object
*/
-jsonObject* oilsUtilsQuickReq( char* service, char* method, jsonObject* params );
+jsonObject* oilsUtilsQuickReq( const char* service, const char* method,
+ const jsonObject* params );
-jsonObject* oilsUtilsStorageReq( char* method, jsonObject* params );
+jsonObject* oilsUtilsStorageReq( const char* method, const jsonObject* params );
-jsonObject* oilsUtilsCStoreReq( char* method, jsonObject* params );
+jsonObject* oilsUtilsCStoreReq( const char* method, const jsonObject* params );
/**
* Searches the storage server for a user with the given username
* Caller is responsible for freeing the returned object
*/
-jsonObject* oilsUtilsFetchUserByUsername( char* name );
+jsonObject* oilsUtilsFetchUserByUsername( const char* name );
/**
* Returns the setting value
* Caller must free the returned string
*/
-char* oilsUtilsFetchOrgSetting( int orgid, char* setting );
+char* oilsUtilsFetchOrgSetting( int orgid, const char* setting );
/**
* Logs into the auth server with the given username and password
* @return The authtoken string which must be de-allocated by the caller
*/
-char* oilsUtilsLogin( char* uname, char* passwd, char* type, int orgId );
+char* oilsUtilsLogin( const char* uname, const char* passwd, const char* type, int orgId );
/**
@@ -103,9 +104,9 @@
*/
jsonObject* oilsUtilsFetchWorkstation( long id );
-jsonObject* oilsUtilsFetchUserByBarcode(char* barcode);
+jsonObject* oilsUtilsFetchUserByBarcode(const char* barcode);
-jsonObject* oilsUtilsFetchWorkstationByName( char* name );
+jsonObject* oilsUtilsFetchWorkstationByName( const char* name );
-int oilsUtilsIsDBTrue( char* val );
+int oilsUtilsIsDBTrue( const char* val );
More information about the open-ils-commits
mailing list