/* 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
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)
*/
/* 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.
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;
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");
-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;