summaryrefslogtreecommitdiffstats
path: root/util/json.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:23:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:23:26 +0000
commitfab3f41b7b3f080c215157a026ee6bc7efbfe968 (patch)
treef0fafb0805c3eb11eb2a278f9f8058376c8f0f2b /util/json.h
parentAdding upstream version 2.1.2. (diff)
downloadnvme-cli-fab3f41b7b3f080c215157a026ee6bc7efbfe968.tar.xz
nvme-cli-fab3f41b7b3f080c215157a026ee6bc7efbfe968.zip
Adding upstream version 2.2.1.upstream/2.2.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--util/json.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/util/json.h b/util/json.h
index 2b8022a..1312cb8 100644
--- a/util/json.h
+++ b/util/json.h
@@ -3,6 +3,7 @@
#define __JSON__H
#include <json.h>
+#include "util/types.h"
/* Wrappers around json-c's API */
@@ -14,17 +15,14 @@
json_object_object_add(o, k, json_object_new_int(v))
#define json_object_add_value_int(o, k, v) \
json_object_object_add(o, k, json_object_new_int(v))
-#ifdef CONFIG_JSONC_14
+#ifndef CONFIG_JSONC_14
+#define json_object_new_uint64(v) util_json_object_new_uint64(v)
+#define json_object_get_uint64(v) util_json_object_get_uint64(v)
+#endif
#define json_object_add_value_uint64(o, k, v) \
json_object_object_add(o, k, json_object_new_uint64(v))
-#else
-#define json_object_add_value_uint64(o, k, v) \
- if ((v) > UINT_MAX) { \
- fprintf(stderr, "Value overflow in %s", k); \
- json_object_object_add(o, k, json_object_new_int(-1)); \
- } else \
- json_object_object_add(o, k, json_object_new_int(v))
-#endif
+#define json_object_add_value_uint128(o, k, v) \
+ json_object_object_add(o, k, util_json_object_new_uint128(v))
#define json_object_add_value_double(o, k, v) \
json_object_object_add(o, k, util_json_object_new_double(v))
#define json_object_add_value_float(o, k, v) \
@@ -45,5 +43,9 @@
JSON_C_TO_STRING_NOSLASHESCAPE))
struct json_object *util_json_object_new_double(long double d);
+struct json_object *util_json_object_new_uint64(uint64_t i);
+struct json_object *util_json_object_new_uint128(nvme_uint128_t val);
+struct json_object *util_json_object_new_uint128(nvme_uint128_t val);
+uint64_t util_json_object_get_uint64(struct json_object *obj);
#endif