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
特此免費獲得許可,免費授予任何獲得此軟件副本和相關文檔文件(“軟件”)的人,以無限制地處理軟件,包括無限制的使用權,複製,複製,修改,合併,發布,分發,分發,分發,分配,sublicense和/或允許軟件允許與以下條件相關的軟件,以下是以下條件。
上述版權通知和此許可通知應包含在軟件的所有副本或大量部分中。
該軟件是“原樣”提供的,沒有任何形式的明示或暗示保證,包括但不限於適銷性,特定目的的適用性和非侵權的保證。在任何情況下,作者或版權持有人均不應對任何索賠,損害賠償或其他責任責任,無論是在合同,侵權的訴訟中還是其他索賠,與軟件或使用或其他軟件中的使用或其他交易有關。