xref: /freebsd-src/contrib/libcbor/src/cbor/internal/builder_callbacks.h (revision 5d3e7166f6a0187fa3f8831b16a06bd9955c21ff)
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_BUILDER_CALLBACKS_H
910ff414cSEd Maste #define LIBCBOR_BUILDER_CALLBACKS_H
1010ff414cSEd Maste 
1110ff414cSEd Maste #include "../callbacks.h"
1210ff414cSEd Maste #include "cbor/common.h"
1310ff414cSEd Maste #include "stack.h"
1410ff414cSEd Maste 
1510ff414cSEd Maste #ifdef __cplusplus
1610ff414cSEd Maste extern "C" {
1710ff414cSEd Maste #endif
1810ff414cSEd Maste 
1910ff414cSEd Maste /** High-level decoding context */
2010ff414cSEd Maste struct _cbor_decoder_context {
2110ff414cSEd Maste   /** Callback creating the last item has failed */
2210ff414cSEd Maste   bool creation_failed;
2310ff414cSEd Maste   /** Stack expectation mismatch */
2410ff414cSEd Maste   bool syntax_error;
2510ff414cSEd Maste   cbor_item_t *root;
2610ff414cSEd Maste   struct _cbor_stack *stack;
2710ff414cSEd Maste };
2810ff414cSEd Maste 
29*5d3e7166SEd Maste /** Internal helper: Append item to the top of the stack while handling errors.
30*5d3e7166SEd Maste  */
31*5d3e7166SEd Maste void _cbor_builder_append(cbor_item_t *item, struct _cbor_decoder_context *ctx);
32*5d3e7166SEd Maste 
3310ff414cSEd Maste void cbor_builder_uint8_callback(void *, uint8_t);
3410ff414cSEd Maste 
3510ff414cSEd Maste void cbor_builder_uint16_callback(void *, uint16_t);
3610ff414cSEd Maste 
3710ff414cSEd Maste void cbor_builder_uint32_callback(void *, uint32_t);
3810ff414cSEd Maste 
3910ff414cSEd Maste void cbor_builder_uint64_callback(void *, uint64_t);
4010ff414cSEd Maste 
4110ff414cSEd Maste void cbor_builder_negint8_callback(void *, uint8_t);
4210ff414cSEd Maste 
4310ff414cSEd Maste void cbor_builder_negint16_callback(void *, uint16_t);
4410ff414cSEd Maste 
4510ff414cSEd Maste void cbor_builder_negint32_callback(void *, uint32_t);
4610ff414cSEd Maste 
4710ff414cSEd Maste void cbor_builder_negint64_callback(void *, uint64_t);
4810ff414cSEd Maste 
49*5d3e7166SEd Maste void cbor_builder_string_callback(void *, cbor_data, uint64_t);
5010ff414cSEd Maste 
5110ff414cSEd Maste void cbor_builder_string_start_callback(void *);
5210ff414cSEd Maste 
53*5d3e7166SEd Maste void cbor_builder_byte_string_callback(void *, cbor_data, uint64_t);
5410ff414cSEd Maste 
5510ff414cSEd Maste void cbor_builder_byte_string_start_callback(void *);
5610ff414cSEd Maste 
57*5d3e7166SEd Maste void cbor_builder_array_start_callback(void *, uint64_t);
5810ff414cSEd Maste 
5910ff414cSEd Maste void cbor_builder_indef_array_start_callback(void *);
6010ff414cSEd Maste 
61*5d3e7166SEd Maste void cbor_builder_map_start_callback(void *, uint64_t);
6210ff414cSEd Maste 
6310ff414cSEd Maste void cbor_builder_indef_map_start_callback(void *);
6410ff414cSEd Maste 
6510ff414cSEd Maste void cbor_builder_tag_callback(void *, uint64_t);
6610ff414cSEd Maste 
6710ff414cSEd Maste void cbor_builder_float2_callback(void *, float);
6810ff414cSEd Maste 
6910ff414cSEd Maste void cbor_builder_float4_callback(void *, float);
7010ff414cSEd Maste 
7110ff414cSEd Maste void cbor_builder_float8_callback(void *, double);
7210ff414cSEd Maste 
7310ff414cSEd Maste void cbor_builder_null_callback(void *);
7410ff414cSEd Maste 
7510ff414cSEd Maste void cbor_builder_undefined_callback(void *);
7610ff414cSEd Maste 
7710ff414cSEd Maste void cbor_builder_boolean_callback(void *, bool);
7810ff414cSEd Maste 
7910ff414cSEd Maste void cbor_builder_indef_break_callback(void *);
8010ff414cSEd Maste 
8110ff414cSEd Maste #ifdef __cplusplus
8210ff414cSEd Maste }
8310ff414cSEd Maste #endif
8410ff414cSEd Maste 
8510ff414cSEd Maste #endif  // LIBCBOR_BUILDER_CALLBACKS_H
86