summaryrefslogtreecommitdiffhomepage
path: root/types.h
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-05-04 11:41:17 +0200
committerJo-Philipp Wich <jo@mein.io>2021-05-04 11:49:37 +0200
commitc4d1648ca6c3ac005b75c3b3b0bb79e664bead75 (patch)
treeff0968c366537455aa1d7bfc42dff81549016e31 /types.h
parentf2eaea3be2ebf87e2837b728e5a0c67eedf296f5 (diff)
lib: add support for pretty printing JSON to printf() and sprintf()
Honour precision specifiers when parsing `J` format strings to enable or disable JSON pretty printing. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'types.h')
-rw-r--r--types.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/types.h b/types.h
index 9dab246..8e1ba5f 100644
--- a/types.h
+++ b/types.h
@@ -355,8 +355,11 @@ uc_value_t *ucv_from_json(uc_vm *, json_object *);
json_object *ucv_to_json(uc_value_t *);
char *ucv_to_string(uc_vm *, uc_value_t *);
-char *ucv_to_jsonstring(uc_vm *, uc_value_t *);
-void ucv_to_stringbuf(uc_vm *, uc_stringbuf_t *, uc_value_t *, bool);
+char *ucv_to_jsonstring_formatted(uc_vm *, uc_value_t *, char, size_t);
+void ucv_to_stringbuf_formatted(uc_vm *, uc_stringbuf_t *, uc_value_t *, size_t, char, size_t);
+
+#define ucv_to_jsonstring(vm, val) ucv_to_jsonstring_formatted(vm, val, '\1', 0)
+#define ucv_to_stringbuf(vm, buf, val, json) ucv_to_stringbuf_formatted(vm, buf, val, 0, json ? '\1' : '\0', 0)
static inline bool
ucv_is_callable(uc_value_t *uv)