From a583982562f73931c32814a509f1195aeecfe4af Mon Sep 17 00:00:00 2001 From: scottmk Date: Wed, 7 Jan 2009 16:27:06 +0000 Subject: [PATCH] Eliminated four dead functions that are never called except by each other: json_parse_file() jsonParseFile() legacy_jsonParseFile() file_to_string() The files affected: utils.h utils.c osrf_json.h osrf_json_tools.c osrf_legacy_json.h osrf_legacy_json.c git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1574 9efc2488-bf62-4759-914b-345cdb29e865 --- include/opensrf/osrf_json.h | 2 -- include/opensrf/osrf_legacy_json.h | 6 ------ include/opensrf/utils.h | 6 ------ src/libopensrf/osrf_json_tools.c | 10 ---------- src/libopensrf/osrf_legacy_json.c | 15 --------------- src/libopensrf/utils.c | 25 ------------------------- 6 files changed, 64 deletions(-) diff --git a/include/opensrf/osrf_json.h b/include/opensrf/osrf_json.h index 4fadfda..46e41a3 100644 --- a/include/opensrf/osrf_json.h +++ b/include/opensrf/osrf_json.h @@ -359,8 +359,6 @@ char* jsonFormatString( const char* jsonString ); /* sets the error handler for all parsers */ void jsonSetGlobalErrorHandler(void (*errorHandler) (const char*)); -jsonObject* jsonParseFile( const char* filename ); - /* ------------------------------------------------------------------------- */ /** * The following methods provide a facility for serializing and diff --git a/include/opensrf/osrf_legacy_json.h b/include/opensrf/osrf_legacy_json.h index a825a8d..a74fb1f 100644 --- a/include/opensrf/osrf_legacy_json.h +++ b/include/opensrf/osrf_legacy_json.h @@ -36,12 +36,6 @@ jsonObject* json_parse_string(char* string); jsonObject* legacy_jsonParseString(const char* string); jsonObject* legacy_jsonParseStringFmt( const char* string, ... ); -jsonObject* json_parse_file( const char* filename ); - -jsonObject* legacy_jsonParseFile( const char* string ); - - - /* does the actual parsing work. returns 0 on success. -1 on error and * -2 if there was no object to build (string was all comments) */ diff --git a/include/opensrf/utils.h b/include/opensrf/utils.h index cb639a0..ab24e8f 100644 --- a/include/opensrf/utils.h +++ b/include/opensrf/utils.h @@ -260,12 +260,6 @@ double get_timestamp_millis( void ); /* returns true if the whole string is a number */ int stringisnum(const char* s); -/* reads a file and returns the string version of the file - user is responsible for freeing the returned char* - */ -char* file_to_string(const char* filename); - - /** Calculates the md5 of the text provided. diff --git a/src/libopensrf/osrf_json_tools.c b/src/libopensrf/osrf_json_tools.c index 91b3f26..475f5de 100644 --- a/src/libopensrf/osrf_json_tools.c +++ b/src/libopensrf/osrf_json_tools.c @@ -164,16 +164,6 @@ static jsonObject* _jsonObjectEncodeClass( const jsonObject* obj, int ignoreClas return newObj; } -jsonObject* jsonParseFile( const char* filename ) { - if(!filename) return NULL; - char* data = file_to_string(filename); - jsonObject* o = jsonParseString(data); - free(data); - return o; -} - - - jsonObject* jsonObjectFindPath( const jsonObject* obj, const char* format, ...) { if(!obj || !format || strlen(format) < 1) return NULL; diff --git a/src/libopensrf/osrf_legacy_json.c b/src/libopensrf/osrf_legacy_json.c index 17dab25..31d62b1 100644 --- a/src/libopensrf/osrf_legacy_json.c +++ b/src/libopensrf/osrf_legacy_json.c @@ -703,21 +703,6 @@ int json_handle_error(char* string, unsigned long* index, char* err_msg) { return -1; } - -jsonObject* legacy_jsonParseFile( const char* filename ) { - return json_parse_file( filename ); -} - -jsonObject* json_parse_file(const char* filename) { - if(!filename) return NULL; - char* data = file_to_string(filename); - jsonObject* o = json_parse_string(data); - free(data); - return o; -} - - - char* legacy_jsonObjectToJSON( const jsonObject* obj ) { if(obj == NULL) return strdup("null"); diff --git a/src/libopensrf/utils.c b/src/libopensrf/utils.c index 28d963a..39a9235 100644 --- a/src/libopensrf/utils.c +++ b/src/libopensrf/utils.c @@ -479,31 +479,6 @@ int stringisnum(const char* s) { -char* file_to_string(const char* filename) { - - if(!filename) return NULL; - - FILE * file = fopen( filename, "r" ); - if( !file ) { - osrfLogError( OSRF_LOG_MARK, "Unable to open file [%s]", filename ); - return NULL; - } - - size_t num_read; - char buf[ BUFSIZ + 1 ]; - growing_buffer* gb = buffer_init(sizeof(buf)); - - while( ( num_read = fread( buf, 1, sizeof(buf) - 1, file) ) ) { - buf[ num_read ] = '\0'; - buffer_add(gb, buf); - } - - fclose(file); - - return buffer_release(gb); -} - - char* md5sum( const char* text, ... ) { struct md5_ctx ctx; -- 2.43.2