libcbor
0.5.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
|
#include "cbor/common.h"
Go to the source code of this file.
Functions | |
size_t | cbor_bytestring_length (const cbor_item_t *item) |
Returns the length of the binary data. More... | |
bool | cbor_bytestring_is_definite (const cbor_item_t *item) |
Is the byte string definite? More... | |
bool | cbor_bytestring_is_indefinite (const cbor_item_t *item) |
Is the byte string indefinite? More... | |
cbor_mutable_data | cbor_bytestring_handle (const cbor_item_t *item) |
Get the handle to the binary data. More... | |
void | cbor_bytestring_set_handle (cbor_item_t *item, cbor_mutable_data CBOR_RESTRICT_POINTER data, size_t length) |
Set the handle to the binary data. More... | |
cbor_item_t ** | cbor_bytestring_chunks_handle (const cbor_item_t *item) |
Get the handle to the array of chunks. More... | |
size_t | cbor_bytestring_chunk_count (const cbor_item_t *item) |
Get the number of chunks this string consist of. More... | |
bool | cbor_bytestring_add_chunk (cbor_item_t *item, cbor_item_t *chunk) |
Appends a chunk to the bytestring. More... | |
cbor_item_t * | cbor_new_definite_bytestring () |
Creates a new definite byte string. More... | |
cbor_item_t * | cbor_new_indefinite_bytestring () |
Creates a new indefinite byte string. More... | |
cbor_item_t * | cbor_build_bytestring (cbor_data handle, size_t length) |
Creates a new byte string and initializes it. More... | |
cbor_item_t* cbor_build_bytestring | ( | cbor_data | handle, |
size_t | length | ||
) |
Creates a new byte string and initializes it.
The handle
will be copied to a newly allocated block
handle | Block of binary data |
length | Length of data |
handle
. NULL
on malloc failure. Definition at line 63 of file bytestrings.c.
bool cbor_bytestring_add_chunk | ( | cbor_item_t * | item, |
cbor_item_t * | chunk | ||
) |
Appends a chunk to the bytestring.
Indefinite byte strings only.
May realloc the chunk storage.
item[borrow] | An indefinite byte string |
item[incref] | A definite byte string |
chunk
is not increased and the item
is left intact. Definition at line 95 of file bytestrings.c.
size_t cbor_bytestring_chunk_count | ( | const cbor_item_t * | item | ) |
Get the number of chunks this string consist of.
item[borrow] | A indefinite bytestring |
Definition at line 87 of file bytestrings.c.
cbor_item_t** cbor_bytestring_chunks_handle | ( | const cbor_item_t * | item | ) |
Get the handle to the array of chunks.
Manipulations with the memory block (e.g. sorting it) are allowed, but the validity and the number of chunks must be retained.
item[borrow] | A indefinite byte string |
Definition at line 80 of file bytestrings.c.
cbor_mutable_data cbor_bytestring_handle | ( | const cbor_item_t * | item | ) |
Get the handle to the binary data.
Definite items only. Modifying the data is allowed. In that case, the caller takes responsibility for the effect on items this item might be a part of
item[borrow] | A definite byte string |
NULL
if no data have been assigned yet. Definition at line 18 of file bytestrings.c.
bool cbor_bytestring_is_definite | ( | const cbor_item_t * | item | ) |
Is the byte string definite?
item[borrow] | a byte string |
Definition at line 24 of file bytestrings.c.
bool cbor_bytestring_is_indefinite | ( | const cbor_item_t * | item | ) |
Is the byte string indefinite?
item[borrow] | a byte string |
Definition at line 30 of file bytestrings.c.
size_t cbor_bytestring_length | ( | const cbor_item_t * | item | ) |
Returns the length of the binary data.
For definite byte strings only
item[borrow] | a definite bytestring |
Definition at line 12 of file bytestrings.c.
void cbor_bytestring_set_handle | ( | cbor_item_t * | item, |
cbor_mutable_data CBOR_RESTRICT_POINTER | data, | ||
size_t | length | ||
) |
Set the handle to the binary data.
item[borrow] | A definite byte string |
data | The memory block. The caller gives up the ownership of the block. libcbor will deallocate it when appropriate using its free function |
length | Length of the data block |
Definition at line 72 of file bytestrings.c.
cbor_item_t* cbor_new_definite_bytestring | ( | ) |
Creates a new definite byte string.
The handle is initialized to NULL
and length to 0
NULL
on malloc failure. Definition at line 35 of file bytestrings.c.
cbor_item_t* cbor_new_indefinite_bytestring | ( | ) |
Creates a new indefinite byte string.
The chunks array is initialized to NULL
and chunkcount to 0
NULL
on malloc failure. Definition at line 46 of file bytestrings.c.