blob: 506c6689b5654a6fd962c8fc3801f5d30a6a8a76 [file] [log] [blame]
Laurence Lundblade33ed26f2024-11-24 10:26:43 -08001/*==============================================================================
2 Copyright (c) 2016-2018, The Linux Foundation.
3 Copyright (c) 2018-2024, Laurence Lundblade.
4 Copyright (c) 2021, Arm Limited.
5 All rights reserved.
6
7 Created on 11/14/24 from qcbor_decode.c
8
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are
12met:
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above
16 copyright notice, this list of conditions and the following
17 disclaimer in the documentation and/or other materials provided
18 with the distribution.
19 * Neither the name of The Linux Foundation nor the names of its
20 contributors, nor the name "Laurence Lundblade" may be used to
21 endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
25WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
27ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
28BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
34IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 =============================================================================*/
36
37#ifndef decode_private_h
38#define decode_private_h
39
40
41QCBORError
42QCBORDecode_Private_GetNextTagContent(QCBORDecodeContext *pMe,
43 QCBORItem *pDecodedItem);
44
45void
46QCBORDecode_Private_ProcessTagItemMulti(QCBORDecodeContext *pMe,
47 QCBORItem *pItem,
48 const uint8_t uTagRequirement,
49 const uint8_t uQCBORTypes[],
50 const uint64_t uTagNumbers[],
51 QCBORTagContentCallBack *pfCB,
52 size_t uOffset);
53
54
55void
56QCBORDecode_Private_ProcessTagItem(QCBORDecodeContext *pMe,
57 QCBORItem *pItem,
58 const uint8_t uTagRequirement,
59 const uint8_t uQCBORTypes[],
60 const uint64_t uTagNumber,
61 QCBORTagContentCallBack *pfCB,
62 size_t uOffset);
63
64void
65QCBORDecode_Private_GetItemInMapNoCheckSZ(QCBORDecodeContext *pMe,
66 const char *szLabel,
67 const uint8_t uQcborType,
68 QCBORItem *pItem,
69 size_t *puOffset);
70
71void
72QCBORDecode_Private_GetItemInMapNoCheckN(QCBORDecodeContext *pMe,
73 const int64_t nLabel,
74 const uint8_t uQcborType,
75 QCBORItem *pItem,
76 size_t *puOffset);
77
78static inline void
79QCBORDecode_Private_GetAndTell(QCBORDecodeContext *pMe, QCBORItem *Item, size_t *uOffset)
80{
81#ifndef QCBOR_DISABLE_TAGS
82 if(pMe->uLastError != QCBOR_SUCCESS) {
83 return;
84 }
85
86 *uOffset = QCBORDecode_Tell(pMe);
87#else
88 *uOffset = SIZE_MAX;
89
90#endif /* ! QCBOR_DISABLE_TAGS */
91 pMe->uLastError = (uint8_t)QCBORDecode_Private_GetNextTagContent(pMe, Item);
92}
93
94
95#endif /* decode_private_h */