1 /* 2 * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef CBOR_DUMP_H 8 #define CBOR_DUMP_H 9 10 #include <stddef.h> 11 #include <stdint.h> 12 #include <stdio.h> 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 /** 19 * Dictionary entry for mapping a CBOR ID to a string. 20 */ 21 struct cbor_dictionary_entry 22 { 23 int32_t id; 24 const char *string; 25 }; 26 27 /** 28 * Dump decoded cbor to the specified file. 29 * 30 * \param[in] file Dump to this file 31 * \param[in] cbor Serialized cbor to decode 32 * \param[in] cbor_len Length of the cbor 33 * \param[in] indent Initial indentation of dump output 34 * \param[in] root_label Root label or NULL if none. 35 * \param[in] dictionary Dictionary of IDs to strings. NULL if none. 36 * \param[in] dictionary_len Number of entries in the dictionary. 37 */ 38 int cbor_dump(FILE *file, 39 const uint8_t *cbor, size_t cbor_len, 40 unsigned int indent, const char *root_label, 41 const struct cbor_dictionary_entry *dictionary, unsigned int dictionary_len); 42 43 44 #ifdef __cplusplus 45 } /* extern "C" */ 46 #endif 47 48 #endif /* CBOR_DUMP_H */ 49