1 /*
2 * This file has been generated from the cddl-gen submodule.
3 * Commit 9f77837f9950da1633d22abf6181a830521a6688
4 */
5
6 /*
7 * Copyright (c) 2021 Nordic Semiconductor ASA
8 *
9 * SPDX-License-Identifier: Apache-2.0
10 */
11
12 /*
13 * Generated with cddl_gen.py (https://github.com/NordicSemiconductor/cddl-gen)
14 * at: 2021-08-02 17:09:42
15 * Generated with a default_max_qty of 3
16 */
17
18 #include <stdint.h>
19 #include <stdbool.h>
20 #include <stddef.h>
21 #include <string.h>
22 #include "cbor_decode.h"
23 #include "serial_recovery_cbor.h"
24
25 #if DEFAULT_MAX_QTY != 3
26 #error "The type file was generated with a different default_max_qty than this file"
27 #endif
28
29
decode_Member(cbor_state_t * state,struct Member_ * result)30 static bool decode_Member(
31 cbor_state_t *state, struct Member_ *result)
32 {
33 cbor_print("%s\n", __func__);
34 cbor_string_type_t tmp_str;
35 bool int_res;
36
37 bool tmp_result = (((union_start_code(state) && (int_res = (((((tstrx_expect(state, ((tmp_str.value = (const uint8_t *)"image",
38 tmp_str.len = sizeof("image") - 1, &tmp_str)))))
39 && (intx32_decode(state, (&(*result)._Member_image)))) && (((*result)._Member_choice = _Member_image) || 1))
40 || (union_elem_code(state) && ((((tstrx_expect(state, ((tmp_str.value = (const uint8_t *)"data",
41 tmp_str.len = sizeof("data") - 1, &tmp_str)))))
42 && (bstrx_decode(state, (&(*result)._Member_data)))) && (((*result)._Member_choice = _Member_data) || 1)))
43 || (union_elem_code(state) && ((((tstrx_expect(state, ((tmp_str.value = (const uint8_t *)"len",
44 tmp_str.len = sizeof("len") - 1, &tmp_str)))))
45 && (intx32_decode(state, (&(*result)._Member_len)))) && (((*result)._Member_choice = _Member_len) || 1)))
46 || (union_elem_code(state) && ((((tstrx_expect(state, ((tmp_str.value = (const uint8_t *)"off",
47 tmp_str.len = sizeof("off") - 1, &tmp_str)))))
48 && (intx32_decode(state, (&(*result)._Member_off)))) && (((*result)._Member_choice = _Member_off) || 1)))
49 || (union_elem_code(state) && ((((tstrx_expect(state, ((tmp_str.value = (const uint8_t *)"sha",
50 tmp_str.len = sizeof("sha") - 1, &tmp_str)))))
51 && (bstrx_decode(state, (&(*result)._Member_sha)))) && (((*result)._Member_choice = _Member_sha) || 1)))), union_end_code(state), int_res))));
52
53 if (!tmp_result)
54 cbor_trace();
55
56 return tmp_result;
57 }
58
decode_Upload(cbor_state_t * state,struct Upload * result)59 static bool decode_Upload(
60 cbor_state_t *state, struct Upload *result)
61 {
62 cbor_print("%s\n", __func__);
63 bool int_res;
64
65 bool tmp_result = (((map_start_decode(state) && (int_res = (multi_decode(1, 5, &(*result)._Upload_members_count, (void *)decode_Member, state, (&(*result)._Upload_members), sizeof(struct Member_))), ((map_end_decode(state)) && int_res)))));
66
67 if (!tmp_result)
68 cbor_trace();
69
70 return tmp_result;
71 }
72
73
74
type_test_decode_Upload(struct Upload * result)75 __attribute__((unused)) static bool type_test_decode_Upload(
76 struct Upload *result)
77 {
78 /* This function should not be called, it is present only to test that
79 * the types of the function and struct match, since this information
80 * is lost with the casts in the entry function.
81 */
82 return decode_Upload(NULL, result);
83 }
84
85
cbor_decode_Upload(const uint8_t * payload,uint32_t payload_len,struct Upload * result,uint32_t * payload_len_out)86 bool cbor_decode_Upload(
87 const uint8_t *payload, uint32_t payload_len,
88 struct Upload *result,
89 uint32_t *payload_len_out)
90 {
91 return entry_function(payload, payload_len, (const void *)result,
92 payload_len_out, (void *)decode_Upload,
93 1, 2);
94 }
95