xref: /netbsd/external/mit/libcbor/dist/src/cbor.h (revision 4ab93bc7)
1*4ab93bc7Schristos /*
2*4ab93bc7Schristos  * Copyright (c) 2014-2019 Pavel Kalvoda <me@pavelkalvoda.com>
3*4ab93bc7Schristos  *
4*4ab93bc7Schristos  * libcbor is free software; you can redistribute it and/or modify
5*4ab93bc7Schristos  * it under the terms of the MIT license. See LICENSE for details.
6*4ab93bc7Schristos  */
7*4ab93bc7Schristos 
8*4ab93bc7Schristos #ifndef LIBCBOR_H_
9*4ab93bc7Schristos #define LIBCBOR_H_
10*4ab93bc7Schristos 
11*4ab93bc7Schristos #include "cbor/common.h"
12*4ab93bc7Schristos #include "cbor/data.h"
13*4ab93bc7Schristos 
14*4ab93bc7Schristos #include "cbor/arrays.h"
15*4ab93bc7Schristos #include "cbor/bytestrings.h"
16*4ab93bc7Schristos #include "cbor/floats_ctrls.h"
17*4ab93bc7Schristos #include "cbor/ints.h"
18*4ab93bc7Schristos #include "cbor/maps.h"
19*4ab93bc7Schristos #include "cbor/strings.h"
20*4ab93bc7Schristos #include "cbor/tags.h"
21*4ab93bc7Schristos 
22*4ab93bc7Schristos #include "cbor/callbacks.h"
23*4ab93bc7Schristos #include "cbor/encoding.h"
24*4ab93bc7Schristos #include "cbor/serialization.h"
25*4ab93bc7Schristos #include "cbor/streaming.h"
26*4ab93bc7Schristos 
27*4ab93bc7Schristos #ifdef __cplusplus
28*4ab93bc7Schristos extern "C" {
29*4ab93bc7Schristos #endif
30*4ab93bc7Schristos 
31*4ab93bc7Schristos /*
32*4ab93bc7Schristos  * ============================================================================
33*4ab93bc7Schristos  * High level decoding
34*4ab93bc7Schristos  * ============================================================================
35*4ab93bc7Schristos  */
36*4ab93bc7Schristos 
37*4ab93bc7Schristos /** Loads data item from a buffer
38*4ab93bc7Schristos  *
39*4ab93bc7Schristos  * @param source The buffer
40*4ab93bc7Schristos  * @param source_size
41*4ab93bc7Schristos  * @param result[out] Result indicator. #CBOR_ERR_NONE on success
42*4ab93bc7Schristos  * @return **new** CBOR item or `NULL` on failure. In that case, \p result
43*4ab93bc7Schristos  * contains location and description of the error.
44*4ab93bc7Schristos  */
45*4ab93bc7Schristos cbor_item_t* cbor_load(cbor_data source, size_t source_size,
46*4ab93bc7Schristos                        struct cbor_load_result* result);
47*4ab93bc7Schristos 
48*4ab93bc7Schristos /** Deep copy of an item
49*4ab93bc7Schristos  *
50*4ab93bc7Schristos  * All the reference counts in the new structure are set to one.
51*4ab93bc7Schristos  *
52*4ab93bc7Schristos  * @param item[borrow] item to copy
53*4ab93bc7Schristos  * @return **new** CBOR deep copy
54*4ab93bc7Schristos  */
55*4ab93bc7Schristos cbor_item_t* cbor_copy(cbor_item_t* item);
56*4ab93bc7Schristos 
57*4ab93bc7Schristos #if CBOR_PRETTY_PRINTER
58*4ab93bc7Schristos #include <stdio.h>
59*4ab93bc7Schristos 
60*4ab93bc7Schristos void cbor_describe(cbor_item_t* item, FILE* out);
61*4ab93bc7Schristos #endif
62*4ab93bc7Schristos 
63*4ab93bc7Schristos #ifdef __cplusplus
64*4ab93bc7Schristos }
65*4ab93bc7Schristos #endif
66*4ab93bc7Schristos 
67*4ab93bc7Schristos #endif  // LIBCBOR_H_
68