[Opensrf-commits] r1574 - in trunk: include/opensrf src/libopensrf

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jan 7 11:27:08 EST 2009


Author: scottmk
Date: 2009-01-07 11:27:06 -0500 (Wed, 07 Jan 2009)
New Revision: 1574

Modified:
   trunk/include/opensrf/osrf_json.h
   trunk/include/opensrf/osrf_legacy_json.h
   trunk/include/opensrf/utils.h
   trunk/src/libopensrf/osrf_json_tools.c
   trunk/src/libopensrf/osrf_legacy_json.c
   trunk/src/libopensrf/utils.c
Log:
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


Modified: trunk/include/opensrf/osrf_json.h
===================================================================
--- trunk/include/opensrf/osrf_json.h	2009-01-06 20:55:03 UTC (rev 1573)
+++ trunk/include/opensrf/osrf_json.h	2009-01-07 16:27:06 UTC (rev 1574)
@@ -359,8 +359,6 @@
 /* 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

Modified: trunk/include/opensrf/osrf_legacy_json.h
===================================================================
--- trunk/include/opensrf/osrf_legacy_json.h	2009-01-06 20:55:03 UTC (rev 1573)
+++ trunk/include/opensrf/osrf_legacy_json.h	2009-01-07 16:27:06 UTC (rev 1574)
@@ -36,12 +36,6 @@
 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) 
  */

Modified: trunk/include/opensrf/utils.h
===================================================================
--- trunk/include/opensrf/utils.h	2009-01-06 20:55:03 UTC (rev 1573)
+++ trunk/include/opensrf/utils.h	2009-01-07 16:27:06 UTC (rev 1574)
@@ -260,13 +260,7 @@
 /* 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.
   The returned string must be freed by the caller.

Modified: trunk/src/libopensrf/osrf_json_tools.c
===================================================================
--- trunk/src/libopensrf/osrf_json_tools.c	2009-01-06 20:55:03 UTC (rev 1573)
+++ trunk/src/libopensrf/osrf_json_tools.c	2009-01-07 16:27:06 UTC (rev 1574)
@@ -164,16 +164,6 @@
 	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;	
 

Modified: trunk/src/libopensrf/osrf_legacy_json.c
===================================================================
--- trunk/src/libopensrf/osrf_legacy_json.c	2009-01-06 20:55:03 UTC (rev 1573)
+++ trunk/src/libopensrf/osrf_legacy_json.c	2009-01-07 16:27:06 UTC (rev 1574)
@@ -703,21 +703,6 @@
 	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");

Modified: trunk/src/libopensrf/utils.c
===================================================================
--- trunk/src/libopensrf/utils.c	2009-01-06 20:55:03 UTC (rev 1573)
+++ trunk/src/libopensrf/utils.c	2009-01-07 16:27:06 UTC (rev 1574)
@@ -479,31 +479,6 @@
 	
 
 
-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;



More information about the opensrf-commits mailing list