json: add spdk_json_write_[u]int64()
Change-Id: I29c2c8f8546774842adf7e77e7bb550735c6fccc Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
3c3824a3d2
commit
d921d9ed9f
@ -196,6 +196,8 @@ int spdk_json_write_null(struct spdk_json_write_ctx *w);
|
||||
int spdk_json_write_bool(struct spdk_json_write_ctx *w, bool val);
|
||||
int spdk_json_write_int32(struct spdk_json_write_ctx *w, int32_t val);
|
||||
int spdk_json_write_uint32(struct spdk_json_write_ctx *w, uint32_t val);
|
||||
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_array_begin(struct spdk_json_write_ctx *w);
|
||||
|
@ -188,6 +188,30 @@ spdk_json_write_uint32(struct spdk_json_write_ctx *w, uint32_t val)
|
||||
return emit(w, buf, count);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_json_write_int64(struct spdk_json_write_ctx *w, int64_t val)
|
||||
{
|
||||
char buf[32];
|
||||
int count;
|
||||
|
||||
if (begin_value(w)) return fail(w);
|
||||
count = snprintf(buf, sizeof(buf), "%" PRId64, val);
|
||||
if (count <= 0 || (size_t)count >= sizeof(buf)) return fail(w);
|
||||
return emit(w, buf, count);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_json_write_uint64(struct spdk_json_write_ctx *w, uint64_t val)
|
||||
{
|
||||
char buf[32];
|
||||
int count;
|
||||
|
||||
if (begin_value(w)) return fail(w);
|
||||
count = snprintf(buf, sizeof(buf), "%" PRIu64, val);
|
||||
if (count <= 0 || (size_t)count >= sizeof(buf)) return fail(w);
|
||||
return emit(w, buf, count);
|
||||
}
|
||||
|
||||
static void
|
||||
write_hex_4(void *dest, uint16_t val)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user