summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-03-23 19:52:14 +0100
committerJo-Philipp Wich <jo@mein.io>2022-03-31 10:03:30 +0200
commit77942af25401d1bfb4d159898a278ef42fd36f7b (patch)
tree7bc93abed3a86dd224aa621be38be5bd577eec72 /include
parent0b4aaa3c2bbc3f582d7cbc3f4efb7b1ae3a2d82c (diff)
build: add polyfills for older libjson-c versions
The libjson-c versions commonly shipped by Debian and Ubuntu lack unsigned 64bit integer support and a number of extended API functions. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'include')
-rw-r--r--include/ucode/util.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/ucode/util.h b/include/ucode/util.h
index 3203499..35c1e56 100644
--- a/include/ucode/util.h
+++ b/include/ucode/util.h
@@ -159,4 +159,30 @@ static inline struct printbuf *xprintbuf_new(void) {
return pb;
}
+
+/* json-c compat */
+
+#ifndef HAVE_PARSE_END
+static inline size_t json_tokener_get_parse_end(struct json_tokener *tok) {
+ return (size_t)tok->char_offset;
+}
+#endif
+
+#ifndef HAVE_ARRAY_EXT
+static inline struct json_object *json_object_new_array_ext(int size) {
+ (void) size;
+ return json_object_new_array();
+}
+#endif
+
+#ifndef HAVE_JSON_UINT64
+static inline struct json_object *json_object_new_uint64(uint64_t i) {
+ return json_object_new_int64((int64_t)i);
+}
+
+static inline uint64_t json_object_get_uint64(const struct json_object *obj) {
+ return (uint64_t)json_object_get_int64(obj);
+}
+#endif
+
#endif /* UCODE_UTIL_H */