Laurence Lundblade | 33ed26f | 2024-11-24 10:26:43 -0800 | [diff] [blame] | 1 | /*============================================================================== |
| 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 | |
| 10 | Redistribution and use in source and binary forms, with or without |
| 11 | modification, are permitted provided that the following conditions are |
| 12 | met: |
| 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 | |
| 24 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 25 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 27 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 28 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 29 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 30 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 31 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 32 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 33 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 34 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 35 | =============================================================================*/ |
| 36 | |
| 37 | #ifndef decode_private_h |
| 38 | #define decode_private_h |
| 39 | |
| 40 | |
| 41 | QCBORError |
| 42 | QCBORDecode_Private_GetNextTagContent(QCBORDecodeContext *pMe, |
| 43 | QCBORItem *pDecodedItem); |
| 44 | |
| 45 | void |
| 46 | QCBORDecode_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 | |
| 55 | void |
| 56 | QCBORDecode_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 | |
| 64 | void |
| 65 | QCBORDecode_Private_GetItemInMapNoCheckSZ(QCBORDecodeContext *pMe, |
| 66 | const char *szLabel, |
| 67 | const uint8_t uQcborType, |
| 68 | QCBORItem *pItem, |
| 69 | size_t *puOffset); |
| 70 | |
| 71 | void |
| 72 | QCBORDecode_Private_GetItemInMapNoCheckN(QCBORDecodeContext *pMe, |
| 73 | const int64_t nLabel, |
| 74 | const uint8_t uQcborType, |
| 75 | QCBORItem *pItem, |
| 76 | size_t *puOffset); |
| 77 | |
| 78 | static inline void |
| 79 | QCBORDecode_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 */ |