110ff414cSEd Maste /* 210ff414cSEd Maste * Copyright (c) 2014-2020 Pavel Kalvoda <me@pavelkalvoda.com> 310ff414cSEd Maste * 410ff414cSEd Maste * libcbor is free software; you can redistribute it and/or modify 510ff414cSEd Maste * it under the terms of the MIT license. See LICENSE for details. 610ff414cSEd Maste */ 710ff414cSEd Maste 810ff414cSEd Maste #ifndef LIBCBOR_CALLBACKS_H 910ff414cSEd Maste #define LIBCBOR_CALLBACKS_H 1010ff414cSEd Maste 11*5d3e7166SEd Maste #include <stdint.h> 12*5d3e7166SEd Maste 1310ff414cSEd Maste #include "cbor/cbor_export.h" 1410ff414cSEd Maste #include "cbor/common.h" 1510ff414cSEd Maste 1610ff414cSEd Maste #ifdef __cplusplus 1710ff414cSEd Maste extern "C" { 1810ff414cSEd Maste #endif 1910ff414cSEd Maste 2010ff414cSEd Maste /** Callback prototype */ 2110ff414cSEd Maste typedef void (*cbor_int8_callback)(void *, uint8_t); 2210ff414cSEd Maste 2310ff414cSEd Maste /** Callback prototype */ 2410ff414cSEd Maste typedef void (*cbor_int16_callback)(void *, uint16_t); 2510ff414cSEd Maste 2610ff414cSEd Maste /** Callback prototype */ 2710ff414cSEd Maste typedef void (*cbor_int32_callback)(void *, uint32_t); 2810ff414cSEd Maste 2910ff414cSEd Maste /** Callback prototype */ 3010ff414cSEd Maste typedef void (*cbor_int64_callback)(void *, uint64_t); 3110ff414cSEd Maste 3210ff414cSEd Maste /** Callback prototype */ 3310ff414cSEd Maste typedef void (*cbor_simple_callback)(void *); 3410ff414cSEd Maste 3510ff414cSEd Maste /** Callback prototype */ 36*5d3e7166SEd Maste typedef void (*cbor_string_callback)(void *, cbor_data, uint64_t); 3710ff414cSEd Maste 3810ff414cSEd Maste /** Callback prototype */ 39*5d3e7166SEd Maste typedef void (*cbor_collection_callback)(void *, uint64_t); 4010ff414cSEd Maste 4110ff414cSEd Maste /** Callback prototype */ 4210ff414cSEd Maste typedef void (*cbor_float_callback)(void *, float); 4310ff414cSEd Maste 4410ff414cSEd Maste /** Callback prototype */ 4510ff414cSEd Maste typedef void (*cbor_double_callback)(void *, double); 4610ff414cSEd Maste 4710ff414cSEd Maste /** Callback prototype */ 4810ff414cSEd Maste typedef void (*cbor_bool_callback)(void *, bool); 4910ff414cSEd Maste 5010ff414cSEd Maste /** Callback bundle -- passed to the decoder */ 5110ff414cSEd Maste struct cbor_callbacks { 5210ff414cSEd Maste /** Unsigned int */ 5310ff414cSEd Maste cbor_int8_callback uint8; 5410ff414cSEd Maste /** Unsigned int */ 5510ff414cSEd Maste cbor_int16_callback uint16; 5610ff414cSEd Maste /** Unsigned int */ 5710ff414cSEd Maste cbor_int32_callback uint32; 5810ff414cSEd Maste /** Unsigned int */ 5910ff414cSEd Maste cbor_int64_callback uint64; 6010ff414cSEd Maste 6110ff414cSEd Maste /** Negative int */ 6210ff414cSEd Maste cbor_int64_callback negint64; 6310ff414cSEd Maste /** Negative int */ 6410ff414cSEd Maste cbor_int32_callback negint32; 6510ff414cSEd Maste /** Negative int */ 6610ff414cSEd Maste cbor_int16_callback negint16; 6710ff414cSEd Maste /** Negative int */ 6810ff414cSEd Maste cbor_int8_callback negint8; 6910ff414cSEd Maste 7010ff414cSEd Maste /** Definite byte string */ 7110ff414cSEd Maste cbor_simple_callback byte_string_start; 7210ff414cSEd Maste /** Indefinite byte string start */ 7310ff414cSEd Maste cbor_string_callback byte_string; 7410ff414cSEd Maste 7510ff414cSEd Maste /** Definite string */ 7610ff414cSEd Maste cbor_string_callback string; 7710ff414cSEd Maste /** Indefinite string start */ 7810ff414cSEd Maste cbor_simple_callback string_start; 7910ff414cSEd Maste 8010ff414cSEd Maste /** Definite array */ 8110ff414cSEd Maste cbor_simple_callback indef_array_start; 8210ff414cSEd Maste /** Indefinite array */ 8310ff414cSEd Maste cbor_collection_callback array_start; 8410ff414cSEd Maste 8510ff414cSEd Maste /** Definite map */ 8610ff414cSEd Maste cbor_simple_callback indef_map_start; 8710ff414cSEd Maste /** Indefinite map */ 8810ff414cSEd Maste cbor_collection_callback map_start; 8910ff414cSEd Maste 9010ff414cSEd Maste /** Tags */ 9110ff414cSEd Maste cbor_int64_callback tag; 9210ff414cSEd Maste 9310ff414cSEd Maste /** Half float */ 9410ff414cSEd Maste cbor_float_callback float2; 9510ff414cSEd Maste /** Single float */ 9610ff414cSEd Maste cbor_float_callback float4; 9710ff414cSEd Maste /** Double float */ 9810ff414cSEd Maste cbor_double_callback float8; 9910ff414cSEd Maste /** Undef */ 10010ff414cSEd Maste cbor_simple_callback undefined; 10110ff414cSEd Maste /** Null */ 10210ff414cSEd Maste cbor_simple_callback null; 10310ff414cSEd Maste /** Bool */ 10410ff414cSEd Maste cbor_bool_callback boolean; 10510ff414cSEd Maste 10610ff414cSEd Maste /** Indefinite item break */ 10710ff414cSEd Maste cbor_simple_callback indef_break; 10810ff414cSEd Maste }; 10910ff414cSEd Maste 11010ff414cSEd Maste /** Dummy callback implementation - does nothing */ 11110ff414cSEd Maste CBOR_EXPORT void cbor_null_uint8_callback(void *, uint8_t); 11210ff414cSEd Maste 11310ff414cSEd Maste /** Dummy callback implementation - does nothing */ 11410ff414cSEd Maste CBOR_EXPORT void cbor_null_uint16_callback(void *, uint16_t); 11510ff414cSEd Maste 11610ff414cSEd Maste /** Dummy callback implementation - does nothing */ 11710ff414cSEd Maste CBOR_EXPORT void cbor_null_uint32_callback(void *, uint32_t); 11810ff414cSEd Maste 11910ff414cSEd Maste /** Dummy callback implementation - does nothing */ 12010ff414cSEd Maste CBOR_EXPORT void cbor_null_uint64_callback(void *, uint64_t); 12110ff414cSEd Maste 12210ff414cSEd Maste /** Dummy callback implementation - does nothing */ 12310ff414cSEd Maste CBOR_EXPORT void cbor_null_negint8_callback(void *, uint8_t); 12410ff414cSEd Maste 12510ff414cSEd Maste /** Dummy callback implementation - does nothing */ 12610ff414cSEd Maste CBOR_EXPORT void cbor_null_negint16_callback(void *, uint16_t); 12710ff414cSEd Maste 12810ff414cSEd Maste /** Dummy callback implementation - does nothing */ 12910ff414cSEd Maste CBOR_EXPORT void cbor_null_negint32_callback(void *, uint32_t); 13010ff414cSEd Maste 13110ff414cSEd Maste /** Dummy callback implementation - does nothing */ 13210ff414cSEd Maste CBOR_EXPORT void cbor_null_negint64_callback(void *, uint64_t); 13310ff414cSEd Maste 13410ff414cSEd Maste /** Dummy callback implementation - does nothing */ 135*5d3e7166SEd Maste CBOR_EXPORT void cbor_null_string_callback(void *, cbor_data, uint64_t); 13610ff414cSEd Maste 13710ff414cSEd Maste /** Dummy callback implementation - does nothing */ 13810ff414cSEd Maste CBOR_EXPORT void cbor_null_string_start_callback(void *); 13910ff414cSEd Maste 14010ff414cSEd Maste /** Dummy callback implementation - does nothing */ 141*5d3e7166SEd Maste CBOR_EXPORT void cbor_null_byte_string_callback(void *, cbor_data, uint64_t); 14210ff414cSEd Maste 14310ff414cSEd Maste /** Dummy callback implementation - does nothing */ 14410ff414cSEd Maste CBOR_EXPORT void cbor_null_byte_string_start_callback(void *); 14510ff414cSEd Maste 14610ff414cSEd Maste /** Dummy callback implementation - does nothing */ 147*5d3e7166SEd Maste CBOR_EXPORT void cbor_null_array_start_callback(void *, uint64_t); 14810ff414cSEd Maste 14910ff414cSEd Maste /** Dummy callback implementation - does nothing */ 15010ff414cSEd Maste CBOR_EXPORT void cbor_null_indef_array_start_callback(void *); 15110ff414cSEd Maste 15210ff414cSEd Maste /** Dummy callback implementation - does nothing */ 153*5d3e7166SEd Maste CBOR_EXPORT void cbor_null_map_start_callback(void *, uint64_t); 15410ff414cSEd Maste 15510ff414cSEd Maste /** Dummy callback implementation - does nothing */ 15610ff414cSEd Maste CBOR_EXPORT void cbor_null_indef_map_start_callback(void *); 15710ff414cSEd Maste 15810ff414cSEd Maste /** Dummy callback implementation - does nothing */ 15910ff414cSEd Maste CBOR_EXPORT void cbor_null_tag_callback(void *, uint64_t); 16010ff414cSEd Maste 16110ff414cSEd Maste /** Dummy callback implementation - does nothing */ 16210ff414cSEd Maste CBOR_EXPORT void cbor_null_float2_callback(void *, float); 16310ff414cSEd Maste 16410ff414cSEd Maste /** Dummy callback implementation - does nothing */ 16510ff414cSEd Maste CBOR_EXPORT void cbor_null_float4_callback(void *, float); 16610ff414cSEd Maste 16710ff414cSEd Maste /** Dummy callback implementation - does nothing */ 16810ff414cSEd Maste CBOR_EXPORT void cbor_null_float8_callback(void *, double); 16910ff414cSEd Maste 17010ff414cSEd Maste /** Dummy callback implementation - does nothing */ 17110ff414cSEd Maste CBOR_EXPORT void cbor_null_null_callback(void *); 17210ff414cSEd Maste 17310ff414cSEd Maste /** Dummy callback implementation - does nothing */ 17410ff414cSEd Maste CBOR_EXPORT void cbor_null_undefined_callback(void *); 17510ff414cSEd Maste 17610ff414cSEd Maste /** Dummy callback implementation - does nothing */ 17710ff414cSEd Maste CBOR_EXPORT void cbor_null_boolean_callback(void *, bool); 17810ff414cSEd Maste 17910ff414cSEd Maste /** Dummy callback implementation - does nothing */ 18010ff414cSEd Maste CBOR_EXPORT void cbor_null_indef_break_callback(void *); 18110ff414cSEd Maste 18210ff414cSEd Maste /** Dummy callback bundle - does nothing */ 18310ff414cSEd Maste CBOR_EXPORT extern const struct cbor_callbacks cbor_empty_callbacks; 18410ff414cSEd Maste 18510ff414cSEd Maste #ifdef __cplusplus 18610ff414cSEd Maste } 18710ff414cSEd Maste #endif 18810ff414cSEd Maste 18910ff414cSEd Maste #endif // LIBCBOR_CALLBACKS_H 190