Libcbor adalah perpustakaan C untuk parsing dan menghasilkan CBOR, format data biner tanpa skema umum.
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 );
}Dapatkan dokumentasi terbaru di libcbor.readthedocs.org
Laporan dan kontribusi bug dipersilakan. Silakan lihat Contributing.md untuk info lebih lanjut.
Kudos untuk semua kontributor!
Lisensi MIT (MIT)
Hak Cipta (C) Pavel Kalvoda, 2014-2020
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Pemberitahuan hak cipta di atas dan pemberitahuan izin ini harus dimasukkan dalam semua salinan atau bagian substansial dari perangkat lunak.
Perangkat lunak ini disediakan "sebagaimana adanya", tanpa jaminan apa pun, tersurat maupun tersirat, termasuk tetapi tidak terbatas pada jaminan dapat diperjualbelikan, kebugaran untuk tujuan tertentu dan nonpringement. Dalam hal apa pun penulis atau pemegang hak cipta tidak akan bertanggung jawab atas klaim, kerusakan atau tanggung jawab lainnya, baik dalam tindakan kontrak, gugatan atau sebaliknya, timbul dari, di luar atau sehubungan dengan perangkat lunak atau penggunaan atau transaksi lain dalam perangkat lunak.