renamed hcl_json_t to hcl_jsoner_t
This commit is contained in:
parent
f87fdba5cb
commit
fa726cd82b
@ -118,6 +118,13 @@ hclc_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
|
||||
hclc_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||
hclc_LDADD = $(LIBADD_LIB_COMMON) $(PTHREAD_LIBS) -lhcl -lhclex
|
||||
hclc_DEPENDENCIES = libhclex.la
|
||||
|
||||
bin_PROGRAMS += hclj
|
||||
hclj_SOURCES = main-j.c
|
||||
hclj_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
|
||||
hclj_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||
hclj_LDADD = $(LIBADD_LIB_COMMON) $(PTHREAD_LIBS) -lhcl -lhclex
|
||||
hclj_DEPENDENCIES = libhclex.la
|
||||
endif
|
||||
|
||||
|
||||
|
@ -98,7 +98,7 @@ host_triplet = @host@
|
||||
bin_PROGRAMS = hcl$(EXEEXT) $(am__EXEEXT_1)
|
||||
@ENABLE_HCLEX_TRUE@am__append_5 = libhclex.la
|
||||
@ENABLE_HCLEX_TRUE@am__append_6 = hcl-c.h hcl-s.h hcl-tmr.h hcl-xutl.h hcl-json.h
|
||||
@ENABLE_HCLEX_TRUE@am__append_7 = hcls hclc
|
||||
@ENABLE_HCLEX_TRUE@am__append_7 = hcls hclc hclj
|
||||
subdir = lib
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
|
||||
@ -176,7 +176,8 @@ libhclex_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(libhclex_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
@ENABLE_HCLEX_TRUE@am_libhclex_la_rpath = -rpath $(pkglibdir)
|
||||
@ENABLE_HCLEX_TRUE@am__EXEEXT_1 = hcls$(EXEEXT) hclc$(EXEEXT)
|
||||
@ENABLE_HCLEX_TRUE@am__EXEEXT_1 = hcls$(EXEEXT) hclc$(EXEEXT) \
|
||||
@ENABLE_HCLEX_TRUE@ hclj$(EXEEXT)
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am_hcl_OBJECTS = hcl-main.$(OBJEXT)
|
||||
hcl_OBJECTS = $(am_hcl_OBJECTS)
|
||||
@ -189,6 +190,12 @@ hclc_OBJECTS = $(am_hclc_OBJECTS)
|
||||
hclc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(hclc_LDFLAGS) $(LDFLAGS) -o $@
|
||||
am__hclj_SOURCES_DIST = main-j.c
|
||||
@ENABLE_HCLEX_TRUE@am_hclj_OBJECTS = hclj-main-j.$(OBJEXT)
|
||||
hclj_OBJECTS = $(am_hclj_OBJECTS)
|
||||
hclj_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(hclj_LDFLAGS) $(LDFLAGS) -o $@
|
||||
am__hcls_SOURCES_DIST = main-s.c
|
||||
@ENABLE_HCLEX_TRUE@am_hcls_OBJECTS = hcls-main-s.$(OBJEXT)
|
||||
hcls_OBJECTS = $(am_hcls_OBJECTS)
|
||||
@ -230,10 +237,10 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
am__v_CCLD_1 =
|
||||
SOURCES = $(libhcl_la_SOURCES) $(libhclex_la_SOURCES) $(hcl_SOURCES) \
|
||||
$(hclc_SOURCES) $(hcls_SOURCES)
|
||||
$(hclc_SOURCES) $(hclj_SOURCES) $(hcls_SOURCES)
|
||||
DIST_SOURCES = $(libhcl_la_SOURCES) $(am__libhclex_la_SOURCES_DIST) \
|
||||
$(hcl_SOURCES) $(am__hclc_SOURCES_DIST) \
|
||||
$(am__hcls_SOURCES_DIST)
|
||||
$(am__hclj_SOURCES_DIST) $(am__hcls_SOURCES_DIST)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
@ -410,6 +417,7 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
@ -498,6 +506,11 @@ hcl_DEPENDENCIES = libhcl.la
|
||||
@ENABLE_HCLEX_TRUE@hclc_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||
@ENABLE_HCLEX_TRUE@hclc_LDADD = $(LIBADD_LIB_COMMON) $(PTHREAD_LIBS) -lhcl -lhclex
|
||||
@ENABLE_HCLEX_TRUE@hclc_DEPENDENCIES = libhclex.la
|
||||
@ENABLE_HCLEX_TRUE@hclj_SOURCES = main-j.c
|
||||
@ENABLE_HCLEX_TRUE@hclj_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
|
||||
@ENABLE_HCLEX_TRUE@hclj_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||
@ENABLE_HCLEX_TRUE@hclj_LDADD = $(LIBADD_LIB_COMMON) $(PTHREAD_LIBS) -lhcl -lhclex
|
||||
@ENABLE_HCLEX_TRUE@hclj_DEPENDENCIES = libhclex.la
|
||||
all: hcl-cfg.h
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
@ -646,6 +659,10 @@ hclc$(EXEEXT): $(hclc_OBJECTS) $(hclc_DEPENDENCIES) $(EXTRA_hclc_DEPENDENCIES)
|
||||
@rm -f hclc$(EXEEXT)
|
||||
$(AM_V_CCLD)$(hclc_LINK) $(hclc_OBJECTS) $(hclc_LDADD) $(LIBS)
|
||||
|
||||
hclj$(EXEEXT): $(hclj_OBJECTS) $(hclj_DEPENDENCIES) $(EXTRA_hclj_DEPENDENCIES)
|
||||
@rm -f hclj$(EXEEXT)
|
||||
$(AM_V_CCLD)$(hclj_LINK) $(hclj_OBJECTS) $(hclj_LDADD) $(LIBS)
|
||||
|
||||
hcls$(EXEEXT): $(hcls_OBJECTS) $(hcls_DEPENDENCIES) $(EXTRA_hcls_DEPENDENCIES)
|
||||
@rm -f hcls$(EXEEXT)
|
||||
$(AM_V_CCLD)$(hcls_LINK) $(hcls_OBJECTS) $(hcls_LDADD) $(LIBS)
|
||||
@ -658,6 +675,7 @@ distclean-compile:
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hcl-main.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hclc-main-c.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hclj-main-j.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hcls-main-s.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-bigint.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-comp.Plo@am__quote@
|
||||
@ -920,6 +938,20 @@ hclc-main-c.obj: main-c.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hclc-main-c.obj `if test -f 'main-c.c'; then $(CYGPATH_W) 'main-c.c'; else $(CYGPATH_W) '$(srcdir)/main-c.c'; fi`
|
||||
|
||||
hclj-main-j.o: main-j.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclj_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hclj-main-j.o -MD -MP -MF $(DEPDIR)/hclj-main-j.Tpo -c -o hclj-main-j.o `test -f 'main-j.c' || echo '$(srcdir)/'`main-j.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hclj-main-j.Tpo $(DEPDIR)/hclj-main-j.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main-j.c' object='hclj-main-j.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclj_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hclj-main-j.o `test -f 'main-j.c' || echo '$(srcdir)/'`main-j.c
|
||||
|
||||
hclj-main-j.obj: main-j.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclj_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hclj-main-j.obj -MD -MP -MF $(DEPDIR)/hclj-main-j.Tpo -c -o hclj-main-j.obj `if test -f 'main-j.c'; then $(CYGPATH_W) 'main-j.c'; else $(CYGPATH_W) '$(srcdir)/main-j.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hclj-main-j.Tpo $(DEPDIR)/hclj-main-j.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main-j.c' object='hclj-main-j.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclj_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hclj-main-j.obj `if test -f 'main-j.c'; then $(CYGPATH_W) 'main-j.c'; else $(CYGPATH_W) '$(srcdir)/main-j.c'; fi`
|
||||
|
||||
hcls-main-s.o: main-s.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcls_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hcls-main-s.o -MD -MP -MF $(DEPDIR)/hcls-main-s.Tpo -c -o hcls-main-s.o `test -f 'main-s.c' || echo '$(srcdir)/'`main-s.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hcls-main-s.Tpo $(DEPDIR)/hcls-main-s.Po
|
||||
|
188
lib/hcl-json.h
188
lib/hcl-json.h
@ -29,25 +29,25 @@
|
||||
|
||||
#include <hcl.h>
|
||||
|
||||
typedef struct hcl_json_t hcl_json_t;
|
||||
typedef struct hcl_jsoner_t hcl_jsoner_t;
|
||||
|
||||
enum hcl_json_option_t
|
||||
enum hcl_jsoner_option_t
|
||||
{
|
||||
HCL_JSON_TRAIT,
|
||||
HCL_JSON_LOG_MASK,
|
||||
};
|
||||
typedef enum hcl_json_option_t hcl_json_option_t;
|
||||
typedef enum hcl_jsoner_option_t hcl_jsoner_option_t;
|
||||
|
||||
enum hcl_json_trait_t
|
||||
enum hcl_jsoner_trait_t
|
||||
{
|
||||
/* no trait defined at this moment. XXXX is just a placeholder */
|
||||
HCL_JSON_XXXX = (1 << 0)
|
||||
};
|
||||
typedef enum hcl_json_trait_t hcl_json_trait_t;
|
||||
typedef enum hcl_jsoner_trait_t hcl_jsoner_trait_t;
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
enum hcl_json_state_t
|
||||
enum hcl_jsoner_state_t
|
||||
{
|
||||
HCL_JSON_STATE_START,
|
||||
HCL_JSON_STATE_ARRAY_STARTED,
|
||||
@ -57,109 +57,109 @@ enum hcl_json_state_t
|
||||
HCL_JSON_STATE_IN_NUMERIC_VALUE,
|
||||
HCL_JSON_STATE_IN_QUOTED_VALUE
|
||||
};
|
||||
typedef enum hcl_json_state_t hcl_json_state_t;
|
||||
typedef enum hcl_jsoner_state_t hcl_jsoner_state_t;
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if 0
|
||||
struct hcl_json_root_t
|
||||
struct hcl_jsoner_root_t
|
||||
{
|
||||
int type;
|
||||
hcl_json_value_t* value;
|
||||
hcl_jsoner_value_t* value;
|
||||
};
|
||||
|
||||
struct hcl_json_list_t
|
||||
struct hcl_jsoner_list_t
|
||||
{
|
||||
int type; /* array or table */
|
||||
hcl_json_pair_t* cell;
|
||||
hcl_jsoner_pair_t* cell;
|
||||
};
|
||||
|
||||
struct hcl_json_value_t
|
||||
struct hcl_jsoner_value_t
|
||||
{
|
||||
int type; /* atom or pair */
|
||||
union
|
||||
{
|
||||
hcl_json_value_t* value;
|
||||
hcl_json_pair_t* cell;
|
||||
hcl_jsoner_value_t* value;
|
||||
hcl_jsoner_pair_t* cell;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct hcl_json_atom_t
|
||||
struct hcl_jsoner_atom_t
|
||||
{
|
||||
int type; /* string, word, number */
|
||||
};
|
||||
|
||||
struct hcl_json_pair_t
|
||||
struct hcl_jsoner_pair_t
|
||||
{
|
||||
hcl_json_atom_t* key;
|
||||
hcl_json_value_t* value;
|
||||
hcl_json_pair_t* next;
|
||||
hcl_jsoner_atom_t* key;
|
||||
hcl_jsoner_value_t* value;
|
||||
hcl_jsoner_pair_t* next;
|
||||
};
|
||||
#endif
|
||||
/* ========================================================================= */
|
||||
enum hcl_json_reply_type_t
|
||||
enum hcl_jsoner_reply_type_t
|
||||
{
|
||||
HCL_JSON_REPLY_TYPE_OK = 0,
|
||||
HCL_JSON_REPLY_TYPE_ERROR = 1
|
||||
};
|
||||
typedef enum hcl_json_reply_type_t hcl_json_reply_type_t;
|
||||
typedef enum hcl_jsoner_reply_type_t hcl_jsoner_reply_type_t;
|
||||
|
||||
typedef void (*hcl_json_log_write_t) (
|
||||
hcl_json_t* json,
|
||||
typedef void (*hcl_jsoner_log_write_t) (
|
||||
hcl_jsoner_t* json,
|
||||
unsigned int mask,
|
||||
const hcl_ooch_t* msg,
|
||||
hcl_oow_t len
|
||||
);
|
||||
|
||||
typedef int (*hcl_json_start_reply_t) (
|
||||
hcl_json_t* json,
|
||||
hcl_json_reply_type_t type,
|
||||
typedef int (*hcl_jsoner_start_reply_t) (
|
||||
hcl_jsoner_t* json,
|
||||
hcl_jsoner_reply_type_t type,
|
||||
const hcl_ooch_t* dptr,
|
||||
hcl_oow_t dlen
|
||||
);
|
||||
|
||||
typedef int (*hcl_json_feed_attr_t) (
|
||||
hcl_json_t* json,
|
||||
typedef int (*hcl_jsoner_feed_attr_t) (
|
||||
hcl_jsoner_t* json,
|
||||
const hcl_oocs_t* key,
|
||||
const hcl_oocs_t* val
|
||||
);
|
||||
|
||||
typedef int (*hcl_json_start_data_t) (
|
||||
hcl_json_t* json
|
||||
typedef int (*hcl_jsoner_start_data_t) (
|
||||
hcl_jsoner_t* json
|
||||
);
|
||||
|
||||
typedef int (*hcl_json_feed_data_t) (
|
||||
hcl_json_t* json,
|
||||
typedef int (*hcl_jsoner_feed_data_t) (
|
||||
hcl_jsoner_t* json,
|
||||
const void* ptr,
|
||||
hcl_oow_t len
|
||||
);
|
||||
|
||||
typedef int (*hcl_json_end_data_t) (
|
||||
hcl_json_t* json
|
||||
typedef int (*hcl_jsoner_end_data_t) (
|
||||
hcl_jsoner_t* json
|
||||
);
|
||||
|
||||
enum hcl_json_end_reply_state_t
|
||||
enum hcl_jsoner_end_reply_state_t
|
||||
{
|
||||
HCL_JSON_END_REPLY_STATE_OK,
|
||||
HCL_JSON_END_REPLY_STATE_REVOKED
|
||||
};
|
||||
typedef enum hcl_json_end_reply_state_t hcl_json_end_reply_state_t;
|
||||
typedef enum hcl_jsoner_end_reply_state_t hcl_jsoner_end_reply_state_t;
|
||||
|
||||
typedef int (*hcl_json_end_reply_t) (
|
||||
hcl_json_t* json,
|
||||
hcl_json_end_reply_state_t state
|
||||
typedef int (*hcl_jsoner_end_reply_t) (
|
||||
hcl_jsoner_t* json,
|
||||
hcl_jsoner_end_reply_state_t state
|
||||
);
|
||||
|
||||
struct hcl_json_prim_t
|
||||
struct hcl_jsoner_prim_t
|
||||
{
|
||||
hcl_json_log_write_t log_write;
|
||||
hcl_jsoner_log_write_t log_write;
|
||||
|
||||
hcl_json_start_reply_t start_reply; /* mandatory */
|
||||
hcl_json_feed_attr_t feed_attr; /* optional */
|
||||
hcl_json_feed_data_t feed_data; /* optional */
|
||||
hcl_json_end_reply_t end_reply; /* mandatory */
|
||||
hcl_jsoner_start_reply_t start_reply; /* mandatory */
|
||||
hcl_jsoner_feed_attr_t feed_attr; /* optional */
|
||||
hcl_jsoner_feed_data_t feed_data; /* optional */
|
||||
hcl_jsoner_end_reply_t end_reply; /* mandatory */
|
||||
};
|
||||
typedef struct hcl_json_prim_t hcl_json_prim_t;
|
||||
typedef struct hcl_jsoner_prim_t hcl_jsoner_prim_t;
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
@ -167,127 +167,127 @@ typedef struct hcl_json_prim_t hcl_json_prim_t;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
HCL_EXPORT hcl_json_t* hcl_json_open (
|
||||
HCL_EXPORT hcl_jsoner_t* hcl_jsoner_open (
|
||||
hcl_mmgr_t* mmgr,
|
||||
hcl_oow_t xtnsize,
|
||||
hcl_json_prim_t* prim,
|
||||
hcl_jsoner_prim_t* prim,
|
||||
hcl_errnum_t* errnum
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_json_close (
|
||||
hcl_json_t* json
|
||||
HCL_EXPORT void hcl_jsoner_close (
|
||||
hcl_jsoner_t* json
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_json_reset (
|
||||
hcl_json_t* json
|
||||
HCL_EXPORT void hcl_jsoner_reset (
|
||||
hcl_jsoner_t* json
|
||||
);
|
||||
|
||||
HCL_EXPORT int hcl_json_feed (
|
||||
hcl_json_t* json,
|
||||
HCL_EXPORT int hcl_jsoner_feed (
|
||||
hcl_jsoner_t* json,
|
||||
const void* ptr,
|
||||
hcl_oow_t len,
|
||||
hcl_oow_t* xlen
|
||||
);
|
||||
|
||||
HCL_EXPORT hcl_json_state_t hcl_json_getstate (
|
||||
hcl_json_t* json
|
||||
HCL_EXPORT hcl_jsoner_state_t hcl_jsoner_getstate (
|
||||
hcl_jsoner_t* json
|
||||
);
|
||||
|
||||
HCL_EXPORT int hcl_json_setoption (
|
||||
hcl_json_t* json,
|
||||
hcl_json_option_t id,
|
||||
HCL_EXPORT int hcl_jsoner_setoption (
|
||||
hcl_jsoner_t* json,
|
||||
hcl_jsoner_option_t id,
|
||||
const void* value
|
||||
);
|
||||
|
||||
HCL_EXPORT int hcl_json_getoption (
|
||||
hcl_json_t* json,
|
||||
hcl_json_option_t id,
|
||||
HCL_EXPORT int hcl_jsoner_getoption (
|
||||
hcl_jsoner_t* json,
|
||||
hcl_jsoner_option_t id,
|
||||
void* value
|
||||
);
|
||||
|
||||
|
||||
HCL_EXPORT void* hcl_json_getxtn (
|
||||
hcl_json_t* json
|
||||
HCL_EXPORT void* hcl_jsoner_getxtn (
|
||||
hcl_jsoner_t* json
|
||||
);
|
||||
|
||||
HCL_EXPORT hcl_mmgr_t* hcl_json_getmmgr (
|
||||
hcl_json_t* json
|
||||
HCL_EXPORT hcl_mmgr_t* hcl_jsoner_getmmgr (
|
||||
hcl_jsoner_t* json
|
||||
);
|
||||
|
||||
HCL_EXPORT hcl_cmgr_t* hcl_json_getcmgr (
|
||||
hcl_json_t* json
|
||||
HCL_EXPORT hcl_cmgr_t* hcl_jsoner_getcmgr (
|
||||
hcl_jsoner_t* json
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_json_setcmgr (
|
||||
hcl_json_t* json,
|
||||
HCL_EXPORT void hcl_jsoner_setcmgr (
|
||||
hcl_jsoner_t* json,
|
||||
hcl_cmgr_t* cmgr
|
||||
);
|
||||
|
||||
|
||||
HCL_EXPORT hcl_errnum_t hcl_json_geterrnum (
|
||||
hcl_json_t* json
|
||||
HCL_EXPORT hcl_errnum_t hcl_jsoner_geterrnum (
|
||||
hcl_jsoner_t* json
|
||||
);
|
||||
|
||||
HCL_EXPORT const hcl_ooch_t* hcl_json_geterrstr (
|
||||
hcl_json_t* json
|
||||
HCL_EXPORT const hcl_ooch_t* hcl_jsoner_geterrstr (
|
||||
hcl_jsoner_t* json
|
||||
);
|
||||
|
||||
HCL_EXPORT const hcl_ooch_t* hcl_json_geterrmsg (
|
||||
hcl_json_t* json
|
||||
HCL_EXPORT const hcl_ooch_t* hcl_jsoner_geterrmsg (
|
||||
hcl_jsoner_t* json
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_json_seterrnum (
|
||||
hcl_json_t* json,
|
||||
HCL_EXPORT void hcl_jsoner_seterrnum (
|
||||
hcl_jsoner_t* json,
|
||||
hcl_errnum_t errnum
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_json_seterrbfmt (
|
||||
hcl_json_t* json,
|
||||
HCL_EXPORT void hcl_jsoner_seterrbfmt (
|
||||
hcl_jsoner_t* json,
|
||||
hcl_errnum_t errnum,
|
||||
const hcl_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_json_seterrufmt (
|
||||
hcl_json_t* json,
|
||||
HCL_EXPORT void hcl_jsoner_seterrufmt (
|
||||
hcl_jsoner_t* json,
|
||||
hcl_errnum_t errnum,
|
||||
const hcl_uch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_json_logbfmt (
|
||||
hcl_json_t* json,
|
||||
HCL_EXPORT void hcl_jsoner_logbfmt (
|
||||
hcl_jsoner_t* json,
|
||||
unsigned int mask,
|
||||
const hcl_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_json_logufmt (
|
||||
hcl_json_t* json,
|
||||
HCL_EXPORT void hcl_jsoner_logufmt (
|
||||
hcl_jsoner_t* json,
|
||||
unsigned int mask,
|
||||
const hcl_uch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT void* hcl_json_allocmem (
|
||||
hcl_json_t* json,
|
||||
HCL_EXPORT void* hcl_jsoner_allocmem (
|
||||
hcl_jsoner_t* json,
|
||||
hcl_oow_t size
|
||||
);
|
||||
|
||||
HCL_EXPORT void* hcl_json_callocmem (
|
||||
hcl_json_t* json,
|
||||
HCL_EXPORT void* hcl_jsoner_callocmem (
|
||||
hcl_jsoner_t* json,
|
||||
hcl_oow_t size
|
||||
);
|
||||
|
||||
HCL_EXPORT void* hcl_json_reallocmem (
|
||||
hcl_json_t* json,
|
||||
HCL_EXPORT void* hcl_jsoner_reallocmem (
|
||||
hcl_jsoner_t* json,
|
||||
void* ptr,
|
||||
hcl_oow_t size
|
||||
);
|
||||
|
||||
|
||||
HCL_EXPORT void hcl_json_freemem (
|
||||
hcl_json_t* json,
|
||||
HCL_EXPORT void hcl_jsoner_freemem (
|
||||
hcl_jsoner_t* json,
|
||||
void* ptr
|
||||
);
|
||||
|
||||
|
106
lib/json.c
106
lib/json.c
@ -34,22 +34,22 @@
|
||||
|
||||
struct dummy_hcl_xtn_t
|
||||
{
|
||||
hcl_json_t* json;
|
||||
hcl_jsoner_t* json;
|
||||
};
|
||||
typedef struct dummy_hcl_xtn_t dummy_hcl_xtn_t;
|
||||
|
||||
enum hcl_json_reply_attr_type_t
|
||||
enum hcl_jsoner_reply_attr_type_t
|
||||
{
|
||||
HCL_JSON_REPLY_ATTR_TYPE_UNKNOWN,
|
||||
HCL_JSON_REPLY_ATTR_TYPE_DATA
|
||||
};
|
||||
typedef enum hcl_json_reply_attr_type_t hcl_json_reply_attr_type_t;
|
||||
typedef enum hcl_jsoner_reply_attr_type_t hcl_jsoner_reply_attr_type_t;
|
||||
|
||||
struct hcl_json_t
|
||||
struct hcl_jsoner_t
|
||||
{
|
||||
hcl_mmgr_t* mmgr;
|
||||
hcl_cmgr_t* cmgr;
|
||||
hcl_json_prim_t prim;
|
||||
hcl_jsoner_prim_t prim;
|
||||
hcl_t* dummy_hcl;
|
||||
|
||||
hcl_errnum_t errnum;
|
||||
@ -72,7 +72,7 @@ struct hcl_json_t
|
||||
hcl_oow_t capa;
|
||||
} req;
|
||||
|
||||
hcl_json_state_t state;
|
||||
hcl_jsoner_state_t state;
|
||||
struct
|
||||
{
|
||||
struct
|
||||
@ -82,8 +82,8 @@ struct hcl_json_t
|
||||
hcl_oow_t capa;
|
||||
} tok;
|
||||
|
||||
hcl_json_reply_type_t type;
|
||||
hcl_json_reply_attr_type_t last_attr_type;
|
||||
hcl_jsoner_reply_type_t type;
|
||||
hcl_jsoner_reply_attr_type_t last_attr_type;
|
||||
struct
|
||||
{
|
||||
hcl_ooch_t* ptr;
|
||||
@ -138,7 +138,7 @@ struct hcl_json_t
|
||||
static void log_write_for_dummy (hcl_t* hcl, unsigned int mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
dummy_hcl_xtn_t* xtn = (dummy_hcl_xtn_t*)hcl_getxtn(hcl);
|
||||
hcl_json_t* json;
|
||||
hcl_jsoner_t* json;
|
||||
|
||||
json = xtn->json;
|
||||
json->prim.log_write (json, mask, msg, len);
|
||||
@ -185,12 +185,12 @@ static HCL_INLINE int is_digitchar (hcl_ooci_t c)
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
static void clear_reply_token (hcl_json_t* json)
|
||||
static void clear_reply_token (hcl_jsoner_t* json)
|
||||
{
|
||||
json->rep.tok.len = 0;
|
||||
}
|
||||
|
||||
static int add_to_reply_token (hcl_json_t* json, hcl_ooch_t ch)
|
||||
static int add_to_reply_token (hcl_jsoner_t* json, hcl_ooch_t ch)
|
||||
{
|
||||
if (json->rep.tok.len >= json->rep.tok.capa)
|
||||
{
|
||||
@ -198,7 +198,7 @@ static int add_to_reply_token (hcl_json_t* json, hcl_ooch_t ch)
|
||||
hcl_oow_t newcapa;
|
||||
|
||||
newcapa = HCL_ALIGN_POW2(json->rep.tok.len + 1, HCL_JSON_TOKEN_NAME_ALIGN);
|
||||
tmp = hcl_json_reallocmem(json, json->rep.tok.ptr, newcapa * HCL_SIZEOF(*tmp));
|
||||
tmp = hcl_jsoner_reallocmem(json, json->rep.tok.ptr, newcapa * HCL_SIZEOF(*tmp));
|
||||
if (!tmp) return -1;
|
||||
|
||||
json->rep.tok.capa = newcapa;
|
||||
@ -209,12 +209,12 @@ static int add_to_reply_token (hcl_json_t* json, hcl_ooch_t ch)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static HCL_INLINE int is_token (hcl_json_t* json, const hcl_bch_t* str)
|
||||
static HCL_INLINE int is_token (hcl_jsoner_t* json, const hcl_bch_t* str)
|
||||
{
|
||||
return hcl_comp_oochars_bcstr(json->rep.tok.ptr, json->rep.tok.len, str) == 0;
|
||||
}
|
||||
|
||||
static HCL_INLINE int is_token_integer (hcl_json_t* json, hcl_oow_t* value)
|
||||
static HCL_INLINE int is_token_integer (hcl_jsoner_t* json, hcl_oow_t* value)
|
||||
{
|
||||
hcl_oow_t i;
|
||||
hcl_oow_t v = 0;
|
||||
@ -250,14 +250,14 @@ static HCL_INLINE hcl_ooch_t unescape (hcl_ooch_t c)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int handle_char (hcl_json_t* json, hcl_ooci_t c, hcl_oow_t nbytes)
|
||||
static int handle_char (hcl_jsoner_t* json, hcl_ooci_t c, hcl_oow_t nbytes)
|
||||
{
|
||||
switch (json->state)
|
||||
{
|
||||
case HCL_JSON_STATE_START:
|
||||
if (c == HCL_OOCI_EOF)
|
||||
{
|
||||
hcl_json_seterrbfmt (json, HCL_EFINIS, "unexpected end before reply name");
|
||||
hcl_jsoner_seterrbfmt (json, HCL_EFINIS, "unexpected end before reply name");
|
||||
goto oops;
|
||||
}
|
||||
else if (c == '[')
|
||||
@ -277,7 +277,7 @@ static int handle_char (hcl_json_t* json, hcl_ooci_t c, hcl_oow_t nbytes)
|
||||
}
|
||||
else
|
||||
{
|
||||
hcl_json_seterrbfmt (json, HCL_EINVAL, "not starting with [ or { - %jc", (hcl_ooch_t)c);
|
||||
hcl_jsoner_seterrbfmt (json, HCL_EINVAL, "not starting with [ or { - %jc", (hcl_ooch_t)c);
|
||||
goto oops;
|
||||
}
|
||||
break;
|
||||
@ -306,7 +306,7 @@ static int handle_char (hcl_json_t* json, hcl_ooci_t c, hcl_oow_t nbytes)
|
||||
}
|
||||
else
|
||||
{
|
||||
hcl_json_seterrbfmt (json, HCL_EINVAL, "not starting with [ or { - %jc", (hcl_ooch_t)c);
|
||||
hcl_jsoner_seterrbfmt (json, HCL_EINVAL, "not starting with [ or { - %jc", (hcl_ooch_t)c);
|
||||
goto oops;
|
||||
}
|
||||
break;
|
||||
@ -334,7 +334,7 @@ static int handle_char (hcl_json_t* json, hcl_ooci_t c, hcl_oow_t nbytes)
|
||||
}
|
||||
else
|
||||
{
|
||||
hcl_json_seterrbfmt (json, HCL_EINVAL, "not starting with [ or { - %jc", (hcl_ooch_t)c);
|
||||
hcl_jsoner_seterrbfmt (json, HCL_EINVAL, "not starting with [ or { - %jc", (hcl_ooch_t)c);
|
||||
goto oops;
|
||||
}
|
||||
break;
|
||||
@ -358,7 +358,7 @@ static int handle_char (hcl_json_t* json, hcl_ooci_t c, hcl_oow_t nbytes)
|
||||
break;
|
||||
|
||||
default:
|
||||
hcl_json_seterrbfmt (json, HCL_EINTERN, "internal error - must not be called for state %d", (int)json->state);
|
||||
hcl_jsoner_seterrbfmt (json, HCL_EINTERN, "internal error - must not be called for state %d", (int)json->state);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ oops:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int feed_json_data (hcl_json_t* json, const hcl_bch_t* data, hcl_oow_t len, hcl_oow_t* xlen)
|
||||
static int feed_json_data (hcl_jsoner_t* json, const hcl_bch_t* data, hcl_oow_t len, hcl_oow_t* xlen)
|
||||
{
|
||||
const hcl_bch_t* ptr;
|
||||
const hcl_bch_t* end;
|
||||
@ -422,14 +422,14 @@ oops:
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
hcl_json_t* hcl_json_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_json_prim_t* prim, hcl_errnum_t* errnum)
|
||||
hcl_jsoner_t* hcl_jsoner_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_jsoner_prim_t* prim, hcl_errnum_t* errnum)
|
||||
{
|
||||
hcl_json_t* json;
|
||||
hcl_jsoner_t* json;
|
||||
hcl_t* hcl;
|
||||
hcl_vmprim_t vmprim;
|
||||
dummy_hcl_xtn_t* xtn;
|
||||
|
||||
json = (hcl_json_t*)HCL_MMGR_ALLOC(mmgr, HCL_SIZEOF(*json) + xtnsize);
|
||||
json = (hcl_jsoner_t*)HCL_MMGR_ALLOC(mmgr, HCL_SIZEOF(*json) + xtnsize);
|
||||
if (!json)
|
||||
{
|
||||
if (errnum) *errnum = HCL_ESYSMEM;
|
||||
@ -467,15 +467,15 @@ hcl_json_t* hcl_json_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_json_prim_t*
|
||||
return json;
|
||||
}
|
||||
|
||||
void hcl_json_close (hcl_json_t* json)
|
||||
void hcl_jsoner_close (hcl_jsoner_t* json)
|
||||
{
|
||||
if (json->rep.tok.ptr) hcl_json_freemem (json, json->rep.tok.ptr);
|
||||
if (json->rep.last_attr_key.ptr) hcl_json_freemem (json, json->rep.last_attr_key.ptr);
|
||||
if (json->rep.tok.ptr) hcl_jsoner_freemem (json, json->rep.tok.ptr);
|
||||
if (json->rep.last_attr_key.ptr) hcl_jsoner_freemem (json, json->rep.last_attr_key.ptr);
|
||||
hcl_close (json->dummy_hcl);
|
||||
HCL_MMGR_FREE (json->mmgr, json);
|
||||
}
|
||||
|
||||
int hcl_json_setoption (hcl_json_t* json, hcl_json_option_t id, const void* value)
|
||||
int hcl_jsoner_setoption (hcl_jsoner_t* json, hcl_jsoner_option_t id, const void* value)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
@ -496,11 +496,11 @@ int hcl_json_setoption (hcl_json_t* json, hcl_json_option_t id, const void* valu
|
||||
return 0;
|
||||
}
|
||||
|
||||
hcl_json_seterrnum (json, HCL_EINVAL);
|
||||
hcl_jsoner_seterrnum (json, HCL_EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int hcl_json_getoption (hcl_json_t* json, hcl_json_option_t id, void* value)
|
||||
int hcl_jsoner_getoption (hcl_jsoner_t* json, hcl_jsoner_option_t id, void* value)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
@ -513,55 +513,55 @@ int hcl_json_getoption (hcl_json_t* json, hcl_json_option_t id, void* value)
|
||||
return 0;
|
||||
};
|
||||
|
||||
hcl_json_seterrnum (json, HCL_EINVAL);
|
||||
hcl_jsoner_seterrnum (json, HCL_EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void* hcl_json_getxtn (hcl_json_t* json)
|
||||
void* hcl_jsoner_getxtn (hcl_jsoner_t* json)
|
||||
{
|
||||
return (void*)(json + 1);
|
||||
}
|
||||
|
||||
hcl_mmgr_t* hcl_json_getmmgr (hcl_json_t* json)
|
||||
hcl_mmgr_t* hcl_jsoner_getmmgr (hcl_jsoner_t* json)
|
||||
{
|
||||
return json->mmgr;
|
||||
}
|
||||
|
||||
hcl_cmgr_t* hcl_json_getcmgr (hcl_json_t* json)
|
||||
hcl_cmgr_t* hcl_jsoner_getcmgr (hcl_jsoner_t* json)
|
||||
{
|
||||
return json->cmgr;
|
||||
}
|
||||
|
||||
void hcl_json_setcmgr (hcl_json_t* json, hcl_cmgr_t* cmgr)
|
||||
void hcl_jsoner_setcmgr (hcl_jsoner_t* json, hcl_cmgr_t* cmgr)
|
||||
{
|
||||
json->cmgr = cmgr;
|
||||
}
|
||||
|
||||
hcl_errnum_t hcl_json_geterrnum (hcl_json_t* json)
|
||||
hcl_errnum_t hcl_jsoner_geterrnum (hcl_jsoner_t* json)
|
||||
{
|
||||
return json->errnum;
|
||||
}
|
||||
|
||||
const hcl_ooch_t* hcl_json_geterrstr (hcl_json_t* json)
|
||||
const hcl_ooch_t* hcl_jsoner_geterrstr (hcl_jsoner_t* json)
|
||||
{
|
||||
return hcl_errnum_to_errstr(json->errnum);
|
||||
}
|
||||
|
||||
const hcl_ooch_t* hcl_json_geterrmsg (hcl_json_t* json)
|
||||
const hcl_ooch_t* hcl_jsoner_geterrmsg (hcl_jsoner_t* json)
|
||||
{
|
||||
if (json->errmsg.len <= 0) return hcl_errnum_to_errstr(json->errnum);
|
||||
return json->errmsg.buf;
|
||||
}
|
||||
|
||||
void hcl_json_seterrnum (hcl_json_t* json, hcl_errnum_t errnum)
|
||||
void hcl_jsoner_seterrnum (hcl_jsoner_t* json, hcl_errnum_t errnum)
|
||||
{
|
||||
/*if (json->shuterr) return; */
|
||||
json->errnum = errnum;
|
||||
json->errmsg.len = 0;
|
||||
}
|
||||
|
||||
void hcl_json_seterrbfmt (hcl_json_t* json, hcl_errnum_t errnum, const hcl_bch_t* fmt, ...)
|
||||
void hcl_jsoner_seterrbfmt (hcl_jsoner_t* json, hcl_errnum_t errnum, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -575,7 +575,7 @@ void hcl_json_seterrbfmt (hcl_json_t* json, hcl_errnum_t errnum, const hcl_bch_t
|
||||
json->errmsg.len = json->dummy_hcl->errmsg.len;
|
||||
}
|
||||
|
||||
void hcl_json_seterrufmt (hcl_json_t* json, hcl_errnum_t errnum, const hcl_uch_t* fmt, ...)
|
||||
void hcl_jsoner_seterrufmt (hcl_jsoner_t* json, hcl_errnum_t errnum, const hcl_uch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -591,7 +591,7 @@ void hcl_json_seterrufmt (hcl_json_t* json, hcl_errnum_t errnum, const hcl_uch_t
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
void hcl_json_logbfmt (hcl_json_t* json, unsigned int mask, const hcl_bch_t* fmt, ...)
|
||||
void hcl_jsoner_logbfmt (hcl_jsoner_t* json, unsigned int mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
@ -599,7 +599,7 @@ void hcl_json_logbfmt (hcl_json_t* json, unsigned int mask, const hcl_bch_t* fmt
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
void hcl_json_logufmt (hcl_json_t* json, unsigned int mask, const hcl_uch_t* fmt, ...)
|
||||
void hcl_jsoner_logufmt (hcl_jsoner_t* json, unsigned int mask, const hcl_uch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
@ -609,51 +609,51 @@ void hcl_json_logufmt (hcl_json_t* json, unsigned int mask, const hcl_uch_t* fmt
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
void* hcl_json_allocmem (hcl_json_t* json, hcl_oow_t size)
|
||||
void* hcl_jsoner_allocmem (hcl_jsoner_t* json, hcl_oow_t size)
|
||||
{
|
||||
void* ptr;
|
||||
|
||||
ptr = HCL_MMGR_ALLOC(json->mmgr, size);
|
||||
if (!ptr) hcl_json_seterrnum (json, HCL_ESYSMEM);
|
||||
if (!ptr) hcl_jsoner_seterrnum (json, HCL_ESYSMEM);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void* hcl_json_callocmem (hcl_json_t* json, hcl_oow_t size)
|
||||
void* hcl_jsoner_callocmem (hcl_jsoner_t* json, hcl_oow_t size)
|
||||
{
|
||||
void* ptr;
|
||||
|
||||
ptr = HCL_MMGR_ALLOC(json->mmgr, size);
|
||||
if (!ptr) hcl_json_seterrnum (json, HCL_ESYSMEM);
|
||||
if (!ptr) hcl_jsoner_seterrnum (json, HCL_ESYSMEM);
|
||||
else HCL_MEMSET (ptr, 0, size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void* hcl_json_reallocmem (hcl_json_t* json, void* ptr, hcl_oow_t size)
|
||||
void* hcl_jsoner_reallocmem (hcl_jsoner_t* json, void* ptr, hcl_oow_t size)
|
||||
{
|
||||
ptr = HCL_MMGR_REALLOC(json->mmgr, ptr, size);
|
||||
if (!ptr) hcl_json_seterrnum (json, HCL_ESYSMEM);
|
||||
if (!ptr) hcl_jsoner_seterrnum (json, HCL_ESYSMEM);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void hcl_json_freemem (hcl_json_t* json, void* ptr)
|
||||
void hcl_jsoner_freemem (hcl_jsoner_t* json, void* ptr)
|
||||
{
|
||||
HCL_MMGR_FREE (json->mmgr, ptr);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
hcl_json_state_t hcl_json_getstate (hcl_json_t* json)
|
||||
hcl_jsoner_state_t hcl_jsoner_getstate (hcl_jsoner_t* json)
|
||||
{
|
||||
return json->state;
|
||||
}
|
||||
|
||||
void hcl_json_reset (hcl_json_t* json)
|
||||
void hcl_jsoner_reset (hcl_jsoner_t* json)
|
||||
{
|
||||
/* TODO: reset XXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxx */
|
||||
json->state = HCL_JSON_STATE_START;
|
||||
}
|
||||
|
||||
int hcl_json_feed (hcl_json_t* json, const void* ptr, hcl_oow_t len, hcl_oow_t* xlen)
|
||||
int hcl_jsoner_feed (hcl_jsoner_t* json, const void* ptr, hcl_oow_t len, hcl_oow_t* xlen)
|
||||
{
|
||||
int x;
|
||||
hcl_oow_t total, ylen;
|
||||
|
40
lib/main-j.c
Normal file
40
lib/main-j.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include <hcl-json.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
static void* sys_alloc (hcl_mmgr_t* mmgr, hcl_oow_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void* sys_realloc (hcl_mmgr_t* mmgr, void* ptr, hcl_oow_t size)
|
||||
{
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
|
||||
static void sys_free (hcl_mmgr_t* mmgr, void* ptr)
|
||||
{
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
static hcl_mmgr_t sys_mmgr =
|
||||
{
|
||||
sys_alloc,
|
||||
sys_realloc,
|
||||
sys_free,
|
||||
HCL_NULL
|
||||
};
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
|
||||
hcl_jsoner_t* jsoner;
|
||||
|
||||
|
||||
jsoner = hcl_jsoner_open (&mmgr, 0, NULL, NULL);
|
||||
|
||||
|
||||
hcl_jsoner_close (jsoner);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user