Loading include/spdk/json.h +2 −0 Original line number Diff line number Diff line Loading @@ -200,6 +200,8 @@ int spdk_json_write_int64(struct spdk_json_write_ctx *w, int64_t val); int spdk_json_write_uint64(struct spdk_json_write_ctx *w, uint64_t val); int spdk_json_write_string(struct spdk_json_write_ctx *w, const char *val); int spdk_json_write_string_raw(struct spdk_json_write_ctx *w, const char *val, size_t len); int spdk_json_write_string_fmt(struct spdk_json_write_ctx *w, const char *fmt, ...) __attribute__((__format__(__printf__, 2, 3))); int spdk_json_write_array_begin(struct spdk_json_write_ctx *w); int spdk_json_write_array_end(struct spdk_json_write_ctx *w); int spdk_json_write_object_begin(struct spdk_json_write_ctx *w); Loading lib/json/json_internal.h +3 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #include "spdk/json.h" #include <stdarg.h> #include <stdlib.h> #include <inttypes.h> #include <stdbool.h> Loading @@ -46,6 +47,8 @@ #include <string.h> #include <errno.h> #include "spdk/string.h" #define SPDK_JSON_MAX_NESTING_DEPTH 64 static inline bool Loading lib/json/json_write.c +20 −0 Original line number Diff line number Diff line Loading @@ -317,6 +317,26 @@ spdk_json_write_string(struct spdk_json_write_ctx *w, const char *val) return spdk_json_write_string_raw(w, val, strlen(val)); } int spdk_json_write_string_fmt(struct spdk_json_write_ctx *w, const char *fmt, ...) { char *s; va_list args; int rc; va_start(args, fmt); s = spdk_vsprintf_alloc(fmt, args); va_end(args); if (s == NULL) { return -1; } rc = spdk_json_write_string(w, s); free(s); return rc; } int spdk_json_write_array_begin(struct spdk_json_write_ctx *w) { Loading mk/json.unittest.mk +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.app.mk JSON_DIR := $(SPDK_ROOT_DIR)/lib/json JSONRPC_DIR := $(SPDK_ROOT_DIR)/lib/jsonrpc SPDK_LIB_LIST = json log SPDK_LIB_LIST = json util log C_SRCS = $(TEST_FILE) $(OTHER_FILES) Loading test/lib/json/jsoncat/Makefile +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ APP = jsoncat C_SRCS = jsoncat.c SPDK_LIB_LIST = json SPDK_LIB_LIST = json util LIBS += $(SPDK_LIB_LINKER_ARGS) Loading Loading
include/spdk/json.h +2 −0 Original line number Diff line number Diff line Loading @@ -200,6 +200,8 @@ int spdk_json_write_int64(struct spdk_json_write_ctx *w, int64_t val); int spdk_json_write_uint64(struct spdk_json_write_ctx *w, uint64_t val); int spdk_json_write_string(struct spdk_json_write_ctx *w, const char *val); int spdk_json_write_string_raw(struct spdk_json_write_ctx *w, const char *val, size_t len); int spdk_json_write_string_fmt(struct spdk_json_write_ctx *w, const char *fmt, ...) __attribute__((__format__(__printf__, 2, 3))); int spdk_json_write_array_begin(struct spdk_json_write_ctx *w); int spdk_json_write_array_end(struct spdk_json_write_ctx *w); int spdk_json_write_object_begin(struct spdk_json_write_ctx *w); Loading
lib/json/json_internal.h +3 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #include "spdk/json.h" #include <stdarg.h> #include <stdlib.h> #include <inttypes.h> #include <stdbool.h> Loading @@ -46,6 +47,8 @@ #include <string.h> #include <errno.h> #include "spdk/string.h" #define SPDK_JSON_MAX_NESTING_DEPTH 64 static inline bool Loading
lib/json/json_write.c +20 −0 Original line number Diff line number Diff line Loading @@ -317,6 +317,26 @@ spdk_json_write_string(struct spdk_json_write_ctx *w, const char *val) return spdk_json_write_string_raw(w, val, strlen(val)); } int spdk_json_write_string_fmt(struct spdk_json_write_ctx *w, const char *fmt, ...) { char *s; va_list args; int rc; va_start(args, fmt); s = spdk_vsprintf_alloc(fmt, args); va_end(args); if (s == NULL) { return -1; } rc = spdk_json_write_string(w, s); free(s); return rc; } int spdk_json_write_array_begin(struct spdk_json_write_ctx *w) { Loading
mk/json.unittest.mk +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.app.mk JSON_DIR := $(SPDK_ROOT_DIR)/lib/json JSONRPC_DIR := $(SPDK_ROOT_DIR)/lib/jsonrpc SPDK_LIB_LIST = json log SPDK_LIB_LIST = json util log C_SRCS = $(TEST_FILE) $(OTHER_FILES) Loading
test/lib/json/jsoncat/Makefile +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ APP = jsoncat C_SRCS = jsoncat.c SPDK_LIB_LIST = json SPDK_LIB_LIST = json util LIBS += $(SPDK_LIB_LINKER_ARGS) Loading