master
h 45 lines 1.58 KB
Raw
1 /*
2 * QEMU CBOR helpers
3 *
4 * Copyright (c) 2024 Dorjoy Chowdhury <dorjoychy111@gmail.com>
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or
7 * (at your option) any later version. See the COPYING file in the
8 * top-level directory.
9 */
10
11 #ifndef QEMU_VIRTIO_CBOR_HELPERS_H
12 #define QEMU_VIRTIO_CBOR_HELPERS_H
13
14 #include <cbor.h>
15
16 bool qemu_cbor_map_add(cbor_item_t *map, cbor_item_t *key, cbor_item_t *value);
17
18 bool qemu_cbor_array_push(cbor_item_t *array, cbor_item_t *value);
19
20 bool qemu_cbor_add_bool_to_map(cbor_item_t *map, const char *key, bool value);
21
22 bool qemu_cbor_add_uint8_to_map(cbor_item_t *map, const char *key,
23 uint8_t value);
24
25 bool qemu_cbor_add_map_to_map(cbor_item_t *map, const char *key,
26 size_t nested_map_size,
27 cbor_item_t **nested_map);
28
29 bool qemu_cbor_add_bytestring_to_map(cbor_item_t *map, const char *key,
30 uint8_t *arr, size_t len);
31
32 bool qemu_cbor_add_null_to_map(cbor_item_t *map, const char *key);
33
34 bool qemu_cbor_add_string_to_map(cbor_item_t *map, const char *key,
35 const char *value);
36
37 bool qemu_cbor_add_uint8_array_to_map(cbor_item_t *map, const char *key,
38 uint8_t *arr, size_t len);
39
40 bool qemu_cbor_add_uint8_key_bytestring_to_map(cbor_item_t *map, uint8_t key,
41 uint8_t *buf, size_t len);
42
43 bool qemu_cbor_add_uint64_to_map(cbor_item_t *map, const char *key,
44 uint64_t value);
45 #endif