libcbor 0.12.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
Loading...
Searching...
No Matches
streaming.c File Reference
#include "streaming.h"
#include "internal/loaders.h"

Go to the source code of this file.

Macros

#define CLAIM_BYTES_AND_INVOKE(callback_name, length, source_extra_offset)
 
#define READ_CLAIM_INVOKE(callback_name, length_reader, length_bytes)
 

Functions

struct cbor_decoder_result cbor_stream_decode (cbor_data source, size_t source_size, const struct cbor_callbacks *callbacks, void *context)
 Stateless decoder.
 

Macro Definition Documentation

◆ CLAIM_BYTES_AND_INVOKE

#define CLAIM_BYTES_AND_INVOKE ( callback_name,
length,
source_extra_offset )
Value:
do { \
if (claim_bytes(length, source_size, &result)) { \
callbacks->callback_name(context, source + 1 + source_extra_offset, \
length); \
} \
} while (0)

Definition at line 26 of file streaming.c.

◆ READ_CLAIM_INVOKE

#define READ_CLAIM_INVOKE ( callback_name,
length_reader,
length_bytes )
Value:
do { \
if (claim_bytes(length_bytes, source_size, &result)) { \
uint64_t length = length_reader(source + 1); \
CLAIM_BYTES_AND_INVOKE(callback_name, length, length_bytes); \
} \
return result; \
} while (0)

Definition at line 34 of file streaming.c.

Function Documentation

◆ cbor_stream_decode()

struct cbor_decoder_result cbor_stream_decode ( cbor_data source,
size_t source_size,
const struct cbor_callbacks * callbacks,
void * context )

Stateless decoder.

Will try parsing the source and will invoke the appropriate callback on success. Decodes one item at a time. No memory allocations occur.

Parameters
sourceInput buffer
source_sizeLength of the buffer
callbacksThe callback bundle
contextAn arbitrary pointer to allow for maintaining context.

Definition at line 43 of file streaming.c.