xref: /freebsd/contrib/libcbor/src/cbor/streaming.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_STREAMING_H
910ff414cSEd Maste #define LIBCBOR_STREAMING_H
1010ff414cSEd Maste 
1110ff414cSEd Maste #include "callbacks.h"
1210ff414cSEd Maste #include "cbor/cbor_export.h"
1310ff414cSEd Maste #include "cbor/common.h"
1410ff414cSEd Maste 
1510ff414cSEd Maste #ifdef __cplusplus
1610ff414cSEd Maste extern "C" {
1710ff414cSEd Maste #endif
1810ff414cSEd Maste 
1910ff414cSEd Maste /** Stateless decoder
2010ff414cSEd Maste  *
21*5d3e7166SEd Maste  * Will try parsing the \p source and will invoke the appropriate callback on
2210ff414cSEd Maste  * success. Decodes one item at a time. No memory allocations occur.
2310ff414cSEd Maste  *
24*5d3e7166SEd Maste  * @param source Input buffer
25*5d3e7166SEd Maste  * @param source_size Length of the buffer
2610ff414cSEd Maste  * @param callbacks The callback bundle
2710ff414cSEd Maste  * @param context An arbitrary pointer to allow for maintaining context.
2810ff414cSEd Maste  */
29*5d3e7166SEd Maste _CBOR_NODISCARD CBOR_EXPORT struct cbor_decoder_result cbor_stream_decode(
30*5d3e7166SEd Maste     cbor_data source, size_t source_size,
3110ff414cSEd Maste     const struct cbor_callbacks* callbacks, void* context);
3210ff414cSEd Maste 
3310ff414cSEd Maste #ifdef __cplusplus
3410ff414cSEd Maste }
3510ff414cSEd Maste #endif
3610ff414cSEd Maste 
3710ff414cSEd Maste #endif  // LIBCBOR_STREAMING_H
38