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 --- examples/blobmsg-example.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'examples') diff --git a/examples/blobmsg-example.c b/examples/blobmsg-example.c index 01b0518..1c86017 100644 --- a/examples/blobmsg-example.c +++ b/examples/blobmsg-example.c @@ -49,6 +49,9 @@ static void dump_attr_data(struct blob_attr *data, int indent, int next_indent) case BLOBMSG_TYPE_INT64: indent_printf(indent, "%"PRIu64"\n", blobmsg_get_u64(data)); break; + case BLOBMSG_TYPE_DOUBLE: + indent_printf(indent, "%lf\n", blobmsg_get_double(data)); + break; case BLOBMSG_TYPE_TABLE: case BLOBMSG_TYPE_ARRAY: if (!indent) @@ -113,6 +116,7 @@ fill_message(struct blob_buf *buf) blobmsg_add_string(buf, "message", "Hello, world!"); tbl = blobmsg_open_table(buf, "testdata"); + blobmsg_add_double(buf, "double", 1.337e2); blobmsg_add_u32(buf, "hello", 1); blobmsg_add_string(buf, "world", "2"); blobmsg_close_table(buf, tbl); @@ -121,6 +125,7 @@ fill_message(struct blob_buf *buf) blobmsg_add_u32(buf, NULL, 0); blobmsg_add_u32(buf, NULL, 1); blobmsg_add_u32(buf, NULL, 2); + blobmsg_add_double(buf, "double", 1.337e2); blobmsg_close_table(buf, tbl); } -- cgit v1.2.3