Path: blob/main/contrib/libcbor/src/cbor/callbacks.h
39488 views
/*1* Copyright (c) 2014-2020 Pavel Kalvoda <[email protected]>2*3* libcbor is free software; you can redistribute it and/or modify4* it under the terms of the MIT license. See LICENSE for details.5*/67#ifndef LIBCBOR_CALLBACKS_H8#define LIBCBOR_CALLBACKS_H910#include <stdint.h>1112#include "cbor/cbor_export.h"13#include "cbor/common.h"1415#ifdef __cplusplus16extern "C" {17#endif1819/** Callback prototype */20typedef void (*cbor_int8_callback)(void *, uint8_t);2122/** Callback prototype */23typedef void (*cbor_int16_callback)(void *, uint16_t);2425/** Callback prototype */26typedef void (*cbor_int32_callback)(void *, uint32_t);2728/** Callback prototype */29typedef void (*cbor_int64_callback)(void *, uint64_t);3031/** Callback prototype */32typedef void (*cbor_simple_callback)(void *);3334/** Callback prototype */35typedef void (*cbor_string_callback)(void *, cbor_data, uint64_t);3637/** Callback prototype */38typedef void (*cbor_collection_callback)(void *, uint64_t);3940/** Callback prototype */41typedef void (*cbor_float_callback)(void *, float);4243/** Callback prototype */44typedef void (*cbor_double_callback)(void *, double);4546/** Callback prototype */47typedef void (*cbor_bool_callback)(void *, bool);4849/** Callback bundle -- passed to the decoder */50struct cbor_callbacks {51/** Unsigned int */52cbor_int8_callback uint8;53/** Unsigned int */54cbor_int16_callback uint16;55/** Unsigned int */56cbor_int32_callback uint32;57/** Unsigned int */58cbor_int64_callback uint64;5960/** Negative int */61cbor_int64_callback negint64;62/** Negative int */63cbor_int32_callback negint32;64/** Negative int */65cbor_int16_callback negint16;66/** Negative int */67cbor_int8_callback negint8;6869/** Definite byte string */70cbor_simple_callback byte_string_start;71/** Indefinite byte string start */72cbor_string_callback byte_string;7374/** Definite string */75cbor_string_callback string;76/** Indefinite string start */77cbor_simple_callback string_start;7879/** Definite array */80cbor_simple_callback indef_array_start;81/** Indefinite array */82cbor_collection_callback array_start;8384/** Definite map */85cbor_simple_callback indef_map_start;86/** Indefinite map */87cbor_collection_callback map_start;8889/** Tags */90cbor_int64_callback tag;9192/** Half float */93cbor_float_callback float2;94/** Single float */95cbor_float_callback float4;96/** Double float */97cbor_double_callback float8;98/** Undef */99cbor_simple_callback undefined;100/** Null */101cbor_simple_callback null;102/** Bool */103cbor_bool_callback boolean;104105/** Indefinite item break */106cbor_simple_callback indef_break;107};108109/** Dummy callback implementation - does nothing */110CBOR_EXPORT void cbor_null_uint8_callback(void *, uint8_t);111112/** Dummy callback implementation - does nothing */113CBOR_EXPORT void cbor_null_uint16_callback(void *, uint16_t);114115/** Dummy callback implementation - does nothing */116CBOR_EXPORT void cbor_null_uint32_callback(void *, uint32_t);117118/** Dummy callback implementation - does nothing */119CBOR_EXPORT void cbor_null_uint64_callback(void *, uint64_t);120121/** Dummy callback implementation - does nothing */122CBOR_EXPORT void cbor_null_negint8_callback(void *, uint8_t);123124/** Dummy callback implementation - does nothing */125CBOR_EXPORT void cbor_null_negint16_callback(void *, uint16_t);126127/** Dummy callback implementation - does nothing */128CBOR_EXPORT void cbor_null_negint32_callback(void *, uint32_t);129130/** Dummy callback implementation - does nothing */131CBOR_EXPORT void cbor_null_negint64_callback(void *, uint64_t);132133/** Dummy callback implementation - does nothing */134CBOR_EXPORT void cbor_null_string_callback(void *, cbor_data, uint64_t);135136/** Dummy callback implementation - does nothing */137CBOR_EXPORT void cbor_null_string_start_callback(void *);138139/** Dummy callback implementation - does nothing */140CBOR_EXPORT void cbor_null_byte_string_callback(void *, cbor_data, uint64_t);141142/** Dummy callback implementation - does nothing */143CBOR_EXPORT void cbor_null_byte_string_start_callback(void *);144145/** Dummy callback implementation - does nothing */146CBOR_EXPORT void cbor_null_array_start_callback(void *, uint64_t);147148/** Dummy callback implementation - does nothing */149CBOR_EXPORT void cbor_null_indef_array_start_callback(void *);150151/** Dummy callback implementation - does nothing */152CBOR_EXPORT void cbor_null_map_start_callback(void *, uint64_t);153154/** Dummy callback implementation - does nothing */155CBOR_EXPORT void cbor_null_indef_map_start_callback(void *);156157/** Dummy callback implementation - does nothing */158CBOR_EXPORT void cbor_null_tag_callback(void *, uint64_t);159160/** Dummy callback implementation - does nothing */161CBOR_EXPORT void cbor_null_float2_callback(void *, float);162163/** Dummy callback implementation - does nothing */164CBOR_EXPORT void cbor_null_float4_callback(void *, float);165166/** Dummy callback implementation - does nothing */167CBOR_EXPORT void cbor_null_float8_callback(void *, double);168169/** Dummy callback implementation - does nothing */170CBOR_EXPORT void cbor_null_null_callback(void *);171172/** Dummy callback implementation - does nothing */173CBOR_EXPORT void cbor_null_undefined_callback(void *);174175/** Dummy callback implementation - does nothing */176CBOR_EXPORT void cbor_null_boolean_callback(void *, bool);177178/** Dummy callback implementation - does nothing */179CBOR_EXPORT void cbor_null_indef_break_callback(void *);180181/** Dummy callback bundle - does nothing */182CBOR_EXPORT extern const struct cbor_callbacks cbor_empty_callbacks;183184#ifdef __cplusplus185}186#endif187188#endif // LIBCBOR_CALLBACKS_H189190191