xref: /freebsd/contrib/libcbor/src/cbor/streaming.h (revision aa1a8ff2d6dbc51ef058f46f3db5a8bb77967145)
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_STREAMING_H
9 #define LIBCBOR_STREAMING_H
10 
11 #include "callbacks.h"
12 #include "cbor/cbor_export.h"
13 #include "cbor/common.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /** Stateless decoder
20  *
21  * Will try parsing the \p source and will invoke the appropriate callback on
22  * success. Decodes one item at a time. No memory allocations occur.
23  *
24  * @param source Input buffer
25  * @param source_size Length of the buffer
26  * @param callbacks The callback bundle
27  * @param context An arbitrary pointer to allow for maintaining context.
28  */
29 _CBOR_NODISCARD CBOR_EXPORT struct cbor_decoder_result cbor_stream_decode(
30     cbor_data source, size_t source_size,
31     const struct cbor_callbacks* callbacks, void* context);
32 
33 #ifdef __cplusplus
34 }
35 #endif
36 
37 #endif  // LIBCBOR_STREAMING_H
38