libcbor
0.11.0 (2024-02-04)
LIBCBOR是用于解析和生成CBOR的C库,CBOR是通用模式的二进制数据格式。
git clone https://github.com/PJK/libcbor
cmake -DCMAKE_BUILD_TYPE=Release libcbor
make
make installbrew install libcborsudo add-apt-repository universe
sudo apt-get install libcbor-devyum install libcbor-devel #include <cbor.h>
#include <stdio.h>
int main ( void ) {
/* Preallocate the map structure */
cbor_item_t * root = cbor_new_definite_map ( 2 );
/* Add the content */
bool success = cbor_map_add (
root , ( struct cbor_pair ){
. key = cbor_move ( cbor_build_string ( "Is CBOR awesome?" )),
. value = cbor_move ( cbor_build_bool (true))});
success &= cbor_map_add (
root , ( struct cbor_pair ){
. key = cbor_move ( cbor_build_uint8 ( 42 )),
. value = cbor_move ( cbor_build_string ( "Is the answer" ))});
if (! success ) return 1 ;
/* Output: `length` bytes of data in the `buffer` */
unsigned char * buffer ;
size_t buffer_size ;
cbor_serialize_alloc ( root , & buffer , & buffer_size );
fwrite ( buffer , 1 , buffer_size , stdout );
free ( buffer );
fflush ( stdout );
cbor_decref ( & root );
}在libcbor.readthedocs.org上获取最新文档
欢迎错误报告和贡献。有关更多信息,请参见dragting.md。
对所有贡献者表示敬意!
麻省理工学院许可证(MIT)
版权(C)Pavel Kalvoda,2014-2020
特此免费授予获得此软件副本和相关文档文件副本(“软件”)的任何人,以无限制处理该软件,包括无限制的使用权,复制,复制,修改,合并,合并,发布,分发,分发,分发,订婚,和/或允许软件的副本,并允许对以下条件提供以下条件,以下是以下条件。
上述版权通知和此许可通知应包含在软件的所有副本或大量部分中。
该软件是“原样”提供的,没有任何形式的明示或暗示保证,包括但不限于适销性,特定目的的适用性和非侵权的保证。在任何情况下,作者或版权持有人都不应对任何索赔,损害赔偿或其他责任责任,无论是在合同,侵权的诉讼中还是其他责任,是由软件,使用或与软件中的使用或其他交易有关的。