116#define CHECK_RES(ctx, res) \
119 ctx->creation_failed = true; \
126#define CHECK_LENGTH(ctx, length) \
128 if (length > SIZE_MAX) { \
129 ctx->creation_failed = true; \
134#define PUSH_CTX_STACK(ctx, res, subitems) \
136 if (_cbor_stack_push(ctx->stack, res, subitems) == NULL) { \
138 ctx->creation_failed = true; \
219 if (new_handle == NULL) {
224 memcpy(new_handle, data, length);
227 if (new_chunk == NULL) {
261 if (new_handle == NULL) {
266 memcpy(new_handle, data, length);
268 if (new_chunk == NULL) {
337 switch (item->
type) {
_cbor_malloc_t _cbor_malloc
bool cbor_array_is_indefinite(const cbor_item_t *item)
Is the array indefinite?
bool cbor_array_push(cbor_item_t *array, cbor_item_t *pushee)
Append to the end.
bool cbor_array_is_definite(const cbor_item_t *item)
Is the array definite?
cbor_item_t * cbor_new_definite_array(size_t size)
Create new definite array.
cbor_item_t * cbor_new_indefinite_array(void)
Create new indefinite array.
void cbor_builder_byte_string_callback(void *context, cbor_data data, uint64_t length)
void cbor_builder_uint64_callback(void *context, uint64_t value)
void cbor_builder_boolean_callback(void *context, bool value)
bool _cbor_is_indefinite(cbor_item_t *item)
Is the (partially constructed) item indefinite?
void cbor_builder_byte_string_start_callback(void *context)
void cbor_builder_array_start_callback(void *context, uint64_t size)
void cbor_builder_string_start_callback(void *context)
void cbor_builder_indef_map_start_callback(void *context)
void cbor_builder_negint16_callback(void *context, uint16_t value)
void cbor_builder_undefined_callback(void *context)
void cbor_builder_negint32_callback(void *context, uint32_t value)
void cbor_builder_null_callback(void *context)
void cbor_builder_map_start_callback(void *context, uint64_t size)
void cbor_builder_uint32_callback(void *context, uint32_t value)
#define CHECK_LENGTH(ctx, length)
#define CHECK_RES(ctx, res)
void cbor_builder_indef_array_start_callback(void *context)
#define PUSH_CTX_STACK(ctx, res, subitems)
void cbor_builder_uint16_callback(void *context, uint16_t value)
void cbor_builder_negint8_callback(void *context, uint8_t value)
void cbor_builder_string_callback(void *context, cbor_data data, uint64_t length)
void cbor_builder_tag_callback(void *context, uint64_t value)
void cbor_builder_uint8_callback(void *context, uint8_t value)
void cbor_builder_float4_callback(void *context, float value)
void cbor_builder_negint64_callback(void *context, uint64_t value)
void _cbor_builder_append(cbor_item_t *item, struct _cbor_decoder_context *ctx)
Internal helper: Append item to the top of the stack while handling errors.
void cbor_builder_float8_callback(void *context, double value)
void cbor_builder_float2_callback(void *context, float value)
void cbor_builder_indef_break_callback(void *context)
bool cbor_bytestring_is_indefinite(const cbor_item_t *item)
Is the byte string indefinite?
cbor_item_t * cbor_new_definite_bytestring(void)
Creates a new definite byte string.
bool cbor_bytestring_add_chunk(cbor_item_t *item, cbor_item_t *chunk)
Appends a chunk to the bytestring.
cbor_item_t * cbor_new_indefinite_bytestring(void)
Creates a new indefinite byte string.
void cbor_bytestring_set_handle(cbor_item_t *item, cbor_mutable_data data, size_t length)
Set the handle to the binary data.
bool cbor_isa_string(const cbor_item_t *item)
Does the item have the appropriate major type?
bool cbor_isa_bytestring(const cbor_item_t *item)
Does the item have the appropriate major type?
void cbor_decref(cbor_item_t **item_ref)
Decreases the item's reference count by one, deallocating the item if needed.
const unsigned char * cbor_data
@ CBOR_TYPE_BYTESTRING
2 - byte strings
@ CBOR_TYPE_STRING
3 - strings
@ CBOR_TYPE_ARRAY
4 - arrays
cbor_item_t * cbor_new_undef(void)
Constructs new undef ctrl item.
cbor_item_t * cbor_new_float2(void)
Constructs a new float item.
cbor_item_t * cbor_new_float8(void)
Constructs a new float item.
void cbor_set_float4(cbor_item_t *item, float value)
Assigns a float value.
void cbor_set_float8(cbor_item_t *item, double value)
Assigns a float value.
cbor_item_t * cbor_build_bool(bool value)
Constructs new boolean ctrl item.
cbor_item_t * cbor_new_null(void)
Constructs new null ctrl item.
void cbor_set_float2(cbor_item_t *item, float value)
Assigns a float value.
cbor_item_t * cbor_new_float4(void)
Constructs a new float item.
void cbor_set_uint16(cbor_item_t *item, uint16_t value)
Assigns the integer value.
cbor_item_t * cbor_new_int32(void)
Allocates new integer with 4B width.
void cbor_set_uint32(cbor_item_t *item, uint32_t value)
Assigns the integer value.
cbor_item_t * cbor_new_int8(void)
Allocates new integer with 1B width.
void cbor_set_uint8(cbor_item_t *item, uint8_t value)
Assigns the integer value.
void cbor_mark_negint(cbor_item_t *item)
Marks the integer item as a negative integer.
cbor_item_t * cbor_new_int64(void)
Allocates new integer with 8B width.
cbor_item_t * cbor_new_int16(void)
Allocates new integer with 2B width.
void cbor_mark_uint(cbor_item_t *item)
Marks the integer item as a positive integer.
void cbor_set_uint64(cbor_item_t *item, uint64_t value)
Assigns the integer value.
bool cbor_map_is_definite(const cbor_item_t *item)
Is this map definite?
bool _cbor_map_add_key(cbor_item_t *item, cbor_item_t *key)
Add a key to the map.
cbor_item_t * cbor_new_indefinite_map(void)
Create a new indefinite map.
bool cbor_map_is_indefinite(const cbor_item_t *item)
Is this map indefinite?
bool _cbor_map_add_value(cbor_item_t *item, cbor_item_t *value)
Add a value to the map.
cbor_item_t * cbor_new_definite_map(size_t size)
Create a new definite map.
void _cbor_stack_pop(struct _cbor_stack *stack)
cbor_item_t * cbor_new_definite_string(void)
Creates a new definite string.
void cbor_string_set_handle(cbor_item_t *item, cbor_mutable_data data, size_t length)
Set the handle to the underlying string.
bool cbor_string_add_chunk(cbor_item_t *item, cbor_item_t *chunk)
Appends a chunk to the string.
cbor_item_t * cbor_new_indefinite_string(void)
Creates a new indefinite string.
bool cbor_string_is_indefinite(const cbor_item_t *item)
Is the string indefinite?
High-level decoding context.
bool creation_failed
Callback creating the last item has failed.
bool syntax_error
Stack expectation mismatch.
struct _cbor_stack * stack
cbor_item_t * item
Item under construction.
size_t subitems
How many outstanding subitems are expected.
struct _cbor_stack_record * top
cbor_type type
Major type discriminator.