Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Gaul <andre@gaul.io>2016-11-19 20:55:49 +0300
committerFelix Fietkau <nbd@nbd.name>2017-01-04 23:36:31 +0300
commit7f671b1e68a6664b5baf3e3cffc1bb0880984267 (patch)
treeb8c212bc9c1fcf230975f5a0e2d86bfec6420c5c /examples
parent0fe13749d095ca22c788e55902979323e85367c3 (diff)
blobmsg: add support for double
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 <andre@gaul.io> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'examples')
-rw-r--r--examples/blobmsg-example.c5
1 files changed, 5 insertions, 0 deletions
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);
}