YAJL 2.0.0
|
00001 /* 00002 * Copyright (c) 2007-2011, Lloyd Hilaiel <lloyd@hilaiel.com> 00003 * 00004 * Permission to use, copy, modify, and/or distribute this software for any 00005 * purpose with or without fee is hereby granted, provided that the above 00006 * copyright notice and this permission notice appear in all copies. 00007 * 00008 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 00009 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 00010 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 00011 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 00012 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 00013 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 00014 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00015 */ 00016 00022 #include <yajl/yajl_common.h> 00023 00024 #ifndef __YAJL_PARSE_H__ 00025 #define __YAJL_PARSE_H__ 00026 00027 #include <stddef.h> 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 typedef enum { 00035 yajl_status_ok, 00037 yajl_status_client_canceled, 00040 yajl_status_error 00041 } yajl_status; 00042 00044 YAJL_API const char * yajl_status_to_string(yajl_status code); 00045 00047 typedef struct yajl_handle_t * yajl_handle; 00048 00074 typedef struct { 00075 int (* yajl_null)(void * ctx); 00076 int (* yajl_boolean)(void * ctx, int boolVal); 00077 int (* yajl_integer)(void * ctx, long long integerVal); 00078 int (* yajl_double)(void * ctx, double doubleVal); 00081 int (* yajl_number)(void * ctx, const char * numberVal, 00082 size_t numberLen); 00083 00086 int (* yajl_string)(void * ctx, const unsigned char * stringVal, 00087 size_t stringLen); 00088 00089 int (* yajl_start_map)(void * ctx); 00090 int (* yajl_map_key)(void * ctx, const unsigned char * key, 00091 size_t stringLen); 00092 int (* yajl_end_map)(void * ctx); 00093 00094 int (* yajl_start_array)(void * ctx); 00095 int (* yajl_end_array)(void * ctx); 00096 } yajl_callbacks; 00097 00107 YAJL_API yajl_handle yajl_alloc(const yajl_callbacks * callbacks, 00108 yajl_alloc_funcs * afs, 00109 void * ctx); 00110 00111 00115 typedef enum { 00123 yajl_allow_comments = 0x01, 00133 yajl_dont_validate_strings = 0x02, 00141 yajl_allow_trailing_garbage = 0x04, 00151 yajl_allow_multiple_values = 0x08, 00159 yajl_allow_partial_values = 0x10 00160 } yajl_option; 00161 00166 YAJL_API int yajl_config(yajl_handle h, yajl_option opt, ...); 00167 00169 YAJL_API void yajl_free(yajl_handle handle); 00170 00176 YAJL_API yajl_status yajl_parse(yajl_handle hand, 00177 const unsigned char * jsonText, 00178 size_t jsonTextLength); 00179 00189 YAJL_API yajl_status yajl_complete_parse(yajl_handle hand); 00190 00201 YAJL_API unsigned char * yajl_get_error(yajl_handle hand, int verbose, 00202 const unsigned char * jsonText, 00203 size_t jsonTextLength); 00204 00217 YAJL_API size_t yajl_get_bytes_consumed(yajl_handle hand); 00218 00220 YAJL_API void yajl_free_error(yajl_handle hand, unsigned char * str); 00221 00222 #ifdef __cplusplus 00223 } 00224 #endif 00225 00226 #endif