From 7f671b1e68a6664b5baf3e3cffc1bb0880984267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gaul?= Date: Sat, 19 Nov 2016 18:55:49 +0100 Subject: blobmsg: add support for double MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds support for double floating point type to make it more JSON compatible. For type checking it also adds a stub BLOB_ATTR_DOUBLE type. If necessary, the accessor functions for blob can be added later Signed-off-by: André Gaul Signed-off-by: Felix Fietkau --- blobmsg_json.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'blobmsg_json.c') diff --git a/blobmsg_json.c b/blobmsg_json.c index 8a6ed8f..ca9dd1a 100644 --- a/blobmsg_json.c +++ b/blobmsg_json.c @@ -69,6 +69,9 @@ bool blobmsg_add_json_element(struct blob_buf *b, const char *name, json_object case json_type_int: blobmsg_add_u32(b, name, json_object_get_int(obj)); break; + case json_type_double: + blobmsg_add_double(b, name, json_object_get_double(obj)); + break; case json_type_null: blobmsg_add_field(b, BLOBMSG_TYPE_UNSPEC, name, NULL, 0); break; @@ -255,6 +258,9 @@ static void blobmsg_format_element(struct strbuf *s, struct blob_attr *attr, boo case BLOBMSG_TYPE_INT64: sprintf(buf, "%" PRId64, (int64_t) be64_to_cpu(*(uint64_t *)data)); break; + case BLOBMSG_TYPE_DOUBLE: + sprintf(buf, "%lf", blobmsg_get_double(attr)); + break; case BLOBMSG_TYPE_STRING: blobmsg_format_string(s, data); return; -- cgit v1.2.3