commit | cb2277a49f5bc69b8c6e9d0749eb3ca3480bd626 | [log] [tgz] |
---|---|---|
author | Scott Bertin <sbertin@telular.com> | Mon Apr 23 12:00:35 2018 -0400 |
committer | Scott Bertin <sbertin@telular.com> | Mon Apr 23 12:20:15 2018 -0400 |
tree | baed6f00a72b8bc9e65aa8b1b599560c8cb825d4 | |
parent | 7f04380047c886e078e89da39a0d01c9b8ababf9 [diff] |
Determine buffer size needed without encoding. If a NULL buffer is passed to cn_cbor_encoder_write, it will determine the necessary size of the buffer without doing the encoding. The buf_size parameter can still set an upper limit on the size.
This is a constrained node implementation of CBOR in C that I threw together in 2013, before the publication of RFC 7049, to validate certain implementability considerations.
Its API model was inspired by nxjson. It turns out that this API model actually works even better with the advantages of the CBOR format.
This code has been used in a number of research implementations on constrained nodes, with resulting code sizes appreciably under 1 KiB on ARM platforms.
I always meant to improve the interface some more with certain API changes, in order to get even closer to 0.5 KiB, but I ran out of time. So here it is. If I do get around to making these changes, the API will indeed change a bit, so please be forewarned.
There is a Simple-Makefile
for playing around, as well as a complete cmake
-based build environment. (You can choose what fits your needs better.)
Building with cmake
:
./build.sh
Building including testing:
./build.sh all test
Generating a test coverage report (requires lcov[^1]; result in build/lcov/index.html
):
./build.sh all coveralls coverage_report
License: MIT
[^1]: Installation with homebrew: brew install lcov