Mercurial > libjeffpc
changeset 707:9890d8dbac1f
val: switch CBOR packing to pack-val op
As a side effect, all nvlist are now encoded as definite length maps.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
line wrap: on
line diff
--- a/tests/nvl-pack/cmd-clear.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/cmd-clear.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿ÿ \ No newline at end of file + \ No newline at end of file
--- a/tests/nvl-pack/cmd-empty.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/cmd-empty.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿ÿ \ No newline at end of file + \ No newline at end of file
--- a/tests/nvl-pack/multi-bb.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/multi-bb.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cabcõcdefôÿ \ No newline at end of file +¢cabcõcdefô \ No newline at end of file
--- a/tests/nvl-pack/multi-ib.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/multi-ib.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cabccdefõÿ \ No newline at end of file +¢cabccdefõ \ No newline at end of file
--- a/tests/nvl-pack/multi-in.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/multi-in.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cabccdeföÿ \ No newline at end of file +¢cabccdefö \ No newline at end of file
--- a/tests/nvl-pack/single-bool-false.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/single-bool-false.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cABCôÿ \ No newline at end of file +¡cABCô \ No newline at end of file
--- a/tests/nvl-pack/single-bool-true.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/single-bool-true.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cABCõÿ \ No newline at end of file +¡cABCõ \ No newline at end of file
--- a/tests/nvl-pack/single-null.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/single-null.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cABCöÿ \ No newline at end of file +¡cABCö \ No newline at end of file
--- a/tests/nvl-pack/single-str.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/single-str.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cABCcDEFÿ \ No newline at end of file +¡cABCcDEF \ No newline at end of file
--- a/tests/nvl-pack/single-u16.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/single-u16.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cABCîÿ \ No newline at end of file +¡cABCî \ No newline at end of file
--- a/tests/nvl-pack/single-u8-medium.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/single-u8-medium.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cABCdÿ \ No newline at end of file +¡cABCd \ No newline at end of file
--- a/tests/nvl-pack/single-u8-tiny.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/single-u8-tiny.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cABCÿ \ No newline at end of file +¡cABC \ No newline at end of file
--- a/tests/nvl-pack/uint-limits-1.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/uint-limits-1.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cabcÿ \ No newline at end of file +¡cabc \ No newline at end of file
--- a/tests/nvl-pack/uint-limits-1311768467463790320.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/uint-limits-1311768467463790320.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cabc4Vxš¼Þðÿ \ No newline at end of file +¡cabc4Vxš¼Þð \ No newline at end of file
--- a/tests/nvl-pack/uint-limits-18446744073709551615.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/uint-limits-18446744073709551615.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cabcÿÿÿÿÿÿÿÿÿ \ No newline at end of file +¡cabcÿÿÿÿÿÿÿÿ \ No newline at end of file
--- a/tests/nvl-pack/uint-limits-23.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/uint-limits-23.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cabcÿ \ No newline at end of file +¡cabc \ No newline at end of file
--- a/tests/nvl-pack/uint-limits-24.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/uint-limits-24.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cabcÿ \ No newline at end of file +¡cabc \ No newline at end of file
--- a/tests/nvl-pack/uint-limits-255.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/uint-limits-255.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cabcÿÿ \ No newline at end of file +¡cabcÿ \ No newline at end of file
--- a/tests/nvl-pack/uint-limits-4294967295.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/uint-limits-4294967295.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cabcÿÿÿÿÿ \ No newline at end of file +¡cabcÿÿÿÿ \ No newline at end of file
--- a/tests/nvl-pack/uint-limits-65535.cbor Mon Mar 18 21:31:12 2019 -0400 +++ b/tests/nvl-pack/uint-limits-65535.cbor Mon Mar 18 21:32:39 2019 -0400 @@ -1,1 +1,1 @@ -¿cabcÿÿÿ \ No newline at end of file +¡cabcÿÿ \ No newline at end of file
--- a/val_fmt_cbor.c Mon Mar 18 21:31:12 2019 -0400 +++ b/val_fmt_cbor.c Mon Mar 18 21:32:39 2019 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * Copyright (c) 2017-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,40 +29,6 @@ * nvl packing interface */ -static int cbor_nvl_prologue(struct buffer *buffer, struct nvlist *nvl) -{ - return cbor_pack_map_start(buffer, CBOR_UNKNOWN_NELEM); -} - -static int cbor_nvl_epilogue(struct buffer *buffer, struct nvlist *nvl) -{ - return cbor_pack_map_end(buffer, CBOR_UNKNOWN_NELEM); -} - -static int cbor_array_prologue(struct buffer *buffer, struct val *const *vals, - size_t nelem) -{ - return cbor_pack_array_start(buffer, nelem); -} - -static int cbor_array_epilogue(struct buffer *buffer, struct val *const *vals, - size_t nelem) -{ - return cbor_pack_array_end(buffer, nelem); -} - const struct valops valops_cbor = { - .pack = { - .nvl_prologue = cbor_nvl_prologue, - .nvl_epilogue = cbor_nvl_epilogue, - - .array_prologue = cbor_array_prologue, - .array_epilogue = cbor_array_epilogue, - - .val_blob = cbor_pack_blob, - .val_bool = cbor_pack_bool, - .val_int = cbor_pack_uint, - .val_null = cbor_pack_null, - .val_str = cbor_pack_cstr, - } + .pack_val = cbor_pack_val, };