1 /* 2 * Copyright (c) 2014-2020 Pavel Kalvoda <me@pavelkalvoda.com> 3 * 4 * libcbor is free software; you can redistribute it and/or modify 5 * it under the terms of the MIT license. See LICENSE for details. 6 */ 7 8 #ifndef LIBCBOR_BUILDER_CALLBACKS_H 9 #define LIBCBOR_BUILDER_CALLBACKS_H 10 11 #include "../callbacks.h" 12 #include "cbor/common.h" 13 #include "stack.h" 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 /** High-level decoding context */ 20 struct _cbor_decoder_context { 21 /** Callback creating the last item has failed */ 22 bool creation_failed; 23 /** Stack expectation mismatch */ 24 bool syntax_error; 25 cbor_item_t *root; 26 struct _cbor_stack *stack; 27 }; 28 29 /** Internal helper: Append item to the top of the stack while handling errors. 30 */ 31 void _cbor_builder_append(cbor_item_t *item, struct _cbor_decoder_context *ctx); 32 33 void cbor_builder_uint8_callback(void *, uint8_t); 34 35 void cbor_builder_uint16_callback(void *, uint16_t); 36 37 void cbor_builder_uint32_callback(void *, uint32_t); 38 39 void cbor_builder_uint64_callback(void *, uint64_t); 40 41 void cbor_builder_negint8_callback(void *, uint8_t); 42 43 void cbor_builder_negint16_callback(void *, uint16_t); 44 45 void cbor_builder_negint32_callback(void *, uint32_t); 46 47 void cbor_builder_negint64_callback(void *, uint64_t); 48 49 void cbor_builder_string_callback(void *, cbor_data, uint64_t); 50 51 void cbor_builder_string_start_callback(void *); 52 53 void cbor_builder_byte_string_callback(void *, cbor_data, uint64_t); 54 55 void cbor_builder_byte_string_start_callback(void *); 56 57 void cbor_builder_array_start_callback(void *, uint64_t); 58 59 void cbor_builder_indef_array_start_callback(void *); 60 61 void cbor_builder_map_start_callback(void *, uint64_t); 62 63 void cbor_builder_indef_map_start_callback(void *); 64 65 void cbor_builder_tag_callback(void *, uint64_t); 66 67 void cbor_builder_float2_callback(void *, float); 68 69 void cbor_builder_float4_callback(void *, float); 70 71 void cbor_builder_float8_callback(void *, double); 72 73 void cbor_builder_null_callback(void *); 74 75 void cbor_builder_undefined_callback(void *); 76 77 void cbor_builder_boolean_callback(void *, bool); 78 79 void cbor_builder_indef_break_callback(void *); 80 81 #ifdef __cplusplus 82 } 83 #endif 84 85 #endif // LIBCBOR_BUILDER_CALLBACKS_H 86